/** * Get the child of this node at the given position. * @param index The in the node list of the child. * @return The child at that index. */ public Node getChild (int index) { return ( (null == getChildren ()) ? null : getChildren ().elementAt (index)); }
/** * Get the style data in this tag. * @return The HTML of the children of this tag. */ public String getStyleCode () { return (getChildrenHTML ()); }
/** * Returns the node number of the first node containing the given text. * This can be useful to index into the composite tag and get other children. * Text is compared without case sensitivity and conversion to uppercase * uses an English locale. * @param text The text to search for. * @return int The node index in the children list of the node containing * the text or -1 if not found. * @see #findPositionOf (String, Locale) */ public int findPositionOf (String text) { return (findPositionOf (text, Locale.ENGLISH)); }
/** * Return this tag as HTML code. * @return This tag and it's contents (children) and the end tag * as HTML code. */ public String toHtml() { StringBuilder sb = new StringBuilder(); sb.append (super.toHtml ()); if (!isEmptyXmlTag()) { putChildrenInto(sb); if (null != getEndTag ()) putEndTagInto(sb); } return sb.toString(); }
public Row() { rowNode = (TableRow) newTag(TableRow.class); rowNode.setChildren(new NodeList()); Tag endNode = new TableRow(); endNode.setTagName("/" + rowNode.getTagName().toLowerCase()); rowNode.setEndTag(endNode); }
/** * Return this tag as HTML code. * @param verbatim If <code>true</code> return as close to the original * page text as possible. * @return This tag and it's contents (children) and the end tag * as HTML code. */ public String toHtml (boolean verbatim) { StringBuffer ret; ret = new StringBuffer (); ret.append (super.toHtml (verbatim)); if (!isEmptyXmlTag ()) { putChildrenInto (ret, verbatim); if (null != getEndTag ()) putEndTagInto (ret, verbatim); } return (ret.toString ()); }
if (visitor.shouldRecurseChildren ()) if (null != getChildren ()) children = children (); while (children.hasMoreNodes ()) if ((null != getEndTag ()) && (this != getEndTag ())) // 2nd guard handles <tag/> getEndTag ().accept (visitor);
buffer.append (super.toString ()); buffer.append (System.getProperty ("line.separator")); for (SimpleNodeIterator e = children (); e.hasMoreNodes ();) ((CompositeTag)node).toString (level + 1, buffer); else if ((null != getEndTag ()) && (this != getEndTag ())) // 2nd guard handles <tag/> buffer.append (getEndTag ().toString ()); buffer.append (System.getProperty ("line.separator"));
/** * Return the HTML code for the children of this tag. * @return A string with the HTML code for the contents of this tag. */ public String getChildrenHTML() { StringBuffer buff = new StringBuffer(); for (SimpleNodeIterator e = children();e.hasMoreNodes();) { AbstractNode node = (AbstractNode)e.nextNode(); buff.append(node.toHtml()); } return buff.toString(); }
Tag endTag = beginTag.getEndTag(); int beginTagBegin = beginTag.getStartPosition (); int endTagBegin = beginTag.getEndPosition (); int beginTagEnd = endTag.getStartPosition (); int endTagEnd = endTag.getEndPosition ();
/** * Add the textual contents of the end tag of this node to the buffer. * @param sb The buffer to append to. */ protected void putEndTagInto(StringBuilder sb) { // eliminate virtual tags // if (!(endTag.getStartPosition () == endTag.getEndPosition ())) sb.append(getEndTag ().toHtml()); }
/** * Finds a text node, however embedded it might be, and returns * it. The text node will retain links to its parents, so * further navigation is possible. * @param searchText The text to search for. * @return The list of text nodes (recursively) found. */ public Text[] digupStringNode(String searchText) { NodeList nodeList = searchFor(searchText); NodeList stringNodes = new NodeList(); for (int i=0;i<nodeList.size();i++) { Node node = nodeList.elementAt(i); if (node instanceof Text) { stringNodes.add(node); } else { if (node instanceof CompositeTag) { CompositeTag ctag = (CompositeTag)node; Text[] nodes = ctag.digupStringNode(searchText); for (int j=0;j<nodes.length;j++) stringNodes.add(nodes[j]); } } } Text[] stringNode = new Text[stringNodes.size()]; for (int i=0;i<stringNode.length;i++) { stringNode[i] = (Text)stringNodes.elementAt(i); } return stringNode; }
/** * Get the list of input fields. * @return Input elements in the form. */ public NodeList getFormInputs() { return (searchFor (InputTag.class, true)); }
Tag jEndTag = jStartTag.getEndTag(); int jStartTagBegin = jStartTag.getStartPosition (); int jEndTagEnd = jEndTag.getEndPosition (); for (int k=0; k<links.size(); k++) Tag kEndTag = kStartTag.getEndTag(); int kStartTagBegin = kStartTag.getStartPosition (); int kEndTagEnd = kEndTag.getEndPosition (); if ((k!=j) && (kStartTagBegin>jStartTagBegin) && (kEndTagEnd<jEndTagEnd))
public Row() { rowNode = (TableRow) newTag(TableRow.class); rowNode.setChildren(new NodeList()); Tag endNode = new TableRow(); endNode.setTagName("/" + rowNode.getTagName().toLowerCase()); rowNode.setEndTag(endNode); }
buffer.append (super.toString ()); buffer.append (System.getProperty ("line.separator")); for (SimpleNodeIterator e = children (); e.hasMoreNodes ();) ((CompositeTag)node).toString (level + 1, buffer); else if ((null != getEndTag ()) && (this != getEndTag ())) // 2nd guard handles <tag/> buffer.append (getEndTag ().toString ()); buffer.append (System.getProperty ("line.separator"));
/** * Return the HTML code for the children of this tag. * @return A string with the HTML code for the contents of this tag. */ public String getChildrenHTML() { StringBuilder buff = new StringBuilder(); for (SimpleNodeIterator e = children();e.hasMoreNodes();) { AbstractNode node = (AbstractNode)e.nextNode(); buff.append(node.toHtml()); } return buff.toString(); }
Tag endTag = beginTag.getEndTag(); int beginTagBegin = beginTag.getStartPosition (); int endTagBegin = beginTag.getEndPosition (); int beginTagEnd = endTag.getStartPosition (); int endTagEnd = endTag.getEndPosition ();