public final class DomHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ANNOTATION_ELEMENT_NAME
The name of the annotation element.
|
static List<String> |
CLASS_FIELD_METHOD_ELEMENT_NAMES
The names of DOM Elements corresponding to Java class Fields or Methods.
|
static String |
DOCUMENTATION_ELEMENT_NAME
The name of the documentation element.
|
static List<String> |
ENUMERATION_FIELD_METHOD_ELEMENT_NAMES
The names of DOM Elements corresponding to Java enum Fields or Methods.
|
static String |
XSD_SCHEMA_NAMESPACE_PREFIX
The namespace schema prefix for the URI
http://www.w3.org/2001/XMLSchema
(i.e. |
Modifier and Type | Method and Description |
---|---|
static void |
addXmlDocumentAnnotationTo(Node aNode,
String formattedDocumentation)
Adds the given formattedDocumentation within an XML documentation annotation under the supplied Node.
|
static ClassLocation |
getClassLocation(Node aNode,
Set<ClassLocation> classLocations)
Retrieves the ClassLocation for the supplied aNode.
|
static String |
getElementTagName(Node aNode)
Retrieves the TagName for the supplied Node if it is an Element, and null otherwise.
|
static FieldLocation |
getFieldLocation(Node aNode,
Set<FieldLocation> fieldLocations)
Retrieves a FieldLocation from the supplied Set, provided that the FieldLocation matches the supplied Node.
|
static <T extends FieldLocation> |
getFieldOrMethodLocationIfValid(Node aNode,
Node containingClassNode,
Set<? extends FieldLocation> locations)
Retrieves a FieldLocation or MethodLocation from the supplied Set of Field- or MethodLocations, provided that
the supplied Node has the given containing Node corresponding to a Class or an Enum.
|
static MethodLocation |
getMethodLocation(Node aNode,
Set<MethodLocation> methodLocations)
Finds the MethodLocation within the given Set, which corresponds to the supplied DOM Node.
|
static String |
getNameAttribute(Node aNode)
Retrieves the value of the
name attribute of the supplied Node. |
static String |
getValueAttribute(Node aNode)
Retrieves the value of the
value attribute of the supplied Node. |
static String |
getXPathFor(Node aNode)
Retrieves the XPath for the supplied Node within its document.
|
static void |
insertXmlDocumentationAnnotationsFor(Node aNode,
SortedMap<ClassLocation,JavaDocData> classJavaDocs,
SortedMap<FieldLocation,JavaDocData> fieldJavaDocs,
SortedMap<MethodLocation,JavaDocData> methodJavaDocs,
JavaDocRenderer renderer)
Processes the supplied DOM Node, inserting XML Documentation annotations if applicable.
|
static boolean |
isNamedElement(Node aNode)
Checks if the supplied DOM Node is a DOM Element having a defined "name" attribute.
|
public static final String ANNOTATION_ELEMENT_NAME
public static final String DOCUMENTATION_ELEMENT_NAME
public static final String XSD_SCHEMA_NAMESPACE_PREFIX
http://www.w3.org/2001/XMLSchema
(i.e. XMLConstants.W3C_XML_SCHEMA_NS_URI
).public static final List<String> CLASS_FIELD_METHOD_ELEMENT_NAMES
public static String getNameAttribute(Node aNode)
name
attribute of the supplied Node.aNode
- A DOM Node.name
attribute of the supplied Node/Element.public static String getValueAttribute(Node aNode)
value
attribute of the supplied Node.aNode
- A DOM Node.value
attribute of the supplied Node/Element.public static boolean isNamedElement(Node aNode)
aNode
- A DOM Node.true
if the supplied aNode is an Elemnet having a defined "name" attribute.public static String getElementTagName(Node aNode)
aNode
- A DOM Node.public static void addXmlDocumentAnnotationTo(Node aNode, String formattedDocumentation)
Adds the given formattedDocumentation within an XML documentation annotation under the supplied Node. Only adds the documentation annotation if the formattedDocumentation is non-null and non-empty. The documentation annotation is on the form:
<xs:annotation>
<xs:documentation>(JavaDoc here, within a CDATA section)</xs:documentation>
</xs:annotation>
aNode
- The non-null Node to which an XML documentation annotation should be added.formattedDocumentation
- The documentation text to add.public static String getXPathFor(Node aNode)
aNode
- The DOM Node for which the XPath should be retrieved.public static ClassLocation getClassLocation(Node aNode, Set<ClassLocation> classLocations)
aNode
- A non-null DOM Node.classLocations
- The set of known ClassLocations, extracted from the JavaDocs.public static MethodLocation getMethodLocation(Node aNode, Set<MethodLocation> methodLocations)
aNode
- A DOM Node.methodLocations
- The Set of all found/known MethodLocation instances.null
if no match was found.public static FieldLocation getFieldLocation(Node aNode, Set<FieldLocation> fieldLocations)
aNode
- The non-null Node.fieldLocations
- The Set of known/found FieldLocation instances.public static <T extends FieldLocation> T getFieldOrMethodLocationIfValid(Node aNode, Node containingClassNode, Set<? extends FieldLocation> locations)
T
- The FieldLocation type.aNode
- A non-null DOM Node.containingClassNode
- A Non-null DOM Node corresponding to a Class or Enum.locations
- A Set containing known/found Field- and MethodLocations.public static void insertXmlDocumentationAnnotationsFor(Node aNode, SortedMap<ClassLocation,JavaDocData> classJavaDocs, SortedMap<FieldLocation,JavaDocData> fieldJavaDocs, SortedMap<MethodLocation,JavaDocData> methodJavaDocs, JavaDocRenderer renderer)
aNode
- The DOM Node to process.classJavaDocs
- A Map relating ClassLocation
s to JavaDocData
.fieldJavaDocs
- A Map relating FieldLocation
s to JavaDocData
.methodJavaDocs
- A Map relating MethodLocation
s to JavaDocData
.renderer
- A non-null JavaDocRenderer
.Copyright © 2005–2016 MojoHaus. All rights reserved.