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

java.lang.Object
  extended by org.eclipse.emf.ecore.xmi.util.XMLProcessor

public class XMLProcessor
extends java.lang.Object

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


Field Summary
protected  EcoreBuilder ecoreBuilder
           
protected  ExtendedMetaData extendedMetaData
           
protected  java.util.Map<java.lang.Object,java.lang.Object> loadOptions
           
protected  java.util.Map<java.lang.String,Resource.Factory> registrations
           
protected  EPackage.Registry registry
           
protected  java.util.Map<java.lang.Object,java.lang.Object> saveOptions
           
protected static java.lang.String STAR_EXTENSION
           
protected static java.lang.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(java.util.Collection<URI> schemaURIs)
          Create an XML processor that is aware of XML Schemas specified.
protected XMLProcessor(EPackage.Registry registry)
          Protected constructor - should be used for in statically 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  java.util.Map<java.lang.String,Resource.Factory> getRegistrations()
           
 Resource load(org.xml.sax.InputSource inputSource, java.util.Map<?,?> options)
           
 Resource load(java.io.InputStream is, java.util.Map<?,?> options)
           
 Resource load(org.w3c.dom.Node node, java.util.Map<?,?> options)
           
 Resource load(java.lang.String systemId, java.util.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(org.w3c.dom.Document document, Resource resource, DOMHandler handler, java.util.Map<?,?> options)
           
 void save(java.io.OutputStream outputStream, Resource resource, java.util.Map<?,?> options)
           
 void save(java.io.Writer writer, Resource resource, java.util.Map<?,?> options)
           
 java.lang.String saveToString(Resource resource, java.util.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 java.lang.String XML_EXTENSION
See Also:
Constant Field Values

STAR_EXTENSION

protected static final java.lang.String STAR_EXTENSION
See Also:
Constant Field Values

XML_URI

protected static final URI XML_URI

registrations

protected java.util.Map<java.lang.String,Resource.Factory> registrations

loadOptions

protected java.util.Map<java.lang.Object,java.lang.Object> loadOptions

saveOptions

protected java.util.Map<java.lang.Object,java.lang.Object> 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 statically 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 org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

XMLProcessor

public XMLProcessor(java.util.Collection<URI> schemaURIs)
             throws org.xml.sax.SAXException
Create an XML processor that is aware of XML Schemas specified.

Parameters:
schemaURIs - - a list of URI URI which point to XML Schemas
Throws:
org.xml.sax.SAXException
Method Detail

getRegistrations

protected java.util.Map<java.lang.String,Resource.Factory> 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(java.lang.String systemId,
                     java.util.Map<?,?> options)
              throws java.io.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:
java.io.IOException
See Also:
Resource, URI

load

public Resource load(java.io.InputStream is,
                     java.util.Map<?,?> options)
              throws java.io.IOException
Throws:
java.io.IOException

load

public Resource load(org.xml.sax.InputSource inputSource,
                     java.util.Map<?,?> options)
              throws java.io.IOException
Throws:
java.io.IOException

load

public Resource load(org.w3c.dom.Node node,
                     java.util.Map<?,?> options)
              throws java.io.IOException
Throws:
java.io.IOException

save

public void save(java.io.OutputStream outputStream,
                 Resource resource,
                 java.util.Map<?,?> options)
          throws java.io.IOException
Throws:
java.io.IOException

save

public void save(java.io.Writer writer,
                 Resource resource,
                 java.util.Map<?,?> options)
          throws java.io.IOException
Throws:
java.io.IOException

save

public void save(org.w3c.dom.Document document,
                 Resource resource,
                 DOMHandler handler,
                 java.util.Map<?,?> options)
          throws java.io.IOException
Throws:
java.io.IOException

saveToString

public java.lang.String saveToString(Resource resource,
                                     java.util.Map<?,?> options)
                              throws java.io.IOException
Throws:
java.io.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.