Class MetacardImpl

java.lang.Object
ddf.catalog.data.impl.MetacardImpl
All Implemented Interfaces:
ddf.catalog.data.Metacard, Serializable

public class MetacardImpl extends Object implements ddf.catalog.data.Metacard
Implements the Metacard's required attributes.

Serialization Note

This class is Serializable and care should be taken with compatibility if changes are made.

For backward and forward compatibility, ObjectOutputStream.defaultWriteObject() is invoked when this object is serialized because it provides "enhanced flexibility" (Joshua Block Effective Java, Second Edition Item 75). Invoking ObjectOutputStream.defaultWriteObject() allows the flexibility to add nontransient instance fields in later versions if necessary. If earlier versions do not have the newly added fields, those fields will be ignored and the deserialization will still take place. In addition, ObjectInputStream.defaultReadObject() is necessary to facilitate any of the written fields.

For what constitutes a compatible change in serialization, see Sun's Guidelines.

See Also:
  • Field Details

    • BASIC_METACARD

      public static final ddf.catalog.data.MetacardType BASIC_METACARD
      A Constant for a MetacardType with the required
      invalid reference
      AttributeType
      s.
  • Constructor Details

    • MetacardImpl

      public MetacardImpl()
      Creates a Metacard with a type of BASIC_METACARD and empty Attributes.
    • MetacardImpl

      public MetacardImpl(ddf.catalog.data.MetacardType type)
      Creates a Metacard with the provided MetacardType and empty Attribute s.
      Parameters:
      type - the MetacardType
    • MetacardImpl

      public MetacardImpl(ddf.catalog.data.Metacard metacard)
      Creates a Metacard with the provided Metacard.
      Parameters:
      metacard - the Metacard to create this new Metacard from
    • MetacardImpl

      public MetacardImpl(ddf.catalog.data.Metacard metacard, ddf.catalog.data.MetacardType type)
      Creates a Metacard with the provided Metacard and MetacardType. This method does not simply wrap the metacard and keep its type, but will create a new metacard and clone any attributes defined by the MetacardType that exist on the given Metacard. Note, this means any attributes with null values will not be copied over.
      Parameters:
      metacard - the Metacard to create this new Metacard from
      type - the MetacardType of metacard to create
  • Method Details

    • getCreatedDate

      public Date getCreatedDate()
      Specified by:
      getCreatedDate in interface ddf.catalog.data.Metacard
    • setCreatedDate

      public void setCreatedDate(Date created)
      Sets the date/time the Metacard was created.
      Convenience method for setAttribute(new AttributeImpl(Metacard.CREATED, created))
      Parameters:
      created - Date when this Metacard was created.
      See Also:
      • Metacard.CREATED
    • getModifiedDate

      public Date getModifiedDate()
      Specified by:
      getModifiedDate in interface ddf.catalog.data.Metacard
    • setModifiedDate

      public void setModifiedDate(Date modified)
      Sets the date/time the Metacard was last modifed.
      Convenience method for setAttribute(new AttributeImpl(Metacard.MODIFIED, modified))
      Parameters:
      modified - Date when this Metacard was last modified.
      See Also:
      • Metacard.MODIFIED
    • getExpirationDate

      public Date getExpirationDate()
      Specified by:
      getExpirationDate in interface ddf.catalog.data.Metacard
    • setExpirationDate

      public void setExpirationDate(Date expiration)
      Sets the date/time this Metacard is no longer valid and could be removed.
      Convenience method for setAttribute(new AttributeImpl(Metacard.EXPIRATION, expiration))
      Parameters:
      expiration - Date when the Metacard expires and should be removed from any stores.
      See Also:
      • Metacard.EXPIRATION
    • getEffectiveDate

      public Date getEffectiveDate()
      Specified by:
      getEffectiveDate in interface ddf.catalog.data.Metacard
    • setEffectiveDate

      public void setEffectiveDate(Date effective)
      Sets the date/time the Metacard was last known to be valid.
      Convenience method for setAttribute(new AttributeImpl(Metacard.EFFECTIVE, effective))
      Parameters:
      effective - Date when the information represented by the Metacard was last known to be valid.
      See Also:
      • Metacard.EFFECTIVE
    • getId

      public String getId()
      Specified by:
      getId in interface ddf.catalog.data.Metacard
    • setId

      public void setId(String id)
      Sets the ID of the Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.ID, id))
      Parameters:
      id - unique identifier of the Metacard.
      See Also:
      • Metacard.ID
    • getLocation

      public String getLocation()
      Specified by:
      getLocation in interface ddf.catalog.data.Metacard
    • setLocation

      public void setLocation(String wkt)
      Sets the WKT representation of the geometry.
      Convenience method for setAttribute(new AttributeImpl(Metacard.GEOGRAPHY, wkt))
      Parameters:
      wkt - WKT-defined geospatial String, returns null if not applicable
      See Also:
      • Metacard.GEOGRAPHY
    • getSourceId

      public String getSourceId()
      Specified by:
      getSourceId in interface ddf.catalog.data.Metacard
    • setSourceId

      public void setSourceId(String sourceId)
      Specified by:
      setSourceId in interface ddf.catalog.data.Metacard
    • getThumbnail

      public byte[] getThumbnail()
      Specified by:
      getThumbnail in interface ddf.catalog.data.Metacard
    • setThumbnail

      public void setThumbnail(byte[] bytes)
      Sets the thumbnail associated with this Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.THUMBNAIL, bytes))
      Parameters:
      bytes - thumbnail for the Metacard.
      See Also:
      • Metacard.THUMBNAIL
    • getTitle

      public String getTitle()
      Specified by:
      getTitle in interface ddf.catalog.data.Metacard
    • setTitle

      public void setTitle(String title)
      Sets the title of this Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.TITLE, id))
      Parameters:
      title - Title of the Metacard
      See Also:
      • Metacard.TITLE
    • getMetadata

      public String getMetadata()
      Specified by:
      getMetadata in interface ddf.catalog.data.Metacard
    • setMetadata

      public void setMetadata(String metadata)
      Sets the metadata associated with this Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.METADATA, metadata))
      Parameters:
      metadata - Associated metadata of the Metacard
      See Also:
      • Metacard.METADATA
    • getMetacardType

      public ddf.catalog.data.MetacardType getMetacardType()
      Specified by:
      getMetacardType in interface ddf.catalog.data.Metacard
    • setType

      public void setType(ddf.catalog.data.MetacardType type)
      Sets the MetacardType of the Metacard.
      Parameters:
      type - MetacardType of the Metacard
      See Also:
      • MetacardType
    • getContentTypeNamespace

      public URI getContentTypeNamespace()
      Specified by:
      getContentTypeNamespace in interface ddf.catalog.data.Metacard
    • setTargetNamespace

      public void setTargetNamespace(URI targetNamespace)
      Some types of metadata use different content types. If utilized, sets the URI of the content type.
      Convenience method for setAttribute(new AttributeImpl(Metacard.TARGET_NAMESPACE, targetNamespace))
      Parameters:
      targetNamespace - URI of the sub-type, null if unused
      See Also:
      • Metacard.TARGET_NAMESPACE
    • getContentTypeName

      public String getContentTypeName()
      Specified by:
      getContentTypeName in interface ddf.catalog.data.Metacard
    • setContentTypeName

      public void setContentTypeName(String contentType)
      Sets the name of the content type of the Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.CONTENT_TYPE, contentType))
      Parameters:
      contentType - name of content type of the Metacard
      See Also:
      • Metacard.CONTENT_TYPE
    • setTags

      public void setTags(Set<String> tags)
      Sets the tags associated with this metacard
      Parameters:
      tags - set of tags
    • getPointOfContact

      public String getPointOfContact()
      Returns the Point of Contact for the Metacard
      Returns:
      A String representing the Point of Contact for the Metacard.
    • setPointOfContact

      public void setPointOfContact(String pointOfContact)
      Sets the point of contact for the Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.POINT_OF_CONTACT, pointOfContact))
      Parameters:
      pointOfContact - the point of contact for the Metacard
      See Also:
      • Metacard.POINT_OF_CONTACT
    • getDescription

      public String getDescription()
      Returns the description for the Metacard
      Returns:
      A String representing the description for the Metacard.
    • setDescription

      public void setDescription(String description)
      Sets the description of the Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.DESCRIPTION, description))
      Parameters:
      description - the description of the Metacard
      See Also:
      • Metacard.DESCRIPTION
    • getContentTypeVersion

      public String getContentTypeVersion()
      Specified by:
      getContentTypeVersion in interface ddf.catalog.data.Metacard
    • setContentTypeVersion

      public void setContentTypeVersion(String contentTypeVersion)
      Sets the version of the content type of the Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.CONTENT_TYPE_VERSION, contentTypeVersion))
      Parameters:
      contentTypeVersion - version of content type of the Metacard
      See Also:
      • Metacard.CONTENT_TYPE_VERSION
    • getResourceURI

      public URI getResourceURI()
      Specified by:
      getResourceURI in interface ddf.catalog.data.Metacard
    • setResourceURI

      public void setResourceURI(URI uri)
      Sets the value of this Metacards Resource URI and in the form of a URI Object.
      Convenience method for setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, uri))
      Parameters:
      uri - a URI representation of the Metacard's Resource URI which itself is stored as a String ddf.catalog.data.AttributeType.AttributeFormat
      See Also:
      • Metacard.RESOURCE_URI
    • getResourceSize

      public String getResourceSize()
      Specified by:
      getResourceSize in interface ddf.catalog.data.Metacard
    • setResourceSize

      public void setResourceSize(String dadSize)
      Sets the size of the resource which may or may not contain a unit.
      Convenience method for setAttribute(new AttributeImpl(Metacard.RESOURCE_SIZE, dadSize))
      Parameters:
      dadSize - String representation of the size
      See Also:
      • Metacard.RESOURCE_SIZE
    • getSecurity

      public Map<String,List<String>> getSecurity()
      Returns the security relevant markings on the Metacard.
      Returns:
      security markings
    • setSecurity

      public void setSecurity(HashMap<String,List<String>> security)
      Sets the security markings on this Metacard.
      Convenience method for setAttribute(new AttributeImpl(Metacard.SECURITY, security))
      Parameters:
      security -
    • requestData

      protected <T> T requestData(String attributeName, Class<T> returnType)
      The brains of the operation -- does the interaction with the map or the wrapped metacard.
      Type Parameters:
      T - the type of the Attribute value expected
      Parameters:
      attributeName - the name of the Attribute to retrieve
      returnType - the class that the value of the AttributeType is expected to be bound to
      Returns:
      the value of the requested Attribute name
    • requestDate

      protected Date requestDate(String key)
      Get Date data from the map or wrapped metacard.
      Convenience method for requestData(key, Date.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestDouble

      protected Double requestDouble(String key)
      Get Double data from the map or wrapped metacard.
      Convenience method for requestData(key, Double.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestInputStream

      protected InputStream requestInputStream(String key)
      Get BinaryContent data from the map or wrapped metacard.
      Convenience method for requestData(key, BinaryContent.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestInteger

      protected Integer requestInteger(String key)
      Get Integer data from the map or wrapped metacard.
      Convenience method for requestData(key, Integer.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestLong

      protected Long requestLong(String key)
      Get Long data from the map or wrapped metacard.
      Convenience method for requestData(key, Long.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestString

      protected String requestString(String key)
      Get String data from the map or wrapped metacard.
      Convenience method for requestData(key, String.class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • requestBytes

      protected byte[] requestBytes(String key)
      Get
      invalid reference
      byte[]
      data from the map or wrapped metacard.
      Convenience method for requestData(key, byte[].class))
      Parameters:
      key - the name of the Attribute to retrieve
      Returns:
      the value of the requested Attribute name
      See Also:
    • getAttribute

      public ddf.catalog.data.Attribute getAttribute(String name)
      Specified by:
      getAttribute in interface ddf.catalog.data.Metacard
    • setAttribute

      public void setAttribute(String name, Serializable value)
      Set an attribute via a name/value pair.
      Parameters:
      name - the name of the Attribute
      value - the value of the Attribute
    • setAttribute

      public void setAttribute(ddf.catalog.data.Attribute attribute)
      Specified by:
      setAttribute in interface ddf.catalog.data.Metacard
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object