@Override public String getAttributeValue(String localName, String namespaceURI) { return element.getAttributeValue(localName, namespaceURI); } };
@Override public String getAttributeValue(String name) { return element.getAttributeValue(name); }
private String getHref(Element element) { String href = element.getAttributeValue("href"); if (href == null) { Element a = element.getFirstChildElement("a"); if (a != null) { href = a.getAttributeValue("href"); } } return href; } }
private String getHref(Element element) { String href = element.getAttributeValue("href"); if (href == null) { Element a = element.getFirstChildElement("a"); if (a != null) { href = a.getAttributeValue("href"); } } return href; } }
public Element addStyleClass(String styleClass) { String currentClass = getAttributeValue("class"); if (currentClass != null) { styleClass = currentClass + " " + styleClass; } addAttribute("class", styleClass); return this; }
public Element addStyleClass(String styleClass) { String currentClass = getAttributeValue("class"); if (currentClass != null) { styleClass = currentClass + " " + styleClass; } addAttribute("class", styleClass); return this; }
static void addClass(Element resultElement, String newClass) { String className = resultElement.getAttributeValue("class"); resultElement .addAttribute("class", className == null ? newClass : className + " " + newClass); } }
public boolean hasLinkedCSS(String baseOutputDir, String css) { for (Element style : getHeadElement().getChildElements("link")) { if ("stylesheet".equals(style.getAttributeValue("rel")) && css.endsWith(style.getAttributeValue("href"))) { return combine(baseOutputDir, style.getAttributeValue("href")).exists(); } } return false; }
private String textOfElementWithClass(Element[] elements, String clazz) { for (Element div : elements) { if (clazz.equals(div.getAttributeValue("class"))) { return div.getText(); } } return ""; }
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; }
public boolean hasLinkedJavaScript(String baseOutputDir, String javaScript) { for (Element style : getHeadElement().getChildElements("script")) { if ("text/javascript".equals(style.getAttributeValue("type")) && javaScript.equals(style.getAttributeValue("src"))) { return combine(baseOutputDir, style.getAttributeValue("src")).exists(); } } return false; }
public String getLinkedCSS(String baseOutputDir, String css) throws IOException { for (Element style : getHeadElement().getChildElements("link")) { if ("stylesheet".equals(style.getAttributeValue("rel")) && css.endsWith(style.getAttributeValue("href"))) { return readFile(combine(baseOutputDir, style.getAttributeValue("href")).getPath()); } } return ""; }
public String getLinkedJavaScript(String baseOutputDir, String javaScript) throws IOException { for (Element style : getHeadElement().getChildElements("script")) { if ("text/javascript".equals(style.getAttributeValue("type")) && javaScript.equals(style.getAttributeValue("src"))) { return readFile(combine(baseOutputDir, style.getAttributeValue("src")).getPath()); } } return ""; }
private String getTargetExpression(SetEvent event) { if (event.getElement().getAttributeValue("set") != null) { return event.getElement().getAttributeValue("set"); } else { return event.getExpression(); } } }
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; }
public boolean getLinkExists(String expectedResource) { Element[] links = result.getRootElement().getFirstChildElement("head").getChildElements("link"); for (Element link : links) { if (link.getAttributeValue("href").equals(expectedResource)) { return true; } } return false; }
public String getElementXML(String className) { Element[] childDivs = getRootElement().getDescendantElements("div"); for (Element div : childDivs) { if (className.equals(div.getAttributeValue("class"))) { return div.toXML(); } } return ""; }
public boolean getScriptExists(String expectedResource) { Element[] scripts = result.getRootElement().getFirstChildElement("head").getChildElements("script"); for (Element script : scripts) { if (script.getAttributeValue("src").equals(expectedResource)) { return true; } } return false; }
public void beforeParsing(Document document) { Element rootElement = new Element(document.getRootElement()); String newValue = text; String existingValue = rootElement.getAttributeValue(FAKE_EXTENSION_ATTR_NAME); if (existingValue != null) { newValue = existingValue + ", " + newValue; } rootElement.addAttribute(FAKE_EXTENSION_ATTR_NAME, newValue); } }
public String process(String javaFragment) throws Exception { compiler = new JavaSourceCompiler(); String htmlFragment = ""; Object fixture = compile(javaFragment); ProcessingResult result = process(htmlFragment, fixture); return result.getRootElement().getAttributeValue(FakeExtensionBase.FAKE_EXTENSION_ATTR_NAME); }