net.sourceforge.nrl.parser.operators
Class XmlOperatorPersistence

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

public class XmlOperatorPersistence
extends Object

Persistence support for the operator classes. To use this for loading:

For saving, just call save(IOperators, Writer).

Since:
1.5.0

Nested Class Summary
static class XmlOperatorPersistence.LoadedVersion
          Returned by load(Reader), the version of the operator file.
 
Constructor Summary
XmlOperatorPersistence(javax.xml.bind.JAXBContext version14Context, javax.xml.bind.JAXBContext version15Context)
          Initialise the persistence class.
 
Method Summary
 IOperators getOperators()
           
 XmlOperatorPersistence.LoadedVersion load(File file)
          Load from a file - see load(Reader).
 XmlOperatorPersistence.LoadedVersion load(Reader reader)
          Load an operator XML file using a reader.
 void save(IOperators operators, Writer writer)
          Save the mapping using a writer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlOperatorPersistence

public XmlOperatorPersistence(javax.xml.bind.JAXBContext version14Context,
                              javax.xml.bind.JAXBContext version15Context)
Initialise the persistence class. The caller must provide the JAXB context for the version 1.4 schema and version 1.5 schema. This is so that the caller can make its own decision about caching / creating the context.

Parameters:
version14Context - context for version 1.4 schema (package is net.sourceforge.nrl.parser.jaxb14)
version15Context - context for version 1.5 schema (package is net.sourceforge.nrl.parser.jaxb15)
Method Detail

getOperators

public IOperators getOperators()

load

public XmlOperatorPersistence.LoadedVersion load(File file)
                                          throws javax.xml.bind.JAXBException,
                                                 SAXException,
                                                 IOException
Load from a file - see load(Reader).

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

load

public XmlOperatorPersistence.LoadedVersion load(Reader reader)
                                          throws javax.xml.bind.JAXBException,
                                                 SAXException,
                                                 IOException
Load an operator XML file using a reader. If this was successful, returns the version of the file.

If the call was successful, calling getOperators() next returns the loaded operators.

Parameters:
reader - the reader
Returns:
the version
Throws:
javax.xml.bind.JAXBException
SAXException
IOException

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-2010 Christian Nentwich and others