project35.mda.schema
Class MsvSchemaReader

java.lang.Object
  extended by project35.mda.schema.MsvSchemaReader
All Implemented Interfaces:
com.sun.msv.grammar.ExpressionVisitorVoid, SchemaReaderInterface

public class MsvSchemaReader
extends java.lang.Object
implements SchemaReaderInterface, com.sun.msv.grammar.ExpressionVisitorVoid

Implementation of the SchemaReaderInterface based upon Sun's Multi Schema Validator (MSV). This class was written by Kai Runte, who helped vastly improve the old schema reader originally used by Project35.


Copyright (c) 2008 Kevin Garwood for Project35. The original code was developed by Kai Runte for the University of Manchester. Revisions have been made for Project35, a project that is independent of that institution. This code is licensed under the Academic Free License version 3.0. The code attribution for the original code is included here:

Copyright (c) Kai Runte and University of Manchester 2007. All rights reserved. Licensed under the Academic Free License version 3.0. For more information on the terms and conditions, please see the file "LICENSE" that is included in this distribution.


Version:
1.0
Author:
Kai Runte

Nested Class Summary
static class MsvSchemaReader.BooleanFieldModelFactory
          Factory for BooleanFieldModel.
static interface MsvSchemaReader.BoundedDataFieldModelFactory
          Factory for bounded (numeric) DataFieldModel.
static class MsvSchemaReader.BoundedDoubleFieldModelFactory
          Factory for bounded DataFieldModel containing Double.
static class MsvSchemaReader.BoundedFloatFieldModelFactory
          Factory for bounded DataFieldModel containing Float.
static class MsvSchemaReader.BoundedIntegerFieldModelFactory
          Factory for bounded DataFieldModel containing Integer.
static interface MsvSchemaReader.DataFieldModelFactory
          Each implementation of this interface returns a certain type of DataFieldModel.
static class MsvSchemaReader.IdFieldModelFactory
          Factory for IDFieldModel.
static class MsvSchemaReader.IdrefsFieldModelFactory
          Factory for ListFieldModel containing references to IDFieldModel.
static class MsvSchemaReader.TextFieldModelFactory
          Factory for TextFieldModel.
static class MsvSchemaReader.ValidatedEditFieldModelFactory
          Factory for a validated EditFieldModel.
static class MsvSchemaReader.ValidatedTextFieldModelFactory
          Factory for a validated TextFieldModel.
 
Constructor Summary
MsvSchemaReader(Project35ApplicationContext project35ApplicationContext)
          Constructor.
 
Method Summary
 Project35ConfigurationReader getConfigurationReader()
          gets the configuration file reader
 RecordModelFactory getRecordModelFactory()
          Returns the record structures created from reading the schema
 RecordModel getTopLevelRecord()
           
 java.util.List getWarnings()
          Returns the warnings created by parsed schema.
 boolean hasWarnings()
          Returns whether the parsed schema created any warnings.
 void initialiseConfigurationReader(java.io.InputStream mainConfigurationStream, java.net.URL documentDirectory, java.net.URL resourceDirectory, java.io.InputStream extensionLauncherStream, java.io.File sessionFile)
          Initialises the configuration of the schema reader.
 void onAnyString()
           
 void onAttribute(com.sun.msv.grammar.AttributeExp attributeExp)
           
 void onChoice(com.sun.msv.grammar.ChoiceExp choiceExp)
           
 void onConcur(com.sun.msv.grammar.ConcurExp concurExp)
           
 void onData(com.sun.msv.grammar.DataExp dataExp)
           
 void onElement(com.sun.msv.grammar.ElementExp elementExp)
           
 void onEpsilon()
           
 void onInterleave(com.sun.msv.grammar.InterleaveExp interleaveExp)
           
 void onList(com.sun.msv.grammar.ListExp listExp)
           
 void onMixed(com.sun.msv.grammar.MixedExp mixedExp)
           
 void onNullSet()
           
 void onOneOrMore(com.sun.msv.grammar.OneOrMoreExp oneOrMoreExp)
           
 void onOther(com.sun.msv.grammar.OtherExp otherExp)
           
 void onRef(com.sun.msv.grammar.ReferenceExp referenceExp)
           
 void onSequence(com.sun.msv.grammar.SequenceExp sequenceExp)
           
 void onValue(com.sun.msv.grammar.ValueExp valueExp)
           
 void parseDocument(java.net.URL schemaURL)
          Parses the schema at the given URL.
 void setEnableClassLoader(boolean enableClassLoader)
          determines whether class loader should be enabled; this is important when Project35 is deployed within another application or not
 void setIgnoreTopLevelElement(boolean ignoreTopLevelElement)
           
 void setTopLevelElementName(java.lang.String topLevelElementName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MsvSchemaReader

public MsvSchemaReader(Project35ApplicationContext project35ApplicationContext)
Constructor. Doesn't need any arguments.

Method Detail

getRecordModelFactory

public RecordModelFactory getRecordModelFactory()
Description copied from interface: SchemaReaderInterface
Returns the record structures created from reading the schema

Specified by:
getRecordModelFactory in interface SchemaReaderInterface

getConfigurationReader

public Project35ConfigurationReader getConfigurationReader()
Description copied from interface: SchemaReaderInterface
gets the configuration file reader

Specified by:
getConfigurationReader in interface SchemaReaderInterface

setTopLevelElementName

public void setTopLevelElementName(java.lang.String topLevelElementName)
Specified by:
setTopLevelElementName in interface SchemaReaderInterface

initialiseConfigurationReader

public void initialiseConfigurationReader(java.io.InputStream mainConfigurationStream,
                                          java.net.URL documentDirectory,
                                          java.net.URL resourceDirectory,
                                          java.io.InputStream extensionLauncherStream,
                                          java.io.File sessionFile)
                                   throws Project35Exception
Description copied from interface: SchemaReaderInterface
Initialises the configuration of the schema reader.

Specified by:
initialiseConfigurationReader in interface SchemaReaderInterface
Parameters:
mainConfigurationStream - The input stream of the configuration.
documentDirectory - The document directory of the desired model.
resourceDirectory - The resource directory of the desired model.
Throws:
Project35Exception

setEnableClassLoader

public void setEnableClassLoader(boolean enableClassLoader)
Description copied from interface: SchemaReaderInterface
determines whether class loader should be enabled; this is important when Project35 is deployed within another application or not

Specified by:
setEnableClassLoader in interface SchemaReaderInterface

setIgnoreTopLevelElement

public void setIgnoreTopLevelElement(boolean ignoreTopLevelElement)
Specified by:
setIgnoreTopLevelElement in interface SchemaReaderInterface

parseDocument

public void parseDocument(java.net.URL schemaURL)
                   throws javax.xml.parsers.ParserConfigurationException,
                          org.xml.sax.SAXException,
                          Project35Exception,
                          java.io.IOException
Description copied from interface: SchemaReaderInterface
Parses the schema at the given URL.

Specified by:
parseDocument in interface SchemaReaderInterface
Parameters:
schemaURL - The schema location.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
Project35Exception
java.io.IOException

getTopLevelRecord

public RecordModel getTopLevelRecord()
Specified by:
getTopLevelRecord in interface SchemaReaderInterface
Returns:
the top level record model.

hasWarnings

public boolean hasWarnings()
Returns whether the parsed schema created any warnings.

Specified by:
hasWarnings in interface SchemaReaderInterface
Returns:
whether the parsed schema created any warnings.

getWarnings

public java.util.List getWarnings()
Returns the warnings created by parsed schema.

Specified by:
getWarnings in interface SchemaReaderInterface
Returns:
the warnings created by parsed schema.

onRef

public void onRef(com.sun.msv.grammar.ReferenceExp referenceExp)
Specified by:
onRef in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
referenceExp - the ReferenceExp to process

onChoice

public void onChoice(com.sun.msv.grammar.ChoiceExp choiceExp)
Specified by:
onChoice in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
choiceExp -

onSequence

public void onSequence(com.sun.msv.grammar.SequenceExp sequenceExp)
Specified by:
onSequence in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
sequenceExp -

onInterleave

public void onInterleave(com.sun.msv.grammar.InterleaveExp interleaveExp)
Specified by:
onInterleave in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
interleaveExp -

onAttribute

public void onAttribute(com.sun.msv.grammar.AttributeExp attributeExp)
Specified by:
onAttribute in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
attributeExp -

onElement

public void onElement(com.sun.msv.grammar.ElementExp elementExp)
Specified by:
onElement in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
elementExp -

onOneOrMore

public void onOneOrMore(com.sun.msv.grammar.OneOrMoreExp oneOrMoreExp)
Specified by:
onOneOrMore in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
oneOrMoreExp -

onData

public void onData(com.sun.msv.grammar.DataExp dataExp)
Specified by:
onData in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
dataExp -

onMixed

public void onMixed(com.sun.msv.grammar.MixedExp mixedExp)
Specified by:
onMixed in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
mixedExp -
To Do:
not implemented yet

onList

public void onList(com.sun.msv.grammar.ListExp listExp)
Specified by:
onList in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
listExp -
To Do:
not implemented yet

onOther

public void onOther(com.sun.msv.grammar.OtherExp otherExp)
Specified by:
onOther in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
otherExp -
To Do:
not implemented yet

onEpsilon

public void onEpsilon()
Specified by:
onEpsilon in interface com.sun.msv.grammar.ExpressionVisitorVoid
To Do:
not implemented yet

onNullSet

public void onNullSet()
Specified by:
onNullSet in interface com.sun.msv.grammar.ExpressionVisitorVoid
To Do:
not implemented yet

onAnyString

public void onAnyString()
Specified by:
onAnyString in interface com.sun.msv.grammar.ExpressionVisitorVoid
To Do:
not implemented yet

onValue

public void onValue(com.sun.msv.grammar.ValueExp valueExp)
Specified by:
onValue in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
valueExp -
To Do:
not implemented yet

onConcur

public void onConcur(com.sun.msv.grammar.ConcurExp concurExp)
Specified by:
onConcur in interface com.sun.msv.grammar.ExpressionVisitorVoid
Parameters:
concurExp -
To Do:
not implemented yet