registryobjectutils.java
来自「world wind java sdk 源码」· Java 代码 · 共 441 行 · 第 1/2 页
JAVA
441 行
/*
Copyright (C) 2001, 2008 United States Government as represented by
the Administrator of the National Aeronautics and Space Administration.
All Rights Reserved.
*/
package gov.nasa.worldwind.applications.gio.esg;
import gov.nasa.worldwind.applications.gio.catalogui.CatalogKey;
import gov.nasa.worldwind.applications.gio.ebrim.*;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.util.Logging;
import java.util.*;
/**
* @author dcollins
* @version $Id: RegistryObjectUtils.java 5517 2008-07-15 23:36:34Z dcollins $
*/
public class RegistryObjectUtils
{
public static void makeCommonParams(RegistryObject src, AVList dest)
{
makeCommonParams(src, dest, true);
}
public static void makeCommonParamsNoOverwrite(RegistryObject src, AVList dest)
{
makeCommonParams(src, dest, false);
}
private static void makeCommonParams(RegistryObject src, AVList dest, boolean overwrite)
{
if (src == null)
{
String message = "nullValue.SrcIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (dest == null)
{
String message = "nullValue.DestIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
InternationalString is = src.getDescription();
if (is != null)
{
String s = getStringForLocale(is, Locale.getDefault());
if (s != null)
if (dest.getValue(CatalogKey.DESCRIPTION) == null || overwrite)
dest.setValue(CatalogKey.DESCRIPTION, s);
}
String s = src.getId();
if (s != null)
if (dest.getValue(CatalogKey.ID) == null || overwrite)
dest.setValue(CatalogKey.ID, s);
is = src.getName();
if (is != null)
{
s = getStringForLocale(is, Locale.getDefault());
if (s != null)
if (dest.getValue(CatalogKey.NAME) == null || overwrite)
dest.setValue(CatalogKey.NAME, s);
}
for (Iterator<Slot> iter = src.getSlotIterator(); iter.hasNext(); )
{
Slot slot = iter.next();
if (slot != null)
{
String name = slot.getName();
if ("Abstract".equalsIgnoreCase(name))
{
String[] sv = getValues(slot);
if (sv != null)
if (dest.getValue(CatalogKey.ABSTRACT) == null || overwrite)
dest.setValue(CatalogKey.ABSTRACT, sv);
}
else if ("Content Start Date".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.CONTENT_START_DATE) == null || overwrite)
dest.setValue(CatalogKey.CONTENT_START_DATE, asDate(s));
}
else if ("Content End Date".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.CONTENT_END_DATE) == null || overwrite)
dest.setValue(CatalogKey.CONTENT_END_DATE, asDate(s));
}
else if ("Harvest Date".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.HARVEST_DATE) == null || overwrite)
dest.setValue(CatalogKey.HARVEST_DATE, asDate(s));
}
else if ("Harvest Type".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.HARVEST_TYPE) == null || overwrite)
dest.setValue(CatalogKey.HARVEST_TYPE, s);
}
else if ("Keyword".equalsIgnoreCase(name) ||
"Keywords".equalsIgnoreCase(name) ||
"KeywordList".equalsIgnoreCase(name))
{
String[] sv = getValues(slot);
if (sv != null)
if (dest.getValue(CatalogKey.KEYWORDS) == null || overwrite)
dest.setValue(CatalogKey.KEYWORDS, sv);
}
else if ("Modification Date".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.MODIFICATION_DATE) == null || overwrite)
dest.setValue(CatalogKey.MODIFICATION_DATE, asDate(s));
}
else if ("Online Resource".equalsIgnoreCase(name))
{
String[] sv = getValues(slot);
if (sv != null)
if (dest.getValue(CatalogKey.ONLINE_RESOURCE) == null || overwrite)
dest.setValue(CatalogKey.ONLINE_RESOURCE, sv);
}
else if ("Originator".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.ORIGINATOR) == null || overwrite)
dest.setValue(CatalogKey.ORIGINATOR, s);
}
else if (name != null && (name.contains("title") || name.contains("Title")))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.TITLE) == null || overwrite)
dest.setValue(CatalogKey.TITLE, s);
}
else if ("Version".equalsIgnoreCase(name))
{
s = getFirstValue(slot);
if (s != null)
if (dest.getValue(CatalogKey.VERSION) == null || overwrite)
dest.setValue(CatalogKey.VERSION, s);
}
}
}
}
public static void makeClassificationParams(Iterator<ClassificationNode> src, AVList dest)
{
if (src == null)
{
String message = "nullValue.SrcIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (dest == null)
{
String message = "nullValue.DestIsNull";
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
String serviceType = null;
List<String> nationalAppList = null;
while (src.hasNext())
{
ClassificationNode cls = src.next();
if (cls != null)
{
String s = cls.getCode();
if (s != null)
{
if (s.contains("wms") || s.contains("WMS"))
serviceType = CatalogKey.WMS;
else if (s.contains("wfs") || s.contains("WFS"))
serviceType = CatalogKey.WFS;
else if (s.contains("wcs") || s.contains("WCS"))
serviceType = CatalogKey.WCS;
// "1000" is the code for the "NASA National Applications" ClassificationScheme.
else if (s.contains("1000"))
{
InternationalString is = cls.getName();
if (is != null)
{
s = RegistryObjectUtils.getStringForLocale(is, Locale.getDefault());
if (nationalAppList == null)
nationalAppList = new ArrayList<String>();
nationalAppList.add(s);
}
}
}
}
}
dest.setValue(CatalogKey.SERVICE_TYPE, serviceType);
String[] nationalAppArray = null;
if (nationalAppList != null)
{
nationalAppArray = new String[nationalAppList.size()];
nationalAppList.toArray(nationalAppArray);
}
dest.setValue(ESGKey.NATIONAL_APPLICATIONS, nationalAppArray);
}
public static void makePersonParams(Person src, AVList dest)
{
if (src == null)
{
String message = "nullValue.SrcIsNull";
Logging.logger().severe(message);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?