You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VariableFactory.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.itmill.toolkit.terminal.gwt.client;
  2. import java.util.HashMap;
  3. import com.google.gwt.xml.client.NamedNodeMap;
  4. import com.google.gwt.xml.client.Node;
  5. import com.google.gwt.xml.client.NodeList;
  6. import com.itmill.toolkit.terminal.gwt.client.ui.Component;
  7. public class VariableFactory {
  8. public static Variable getVariable(Node n, Component owner) {
  9. String nName = n.getNodeName();
  10. NamedNodeMap attr = n.getAttributes();
  11. if(nName.equals("boolean")) {
  12. String name = attr.getNamedItem("name").getNodeValue();
  13. String id = attr.getNamedItem("id").getNodeValue();
  14. boolean b = attr.getNamedItem("value").getNodeValue().equals("true");
  15. BooleanVariable v = new BooleanVariable(owner,name,id);
  16. v.setValue(b);
  17. return v;
  18. } else {
  19. return null;
  20. }
  21. }
  22. public static HashMap getAllVariables(Node n, Component owner) {
  23. HashMap v = new HashMap();
  24. NodeList children = n.getChildNodes();
  25. for (int i = 0; i < children.getLength(); i++) {
  26. Variable var = getVariable(children.item(i), owner);
  27. if(var != null)
  28. v.put(var.getName(), var);
  29. }
  30. return v;
  31. }
  32. }