⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicmetadataexporter.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.esri.solutions.jitk.common.metadata;

import com.esri.solutions.jitk.datasources.ogc.csw.CswRecord;
import com.esri.solutions.jitk.datasources.ogc.csw.Envelope;


/**
 * {@link IMetadataExporter} implementation that extracts fields from a
 * {@link CswRecord}.
 * <p>
 * A {@link CswRecord} represents an XML document encoded with fields defined by
 * the <a href="http://dublincore.org/">Dublin Core Metadata Initiative</a>. A
 * Dublin Core document is returned from a Catalog Service for the Web (CS/W) in
 * response to a search operation. The fields included in this class represent
 * the basic fields that all CS/W implementations must provide when generating a
 * response.
 * </p>
 * <p>
 * </p>
 */
public class BasicMetadataExporter implements IMetadataExporter {
    /**
     * Reference to the {@link CswRecord} that contains the actual CS/W
     * metadata document.
     */
    private CswRecord _cswRecord = null;

    /**
     * {@link String} ID of the exporter.
     */
    private String _exporterID = null;

    /**
     * Abstract data field of the {@link CswRecord}.
     * {@link CswRecord#getAbstractData()}.
     */
    private String _abstractData;

    /**
     * Brief field of the {@link CswRecord}.  {@link CswRecord#getBriefMetadata()}.
     */
    private String _briefMetadata;

    /**
     * Full metadata field of the {@link CswRecord}.
     * {@link CswRecord#getFullMetadata()}.
     */
    private String _fullMetadata;

    /**
     * ID of the {@link CswRecord}.  {@link CswRecord#getId()}.
     */
    private String _recordID;

    /**
     * Value indicating if the {@link CswRecord} is marked as live data and/or
     * maps.  {@link CswRecord#isLiveDataOrMap()}.
     */
    private boolean _isLiveDataOrMap;

    /**
     * Metadata resource Url field of the {@link CswRecord#getMetadataResourceURL()}.
     */
    private String _metadataResourceURL;

    /**
     * Summary field of the {@link CswRecord}.
     * {@link CswRecord#getSummaryMetadata()}.
     */
    private String _summaryMetadata;

    /**
     * Title of the {@link CswRecord}.  {@link CswRecord#getTitle()}.
     */
    private String _title;

    /**
     * Date modified of the {@link CswRecord}.  {@link CswRecord#getDateModified()}.
     */
    private String _dateModified = null;

    /**
     * Value indicating if the {@link CswRecord} has geographic location data.
     */
    private boolean _hasGeometryData = Boolean.FALSE;

    /**
     * Minimum longitude of the {@link CswRecord}.
     */
    double _minx;

    /**
     * Minimum latitude of the {@link CswRecord}.
     */
    double _miny;

    /**
     * Maximum longitude of the {@link CswRecord}.
     */
    double _maxx;

    /**
     * Maximum latitude of the {@link CswRecord}.
     */
    double _maxy;

    /**
     * Provenance field of the {@link CswRecord}.
     */
    private String _provenance = null;

    /**
     * Content type of the actual metadata item of the {@link CswRecord}.
     */
    private String _metadataContentType = null;

    /**
     * {@link MetadataExporterState} state of the exporter.
     */
    private MetadataExporterState _state = MetadataExporterState.NEEDS_RESET;

    /**
     * {@inheritDoc}
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataExporter#begin()
     * @throws IllegalStateException
     *             if the exporter is not ready to begin exporting.
     */
    public void begin() {
        if (_state != MetadataExporterState.NEEDS_RESET) {
            throw new IllegalStateException(
                "Exporter is not ready to begin exporting.");
        }

        _abstractData = null;
        _briefMetadata = null;
        _fullMetadata = null;
        _isLiveDataOrMap = false;
        _metadataResourceURL = null;
        _recordID = null;
        _summaryMetadata = null;
        _title = null;
        _metadataContentType = null;
        _state = MetadataExporterState.READY_TO_EXPORT;
    }

    /**
     * {@inheritDoc}
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataExporter#end()
     * @throws IllegalStateException
     *             if the exporter is not yet finished exporting.
     */
    public void end() {
        if (_state != MetadataExporterState.EXPORT_FINISHED) {
            throw new IllegalStateException(
                "Exporter is not finished exporting; end() cannot be called.");
        }

        // Intentionally does nothing else. There is no cleanup required.
    }

    /*
     * (non-Javadoc)
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataExporter#export()
     */
    public void export() {
        Envelope recordEnv = null;

        if (_state != MetadataExporterState.READY_TO_EXPORT) {
            throw new IllegalStateException(
                "Exporter is not yet ready to export.");
        }

        _state = MetadataExporterState.EXPORTING;
        _abstractData = _cswRecord.getAbstractData();
        _briefMetadata = _cswRecord.getBriefMetadata();
        _fullMetadata = _cswRecord.getFullMetadata();
        _isLiveDataOrMap = _cswRecord.isLiveDataOrMap();
        _metadataResourceURL = _cswRecord.getMetadataResourceURL();
        _recordID = _cswRecord.getId();
        _summaryMetadata = _cswRecord.getSummaryMetadata();
        _title = _cswRecord.getTitle();
        _dateModified = _cswRecord.getDateModified();
        _metadataContentType = _cswRecord.getMetadataContentType();
        _provenance = _cswRecord.getProvenance();

        recordEnv = _cswRecord.getEnvelope();

        if (recordEnv != null) {
            _hasGeometryData = Boolean.TRUE;

            _minx = recordEnv.getMinX();
            _miny = recordEnv.getMinY();
            _maxx = recordEnv.getMaxX();
            _maxy = recordEnv.getMaxY();
        }

        _state = MetadataExporterState.EXPORT_FINISHED;
    }

    /*
     * (non-Javadoc)
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataExporter#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;
    }

    /**
     * {@inheritDoc}
     *
     * This implementation requires that {@code raw} be of type
     * {@link CswRecord}.
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataExporter#setRaw(java.lang.Object)
     * @throws IllegalArgumentException
     *             if {@code raw} is not a {@link CswRecord}
     */
    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");
        }

        _cswRecord = (CswRecord) raw;
        _state = MetadataExporterState.NEEDS_RESET;
    }

    /**
     * Retrieves the Abstract Data from the CS/W response.
     *
     * @return {@link String} containing the Abstract Data
     * @throws IllegalStateException
     *             if the exporter is not finished working.
     * @see #preventAccessIfExportHasNotCompleted()
     */
    public String getAbstractData() {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -