Examples of CStringBuilder


Examples of org.allcolor.xml.parser.CStringBuilder

  public CContentParticle(
    final String   cp,
    final CContentParticle parent) {
    this.parent = parent;

    CStringBuilder cpBuffer = new CStringBuilder().append(cp.trim());
    correctParenthesis(cpBuffer);
    this.cardinality     = calculateCardinality(cpBuffer);
    this.type       = analyzeType(cpBuffer);
    this.cp         = cpBuffer.toString();

    if (this.type == NAME) {
      if ((this.cp.indexOf("(") != -1) ||
          (this.cp.indexOf(")") != -1) ||
          (this.cp.indexOf(",") != -1) ||
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   * @return DOCUMENT ME!
   */
  public boolean matches(
    final List elements,
    final boolean partialMatch) {
    CStringBuilder toMatch = new CStringBuilder();

    for (Iterator it = elements.iterator(); it.hasNext();) {
      Object next = it.next();

      if (next instanceof Node) {
        Node   node = (Node) next;
        String name = node.getNodeName();

        if ((node.getNodeType() != Node.TEXT_NODE) &&
            (node.getNodeType() != Node.ELEMENT_NODE) &&
            (node.getNodeType() != Node.CDATA_SECTION_NODE)) {
          continue;
        } // end if
        else if (node.getNodeType() == Node.TEXT_NODE) {
          if (CText.isElementContentWhitespace((Text) node)) {
            continue;
          }

          name = "#PCDATA";
        } // end else if
        else if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
          name = "#PCDATA";
        } // end else if

        toMatch.append(name);
        toMatch.append(" ");
      } // end if
      else if (next instanceof String) {
        toMatch.append(next);
        toMatch.append(" ");
      } // end else if
    } // end for

    return matches(toMatch.toString(), partialMatch);
  } // end matches()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

    while (part.getParent() != null) {
      part = part.getParent();
      tabs++;
    } // end while

    CStringBuilder result = new CStringBuilder();

    for (int i = 0; i < tabs; i++) {
      result.append("\t");
    } // end for

    if (type == CHOICE) {
      result.append("Choice cp : '");
    } else if (type == NAME) {
      result.append("Name cp : '");
    } else {
      result.append("Sequence cp : '");
    }

    result.append(cp);
    result.append("' cardinality : ");

    if (cardinality == CARDINAL_01) {
      result.append("?\n");
    }

    if (cardinality == CARDINAL_0N) {
      result.append("*\n");
    }

    if (cardinality == CARDINAL_1N) {
      result.append("+\n");
    }

    if (cardinality == CARDINAL_11) {
      result.append("1\n");
    }

    for (Iterator it = childCP.iterator(); it.hasNext();) {
      CContentParticle child = (CContentParticle) it.next();
      result.append(child);
    } // end for

    if (this.getParent() == null) {
      Stack stack = getRegExp();
      int   iNum = 0;

      while (stack.size() > 0) {
        result.append("Regexp");
        result.append(iNum++);
        result.append(" : \"");
        result.append(((Pattern) stack.pop()).pattern());
        result.append("\"\n");
      } // end while
    } // end if

    return result.toString();
  } // end toString()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   * @param tokenizer DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  private static String getRest(final CStringTokenizer tokenizer) {
    CStringBuilder result = new CStringBuilder();

    while (tokenizer.hasMoreTokens()) {
      result.append(tokenizer.nextToken());
    } // end while

    return result.toString();
  } // end getRest()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

      while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken().trim();

        if (token.equals("(")) {
          CStringBuilder result = new CStringBuilder();
          result.append("(");

          while ((token.equals("(")) &&
              (tokenizer.hasMoreTokens())) {
            iOpen++;

            if (iOpen > 1) {
              result.append(token);
            }

            token = tokenizer.nextToken();
          } // end while

          while (((!token.equals(")")) || (iOpen > 0)) &&
              (tokenizer.hasMoreTokens())) {
            result.append(token);
            token = tokenizer.nextToken();

            if (token.equals(")")) {
              iOpen--;
            }

            if (token.equals("(")) {
              iOpen++;
            }
          } // end while

          result.append(")");

          if (tokenizer.hasMoreTokens()) {
            token = tokenizer.nextToken();

            if ((token.startsWith("*")) ||
                (token.startsWith("?")) ||
                (token.startsWith("+"))) {
              result.append(token.substring(0, 1));
              cp       = (token.substring(1) +
                getRest(tokenizer).trim()).trim();
              booBreak     = true;
            } // end if
          } // end if

          String child = result.toString().trim();

          if (!getParticleAsString().equals(child)) {
            CContentParticle nCp = new CContentParticle(child,
                this);
            appendChild(nCp);
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   *
   * @throws Exception DOCUMENT ME!
   */
  private String generateRegExpPattern()
    throws Exception {
    CStringBuilder result = new CStringBuilder();

    if ((getType() == CHOICE) || (getType() == SEQ)) {
      result.append("(");

      for (Iterator it = getChildParticles().iterator();
          it.hasNext();) {
        result.append(((CContentParticle) it.next()).generateRegExpPattern());

        if (getParent() == null) {
          stack.push(Pattern.compile(result.toString() + ")"));
        } // end if

        if ((it.hasNext()) && (getType() == CHOICE)) {
          result.append("|");
        }
      } // end for

      result.append(")");

      if (getCardinality() == CARDINAL_0N) {
        result.append("*");
      } else if (getCardinality() == CARDINAL_1N) {
        result.append("+");
      } else if (getCardinality() == CARDINAL_01) {
        result.append("?");
      }
    } // end if
    else if (getType() == NAME) {
      result.append("(");
      result.append(cp);
      result.append("\\s");
      result.append(")");

      if (getCardinality() == CARDINAL_0N) {
        result.append("*");
      } else if (getCardinality() == CARDINAL_1N) {
        result.append("+");
      } else if (getCardinality() == CARDINAL_01) {
        result.append("?");
      }
    } // end else if

    return result.toString();
  } // end generateRegExpPattern()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

  public String toString() {
    if (content == null) {
      return "";
    }

    CStringBuilder result = new CStringBuilder();
    result.append("<");
    result.append(content);
    result.append(">");

    return result.toString();
  } // end toString()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   * DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public String toString() {
    CStringBuilder result = new CStringBuilder();
    result.append("<!ELEMENT ");
    result.append(name);
    result.append(" ");
    result.append(validNodes);
    result.append(">\n");

    return result.toString();
  } // end toString()
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   * @return DOCUMENT ME!
   */
  protected final String _GetTextContent(final Element elem,
      CStringBuilder content) {
    if (content == null) {
      content = new CStringBuilder();
    } // end if

    NodeList nl = elem.getChildNodes();

    for (int i = 0; i < nl.getLength(); i++) {
View Full Code Here

Examples of org.allcolor.xml.parser.CStringBuilder

   * DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public String toString() {
    CStringBuilder buffer = new CStringBuilder();
    CSSRuleList    list = getCssRules();

    for (int i = 0; i < list.getLength(); i++) {
      buffer.append(list.item(i));
    } // end for

    return buffer.toString();
  } // end toString()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.