com.google.gwt.xml.client.Node Java Examples

The following examples show how to use com.google.gwt.xml.client.Node. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertiesAdapter.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {
    String label = ParseUtils.IDOrLabel(node);

    String op = ParseUtils.failSafe(node.getAttributes().getNamedItem("operator"), TemporalOperator.Concurrency.toString());

    //QName id = QName.valueOf(node.getAttributes().getNamedItem("id").getNodeValue());
    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());

    Container properties = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            TemporalOperator.valueOf(op),
            StereoTypes.Properties);
    return properties;
}
 
Example #2
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void endVisit(Container container) {
    if(stack.size()>1){
        Node el = stack.pop();
        stack.peek().appendChild(el);
    }
    else if(stack.size()==1)
    {
        Node root = stack.pop();

        Element dialogEl = DOMUtils.createElementNS(document, dialog.getId().getNamespaceURI(), "dialog");
        dialogEl.setAttribute("id", dialog.getId().getLocalPart());
        dialogEl.appendChild(root);
        document.appendChild(dialogEl);

    }
    else
    {
        throw new RuntimeException("Parse error");
    }
}
 
Example #3
Source File: EditorPanelAdapter.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {

    String label = ParseUtils.IDOrLabel(node);

    //QName id = QName.valueOf(node.getAttributes().getNamedItem("id").getNodeValue());
    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());

    Container container = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            TemporalOperator.Choice,
            StereoTypes.EditorPanel);

    return container;
}
 
Example #4
Source File: DOMUtils.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Node getFirstChildElement(Node parent) {
    NodeList children = parent.getChildNodes();

    for(int i=0; i<children.getLength(); i++)
    {
        Node child = children.item(i);
        if(child.getNodeType() == Node.ELEMENT_NODE)
            return child;
    }

    return null;
}
 
Example #5
Source File: ToolstripAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {

    String label = ParseUtils.IDOrLabel(node);

    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());
    Container tools = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            StereoTypes.Toolstrip);
    return tools;
}
 
Example #6
Source File: TodoAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {

    String label = ParseUtils.IDOrLabel(node);

    String idAtt = UUID.uuid().toString();//node.getAttributes().getNamedItem("id").getNodeValue();
    QName id = new QName(node.getNamespaceURI(), "todo_"+idAtt);
    Output output = new Output(
            id.getNamespaceURI(), id.getLocalPart(),
            label, StereoTypes.Todo);

    return output;
}
 
Example #7
Source File: FormAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {
    String label = ParseUtils.IDOrLabel(node);

    //QName id = QName.valueOf(node.getAttributes().getNamedItem("id").getNodeValue());
    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());

    Container form = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            TemporalOperator.Concurrency,
            StereoTypes.Form);
    return form;
}
 
Example #8
Source File: PulldownAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {

    String label = ParseUtils.IDOrLabel(node);

    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());
    Container form = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            StereoTypes.PullDown);
    return form;
}
 
Example #9
Source File: DMRAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public DMRMapping fromXML(Node node) {

    DMRMapping mapping = new DMRMapping();
    Node address = node.getAttributes().getNamedItem("address");
    if(address !=null)
    {
        mapping.setAddress(address.getNodeValue());
    }

    NodeList children = node.getChildNodes();
    List<String> attributes = new LinkedList<String>();
    List<String> objects = new LinkedList<String>();
    for(int i=0; i<children.getLength(); i++)
    {
        Node child = children.item(i);
        if(!( Node.ELEMENT_NODE == child.getNodeType()))
            continue;

        if(child.getNodeName().equals("attribute"))
        {
            attributes.add(child.getAttributes().getNamedItem("name").getNodeValue());
        }
        else if(child.getNodeName().equals("object"))
        {
            objects.add(child.getAttributes().getNamedItem("name").getNodeValue());
        }
    }
    mapping.addAttributes(attributes);
    mapping.addObjects(objects);
    return mapping;
}
 
Example #10
Source File: PagesAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {

    String label = ParseUtils.IDOrLabel(node);

    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());
    Container form = new Container(
            id.getNamespaceURI(), id.getLocalPart(),
            label,
            TemporalOperator.Choice,
            StereoTypes.Pages);
    return form;
}
 
Example #11
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseTest(Node test, Test t) {
	Element testEl = (Element) test;

	HashMap<Integer, String> args = new HashMap<>();

	t.exception = testEl.getAttribute("expect");

	Element op = (Element) testEl.getElementsByTagName("op").item(0);

	NamedNodeMap attrs = op.getAttributes();
	for (int i = 0; i < attrs.getLength(); i++) {
		Node attr = attrs.item(i);
		String name = attr.getNodeName();

		switch (name) {
		case "name":
			t.operation = attr.getNodeValue();
			break;
		default:
			if (name.startsWith("arg")) {
				int argIdx = Integer.valueOf(name.replace("arg", ""));
				args.put(argIdx, attr.getNodeValue());
			} else {
				// sLogger.severe("-------" + name + "-------");
			}
			break;
		}
	}

	for (int i = 1; i <= args.size(); i++) {
		String argN = args.get(i);
		t.arguments.add(argN);
	}

	t.result = op.getChildNodes().item(0).getNodeValue().trim();
}
 
Example #12
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseTestCase(Node case0, TestCase tc) {
	NodeList caseChildren = case0.getChildNodes();

	for (int i = 0; i < caseChildren.getLength(); i++) {
		Node caseChild = caseChildren.item(i);
		String name = caseChild.getNodeName();

		switch (name) {
		case "desc":
			tc.description = trim(caseChild.getChildNodes().item(0)
					.getNodeValue());
			break;
		case "a":
			tc.geometryA = trim(caseChild.getChildNodes().item(0)
					.getNodeValue());
			break;
		case "b":
			tc.geometryB = trim(caseChild.getChildNodes().item(0)
					.getNodeValue());
			break;
		case "test":
			Test t = new Test();
			tc.tests.add(t);
			parseTest(caseChild, t);
			break;
		default:
			// sLogger.severe("-------" + name + "-------");
			break;
		}
	}
}
 
Example #13
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void dfsElement(Builder builder, Node root) {

        // the node itself
        ElementAdapter adapter = getAdapter(root.getNodeName());

        if(InteractionUnit.class == adapter.getType())
        {
            // interaction unit contents
            InteractionUnit unit = (InteractionUnit)adapter.fromXML(root);

            if(unit instanceof Container)
                builder.start((Container)unit);
            else
                builder.add(unit);

            // it's children
            NodeList children = root.getChildNodes();

            for(int i=0; i<children.getLength(); i++)
            {

                Node child = children.item(i);

                // skip anything except elements
                if(! (Node.ELEMENT_NODE == child.getNodeType()))
                    continue;

                if(child.hasChildNodes())
                {
                    dfsElement(builder, child);
                }
                else
                {
                    ElementAdapter childAdapter = getAdapter(child.getNodeName());
                    if(DMRMapping.class==childAdapter.getType())
                        builder.mappedBy((DMRMapping)childAdapter.fromXML(child));
                    else if(InteractionUnit.class==childAdapter.getType())
                        builder.add((InteractionUnit)childAdapter.fromXML(child));
                }
            }

            if(unit instanceof Container)
                builder.end();
        }
        else if (DMRMapping.class == adapter.getType())
        {
            // dmr mapping contents
            DMRMapping mapping = (DMRMapping) adapter.fromXML(root);
            builder.mappedBy(mapping);
        }

    }
 
Example #14
Source File: UsewareAdapter.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public InteractionUnit fromXML(Node node) {
    return createUnitByName(elementName, node);
}
 
Example #15
Source File: UsewareAdapter.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private InteractionUnit createUnitByName(String name, Node node)
{
    InteractionUnit unit = null;

    //QName.valueOf(node.getAttributes().getNamedItem("id").getNodeValue());
    QName id = new QName(node.getNamespaceURI(), node.getAttributes().getNamedItem("id").getNodeValue());
    String label = ParseUtils.IDOrLabel(node);

    if("container".equals(name))
    {
        String op = ParseUtils.failSafe(node.getAttributes().getNamedItem("operator"), TemporalOperator.Concurrency.toString());
        unit = new Container(
                id.getNamespaceURI(), id.getLocalPart(),
                label,
                TemporalOperator.valueOf(op)
        );

    }
    else if("input".equals(name))
    {
        unit = new Input(id.getNamespaceURI(), id.getLocalPart(),
                label);

    }
    else if("output".equals(name))
    {

        unit = new Output(id.getNamespaceURI(), id.getLocalPart(),
                label);
    }
    else if("select".equals(name))
    {
        unit = new Select(id.getNamespaceURI(), id.getLocalPart(),
                label);
    }
    else if("trigger".equals(name))
    {
        unit = new Trigger(id.getNamespaceURI(), id.getLocalPart(),
                QName.valueOf(ParseUtils.failSafe(node.getAttributes().getNamedItem("type"), "")),
                label);
    }
    else if("link".equals(name))
    {
        unit = new Link(id.getNamespaceURI(), id.getLocalPart(),
                QName.valueOf(ParseUtils.failSafe(node.getAttributes().getNamedItem("target"), "")),
                label);
    }
    return unit;
}
 
Example #16
Source File: ParseUtils.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String failSafe(Node node, String fallback)
{
    return node !=null ? node.getNodeValue() : fallback;
}
 
Example #17
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestRun read(String s) {

		Document doc = XMLParser.parse(s);
		TestRun tr = new TestRun();

		Element run = doc.getDocumentElement();

		NodeList runChildren = run.getChildNodes();
		for (int i = 0; i < runChildren.getLength(); i++) {
			Node runChild = runChildren.item(i);
			String name = runChild.getNodeName();

			switch (name) {
			case "desc":
				tr.description = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "precisionModel":
				tr.precisionModel = trim(((Element) runChild)
						.getAttribute("type"));
				break;
			case "resultMatcher":
				tr.resultMatcher = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "geometryOperation":
				tr.geometryOperation = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "case":
				TestCase tc = new TestCase();
				tr.testCases.add(tc);
				parseTestCase(runChild, tc);
				break;
			default:
				// sLogger.severe("-------" + name + "-------");
				break;
			}
		}

		return tr;
	}
 
Example #18
Source File: DOMUtils.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static JavaScriptObject getJSObj(Node node)
{
    return ((DOMItem)node).getJsObject();
}
 
Example #19
Source File: Util.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * Format generated xml doc by indentation
 *
 * @param node
 * @param indent
 * @return
 */
public static String formatXML(Node node, String indent) {
	StringBuilder formatted = new StringBuilder();

	if (node.getNodeType() == Node.ELEMENT_NODE) {
		StringBuilder attributes = new StringBuilder();
		for (int k = 0; k < node.getAttributes().getLength(); k++) {
			attributes.append(" ");
			attributes.append(node.getAttributes().item(k).getNodeName());
			attributes.append("=\"");
			attributes.append(node.getAttributes().item(k).getNodeValue());
			attributes.append("\"");
		}

		formatted.append(indent);
		formatted.append("<");
		formatted.append(node.getNodeName());
		formatted.append(attributes.toString());
		if (!node.hasChildNodes()) {
			formatted.append("/>\n");
			return formatted.toString();
		}
		if ((node.hasChildNodes() && node.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
			formatted.append(">");
		} else {
			formatted.append(">\n");
		}

		for (int i = 0; i < node.getChildNodes().getLength(); i++) {
			formatted
			.append(formatXML(node.getChildNodes().item(i), indent + "   "));
		}

		if (node.hasChildNodes()
				&& node.getFirstChild().getNodeType() != Node.TEXT_NODE) {
			formatted.append(indent);
		}
		formatted.append("</");
		formatted.append(node.getNodeName());
		formatted.append(">\n");
	} else {
		if (node.toString().trim().length() > 0) {
			formatted.append(node.toString());
		}
	}

	String xml = formatted.toString();
	xml = xml.replace("&semi;", ";");
	return xml;
}
 
Example #20
Source File: ParseUtils.java    From core with GNU Lesser General Public License v2.1 3 votes vote down vote up
public static String IDOrLabel(Node node) {
    String label = node.getAttributes().getNamedItem("label")!=null ?
            node.getAttributes().getNamedItem("label").getNodeValue() : node.getAttributes().getNamedItem("id").getNodeValue();

    return label;

}
 
Example #21
Source File: ElementAdapter.java    From core with GNU Lesser General Public License v2.1 votes vote down vote up
T fromXML(Node node);