org.eclipse.emf.ecore.xmi.util
Class XMLProcessor

java.lang.Object
  extended byorg.eclipse.emf.ecore.xmi.util.XMLProcessor

public class XMLProcessor
extends Object

XMLProcessor provides helper methods to serialize and deserialize XML using EMF framework.


Field Summary
protected  EcoreBuilder ecoreBuilder
           
protected  ExtendedMetaData extendedMetaData
           
protected  Map loadOptions
           
protected  Map registrations
           
protected  EPackage.Registry registry
           
protected  Map saveOptions
           
protected static String STAR_EXTENSION
           
protected static String XML_EXTENSION
           
protected static URI XML_URI
           
 
Constructor Summary
  XMLProcessor()
          Use this constructor to create an XML processor that is not aware of any schema.
  XMLProcessor(Collection schemaURIs)
          Create an XML processor that is aware of XML Schemas specified.
protected XMLProcessor(EPackage.Registry registry)
          Protected constructor - should be used for in staticly generated models, or in the case schema(s) is known when XMLProcessor is created
  XMLProcessor(URI schemaURI)
           
 
Method Summary
protected  EcoreBuilder createEcoreBuilder()
           
protected  ExtendedMetaData createExtendedMetaData()
          This methods can be used to provide a different ExtendedMetaData.
protected  ResourceSet createResourceSet()
           
 EPackage.Registry getEPackageRegistry()
           
 ExtendedMetaData getExtendedMetaData()
           
protected  Map getRegistrations()
           
 Resource load(InputSource inputSource, Map options)
           
 Resource load(InputStream is, Map options)
           
 Resource load(Node node, Map options)
           
 Resource load(String systemId, Map options)
          Given a system identifier and option, this methods creates an EMF Resource (using URI#createURI method) and loads the resource data.
 void save(Document document, Resource resource, DOMHandler handler, Map options)
           
 void save(OutputStream outputStream, Resource resource, Map options)
           
 void save(Writer writer, Resource resource, Map options)
           
 String saveToString(Resource resource, Map options)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ecoreBuilder

protected EcoreBuilder ecoreBuilder

XML_EXTENSION

protected static final String XML_EXTENSION
See Also:
Constant Field Values

STAR_EXTENSION

protected static final String STAR_EXTENSION
See Also:
Constant Field Values

XML_URI

protected static final URI XML_URI

registrations

protected Map registrations

loadOptions

protected Map loadOptions

saveOptions

protected Map saveOptions

extendedMetaData

protected ExtendedMetaData extendedMetaData

registry

protected EPackage.Registry registry
Constructor Detail

XMLProcessor

protected XMLProcessor(EPackage.Registry registry)
Protected constructor - should be used for in staticly generated models, or in the case schema(s) is known when XMLProcessor is created


XMLProcessor

public XMLProcessor()
Use this constructor to create an XML processor that is not aware of any schema. Use XMLOptions to configure this processor to process, for example, schemaLocation/noNamespaceSchema location attributes.


XMLProcessor

public XMLProcessor(URI schemaURI)
             throws SAXException

XMLProcessor

public XMLProcessor(Collection schemaURIs)
             throws SAXException
Create an XML processor that is aware of XML Schemas specified.

Parameters:
schemaURIs - - a list of URI org.eclipse.common.util.URI which point to XML Schemas
Throws:
SAXException
Method Detail

getRegistrations

protected Map getRegistrations()

getEPackageRegistry

public EPackage.Registry getEPackageRegistry()
Returns:
a map of namespace URI to EPackage. This registry should be treated as read-only. The registry does not include packages loaded on demand (@see #getExtendedMetaData to retrieve demand loaded packages)

getExtendedMetaData

public ExtendedMetaData getExtendedMetaData()
Returns:
The ExtendedMetaData used by XMLProcessor to register all Ecore packages. The ExtendedMetaData can be used to retieve information about the model (e.g. @see ExtendedMetaData#getElement(String, String)). The ExtendedMetaData should be treated as read-only.

load

public Resource load(String systemId,
                     Map options)
              throws IOException
Given a system identifier and option, this methods creates an EMF Resource (using URI#createURI method) and loads the resource data.

Parameters:
systemId - - system identifier
options - - options map
Returns:
Loaded resource
Throws:
IOException
See Also:
Resource, URI

load

public Resource load(InputStream is,
                     Map options)
              throws IOException
Throws:
IOException

load

public Resource load(InputSource inputSource,
                     Map options)
              throws IOException
Throws:
IOException

load

public Resource load(Node node,
                     Map options)
              throws IOException
Throws:
IOException

save

public void save(OutputStream outputStream,
                 Resource resource,
                 Map options)
          throws IOException
Throws:
IOException

save

public void save(Writer writer,
                 Resource resource,
                 Map options)
          throws IOException
Throws:
IOException

save

public void save(Document document,
                 Resource resource,
                 DOMHandler handler,
                 Map options)
          throws IOException
Throws:
IOException

saveToString

public String saveToString(Resource resource,
                           Map options)
                    throws IOException
Throws:
IOException

createResourceSet

protected ResourceSet createResourceSet()

createEcoreBuilder

protected EcoreBuilder createEcoreBuilder()

createExtendedMetaData

protected ExtendedMetaData createExtendedMetaData()
This methods can be used to provide a different ExtendedMetaData. Note that if this method creates a new EPackage.Registry it must also assign the global registry variable.

Returns:
ExtendedMetaData

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.