📄 mapservicemetadataexporter.java
字号:
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.AbstractMapServiceMetadataExporter#getExporterId()
*/
public String getExporterId() {
return _exporterID;
}
/**
* Sets the ID used to identify this exporter.
*
* @param id {@link String} containing the ID; cannot be {@code null}.
*/
public void setExporterId(String id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
_exporterID = id;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.AbstractMapServiceMetadataExporter#setRaw(java.lang.Object)
*/
public void setRaw(Object raw) {
if (raw == null) {
throw new NullPointerException("raw cannot be null");
}
if (!(raw instanceof CswRecord)) {
throw new IllegalArgumentException(
"raw must be an instance of a com.esri.solutions.jitk.datasources.ogc.csw.CswRecord");
}
_record = (CswRecord) raw;
_state = MetadataExporterState.NEEDS_RESET;
}
/**
* Checks the state of the exporter to ensure that the
* {@link #setRaw(Object)()} has been invoked, thus requiring this object to
* be reset in preparation for a new export to occur.
*
* @return {@code boolean} {@code true} if the internal state of the
* exporter is {@link MetadataExporterState#NEEDS_RESET};
* {@code false} otherwise.
*/
public boolean isInNeedOfReset() {
return _state == MetadataExporterState.NEEDS_RESET;
}
/**
* Checks the state of the exporter to ensure that the {@link #begin()} has
* finished its operation and the exporter is in the proper state for
* {@link #export()} to be invoked.
*
* @return {@code boolean} {@code true} if the internal state of the
* exporter is {@link MetadataExporterState#READY_TO_EXPORT};
* {@code false} otherwise.
*/
public boolean isReadyToExport() {
return _state == MetadataExporterState.READY_TO_EXPORT;
}
/**
* Checks the state of the exporter to ensure that the {@link #export()} has
* finished its operation.
*
* @return {@code boolean} {@code true} if the internal state of the
* exporter is {@link MetadataExporterState#EXPORT_FINISHED};
* {@code false} otherwise.
*/
public boolean isFinishedExporting() {
return _state == MetadataExporterState.EXPORT_FINISHED;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.AbstractMapServiceMetadataExporter#getServiceUrl()
*/
public String getServiceUrl() {
preventAccessIfExportHasNotCompleted();
return _serviceUrl;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.AbstractMapServiceMetadataExporter#getServiceName()
*/
public String getServiceName() {
preventAccessIfExportHasNotCompleted();
return _serviceName;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.AbstractMapServiceMetadataExporter#getServiceType()
*/
public ServiceType getServiceType() {
preventAccessIfExportHasNotCompleted();
return _serviceType;
}
/**
* Sets the service type mappings for this exporter.
*
* @param mappings {@link Map} of service type mappings. The key should be the expected
* value in the metadata document. The value will be a mapping to a specific ADF service
* type.
*
* <p>
* Example mappings: <br>
*
* <table>
* <tr>
* <td>Key:</td>
* <td>Value:</td>
* </tr>
* <tr>
* <td>image</td>
* <td>ArcIMS</td>
* </tr>
* <tr>
* <td>wms</td>
* <td>WMS</td>
* </tr>
* <tr>
* <td>arcgis</td>
* <td>AGSWeb</td>
* </tr>
* </table>
* </p>
*/
public void setServiceTypeMappings(Map<String, String> mappings) {
if (mappings == null) {
throw new NullPointerException(
"service type mappings cannot be null");
}
_serviceTypeMappings = mappings;
}
/**
* Sets the XPath mappings to retrieve service information from
* the metadata document.
*
* @param mappings {@link Map} containing the XPaths to service information. Cannot be {@code null}.
*
* <p>
* Example mappings: <br>
*
* <table>
* <tr>
* <td>Key:</td>
* <td>Value:</td>
* </tr>
* <tr>
* <td>serviceUrl</td>
* <td>//metadata/Esri/Server/text()</td>
* </tr>
* <tr>
* <td>serviceName</td>
* <td>//metadata/Esri/Service/text()</td>
* </tr>
* <tr>
* <td>serviceType</td>
* <td>//metadata/Esri/ServiceType/text()</td>
* </tr>
* </table>
* </p>
*/
public void setXpathMappings(Map<String, String> mappings) {
if (mappings == null) {
throw new NullPointerException("xpath mappings cannot be null");
}
_xpathMappings = mappings;
}
/**
* Utility method that will throw an {@link IllegalStateException} if this
* exporter is not finished working.
*
* @throws IllegalStateException
* if {@link #isFinishedExporting()} returns {@code false}.
* @see #isFinishedExporting()
*/
private void preventAccessIfExportHasNotCompleted() {
if (!isFinishedExporting()) {
throw new IllegalStateException(
"Data cannot be retrieved; exporter has not completed the export operation");
}
}
/**
* Retrieves the {@link ServiceType} mapping for the give {@code type}.
*
* @param type {@link String} service type extracted from the metadata document.
* @return {@link ServiceType} mapping.
*/
private ServiceType getServiceTypeMapping(String type) {
ServiceType serviceType = null;
String typeMapping = null;
if (type == null) {
throw new NullPointerException("type cannot be null");
}
if (_serviceTypeMappings.containsKey(type)) {
typeMapping = _serviceTypeMappings.get(type);
for (ServiceType st : ServiceType.values()) {
if (typeMapping.equalsIgnoreCase(st.getServiceType())) {
serviceType = st;
break;
}
}
} else {
_logger.warn("Unable to find service type mapping for: [" + type +
"]");
}
if (serviceType == null) {
_logger.warn("Unable to find service type mapping for: [" + type +
"]");
}
return serviceType;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -