biz.c24.io.api.data
Class SourcedEnumeration

java.lang.Object
  extended by biz.c24.io.api.data.SourcedEnumeration
All Implemented Interfaces:
Enumeration, ModelComponent, Validator, Serializable
Direct Known Subclasses:
DatabaseSourcedEnumeration, URISourcedEnumeration

public abstract class SourcedEnumeration
extends Object
implements Enumeration

An enumeration sourced from an external repository of static data such as a file, url, database.

See Also:
Serialized Form

Constructor Summary
SourcedEnumeration(String rootClassName, Source source, XPathStatement xpath, boolean trim, ClassLoader classLoader)
          Creates a new instance.
 
Method Summary
 Annotation getAnnotation()
          Returns the annotation associated with this enumeration.
 Annotation getAnnotation(int index)
          Returns the annotation associated with the enumeration value at index.
 ClassLoader getClassLoader()
          Returns the class loader used to load the root element.
 int getCount()
          Returns the number of enumeration values.
 int getIndex(String value)
          Returns the first index of value or -1 if it was not found.
 String getName()
          Returns the name of this component.
 String getName(int index)
          Returns the name associated with the enumeration value at index.
 String getRootClassName()
          Returns the root class name.
 Source getSource()
          Returns the source used to load the objects.
 String getValue(int index)
          Returns the enumeration value at index.
 XPathStatement getXPath()
          Returns the xpath statement used to select the enumeration data.
 void init()
          Forcibly attempt to re-initalize.
 boolean isErrored()
          Returns whether the initialization of the underlying enumeration has errored In which case it re-initialization must be done maunally via the init() method.
 boolean isInitialized()
          Returns whether the underlying eunmeration has been loaded.
 boolean isTrim()
          Returns whether enuemration values will have whitespace removed.
 String toString()
           
 boolean validate(Object object, DataComponent component, ComplexDataObject context, ValidationManager manager)
          Validate the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface biz.c24.io.api.data.Enumeration
getErrorCode
 

Constructor Detail

SourcedEnumeration

public SourcedEnumeration(String rootClassName,
                          Source source,
                          XPathStatement xpath,
                          boolean trim,
                          ClassLoader classLoader)
Creates a new instance.

Parameters:
rootClassName - The class name of the root element / type.
source - The source to be used to parse the data.
xpath - The xpath to select the values used for the enumeration.
trim - Whether to trim whitespace from the returned values.
classLoader - The class loader to use to load the root class.
Method Detail

isInitialized

public boolean isInitialized()
Returns whether the underlying eunmeration has been loaded.

Returns:
Whether this enumeration is initialized.

isErrored

public boolean isErrored()
Returns whether the initialization of the underlying enumeration has errored

In which case it re-initialization must be done maunally via the init() method.

Returns:
Whether this enumeration has errored.

init

public void init()
          throws FactoryException
Forcibly attempt to re-initalize.

Throws:
FactoryException - If the re-initialization failed.

validate

public boolean validate(Object object,
                        DataComponent component,
                        ComplexDataObject context,
                        ValidationManager manager)
                 throws ValidationException
Description copied from interface: Validator
Validate the given object.

Specified by:
validate in interface Validator
Parameters:
object - The object to be validated - commonly a String, Integer, Double, Date etc.
component - The Element or Attribute inside context which defines object.
context - The parent of object - could be null.
manager - The validation manager which is performing this validation.
Returns:
Whether the object is valid if the validation manager is not operating in exception mode.
Throws:
ValidationException - If the object is not valid and the validation maanger is operating in exception mode.

getRootClassName

public String getRootClassName()
Returns the root class name.

Returns:
The class name.

getClassLoader

public ClassLoader getClassLoader()
Returns the class loader used to load the root element.

Returns:
The class loader.

getSource

public Source getSource()
Returns the source used to load the objects.

Returns:
The source.

isTrim

public boolean isTrim()
Returns whether enuemration values will have whitespace removed.

Returns:
Whether trimming is enabled.

getXPath

public XPathStatement getXPath()
Returns the xpath statement used to select the enumeration data.

Returns:
The xpath statement.

getAnnotation

public Annotation getAnnotation()
Description copied from interface: Enumeration
Returns the annotation associated with this enumeration.

Specified by:
getAnnotation in interface Enumeration
Returns:
The annotation

getIndex

public int getIndex(String value)
Description copied from interface: Enumeration
Returns the first index of value or -1 if it was not found.

Specified by:
getIndex in interface Enumeration
Parameters:
value - The value to look for.
Returns:
The index of the first occurance of value or -1 if it was not found.

getCount

public int getCount()
Description copied from interface: Enumeration
Returns the number of enumeration values.

Specified by:
getCount in interface Enumeration
Returns:
The number of values.

getValue

public String getValue(int index)
Description copied from interface: Enumeration
Returns the enumeration value at index.

Specified by:
getValue in interface Enumeration
Parameters:
index - The index of the value to return.
Returns:
The value at index.

getName

public String getName(int index)
Description copied from interface: Enumeration
Returns the name associated with the enumeration value at index.

Specified by:
getName in interface Enumeration
Parameters:
index - The index of the name to return.
Returns:
The name at index.

getAnnotation

public Annotation getAnnotation(int index)
Description copied from interface: Enumeration
Returns the annotation associated with the enumeration value at index.

Specified by:
getAnnotation in interface Enumeration
Parameters:
index - The index of the annotation to return.
Returns:
The name at index.

getName

public String getName()
Description copied from interface: ModelComponent
Returns the name of this component.

Specified by:
getName in interface ModelComponent
Returns:
The name.

toString

public String toString()
Overrides:
toString in class Object


C24 Technologies © 2002-2012: All Rights Reserved.