Examples of HyperLinkUtil


Examples of org.exoplatform.services.html.util.HyperLinkUtil

      for (HTMLNode child : document.getRoot().getChildrenNode().get(1).getChildrenNode())
      {
         System.out.println(child.getName().toString() + " : " + new String(child.getValue()));
      }

      HyperLinkUtil hyperlinkUtil = new HyperLinkUtil();
      List<String> linkList = new ArrayList<String>();

      //SiteLink---------------------------------------------------------------------------------
      linkList = hyperlinkUtil.getSiteLink(document.getRoot());
      assertEquals(3, linkList.size());
      assertEquals("http://www.exoplatform.com", linkList.get(0).toString());

      System.out.println("\nSHOW ALL HYPERLINKs: ");
      for (int i = 0; i < linkList.size(); i++)
      {
         System.out.println(linkList.get(i).toString());
      }

      HTMLNode tableNode = NodePathUtil.lookFor(document.getRoot(), NodePathParser.toPath("html.body.table"));
      linkList.clear();
      linkList = hyperlinkUtil.getSiteLink(tableNode);
      assertEquals(2, linkList.size());
      assertEquals("/homepage.html", linkList.get(0).toString());

      //ImageLink--------------------------------------------------------------------------------
      String imageLink = hyperlinkUtil.getSingleImageLink(document.getRoot());
      assertEquals("/images/home.gif", imageLink);
      System.out.println("\nIMAGE-LINK: " + imageLink);

      //CreateFullNormalLink.---------------------------------------------------------------------   
      HTMLNode bodyNode = document.getRoot().getChildrenNode().get(1);
      assertEquals(bodyNode.getName(), Name.BODY);
      /*
      URL url_ = new URL("http://www.exoplatform.com");   
      assertNotNull(url_);   
      hyperlinkUtil.createFullNormalLink(bodyNode, url_);
      */
      linkList.clear();
      linkList = hyperlinkUtil.getSiteLink(document.getRoot());
      System.out.println("\nSHOW ALL HYPERLINKs: ");
      for (int i = 0; i < linkList.size(); i++)
      {
         System.out.println(linkList.get(i).toString());
      }
      HTMLNode row2Node = tableNode.getChildren().get(0).getChildrenNode().get(1);
      assertNotNull(row2Node);
      assertEquals(row2Node.getName(), Name.TR);
      assertEquals("tr", new String(row2Node.getValue()));
      //System.out.println("ROW2: " + row2Node.getTextValue());
      HTMLNode row2Cell2 = row2Node.getChildrenNode().get(1);

      assertNotNull(new URL("http://www.mysite.net"));
      URLCreator urlCreator = new URLCreator();
      hyperlinkUtil.createFullNormalLink(row2Cell2, new URL("http://www.mysite.net"), urlCreator);
      linkList.clear();
      linkList = hyperlinkUtil.getSiteLink(document.getRoot());
      System.out.println("\nSHOW ALL HYPERLINKs: ");
      for (int i = 0; i < linkList.size(); i++)
      {
         System.out.println(linkList.get(i).toString());
      }

      //CreateFullImageLink.-----------------------------------------------------------------------
      hyperlinkUtil.createFullImageLink(document.getRoot(), new URL("http://www.myImageLink.net"));
      System.out.println("\nNEW IMAGE_LINK1:" + hyperlinkUtil.getSingleImageLink(document.getRoot()));
      hyperlinkUtil.createFullImageLink(document.getRoot(), new URL("http://www.exo.com"), new URLCreator());
      System.out.println("\nNEW IMAGE_LINK2:" + hyperlinkUtil.getSingleImageLink(document.getRoot()));
   }
View Full Code Here

Examples of org.vietspider.html.util.HyperLinkUtil

        new AutoSelectDataNode2(document, url, handler, tree);
       
        if(paths.length < 1) {
          HTMLExtractor extractor  = new HTMLExtractor();
          NodePathParser pathParser = new NodePathParser();
          if(hyperlinkUtil == null) hyperlinkUtil = new HyperLinkUtil();
          HTMLNode header = null;
          HTMLNode body = null;
          try {
            NodePath nodePath  = pathParser.toPath("HEAD");
            header = extractor.lookNode(document.getRoot(), nodePath);
View Full Code Here

Examples of org.vietspider.html.util.HyperLinkUtil

     
      NodePath headerPath  = pathParser.toPath("HEAD");
      HTMLNode header = extractor.lookNode(document.getRoot(), headerPath);
   
      if(toolbar.isShowAll()) {
        if(hyperlinkUtil == null) hyperlinkUtil = new HyperLinkUtil();
        try {
          String address = toolbar.getText();
          URL home = new URL(address);
         
          hyperlinkUtil.createFullNormalLink(node, home);
View Full Code Here

Examples of org.vietspider.html.util.HyperLinkUtil

  }

  public void setDocument(HTMLDocument doc){
    this.document = doc;

    if(hyperlinkUtil == null) hyperlinkUtil = new HyperLinkUtil();
    removeIFrameSource(document.getRoot());
    //    try {
    //      String address = toolbar.getText();
    //      URL home = new URL(address);
    //      Map<String,String> map = new HashMap<String,String>();
View Full Code Here

Examples of org.vietspider.html.util.HyperLinkUtil

  }
 
  public List<String> getLinks() throws Exception {
    HTMLParser2 parser2 = new HTMLParser2();
    HTMLDocument document  = parser2.createDocument(file, null);
    HyperLinkUtil linkUtil = new HyperLinkUtil() ;
    return linkUtil.scanSiteLink(document.getRoot());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.