summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-09 10:07:35 (EDT)
committerpelder2007-05-09 10:07:35 (EDT)
commit76370c9230386f0c07fb3e6016342c1e0a91752d (patch)
tree6832c3cf5ce4bcec9ac3ccf1279c14290f36c745
parentae7ecbc6e4e2f6559b37696db329830b621ef1fa (diff)
downloadorg.eclipse.jet-76370c9230386f0c07fb3e6016342c1e0a91752d.zip
org.eclipse.jet-76370c9230386f0c07fb3e6016342c1e0a91752d.tar.gz
org.eclipse.jet-76370c9230386f0c07fb3e6016342c1e0a91752d.tar.bz2
[178693] NullPointerException in c:dump tag
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/DumpTag.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/DumpTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/DumpTag.java
index d1e1760..4bff46a 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/DumpTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/DumpTag.java
@@ -123,6 +123,7 @@ public class DumpTag extends AbstractEmptyTag {
final String NODE_VALUE_XPATH = "string()"; //$NON-NLS-1$
XPathContextExtender xpc = XPathContextExtender.getInstance(context);
+ if(node == null) return;
INodeInspector inspector = InspectorManager.getInstance().getInspector(node);
if(inspector == null)
{
@@ -133,15 +134,20 @@ public class DumpTag extends AbstractEmptyTag {
if(nodeKind == NodeKind.ELEMENT)
{
out.append("<"); //$NON-NLS-1$
- final String tagName = inspector.nameOf(node);
+ String tagName = inspector.nameOf(node);
+ if(tagName == null) tagName = "???"; //$NON-NLS-1$
out.append(tagName);
final Object[] attrs = xpc.resolve(node, ATTRIBUTEs_XPATH);
for (int i = 0; attrs != null && i < attrs.length; i++)
{
out.append(" "); //$NON-NLS-1$
- out.append(xpc.resolveAsString(attrs[i], ATTRIBUTE_NAME_XPATH));
+ String attrName = xpc.resolveAsString(attrs[i], ATTRIBUTE_NAME_XPATH);
+ if(attrName == null) attrName = "???"; //$NON-NLS-1$
+ out.append(attrName);
out.append("="); //$NON-NLS-1$
- out.append(useRightQuotes(xpc.resolveAsString(attrs[i], NODE_VALUE_XPATH)));
+ String value = xpc.resolveAsString(attrs[i], NODE_VALUE_XPATH);
+ if(value == null) value = ""; //$NON-NLS-1$
+ out.append(useRightQuotes(value));
}
final Object[] children = xpc.resolve(node, CHILD_NODES_XPATH);
if(children != null && children.length > 0)
@@ -159,14 +165,17 @@ public class DumpTag extends AbstractEmptyTag {
}
else if(nodeKind == NodeKind.TEXT)
{
- String buffer = xpc.resolveAsString(node, NODE_VALUE_XPATH);
- if (entities) { buffer = insertEntities(buffer); }
- out.append(buffer);
+ String value = xpc.resolveAsString(node, NODE_VALUE_XPATH);
+ if(value == null) value = ""; //$NON-NLS-1$
+ if (entities) { value = insertEntities(value); }
+ out.append(value);
}
else if(nodeKind == NodeKind.COMMENT)
{
out.append("<!--"); //$NON-NLS-1$
- out.append(xpc.resolveAsString(node, NODE_VALUE_XPATH));
+ String value = xpc.resolveAsString(node, NODE_VALUE_XPATH);
+ if(value == null) value = ""; //$NON-NLS-1$
+ out.append(value);
out.append("-->"); //$NON-NLS-1$
}
else if(nodeKind == NodeKind.ROOT)
@@ -203,7 +212,7 @@ public class DumpTag extends AbstractEmptyTag {
continue;
}
INodeInspector childInspector = InspectorManager.getInstance().getInspector(children[i]);
- textEncountered = textEncountered || childInspector.getNodeKind(children[i]) == NodeKind.TEXT;
+ textEncountered = textEncountered || (childInspector != null && childInspector.getNodeKind(children[i]) == NodeKind.TEXT);
if(!textEncountered && format)
{
@@ -276,6 +285,7 @@ public class DumpTag extends AbstractEmptyTag {
}
if (inspector.getNodeKind(node) == NodeKind.TEXT) {
String buffer = inspector.stringValueOf(node);
+ if(buffer == null) buffer = ""; //$NON-NLS-1$
// if (node.isCDataNode()) {
// out.write("<![CDATA["+buffer+"]]>");
// written = true;