Package org.jdom

Examples of org.jdom.Text


        decrementNesting();
        this.currentElement = this.currentElement.getParentElement();
    }

    public void writeTextContent(String text) throws IOException {
        this.currentElement.addContent(new Text(text));
    }
View Full Code Here


    assertEquals("Tilden <b>Hike</b>", item.getTitle());
    assertEquals("A hike in Tilden Park...", item.getDescription());
  }

  public void testTrimContents() {
    Content whitespace = new Text(" \n\t\t");
    Content cdata = new CDATA("Test");
    List<Content> content;
    List newList;

    // Empty content list
View Full Code Here

                Document valueDocument = (Document) value;
                addContent(valueDocument.getContent());
            }
            else if (value instanceof Text || value instanceof CDATA) {
                String string = ((Text) value).getText();
                element.addContent(new Text(string));
            }
            else if (value instanceof ProcessingInstruction) {
                ProcessingInstruction pi =
                    (ProcessingInstruction) ((ProcessingInstruction) value)
                        .clone();
                element.addContent(pi);
            }
            else if (value instanceof Comment) {
                Comment comment = (Comment) ((Comment) value).clone();
                element.addContent(comment);
            }
            else {
                String string = (String) TypeUtils.convert(value, String.class);
                if (string != null && !string.equals("")) {
                    element.addContent(new Text(string));
                }
            }
        }
    }
View Full Code Here

     
    }
    if (n.getConstructorType() == Factory.Node_charRef) {
      IInteger code = (IInteger) n.get(0);
      int c = java.lang.Integer.parseInt(code.getStringRepresentation());
      return new Text(new java.lang.String(Character.toChars(c)));
    }
    if (n.getConstructorType() == Factory.Node_entityRef) {
      return new EntityRef(((IString)n.get(0)).getValue());
    }

    java.lang.String text = ((IString)n.get(0)).getValue();
    if (n.getConstructorType() == Factory.Node_cdata) {
      return new CDATA(text);
    }
    if (n.getConstructorType() == Factory.Node_charData) {
      return new Text(text);
    }
    if (n.getConstructorType() == Factory.Node_comment) {
      return new Comment(text);
    }
   
View Full Code Here

    if (content instanceof CDATA) { // CDATA first (is subtype of Text)
      CDATA cdata = (CDATA)content;
      return vf.constructor(Factory.Node_cdata, getString(trim, cdata));
    }
    if (content instanceof Text) {
      Text text = (Text)content;
      return vf.constructor(Factory.Node_charData, getString(trim, text));
    }
    if (content instanceof Comment) {
      Comment comment = (Comment)content;
      IString data = vf.string(comment.getText());
View Full Code Here

      }

      if (addr > 0) {
        String tmp = new String(buffer.charArray[base + l], c, addr);
        // create new text node and make sure we insert &nbsp; (160)
        Text text = new Text(tmp.replace(' ', (char) 160));
        Element chunk = null;
        if ((currAttr & 0xfff) != 0) {
          if ((currAttr & VDUBuffer.BOLD) != 0)
            chunk = addChunk(new Element("B"), chunk, text);
          if ((currAttr & VDUBuffer.UNDERLINE) != 0)
View Full Code Here

                    text = elem.getText().trim();
                } else if (obj instanceof Attribute) {
                    Attribute att = (Attribute) obj;
                    text = att.getValue().trim();
                } else if (obj instanceof Text) {
                    Text txt = (Text) obj;
                    text = txt.getText().trim();
                } else if (obj instanceof Comment) {
                    Comment com = (Comment) obj;
                    text = com.getText().trim();
                } else if (obj instanceof ProcessingInstruction) {
                    ProcessingInstruction pi = (ProcessingInstruction) obj;
View Full Code Here

                    }
                } else if (node instanceof Attribute) {
                    Attribute att = (Attribute) node;
                    metadata.add(name, att.getValue());
                } else if (node instanceof Text) {
                    Text text = (Text) node;
                    metadata.add(name, text.getText());
                } else if (node instanceof Comment) {
                    Comment com = (Comment) node;
                    metadata.add(name, com.getText());
                } else if (node instanceof ProcessingInstruction) {
                    ProcessingInstruction pi = (ProcessingInstruction) node;
View Full Code Here

        }

        String[] children = {"done-flag", "uri-template"};
        for (String child : children) {
            Element childEle = new Element(child);
            childEle.setContent(new Text(((String) eval.getVariable(dataInName + "." + child)).replace('%', '$')));
            dsEle.getChildren().add(childEle);
        }

        String[] eleChildren = {"start-instance", "end-instance"};
        for (String child : eleChildren) {
            Element childEle = new Element(child);
            childEle.setContent(new Text("${" + ((String) eval.getVariable(dataInName + "." + child)) + "}"));
            ele.getChildren().add(childEle);
        }

        return ele;
    }
View Full Code Here

  private Element generateElement (String parentName, Span span, List childSpans, THashMap tree)
  {
    Element parentElt = new Element (parentName);
    if (childSpans == null || childSpans.isEmpty ()) {
      parentElt.setContent (new Text (span.getText ()));
    } else {
      List childElts = new ArrayList (childSpans.size());
      int start = span.getStartIdx ();
      int current = 0;
      for (int i = 0; i < childSpans.size(); i++) {
        LabeledSpan childSpan = (LabeledSpan) childSpans.get (i);
        Label childLabel = childSpan.getLabel();

        int childStart = childSpan.getStartIdx () - start;
        if (childStart > current) {
          childElts.add (new Text (span.getText().substring (current, childStart)));
        }

        if (childLabel == backgroundTag) {
          childElts.add (new Text (childSpan.getText()));
        } else {
          String name = childLabel.getEntry ().toString();
          List grandchildren = (List) tree.get (childSpan);
          childElts.add (generateElement (name, childSpan, grandchildren, tree));
        }

        current = childSpan.getEndIdx () - start;
      }

      if (current < span.getEndIdx ())
        childElts.add (new Text (span.getText().substring (current)));

      parentElt.addContent (childElts);
    }

    return parentElt;
View Full Code Here

TOP

Related Classes of org.jdom.Text

Copyright © 2018 www.massapicom. 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.