//============================================================================== // DocumentProperty.java //============================================================================== package tribble.archive; import java.io.IOException; import java.lang.Exception; import java.lang.Object; import java.lang.String; /******************************************************************************* * Generic document property. * *

* This class provides the fundamental attributes and methods for a * document property that is associated with an archive document. * *

* An archive document is composed of content data (such as an image, * text, or other kind of user data) and one or more properties. * All of the documents within an archive system typically share the same set of * document properties, although this is not required of any implementation. * *

* Document properties specify attributes of the document beyond the content data * of the document, the meaning of which are defined by the implementation. * For example, a given implementation might provide properties specifying things * like a document's modification date, number of pages it contains, the names of * its authors, its access permissions, its expiration date, an identification * number shared by other related documents within the same batch, and so forth. * In addition to the document ID, one or more of these properties might be * used as the indices to store the document in the archive system. * *

* Each document property has the following attributes: *

* * There may be other attributes of the properties, which are specific to the * particular subclass implementation of the archive system. * *

* A given property that is associated with a particular archive document also * has a value, which is an object of some sort. * The values of the properties can be accessed for a given document that was * retrieved by an {@link ArchiveReader}, by calling the * {@link ArchiveDocument#getProperty ArchiveDocument.getProperty()} method. * *

* The value of a property is the minimum amount of information that is * useful to an implementation. The other attributes may be used or ignored by * the implementation as it deems necessary. * *

* Note: This requires Java 1.5 or later. * * *

*
Source code:
*
* http://david.tribble.com/src/java/tribble/archive/DocumentProperty.java *
*
Documentation:
*
* http://david.tribble.com/docs/tribble/archive/DocumentProperty.html *
*
* * * @version API 2.0, $Revision: 1.1 $ $Date: 2008/04/03 23:03:56 $ * @since 2008-04-03 * @author David R. Tribble (david@tribble.com) * Copyright ©2004 by David R. Tribble, all rights reserved. * * @see WritableProperty * @see ArchiveDocument */ public class DocumentProperty { static final String REV = "@(#)tribble/archive/DocumentProperty.java $Revision: 1.1 $ $Date: 2008/04/03 23:03:56 $\n"; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Constants //---------------------------------- // Property types /** Property type: Alphanumeric text. */ public static final String TYPE_TEXT = "Alphanumeric"; /** Property type: Binary data. */ public static final String TYPE_BINARY = "Binary"; /** Property type: Numeric. */ public static final String TYPE_NUM = "Numeric"; /** Property type: Date/time. */ public static final String TYPE_DATE = "Date"; /** Property type: Filename. */ public static final String TYPE_FILE = "File"; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Variables /** Property name. */ protected String m_name; /** Property type. * This can be one of the {@link #TYPE_TEXT TYPE_XXX} constants * or some other application-defined value. */ protected String m_type; /** Text property length. */ protected int m_len; /** Output format (for non-String type properties). */ protected String m_outFmt; /** Input format (for non-String type properties). */ protected String m_inFmt; /** Default output value. */ protected Object m_dflVal; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Constructors /************************************************************************** * Constructor. * * @param name * The name of this document property. * * @since API 2.0, 2008-04-03 */ protected DocumentProperty(String name) { // Initialize m_name = name; } // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Methods /*************************************************************************** * Compares two objects for equality. * * @param obj * The object to compare this object to. * * @return * True if these objects are equal, false otherwise. * * @since API 2.0, 2008-04-03 */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (obj instanceof DocumentProperty) return this.m_name.equals(((DocumentProperty) obj).m_name); return false; } /*************************************************************************** * Generates a hash code for this property. * * @return * An integer hash code for this property. * * @since API 2.0, 2008-04-03 */ @Override public int hashCode() { return m_name.hashCode(); } /*************************************************************************** * Retrieve the name of this document property. * * @return * The name of this property. * * @since API 2.0, 2008-04-03 */ public String getName() { return m_name; } /*************************************************************************** * Retrieve the type of this document property. * * @return * The type of this property, which is one of the * {@link #TYPE_TEXT TYPE_XXX} constants or some other * application-defined value, or null if it is not defined. * * @since API 2.0, 2008-04-03 */ public String getType() { return m_type; } /*************************************************************************** * Retrieve the length of this document property. * * @return * The length of this document property, or zero if it is not defined. * * @since API 2.0, 2008-04-03 */ public int getLength() { return m_len; } /*************************************************************************** * Retrieve the output format specification for this document property. * * @return * The formatting specification of this property, which specifies how the * property value should be formatted when it is stored in an archive * document; or null if it is not defined. * * @since API 2.0, 2008-04-03 */ public String getOutputFormat() { return m_outFmt; } /*************************************************************************** * Retrieve the input (source) format specification for this document * property. * * @return * The source formatting specification of this property, which specifies the * format of the property value before it is stored in an archive document * (i.e., it specifies how the source value for this property should be * unformatted when its value is set, prior to being * reformatted when it is written to the archive); * or null if it is not defined. * * @since API 2.0, 2008-04-03 */ public String getInputFormat() { return m_inFmt; } /*************************************************************************** * Retrieve the default value for this document property. * * @return * The default value to be used by this document property if it is not * explicitly set to another value. This is null if the property has no * default value established. * * @since API 2.0, 2008-04-03 */ public Object getDefaultValue() { return m_dflVal; } } // End DocumentProperty.java