コード例 #1
0
 private String textOfElementWithClass(Element[] elements, String clazz) {
   for (Element div : elements) {
     if (clazz.equals(div.getAttributeValue("class"))) {
       return div.getText();
     }
   }
   return "";
 }
コード例 #2
0
 public boolean hasEmbeddedCSS(String css) {
   Element head = getHeadElement();
   for (Element style : head.getChildElements("style")) {
     if (style.getText().contains(css)) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
  public String getElementXML(String className) {
    Element[] childDivs = getRootElement().getDescendantElements("div");

    for (Element div : childDivs) {
      if (className.equals(div.getAttributeValue("class"))) {
        return div.toXML();
      }
    }
    return "";
  }
コード例 #4
0
 public boolean hasEmbeddedJavaScript(String javaScript) {
   Element head = getHeadElement();
   for (Element script : head.getChildElements("script")) {
     String type = script.getAttributeValue("type");
     if ("text/javascript".equals(type) && script.getText().contains(javaScript)) {
       return true;
     }
   }
   return false;
 }
コード例 #5
0
 public boolean hasJavaScriptDeclaration(String cssFilename) {
   Element head = getHeadElement();
   for (Element script : head.getChildElements("script")) {
     String type = script.getAttributeValue("type");
     String src = script.getAttributeValue("src");
     if ("text/javascript".equals(type) && cssFilename.equals(src)) {
       return true;
     }
   }
   return false;
 }
コード例 #6
0
 public boolean hasCSSDeclaration(String cssFilename) {
   Element head = getHeadElement();
   for (Element link : head.getChildElements("link")) {
     String href = link.getAttributeValue("href");
     String type = link.getAttributeValue("type");
     String rel = link.getAttributeValue("rel");
     if (cssFilename.equals(href) && "text/css".equals(type) && "stylesheet".equals(rel)) {
       return true;
     }
   }
   return false;
 }
コード例 #7
0
  @Override
  public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) {
    Check.isFalse(
        commandCall.hasChildCommands(), "Nesting commands inside an 'echo' is not supported");

    Object result = evaluator.evaluate(commandCall.getExpression());

    Element element = commandCall.getElement();
    if (result != null) {
      element.appendText(result.toString());
    } else {
      Element child = new Element("em");
      child.appendText("null");
      element.appendChild(child);
    }
  }