예제 #1
0
  /**
   * A {@link StartTag} can be only written after we are sure that all the necessary namespace
   * declarations are given.
   */
  boolean isReadyToCommit() {
    if (owner != null && owner.isBlocked()) return false;

    for (Content c = getNext(); c != null; c = c.getNext())
      if (c.concludesPendingStartTag()) return true;

    return false;
  }
예제 #2
0
 public void written() {
   firstAtt = lastAtt = null;
   uri = null;
   if (owner != null) {
     assert owner.startTag == this;
     owner.startTag = null;
   }
 }
  public void parse(Reader r, boolean withLineNumbers) {
    JavaScanner js = new JavaScanner(r);

    ContainerElement container;
    Style lineStyle;
    if (withLineNumbers) {
      container =
          new OrderedListElement(
              new Style(normalStyle, new StyleSheetKey("ol", "linenumbers", null)), 1);
      lineStyle = new Style(container.getStyle(), new StyleSheetKey("li", null, null));
    } else {
      container = new BlockElement(normalStyle);
      lineStyle = null;
    }
    ContainerElement line = null;
    TextElement newLine = new TextElement(normalStyle, "\n");

    JavaScanner.Kind kind;
    while ((kind = js.scan()) != JavaScanner.Kind.EOF) {
      if (withLineNumbers && line == null) {
        line = new ContainerElement(lineStyle);
      }
      if (kind == JavaScanner.Kind.NEWLINE) {
        if (line != null) {
          line.add(newLine);
          container.add(line);
          line = null;
        } else {
          container.add(newLine);
        }
        continue;
      }
      TextElement textElement = new TextElement(styles.get(kind), js.getString());
      if (line != null) {
        line.add(textElement);
      } else {
        container.add(textElement);
      }
    }

    root = container;
    doCallback();
  }