Xindice API
version 1.1

org.apache.xindice.core.meta
Class MetaData

java.lang.Object
  |
  +--org.apache.xindice.core.meta.MetaData
All Implemented Interfaces:
XMLSerializable

public class MetaData
extends Object
implements XMLSerializable

Implements the MetaData interface.

 <meta>
   <system [type="doc|col"] [href="uri"]/>
   <attrs>
     <attr name="name" value="value"/>
     <attr name="name" value="value"/>
   </attrs>
   <custom>
     ...
   </custom>
 </meta>
 

Version:
$Revision: 511426 $, $Date: 2007-02-24 22:25:02 -0500 (Sat, 24 Feb 2007) $
Author:
ku, Dave Viner

Field Summary
static short COLLECTION
           
static short DOCUMENT
           
static short LINK
           
static String NS_URI
           
static short UNKNOWN
           
static boolean USE_NS
           
 
Constructor Summary
MetaData()
           
MetaData(org.w3c.dom.Element elem)
           
MetaData(short type, String owner, long created, long modified)
           
MetaData(String owner)
           
 
Method Summary
 void copyDataFrom(MetaData meta)
          Copies only user data (link, attributes, custom document) from another meta data
 void copyFrom(MetaData meta)
          Copies from another meta data
 Object getAttribute(Object name)
          Retrieves the attribute by name
 Boolean getAttributeAsBoolean(Object name)
           
 Integer getAttributeAsInteger(Object name)
           
 Long getAttributeAsLong(Object name)
           
 Short getAttributeAsShort(Object name)
           
 Enumeration getAttributeKeys()
          Returns enumeration of all attributes
 long getCreatedTime()
          Returns the time of creation
 org.w3c.dom.Document getCustomDocument()
          Returns the (optional) custom meta document
 long getLastModifiedTime()
          Returns the time of last modification
 String getLinkTargetURI()
          Returns the linked target URI, if this is a link
 String getOwner()
          Returns the canonical name of the owner object.
 short getType()
          Returns the type of the owner object, e.g., COLLECTION, DOCUMENT, or LINK
static String getTypeString(short type)
          Return a string representing which type passed in.
 boolean hasContext()
          Determine whether this obect has created or modified times set
 boolean isDirty()
          Returns whether this MetaData is dirty
static short parseTypeString(String str)
          Return a short representing the string given.
 Object removeAttribute(Object name)
          Remove an attribute by name
 Object setAttribute(Object name, Object value)
          Sets the attribute by name
 void setContext(long created, long modified)
          Set the created and modified times.
 void setCustomDocument(org.w3c.dom.Document doc)
          Sets the (optional) custom meta document
 void setDirty(boolean dirty)
          Reset the dirtiness of this object
 void setLinkTargetURI(String link)
           
 void setOwner(String owner)
          Set the owner of this object
 void setType(short type)
          Set the type for this object.
 void streamFromXML(org.w3c.dom.Element source)
          Given some xml, populate the metadata.
 void streamFromXML(org.w3c.dom.Element source, boolean includeTime)
          Given some xml, populate the metadata.
 org.w3c.dom.Element streamToXML(org.w3c.dom.Document doc)
          Stream this MetaData into an xml document
 org.w3c.dom.Element streamToXML(org.w3c.dom.Document doc, boolean includeTime)
          Stream this MetaData into an xml document
 String toString()
          Return a string representing this MetaData It will look like: META[doc owner=OWNER created=CREATED modified=MODIFIED link=LINK attrs=ATTRS]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final short UNKNOWN

COLLECTION

public static final short COLLECTION

DOCUMENT

public static final short DOCUMENT

LINK

public static final short LINK

NS_URI

public static final String NS_URI

USE_NS

public static final boolean USE_NS
Constructor Detail

MetaData

public MetaData()

MetaData

public MetaData(String owner)
Parameters:
owner - the owner of this metadata.

MetaData

public MetaData(short type,
                String owner,
                long created,
                long modified)
Parameters:
type - the type of object for this metadata
owner - the owner of this metadata
created - the time when this was created
modified - the time when this was modified.

MetaData

public MetaData(org.w3c.dom.Element elem)
Parameters:
elem - an XML representation of the desired metadata.
Method Detail

isDirty

public final boolean isDirty()
Returns whether this MetaData is dirty
Returns:
boolean

setDirty

public final void setDirty(boolean dirty)
Reset the dirtiness of this object
Parameters:
dirty -  

getCreatedTime

public long getCreatedTime()
Returns the time of creation
Returns:
long creation time

getLastModifiedTime

public long getLastModifiedTime()
Returns the time of last modification
Returns:
long last modified time

getType

public short getType()
Returns the type of the owner object, e.g., COLLECTION, DOCUMENT, or LINK
Returns:
short the object type

getOwner

public String getOwner()
Returns the canonical name of the owner object.
Returns:
String the canonical name of the owner object

getAttributeKeys

public Enumeration getAttributeKeys()
Returns enumeration of all attributes
Returns:
Enumeration of attributes

getAttribute

public Object getAttribute(Object name)
Retrieves the attribute by name
Parameters:
name - the attribute name
Returns:
String the value of attribute, or null if not found

getAttributeAsBoolean

public Boolean getAttributeAsBoolean(Object name)

getAttributeAsInteger

public Integer getAttributeAsInteger(Object name)

getAttributeAsLong

public Long getAttributeAsLong(Object name)

getAttributeAsShort

public Short getAttributeAsShort(Object name)

setAttribute

public Object setAttribute(Object name,
                           Object value)
Sets the attribute by name
Parameters:
name - the attribute name
value - the attribute value
Returns:
Object the old value, if any

removeAttribute

public Object removeAttribute(Object name)
Remove an attribute by name
Parameters:
name - the attribute to remove
Returns:
Object the removed value

getCustomDocument

public org.w3c.dom.Document getCustomDocument()
Returns the (optional) custom meta document
Returns:
Document the custom meta document

setCustomDocument

public void setCustomDocument(org.w3c.dom.Document doc)
Sets the (optional) custom meta document
Parameters:
doc - the Document

copyFrom

public void copyFrom(MetaData meta)
Copies from another meta data
Parameters:
meta - the meta to copy from

copyDataFrom

public void copyDataFrom(MetaData meta)
Copies only user data (link, attributes, custom document) from another meta data
Parameters:
meta - the meta to copy from

getLinkTargetURI

public String getLinkTargetURI()
Returns the linked target URI, if this is a link
Returns:
String the URI of the linked target

streamToXML

public final org.w3c.dom.Element streamToXML(org.w3c.dom.Document doc)
                                      throws org.w3c.dom.DOMException
Stream this MetaData into an xml document
Specified by:
streamToXML in interface XMLSerializable
Parameters:
doc - the xml document to be populated.

streamToXML

public final org.w3c.dom.Element streamToXML(org.w3c.dom.Document doc,
                                             boolean includeTime)
                                      throws org.w3c.dom.DOMException
Stream this MetaData into an xml document
Parameters:
doc - the xml document to populate
includeTime - whether or not to include the create/modified times
Returns:
Element the root element

streamFromXML

public final void streamFromXML(org.w3c.dom.Element source)
                         throws org.w3c.dom.DOMException
Given some xml, populate the metadata.
Specified by:
streamFromXML in interface XMLSerializable
Parameters:
source - The xml to populate metadata with

streamFromXML

public final void streamFromXML(org.w3c.dom.Element source,
                                boolean includeTime)
                         throws org.w3c.dom.DOMException
Given some xml, populate the metadata.
Parameters:
source - The xml to populate the metadata with
includeTime - Whether or not to reset the create/modified times

getTypeString

public static String getTypeString(short type)
Return a string representing which type passed in. It will be either doc, col, link, none.
Parameters:
type - The type you want translated.
Returns:
String representing this type

parseTypeString

public static short parseTypeString(String str)
Return a short representing the string given. The string should be doc, col, or link.
Parameters:
str - The string to parse
Returns:
short The short for this string.

hasContext

public boolean hasContext()
Determine whether this obect has created or modified times set
Returns:
boolean

setContext

public void setContext(long created,
                       long modified)
Set the created and modified times. If 0 value is passed, time is not changed.
Parameters:
created - the new creation time
modified - the new modified time

setType

public void setType(short type)
Set the type for this object. If the type is already set to the value passed in, nothing is changed.
Parameters:
type - the type for this object.

setOwner

public void setOwner(String owner)
Set the owner of this object
Parameters:
owner - the owner to be ass

setLinkTargetURI

public void setLinkTargetURI(String link)

toString

public String toString()
Return a string representing this MetaData It will look like: META[doc owner=OWNER created=CREATED modified=MODIFIED link=LINK attrs=ATTRS]
Overrides:
toString in class Object
Returns:
String

Xindice API
version 1.1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.