COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification

org.eclipse.cosmos.rm.repository.internal
Class SMLRepositoryUtil

java.lang.Object
  extended by org.eclipse.cosmos.rm.repository.internal.SMLRepositoryUtil

public class SMLRepositoryUtil
extends java.lang.Object

Consists of common utility methods


Constructor Summary
SMLRepositoryUtil()
           
 
Method Summary
static void appendSMLIFIdentityInformation(java.lang.StringBuffer buffer, org.eclipse.cosmos.rm.repository.provisional.resource.ISMLIFIdentity identity)
          Create the starting tags to a new SML-IF file, including the identity information, and append them to the string buffer.
static java.lang.String extractReference(org.w3c.dom.Node root)
          Extracts the text node representing the SML document reference from the root node passed in.
static java.lang.String firstSegment(java.lang.String path, int index)
          Returns the index-th segment of path starting from the beginning.
static java.lang.String getAlternativeId(org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository, java.lang.String id)
          A document can have two alternative IDs: one relative to the context root directory or an absolute path from the the context directory.
static java.lang.String getDocumentName(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document)
          Returns the document's id relative to the context root directory
static java.lang.String getDocumentPath(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document)
          Returns the full document's id (i.e. an absolute path)
static boolean isNullOrEmpty(java.lang.String string)
          Returns a flag indicating if the passed in string is null or an empty string
static java.lang.String retrieveAlias(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document, java.util.Map aliases)
          Retrieves the first alias of the document passed in.
static ISMLResourceFacet[] retrieveFacets(ISMLResourceInstance document, org.w3c.dom.Node root, org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository)
          Retrieves and returns the facets of 'root'.
static ISMLResourceProperty[] retrieveProperties(org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository, ISMLResourceInstance document, org.w3c.dom.Node root)
          Retrieves and returns the properties of 'root'.
static ISMLResourceInstance[] retrieveResources(org.w3c.dom.Node root, org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository)
          Retrieves and returns the resources of 'root'.
static java.lang.String retrieveRootAttribute(org.w3c.dom.Node node, java.lang.String uri, java.lang.String localName)
          Retrieve the value of the attribute with the name space and local name passed in
static java.lang.String[] tokenizeQualifiedName(java.lang.String name)
          Tokenizes the qualified name passed in into two tokens: the prefix and the local name.
static java.lang.String[] toStringArray(java.util.Collection map)
          Converts the map into an String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMLRepositoryUtil

public SMLRepositoryUtil()
Method Detail

extractReference

public static java.lang.String extractReference(org.w3c.dom.Node root)
Extracts the text node representing the SML document reference from the root node passed in.

Parameters:
root - The root node
Returns:
A string representing the SML document reference

retrieveFacets

public static ISMLResourceFacet[] retrieveFacets(ISMLResourceInstance document,
                                                 org.w3c.dom.Node root,
                                                 org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository)
Retrieves and returns the facets of 'root'. Only the facets that are direct children of root are returned.

Parameters:
document - The resource instance
root - The root node
repository - The repository
Returns:
The direct facets of 'root'

retrieveProperties

public static ISMLResourceProperty[] retrieveProperties(org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository,
                                                        ISMLResourceInstance document,
                                                        org.w3c.dom.Node root)
Retrieves and returns the properties of 'root'. Only the properties that are direct children of root are returned.

Parameters:
repository - The repository
document - The parent document
root - The root node that will be used as the context
Returns:
The direct properties of 'root'

retrieveResources

public static ISMLResourceInstance[] retrieveResources(org.w3c.dom.Node root,
                                                       org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository)
Retrieves and returns the resources of 'root'. Only the resources that are direct children of root are returned.

Parameters:
root - The root node that will be used as the context
repository - The repository
Returns:
The direct resources of 'root'

retrieveRootAttribute

public static java.lang.String retrieveRootAttribute(org.w3c.dom.Node node,
                                                     java.lang.String uri,
                                                     java.lang.String localName)
Retrieve the value of the attribute with the name space and local name passed in

Parameters:
node - The context node
uri - The name space URI
localName - The local name
Returns:
The value of the attribute or null if it can't be found

firstSegment

public static java.lang.String firstSegment(java.lang.String path,
                                            int index)
Returns the index-th segment of path starting from the beginning. Null is returned if it is not found

Parameters:
path - The path
index - The index of the segment
Returns:
index-th segment from left; null if it can't be found

isNullOrEmpty

public static boolean isNullOrEmpty(java.lang.String string)
Returns a flag indicating if the passed in string is null or an empty string

Parameters:
string - The string to be checked
Returns:
true if string is null or string.length <= 0

appendSMLIFIdentityInformation

public static void appendSMLIFIdentityInformation(java.lang.StringBuffer buffer,
                                                  org.eclipse.cosmos.rm.repository.provisional.resource.ISMLIFIdentity identity)
Create the starting tags to a new SML-IF file, including the identity information, and append them to the string buffer.

Parameters:
buffer - The string buffer to append the data to
identity - The SML-IF identity

getAlternativeId

public static java.lang.String getAlternativeId(org.eclipse.cosmos.rm.repository.provisional.core.ISMLRepository repository,
                                                java.lang.String id)
A document can have two alternative IDs: one relative to the context root directory or an absolute path from the the context directory.

Parameters:
repository - The repository
id - The id of the document
Returns:
The alternative id that can be used to reference the document

getDocumentName

public static java.lang.String getDocumentName(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document)
Returns the document's id relative to the context root directory

Parameters:
document - The document
Returns:
The path of the document relative to the context root directory

getDocumentPath

public static java.lang.String getDocumentPath(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document)
Returns the full document's id (i.e. an absolute path)

Parameters:
document - The document
Returns:
The absolute path of the document

tokenizeQualifiedName

public static java.lang.String[] tokenizeQualifiedName(java.lang.String name)
Tokenizes the qualified name passed in into two tokens: the prefix and the local name.

Parameters:
name - The qualified name (expected to be in the format :)
Returns:
The tokens of the qualified name

retrieveAlias

public static java.lang.String retrieveAlias(org.eclipse.cosmos.rm.repository.provisional.resource.ISMLDocument document,
                                             java.util.Map aliases)
Retrieves the first alias of the document passed in. The method will first attempt to retrieve the alias from the aliases map. The id of the document is returned if none is found in the aliases map.

Parameters:
document - The document
aliases - Document aliases indexed by document id
Returns:
The first alias of the document

toStringArray

public static java.lang.String[] toStringArray(java.util.Collection map)
Converts the map into an String array. It assumes that the map's values are List of String

Parameters:
map - The map to be converted
Returns:
A string array representation

COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification