Ejemplo n.º 1
0
  public void startNode(String name) {
    startPointer = writer.getPointer();
    quickNodeValue = false;
    lastTagHadAttributes = false;
    tagIsEmpty = false;
    finishTag();
    if (depth != 0) writer.write(LF);
    writer.write(
        WikiTableDriver.DELIM
            + WikiTableDriver.QUOTES
            + WikiTableDriver.START_NODE
            + WikiTableDriver.QUOTES
            + WikiTableDriver.DELIM);

    if (this.useLineSeparateBetweenTags) {
      writer.write(LF + WikiTableDriver.DELIM);
    }

    writer.write(name + WikiTableDriver.DELIM);
    elementStack.push(name);
    tagInProgress = true;
    depth++;
    readyForNewLine = true;
    tagIsEmpty = true;
  }
Ejemplo n.º 2
0
  /**
   * Adds attribute for XML node
   *
   * @param key - name of attribute
   * @param value - value of attribute
   */
  public void addAttribute(String key, String value) {
    writer.write(
        LF
            + WikiTableDriver.DELIM
            + WikiTableDriver.QUOTES
            + WikiTableDriver.ADD_ATTRIBUTE
            + WikiTableDriver.QUOTES
            + WikiTableDriver.DELIM);

    if (this.useLineSeparateBetweenTags) {
      writer.write(LF + WikiTableDriver.DELIM);
    }

    writer.write(key + WikiTableDriver.DELIM);

    writeAttributeValue(writer, value);
    writer.write(WikiTableDriver.DELIM);
    lastTagHadAttributes = true;
  }
Ejemplo n.º 3
0
  /**
   * Stores value of previously defined XML node
   *
   * @param text - value of node
   */
  public void setValue(String text) {
    readyForNewLine = false;
    tagIsEmpty = false;
    finishTag();

    if (lastTagHadAttributes) {
      writer.write(
          LF
              + WikiTableDriver.DELIM
              + WikiTableDriver.QUOTES
              + WikiTableDriver.SET_VALUE
              + WikiTableDriver.QUOTES
              + WikiTableDriver.DELIM);
      quickNodeValue = false;
    } else {
      String startTag =
          StringHelper.replace(
              writer.substring(startPointer),
              WikiTableDriver.START_NODE,
              WikiTableDriver.SET_NODE_VALUE);

      if (this.useLineSeparateBetweenTags) {
        writer.write(LF + WikiTableDriver.DELIM);
      }

      writer.setPointer(startPointer);
      writer.write(startTag);
      quickNodeValue = true;
    }

    writeText(writer, text);
    writer.write(WikiTableDriver.DELIM);
  }
Ejemplo n.º 4
0
 /** Marks end of node */
 public void endNode() {
   depth--;
   if (tagIsEmpty) {
     String prevTag = (String) elementStack.pop(); // Silently();
     if (!quickNodeValue) {
       writer.write(
           LF
               + WikiTableDriver.DELIM
               + WikiTableDriver.QUOTES
               + WikiTableDriver.END_NODE
               + WikiTableDriver.QUOTES
               + WikiTableDriver.DELIM);
       if (this.useLineSeparateBetweenTags) {
         writer.write(LF + WikiTableDriver.DELIM);
       }
       writer.write(prevTag + WikiTableDriver.DELIM);
     }
     readyForNewLine = false;
   } else {
     String prevTag = (String) elementStack.pop();
     if (!quickNodeValue) {
       writer.write(
           LF
               + WikiTableDriver.DELIM
               + WikiTableDriver.QUOTES
               + WikiTableDriver.END_NODE
               + WikiTableDriver.QUOTES
               + WikiTableDriver.DELIM);
       if (this.useLineSeparateBetweenTags) {
         writer.write(LF + WikiTableDriver.DELIM);
       }
       writer.write(prevTag + WikiTableDriver.DELIM);
     }
   }
   finishTag();
   readyForNewLine = true;
   if (depth == 0) {
     writer.flush();
   }
   quickNodeValue = false;
 }
Ejemplo n.º 5
0
 private void endOfLine() {
   writer.write(LF);
   for (int i = 0; i < depth; i++) {
     writer.write(lineIndenter);
   }
 }
Ejemplo n.º 6
0
 /** Closes output */
 public void close() {
   writer.close();
 }
Ejemplo n.º 7
0
 /** Flushes output */
 public void flush() {
   writer.flush();
 }