gate.creole
Class AnnotationSchema

java.lang.Object
  |
  +--gate.util.AbstractFeatureBearer
        |
        +--gate.creole.AbstractResource
              |
              +--gate.creole.AbstractLanguageResource
                    |
                    +--gate.creole.AnnotationSchema
All Implemented Interfaces:
FeatureBearer, LanguageResource, Resource, Serializable

public class AnnotationSchema
extends AbstractLanguageResource

This class handles annotation schemas.An annotation schema is a representation of an annotation, together with its types and their attributes, values and types.

See Also:
Serialized Form

Field Summary
protected  String annotationName
          The name of the annotation
private static boolean DEBUG
          Debug flag
protected  Set featureSchemaSet
          Schemas for the attributes
private static Map java2xSchemaMap
          A map between JAva types and XSchema
protected  URL xmlFileUrl
          The xml file URL of the resource
private static javax.xml.parsers.DocumentBuilder xmlParser
          Parser for the XSchema source files
private static Map xSchema2JavaMap
          A map between XSchema types and Java Types
 
Fields inherited from class gate.creole.AbstractLanguageResource
dataStore, serialVersionUID
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Constructor Summary
AnnotationSchema()
          Constructs an annotation schema.
 
Method Summary
private  org.jdom.Document buildJdomFromDom(org.w3c.dom.Document aDom)
          This method builds a JDom structure from a W3C Dom one.Of course that can be considered a waist of time, but a JDOM structure is more flexible than a DOM one.
 void createAndAddFeatureSchemaObject(org.jdom.Element anAttributeElement)
          This method creates and adds a FeatureSchema object to the current AnnotationSchema one.
private  void createAnnotationSchemaObject(org.jdom.Element anElement)
          This method creates an AnnotationSchema object fom an org.jdom.Element
 void fromXSchema(InputStream anXSchemaInputStream)
          Creates an AnnotationSchema object from an XSchema file
 void fromXSchema(URL anXSchemaURL)
          Creates an AnnotationSchema object from an XSchema file
 String getAnnotationName()
          Returns the value of annotation name
 FeatureSchema getFeatureSchema(String featureName)
           
 Set getFeatureSchemaSet()
          Returns the feature schema set
 URL getXmlFileUrl()
          Get method for the resource xml file URL
 Resource init()
          Initialise this resource, and return it.
 void setAnnotationName(String annotationName)
          Sets the annotation name
 void setFeatureSchemaSet(Set featureSchemaSet)
          Sets the feature schema set
private static void setUpStaticData()
          This sets up two Maps between XSchema types and their coresponding Java types + a DOM xml parser
 void setXmlFileUrl(URL xmlFileUrl)
          Set method for the resource xml file URL
 String toXSchema()
           
private  void workWithJDom(org.jdom.Document jDom)
          This method uses the JDom structure for our XSchema needs.
 
Methods inherited from class gate.creole.AbstractLanguageResource
getDataStore, setDataStore, sync
 
Methods inherited from class gate.creole.AbstractResource
getName, setName
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, getName, setFeatures, setName
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

xSchema2JavaMap

private static Map xSchema2JavaMap
A map between XSchema types and Java Types

java2xSchemaMap

private static Map java2xSchemaMap
A map between JAva types and XSchema

xmlParser

private static javax.xml.parsers.DocumentBuilder xmlParser
Parser for the XSchema source files

annotationName

protected String annotationName
The name of the annotation

featureSchemaSet

protected Set featureSchemaSet
Schemas for the attributes

xmlFileUrl

protected URL xmlFileUrl
The xml file URL of the resource
Constructor Detail

AnnotationSchema

public AnnotationSchema()
Constructs an annotation schema.
Method Detail

setUpStaticData

private static void setUpStaticData()
                             throws ResourceInstantiationException
This sets up two Maps between XSchema types and their coresponding Java types + a DOM xml parser

getAnnotationName

public String getAnnotationName()
Returns the value of annotation name

setAnnotationName

public void setAnnotationName(String annotationName)
Sets the annotation name

getFeatureSchemaSet

public Set getFeatureSchemaSet()
Returns the feature schema set

setFeatureSchemaSet

public void setFeatureSchemaSet(Set featureSchemaSet)
Sets the feature schema set

getFeatureSchema

public FeatureSchema getFeatureSchema(String featureName)
Returns:
a FeatureSchema object from featureSchemaSet, given a feature name.It will return null if the feature name is not found.

init

public Resource init()
              throws ResourceInstantiationException
Initialise this resource, and return it. If the schema XML source file URL has been set, it will construct itself from that file.
Overrides:
init in class AbstractResource

setXmlFileUrl

public void setXmlFileUrl(URL xmlFileUrl)
Set method for the resource xml file URL

getXmlFileUrl

public URL getXmlFileUrl()
Get method for the resource xml file URL

fromXSchema

public void fromXSchema(URL anXSchemaURL)
                 throws ResourceInstantiationException
Creates an AnnotationSchema object from an XSchema file
Parameters:
anXSchemaURL - the URL where to find the XSchema file

fromXSchema

public void fromXSchema(InputStream anXSchemaInputStream)
                 throws ResourceInstantiationException
Creates an AnnotationSchema object from an XSchema file
Parameters:
anXSchemaInputStream - the Input Stream containing the XSchema file

buildJdomFromDom

private org.jdom.Document buildJdomFromDom(org.w3c.dom.Document aDom)
This method builds a JDom structure from a W3C Dom one.Of course that can be considered a waist of time, but a JDOM structure is more flexible than a DOM one.
Parameters:
aDom - W3C dom structure
Returns:
Document

workWithJDom

private void workWithJDom(org.jdom.Document jDom)
This method uses the JDom structure for our XSchema needs. What it does is to add semantics to the XML elements defined in XSchema. In the end we need to construct an AnnotationSchema object form an XSchema file.
Parameters:
jDom - the JDOM structure containing the XSchema document. It must not be null

createAnnotationSchemaObject

private void createAnnotationSchemaObject(org.jdom.Element anElement)
This method creates an AnnotationSchema object fom an org.jdom.Element
Parameters:
anElement - is an XSchema element element

createAndAddFeatureSchemaObject

public void createAndAddFeatureSchemaObject(org.jdom.Element anAttributeElement)
This method creates and adds a FeatureSchema object to the current AnnotationSchema one.
Parameters:
anElement - is an XSchema attribute element

toXSchema

public String toXSchema()
Returns:
a String containing the XSchema document representing an AnnotationSchema object.