registryobjectutils.java
来自「world wind java sdk 源码」· Java 代码 · 共 441 行 · 第 1/2 页
JAVA
441 行
throw new IllegalArgumentException(message);
}
if (dest == null)
{
String message = "nullValue.DestIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
PersonName personName = src.getPersonName();
if (personName != null)
dest.setValue(CatalogKey.CONTACT_NAME, personName);
Iterator<Address> addressIter = src.getAddressIterator();
if (addressIter != null)
dest.setValue(CatalogKey.CONTACT_ADDRESS, asArray(addressIter, new Address[0]));
Iterator<EmailAddress> emailIter = src.getEmailAddressIterator();
if (emailIter != null)
dest.setValue(CatalogKey.CONTACT_EMAIL_ADDRESSS, asArray(emailIter, new EmailAddress[0]));
Iterator<TelephoneNumber> telephoneNumberIterator = src.getTelephoneNumberIterator();
if (telephoneNumberIterator != null)
dest.setValue(CatalogKey.CONTACT_TELEPHONE_NUMBER, asArray(telephoneNumberIterator, new TelephoneNumber[0]));
for (Iterator<Slot> iter = src.getSlotIterator(); iter.hasNext(); )
{
Slot slot = iter.next();
if (slot != null)
{
String name = slot.getName();
if ("AddressType".equalsIgnoreCase(name))
{
String[] sv = getValues(slot);
if (sv != null)
dest.setValue(CatalogKey.CONTACT_ADDRESS_TYPE, sv);
}
}
}
}
public static String[] getStrings(InternationalString is)
{
if (is == null)
{
String message = "nullValue.InternationalStringIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
ArrayList<String> values = new ArrayList<String>();
for (LocalizedString ls : is)
{
String s = ls != null ? ls.getValue() : null;
values.add(s);
}
String[] array = new String[values.size()];
values.toArray(array);
return array;
}
public static String getFirstString(InternationalString is)
{
if (is == null)
{
String message = "nullValue.InternationalStringIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
for (LocalizedString ls : is)
{
if (ls != null)
{
String s = ls.getValue();
if (s != null)
return s;
}
}
return null;
}
public static String getStringForLocale(InternationalString is, Locale locale)
{
if (is == null)
{
String message = "nullValue.InternationalStringIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
String s = null;
LocalizedString first = null;
LocalizedString match = null;
for (LocalizedString ls : is)
{
if (ls != null)
{
if (first == null)
first = ls;
String lang = ls.getLang();
if (lang != null && locale != null)
{
lang = lang.replaceAll("[ _-]", ".");
if (lang.matches(locale.toString()))
{
match = ls;
break;
}
}
}
}
if (match != null)
s = match.getValue();
else if (first != null)
s = first.getValue();
return s;
}
public static String[] getValues(Slot slot)
{
if (slot == null)
{
String message = "nullValue.SlotIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
ArrayList<String> values = null;
ValueList vl = slot.getValueList();
if (vl != null)
{
values = new ArrayList<String>();
for (Value v : vl)
{
String s = v != null ? v.getValue() : null;
values.add(s);
}
}
String[] array = null;
if (values != null)
{
array = new String[values.size()];
values.toArray(array);
}
return array;
}
public static String getFirstValue(Slot slot)
{
if (slot == null)
{
String message = "nullValue.SlotIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
ValueList vl = slot.getValueList();
if (vl != null)
{
for (Value v : vl)
{
if (v != null)
{
String s = v.getValue();
if (s != null)
return s;
}
}
}
return null;
}
private static <T> T[] asArray(Iterator<T> iter, T[] a)
{
if (iter == null)
{
String message = Logging.getMessage("nullValue.Iterator");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
T obj = null;
List<T> list = null;
while (iter.hasNext())
{
obj = iter.next();
if (obj != null)
{
if (list == null)
list = new ArrayList<T>();
list.add(obj);
}
}
T[] array = null;
if (list != null && obj != null)
array = list.toArray(a);
return array;
}
private static Object asDate(String s)
{
if (s == null)
{
String message = Logging.getMessage("nullValue.StringIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
Date date = ParserUtils.parseWMSDate(s);
return date != null ? date : s;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?