public boolean set(Node otherNode) { if (otherNode == null) return false; setName(otherNode.getName()); setValue(otherNode.getValue()); removeAllAttributes(); int nOtherAttributes = otherNode.getNAttributes(); for (int n=0; n<nOtherAttributes; n++) { Attribute otherAttr = otherNode.getAttribute(n); Attribute thisAttr = new Attribute(otherAttr); addAttribute(thisAttr); } removeAllNodes(); int nOtherChildNodes = otherNode.getNNodes(); for (int n=0; n<nOtherChildNodes; n++) { Node otherChildNode = otherNode.getNode(n); Node thisChildNode = new Node(); thisChildNode.set(otherChildNode); addNode(thisChildNode); } return true; }
public void output(PrintWriter ps, int indentLevel, boolean hasChildNode) { String indentString = getIndentLevelString(indentLevel); String name = getName(); String value = getValue(); if (hasNodes() == false || hasChildNode == false) { ps.print(indentString + "<" + name); outputAttributes(ps); // Thnaks for Tho Beisch (11/09/04) if (value == null || value.length() == 0) { // Not using the short notation <node /> because it cause compatibility trouble ps.println("></" + name + ">"); } else { ps.println(">" + XML.escapeXMLChars(value) + "</" + name + ">"); } return; } ps.print(indentString + "<" + name); outputAttributes(ps); ps.println(">"); int nChildNodes = getNNodes(); for (int n=0; n<nChildNodes; n++) { Node cnode = getNode(n); cnode.output(ps, indentLevel+1, true); } ps.println(indentString +"</" + name + ">"); }
private Node createResponseNode(String var) { Node queryResNode = new Node(); queryResNode.setName(Control.NS, Control.QUERY_STATE_VARIABLE_RESPONSE); queryResNode.setNameSpace(Control.NS, Control.XMLNS); Node returnNode = new Node(); returnNode.setName(Control.RETURN); returnNode.setValue(var); queryResNode.addNode(returnNode); return queryResNode; } }
public ArgumentList getResponse() { ArgumentList argList = new ArgumentList(); Node resNode = getActionResponseNode(); if (resNode == null) return argList; int nArgs = resNode.getNNodes(); for (int n=0; n<nArgs; n++) { Node node = resNode.getNode(n); String name = node.getName(); String value = node.getValue(); Argument arg = new Argument(name, value); argList.add(arg); } return argList; } }
public boolean set(Node node) { // Child Node -> Property; int nNode = node.getNNodes(); for (int n=0; n<nNode; n++) { Node cnode = node.getNode(n); if (ContainerNode.isContainerNode(cnode) == true) continue; if (ItemNode.isItemNode(cnode) == true) continue; setProperty(cnode.getName(), cnode.getValue()); } // Attribute -> Attribute; int nAttr = node.getNAttributes(); for (int n=0; n<nAttr; n++) { Attribute attr = node.getAttribute(n); setAttribute(attr.getName(), attr.getValue()); } return true; }
public PropertyList getPropertyList() { PropertyList properties = new PropertyList(); Node varSetNode = getEnvelopeNode(); // I2P change: ParserException caught in getRootNode() causes // getEnvelopeNode() to return null if (varSetNode == null) return properties; for (int i = 0; i<varSetNode.getNNodes(); i++){ Node propNode = varSetNode.getNode(i); if (propNode == null) continue; Property prop = getProperty(propNode.getNode(0)); properties.add(prop); } return properties; }
private void setURLBase(String value) { if (isRootDevice() == true) { Node node = getRootNode().getNode(URLBASE_NAME); if (node != null) { node.setValue(value); return; } node = new Node(URLBASE_NAME); node.setValue(value); int index = 1; if (getRootNode().hasNodes() == false) index = 1; getRootNode().insertNode(node, index); } }
public void setArgumentList(ArgumentList al){ Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME); if (argumentListNode == null){ argumentListNode = new Node(ArgumentList.ELEM_NAME); getActionNode().addNode(argumentListNode); }else{ argumentListNode.removeAllNodes(); } Iterator<Argument> i = al.iterator(); while (i.hasNext()) { Argument a = i.next(); a.setService(getService()); argumentListNode.addNode(a.getArgumentNode()); } }
/** * Add a Service to device without checking for duplicate or syntax error * * @param s * Add Service s to the Device */ public void addService(Service s) { Node serviceListNode = getDeviceNode().getNode(ServiceList.ELEM_NAME); if (serviceListNode == null) { serviceListNode = new Node(ServiceList.ELEM_NAME); getDeviceNode().addNode(serviceListNode); } serviceListNode.addNode(s.getServiceNode()); }
public boolean set(Node node) { setValue(node.getValue()); // Attribute -> Attribute; int nAttr = node.getNAttributes(); for (int n=0; n<nAttr; n++) { Attribute attr = node.getAttribute(n); setAttribute(attr.getName(), attr.getValue()); } return true; }
public final static Node createEnvelopeBodyNode() { // <Envelope> Node envNode = new Node(SOAP.XMLNS + SOAP.DELIM + SOAP.ENVELOPE); envNode.setAttribute("xmlns" + SOAP.DELIM + SOAP.XMLNS, SOAP.XMLNS_URL); envNode.setAttribute(SOAP.XMLNS + SOAP.DELIM + "encodingStyle", SOAP.ENCSTYLE_URL); // <Body> Node bodyNode = new Node(SOAP.XMLNS + SOAP.DELIM + SOAP.BODY); envNode.addNode(bodyNode); return envNode; }
public static boolean isArgumentNode(Node node) { return Argument.ELEM_NAME.equals(node.getName()); }
public String getValue() { return getAllowedValueNode().getValue(); } }
public void outputAttributes(PrintWriter ps) { int nAttributes = getNAttributes(); for (int n=0; n<nAttributes; n++) { Attribute attr = getAttribute(n); ps.print(" " + attr.getName() + "=\"" + XML.escapeXMLChars(attr.getValue()) + "\""); } }
public void setAttribute(String name, String value) { Attribute attr = getAttribute(name); if (attr != null) { attr.setValue(value); return; } attr = new Attribute(name, value); addAttribute(attr); }
private Property getProperty(Node varNode) { Property prop = new Property(); if (varNode == null) return prop; // remove the event namespace String variableName = varNode.getName(); int index = variableName.lastIndexOf(':'); if (index != -1) variableName = variableName.substring(index + 1); prop.setName(variableName); prop.setValue(varNode.getValue()); return prop; }