org.modeshape.sequencer.teiid
Class XmiGraphReader

java.lang.Object
  extended by org.modeshape.sequencer.teiid.XmiGraphReader
Direct Known Subclasses:
CndFromEcore.CndGraphReader, XmiModelReader

public class XmiGraphReader
extends Object

A class that can be used to read an XMI file that has been imported into a graph.


Field Summary
protected  ValueFactory<Boolean> booleanFactory
           
protected  ExecutionContext context
           
protected  String currentNamespaceUri
           
protected static Map<String,String> EDATATYPE_TO_JCR_TYPENAME
           
protected  boolean generateShortNames
           
protected  Inflector inflector
           
protected  NameFactory nameFactory
           
protected  NamespaceRegistry namespaces
           
protected  PathFactory pathFactory
           
protected  PropertyFactory propertyFactory
           
protected  ValueFactory<String> stringFactory
           
protected  Subgraph subgraph
           
protected  Map<Name,Name> typeNameReplacements
           
protected  UuidFactory uuidFactory
           
protected  ValueFactories valueFactories
           
 
Constructor Summary
protected XmiGraphReader(Subgraph subgraph, boolean generateShortNames)
           
 
Method Summary
protected  String firstValue(Node node, Name propertyName)
           
protected  String firstValue(Node node, Name propertyName, String defaultValue)
           
protected  String firstValue(Node node, String propertyName)
           
protected  boolean firstValue(Node node, String propertyName, boolean defaultValue)
           
protected  double firstValue(Node node, String propertyName, double defaultValue)
           
protected  long firstValue(Node node, String propertyName, long defaultValue)
           
protected  String firstValue(Node node, String propertyName, String defaultValue)
           
 String getCurrentNamespaceUri()
          Get the current namespace URI.
protected  String jcrTypeNameFor(Name dataType)
           
protected  Name nameForHref(Name eObjectReferenceName)
          Determine the name of the property that is used to hold the "href" URL literal value of the EObject reference.
protected  Name nameForResolvedId(Name eObjectReferenceName)
          Determine the name of the property that is used to hold the identifier(s) for the resolved EObject reference.
protected  Name nameForResolvedName(Name eObjectReferenceName)
          Determine the name of the property that is used to hold the name(s) for the resolved EObject reference.
protected  Name nameForResolvedReference(Name eObjectReferenceName)
          Determine the name of the property that is used to hold the WEAKREFERENCE values for the resolved EObject reference.
protected  Name nameFrom(Name name)
           
protected  Name nameFrom(String name)
           
protected  List<Name> names(Node node, String propertyName, String regexDelimiter)
           
protected  String namespacePrefix(String prefix)
           
protected  Path path(Path parent, Name name)
           
protected  Path path(Path parent, Name name, int snsIndex)
           
protected  Path path(Path parent, Path.Segment segment)
           
protected  Path path(Path parent, String relativePath)
           
protected  Path pathFrom(Object path)
           
protected  Property property(Name name, Object... values)
           
protected  Property property(Name name, PropertyType type, Object... values)
           
protected  List<UUID> references(Property property)
          Extracts the "mmuuid" values from the property if the property is indeed an XMI reference to local objects.
protected  Path relativePathFrom(Name... names)
           
protected  void replaceTypeName(Name replaced, Name with)
           
protected  void replaceTypeName(String replaced, String with)
           
protected  void setCurrentNamespaceUri(String uri)
           
protected  Name shortenName(Name name)
           
protected  String stringFrom(Object value)
           
protected  Name typeNameFrom(Name name)
           
protected  UUID uuidFor(Node node)
           
protected  List<String> values(Node node, String propertyName, String regexDelimiter)
           
protected  UUID xmiUuidFor(Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDATATYPE_TO_JCR_TYPENAME

protected static final Map<String,String> EDATATYPE_TO_JCR_TYPENAME

context

protected final ExecutionContext context

valueFactories

protected final ValueFactories valueFactories

stringFactory

protected final ValueFactory<String> stringFactory

booleanFactory

protected final ValueFactory<Boolean> booleanFactory

nameFactory

protected final NameFactory nameFactory

pathFactory

protected final PathFactory pathFactory

uuidFactory

protected final UuidFactory uuidFactory

propertyFactory

protected final PropertyFactory propertyFactory

subgraph

protected final Subgraph subgraph

namespaces

protected final NamespaceRegistry namespaces

inflector

protected final Inflector inflector

generateShortNames

protected final boolean generateShortNames

currentNamespaceUri

protected String currentNamespaceUri

typeNameReplacements

protected final Map<Name,Name> typeNameReplacements
Constructor Detail

XmiGraphReader

protected XmiGraphReader(Subgraph subgraph,
                         boolean generateShortNames)
Method Detail

replaceTypeName

protected void replaceTypeName(Name replaced,
                               Name with)

replaceTypeName

protected void replaceTypeName(String replaced,
                               String with)

setCurrentNamespaceUri

protected void setCurrentNamespaceUri(String uri)

getCurrentNamespaceUri

public String getCurrentNamespaceUri()
Get the current namespace URI.

Returns:
the URI of the current namespace, or null if there is none

namespacePrefix

protected String namespacePrefix(String prefix)

firstValue

protected String firstValue(Node node,
                            Name propertyName)

firstValue

protected String firstValue(Node node,
                            Name propertyName,
                            String defaultValue)

firstValue

protected String firstValue(Node node,
                            String propertyName)

firstValue

protected String firstValue(Node node,
                            String propertyName,
                            String defaultValue)

firstValue

protected boolean firstValue(Node node,
                             String propertyName,
                             boolean defaultValue)

firstValue

protected long firstValue(Node node,
                          String propertyName,
                          long defaultValue)

firstValue

protected double firstValue(Node node,
                            String propertyName,
                            double defaultValue)

values

protected List<String> values(Node node,
                              String propertyName,
                              String regexDelimiter)

names

protected List<Name> names(Node node,
                           String propertyName,
                           String regexDelimiter)

jcrTypeNameFor

protected String jcrTypeNameFor(Name dataType)

pathFrom

protected Path pathFrom(Object path)

relativePathFrom

protected Path relativePathFrom(Name... names)

path

protected Path path(Path parent,
                    Name name)

path

protected Path path(Path parent,
                    String relativePath)

path

protected Path path(Path parent,
                    Name name,
                    int snsIndex)

path

protected Path path(Path parent,
                    Path.Segment segment)

property

protected Property property(Name name,
                            Object... values)

property

protected Property property(Name name,
                            PropertyType type,
                            Object... values)

nameFrom

protected Name nameFrom(String name)

nameFrom

protected Name nameFrom(Name name)

typeNameFrom

protected Name typeNameFrom(Name name)

nameForHref

protected Name nameForHref(Name eObjectReferenceName)
Determine the name of the property that is used to hold the "href" URL literal value of the EObject reference.

The resulting name fits one of two patterns, depending upon whether the local part of the reference name is singular or plural. If singular, then the resulting name will have "Href" appended to the local part of the supplied name. If plural, then the resulting name will consist of the singularlized local part appended with "Hrefs". In all cases, the namespace URI of the resulting name will match that of the supplied name.

Parameters:
eObjectReferenceName - the name of the normal EObject reference property, which is typically a href
Returns:
the name

nameForResolvedReference

protected Name nameForResolvedReference(Name eObjectReferenceName)
Determine the name of the property that is used to hold the WEAKREFERENCE values for the resolved EObject reference.

This method just returns the name without modification.

Parameters:
eObjectReferenceName - the name of the normal EObject reference property, which is typically a href
Returns:
the name

nameForResolvedName

protected Name nameForResolvedName(Name eObjectReferenceName)
Determine the name of the property that is used to hold the name(s) for the resolved EObject reference.

The resulting name fits one of two patterns, depending upon whether the local part of the reference name is singular or plural. If singular, then the resulting name will have "Name" appended to the local part of the supplied name. If plural, then the resulting name will consist of the singularlized local part appended with "Names". In all cases, the namespace URI of the resulting name will match that of the supplied name.

Parameters:
eObjectReferenceName - the name of the normal EObject reference property, which is typically a href
Returns:
the name

nameForResolvedId

protected Name nameForResolvedId(Name eObjectReferenceName)
Determine the name of the property that is used to hold the identifier(s) for the resolved EObject reference.

The resulting name fits one of two patterns, depending upon whether the local part of the reference name is singular or plural. If singular, then the resulting name will have "XmiUuid" appended to the local part of the supplied name. If plural, then the resulting name will consist of the singularlized local part appended with "XmiUuids". In all cases, the namespace URI of the resulting name will match that of the supplied name.

Parameters:
eObjectReferenceName - the name of the normal EObject reference property, which is typically a href
Returns:
the name

stringFrom

protected String stringFrom(Object value)

shortenName

protected Name shortenName(Name name)

uuidFor

protected UUID uuidFor(Node node)

xmiUuidFor

protected UUID xmiUuidFor(Node node)

references

protected List<UUID> references(Property property)
Extracts the "mmuuid" values from the property if the property is indeed an XMI reference to local objects.

Parameters:
property - the property
Returns:
the list of mmuuid values, or null if this property does not contain any references; never empty


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.