Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.gatherer.msm
Class MetadataSet  view MetadataSet download MetadataSet.java

java.lang.Object
  extended byorg.greenstone.gatherer.msm.MetadataSet

public class MetadataSet
extends java.lang.Object

An semi-data class to hold details about a loaded metadata set, it also provides some methods to manipulating the data within.

Version:
2.3b

Field Summary
(package private) static int ALL_VALUES
          An element of the tree pruning filter enumeration, that indicates all nodes in the tree should be retained.
private  java.lang.String description
          The description of this metadata set.
private  org.w3c.dom.Document document
          The Document of the DOM model.
private  org.w3c.dom.NodeList elements
          The list of metadata elements which are, of course, children of the root node.
private  java.io.File file
          The File this metadata set was loaded from.
private  java.lang.String name
          The name of this metadata set.
(package private) static int NO_VALUES
          An element of the tree pruning filter enumeration, that indicates no value nodes i.e.
private  org.w3c.dom.Element root
          The document Element of the DOM model.
(package private) static int SUBJECTS_ONLY
          An element of the tree pruning filter enumeration, that indicates only metadata Subject nodes or higher should remain after pruning.
private  java.util.Hashtable value_trees
          A mapping from metadata elements to the root element of the value trees for that element.
 
Constructor Summary
MetadataSet(java.io.File file)
          Constructor.
MetadataSet(java.io.File file, org.w3c.dom.Document document)
          Metadata Set already parsed constructor.
MetadataSet(MetadataSet original)
          Copy constructor.
MetadataSet(MetadataSet original, int condition)
          Conditional copy constructor.
MetadataSet(java.lang.String metadata_template)
           
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Add a mds level attribute.
 java.lang.String addElement(org.w3c.dom.Element others_element, org.greenstone.gatherer.valuetree.GValueModel model)
          Method to add a new metadata element to this metadata set, if and only if the element is not already present.
 java.lang.String addElement(org.w3c.dom.Element others_element, java.lang.String new_name, org.greenstone.gatherer.valuetree.GValueModel model)
          Method to add a new metadata element with the specified new name to this metadata set, if and only if the name is not already in use.
 ElementWrapper addElement(java.lang.String name, java.lang.String language)
          Add a new default metadata element with the given name to this metadata set.
 void addValueTree(ElementWrapper element, org.greenstone.gatherer.valuetree.GValueModel model)
          Add a value tree to a given metadata element.
 int compare(org.w3c.dom.Element e1, org.w3c.dom.Element e2)
           
 boolean containsElement(java.lang.String name)
          A method to determine if this metadata set contains an element with a certain name (case sensitive).
 org.w3c.dom.NamedNodeMap getAttributes()
           
 java.lang.String getCreator()
          Method to retrieve the name of the creator of this metadata set.
 java.lang.String getDescription()
          Method to retrieve the description of this metadata set.
 org.w3c.dom.Document getDocument()
          Method to retrieve the Document associated with this metadata set.
 org.w3c.dom.Element getElement(org.w3c.dom.Element parent_element, java.lang.String name)
           
 org.w3c.dom.Element getElement(int index)
          Method to retrieve the metadata element indicated by an index.
 org.w3c.dom.Element getElement(Metadata metadata)
          This method is used to acquire a reference to the element which matches the given metadata.
 org.w3c.dom.Element getElement(java.lang.String name)
          This method is used to acquire a reference to the element which has the name specified.
 org.w3c.dom.NodeList getElements()
          Method to acquire a list of all the elements in this metadata set.
 java.util.Vector getElementsSorted()
          Method to retrieve a list of all the elements in this metadata set, sorted.
 java.io.File getFile()
          Method to retrieve the original file this metadata set was created from.
 java.lang.String getLastChanged()
          Get the last changed attribute.
 java.lang.String getName()
          Method to get this metadata sets name.
 java.lang.String getNamespace()
          Method to retrieve this metadata sets namespace.
 org.w3c.dom.Element getRoot()
          Method to retrieve the root element, i.e.
 org.greenstone.gatherer.valuetree.GValueModel getValueTree(ElementWrapper element)
          Retrieve the value tree from this set that matches the given element.
private  void init(java.io.File file)
           
 void removeAttribute(java.lang.String name)
          Remove a mds level attribute.
 void removeElement(org.w3c.dom.Element element)
          Method to remove the given element from this metadata set.
 org.greenstone.gatherer.valuetree.GValueModel removeValueTree(ElementWrapper element)
          Used to remove the value tree for a specific element.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set one of the mds level attributes.
 void setFile(java.io.File file)
          Once the metadata set has been saved to a different location, this is used to update the file parameter.
 void setName(java.lang.String name)
           
 int size()
          Method to determine the number of elements in this set.
 java.lang.String toString()
          Method to translate this class into a meaningful string, which in this case is the metadata sets name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

document

private org.w3c.dom.Document document
The Document of the DOM model.


root

private org.w3c.dom.Element root
The document Element of the DOM model.


file

private java.io.File file
The File this metadata set was loaded from.


value_trees

private java.util.Hashtable value_trees
A mapping from metadata elements to the root element of the value trees for that element.


elements

private org.w3c.dom.NodeList elements
The list of metadata elements which are, of course, children of the root node.


description

private java.lang.String description
The description of this metadata set. Cached as it takes more computation time.


name

private java.lang.String name
The name of this metadata set. Cached as it takes more computation time.


ALL_VALUES

static final int ALL_VALUES
An element of the tree pruning filter enumeration, that indicates all nodes in the tree should be retained.

See Also:
Constant Field Values

SUBJECTS_ONLY

static final int SUBJECTS_ONLY
An element of the tree pruning filter enumeration, that indicates only metadata Subject nodes or higher should remain after pruning.

See Also:
Constant Field Values

NO_VALUES

static final int NO_VALUES
An element of the tree pruning filter enumeration, that indicates no value nodes i.e. the entire AssignedValues subtree, should remain after pruning.

See Also:
Constant Field Values
Constructor Detail

MetadataSet

public MetadataSet(java.lang.String metadata_template)

MetadataSet

public MetadataSet(java.io.File file)
Constructor.


MetadataSet

public MetadataSet(java.io.File file,
                   org.w3c.dom.Document document)
Metadata Set already parsed constructor.


MetadataSet

public MetadataSet(MetadataSet original)
Copy constructor.


MetadataSet

public MetadataSet(MetadataSet original,
                   int condition)
Conditional copy constructor.

Method Detail

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
Add a mds level attribute.


addElement

public ElementWrapper addElement(java.lang.String name,
                                 java.lang.String language)
Add a new default metadata element with the given name to this metadata set.


addElement

public java.lang.String addElement(org.w3c.dom.Element others_element,
                                   org.greenstone.gatherer.valuetree.GValueModel model)
Method to add a new metadata element to this metadata set, if and only if the element is not already present.


addElement

public java.lang.String addElement(org.w3c.dom.Element others_element,
                                   java.lang.String new_name,
                                   org.greenstone.gatherer.valuetree.GValueModel model)
Method to add a new metadata element with the specified new name to this metadata set, if and only if the name is not already in use.


addValueTree

public void addValueTree(ElementWrapper element,
                         org.greenstone.gatherer.valuetree.GValueModel model)
Add a value tree to a given metadata element.


compare

public int compare(org.w3c.dom.Element e1,
                   org.w3c.dom.Element e2)

containsElement

public boolean containsElement(java.lang.String name)
A method to determine if this metadata set contains an element with a certain name (case sensitive).


getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()

getCreator

public java.lang.String getCreator()
Method to retrieve the name of the creator of this metadata set.


getDescription

public java.lang.String getDescription()
Method to retrieve the description of this metadata set. Note that this is language specific, so we determine the desired language from the Dictionary. If no such entry exists, first try returning the english version and failing that the first description found.


getDocument

public org.w3c.dom.Document getDocument()
Method to retrieve the Document associated with this metadata set.


getElement

public org.w3c.dom.Element getElement(int index)
Method to retrieve the metadata element indicated by an index.


getElement

public org.w3c.dom.Element getElement(Metadata metadata)
This method is used to acquire a reference to the element which matches the given metadata. Note that this is not the same as metadata.getElement() as the reference returned by it may now be obsolete.


getElement

public org.w3c.dom.Element getElement(java.lang.String name)
This method is used to acquire a reference to the element which has the name specified. Note that this is not the same as metadata.getElement() as the reference returned by it may now be obsolete.


getElement

public org.w3c.dom.Element getElement(org.w3c.dom.Element parent_element,
                                      java.lang.String name)

getElements

public org.w3c.dom.NodeList getElements()
Method to acquire a list of all the elements in this metadata set.


getElementsSorted

public java.util.Vector getElementsSorted()
Method to retrieve a list of all the elements in this metadata set, sorted.


getFile

public java.io.File getFile()
Method to retrieve the original file this metadata set was created from.


getLastChanged

public java.lang.String getLastChanged()
Get the last changed attribute.


getName

public java.lang.String getName()
Method to get this metadata sets name. Note that this is language specific, so we determine the desired language from the Dictionary. If no such entry exists, first try returning the english version and failing that the first name found.


getNamespace

public java.lang.String getNamespace()
Method to retrieve this metadata sets namespace.


getRoot

public org.w3c.dom.Element getRoot()
Method to retrieve the root element, i.e. the Document Element, of the DOM model behind this metadata set.


getValueTree

public org.greenstone.gatherer.valuetree.GValueModel getValueTree(ElementWrapper element)
Retrieve the value tree from this set that matches the given element.


removeAttribute

public void removeAttribute(java.lang.String name)
Remove a mds level attribute.


removeElement

public void removeElement(org.w3c.dom.Element element)
Method to remove the given element from this metadata set.


removeValueTree

public org.greenstone.gatherer.valuetree.GValueModel removeValueTree(ElementWrapper element)
Used to remove the value tree for a specific element.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Set one of the mds level attributes.


setFile

public void setFile(java.io.File file)
Once the metadata set has been saved to a different location, this is used to update the file parameter.


setName

public void setName(java.lang.String name)

size

public int size()
Method to determine the number of elements in this set.


toString

public java.lang.String toString()
Method to translate this class into a meaningful string, which in this case is the metadata sets name.


init

private void init(java.io.File file)