Esempio n. 1
1
  /**
   * If the outbound level is BINARY, convert the string field to binary, then pad to the left with
   * the appropriate number of zero bits to reach a number of bits specified by the bitLength
   * attribute of the TDT definition file.
   */
  private void binaryPadding(Map<String, String> extraparams, Field tdtfield) {
    String fieldname = tdtfield.getName();
    int reqbitlength = tdtfield.getBitLength();
    String value;

    String binaryValue = fieldToBinary(tdtfield, extraparams);
    if (binaryValue.length() < reqbitlength) {
      int extraBitLength = reqbitlength - binaryValue.length();

      StringBuilder zeroPaddedBinaryValue = new StringBuilder("");
      for (int i = 0; i < extraBitLength; i++) {
        zeroPaddedBinaryValue.append("0");
      }
      zeroPaddedBinaryValue.append(binaryValue);
      value = zeroPaddedBinaryValue.toString();
    } else {
      if (binaryValue.length() > reqbitlength)
        throw new TDTException(
            "Binary value ["
                + binaryValue
                + "] for field "
                + fieldname
                + " exceeds maximum allowed "
                + reqbitlength
                + " bits.  Decimal value was "
                + extraparams.get(fieldname));

      value = binaryValue;
    }
    extraparams.put(fieldname, value);
  }
Esempio n. 2
1
  // ## operation writeChemkinSpecies(ReactionModel,SystemSnapshot)
  public static String writeChemkinSpecies(
      ReactionModel p_reactionModel, SystemSnapshot p_beginStatus) {
    // #[ operation writeChemkinSpecies(ReactionModel,SystemSnapshot)

    StringBuilder result = new StringBuilder();
    result.append("SPECIES\n");

    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    // write inert gas
    for (Iterator iter = p_beginStatus.getInertGas(); iter.hasNext(); ) {
      String name = (String) iter.next();
      result.append('\t' + name + '\n');
    }

    // write species
    for (Iterator iter = cerm.getSpecies(); iter.hasNext(); ) {
      Species spe = (Species) iter.next();
      result.append('\t' + spe.getChemkinName() + '\n');
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Esempio n. 3
0
  public static void writeChemkinInputFile(ReactionSystem rs) {
    // #[ operation writeChemkinInputFile(ReactionModel,SystemSnapshot)

    StringBuilder result = new StringBuilder();
    result.append(writeChemkinHeader());
    result.append(writeChemkinElement());
    double start = System.currentTimeMillis();
    result.append(writeChemkinSpecies(rs.reactionModel, rs.initialStatus));
    result.append(writeChemkinThermo(rs.reactionModel));
    Global.chemkinThermo = Global.chemkinThermo + (System.currentTimeMillis() - start) / 1000 / 60;
    start = System.currentTimeMillis();
    result.append(writeChemkinPdepReactions(rs));
    Global.chemkinReaction =
        Global.chemkinReaction + (System.currentTimeMillis() - start) / 1000 / 60;

    String dir = System.getProperty("RMG.workingDirectory");
    if (!dir.endsWith("/")) dir += "/";
    dir += "software/reactorModel/";
    String file = "chemkin/chem.inp";

    try {
      FileWriter fw = new FileWriter(file);
      fw.write(result.toString());
      fw.close();
    } catch (Exception e) {
      System.out.println("Error in writing chemkin input file chem.inp!");
      System.out.println(e.getMessage());
      System.exit(0);
    }

    // #]
  }
Esempio n. 4
0
  // ## operation writeChemkinReactions(ReactionModel)
  // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is
  // currently used anywhere)
  public static String writeChemkinReactions(
      ReactionModel p_reactionModel, Temperature p_temperature) {
    // #[ operation writeChemkinReactions(ReactionModel)
    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");
    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    LinkedHashSet all = cerm.getReactedReactionSet();

    HashSet hs = new HashSet();
    int numfor = 0;
    int numrev = 0;
    int numdup = 0;
    int numnorev = 0;
    for (Iterator iter = all.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (rxn.isForward()) {
        result.append(
            " "
                + rxn.toChemkinString(p_temperature)
                + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature
        //	result.append(" " + rxn.toChemkinString(Global.temperature) + "\n");

      }
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Esempio n. 5
0
  private Node[] processIndexNode(
      final Node theNode,
      final Document theTargetDocument,
      final IndexEntryFoundListener theIndexEntryFoundListener) {
    theNode.normalize();

    boolean ditastyle = false;
    String textNode = null;

    final NodeList childNodes = theNode.getChildNodes();
    final StringBuilder textBuf = new StringBuilder();
    final List<Node> contents = new ArrayList<Node>();
    for (int i = 0; i < childNodes.getLength(); i++) {
      final Node child = childNodes.item(i);
      if (checkElementName(child)) {
        ditastyle = true;
        break;
      } else if (child.getNodeType() == Node.ELEMENT_NODE) {
        textBuf.append(XMLUtils.getStringValue((Element) child));
        contents.add(child);
      } else if (child.getNodeType() == Node.TEXT_NODE) {
        textBuf.append(child.getNodeValue());
        contents.add(child);
      }
    }
    textNode = IndexStringProcessor.normalizeTextValue(textBuf.toString());
    if (textNode.length() == 0) {
      textNode = null;
    }

    if (theNode.getAttributes().getNamedItem(elIndexRangeStartName) != null
        || theNode.getAttributes().getNamedItem(elIndexRangeEndName) != null) {
      ditastyle = true;
    }

    final ArrayList<Node> res = new ArrayList<Node>();
    if ((ditastyle)) {
      final IndexEntry[] indexEntries = indexDitaProcessor.processIndexDitaNode(theNode, "");

      for (final IndexEntry indexEntrie : indexEntries) {
        theIndexEntryFoundListener.foundEntry(indexEntrie);
      }

      final Node[] nodes = transformToNodes(indexEntries, theTargetDocument, null);
      for (final Node node : nodes) {
        res.add(node);
      }

    } else if (textNode != null) {
      final Node[] nodes =
          processIndexString(textNode, contents, theTargetDocument, theIndexEntryFoundListener);
      for (final Node node : nodes) {
        res.add(node);
      }
    } else {
      return new Node[0];
    }

    return (Node[]) res.toArray(new Node[res.size()]);
  }
Esempio n. 6
0
 /**
  * Returns a string representation of all found arguments.
  *
  * @param args array with arguments
  * @return string representation
  */
 static String foundArgs(final Value[] args) {
   // compose found arguments
   final StringBuilder sb = new StringBuilder();
   for (final Value v : args) {
     if (sb.length() != 0) sb.append(", ");
     sb.append(v instanceof Jav ? Util.className(((Jav) v).toJava()) : v.seqType());
   }
   return sb.toString();
 }
Esempio n. 7
0
 private static String encodeChar(char c) {
   StringBuilder buf = new StringBuilder();
   buf.append("_x");
   String str = Integer.toHexString(c);
   for (int i = 4 - str.length(); i > 0; i--) {
     buf.append("0");
   }
   return buf.append(str).append("_").toString();
 }
Esempio n. 8
0
 private static <T> String toString(List<T> list) {
   StringBuilder buf = new StringBuilder();
   int k = -1;
   for (T t : list) {
     if (++k > 0) {
       buf.append(", ");
     }
     buf.append(t);
   }
   return buf.toString();
 }
Esempio n. 9
0
 /**
  * Pads a binary value supplied as a string first parameter to the left with leading zeros in
  * order to reach a required number of bits, as expressed by the second parameter, reqlen. Returns
  * a string value corresponding to the binary value left padded to the required number of bits.
  */
 private String padBinary(String binary, int reqlen) {
   String rv;
   int l = binary.length();
   int pad = (reqlen - (l % reqlen)) % reqlen;
   StringBuilder buffer = new StringBuilder("");
   for (int i = 0; i < pad; i++) {
     buffer.append("0");
   }
   buffer.append(binary);
   rv = buffer.toString();
   return rv;
 }
Esempio n. 10
0
  /**
   * Returns a string built using a particular grammar. Single-quotes strings are counted as literal
   * strings, whereas all other strings appearing in the grammar require substitution with the
   * corresponding value from the extraparams hashmap.
   */
  private String buildGrammar(String grammar, Map<String, String> extraparams) {
    StringBuilder outboundstring = new StringBuilder();
    String[] fields = Pattern.compile("\\s+").split(grammar);
    for (int i = 0; i < fields.length; i++) {
      if (fields[i].substring(0, 1).equals("'")) {
        outboundstring.append(fields[i].substring(1, fields[i].length() - 1));
      } else {
        outboundstring.append(extraparams.get(fields[i]));
      }
    }

    return outboundstring.toString();
  }
Esempio n. 11
0
 /**
  * Encodes an XML element name.
  *
  * <p>This function is mainly for encode element names in result of Drill Through execute, because
  * its element names come from database, we cannot make sure they are valid XML contents.
  *
  * <p>Quoth the <a href="http://xmla.org">XML/A specification</a>, version 1.1:
  *
  * <blockquote>
  *
  * XML does not allow certain characters as element and attribute names. XML for Analysis supports
  * encoding as defined by SQL Server 2000 to address this XML constraint. For column names that
  * contain invalid XML name characters (according to the XML 1.0 specification), the nonvalid
  * Unicode characters are encoded using the corresponding hexadecimal values. These are escaped as
  * _x<i>HHHH_</i> where <i>HHHH</i> stands for the four-digit hexadecimal UCS-2 code for the
  * character in most-significant bit first order. For example, the name "Order Details" is encoded
  * as Order_<i>x0020</i>_Details, where the space character is replaced by the corresponding
  * hexadecimal code.
  *
  * </blockquote>
  *
  * @param name Name of XML element
  * @return encoded name
  */
 private static String encodeElementName(String name) {
   StringBuilder buf = new StringBuilder();
   char[] nameChars = name.toCharArray();
   for (char ch : nameChars) {
     String encodedStr = (ch >= CHAR_TABLE.length ? null : CHAR_TABLE[ch]);
     if (encodedStr == null) {
       buf.append(ch);
     } else {
       buf.append(encodedStr);
     }
   }
   return buf.toString();
 }
Esempio n. 12
0
  private String obtenerNombre(Element raiz) {

    String comillas = "\"";

    StringBuilder nombre = new StringBuilder(comillas);

    String[] vars = {"CliApePat", "CliApeMat", "CliNom"};

    for (String s : vars) {
      nombre.append(raiz.getElementsByTagName(s).item(0).getTextContent() + " ");
    }
    nombre.append(comillas);

    return nombre.toString();
  }
 private void initCommand(Element commandRoot) throws XmlaException {
   Element[] childElems = XmlaUtil.filterChildElements(commandRoot, NS_XMLA, "Statement");
   if (childElems.length != 1) {
     StringBuilder buf = new StringBuilder(100);
     buf.append(MSG_INVALID_XMLA);
     buf.append(": Wrong number of Statement elements: ");
     buf.append(childElems.length);
     throw new XmlaException(
         CLIENT_FAULT_FC,
         HSB_BAD_STATEMENT_CODE,
         HSB_BAD_STATEMENT_FAULT_FS,
         Util.newError(buf.toString()));
   }
   statement = XmlaUtil.textInElement(childElems[0]).replaceAll("\\r", "");
   drillthrough = statement.toUpperCase().indexOf("DRILLTHROUGH") != -1;
 }
Esempio n. 14
0
  private String unirMapeos(LinkedHashMap<String, String> mapa, Object[] descripciones) {

    // mapa(llave,punto)
    // descripciones en el mismo orden que el mapeo
    String comillas = "\"";
    StringBuilder builder = new StringBuilder();

    Iterator<String> iterador = mapa.keySet().iterator();

    int indice = 0;

    while (iterador.hasNext()) {
      String llave = iterador.next();

      String puntaje = mapa.get(llave);

      String descripcion =
          descripciones[indice].toString().equals("null") ? "" : descripciones[indice].toString();

      builder.append(comillas + descripcion + comillas + "," + comillas + puntaje + comillas + ",");

      indice++;
    }
    return builder.toString();
  }
Esempio n. 15
0
  public static String replace(String input, final String expr, String replacement) {
    StringBuilder sb = new StringBuilder();
    int new_index = 0, index = 0, len = expr.length(), input_len = input.length();

    while (true) {
      new_index = input.indexOf(expr, index);
      if (new_index == -1) {
        sb.append(input.substring(index, input_len));
        break;
      }
      sb.append(input.substring(index, new_index));
      sb.append(replacement);
      index = new_index + len;
    }

    return sb.toString();
  }
Esempio n. 16
0
 private static String normalisedVersion(String version, String sep, int maxWidth) {
   String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
   StringBuilder sb = new StringBuilder();
   for (String s : split) {
     sb.append(String.format("%" + maxWidth + 's', s));
   }
   return sb.toString();
 }
Esempio n. 17
0
  private static String dump(Collection<ProtocolConfiguration> configs) {
    StringBuilder sb = new StringBuilder();
    String indent = "  ";
    sb.append("<config>\n");

    for (ProtocolConfiguration cfg : configs) {
      sb.append(indent).append("<").append(cfg.getProtocolName());
      Map<String, String> props = cfg.getProperties();
      if (props.isEmpty()) {
        sb.append(" />\n");
      } else {
        sb.append("\n").append(indent).append(indent);
        for (Map.Entry<String, String> entry : props.entrySet()) {
          String key = entry.getKey();
          String val = entry.getValue();
          key = trim(key);
          val = trim(val);
          sb.append(key).append("=\"").append(val).append("\" ");
        }
        sb.append(" />\n");
      }
    }

    sb.append("</config>\n");
    return sb.toString();
  }
Esempio n. 18
0
  public static String writeChemkinPdepReactions(ReactionSystem rs) {
    // #[ operation writeChemkinReactions(ReactionModel)

    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");

    LinkedList rList = new LinkedList();
    LinkedList troeList = new LinkedList();
    LinkedList tbrList = new LinkedList();
    LinkedList duplicates = new LinkedList();
    LinkedList lindeList = new LinkedList();

    if (rs.dynamicSimulator instanceof JDASPK) {
      rList = ((JDASPK) rs.dynamicSimulator).rList;
      troeList = ((JDASPK) rs.dynamicSimulator).troeList;
      tbrList = ((JDASPK) rs.dynamicSimulator).thirdBodyList;
      duplicates = ((JDASPK) rs.dynamicSimulator).duplicates;
      lindeList = ((JDASPK) rs.dynamicSimulator).lindemannList;
    } else if (rs.dynamicSimulator instanceof JDASSL) {
      rList = ((JDASSL) rs.dynamicSimulator).rList;
      troeList = ((JDASSL) rs.dynamicSimulator).troeList;
      tbrList = ((JDASSL) rs.dynamicSimulator).thirdBodyList;
      duplicates = ((JDASSL) rs.dynamicSimulator).duplicates;
      lindeList = ((JDASSL) rs.dynamicSimulator).lindemannList;
    }

    for (Iterator iter = rList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      // 10/26/07 gmagoon: changed to avoid use of Global.temperature; I am using
      // getPresentTemperature for the time being; it is possible that
      // getInitialStatus.getTemperature or something similar may be more appropriate
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = troeList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = tbrList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = duplicates.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n\tDUP\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n\tDUP\n");
    }
    for (Iterator iter = lindeList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Esempio n. 19
0
  /** pad a value according the field definition. */
  private void padField(Map<String, String> extraparams, Field field) {
    String name = field.getName();
    String value = extraparams.get(name);
    PadDirectionList padDir = field.getPadDir();
    int requiredLength = field.getLength();

    // assert value != null;
    if (value == null) return;

    String padCharString = field.getPadChar();
    // if no pad char specified, don't attempt padding
    if (padCharString == null) return;
    assert padCharString.length() > 0;
    char padChar = padCharString.charAt(0);

    StringBuilder buf = new StringBuilder(requiredLength);
    if (padDir == PadDirectionList.LEFT) {
      for (int i = 0; i < requiredLength - value.length(); i++) buf.append(padChar);
      buf.append(value);
    } else if (padDir == PadDirectionList.RIGHT) {
      buf.append(value);
      for (int i = 0; i < requiredLength - value.length(); i++) buf.append(padChar);
    }
    assert buf.length() == requiredLength;
    if (requiredLength != value.length()) {
      // System.out.println("    updated " + name + " to '" + buf + "'");
      extraparams.put(name, buf.toString());
    }
    /*
    else {
        StringBuilder mybuf = new StringBuilder();
        for (int i = 0; i < value.length(); i++) {
    	if (i > 0)
    	    mybuf.append(',');
    	mybuf.append('\'');
    	mybuf.append(value.charAt(i));
    	mybuf.append('\'');
        }


        System.out.println("    field " + name + " not padded as " + mybuf.toString() + " is already " + requiredLength + " characters long");
    }
    */
  }
Esempio n. 20
0
 /**
  * Returns the child text from a DOM node.
  *
  * @param node the node to parse
  * @return the node text, or <tt>null</tt> if the node did not contain any text
  */
 public static String getText(Node node) {
   StringBuilder s = null;
   Node child = node.getFirstChild();
   while (child != null) {
     if (child.getNodeType() == Node.TEXT_NODE) {
       if (s == null) {
         s = new StringBuilder();
       }
       s.append(((Text) child).getTextContent());
     } else if (child.getNodeType() == Node.CDATA_SECTION_NODE) {
       if (s == null) {
         s = new StringBuilder();
       }
       s.append(((CDATASection) child).getData());
     }
     child = child.getNextSibling();
   }
   return s == null ? null : s.toString();
 }
Esempio n. 21
0
 /** Converts a byte string input into a binary string, using 8-bits per character byte */
 private String bin2bytestring(String binary) {
   String bytestring;
   StringBuilder buffer = new StringBuilder("");
   int len = binary.length();
   for (int i = 0; i < len; i += 8) {
     int j = Integer.parseInt(bin2dec(padBinary(binary.substring(i, i + 8), 8)));
     buffer.append((char) j);
   }
   bytestring = buffer.toString();
   return bytestring;
 }
Esempio n. 22
0
 /**
  * Converts a binary string input into an ASCII string output, assuming that 7-bit compaction was
  * used
  */
 private String bin2asciiseven(String binary) {
   String asciiseven;
   StringBuilder buffer = new StringBuilder("");
   int len = binary.length();
   for (int i = 0; i < len; i += 7) {
     int j = Integer.parseInt(bin2dec(padBinary(binary.substring(i, i + 7), 8)));
     buffer.append((char) j);
   }
   asciiseven = buffer.toString();
   return asciiseven;
 }
Esempio n. 23
0
 /**
  * Converts an ASCII string input into a binary string, using 7-bit compaction of each ASCII byte
  */
 private String asciiseven2bin(String asciiseven) {
   String binary;
   StringBuilder buffer = new StringBuilder("");
   int len = asciiseven.length();
   byte[] bytes = asciiseven.getBytes();
   for (int i = 0; i < len; i++) {
     buffer.append(padBinary(dec2bin(Integer.toString(bytes[i] % 128)), 8).substring(1, 8));
   }
   binary = buffer.toString();
   return binary;
 }
Esempio n. 24
0
 /**
  * Converts an alphanumeric string input into a binary string, using 6-bit compaction of each
  * ASCII byte
  */
 private String alphanumsix2bin(String alphanumsix) {
   String binary;
   StringBuilder buffer = new StringBuilder("");
   int len = alphanumsix.length();
   byte[] bytes = alphanumsix.getBytes();
   for (int i = 0; i < len; i++) {
     buffer.append(padBinary(dec2bin(Integer.toString(bytes[i] % 64)), 8).substring(2, 8));
   }
   binary = buffer.toString();
   return binary;
 }
Esempio n. 25
0
 /**
  * Converts a binary string input into a character string output, assuming that 5-bit compaction
  * was used
  */
 private String bin2uppercasefive(String binary) {
   String uppercasefive;
   StringBuilder buffer = new StringBuilder("");
   int len = binary.length();
   for (int i = 0; i < len; i += 5) {
     int j = Integer.parseInt(bin2dec(padBinary(binary.substring(i, i + 5), 8)));
     buffer.append((char) (j + 64));
   }
   uppercasefive = buffer.toString();
   return uppercasefive;
 }
Esempio n. 26
0
 /**
  * Converts an upper case character string input into a binary string, using 5-bit compaction of
  * each ASCII byte
  */
 private String uppercasefive2bin(String uppercasefive) {
   String binary;
   StringBuilder buffer = new StringBuilder("");
   int len = uppercasefive.length();
   byte[] bytes = uppercasefive.getBytes();
   for (int i = 0; i < len; i++) {
     buffer.append(padBinary(dec2bin(Integer.toString(bytes[i] % 32)), 8).substring(3, 8));
   }
   binary = buffer.toString();
   return binary;
 }
Esempio n. 27
0
 /** Converts a binary string input into a byte string, using 8-bits per character byte */
 private String bytestring2bin(String bytestring) {
   String binary;
   StringBuilder buffer = new StringBuilder("");
   int len = bytestring.length();
   byte[] bytes = bytestring.getBytes();
   for (int i = 0; i < len; i++) {
     buffer.append(padBinary(dec2bin(Integer.toString(bytes[i])), 8));
   }
   binary = buffer.toString();
   return binary;
 }
  private void initProperties(Element propertiesRoot) throws XmlaException {
    Map<String, String> properties = new HashMap<String, String>();
    Element[] childElems = XmlaUtil.filterChildElements(propertiesRoot, NS_XMLA, "PropertyList");
    if (childElems.length == 1) {
      NodeList nlst = childElems[0].getChildNodes();
      for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) {
        Node n = nlst.item(i);
        if (n instanceof Element) {
          Element e = (Element) n;
          if (NS_XMLA.equals(e.getNamespaceURI())) {
            String key = e.getLocalName();
            String value = XmlaUtil.textInElement(e);

            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug(
                  "DefaultXmlaRequest.initProperties: "
                      + " key=\""
                      + key
                      + "\", value=\""
                      + value
                      + "\"");
            }

            properties.put(key, value);
          }
        }
      }
    } else if (childElems.length > 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of PropertyList elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_PROPERTIES_LIST_CODE,
          HSB_BAD_PROPERTIES_LIST_FAULT_FS,
          Util.newError(buf.toString()));
    } else {
    }
    this.properties = Collections.unmodifiableMap(properties);
  }
  private void initExecute(Element executeRoot) throws XmlaException {
    Element[] childElems = XmlaUtil.filterChildElements(executeRoot, NS_XMLA, "Command");
    if (childElems.length != 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of Command elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_COMMAND_CODE,
          HSB_BAD_COMMAND_FAULT_FS,
          Util.newError(buf.toString()));
    }
    initCommand(childElems[0]); // <Command><Statement>

    childElems = XmlaUtil.filterChildElements(executeRoot, NS_XMLA, "Properties");
    if (childElems.length != 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of Properties elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_PROPERTIES_CODE,
          HSB_BAD_PROPERTIES_FAULT_FS,
          Util.newError(buf.toString()));
    }
    initProperties(childElems[0]); // <Properties><PropertyList>
  }
Esempio n. 30
0
 public static String textInElement(Element elem) {
   StringBuilder buf = new StringBuilder(100);
   elem.normalize();
   NodeList nlst = elem.getChildNodes();
   for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) {
     Node n = nlst.item(i);
     if (n instanceof Text) {
       final String data = ((Text) n).getData();
       buf.append(data);
     }
   }
   return buf.toString();
 }