Exemplo n.º 1
0
  @Deprecated
  public boolean process(
      Document source, String rootname, String[] expectedtags, boolean acceptsAttachments) {
    Element root = source.getDocumentElement();
    boolean processed = false;

    if (root != null
        && rootname != null
        && rootname.equals(root.getTagName())
        && expectedtags != null) {
      NodeList children = root.getChildNodes();
      processed = true;

      if (children != null) {
        int i, count = children.getLength();
        int numtags = expectedtags.length;

        for (i = 0; i < count; i++) {
          Node current = children.item(i);
          if (current != null) {
            short type = current.getNodeType();
            String nodename = current.getNodeName();

            if (type == Node.ELEMENT_NODE && nodename != null) {
              boolean matchedtag = false;
              int matchedindex = 0;
              for (int j = 0; j < numtags && !matchedtag; j++) {
                if (nodename.equals(expectedtags[j])) {
                  matchedtag = true;
                  matchedindex = j;
                }
              }

              if (matchedtag) {
                String value = RetrieveNodeValue(current);

                SetValueMethod(nodename, matchedindex, value);

              } else if (acceptsAttachments && nodename.equals("NumAttachments")) {
                String value = RetrieveNodeValue(current);

                int numAttachments = NumericUtils.intValue(value);

                NumAttachmentsMethod(numAttachments);
              } else if (acceptsAttachments && nodename.equals("AttachmentList")) {
                NodeList attachments = current.getChildNodes();
                if (attachments != null) {
                  int attachcount = attachments.getLength();
                  for (int j = 0; j < attachcount; j++) {
                    Node attachnode = attachments.item(j);
                    if (attachnode != null
                        && attachnode.getNodeType() == Node.ELEMENT_NODE
                        && attachnode.getNodeName().equals("Attachment")) {

                      int AttachmentID =
                          NumericUtils.intValue(RetrieveSubnodeValue(attachnode, "AttachmentID"));
                      String CustomerAttachmentKey =
                          RetrieveSubnodeValue(attachnode, "CustomerAttachmentKey");
                      int AttachmentNumber =
                          NumericUtils.intValue(
                              RetrieveSubnodeValue(attachnode, "AttachmentNumber"));
                      String AttachmentCreated =
                          RetrieveSubnodeValue(attachnode, "AttachmentCreated");
                      String AttachmentType = RetrieveSubnodeValue(attachnode, "AttachmentType");
                      String AttachmentData = RetrieveSubnodeValue(attachnode, "AttachmentData");
                      String AttachmentMIME = RetrieveSubnodeValue(attachnode, "AttachmentMIME");
                      int AttachmentWidth =
                          NumericUtils.intValue(
                              RetrieveSubnodeValue(attachnode, "AttachmentWidth"));
                      int AttachmentHeight =
                          NumericUtils.intValue(
                              RetrieveSubnodeValue(attachnode, "AttachmentHeight"));
                      int AttachmentSize =
                          NumericUtils.intValue(RetrieveSubnodeValue(attachnode, "AttachmentSize"));
                      int AttachmentDuration =
                          NumericUtils.intValue(
                              RetrieveSubnodeValue(attachnode, "AttachmentDuration"));
                      String AttachmentStatus =
                          RetrieveSubnodeValue(attachnode, "AttachmentStatus");
                      String AttachmentRating =
                          RetrieveSubnodeValue(attachnode, "AttachmentRating");
                      String AttachmentCaption =
                          RetrieveSubnodeValue(attachnode, "AttachmentCaption");

                      AddAttachmentMethod(
                          AttachmentID,
                          CustomerAttachmentKey,
                          AttachmentNumber,
                          AttachmentCreated,
                          AttachmentType,
                          AttachmentData,
                          AttachmentMIME,
                          AttachmentWidth,
                          AttachmentHeight,
                          AttachmentSize,
                          AttachmentDuration,
                          AttachmentStatus,
                          AttachmentRating,
                          AttachmentCaption);
                    }
                  }
                }

              } else {
                if (WARN_ENABLED)
                  logger.warn("ComHelper - " + rootname + " unexpected tag read " + nodename);
              }
            }
          }
        }
      }
    }

    return processed;
  }
Exemplo n.º 2
0
  /**
   * Evaluates this function. The child node is evaluated, the result of which must be a numeric
   * type (one of Double, Float, Long, Integer). 1 is divided by the tan of this value to give the
   * result as a double value.
   *
   * @return cotangent of the value returned by the child
   */
  @Override
  public Double evaluate() {
    Object c = getChild(0).evaluate();

    return MathUtils.cot(NumericUtils.asDouble(c));
  }