|
COSMOS ${releaseVersion} resource-modeling Project Internal API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.cosmos.rm.validation.internal.common.SMLValidatorUtil
public class SMLValidatorUtil
Provides common utility method used by multiple classes under different pacakges
| Nested Class Summary | |
|---|---|
static class |
SMLValidatorUtil.RemoteRetrievalException
Thrown when there is an error while retrieving a remote document |
| Field Summary | |
|---|---|
static javax.xml.xpath.XPath |
xpath
A static XPath instance used to compile XPath expressions |
| Constructor Summary | |
|---|---|
SMLValidatorUtil()
|
|
| Method Summary | |
|---|---|
static void |
addAttribute(java.lang.StringBuffer stringBuffer,
org.w3c.dom.NamedNodeMap attributes,
boolean close,
boolean end)
Adds XML attributes to the string buffer passed in. |
static void |
addElement(java.lang.StringBuffer stringBuffer,
int indent,
java.lang.String elementName,
boolean close,
boolean end)
Adds an XML element to the string buffer passed in. |
static void |
addIndent(java.lang.StringBuffer stringBuffer,
int indent)
|
static java.lang.String |
beginTagFor(java.lang.String elementName)
Return an XML begin tag for the elementName. |
static java.lang.String |
beginTagFor(java.lang.String namespace,
java.lang.String elementName)
Return an XML begin tag for the namespace and element name. |
static boolean |
checkWorkspaceDirName(java.lang.String dirName)
Answer whether the destination directory entered is a valid project or folder name. |
static boolean |
checkWorkspaceResourceName(java.lang.String resourceName)
|
static java.lang.String |
createElementTag(java.lang.String elementName,
java.lang.String elementData)
Return a full XML element with begin and end tags, and data in between. |
static java.lang.String |
createElementTag(java.lang.String namespace,
java.lang.String elementName,
java.lang.String elementData)
Return a full XML element with begin and end tags, and data in between. |
static javax.xml.parsers.SAXParser |
createSAXParser(java.lang.Object schemaSource,
boolean validating,
org.xml.sax.ext.LexicalHandler lexicalHandler,
IValidationOutput validationLogger)
Answer a new SAXParser instance with the specified attributes. |
static IValidationMessage |
createValidationMessage(DocumentDOMBuilder builder,
org.w3c.dom.Node node,
java.lang.String error)
|
static boolean |
deleteFileTree(java.io.File root)
This method attempts to delete the specified root file. |
static org.w3c.dom.Document |
domParseDocument(java.io.InputStream resource)
|
static org.w3c.dom.Document |
domParseDocument(java.io.InputStream resource,
boolean ignoreComments,
boolean ignoreWhitespace)
Uses a DOM parser to parse the XML file passed in |
static java.lang.String |
endTagFor(java.lang.String elementName)
Return an XML end tag for the elementName. |
static java.lang.String |
endTagFor(java.lang.String namespace,
java.lang.String elementName)
Return an XML end tag for the namespace and element name. |
protected static java.lang.Throwable |
findCause(java.lang.Throwable t)
|
protected static java.lang.String |
getExceptionStackTrace(java.lang.Throwable t)
|
static int |
identifyDocumentType(ResourceWrapper resource)
Returns ISMLConstants.TYPE_DEFINITION if the document type is determined to be definition,
ISMLConstants.TYPE_INSTANCE if instance, ISMLConstants.TYPE_SMLIF
if SML-IF, and ISMLConstants.TYPE_UNKNOWN if content type is unknown |
static int |
identifyDocumentTypeShowError(org.eclipse.core.resources.IFile file)
|
static boolean |
isWhitespace(org.w3c.dom.Node node)
|
static void |
openErrorWithDetail(org.eclipse.swt.widgets.Shell parent,
java.lang.String title,
java.lang.String message,
java.lang.String cause)
|
static void |
openErrorWithDetail(java.lang.String title,
java.lang.String message,
java.lang.Throwable t)
|
static void |
openErrorWithDetail(java.lang.String title,
java.lang.String message,
java.lang.Throwable t,
boolean defaultParent)
|
static java.lang.String |
removeLineBreaks(java.lang.String str)
Removes line breaks and any spaces that follow a line break |
static java.lang.String |
retrieveAbsolutePath(java.lang.String path)
|
static org.w3c.dom.Node[] |
retrieveChildElements(org.w3c.dom.Node node)
Retrieves and returns the child elements of node (i.e. nodes of type Node.ELEMENT_NODE) |
static java.lang.Object |
retrieveDataStructure(java.lang.String databuilderId)
A helper method provided to retrieve the data structure for a databuilder with the given id. |
static java.util.Map |
retrieveNestedMap(java.util.Map map,
java.lang.String key,
boolean create)
|
static org.w3c.dom.Node |
retrieveRemoteDocument(java.lang.String uri)
This method is used to retrieve an XML document referenced by a URI. |
static void |
saxParseDocument(java.io.InputStream resource,
org.xml.sax.helpers.DefaultHandler contentHandler)
Parses the document passed in |
static void |
serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node)
Equivalent to serializeNode(buffer, node, -1, false) |
static void |
serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node,
int indent,
boolean autoFormat)
Equivalent to serializeNode(buffer, node, indent, null, null) |
static void |
serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node,
int indent,
java.lang.String currentIndex,
java.util.Map indices,
boolean autoFormat)
Used to serialize a node into string |
static java.lang.String |
stringReplace(java.lang.String originalString,
java.lang.String oldSubstring,
java.lang.String newSubstring)
Replace all occurrences of oldString in originalString with newString. |
static java.lang.String |
tagFor(boolean end,
java.lang.String namespace,
java.lang.String elementName)
Utility method to return a begin or end tag for the namespace and elementName input. |
static java.lang.String |
tagNameFor(java.lang.String namespace,
java.lang.String elementName)
Return a string that forms a tag name for the namespace and elementName in namespace:elementName format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static javax.xml.xpath.XPath xpath
| Constructor Detail |
|---|
public SMLValidatorUtil()
| Method Detail |
|---|
public static java.lang.Object retrieveDataStructure(java.lang.String databuilderId)
id - The data builder idpublic static java.lang.String removeLineBreaks(java.lang.String str)
str - The string
public static java.util.Map retrieveNestedMap(java.util.Map map,
java.lang.String key,
boolean create)
public static org.w3c.dom.Node retrieveRemoteDocument(java.lang.String uri)
throws SMLValidatorUtil.RemoteRetrievalException
uri - The uri where the document resides
SMLValidatorUtil.RemoteRetrievalException
public static org.w3c.dom.Document domParseDocument(java.io.InputStream resource,
boolean ignoreComments,
boolean ignoreWhitespace)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
resource - The resource to be parsed
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static org.w3c.dom.Document domParseDocument(java.io.InputStream resource)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static void saxParseDocument(java.io.InputStream resource,
org.xml.sax.helpers.DefaultHandler contentHandler)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
resource - The resource to read fromcontentHandler - The content handler
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static int identifyDocumentType(ResourceWrapper resource)
throws java.io.IOException,
org.eclipse.core.runtime.CoreException
ISMLConstants.TYPE_DEFINITION if the document type is determined to be definition,
ISMLConstants.TYPE_INSTANCE if instance, ISMLConstants.TYPE_SMLIF
if SML-IF, and ISMLConstants.TYPE_UNKNOWN if content type is unknown
resource - The file to be checked
org.eclipse.core.runtime.CoreException
java.io.IOExceptionpublic static int identifyDocumentTypeShowError(org.eclipse.core.resources.IFile file)
public static void addElement(java.lang.StringBuffer stringBuffer,
int indent,
java.lang.String elementName,
boolean close,
boolean end)
stringBuffer - The string buffer that the element will be written toindent - The number of indents that should be prefixed to the element writtenelementName - The element nameclose - Indicates whether this element should be closed or not. If set,
a forward slash is added before theelement is ended.end - Indicates if the element should be ended with a closed angle bracket.
For example elements requring attributes are not ended.
public static void addAttribute(java.lang.StringBuffer stringBuffer,
org.w3c.dom.NamedNodeMap attributes,
boolean close,
boolean end)
stringBuffer - The string buffer that the attributes will be written toattributes - attributesclose - If set, a forward slash is added after the attributes.end - If set, a closed angle bracket is added after the attributes
public static void addIndent(java.lang.StringBuffer stringBuffer,
int indent)
public static boolean deleteFileTree(java.io.File root)
root -
public static org.w3c.dom.Node[] retrieveChildElements(org.w3c.dom.Node node)
node - The node
public static java.lang.String tagNameFor(java.lang.String namespace,
java.lang.String elementName)
namespace - elementName -
public static java.lang.String beginTagFor(java.lang.String elementName)
elementName -
public static java.lang.String beginTagFor(java.lang.String namespace,
java.lang.String elementName)
namespace - elementName -
public static java.lang.String endTagFor(java.lang.String elementName)
elementName -
public static java.lang.String endTagFor(java.lang.String namespace,
java.lang.String elementName)
namespace - elementName -
public static java.lang.String tagFor(boolean end,
java.lang.String namespace,
java.lang.String elementName)
end - namespace - elementName -
public static java.lang.String createElementTag(java.lang.String elementName,
java.lang.String elementData)
elementName - elementData -
public static java.lang.String createElementTag(java.lang.String namespace,
java.lang.String elementName,
java.lang.String elementData)
namespace - elementName - elementData -
public static void openErrorWithDetail(org.eclipse.swt.widgets.Shell parent,
java.lang.String title,
java.lang.String message,
java.lang.String cause)
public static void openErrorWithDetail(java.lang.String title,
java.lang.String message,
java.lang.Throwable t)
public static void openErrorWithDetail(java.lang.String title,
java.lang.String message,
java.lang.Throwable t,
boolean defaultParent)
protected static java.lang.String getExceptionStackTrace(java.lang.Throwable t)
protected static java.lang.Throwable findCause(java.lang.Throwable t)
public static java.lang.String stringReplace(java.lang.String originalString,
java.lang.String oldSubstring,
java.lang.String newSubstring)
originalString - original source stringoldSubstring - substring to be replacednewSubstring - new text to be substituted for oldSubstring
java.lang.NullPointerException - if any argument is null
public static IValidationMessage createValidationMessage(DocumentDOMBuilder builder,
org.w3c.dom.Node node,
java.lang.String error)
public static void serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node,
int indent,
boolean autoFormat)
public static void serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node)
public static void serializeNode(java.lang.StringBuffer buffer,
org.w3c.dom.Node node,
int indent,
java.lang.String currentIndex,
java.util.Map indices,
boolean autoFormat)
buffer - The buffer that the string will be written tonode - The starting nodeindent - The starting indent level (use 0 if starting at root)currentIndex - The current index of the node (use null if not interested to store indices)indices - The indices map (currentIndex must not be null if indices is used)autoFormat - Indicates whether the XML content should be formattedpublic static boolean isWhitespace(org.w3c.dom.Node node)
public static javax.xml.parsers.SAXParser createSAXParser(java.lang.Object schemaSource,
boolean validating,
org.xml.sax.ext.LexicalHandler lexicalHandler,
IValidationOutput validationLogger)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedExceptionpublic static java.lang.String retrieveAbsolutePath(java.lang.String path)
public static boolean checkWorkspaceDirName(java.lang.String dirName)
dirName -
public static boolean checkWorkspaceResourceName(java.lang.String resourceName)
|
COSMOS ${releaseVersion} resource-modeling Project Internal API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||