org.ispheres.shared.core
Class Schema

java.lang.Object
  extended by org.ispheres.shared.core.Schema

public class Schema
extends java.lang.Object

The Schema object contains the metadata scheme which is read from a metadata schema file stored in XML. This can be used to validate metadata information entered to the actual metadata scheme that is being used.

Author:
Clinton Freeman mochumbo@users.sourceforge.net, Jonathan Mezach, Ted Zhou

Constructor Summary
Schema()
          Default constructor for Schema object which creates an empty instance of a schema.
Schema(java.io.File schemaFile)
          Constructs the Schema object based on the specified schema file.
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks whether this Schema is equal to another Schema object and returns true when it is.
 java.lang.String getContentType()
          Returns the Content-Type that is used for Schema objects for transfer using SOAP.
 java.util.ArrayList<java.lang.Integer> getDescriptionElements()
          Returns the list of elements that make up the description of a MetadataObject in this schema.
 java.lang.Integer getElementId(java.lang.String elementName)
          Returns the unique identifier of the element with the specified name.
 int[] getElementIds(java.lang.String[] elementNames)
          Retrieves a list of unique identifiers for the elements with the specified names, or throws a NoSuchElementException when one of the specified elements does not exist.
 java.lang.String getElementName(int elementId)
          Returns the name or tag of the element with the specified unique identifier.
 java.util.Map<java.lang.Integer,Element> getElements()
          Returns the mapping of unique identifiers of elements to the actual Element objects.
 java.io.File getFile()
          Returns the filename of the file in which the metadata schema is stored.
 java.util.ArrayList<java.lang.Integer> getObjectLocationElements()
          Returns the list of unique identifiers for the elements that specify the location of the digital object that accompanies MetadataObjects using this Schema.
 java.util.Map<java.lang.Integer,Scheme> getSchemes()
          Returns the mapping of unique identifiers of schemes to the actual Scheme objects.
 int getTitleElement()
          Returns the unique identifier of the element that makes up the title of a MetadataObject in this schema.
 boolean hasElement(int elementId)
          Returns whether the schema defines an element with the specified unique identifier.
 boolean hasElement(java.lang.String elementName)
          Returns whether the schema has an element with the specified name.
 int hashCode()
          Calculates the hascode for this Schema object.
 void populateObject(byte[] serialisedObject)
          Recreates the Schema object based on the data contained in the supplied array of bytes.
 byte[] serialiseObject()
          Creates a serialised form of the Schema object, which is really just a read of the schema file this Schema object was constructed from.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schema

public Schema()
Default constructor for Schema object which creates an empty instance of a schema. This can then be used to populate it from an attachment sent over SOAP.


Schema

public Schema(java.io.File schemaFile)
       throws java.io.IOException
Constructs the Schema object based on the specified schema file.

Parameters:
schemaFile - A File object representing the schema XML file.
Throws:
java.io.IOException - Thrown when the file could not be read.
Method Detail

getFile

public final java.io.File getFile()
Returns the filename of the file in which the metadata schema is stored.

Returns:
A File holding a reference to the file that was used to create the schema from.

getElementId

public final java.lang.Integer getElementId(java.lang.String elementName)
Returns the unique identifier of the element with the specified name.

Parameters:
elementName - The name of the element to search for.
Returns:
An Integer object containing the unique id of the element.

getElementIds

public final int[] getElementIds(java.lang.String[] elementNames)
Retrieves a list of unique identifiers for the elements with the specified names, or throws a NoSuchElementException when one of the specified elements does not exist.

Parameters:
elementNames - A String array containing names of elements defined within this schema.
Returns:
An int array containing the unique identifiers of the elements to retrieve.

getElementName

public final java.lang.String getElementName(int elementId)
Returns the name or tag of the element with the specified unique identifier.

Parameters:
elementId - The unique identifier of the element to search for.
Returns:
A String containing the name of the element.

hasElement

public final boolean hasElement(java.lang.String elementName)
Returns whether the schema has an element with the specified name.

Parameters:
elementName - The name of the element to look for.
Returns:
True when an element with the specified name was found, otherwise false.

hasElement

public final boolean hasElement(int elementId)
Returns whether the schema defines an element with the specified unique identifier.

Parameters:
elementId - The element identifier to search for.
Returns:
True when the schema defines an element with the specified unique identifier, otherwise false.

getElements

public final java.util.Map<java.lang.Integer,Element> getElements()
Returns the mapping of unique identifiers of elements to the actual Element objects.

Returns:
A Map containing the mapping for each of the elements.

getSchemes

public final java.util.Map<java.lang.Integer,Scheme> getSchemes()
Returns the mapping of unique identifiers of schemes to the actual Scheme objects.

Returns:
A Map containing the mapping for each of the schemes.

getObjectLocationElements

public final java.util.ArrayList<java.lang.Integer> getObjectLocationElements()
Returns the list of unique identifiers for the elements that specify the location of the digital object that accompanies MetadataObjects using this Schema.

Returns:
An ArrayList containing Integer objects holding the unique identifiers of each of the object location elements.

getTitleElement

public final int getTitleElement()
Returns the unique identifier of the element that makes up the title of a MetadataObject in this schema.

Returns:
An int containing the unique identifier of the element that contains the title.

getDescriptionElements

public final java.util.ArrayList<java.lang.Integer> getDescriptionElements()
Returns the list of elements that make up the description of a MetadataObject in this schema.

Returns:
An ArrayList containing the element identifiers of the elements that make up the title.

equals

public final boolean equals(java.lang.Object o)
Checks whether this Schema is equal to another Schema object and returns true when it is. A Schema is considered to be equal when all of the instance variables match each other except for the filename.

Overrides:
equals in class java.lang.Object
Parameters:
o - The Object to compare this Schema with.
Returns:
True when both Schema's are equal, otherwise false.

hashCode

public final int hashCode()
Calculates the hascode for this Schema object. This should always return the same value for two Schema objects that are the same.

Overrides:
hashCode in class java.lang.Object
Returns:
An int containing the hashcode for this Schema object.

getContentType

public final java.lang.String getContentType()
Returns the Content-Type that is used for Schema objects for transfer using SOAP.

Returns:
A String representing the Mimetype of the serialised form of a Schema object.

populateObject

public final void populateObject(byte[] serialisedObject)
                          throws DigitalObjectException
Recreates the Schema object based on the data contained in the supplied array of bytes.

Parameters:
serialisedObject - A byte array containing the serialised form of the Schema object.
Throws:
DigitalObjectException

serialiseObject

public final byte[] serialiseObject()
Creates a serialised form of the Schema object, which is really just a read of the schema file this Schema object was constructed from.

Returns:
A byte array containing the serialised data of the Schema object.


Copyright © 2004-2005 The Archaeological Computing Laboratory, University of Sydney. All Rights Reserved.