COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification

org.eclipse.cosmos.rm.validation.internal.databuilders
Class AbstractDataBuilder

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.eclipse.cosmos.rm.validation.internal.databuilders.AbstractDataBuilder
All Implemented Interfaces:
IDataBuilder, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
AbstractPropertyExtractor, DocumentDOMBuilder, ElementSchematronCacheBuilder, ElementSourceBuilder, ElementTypeMapDataBuilder, IdentityConstraintDataBuilder, IdentityDataBuilder, NamespaceContextBuilder, ReferenceExtractor, ReferenceGraphDataBuilder, RootElementAliasLookupBuilder, SMLValidatingBuilder, TargetInstanceBuilder, TargetSchemaBuilder, TypeInheritanceDataBuilderImpl

public abstract class AbstractDataBuilder
extends org.xml.sax.helpers.DefaultHandler
implements IDataBuilder

Abstract class that provides a default implementation of the IDataBuilder interface.


Field Summary
protected  org.xml.sax.Locator locator
          Stores line and column information
 
Constructor Summary
AbstractDataBuilder()
          Constructor
 
Method Summary
protected  void appendToErrorMessage(java.lang.String error)
          Appends to the error message
 void comment(char[] cs, int i, int j)
           
 void endDefinitions()
          This method will be called when the parser ends parsing the definitions part of the document
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void endInstances()
          This method will be called when the parser ends parsing the instances part of the document
 byte getCurrentPhase()
           
 java.lang.String getDefaultNamespace()
           
 IValidationMessage getErrorMessage()
          Returns the error message set.
 java.lang.String getFilePath()
          Retrieves the path of the current file being processed
 byte getPhase()
          Specifies the phase that this data builder is active during parsing.
 java.util.Map getPrefixMap()
           
 java.lang.String getTargetNamespace()
           
 boolean isStructureValid()
          Returns true if this structure is valid.
 void setDefaultNamespace(java.lang.String defaultNamespace)
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void setErrorMessage(IValidationMessage error)
          Sets an error message in case the structure is not valid
 void setFilePath(java.lang.String filePath)
          Sets the path of the current file being processed
 void setPrefixMap(java.util.Map prefix)
           
 void setStructureValidity(boolean validity)
          Sets the structure validity
 void setTargetNamespace(java.lang.String targetNamespace)
           
 void startDefinitions()
          This method will be called when the parser starts parsing the definition part of the document
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          This is used to determine the target name space of the document currently being parsed
 void startInstances()
          This method will be called when the parser starts parsing the instances part of the document
protected  java.lang.String[] tokenizeName(java.lang.String qName)
          A helper method used to tokenize a qualified name into its prefix and local name.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.cosmos.rm.validation.internal.databuilders.IDataBuilder
getDataStructure
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 

Field Detail

locator

protected org.xml.sax.Locator locator
Stores line and column information

Constructor Detail

AbstractDataBuilder

public AbstractDataBuilder()
Constructor

Method Detail

endDefinitions

public void endDefinitions()
Description copied from interface: IDataBuilder
This method will be called when the parser ends parsing the definitions part of the document

Specified by:
endDefinitions in interface IDataBuilder
See Also:
IDataBuilder.endDefinitions()

endInstances

public void endInstances()
Description copied from interface: IDataBuilder
This method will be called when the parser ends parsing the instances part of the document

Specified by:
endInstances in interface IDataBuilder
See Also:
IDataBuilder.endInstances()

getPhase

public byte getPhase()
Description copied from interface: IDataBuilder
Specifies the phase that this data builder is active during parsing. The parser parses the sml document in two parts: Definitions and Instances phases. The valid values are as follows:
 ISMLConstants.DEFINITIONS_PHASE -databuilder is active during the parsing of the definitions elements
 ISMLConstants.INSTANCES_PHASE -databuilder is active during the parsing of the instances elements
 ISMLConstants.DEFINITIONS_INSTANCES_PHASE - databuilder is active during the parsing of the definitions and instances elements
 

Specified by:
getPhase in interface IDataBuilder
Returns:
a phase that this databuilder will be active
See Also:
IDataBuilder.getPhase()

startDefinitions

public void startDefinitions()
Description copied from interface: IDataBuilder
This method will be called when the parser starts parsing the definition part of the document

Specified by:
startDefinitions in interface IDataBuilder
See Also:
IDataBuilder.startDefinitions()

startInstances

public void startInstances()
Description copied from interface: IDataBuilder
This method will be called when the parser starts parsing the instances part of the document

Specified by:
startInstances in interface IDataBuilder
See Also:
IDataBuilder.startInstances()

getCurrentPhase

public byte getCurrentPhase()
Returns:
the currentPhase

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
This is used to determine the target name space of the document currently being parsed

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
See Also:
DefaultHandler.setDocumentLocator(org.xml.sax.Locator)

isStructureValid

public boolean isStructureValid()
Description copied from interface: IDataBuilder
Returns true if this structure is valid. An error message is usually set if this method returns false.

Specified by:
isStructureValid in interface IDataBuilder
See Also:
IDataBuilder.isStructureValid()

setStructureValidity

public void setStructureValidity(boolean validity)
Description copied from interface: IDataBuilder
Sets the structure validity

Specified by:
setStructureValidity in interface IDataBuilder
Parameters:
validity - The validity of the structure
See Also:
IDataBuilder.setStructureValidity(boolean)

getErrorMessage

public IValidationMessage getErrorMessage()
Description copied from interface: IDataBuilder
Returns the error message set. This value can be null if no error message has been set.

Specified by:
getErrorMessage in interface IDataBuilder
Returns:
The error message
See Also:
IDataBuilder.getErrorMessage()

setErrorMessage

public void setErrorMessage(IValidationMessage error)
Description copied from interface: IDataBuilder
Sets an error message in case the structure is not valid

Specified by:
setErrorMessage in interface IDataBuilder
See Also:
org.eclipse.cosmos.rm.validation.internal.databuilders.IDataBuilder#setErrorMessage(java.lang.String)

appendToErrorMessage

protected void appendToErrorMessage(java.lang.String error)
Appends to the error message

Parameters:
error - The error, which is appended as a separate line

getPrefixMap

public java.util.Map getPrefixMap()
Returns:
the prefix

setPrefixMap

public void setPrefixMap(java.util.Map prefix)
Parameters:
prefix - the prefix to set

getTargetNamespace

public java.lang.String getTargetNamespace()
Returns:
the targetNamespace

setTargetNamespace

public void setTargetNamespace(java.lang.String targetNamespace)
Parameters:
targetNamespace - the targetNamespace to set

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Returns:
the defaultNamespace

setDefaultNamespace

public void setDefaultNamespace(java.lang.String defaultNamespace)
Parameters:
defaultNamespace - the defaultNamespace to set

tokenizeName

protected java.lang.String[] tokenizeName(java.lang.String qName)
A helper method used to tokenize a qualified name into its prefix and local name. A string array of size 2 is returned, where String[0] = prefix or empty string if no prefix is found and String[1] = local name

Parameters:
qName - The qualified name of an element/attribute
Returns:
The prefix and local name tokens of the qualified name

setFilePath

public void setFilePath(java.lang.String filePath)
Sets the path of the current file being processed

Specified by:
setFilePath in interface IDataBuilder
Parameters:
filePath - The path

getFilePath

public java.lang.String getFilePath()
Description copied from interface: IDataBuilder
Retrieves the path of the current file being processed

Specified by:
getFilePath in interface IDataBuilder
Returns:
The path of the file being processed
See Also:
IDataBuilder.getFilePath()

comment

public void comment(char[] cs,
                    int i,
                    int j)

COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification