com.endeca.portal.metadata
Class MetadataProperty

java.lang.Object
  extended by com.endeca.portal.metadata.AbstractMetadata
      extended by com.endeca.portal.metadata.MetadataProperty
All Implemented Interfaces:
Metadata

public abstract class MetadataProperty
extends AbstractMetadata

Abstract class representing a Metadata Property. This class provides a basic Metadata implementation for getting and setting the base fields for a Metadata Property (except for "Type" which is meant to be implementation-specific) and storing an instance of the backing Liferay MetadataPropertyRecord.

Author:
Endeca Technologies, Inc.

Constructor Summary
MetadataProperty()
          Constructor that creates a new Metadata object property and its underlying MetadataPropertyRecord object.
MetadataProperty(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord record)
          Constructor that creates a new Metadata object and assigns a given MetadataPropertyRecord to its underlying object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 java.util.Comparator<MetadataProperty> getPropertyComparator()
          Specify the Comparator to use when determining if a MetadataProperty has been modified and should therefore be persisted to the database.
 long getPropertyId()
          Gets the Metadata Property's ID
 com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord getSourceRecord()
          Gets the underlying Liferay source record
abstract  java.lang.String getType()
          Gets the implementation-specific type.
protected  void init(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord record)
          Initializes this AbstractMetadataObject from a MetadataPropertyRecord
 void setPropertyId(long propertyId)
          Sets the Metadata Property's ID
 void setSourceRecord(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord rec)
          Sets the underlying Liferay source record
 java.lang.String toString()
           
 
Methods inherited from class com.endeca.portal.metadata.AbstractMetadata
getDescription, getFeature, getKey, getLastUpdated, getLocale, getObjectId, getRel, getSource, getValue, setDescription, setFeature, setKey, setLastUpdated, setLocale, setObjectId, setRel, setSource, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetadataProperty

public MetadataProperty()
Constructor that creates a new Metadata object property and its underlying MetadataPropertyRecord object. The underlying object is initialized with an id of -1 and is not persisted to the database; that must be done explicitly if you want it to be persisted.


MetadataProperty

public MetadataProperty(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord record)
Constructor that creates a new Metadata object and assigns a given MetadataPropertyRecord to its underlying object. The underlying object is not persisted to the database; that must be done explicitly if you want it to be persisted.

Parameters:
record - the source MetadataRecord
Method Detail

init

protected void init(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord record)
Initializes this AbstractMetadataObject from a MetadataPropertyRecord

Parameters:
record - the MetadataPropertyRecord from which this Metadata Object should be initialized

getType

public abstract java.lang.String getType()
Gets the implementation-specific type.

Specified by:
getType in interface Metadata
Specified by:
getType in class AbstractMetadata
Returns:
the type of metadata this object represents
See Also:
MetadataObject.getType()

getSourceRecord

public com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord getSourceRecord()
Gets the underlying Liferay source record

Returns:
the source record

setSourceRecord

public void setSourceRecord(com.endeca.portal.liferay.ext.metadata.model.MetadataPropertyRecord rec)
Sets the underlying Liferay source record

Parameters:
rec - the source record

getPropertyId

public long getPropertyId()
Gets the Metadata Property's ID

Returns:
the property ID

setPropertyId

public void setPropertyId(long propertyId)
Sets the Metadata Property's ID

Parameters:
propertyId - the property ID

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. Returns true if the other object is a MetadataProperty and its property ID is the same as this one's ID. If the property ID is -1 for either this object or the other object, false will be returned. TODO: What actually should happen when the property ID is -1?

Overrides:
equals in class java.lang.Object

getPropertyComparator

public java.util.Comparator<MetadataProperty> getPropertyComparator()
Specify the Comparator to use when determining if a MetadataProperty has been modified and should therefore be persisted to the database. Return null to use equals() instead of a custom comparator. This base class returns null; subclasses should override this method when necessary. Note that we abuse the Comparator interface - we don't truly care about ordering; we only care if the objects being compared are equivalent (i.e. the comparator returns 0). However, subclasses should fully comply with the Comparator interface for forward compatibility. *

Returns:
a custom Comparator or null to use equals()

toString

public java.lang.String toString()
Overrides:
toString in class AbstractMetadata