org.mycore.datamodel.metadata
Class MCRObjectService

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRObjectService

public class MCRObjectService
extends Object

This class implements all methode for handling one document service data. The service data are to use to handel the database with batch jobs automatical changes. The service class holds two types of data, dates and flags. The flags are text strings and are optional.

The dates are represent by a date and a type. Two types are in service data at every time and can't remove:

Other date types are optional, but as example in Dublin Core:

Version:
$Revision: 14870 $ $Date: 2009-03-13 12:15:22 +0100 (Fri, 13 Mar 2009) $
Author:
Jens Kupferschmidt, Matthias Eichner

Constructor Summary
MCRObjectService()
          This is the constructor of the MCRObjectService class.
 
Method Summary
 void addFlag(String value)
          This method add a flag to the flag list.
 void addFlag(String type, String value)
          This method adds a flag to the flag list.
 void addRule(String permission, Element condition)
          This method add a rule to the rules list.
 Element createXML()
          This method create a XML stream for all structure data.
 Date getDate(String type)
          This method get a date for a given type.
 int getDateSize()
          This method return the size of the date list.
 String getFlag(int index)
          This method get a single flag from the flag list as a string.
 int getFlagIndex(String value)
          This method returns the index for the given flag value.
 String getFlags()
          This method get all flags from the flag list as a string.
 ArrayList<String> getFlags(String type)
          This method returns all flag values of the specified type.
protected  ArrayList<MCRMetaLangText> getFlagsAsMCRMetaLangText(String type)
          This method returns all flag values of the specified type.
 int getFlagSize()
          This method return the size of the flag list.
 String getFlagType(int index)
          This method gets a single flag type from the flag list as a string.
 MCRMetaAccessRule getRule(int index)
          This method get a single rule from the rules list as a JDOM Element.
 int getRuleIndex(String permission)
          This method return the index of a permission in the rules list.
 String getRulePermission(int index)
          This method get a single permission name of rule from the rules list as a string.
 int getRulesSize()
          This method return the size of the rules list.
 boolean isFlagSet(String value)
          This method return a boolean value if the given flag is set or not.
 boolean isFlagTypeSet(String type)
          Proves if the type is set in the flag list.
 boolean isValid()
          This method check the validation of the content of this class.
 void removeFlag(int index)
          This method remove a flag from the flag list.
 void removeFlags(String type)
          This method removes all flags of the specified type from the flag list.
 void removeRule(int index)
          This method remove a rule from the rules list.
 void replaceFlag(int index, String value)
          This method set a flag in the flag list.
 void replaceFlagType(int index, String value)
          This method sets the type value of a flag at the specified index.
 void setDate(String type)
          This method set a date element in the dates list to a actual date value.
 void setDate(String type, Date date)
          This method set a date element in the dates list to a given date value.
 void setFromDOM(Element service_element)
          This method read the XML input stream part from a DOM part for the structure data of the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRObjectService

public MCRObjectService()
This is the constructor of the MCRObjectService class. All data are set to null.

Method Detail

setFromDOM

public final void setFromDOM(Element service_element)
This method read the XML input stream part from a DOM part for the structure data of the document.

Parameters:
service_element - a list of relevant DOM elements for the metadata

getDateSize

public final int getDateSize()
This method return the size of the date list.

Returns:
the size of the date list

getDate

public final Date getDate(String type)
This method get a date for a given type. If the type was not found, an null was returned.

Parameters:
type - the type of the date
Returns:
the date as GregorianCalendar

setDate

public final void setDate(String type)
This method set a date element in the dates list to a actual date value. If the given type exists, the date was update.

Parameters:
type - the type of the date

setDate

public final void setDate(String type,
                          Date date)
This method set a date element in the dates list to a given date value. If the given type exists, the date was update.

Parameters:
type - the type of the date
date - set time to this Calendar

addFlag

public final void addFlag(String value)
This method add a flag to the flag list.

Parameters:
value - - the new flag as string

addFlag

public final void addFlag(String type,
                          String value)
This method adds a flag to the flag list.

Parameters:
type - a type as string
value - the new flag value as string

getFlags

public final String getFlags()
This method get all flags from the flag list as a string.

Returns:
the flags string

getFlagsAsMCRMetaLangText

protected final ArrayList<MCRMetaLangText> getFlagsAsMCRMetaLangText(String type)
This method returns all flag values of the specified type.

Parameters:
type - a type as string.
Returns:
a list of flag values

getFlags

public final ArrayList<String> getFlags(String type)
This method returns all flag values of the specified type.

Parameters:
type - a type as string.
Returns:
a list of flag values

getFlagSize

public final int getFlagSize()
This method return the size of the flag list.

Returns:
the size of the flag list

getFlag

public final String getFlag(int index)
                     throws IndexOutOfBoundsException
This method get a single flag from the flag list as a string.

Returns:
a flag string
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

getFlagType

public final String getFlagType(int index)
                         throws IndexOutOfBoundsException
This method gets a single flag type from the flag list as a string.

Returns:
a flag type
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

isFlagSet

public final boolean isFlagSet(String value)
This method return a boolean value if the given flag is set or not.

Parameters:
value - a searched flag
Returns:
true if the flag was found in the list

isFlagTypeSet

public final boolean isFlagTypeSet(String type)
Proves if the type is set in the flag list.

Parameters:
type - a type as string
Returns:
true if the flag list contains flags with this type, otherwise false

removeFlag

public final void removeFlag(int index)
                      throws IndexOutOfBoundsException
This method remove a flag from the flag list.

Parameters:
index - a index in the list
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

removeFlags

public final void removeFlags(String type)
This method removes all flags of the specified type from the flag list.

Parameters:
type - a type as string

replaceFlag

public final void replaceFlag(int index,
                              String value)
                       throws IndexOutOfBoundsException
This method set a flag in the flag list.

Parameters:
index - a index in the list
value - the value of a flag as string
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

replaceFlagType

public final void replaceFlagType(int index,
                                  String value)
                           throws IndexOutOfBoundsException
This method sets the type value of a flag at the specified index.

Parameters:
index - a index in the list
value - the value of a flag as string
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

addRule

public final void addRule(String permission,
                          Element condition)
This method add a rule to the rules list.

Parameters:
permission - - the new permission as string
condition - - the new rule as JDOM tree Element

getRulesSize

public final int getRulesSize()
This method return the size of the rules list.

Returns:
the size of the rules list

getRuleIndex

public final int getRuleIndex(String permission)
This method return the index of a permission in the rules list.

Returns:
the index of a permission in the rules list

getRule

public final MCRMetaAccessRule getRule(int index)
                                throws IndexOutOfBoundsException
This method get a single rule from the rules list as a JDOM Element.

Returns:
a the MCRMetaAccessRule instance
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

getRulePermission

public final String getRulePermission(int index)
                               throws IndexOutOfBoundsException
This method get a single permission name of rule from the rules list as a string.

Returns:
a rule permission string
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

removeRule

public final void removeRule(int index)
                      throws IndexOutOfBoundsException
This method remove a rule from the rules list.

Parameters:
index - a index in the list
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

createXML

public final Element createXML()
                        throws MCRException
This method create a XML stream for all structure data.

Returns:
a JDOM Element with the XML data of the structure data part
Throws:
MCRException - if the content of this class is not valid

isValid

public final boolean isValid()
This method check the validation of the content of this class. The method returns true if otherwise the method return false

Returns:
a boolean value

getFlagIndex

public final int getFlagIndex(String value)
This method returns the index for the given flag value.

Parameters:
value - the value of a flag as string
Returns:
the index number or -1 if the value was not found