org.apache.tuscany.sdo.helper
Class SDOHelperImpl

java.lang.Object
  extended by org.apache.tuscany.sdo.spi.SDOHelperBase
      extended by org.apache.tuscany.sdo.helper.SDOHelperImpl
All Implemented Interfaces:
SDOHelper, SDOHelper.MetaDataBuilder

public class SDOHelperImpl
extends SDOHelperBase
implements SDOHelper, SDOHelper.MetaDataBuilder


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.tuscany.sdo.api.SDOHelper
SDOHelper.MetaDataBuilder, SDOHelper.XMLOptions
 
Field Summary
 
Fields inherited from class org.apache.tuscany.sdo.spi.SDOHelperBase
javaToSdoMappings, xsdToSdoMappings
 
Fields inherited from interface org.apache.tuscany.sdo.api.SDOHelper
UNBOUNDED, UNSPECIFIED
 
Constructor Summary
SDOHelperImpl()
           
 
Method Summary
 void addAliasName(Property property, String aliasName)
          Add an aliasName to the specified property.
 void addAliasName(Type type, String aliasName)
          Add an aliasName to the specified type.
 void addBaseType(Type type, Type baseType)
          Add a baseType to the specified type.
 void addChangeListener(DataObject dob, EventListener listener)
          An experimental interface, subject to possible change that permits registration of an event listener with a DataObject instance
protected  void addInstanceProperty(org.eclipse.emf.ecore.EModelElement metaObject, Property property, Object value)
           
 void addPropertyInstanceProperty(Property definedProperty, Property instanceProperty, Object value)
          Add anf instance property to the specified property.
 void addTypeInstanceProperty(Type definedType, Property instanceProperty, Object value)
          Add an instance property to the specified type.
 String convertToString(Type dataType, Object value)
          Converts an instance of a data type to a string literal representation.
 CopyHelper createCrossScopeCopyHelper(HelperContext hc)
          Create a new cross scope CopyHelper.
 DataGraph createDataGraph()
          Create an empty data graph.
 DataObject createDataTypeWrapper(Type dataType, Object value)
          Create a DataObject wrapper for an instance of the specified dataType.
 Object createFromString(Type dataType, String literal)
          Creates an instance of a data type from the specified string.
 HelperContext createHelperContext()
          Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.
 HelperContext createHelperContext(boolean extensibleNamespaces)
          Create a HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.
 HelperContext createHelperContext(boolean extensibleNamespaces, Map options)
          Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.
 HelperContext createHelperContext(Map options)
          create a non-extensible HelperContext with default load/save options
 Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type)
          Create a new open content property in the specified TypeHelper scope.
 Property createProperty(Type containingType, String name, Type propertyType)
          Create a new property in the specified containingType.
 Type createType(HelperContext hc, String uri, String name, boolean isDataType)
          Create a Type in the specified TypeHelper scope.
 XMLStreamHelper createXMLStreamHelper(HelperContext hc)
          Create a new XMLStreamHelper, with visibility to types in the specified HelperContext scope.
 List getEnumerationFacet(Type type)
          Return Enumeration facet
 Type getJavaSDOType(Class javaClass)
          Get the SDO built-in type corresponding to the specified Java instanceClass.
 int getLowerBound(Property property)
          Return the lower bound of the specified property or 1 by default
 List getOpenContentProperties(DataObject dataObject)
          Gets the open content subset of the specified DataObject's instance properties.
 List getPatternFacet(Type type)
          Return Pattern facet
 Sequence getSubstitutionValues(DataObject dataObject, Property head)
          Gets the Sequence corresponding to the specified substitutable Property of the specified DataObject.
 List getTypes(HelperContext hc, String uri)
          Gets all of the types associated with a uri.
 int getUpperBound(Property property)
          Return the upper bound of the specified property or -1 if unbounded.
 Type getXSDSDOType(String xsdType)
          Get the SDO built-in type corresponding to the specified XSD type in the XML Schema namespace ("http://www.w3.org/2001/XMLSchema").
 boolean isDocumentRoot(Type type)
          Return true if the specified type is a special DocumentRoot Type.
 boolean isMany(Property property, DataObject context)
          Returns whether the Property is many-valued given the specified context.
 boolean isRequired(Property property)
          Return whether at least one value is required for a valid instance of the specified property.
static DataGraph loadDataGraph(InputStream inputStream, Map options)
           
 DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext scope)
          Load a serialized data graph from the specified insputStream.
 void registerDataGraphTypes(DataGraph dataGraph, List types)
          Registers the specified type(s) to be serialized along with the data object(s) in the graph.
protected  void registerLoadingScope(Map options, TypeHelper scope)
           
 void removeChangeListener(DataObject dob, EventListener listener)
          An experimental interface, subject to possible change that permits deregistration of an event listener with a DataObject instance
 void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options)
          Serialize the specified data graph to the specified outputStream.
 void setAbstract(Type type, boolean isAbstract)
          Set the isAbstract value of the specified type.
 void setContainment(Property property, boolean isContainment)
          Set the isContainment value of the specified property.
 void setDefault(Property property, String defaultValue)
          Set the default value of the specified property.
 void setJavaClassName(Type type, String javaClassName)
          Set the isAbstract value of the specified type.
 void setMany(Property property, boolean isMany)
          Set the isMany value of the specified property.
 void setOpen(Type type, boolean isOpen)
          Set the isOpen value of the specified type.
 void setOpposite(Property property, Property opposite)
          Set the opposite value of the specified property.
 void setPropertyXMLKind(Property property, boolean isXmlElement)
          Set a SDO property to become an XSD element or attribute
 void setReadOnly(Property property, boolean isReadOnly)
          Set the isReadOnly value of the specified property.
 void setRootObject(DataGraph dataGraph, DataObject rootObject)
          Set the root object of a data graph.
 void setSequenced(Type type, boolean isSequenced)
          Set the isSequenced value of the specified type.
 
Methods inherited from class org.apache.tuscany.sdo.spi.SDOHelperBase
createObjectInputStream, createObjectOutputStream, getMetaDataBuilder, getXPath, getXPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.tuscany.sdo.api.SDOHelper
createObjectInputStream, createObjectOutputStream, getMetaDataBuilder, getXPath
 

Constructor Detail

SDOHelperImpl

public SDOHelperImpl()
Method Detail

createDataTypeWrapper

public DataObject createDataTypeWrapper(Type dataType,
                                        Object value)
Description copied from interface: SDOHelper
Create a DataObject wrapper for an instance of the specified dataType. This method is typically used to create a root object that can be passed to the XMLHelper.save() method when the root element to be serialized is an XMLSchema simpleType.

Specified by:
createDataTypeWrapper in interface SDOHelper
Parameters:
dataType - a Type for which isDataType() returns true.
value - the instance value.
Returns:
a DataObject wrapper for the specified value.

createFromString

public Object createFromString(Type dataType,
                               String literal)
Description copied from interface: SDOHelper
Creates an instance of a data type from the specified string.

Specified by:
createFromString in interface SDOHelper
Parameters:
dataType - a Type, for which isDataType() returns true, to instantiate.
literal - the string value of the dataType.
Returns:
an instance of the dataType.
See Also:
SDOHelper.convertToString(Type, Object)

convertToString

public String convertToString(Type dataType,
                              Object value)
Description copied from interface: SDOHelper
Converts an instance of a data type to a string literal representation.

Specified by:
convertToString in interface SDOHelper
Parameters:
dataType - the Type, for which isDataType() returns true, of the value to convert.
value - a value of the dataType.
Returns:
the string literal representation of the value.
See Also:
SDOHelper.createFromString(Type, String)

getXSDSDOType

public Type getXSDSDOType(String xsdType)
Description copied from interface: SDOHelper
Get the SDO built-in type corresponding to the specified XSD type in the XML Schema namespace ("http://www.w3.org/2001/XMLSchema").

Specified by:
getXSDSDOType in interface SDOHelper
Parameters:
xsdType - a type name in the XML Schema namespace.
Returns:
the SDO built-in Type corresponding to the specified XSD type.

getSubstitutionValues

public Sequence getSubstitutionValues(DataObject dataObject,
                                      Property head)
Description copied from interface: SDOHelper
Gets the Sequence corresponding to the specified substitutable Property of the specified DataObject.

Specified by:
getSubstitutionValues in interface SDOHelper
Parameters:
dataObject - the data object.
head - a substitution group head property.
Returns:
the Sequence corresponding to the specified substitutable Property of the specified DataObject or null if the specified Property isn't a substitution head.

getJavaSDOType

public Type getJavaSDOType(Class javaClass)
Description copied from interface: SDOHelper
Get the SDO built-in type corresponding to the specified Java instanceClass.

Specified by:
getJavaSDOType in interface SDOHelper
Parameters:
javaClass - the Java instanceClass of the type.
Returns:
the SDO built-in Type corresponding to the specified instanceClass.

isRequired

public boolean isRequired(Property property)
Description copied from interface: SDOHelper
Return whether at least one value is required for a valid instance of the specified property.

Specified by:
isRequired in interface SDOHelper
Returns:
true if the property is required.

getUpperBound

public int getUpperBound(Property property)
Description copied from interface: SDOHelper
Return the upper bound of the specified property or -1 if unbounded.

Specified by:
getUpperBound in interface SDOHelper
Returns:
the upper bound.

getLowerBound

public int getLowerBound(Property property)
Description copied from interface: SDOHelper
Return the lower bound of the specified property or 1 by default

Specified by:
getLowerBound in interface SDOHelper
Returns:
the lower bound.

getEnumerationFacet

public List getEnumerationFacet(Type type)
Description copied from interface: SDOHelper
Return Enumeration facet

Specified by:
getEnumerationFacet in interface SDOHelper
Returns:
List of enum facets in a Type

getPatternFacet

public List getPatternFacet(Type type)
Description copied from interface: SDOHelper
Return Pattern facet

Specified by:
getPatternFacet in interface SDOHelper
Returns:
List of pattern facets in a Type

isMany

public boolean isMany(Property property,
                      DataObject context)
Description copied from interface: SDOHelper
Returns whether the Property is many-valued given the specified context.

Specified by:
isMany in interface SDOHelper
Parameters:
property - The Property in question
context - The context to check whether the specified Property is many-valued
Returns:
true if the Property is many-valued given the specified context.

createDataGraph

public DataGraph createDataGraph()
Description copied from interface: SDOHelper
Create an empty data graph.

Specified by:
createDataGraph in interface SDOHelper
Returns:
the new data graph instance.

setRootObject

public void setRootObject(DataGraph dataGraph,
                          DataObject rootObject)
Description copied from interface: SDOHelper
Set the root object of a data graph.

Specified by:
setRootObject in interface SDOHelper
Parameters:
dataGraph - the data graph in which to set the root object.
rootObject - the root object.

loadDataGraph

public static DataGraph loadDataGraph(InputStream inputStream,
                                      Map options)
                               throws IOException
Throws:
IOException

registerLoadingScope

protected void registerLoadingScope(Map options,
                                    TypeHelper scope)

loadDataGraph

public DataGraph loadDataGraph(InputStream inputStream,
                               Map options,
                               HelperContext scope)
                        throws IOException
Description copied from interface: SDOHelper
Load a serialized data graph from the specified insputStream.

Specified by:
loadDataGraph in interface SDOHelper
Parameters:
inputStream - the inputStream of the data graph.
options - loader control options, or null.
scope - the HelperContext in which to register deserialized Types and to find Types when creating DataObject instances, or null for default HelperContext.
Returns:
the de-serialized data graph.
Throws:
IOException

saveDataGraph

public void saveDataGraph(DataGraph dataGraph,
                          OutputStream outputStream,
                          Map options)
                   throws IOException
Description copied from interface: SDOHelper
Serialize the specified data graph to the specified outputStream.

Specified by:
saveDataGraph in interface SDOHelper
Parameters:
dataGraph - the data graph to save.
outputStream - the outputStream for the data graph.
options - serializer control options, or null.
Throws:
IOException

registerDataGraphTypes

public void registerDataGraphTypes(DataGraph dataGraph,
                                   List types)
Description copied from interface: SDOHelper
Registers the specified type(s) to be serialized along with the data object(s) in the graph. For example, the list of types returned from TypeHelper.define(commonj.sdo.DataObject) can be registered with this method, allowing deserialization of instances of a dynamically defined model.

Specified by:
registerDataGraphTypes in interface SDOHelper
Parameters:
dataGraph - the DataGraph in which to register the specified type(s).
types - a list containing the type(s) to be registered (TBD or null to automatically register all types used by the objects in the DataGraph).

createHelperContext

public HelperContext createHelperContext()
Description copied from interface: SDOHelper
Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.

Specified by:
createHelperContext in interface SDOHelper
Overrides:
createHelperContext in class SDOHelperBase
Returns:
the new HelperContext
See Also:
SDOHelper.createHelperContext(boolean)

createHelperContext

public HelperContext createHelperContext(boolean extensibleNamespaces)
Description copied from interface: SDOHelper
Create a HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.

Specified by:
createHelperContext in interface SDOHelper
Parameters:
extensibleNamespaces - true if the contents of a namespaces should be incrementally modifiable over time
Returns:
the new HelperContext

createHelperContext

public HelperContext createHelperContext(Map options)
Description copied from interface: SDOHelper
create a non-extensible HelperContext with default load/save options

Specified by:
createHelperContext in interface SDOHelper
Parameters:
options - default load/save options from XMLOptions
Returns:
the new HelperContext

createHelperContext

public HelperContext createHelperContext(boolean extensibleNamespaces,
                                         Map options)
Description copied from interface: SDOHelper
Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use of a new TypeHelper instance to provide scope for type definitions.

Specified by:
createHelperContext in interface SDOHelper
options - Map of default XMLOptions
Returns:
the new HelperContext
See Also:
SDOHelper.createHelperContext(boolean)

createCrossScopeCopyHelper

public CopyHelper createCrossScopeCopyHelper(HelperContext hc)
Description copied from interface: SDOHelper
Create a new cross scope CopyHelper.

Specified by:
createCrossScopeCopyHelper in interface SDOHelper
Returns:
the new CopyHelper.

createXMLStreamHelper

public XMLStreamHelper createXMLStreamHelper(HelperContext hc)
Description copied from interface: SDOHelper
Create a new XMLStreamHelper, with visibility to types in the specified HelperContext scope.

Specified by:
createXMLStreamHelper in interface SDOHelper
Parameters:
hc - the HelperContext to use for locating types.
Returns:
the new XMLStreamHelper.

getTypes

public List getTypes(HelperContext hc,
                     String uri)
Description copied from interface: SDOHelper
Gets all of the types associated with a uri.

Specified by:
getTypes in interface SDOHelper
Parameters:
hc - the HelperContext to use for locating types.
uri - the URI of the Types
Returns:
a List containing instances of Type, null if uri is not found.

getOpenContentProperties

public List getOpenContentProperties(DataObject dataObject)
Description copied from interface: SDOHelper
Gets the open content subset of the specified DataObject's instance properties.

Specified by:
getOpenContentProperties in interface SDOHelper
Parameters:
dataObject - the DataObject instance
Returns:
a List containing any open content properties of the DataObject

isDocumentRoot

public boolean isDocumentRoot(Type type)
Description copied from interface: SDOHelper
Return true if the specified type is a special DocumentRoot Type.

Specified by:
isDocumentRoot in interface SDOHelper
Parameters:
type - the Type in question
Returns:
true if type is a DocumentRoot

createType

public Type createType(HelperContext hc,
                       String uri,
                       String name,
                       boolean isDataType)
Description copied from interface: SDOHelper.MetaDataBuilder
Create a Type in the specified TypeHelper scope.

Specified by:
createType in interface SDOHelper.MetaDataBuilder
Returns:
the new Type.

addBaseType

public void addBaseType(Type type,
                        Type baseType)
Description copied from interface: SDOHelper.MetaDataBuilder
Add a baseType to the specified type.

Specified by:
addBaseType in interface SDOHelper.MetaDataBuilder

addAliasName

public void addAliasName(Type type,
                         String aliasName)
Description copied from interface: SDOHelper.MetaDataBuilder
Add an aliasName to the specified type.

Specified by:
addAliasName in interface SDOHelper.MetaDataBuilder

setOpen

public void setOpen(Type type,
                    boolean isOpen)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isOpen value of the specified type.

Specified by:
setOpen in interface SDOHelper.MetaDataBuilder

setSequenced

public void setSequenced(Type type,
                         boolean isSequenced)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isSequenced value of the specified type.

Specified by:
setSequenced in interface SDOHelper.MetaDataBuilder

setAbstract

public void setAbstract(Type type,
                        boolean isAbstract)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isAbstract value of the specified type.

Specified by:
setAbstract in interface SDOHelper.MetaDataBuilder

setJavaClassName

public void setJavaClassName(Type type,
                             String javaClassName)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isAbstract value of the specified type.

Specified by:
setJavaClassName in interface SDOHelper.MetaDataBuilder

createProperty

public Property createProperty(Type containingType,
                               String name,
                               Type propertyType)
Description copied from interface: SDOHelper.MetaDataBuilder
Create a new property in the specified containingType.

Specified by:
createProperty in interface SDOHelper.MetaDataBuilder

setPropertyXMLKind

public void setPropertyXMLKind(Property property,
                               boolean isXmlElement)
Description copied from interface: SDOHelper.MetaDataBuilder
Set a SDO property to become an XSD element or attribute

Specified by:
setPropertyXMLKind in interface SDOHelper.MetaDataBuilder

createOpenContentProperty

public Property createOpenContentProperty(HelperContext hc,
                                          String uri,
                                          String name,
                                          Type type)
Description copied from interface: SDOHelper.MetaDataBuilder
Create a new open content property in the specified TypeHelper scope.

Specified by:
createOpenContentProperty in interface SDOHelper.MetaDataBuilder

addAliasName

public void addAliasName(Property property,
                         String aliasName)
Description copied from interface: SDOHelper.MetaDataBuilder
Add an aliasName to the specified property.

Specified by:
addAliasName in interface SDOHelper.MetaDataBuilder

setMany

public void setMany(Property property,
                    boolean isMany)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isMany value of the specified property.

Specified by:
setMany in interface SDOHelper.MetaDataBuilder

setContainment

public void setContainment(Property property,
                           boolean isContainment)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isContainment value of the specified property.

Specified by:
setContainment in interface SDOHelper.MetaDataBuilder

setDefault

public void setDefault(Property property,
                       String defaultValue)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the default value of the specified property.

Specified by:
setDefault in interface SDOHelper.MetaDataBuilder

setReadOnly

public void setReadOnly(Property property,
                        boolean isReadOnly)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the isReadOnly value of the specified property.

Specified by:
setReadOnly in interface SDOHelper.MetaDataBuilder

setOpposite

public void setOpposite(Property property,
                        Property opposite)
Description copied from interface: SDOHelper.MetaDataBuilder
Set the opposite value of the specified property.

Specified by:
setOpposite in interface SDOHelper.MetaDataBuilder

addTypeInstanceProperty

public void addTypeInstanceProperty(Type definedType,
                                    Property instanceProperty,
                                    Object value)
Description copied from interface: SDOHelper.MetaDataBuilder
Add an instance property to the specified type.

Specified by:
addTypeInstanceProperty in interface SDOHelper.MetaDataBuilder

addPropertyInstanceProperty

public void addPropertyInstanceProperty(Property definedProperty,
                                        Property instanceProperty,
                                        Object value)
Description copied from interface: SDOHelper.MetaDataBuilder
Add anf instance property to the specified property.

Specified by:
addPropertyInstanceProperty in interface SDOHelper.MetaDataBuilder

addInstanceProperty

protected void addInstanceProperty(org.eclipse.emf.ecore.EModelElement metaObject,
                                   Property property,
                                   Object value)

addChangeListener

public void addChangeListener(DataObject dob,
                              EventListener listener)
Description copied from interface: SDOHelper
An experimental interface, subject to possible change that permits registration of an event listener with a DataObject instance

Specified by:
addChangeListener in interface SDOHelper
Parameters:
dob - DataObject
listener - EventListener

removeChangeListener

public void removeChangeListener(DataObject dob,
                                 EventListener listener)
Description copied from interface: SDOHelper
An experimental interface, subject to possible change that permits deregistration of an event listener with a DataObject instance

Specified by:
removeChangeListener in interface SDOHelper
Parameters:
dob - DataObject
listener - EventListener


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.