public class AnythingToString extends JsonDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { TreeNode tree = jp.getCodec().readTree(jp); return tree.toString(); } }
/** * Construct a new node with the specified parent. * * @param name The name of this node * @param parent The node that is the parent of this node */ public TreeNode(String name, TreeNode parent) { super(); this.name = name; this.parent = parent; if (this.parent != null) this.parent.addChild(this); }
TreeNode rootNode = new TreeNode(); rootNode.setCanAcceptDrop(false); rootNode.setID("0"); rootNode.setAttribute("Name","ROOT"); rootNode.setIcon("16/root.png"); tree.setRoot(rootNode);
TreeNode parent = new TreeNode("MyParentNode"); TreeNode child0 = new TreeNode("ChildNode0"); TreeNode child1 = new TreeNode("ChildNode1"); parent.addChildren(child0, child1); root.addChild(parent);
sb.append(' '); sb.append('<'); sb.append(node.getName()); Iterator names = node.findAttributes(); while (names.hasNext()) { sb.append(' '); sb.append(name); sb.append("=\""); String value = node.findAttribute(name); sb.append(value); sb.append("\""); String body = node.getBody(); if ((body != null) && (body.length() > 0)) { for (int i = 0; i < indent2; i++) Iterator<TreeNode> children = node.findChildren(); while (children.hasNext()) { TreeNode child = children.next(); toString(sb, indent2, child); sb.append(' '); sb.append("</"); sb.append(node.getName()); sb.append(">\n");
if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) { err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML, TAG_PLUGINS_ROOT_ELEM); Iterator<TreeNode> pluginList = root.findChildren("tag-plugin"); while (pluginList.hasNext()) { TreeNode pluginNode = pluginList.next(); TreeNode tagClassNode = pluginNode.findChild("tag-class"); if (tagClassNode == null) { String tagClass = tagClassNode.getBody().trim(); TreeNode pluginClassNode = pluginNode.findChild("plugin-class"); if (pluginClassNode == null) { String pluginClassStr = pluginClassNode.getBody(); TagPlugin tagPlugin = null; try {
private String[] createInitParam(TreeNode elem) throws JasperException { String[] initParam = new String[2]; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("param-name".equals(tname)) { initParam[0] = element.getBody(); } else if ("param-value".equals(tname)) { initParam[1] = element.getBody(); } else if ("description".equals(tname)) { ; // Do nothing } else { err.jspError("jsp.error.unknown.element.in.initParam", tname); } } return initParam; }
TreeNode treeNode = new TreeNode(node.getNodeName(), parent); for (int i = 0; i < n; i++) { Node attribute = attributes.item(i); treeNode.addAttribute(attribute.getNodeName(), attribute.getNodeValue()); body = body.trim(); if (body.length() > 0) treeNode.setBody(body);
this.jspversion = tld.findAttribute("version"); Iterator list = tld.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) || "tlib-version".equals(tname)) { this.tlibversion = element.getBody(); } else if ("jspversion".equals(tname) || "jsp-version".equals(tname)) { this.jspversion = element.getBody(); } else if (!"shortname".equals(tname) && !"short-name".equals(tname)) {
TreeNode uriNode = tld.findChild("uri"); if (uriNode != null) { uri = uriNode.getBody(); Iterator<TreeNode>listenerNodes = tld.findChildren("listener"); while (listenerNodes.hasNext()) { TreeNode listener = listenerNodes.next(); TreeNode listenerClass = listener.findChild("listener-class"); if (listenerClass != null) { String listenerClassName = listenerClass.getBody(); if (listenerClassName != null) { listeners.add(listenerClassName);
private String getUriFromTld(String resourcePath, InputStream in) throws JasperException { // Parse the tag library descriptor at the specified resource path /* SJSAS 6384538 TreeNode tld = new ParserUtils().parseXMLDocument(resourcePath, in); */ // START SJSAS 6384538 TreeNode tld = new ParserUtils().parseXMLDocument( resourcePath, in, options.isValidationEnabled()); // END SJSAS 6384538 TreeNode uri = tld.findChild("uri"); if (uri != null) { String body = uri.getBody(); if (body != null) return body; } return null; }
/** * Return the first child node of this node with the specified name, * if there is one; otherwise, return <code>null</code>. * * @param name Name of the desired child element */ public TreeNode findChild(String name) { if (children == null) return (null); for (TreeNode item: children) { if (name.equals(item.getName())) return (item); } return (null); }
private double getVersion(TreeNode webApp) { String v = webApp.findAttribute("version"); if (v != null) { try { return Double.parseDouble(v); } catch (NumberFormatException e) { } } return 2.3; }
sb.append(' '); sb.append('<'); sb.append(node.getName()); Iterator names = node.findAttributes(); while (names.hasNext()) { sb.append(' '); sb.append(name); sb.append("=\""); String value = node.findAttribute(name); sb.append(value); sb.append("\""); String body = node.getBody(); if ((body != null) && (body.length() > 0)) { for (int i = 0; i < indent2; i++) Iterator children = node.findChildren(); while (children.hasNext()) { TreeNode child = (TreeNode) children.next(); toString(sb, indent2, child); sb.append(' '); sb.append("</"); sb.append(node.getName()); sb.append(">\n");
if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) { err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML, TAG_PLUGINS_ROOT_ELEM); Iterator pluginList = root.findChildren("tag-plugin"); while (pluginList.hasNext()) { TreeNode pluginNode = (TreeNode) pluginList.next(); TreeNode tagClassNode = pluginNode.findChild("tag-class"); if (tagClassNode == null) { String tagClass = tagClassNode.getBody().trim(); TreeNode pluginClassNode = pluginNode.findChild("plugin-class"); if (pluginClassNode == null) { String pluginClassStr = pluginClassNode.getBody(); TagPlugin tagPlugin = null; try {
private String[] createInitParam(TreeNode elem) throws JasperException { String[] initParam = new String[2]; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("param-name".equals(tname)) { initParam[0] = element.getBody(); } else if ("param-value".equals(tname)) { initParam[1] = element.getBody(); } else if ("description".equals(tname)) { ; // Do nothing } else { err.jspError("jsp.error.unknown.element.in.initParam", tname); } } return initParam; }
TreeNode treeNode = new TreeNode(node.getNodeName(), parent); for (int i = 0; i < n; i++) { Node attribute = attributes.item(i); treeNode.addAttribute(attribute.getNodeName(), attribute.getNodeValue()); body = body.trim(); if (body.length() > 0) treeNode.setBody(body);
this.jspversion = tld.findAttribute("version"); Iterator list = tld.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) || "tlib-version".equals(tname)) { this.tlibversion = element.getBody(); } else if ("jspversion".equals(tname) || "jsp-version".equals(tname)) { this.jspversion = element.getBody(); } else if (!"shortname".equals(tname) && !"short-name".equals(tname)) {