/** * Tests if the link is javascript * @return flag indicating if the link is a javascript code */ public boolean isJavascriptLink() { getLink (); // force an evaluation of the booleans return (javascriptLink); }
/** * Return the contents of this link node as a string suitable for debugging. * @return A string representation of this node. */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Link to : "+ getLink() + "; titled : "+getLinkText ()+"; begins at : "+getStartPosition ()+"; ends at : "+getEndPosition ()+ ", AccessKey="); if (getAccessKey ()==null) sb.append("null\n"); else sb.append(getAccessKey ()+"\n"); if (null != getChildren ()) { sb.append(" "+"LinkData\n"); sb.append(" "+"--------\n"); Node node; int i = 0; for (SimpleNodeIterator e=children();e.hasMoreNodes();) { node = e.nextNode(); sb.append(" "+(i++)+ " "); sb.append(node.toString()+"\n"); } } sb.append(" "+"*** END of LinkData ***\n"); return sb.toString(); }
public class MyLinkVisitor extends NodeVisitor { public MyLinkVisitor() { } public void visitTag(Tag tag) { if (tag.getTagName().equals("A")) { LinkTag link = (LinkTag) tag; link.setLink("http://newLink/"); //implement your logic here } } }
String href_ = tag.getAttribute("href"); int linkhandletype=needProcess(href_,true); if (linkhandletype != this.LINK_NO_PARSER_NO_DISTRIBUTE) { link = m_linkTable.getLink(tag.getLink()); if (link != null) { tag.setLink(link.getHref()); } else { if (this.baseUrl != null) link = new CMSLink(baseUrl, tag.getLink(),linkhandletype); else link = new CMSLink(tag.getLink(),linkhandletype); parser = new LinkParser(link); link = parser.getResult(); tag.setLink(link.getHref()); String targetUri = tag.extractLink(); tag.setLink(link.getHref()); } else { if (this.baseUrl != null) tag.setLink(link.getHref());
/** * Return the contents of this link node as a string suitable for debugging. * @return A string representation of this node. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Link to : "+ getLink() + "; titled : "+getLinkText ()+"; begins at : "+getStartPosition ()+"; ends at : "+getEndPosition ()+ ", AccessKey="); if (getAccessKey ()==null) sb.append("null\n"); else sb.append(getAccessKey ()+"\n"); if (null != getChildren ()) { Node node; int i = 0; for (SimpleNodeIterator e=children();e.hasMoreNodes();) { node = e.nextNode(); sb.append(" "+(i++)+ " "); sb.append(node.toString()+"\n"); } } return sb.toString(); }
public void visitTag(Tag tag) { if (tag instanceof LinkTag) ((LinkTag)tag).setLink(linkPrefix + ((LinkTag)tag).getLink()); else if (tag instanceof ImageTag) ((ImageTag)tag).setImageURL(linkPrefix + ((ImageTag)tag).getImageURL()); // process only those nodes that won't be processed by an end tag, // nodes without parents or parents without an end tag, since // the complete processing of all children should happen before // we turn this node back into html text if (null == tag.getParent () && (!(tag instanceof CompositeTag) || null == ((CompositeTag)tag).getEndTag ())) modifiedResult.append(tag.toHtml()); }
@Test public void testLinkExtraction() throws ParserException { Parser parser = new Parser("http://synyx.de"); ObjectFindingVisitor visitor = new ObjectFindingVisitor(LinkTag.class); parser.visitAllNodesWith(visitor); Node[] links = visitor.getTags(); // TODO this could use some more meaningful assertions assertTrue(links.length > 0); for (int i = 0; i < links.length; i++) { LinkTag linkTag = (LinkTag) links[i]; System.out.print("\"" + linkTag.getLinkText() + "\" => "); System.out.println(linkTag.getLink()); } } }
String anchor = link.getLinkText(); String url = normalizeURL(link.extractLink());
public void visitTag(Tag tag) { if (tag instanceof LinkTag) if (-1 != ((LinkTag)tag).getLinkText ().toUpperCase (locale).indexOf (linkTextToFind)) count++; }
mLink = extractLink ();
registerTag (new JspTag ()); registerTag (new LabelTag ()); registerTag (new LinkTag ()); registerTag (new MetaTag ()); registerTag (new ObjectTag ());
public void visitTag(Tag tag) { if (tag instanceof LinkTag) ((LinkTag)tag).setLink(linkPrefix + ((LinkTag)tag).getLink()); else if (tag instanceof ImageTag) ((ImageTag)tag).setImageURL(linkPrefix + ((ImageTag)tag).getImageURL()); // process only those nodes that won't be processed by an end tag, // nodes without parents or parents without an end tag, since // the complete processing of all children should happen before // we turn this node back into html text if (null == tag.getParent () && (!(tag instanceof CompositeTag) || null == ((CompositeTag)tag).getEndTag ())) modifiedResult.append(tag.toHtml()); }
String anchor = link.getLinkText(); String url = link.extractLink();
public void visitTag(Tag tag) { if (tag instanceof LinkTag) if (-1 != ((LinkTag)tag).getLinkText ().toUpperCase (locale).indexOf (linkTextToFind)) count++; }
registerTag (new JspTag ()); registerTag (new LabelTag ()); registerTag (new LinkTag ()); registerTag (new MetaTag ()); registerTag (new ObjectTag ());
/** * Is this a mail address * @return boolean true/false */ public boolean isMailLink() { getLink (); // force an evaluation of the booleans return (mailLink); }
/** * Is this a mail address * @return boolean true/false */ public boolean isMailLink() { getLink (); // force an evaluation of the booleans return (mailLink); }
/** * Tests if the link is javascript * @return flag indicating if the link is a javascript code */ public boolean isJavascriptLink() { getLink (); // force an evaluation of the booleans return (javascriptLink); }