Methods Summary |
---|
protected void | addNodeDescriptor(DeploymentDescriptorNode node)Adds a new DOL descriptor instance to the descriptor associated with this
XMLNode
// nodes are added upon creation
ExtensionElementDescriptor dad = (ExtensionElementDescriptor) node.getDescriptor();
Iterator itr = dad.getElementNames();
// jump over first element;
if (itr.hasNext()) itr.next();
if (itr.hasNext() && !dad.hasAttributes()) {
descriptor.addElement(node.getXMLRootTag().getCompleteName(), dad);
} else {
descriptor.addElement(node.getXMLRootTag().getCompleteName(), dad.getElement(node.getXMLRootTag().getCompleteName()));
}
|
public org.w3c.dom.Element | appendChildNS(org.w3c.dom.Node parent, java.lang.String elementName, com.sun.enterprise.deployment.Descriptor descriptor)
Append a new element child to the current node
if (elementName.indexOf(':")!=-1) {
String prefix = elementName.substring(0, elementName.indexOf(':"));
elementName = elementName.substring(elementName.indexOf(':")+1);
String namespace = getNamespaceFor(descriptor, parent, prefix);
Element child = getOwnerDocument(parent).createElementNS(namespace, elementName);
child.setPrefix(prefix);
parent.appendChild(child);
return child;
}
return super.appendChild(parent, elementName);
|
public org.w3c.dom.Node | appendTextChildNS(org.w3c.dom.Node parent, java.lang.String elementName, java.lang.String text, com.sun.enterprise.deployment.Descriptor descriptor)
Append a new text child
if (text == null || text.length()==0)
return null;
Node child = appendChildNS(parent, elementName, descriptor);
child.appendChild(getOwnerDocument(child).createTextNode(text));
return child;
|
public boolean | endElement(XMLElement element)receives notification of the end of an XML element by the Parser
boolean allDone = element.getCompleteName().equals(getXMLRootTag().getCompleteName()) || element.getQName().equals(TagNames.EXTENSION_ELEMENT);
if (allDone) {
postParsing();
((DeploymentDescriptorNode) getParentNode()).addNodeDescriptor(this);
}
return allDone;
|
public java.lang.Object | getDescriptor()
return descriptor;
|
protected java.util.Map | getDispatchTable()all sub-implementation of this class can use a dispatch table to map xml element to
method name on the descriptor class for setting the element value.
return null;
|
public XMLNode | getHandlerFor(XMLElement element)
ExtensionElementNode subNode = new ExtensionElementNode();
subNode.setParentNode(this);
subNode.setXMLRootTag(new XMLElement(element.getCompleteName()));
return subNode;
|
private java.lang.String | getNamespaceFor(com.sun.enterprise.deployment.Descriptor descriptor, org.w3c.dom.Node parent, java.lang.String prefix)look in the mapping defined in this descriptor and in all parent nodes
for the right namespace for the passed prefix
Map prefixMapping = descriptor.getPrefixMapping();
String namespace = null;
if (prefixMapping!=null) {
namespace = (String) prefixMapping.get(prefix);
}
if (namespace==null) {
Element currentNode = (Element) parent;
namespace="";
while (currentNode!=null && namespace.length()==0) {
namespace = currentNode.getAttributeNS("http://www.w3.org/2000/xmlns/", prefix);
if (namespace.length()==0)
currentNode = (Element) currentNode.getParentNode();
}
}
return namespace;
|
public boolean | handlesElement(XMLElement element)
// we are never handling xml fragment only leaf nodes, we create subnodes for that.
return false;
|
public void | setElementValue(XMLElement element, java.lang.String value)receives notification of the value for a particular tag
descriptor.addElement(element.getCompleteName(), value);
|
public void | startElement(XMLElement element, org.xml.sax.Attributes attributes)SAX Parser API implementation, we don't really care for now.
if (attributes.getLength()>0) {
for (int i=0;i<attributes.getLength();i++) {
if (attributes.getLocalName(i).equals("type")) {
// type declaration... replace the standard xml declaration with ours...
descriptor.getAttributes().addExtraAttribute("xsi:type", attributes.getValue(i));
} else {
descriptor.getAttributes().addExtraAttribute(attributes.getQName(i), attributes.getValue(i));
}
}
}
|
protected void | writeDescriptor(org.w3c.dom.Node parentNode, java.lang.String tagName, com.sun.enterprise.deployment.ExtensionElementDescriptor descriptor)write the deployment extensions nodes associated with this node
Element node = appendChildNS(parentNode, tagName, descriptor);
if (descriptor.hasAttributes()) {
Map attributes = descriptor.getAttributes().getExtraAttributes();
for (Iterator itr = attributes.keySet().iterator();itr.hasNext();) {
String key = (String) itr.next();
String value = (String) attributes.get(key);
String namespace = "";
if (key.indexOf(':")!=-1) {
String prefix = key.substring(0, key.indexOf(':"));
namespace = getNamespaceFor(descriptor, parentNode, prefix);
}
node.setAttributeNS(namespace, key, value);
}
}
addNamespaceDeclaration(node, descriptor);
for (Iterator itr = descriptor.getElementNames();itr.hasNext();) {
String elementName = (String) itr.next();
Object value = descriptor.getElement(elementName);
if (value instanceof ExtensionElementDescriptor) {
writeDescriptor(node, elementName, (ExtensionElementDescriptor) value);
} else
if (value instanceof String) {
appendTextChildNS(node, elementName, (String) value, descriptor);
}
}
|