📄 gisresourcemetadataregistry.java
字号:
/**
*
*/
package com.esri.solutions.jitk.common.metadata;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.esri.adf.web.data.GISResource;
/**
* Implementation of {@link IResourceMetadataRegistry} that maps
* {@link GISResource GISResources} to the {@link IMetadataID IMetadataIDs}
* representing its metadata.
*/
public class GISResourceMetadataRegistry implements IResourceMetadataRegistry {
/**
* Maps IMetadataIDs to the GISResource that they represent
*/
private Map<IMetadataID, GISResource> _registry = new HashMap<IMetadataID, GISResource>();
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#getGISResource(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public GISResource getGISResource(IMetadataID id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
return _registry.get(id);
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#getMetadataID(com.esri.adf.web.data.GISResource)
*/
public IMetadataID getMetadataID(GISResource resource) {
if (resource == null) {
throw new NullPointerException("resource cannot be null");
}
IMetadataID theID = null;
boolean notFound = true;
Iterator<IMetadataID> keyIterator = _registry.keySet().iterator();
while (notFound && keyIterator.hasNext()) {
IMetadataID currentID = keyIterator.next();
GISResource currentResource = _registry.get(currentID);
if (currentResource != null) {
if (currentResource.equals(resource)) {
theID = currentID;
notFound = false;
}
}
}
return theID;
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#metadataExists(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public boolean metadataExists(IMetadataID id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
return _registry.containsKey(id);
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#metadataExists(com.esri.adf.web.data.GISResource)
*/
public boolean metadataExists(GISResource resource) {
if (resource == null) {
throw new NullPointerException("resource cannot be null");
}
return _registry.containsValue(resource);
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#register(com.esri.solutions.jitk.common.metadata.IMetadataID,
* com.esri.adf.web.data.GISResource)
*/
public void register(IMetadataID id, GISResource resource) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
if (resource == null) {
throw new NullPointerException("resource cannot be null");
}
// Remove the entry for the specified ID
unregister(id);
// Get the ID for the GIS Resource represented by "resource", just in
// case it differs from that specified by ID
unregister(resource);
// (Re)register the resource
_registry.put(id, resource);
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#unregister(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public void unregister(IMetadataID id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
// Remove the entry for the specified ID
_registry.remove(id);
}
/*
* (non-Javadoc)
*
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#unregister(com.esri.adf.web.data.GISResource)
*/
public void unregister(GISResource resource) {
if (resource == null) {
throw new NullPointerException("resource cannot be null");
}
// Get the ID for the GISResource represented by "resource"
IMetadataID resourceID = getMetadataID(resource);
// Remove the entry if one was found
if (resourceID != null) {
_registry.remove(resourceID);
}
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IResourceMetadataRegistry#setRegistry(java.util.Map)
*/
public void setRegistry(Map<IMetadataID, GISResource> registry) {
if (registry == null) {
throw new NullPointerException("registry cannot be null");
}
_registry.putAll(registry);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -