net.sourceforge.nrl.parser.operators
Class XmlOperatorLoader

java.lang.Object
  extended by net.sourceforge.nrl.parser.operators.XmlOperatorLoader

public class XmlOperatorLoader
extends Object

Loading support for the operator classes. Call load(File, List) or load(URI, URI, List). This will load the file and resolve model references. Any errors will be added to the supplied list. Returns the version of the operator file loaded. If there were no errors, call getOperators() to get the loaded operators.

Since:
1.4.10

Field Summary
protected static String CURRENT_FILE_VERSION
          File version of this persistence mechanism: currently 1.5.0
 
Constructor Summary
XmlOperatorLoader(IModelLoader modelLoader, IURIResolver uriResolver)
          Initialise the persistence class.
XmlOperatorLoader(IResolverFactory factory)
          Initialise the persistence class using a factory.
 
Method Summary
 IOperators getOperators()
           
 IOperators load(File file, List<NRLError> errors)
          Load from a file - see #load(Reader).
 IOperators load(URI baseURI, URI operatorFileUri, List<NRLError> errors)
          Load an operator file from a URI (relative or absolute) resolved against an absolute base URI.
 void save(IOperators operators, Writer writer)
          Save the mapping using a writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_FILE_VERSION

protected static final String CURRENT_FILE_VERSION
File version of this persistence mechanism: currently 1.5.0

See Also:
Constant Field Values
Constructor Detail

XmlOperatorLoader

public XmlOperatorLoader(IResolverFactory factory)
Initialise the persistence class using a factory.

Parameters:
factory - the factory that will provide a model loader and URI resolver

XmlOperatorLoader

public XmlOperatorLoader(IModelLoader modelLoader,
                         IURIResolver uriResolver)
Initialise the persistence class.

Parameters:
modelLoader - an IModelLoader that will be used to resolve models referenced by the operators.
Method Detail

getOperators

public IOperators getOperators()

load

public IOperators load(File file,
                       List<NRLError> errors)
                throws javax.xml.bind.JAXBException,
                       SAXException,
                       IOException,
                       ResolverException
Load from a file - see #load(Reader).

Parameters:
file - the file to load from
Returns:
the loaded operators
Throws:
javax.xml.bind.JAXBException
SAXException
IOException
ResolverException

load

public IOperators load(URI baseURI,
                       URI operatorFileUri,
                       List<NRLError> errors)
                throws javax.xml.bind.JAXBException,
                       SAXException,
                       IOException,
                       ResolverException
Load an operator file from a URI (relative or absolute) resolved against an absolute base URI.

If the call was successful, calling getOperators() next returns the loaded operators. The IOperators returned will have fully resolved and type checked models.

Parameters:
operatorFileUri - an absolute uri pointing to the operator file
Returns:
the loaded operators
Throws:
javax.xml.bind.JAXBException
SAXException
IOException
ResolverException

save

public void save(IOperators operators,
                 Writer writer)
          throws Exception
Save the mapping using a writer. Always indents.

Parameters:
operators - the operators to save
writer - the writer
Throws:
IOException
Exception


Copyright © 2006-2013. All Rights Reserved.