Example #1
0
  private static String compareElements(String path, Element e1, Element e2) {
    if (!e1.getNamespaceURI().equals(e2.getNamespaceURI()))
      return "Namespaces differ at "
          + path
          + ": "
          + e1.getNamespaceURI()
          + "/"
          + e2.getNamespaceURI();
    if (!e1.getLocalName().equals(e2.getLocalName()))
      return "Names differ at " + path + ": " + e1.getLocalName() + "/" + e2.getLocalName();
    path = path + "/" + e1.getLocalName();
    String s = compareAttributes(path, e1.getAttributes(), e2.getAttributes());
    if (!Utilities.noString(s)) return s;
    s = compareAttributes(path, e2.getAttributes(), e1.getAttributes());
    if (!Utilities.noString(s)) return s;

    Node c1 = e1.getFirstChild();
    Node c2 = e2.getFirstChild();
    c1 = skipBlankText(c1);
    c2 = skipBlankText(c2);
    while (c1 != null && c2 != null) {
      if (c1.getNodeType() != c2.getNodeType())
        return "node type mismatch in children of "
            + path
            + ": "
            + Integer.toString(e1.getNodeType())
            + "/"
            + Integer.toString(e2.getNodeType());
      if (c1.getNodeType() == Node.TEXT_NODE) {
        if (!normalise(c1.getTextContent()).equals(normalise(c2.getTextContent())))
          return "Text differs at "
              + path
              + ": "
              + normalise(c1.getTextContent())
              + "/"
              + normalise(c2.getTextContent());
      } else if (c1.getNodeType() == Node.ELEMENT_NODE) {
        s = compareElements(path, (Element) c1, (Element) c2);
        if (!Utilities.noString(s)) return s;
      }

      c1 = skipBlankText(c1.getNextSibling());
      c2 = skipBlankText(c2.getNextSibling());
    }
    if (c1 != null) return "node mismatch - more nodes in source in children of " + path;
    if (c2 != null) return "node mismatch - more nodes in target in children of " + path;
    return null;
  }
 public void parse(Element element) {
   NodeList nodelist = element.getChildNodes();
   creativeRenditionId = tryParseInt(element.getAttribute("creativeRenditionId"), 0);
   replicaId = tryParseInt(element.getAttribute("adReplicaId"), -1);
   setContentType(element.getAttribute("contentType"));
   setWrapperType(element.getAttribute("wrapperType"));
   setWrapperURL(element.getAttribute("wrapperUrl"));
   setPreference(tryParseInt(element.getAttribute("preference"), 0));
   setHeight(tryParseInt(element.getAttribute("height"), 0));
   setWidth(tryParseInt(element.getAttribute("width"), 0));
   setCreativeAPI(element.getAttribute("creativeApi"));
   int i = 0;
   while (i < nodelist.getLength()) {
     element = nodelist.item(i);
     if (element.getNodeType() == 1) {
       String s = element.getNodeName();
       logger.verbose((new StringBuilder()).append("parse(), name: ").append(s).toString());
       if (s.equals("parameters")) {
         parameters = parseParameters((Element) element);
       } else if (s.equals("asset")) {
         primaryCreativeRenditionAsset = new CreativeRenditionAsset(context);
         primaryCreativeRenditionAsset.parse((Element) element);
       } else if (s.equals("otherAssets")) {
         parseOtherAssets((Element) element);
       } else {
         logger.warn((new StringBuilder()).append("ignore node: ").append(s).toString());
       }
     }
     i++;
   }
 }
  public boolean isValidSOAP() {
    if (document == null || (document.getNodeType() != Node.DOCUMENT_NODE)) {
      return false;
    }

    Element soapEnvelope = document.getDocumentElement();

    try {
      if (soapEnvelope == null || (soapEnvelope.getNodeType() != Node.ELEMENT_NODE)) {
        return false;
      }

      if (soapEnvelope.getNamespaceURI() != null) {
        if (!soapEnvelope.getNamespaceURI().equals(NS_URI_SOAP_ENVELOPE)) return false;
      }

      if (!soapEnvelope.getNodeName().equals(ELEM_SOAP_ENVELOPE)) return false;

      NodeList nodeList = soapEnvelope.getElementsByTagName(ELEM_SOAP_HEADER);
      if (nodeList == null || nodeList.getLength() > 1) {
        return false;
      }

      nodeList = soapEnvelope.getElementsByTagName(ELEM_SOAP_BODY);
      if (nodeList == null || nodeList.getLength() != 1) {
        return false;
      }

      return true;
    } catch (Exception ex) {
      return false;
    }
  }
Example #4
0
  @Override
  public RMAImporter createRGGElement(Element element, RGG rggInstance) {
    if (element.getNodeType() != Element.ELEMENT_NODE) {
      throw new IllegalArgumentException("elements node type must be ELEMENT_NODE");
      /**
       * **************** initialize and set attributes values *************************************
       */
    }

    String var = element.getAttribute(RGG.getConfiguration().getString("VAR"));
    String colspan = element.getAttribute(RGG.getConfiguration().getString("COLUMN-SPAN"));
    String id = element.getAttribute(RGG.getConfiguration().getString("ID"));
    String othercolumns = element.getAttribute(RGG.getConfiguration().getString("OTHER-COLUMNS"));
    /**
     * ********************************************************************************************
     */
    RMAImporter rMAImporter = new RMAImporter();
    VMAImporter vMAImporter = null;
    if (StringUtils.isNotBlank(othercolumns)) {
      vMAImporter = new VMAImporter(rggInstance, StringUtils.split(othercolumns, ','));
    } else {
      vMAImporter = new VMAImporter(rggInstance, null);
    }

    if (StringUtils.isNotBlank(var)) {
      rMAImporter.setVar(var);
    }

    if (StringUtils.isNotBlank(colspan)) {
      if (StringUtils.isNumeric(colspan)) {
        vMAImporter.setColumnSpan(Integer.parseInt(colspan));
      } else if (StringUtils.equals(colspan, RGG.getConfiguration().getString("FULL-SPAN"))) {
        vMAImporter.setColumnSpan(LayoutInfo.FULL_SPAN);
      } else {
        throw new NumberFormatException(
            RGG.getConfiguration().getString("COLUMN-SPAN")
                + " seems not to be a number: "
                + colspan
                + "nor a known keyword!");
      }
    }

    if (StringUtils.isNotBlank(id)) {
      rggInstance.addObject(id, vMAImporter);
    }

    rMAImporter.setVMAImporter(vMAImporter);

    if (element.hasChildNodes()) { // it can only be <iport>
      setInputPorts(rMAImporter, element);
    }
    return rMAImporter;
  }
  public RElement createRGGElement(Element element, at.ac.arcs.rgg.RGG rggInstance) {
    if (element.getNodeType() != Element.ELEMENT_NODE)
      throw new IllegalArgumentException("elements node type must be ELEMENT_NODE");

    RMatrix rMatrix = new RMatrix();
    VMatrix vMatrix = new VMatrix(rggInstance);

    /**
     * **************** initialize and set attributes values *************************************
     */
    String var = element.getAttribute(RGG.getConfiguration().getString("VAR"));
    String colspan = element.getAttribute(RGG.getConfiguration().getString("COLUMN-SPAN"));
    String datatype = element.getAttribute(RGG.getConfiguration().getString("DATA-TYPE"));
    String id = element.getAttribute(RGG.getConfiguration().getString("ID"));
    /**
     * ********************************************************************************************
     */
    if (StringUtils.isNotBlank(datatype)) {
      if (StringUtils.equalsIgnoreCase(RGG.getConfiguration().getString("NUMERIC"), datatype)) {
        vMatrix.setNumeric(true);
      }
    }

    if (StringUtils.isNotBlank(var)) {
      rMatrix.setVar(var);
    }

    if (StringUtils.isNotBlank(colspan)) {
      if (StringUtils.isNumeric(colspan)) {
        vMatrix.setColumnSpan(Integer.parseInt(colspan));
      } else if (StringUtils.equals(colspan, RGG.getConfiguration().getString("FULL-SPAN")))
        vMatrix.setColumnSpan(LayoutInfo.FULL_SPAN);
      else
        throw new NumberFormatException(
            RGG.getConfiguration().getString("COLUMN-SPAN")
                + " seems not to be a number: "
                + colspan
                + "nor a known keyword!");
    }

    if (StringUtils.isNotBlank(id)) {
      rggInstance.addObject(id, vMatrix);
    }
    rMatrix.setVMatrix(vMatrix);

    return rMatrix;
  }
Example #6
0
 /**
  * ************************************************************************* Constructor
  *
  * @param xmlElement The XML config file element for a color definition
  *     <p>************************************************************************
  */
 public ColorInfo(Element xmlElement) {
   if (xmlElement.getNodeType() == Node.ELEMENT_NODE) {
     m_id = xmlElement.getAttribute("id");
     String colorDef = xmlElement.getTextContent();
     if (colorDef == null) {
       Logger.error("Bad color definition: " + m_id, Level.CONFIG, this);
       m_rgb = null;
       return;
     }
     String[] defs = colorDef.split(":");
     if (defs.length != 3) {
       Logger.error("Bad color definition: " + m_id, Level.CONFIG, this);
       m_rgb = null;
       return;
     }
     int colorR = Integer.parseInt(defs[0]);
     int colorG = Integer.parseInt(defs[1]);
     int colorB = Integer.parseInt(defs[2]);
     m_rgb = new Color(Display.getCurrent(), colorR, colorG, colorB);
   }
 }
Example #7
0
 private static void recFromXML(HeteroMap hmap, Element elem) throws HeteroMapLoadingException {
   if (elem.getNodeType() != Node.ELEMENT_NODE) {
     return;
   }
   /*String tag = elem.getNodeName();
   if (tag.equals("hmap")) {
   	HeteroMap hmaps2 = hamp.putNewMap(elem.getAttribute("name"));
   	NodeList nodes = elem.getChildNodes();
   	for (int i = 0; i < nodes.getLength(); i++) {
   		Node n = nodes.item(i);
   		recFromXML(hmap2, n);
   	}
   }
   else if (tag.equals("int")) {
   	int val = Integer.parseInt(elem.getAttribute("value"));
   	hamp.put(elem.getAttribute("name"), val);
   }
   else if (tag.equals("str")) {
   	hamp.put(elem.getAttribute("name"), elem.getAttribute("value"));
   }
   else if (tag.equals("buffer")) {
   	hamp.put(elem.getAttribute("name"), elem.getAttribute("value"));
   }
   else if (tag.equals("bool")) {
   	hamp.put(elem.getAttribute("name"), elem.getAttribute("value").equals("true"));
   }
   else if (tag.equals("list")) {
   	hamp.put(elem.getAttribute("name"), lst);
   	NodeList nodes = elem.getChildNodes();
   	for (int i = 0; i < nodes.getLength(); i++) {
   		Node n = nodes.item(i);
   		recFromXML(hmap2, n);
   	}
   }
   else {
   	throw new LoadingException("invalid tag: " + tag);
   }*/
 }
  public RTextField createRGGElement(Element element, RGG rggInstance) {
    if (element.getNodeType() != Element.ELEMENT_NODE) {
      throw new IllegalArgumentException("elements node type must be ELEMENT_NODE");
    }

    RTextField rtextfield = new RTextField();
    VTextField vtextfield = new VTextField();

    /**
     * **************** initialize and set attributes values *************************************
     */
    String var = element.getAttribute(RGG.getConfiguration().getString("VAR"));
    String label = element.getAttribute(RGG.getConfiguration().getString("LABEL"));
    String colspan = element.getAttribute(RGG.getConfiguration().getString("COLUMN-SPAN"));
    String defaultvalue = element.getAttribute(RGG.getConfiguration().getString("DEFAULT-VALUE"));
    String datatype = element.getAttribute(RGG.getConfiguration().getString("DATA-TYPE"));
    String size = element.getAttribute(RGG.getConfiguration().getString("SIZE"));
    String enabled = element.getAttribute(RGG.getConfiguration().getString("ENABLED"));
    /**
     * ********************************************************************************************
     */
    if (StringUtils.isNotBlank(var)) {
      rtextfield.setVar(var);
    }

    if (StringUtils.isNotBlank(label)) {
      rtextfield.setLabel(label);
    }

    vtextfield.setLabelText(rtextfield.getLabel());

    if (StringUtils.isNotBlank(colspan)) {
      if (StringUtils.isNumeric(colspan)) {
        vtextfield.setColumnSpan(Integer.parseInt(colspan));
      } else if (StringUtils.equals(colspan, RGG.getConfiguration().getString("FULL-SPAN"))) {
        vtextfield.setColumnSpan(LayoutInfo.FULL_SPAN);
      } else {
        throw new NumberFormatException(
            RGG.getConfiguration().getString("COLUMN-SPAN")
                + " seems not to be a number: "
                + colspan
                + "nor a known keyword!");
      }
    }

    if (StringUtils.isNotBlank(defaultvalue)) {
      vtextfield.setDefaultvalue(defaultvalue);
    }

    if (StringUtils.isNotBlank(datatype)) {
      if (StringUtils.equalsIgnoreCase(RGG.getConfiguration().getString("NUMERIC"), datatype)) {
        vtextfield.setNumeric(true);
      }
    }

    if (StringUtils.isNotBlank(size) && StringUtils.isNumeric(size)) {
      vtextfield.setColumns(Integer.parseInt(size));
    }

    if (StringUtils.isNotBlank(enabled)) {
      if (util.match("/(\\w+)\\./", enabled)) {
        String id = util.group(1);
        enabled = util.substitute("s/" + id + "\\.//g", enabled);
        AutoBinding<Object, Object, Object, Object> binding =
            Bindings.createAutoBinding(
                AutoBinding.UpdateStrategy.READ, // one-way binding
                rggInstance.getObject(id), // source of value
                ELProperty.create(enabled), // the property to get
                vtextfield, // the "backing bean"
                BeanProperty.create("enabled") // property to set
                );
        binding.bind();
      }
    }

    rtextfield.setTextfield(vtextfield);
    return rtextfield;
  }
Example #9
0
  public RElement createRGGElement(Element element, RGG rggInstance) {
    if (element.getNodeType() != Element.ELEMENT_NODE)
      throw new IllegalArgumentException("elements node type must be ELEMENT_NODE");

    /**
     * **************** initialize and set attributes values *************************************
     */
    String text = element.getAttribute(RGG.getConfiguration().getString("TEXT"));
    String colspan = element.getAttribute(RGG.getConfiguration().getString("COLUMN-SPAN"));
    String alignment = element.getAttribute(RGG.getConfiguration().getString("ALIGNMENT"));
    String enabled = element.getAttribute(RGG.getConfiguration().getString("ENABLED"));
    /**
     * ********************************************************************************************
     */
    Perl5Util util = new Perl5Util();

    VLabel vlabel = new VLabel(text);
    if (StringUtils.isNotBlank(colspan)) {
      if (StringUtils.isNumeric(colspan)) {
        vlabel.setColumnSpan(Integer.parseInt(colspan));
      } else if (StringUtils.equals(colspan, RGG.getConfiguration().getString("FULL-SPAN")))
        vlabel.setColumnSpan(LayoutInfo.FULL_SPAN);
      else
        throw new NumberFormatException(
            RGG.getConfiguration().getString("COLUMN-SPAN")
                + " seems not to be a number: "
                + colspan);
    }

    if (StringUtils.isNotBlank(alignment)) {
      if (StringUtils.equalsIgnoreCase(RGG.getConfiguration().getString("CENTER"), alignment)) {
        vlabel.setHorizontalAlignment(SwingConstants.CENTER);
      } else if (StringUtils.equalsIgnoreCase(
          RGG.getConfiguration().getString("RIGHT"), alignment)) {
        vlabel.setHorizontalAlignment(SwingConstants.RIGHT);
      } else if (StringUtils.equalsIgnoreCase(
          RGG.getConfiguration().getString("LEFT"), alignment)) {
        vlabel.setHorizontalAlignment(SwingConstants.LEFT);
      } else if (StringUtils.equalsIgnoreCase(RGG.getConfiguration().getString("TOP"), alignment)) {
        vlabel.setHorizontalAlignment(SwingConstants.TOP);
      } else if (StringUtils.equalsIgnoreCase(
          RGG.getConfiguration().getString("BOTTOM"), alignment)) {
        vlabel.setHorizontalAlignment(SwingConstants.BOTTOM);
      }
    }

    if (StringUtils.isNotBlank(enabled)) {
      if (util.match("/(\\w+)\\./", enabled)) {
        String id = util.group(1);
        enabled = util.substitute("s/" + id + "\\.//g", enabled);
        AutoBinding<Object, Object, Object, Object> binding =
            Bindings.createAutoBinding(
                AutoBinding.UpdateStrategy.READ, // one-way binding
                rggInstance.getObject(id), // source of value
                ELProperty.create(enabled), // the property to get
                vlabel, // the "backing bean"
                BeanProperty.create("enabled") // property to set
                );
        binding.bind();
      }
    }

    RLabel rLabel = new RLabel(vlabel);
    if (element.hasChildNodes()) { // it can only be <iport>
      setInputPorts(rLabel, element);
    }
    return rLabel;
  }
Example #10
0
  public RElement createRGGElement(Element element, RGG rggInstance) {
    if (element.getNodeType() != Element.ELEMENT_NODE) {
      throw new IllegalArgumentException("elements node type must be ELEMENT_NODE");
    }

    RCheckBox rcheckbox = new RCheckBox();
    VCheckBox vcheckbox = new VCheckBox();

    /**
     * **************** initialize and set attributes values *************************************
     */
    String var = element.getAttribute(RGG.getConfiguration().getString("VAR"));
    String label = element.getAttribute(RGG.getConfiguration().getString("LABEL"));
    String colspan = element.getAttribute(RGG.getConfiguration().getString("COLUMN-SPAN"));
    String selected = element.getAttribute(RGG.getConfiguration().getString("SELECTED"));
    String returnValueBySelected =
        element.getAttribute(RGG.getConfiguration().getString("RETURN-VALUE-BY-SELECTED"));
    String returnValueByNotSelected =
        element.getAttribute(RGG.getConfiguration().getString("RETURN-VALUE-BY-NOTSELECTED"));
    String labelPosition = element.getAttribute(RGG.getConfiguration().getString("LABELPOSITION"));
    String id = element.getAttribute(RGG.getConfiguration().getString("ID"));
    String enabled = element.getAttribute(RGG.getConfiguration().getString("ENABLED"));
    /**
     * ********************************************************************************************
     */
    if (StringUtils.isNotBlank(var)) {
      rcheckbox.setVar(var);
    }

    if (StringUtils.isNotBlank(label)) {
      vcheckbox.setLabelText(label);
    }

    if (StringUtils.isNotBlank(colspan) && StringUtils.isNumeric(colspan)) {
      vcheckbox.setColumnSpan(Integer.parseInt(colspan));
    }

    if (StringUtils.isNotBlank(selected)) {
      if (StringUtils.equalsIgnoreCase("TRUE", selected)
          || StringUtils.equalsIgnoreCase("T", selected)) {
        vcheckbox.setSelected(true);
      }
    }

    if (StringUtils.isNotBlank(returnValueBySelected)) {
      rcheckbox.setReturnValueBySelected(returnValueBySelected);
    }

    if (StringUtils.isNotBlank(returnValueByNotSelected)) {
      rcheckbox.setReturnValueByNotSelected(returnValueByNotSelected);
    }

    if (StringUtils.isNotBlank(labelPosition)) {
      if (StringUtils.equalsIgnoreCase(labelPosition, RGG.getConfiguration().getString("LEFT"))) {
        vcheckbox.setHorizontalLabelPosition(javax.swing.SwingConstants.LEFT);
      } else if (StringUtils.equalsIgnoreCase(
          labelPosition, RGG.getConfiguration().getString("RIGHT"))) {
        vcheckbox.setHorizontalLabelPosition(javax.swing.SwingConstants.RIGHT);
      } else {
        throw new IllegalArgumentException("labelpositon takes only \"left\" or \"right\"!");
      }
    }
    if (StringUtils.isNotBlank(id)) {
      rggInstance.addObject(id, vcheckbox);
    }

    if (StringUtils.isNotBlank(enabled)) {
      if (util.match("/(\\w+)\\./", enabled)) {
        String sourceid = util.group(1);
        enabled = util.substitute("s/" + sourceid + "\\.//g", enabled);
        AutoBinding<Object, Object, Object, Object> binding =
            Bindings.createAutoBinding(
                AutoBinding.UpdateStrategy.READ, // one-way binding
                rggInstance.getObject(sourceid), // source of value
                ELProperty.create(enabled), // the property to get
                vcheckbox, // the "backing bean"
                BeanProperty.create("enabled") // property to set
                );
        binding.bind();
      }
    }

    rcheckbox.setCheckBox(vcheckbox);

    return rcheckbox;
  }