Top Description Inners Fields Constructors Methods
com.sun.msv.reader.trex.classic

public Class TREXGrammarReader

extends TREXBaseReader
implements XSDatatypeResolver
Class Inheritance
All Implemented Interfaces
com.sun.msv.reader.datatype.xsd.XSDatatypeResolver
Imports
java.text.MessageFormat, java.util.ResourceBundle, javax.xml.parsers.SAXParserFactory, org.relaxng.datatype.Datatype, .DatatypeException, org.xml.sax.InputSource, com.sun.msv.datatype.xsd.StringType, .XSDatatype, com.sun.msv.grammar.Expression, .ExpressionPool, com.sun.msv.grammar.trex.TREXGrammar, com.sun.msv.reader.GrammarReaderController, .IgnoreState, .RunAwayExpressionChecker, .State, .TerminalState, com.sun.msv.reader.datatype.DataTypeVocabulary, com.sun.msv.reader.datatype.xsd.XSDatatypeExp, .XSDatatypeResolver, com.sun.msv.reader.trex.IncludePatternState, .RootState, .TREXBaseReader, .TREXSequencedStringChecker, com.sun.msv.util.StartTagInfo

reads TREX grammar from SAX2 and constructs abstract grammar model.
Author
Kohsuke KAWAGUCHI

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TREXGrammarReader.StateFactory

creates various State object, which in turn parses grammar.

private static class
TREXGrammarReader.UndefinedDataTypeVocabulary

Dummy DataTypeVocabulary for better error recovery.

Field Summary

Modifier and TypeField and Description
protected String
currentGrammarURI

TREX allows either (1) the predefined namespace for TREX or (2) default namespace "" as its namespace.

private boolean
public static final String
TREXNamespace

Namespace URI of TREX

Inherited from com.sun.msv.reader.trex.TREXBaseReader:
ERR_BAD_COMBINEERR_COMBINE_MISSINGERR_DUPLICATE_DEFINITIONERR_INTERLEAVED_ANYSTRINGERR_INTERLEAVED_STRINGERR_MISSING_CHILD_NAMECLASSERR_MORE_THAN_ONE_NAMECLASSERR_NONEXISTENT_PARENT_GRAMMARERR_REPEATED_STRINGERR_SEQUENCED_STRINGERR_UNDECLARED_PREFIXERR_UNDEFINED_PATTERNERR_UNKNOWN_DATATYPE_VOCABULARYgrammarsfactorytargetNamespaceWRN_COMBINE_IGNOREDWRN_OBSOLETED_XMLSCHEMA_NAMSPACE

Constructor Summary

AccessConstructor and Description
public
TREXGrammarReader(GrammarReaderController controller)

easy-to-use constructor.

public
TREXGrammarReader(GrammarReaderController controller, SAXParserFactory parserFactory, ExpressionPool pool)

easy-to-use constructor.

public
TREXGrammarReader(GrammarReaderController controller, SAXParserFactory parserFactory, TREXGrammarReader.StateFactory stateFactory, ExpressionPool pool)

full constructor

Method Summary

Modifier and TypeMethod and Description
public State
createExpressionChildState(State parent, StartTagInfo tag)

Overrides com.sun.msv.reader.trex.TREXBaseReader.createExpressionChildState.

this method must be implemented by the derived class to create language-default expresion state.
protected TREXGrammar
protected TREXGrammarReader.StateFactory
protected boolean
isGrammarElement(StartTagInfo tag)

Implements abstract com.sun.msv.reader.GrammarReader.isGrammarElement.

checks if given element is that of the grammar elements.
protected String
localizeMessage(String propertyName, Object[] args)

Overrides com.sun.msv.reader.trex.TREXBaseReader.localizeMessage.

formats localized message with arguments
private String
mapNamespace(String namespace)

maps obsoleted XML Schema namespace to the current one.

public static TREXGrammar
parse(String grammarURL, SAXParserFactory factory, GrammarReaderController controller)

loads TREX pattern

public static TREXGrammar
parse(InputSource grammar, SAXParserFactory factory, GrammarReaderController controller)

loads TREX pattern

public Datatype
resolveDatatype(String qName)

obtains a named DataType object referenced by a QName.

public XSDatatypeExp
resolveXSDatatype(String
The type of this value varies in the schema language. In XML Schema, for example, in which QNames are used to designate datatypes, this parameter will be QName. In RELAX Core, in which the same syntax is used but NCName is used to designate datatypes. So this parameter will be NCName.
qName
)

Implements com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

public void
wrapUp()

Overrides com.sun.msv.reader.trex.TREXBaseReader.wrapUp.

performs final wrap-up.
Inherited from com.sun.msv.reader.trex.TREXBaseReader:
createNameClassChildStateendElementgetResultgetResultAsGrammargetTargetNamespacestartElement

Field Detail

currentGrammarURIback to summary
protected String currentGrammarURI

TREX allows either (1) the predefined namespace for TREX or (2) default namespace "" as its namespace. This variable holds which namespace is currently in use.

issueObsoletedXMLSchemaNamespaceback to summary
private boolean issueObsoletedXMLSchemaNamespace
TREXNamespaceback to summary
public static final String TREXNamespace

Namespace URI of TREX

Constructor Detail

TREXGrammarReaderback to summary
public TREXGrammarReader(GrammarReaderController controller)

easy-to-use constructor.

TREXGrammarReaderback to summary
public TREXGrammarReader(GrammarReaderController controller, SAXParserFactory parserFactory, ExpressionPool pool)

easy-to-use constructor.

TREXGrammarReaderback to summary
public TREXGrammarReader(GrammarReaderController controller, SAXParserFactory parserFactory, TREXGrammarReader.StateFactory stateFactory, ExpressionPool pool)

full constructor

Method Detail

createExpressionChildStateback to summary
public State createExpressionChildState(State parent, StartTagInfo tag)

Overrides com.sun.msv.reader.trex.TREXBaseReader.createExpressionChildState.

Doc from com.sun.msv.reader.GrammarReader.createExpressionChildState.

this method must be implemented by the derived class to create language-default expresion state.

Returns:State

null if the start tag is an error.

getGrammarback to summary
protected TREXGrammar getGrammar()
getStateFactoryback to summary
protected TREXGrammarReader.StateFactory getStateFactory()
isGrammarElementback to summary
protected boolean isGrammarElement(StartTagInfo tag)

Implements abstract com.sun.msv.reader.GrammarReader.isGrammarElement.

Doc from com.sun.msv.reader.GrammarReader.isGrammarElement.

checks if given element is that of the grammar elements.

localizeMessageback to summary
protected String localizeMessage(String propertyName, Object[] args)

Overrides com.sun.msv.reader.trex.TREXBaseReader.localizeMessage.

Doc from com.sun.msv.reader.GrammarReader.localizeMessage.

formats localized message with arguments

mapNamespaceback to summary
private String mapNamespace(String namespace)

maps obsoleted XML Schema namespace to the current one.

parseback to summary
public static TREXGrammar parse(String grammarURL, SAXParserFactory factory, GrammarReaderController controller)

loads TREX pattern

parseback to summary
public static TREXGrammar parse(InputSource grammar, SAXParserFactory factory, GrammarReaderController controller)

loads TREX pattern

resolveDatatypeback to summary
public Datatype resolveDatatype(String qName)

obtains a named DataType object referenced by a QName.

resolveXSDatatypeback to summary
public XSDatatypeExp resolveXSDatatype(String qName)

Implements com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

Parameters
qName:String

Doc from com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

The type of this value varies in the schema language. In XML Schema, for example, in which QNames are used to designate datatypes, this parameter will be QName. In RELAX Core, in which the same syntax is used but NCName is used to designate datatypes. So this parameter will be NCName.

Returns:XSDatatypeExp

Doc from com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

A non-null valid object. An error should be reported and recovered by the callee.

wrapUpback to summary
public void wrapUp()

Overrides com.sun.msv.reader.trex.TREXBaseReader.wrapUp.

Doc from com.sun.msv.reader.trex.TREXBaseReader.wrapUp.

performs final wrap-up. This method is called from the RootState object, after the parsing is completed.

This method has to be called after the run-away expression check is done.

com.sun.msv.reader.trex.classic back to summary

public Class TREXGrammarReader.StateFactory

extends StateFactory
Class Inheritance
Known Direct Subclasses
com.sun.msv.reader.trex.typed.TypedTREXGrammarInterceptor

creates various State object, which in turn parses grammar. parsing behavior can be customized by implementing custom StateFactory.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public State
public State
concur(State parent, StartTagInfo tag)

public State
data(State parent, StartTagInfo tag)

public State
public State
public State
string(State parent, StartTagInfo tag)

Inherited from com.sun.msv.reader.trex.TREXBaseReader.StateFactory:
attributechoicecreateGrammardivInGrammarelementemptygrammargroupincludedGrammarincludeGrammarinterleavemixednotAllowednsAnyNamensChoicensDifferencensNamensNotnsNsNameoneOrMoreoptionalrefstartzeroOrMore

Constructor Detail

StateFactoryback to summary
public StateFactory()

Method Detail

anyStringback to summary
public State anyString(State parent, StartTagInfo tag)
concurback to summary
public State concur(State parent, StartTagInfo tag)
databack to summary
public State data(State parent, StartTagInfo tag)
defineback to summary
public State define(State parent, StartTagInfo tag)

Implements abstract com.sun.msv.reader.trex.TREXBaseReader.StateFactory.define.

includePatternback to summary
public State includePattern(State parent, StartTagInfo tag)
stringback to summary
public State string(State parent, StartTagInfo tag)
com.sun.msv.reader.trex.classic back to summary

private Class TREXGrammarReader.UndefinedDataTypeVocabulary

extends Object
implements DataTypeVocabulary
Class Inheritance
  • java.lang.Object
  • com.sun.msv.reader.trex.classic.TREXGrammarReader.UndefinedDataTypeVocabulary
All Implemented Interfaces
com.sun.msv.reader.datatype.DataTypeVocabulary

Dummy DataTypeVocabulary for better error recovery. If DataTypeVocabulary is not found, the error is reported and this class is used to prevent further repetitive error messages.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public State
createTopLevelReaderState(StartTagInfo tag)

Implements com.sun.msv.reader.datatype.DataTypeVocabulary.createTopLevelReaderState.

creates a State object that will parse the element specified by tag parameter.
public Datatype
getType(String
local part of the qualified name, like "string" or "integer". prefix part must be removed by the caller.
localTypeName
)

Implements com.sun.msv.reader.datatype.DataTypeVocabulary.getType.

resolves a type name to Datatype object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UndefinedDataTypeVocabularyback to summary
private UndefinedDataTypeVocabulary()

Method Detail

createTopLevelReaderStateback to summary
public State createTopLevelReaderState(StartTagInfo tag)

Implements com.sun.msv.reader.datatype.DataTypeVocabulary.createTopLevelReaderState.

Doc from com.sun.msv.reader.datatype.DataTypeVocabulary.createTopLevelReaderState.

creates a State object that will parse the element specified by tag parameter.

Returns:State

null if given start tag is not recognized by this object. This method is called when an "island" of this vocabulary was found. The state returned from this method will be used to parse the root element of this island. The parent state of this state must implement TypeOwner or ExpressionOwner. In either case, the implementation must report its parsing result by calling either interface. If both interface is implemented, the implementation must notify via TypeOwner interface only and may not call methods of ExpressionOwner. If the parsed island is not a type definition (for example, comments or inclusion), the implementation may not call TypeOwner nor ExpressionOwner.

getTypeback to summary
public Datatype getType(String localTypeName)

Implements com.sun.msv.reader.datatype.DataTypeVocabulary.getType.

Doc from com.sun.msv.reader.datatype.DataTypeVocabulary.getType.

resolves a type name to Datatype object.

Parameters
localTypeName:String

local part of the qualified name, like "string" or "integer". prefix part must be removed by the caller.

Returns:Datatype

a non-null valid datatype object.