Package org.htmlparser.tags

Examples of org.htmlparser.tags.ScriptTag


    createParser("<SCRIPT language=JavaScript>" + "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" "
        + "width=\"80\" height=\"20\" border=\"0\"></a>\");" + "</SCRIPT>");
    parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertType("script", ScriptTag.class, node[0]);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("script code", "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" "
        + "width=\"80\" height=\"20\" border=\"0\"></a>\");", scriptTag.getScriptCode());
  }
View Full Code Here


    createParser("<SCRIPT language=JavaScript>" + "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" "
        + "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");" + "</SCRIPT>");
    parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertType("script", ScriptTag.class, node[0]);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("script code", "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" "
        + "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");", scriptTag.getScriptCode());
  }
View Full Code Here

    String scriptContents = "alert()\r\nalert()";
    createParser("<script>" + scriptContents + "</script>");
    parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertType("script", ScriptTag.class, node[0]);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("script code", scriptContents, scriptTag.getScriptCode());
  }
View Full Code Here

  public void testCreation() {
    StringNode stringNode = new StringNode(new StringBuffer("Script Code"), 0, 0);
    NodeList childVector = new NodeList();
    childVector.add(stringNode);
    ScriptTag scriptTag = new ScriptTag(new TagData(0, 10, "Tag Contents", "tagline"), new CompositeTagData(null,
        null, childVector));

    assertNotNull("Script Tag object creation", scriptTag);
    assertEquals("Script Tag Begin", 0, scriptTag.elementBegin());
    assertEquals("Script Tag End", 10, scriptTag.elementEnd());
    assertEquals("Script Tag Contents", "Tag Contents", scriptTag.getText());
    assertEquals("Script Tag Code", "Script Code", scriptTag.getScriptCode());
    assertEquals("Script Tag Line", "tagline", scriptTag.getTagLine());
  }
View Full Code Here

    parser.addScanner(new ScriptScanner("-s"));

    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertEquals("Expected Raw String", "<SCRIPT>document.write(d+\".com\")</SCRIPT>", scriptTag.toHtml());
  }
View Full Code Here

    String expectedHTML = new String(sb2.toString());

    parseAndAssertNodeCount(2);
    assertTrue("Node should be a script tag", node[1] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[1];
    assertStringEquals("Expected Script Code", expectedHTML, scriptTag.toHtml());
  }
View Full Code Here

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertEquals("Script Src", "/adb.js", scriptTag.getAttribute("src"));
    assertEquals("Script Language", "javascript", scriptTag.getAttribute("language"));
  }
View Full Code Here

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    // parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("Script toHTML()",
        "<SCRIPT LANGUAGE=\"javascript\">\r\nvar lower = '<%=lowerValue%>';\r\n</SCRIPT>", scriptTag.toHtml());
  }
View Full Code Here

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("Script toHTML()", "<SCRIPT SRC=\"<%=sourceFileName%>\"></SCRIPT>", scriptTag.toHtml());
  }
View Full Code Here

  public String[] getID() {
    return MATCH_NAME;
  }

  public Tag createTag(TagData tagData, CompositeTagData compositeTagData) {
    return new ScriptTag(tagData, compositeTagData);
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.ScriptTag

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.