tribble.repository
Class DocumentProperty

java.lang.Object
  extended by tribble.repository.DocumentProperty
Direct Known Subclasses:
WritableProperty

public class DocumentProperty
extends java.lang.Object

Generic document property.

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

A repository document is composed of content data (such as an image, text, or other kind of user data) and zero or more properties. Typically, the properties comprise the keys used to store the document in a document storage system. Typically, all of the documents within a repository system 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 keys to store the document in the repository 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 repository system. For documents being written to a repository by an RepositoryWriter, a property can be associated with the document using the StorableDocument.addProperty() method (or by some other means provided by the implementation).

A given property that is associated with a particular repository document also has a value, which is an object of some sort. Once a property is associated with the document, its value can be set to some object using the StorableDocument.setProperty() method. The values of the properties can be accessed for a given document that was retrieved by an RepositoryReader, by calling the Document.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/repository/DocumentProperty.java
Documentation:
http://david.tribble.com/docs/tribble/repository/DocumentProperty.html

Since:
2008-04-03
Version:
API 2.0, $Revision: 1.2 $ $Date: 2008/04/04 01:28:58 $
Author:
David R. Tribble (david@tribble.com)
Copyright ©2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by the United States Department of State as a terrorist or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.
See Also:
WritableProperty, Document

Field Summary
protected  java.lang.Object m_dflVal
          Default output value.
protected  java.lang.String m_inFmt
          Input format.
protected  int m_len
          Text property length.
protected  java.lang.String m_name
          Property name.
protected  java.lang.String m_outFmt
          Output format.
protected  java.lang.String m_type
          Property type.
protected  boolean m_writable
          Property is modifiable.
static java.lang.String TYPE_BINARY
          Property type: Binary data.
static java.lang.String TYPE_DATE
          Property type: Date/time.
static java.lang.String TYPE_FILE
          Property type: Filename.
static java.lang.String TYPE_NUM
          Property type: Numeric.
static java.lang.String TYPE_TEXT
          Property type: Alphanumeric text.
 
Constructor Summary
DocumentProperty(java.lang.String name)
          Constructor.
DocumentProperty(java.lang.String name, java.lang.String type, int len, java.lang.String outFmt, java.lang.String inFmt, java.lang.Object dflVal)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares two objects for equality.
 java.lang.Object getDefaultValue()
          Retrieve the default value for this document property.
 java.lang.String getInputFormat()
          Retrieve the input (source) format specification for this document property.
 int getLength()
          Retrieve the length of this document property.
 java.lang.String getName()
          Retrieve the name of this document property.
 java.lang.String getOutputFormat()
          Retrieve the output format specification for this document property.
 java.lang.String getType()
          Retrieve the type of this document property.
 int hashCode()
          Generates a hash code for this property.
 void setDefaultValue(java.lang.Object val)
          Establish the default value for this document property.
 void setInputFormat(java.lang.String fmt)
          Establish the input (source) format specification for this document property.
 void setLength(int len)
          Establish the length of this document property.
 void setOutputFormat(java.lang.String fmt)
          Establish the output format specification for this document property.
 void setType(java.lang.String type)
          Establish the type of this document property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_TEXT

public static final java.lang.String TYPE_TEXT
Property type: Alphanumeric text.

See Also:
Constant Field Values

TYPE_BINARY

public static final java.lang.String TYPE_BINARY
Property type: Binary data.

See Also:
Constant Field Values

TYPE_NUM

public static final java.lang.String TYPE_NUM
Property type: Numeric.

See Also:
Constant Field Values

TYPE_DATE

public static final java.lang.String TYPE_DATE
Property type: Date/time.

See Also:
Constant Field Values

TYPE_FILE

public static final java.lang.String TYPE_FILE
Property type: Filename.

See Also:
Constant Field Values

m_name

protected java.lang.String m_name
Property name.


m_type

protected java.lang.String m_type
Property type. This can be one of the TYPE_XXX constants or some other application-defined value.


m_len

protected int m_len
Text property length.


m_outFmt

protected java.lang.String m_outFmt
Output format.


m_inFmt

protected java.lang.String m_inFmt
Input format.


m_dflVal

protected java.lang.Object m_dflVal
Default output value.


m_writable

protected boolean m_writable
Property is modifiable.

Constructor Detail

DocumentProperty

public DocumentProperty(java.lang.String name)
Constructor.

Parameters:
name - The name of this document property. This cannot be null or empty.
Throws:
java.lang.NullPointerException - (unchecked) Thrown if name is null.
java.lang.IllegalArgumentException - (unchecked) Thrown if name is an empty string ("").
Since:
API 2.0, 2008-04-03

DocumentProperty

public DocumentProperty(java.lang.String name,
                        java.lang.String type,
                        int len,
                        java.lang.String outFmt,
                        java.lang.String inFmt,
                        java.lang.Object dflVal)
Constructor.

Parameters:
name - The name of this document property. This cannot be null or empty.
type - Property type. This can be one of the TYPE_XXX constants or some other application-defined value.
len - Text property length.
outFmt - Output format.
inFmt - Input format.
dflVal - Default output value.
Throws:
java.lang.NullPointerException - (unchecked) Thrown if name is null.
java.lang.IllegalArgumentException - (unchecked) Thrown if name is an empty string ("").
Since:
API 2.0, 2008-04-19
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two objects for equality. Document properties are considered equal if they have the same name.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare this object to.
Returns:
True if these objects are equal, false otherwise.
Since:
API 2.0, 2008-04-03

hashCode

public int hashCode()
Generates a hash code for this property.

Overrides:
hashCode in class java.lang.Object
Returns:
An integer hash code for this property.
Since:
API 2.0, 2008-04-03

getName

public java.lang.String getName()
Retrieve the name of this document property.

Returns:
The name of this property.
Since:
API 2.0, 2008-04-03

getType

public java.lang.String getType()
Retrieve the type of this document property.

Returns:
The type of this property, which is one of the TYPE_XXX constants or some other application-defined value, or null if it is not defined.
Since:
API 2.0, 2008-04-03

setType

public void setType(java.lang.String type)
Establish the type of this document property.

Parameters:
type - The type of this property, which is one of the TYPE_XXX constants or some other application-defined value, or null if it is not defined.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if this document property is not modifiable.
Since:
API 2.0, 2008-04-22

getLength

public int getLength()
Retrieve the length of this document property.

Returns:
The length of this document property, or zero if it is not defined.
Since:
API 2.0, 2008-04-03

setLength

public void setLength(int len)
Establish the length of this document property.

Parameters:
len - The length of this document property, or zero if it is not defined.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if this document property is not modifiable.
Since:
API 2.0, 2008-04-22

getOutputFormat

public java.lang.String getOutputFormat()
Retrieve the output format specification for this document property.

Returns:
The formatting specification of this property, which specifies how the property value should be formatted when it is stored in a repository document; or null if it is not defined.
Since:
API 2.0, 2008-04-03

setOutputFormat

public void setOutputFormat(java.lang.String fmt)
Establish the output format specification for this document property.

Parameters:
fmt - The formatting specification of this property, which specifies how the property value should be formatted when it is stored in a repository document; or null if it is not defined.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if this document property is not modifiable.
Since:
API 2.0, 2008-04-22

getInputFormat

public java.lang.String getInputFormat()
Retrieve the input (source) format specification for this document property.

Returns:
The source formatting specification of this property, which specifies the format of the property value before it is stored in a repository 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 repository); or null if it is not defined.
Since:
API 2.0, 2008-04-03

setInputFormat

public void setInputFormat(java.lang.String fmt)
Establish the input (source) format specification for this document property.

Parameters:
fmt - The source formatting specification of this property, which specifies the format of the property value before it is stored in a repository 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 repository); or null if it is not defined.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if this document property is not modifiable.
Since:
API 2.0, 2008-04-22

getDefaultValue

public java.lang.Object getDefaultValue()
Retrieve the default value for this document property.

Returns:
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

setDefaultValue

public void setDefaultValue(java.lang.Object val)
Establish the default value for this document property. If this method is not called, the default value is null.

Parameters:
val - The default value to be used by this document property if it is not explicitly set to another value. This can be null.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if this document property is not modifiable.
Since:
API 2.0, 2008-04-22