本文整理汇总了Java中org.thymeleaf.dom.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于org.thymeleaf.dom包,在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processElement
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
protected ProcessorResult processElement(Arguments arguments, Element element) {
StringBuffer sb = new StringBuffer();
sb.append("<SCRIPT>\n");
sb.append(" var params = \n ");
sb.append(buildContentMap(arguments)).append(";\n ");
sb.append(getUncacheableDataFunction(arguments, element)).append(";\n");
sb.append("</SCRIPT>");
// Add contentNode to the document
Node contentNode = new Macro(sb.toString());
element.clearChildren();
element.getParent().insertAfter(element, contentNode);
element.getParent().removeChild(element);
// Return OK
return ProcessorResult.OK;
}
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:20,代码来源:UncacheableDataProcessor.java
示例2: matchesSafely
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
protected boolean matchesSafely(HtmlElement item) {
Element element = item.getElement();
if(element!=null && element.hasChildren()) {
List<Node> children = element.getChildren();
for(Node child : children) {
if(child instanceof Comment) {
if(expectedText==null) {
return true;
} else {
if(expectedText.equals(((Comment)child).getContent())) {
return true;
}
}
}
}
}
return false;
}
开发者ID:connect-group,项目名称:thymeleaf-tdd,代码行数:22,代码来源:HasComment.java
示例3: matchesSafely
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
public boolean matchesSafely(HtmlElement item) {
StringBuilder text = new StringBuilder();
boolean fail = false;
Element element = item.getElement();
if(element!=null && element.hasChildren()) {
List<Node> children = element.getChildren();
for(Node child : children) {
if(child instanceof Text) {
text.append(((Text)child).getContent());
} else if(!(child instanceof Comment)) {
fail = true;
break;
}
}
}
return !fail && text.toString().equals(value);
}
开发者ID:connect-group,项目名称:thymeleaf-tdd,代码行数:22,代码来源:HasOnlyText.java
示例4: querySelectorAll
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Set<Node> querySelectorAll(String selectors) throws NodeSelectorException {
Assert.notNull(selectors, "selectors is null!");
List<List<Selector>> groups;
try {
Scanner scanner = new Scanner(selectors);
groups = scanner.scan();
} catch (ScannerException e) {
throw new NodeSelectorException(e);
}
Set<Node> results = new LinkedHashSet<Node>();
for (List<Selector> parts : groups) {
Set<Node> result = check(parts);
if (!result.isEmpty()) {
results.addAll(result);
}
}
return results;
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:24,代码来源:DOMNodeSelector.java
示例5: getNextSiblingElement
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Get the next sibling element.
*
* @param node The start node.
* @return The next sibling element or {@code null}.
*/
public static final Element getNextSiblingElement(Node node) {
List<Node> siblings = node.getParent().getChildren();
Node n = null;
int index = siblings.indexOf(node) + 1;
if(index>0 && index<siblings.size()) {
n = siblings.get(index);
while(!(n instanceof Element) && ++index < siblings.size()) {
n = siblings.get(index);
}
if(index==siblings.size()) {
n = null;
}
}
return (Element) n;
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:26,代码来源:DOMHelper.java
示例6: getPreviousSiblingElement
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Get the previous sibling element.
*
* @param node The start node.
* @return The previous sibling element or {@code null}.
*/
public static final Element getPreviousSiblingElement(Node node) {
List<Node> siblings = node.getParent().getChildren();
Node n = null;
int index = siblings.indexOf(node) - 1;
if(index>=0) {
n = siblings.get(index);
while(!(n instanceof Element) && --index >= 0) {
n = siblings.get(index);
}
if(index<0) {
n = null;
}
}
return (Element) n;
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:27,代码来源:DOMHelper.java
示例7: addChildElements
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add child elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#child-combinators">Child combinators</a>
*/
private void addChildElements() {
for (Node node : nodes) {
if(node instanceof NestableNode) {
List<Node> nl = ((NestableNode) node).getChildren();
for (Node n : nl) {
if (!(n instanceof Element)) {
continue;
}
String tag = selector.getTagName();
if (tagEquals(tag, ((Element)n).getNormalizedName()) || tag.equals(Selector.UNIVERSAL_TAG)) {
result.add(n);
}
}
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:23,代码来源:TagChecker.java
示例8: addEmptyElements
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add {@code :empty} elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#empty-pseudo"><code>:empty</code> pseudo-class</a>
*/
private void addEmptyElements() {
for (Node node : nodes) {
boolean empty = true;
if(node instanceof NestableNode) {
List<Node> nl = ((NestableNode) node).getChildren();
for (Node n : nl) {
if (n instanceof Element) {
empty = false;
break;
} else if (n instanceof Text) {
// TODO: Should we trim the text and see if it's length 0?
String value = ((Text) n).getContent();
if (value.length() > 0) {
empty = false;
break;
}
}
}
}
if (empty) {
result.add(node);
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:30,代码来源:PseudoClassSpecifierChecker.java
示例9: addFirstOfType
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add {@code :first-of-type} elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#first-of-type-pseudo"><code>:first-of-type</code> pseudo-class</a>
*/
private void addFirstOfType() {
for (Node node : nodes) {
Node n = DOMHelper.getPreviousSiblingElement(node);
while (n != null) {
if (DOMHelper.getNodeName(n).equals(DOMHelper.getNodeName(node))) {
break;
}
n = DOMHelper.getPreviousSiblingElement(n);
}
if (n == null) {
result.add(node);
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:22,代码来源:PseudoClassSpecifierChecker.java
示例10: addLastOfType
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add {@code :last-of-type} elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#last-of-type-pseudo"><code>:last-of-type</code> pseudo-class</a>
*/
private void addLastOfType() {
for (Node node : nodes) {
Node n = DOMHelper.getNextSiblingElement(node);
while (n != null) {
if (DOMHelper.getNodeName(n).equals(DOMHelper.getNodeName(node))) {
break;
}
n = DOMHelper.getNextSiblingElement(n);
}
if (n == null) {
result.add(node);
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:22,代码来源:PseudoClassSpecifierChecker.java
示例11: check
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Set<Node> check(Set<Node> nodes, Node root) throws NodeSelectorException {
Assert.notNull(nodes, "nodes is null!");
this.nodes = nodes;
result = new LinkedHashSet<Node>();
String value = specifier.getValue();
if ("nth-child".equals(value)) {
addNthChild();
} else if ("nth-last-child".equals(value)) {
addNthLastChild();
} else if ("nth-of-type".equals(value)) {
addNthOfType();
} else if ("nth-last-of-type".equals(value)) {
addNthLastOfType();
} else {
throw new NodeSelectorException("Unknown pseudo nth class: " + value);
}
return result;
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:24,代码来源:PseudoNthSpecifierChecker.java
示例12: addNthOfType
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add {@code :nth-of-type} elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#nth-of-type-pseudo"><code>:nth-of-type</code> pseudo-class</a>
*/
private void addNthOfType() {
for (Node node : nodes) {
int count = 1;
Node n = DOMHelper.getPreviousSiblingElement(node);
while (n != null) {
if (DOMHelper.getNodeName(n).equals(DOMHelper.getNodeName(node))) {
count++;
}
n = DOMHelper.getPreviousSiblingElement(n);
}
if (specifier.isMatch(count)) {
result.add(node);
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:23,代码来源:PseudoNthSpecifierChecker.java
示例13: addNthLastOfType
import org.thymeleaf.dom.Node; //导入依赖的package包/类
/**
* Add {@code nth-last-of-type} elements.
*
* @see <a href="http://www.w3.org/TR/css3-selectors/#nth-last-of-type-pseudo"><code>:nth-last-of-type</code> pseudo-class</a>
*/
private void addNthLastOfType() {
for (Node node : nodes) {
int count = 1;
Node n = DOMHelper.getNextSiblingElement(node);
while (n != null) {
if (DOMHelper.getNodeName(n).equals(DOMHelper.getNodeName(node))) {
count++;
}
n = DOMHelper.getNextSiblingElement(n);
}
if (specifier.isMatch(count)) {
result.add(node);
}
}
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:23,代码来源:PseudoNthSpecifierChecker.java
示例14: htmlFor
import org.thymeleaf.dom.Node; //导入依赖的package包/类
private static StringBuilder htmlFor(Element element, StringBuilder builder) {
startTag(element, builder);
for(Node node : element.getChildren()) {
if(node instanceof Element) {
builder = htmlFor((Element)node, builder);
} else if(node instanceof Text) {
builder.append(((Text)node).getContent());
} else if(node instanceof Comment) {
builder.append("<!--");
builder.append(((Comment)node).getContent());
builder.append("-->");
} else if(node instanceof CDATASection) {
builder.append("<![CDATA[");
builder.append(((CDATASection)node).getContent());
builder.append("]]>");
}
}
endTag(element, builder);
return builder;
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:24,代码来源:HtmlElement.java
示例15: checkRoot
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Test
public void checkRoot() throws NodeSelectorException {
Element root = (Element)nodeSelector.querySelector(":root");
Assert.assertEquals("html", root.getNormalizedName());
DOMNodeSelector subSelector = new DOMNodeSelector(nodeSelector.querySelector("div#scene1"));
Set<Node> subRoot = subSelector.querySelectorAll(":root");
Assert.assertEquals(1, subRoot.size());
NestableAttributeHolderNode node =(NestableAttributeHolderNode) subRoot.iterator().next();
Assert.assertEquals("scene1", node.getAttributeMap().get("id").getValue());
Assert.assertEquals((int) testDataMap.get("div#scene1 div.dialog div"), subSelector.querySelectorAll(":root div.dialog div").size());
Node meta = nodeSelector.querySelector(":root > head > meta");
Assert.assertEquals(meta, new DOMNodeSelector(meta).querySelector(":root"));
}
开发者ID:connect-group,项目名称:thymesheet,代码行数:18,代码来源:DOMNodeSelectorTest.java
示例16: adaptHeader
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
protected void adaptHeader(HtmlTable table) {
Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(
DataTablesDialect.INTERNAL_NODE_TABLE);
Element thead = DomUtils.findElement((Element) tableNode, "thead");
Element tr = new Element("tr");
for (HtmlColumn column : table.getLastHeaderRow().getColumns()) {
Element th = new Element("th");
th.addChild(new Text(column.getContent().toString()));
tr.addChild(th);
}
if (thead != null) {
thead.addChild(tr);
}
else {
thead = new Element("thead");
thead.addChild(tr);
((Element) tableNode).addChild(thead);
}
}
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:25,代码来源:FilteringFeature.java
示例17: adaptFooter
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
protected void adaptFooter(HtmlTable table) {
Element tfoot = new Element("tfoot");
Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(
DataTablesDialect.INTERNAL_NODE_TABLE);
for (HtmlColumn column : table.getLastHeaderRow().getColumns()) {
Element th = new Element("th");
th.addChild(new Text(column.getContent().toString()));
tfoot.addChild(th);
}
((Element) tableNode).addChild(tfoot);
}
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:17,代码来源:FilteringFeature.java
示例18: getMarkupSubstitutes
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
protected List<Node> getMarkupSubstitutes(
final Arguments arguments, final Element element) {
final Element input = new Element("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", csrf.getTokenName());
final String token = csrf.getCurrentToken(org.wisdom.api.http.Context.CONTEXT.get());
if (token != null) {
input.setAttribute("value", token);
} else {
input.setAttribute("value", "invalid");
}
final List<Node> nodes = new ArrayList<>();
nodes.add(input);
return nodes;
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:17,代码来源:ThymeleafCsrfDialect.java
示例19: computeFragment
import org.thymeleaf.dom.Node; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected List<Node> computeFragment(final Arguments arguments, final Element element) {
// The pageTitle attribute could be an expression that needs to be evaluated. Try to evaluate, but fall back
// to its text value if the expression wasn't able to be processed. This will allow things like
// pageTitle="Hello this is a string"
// as well as expressions like
// pageTitle="${'Hello this is a ' + product.name}"
String pageTitle = element.getAttributeValue("pageTitle");
try {
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, pageTitle);
pageTitle = (String) expression.execute(arguments.getConfiguration(), arguments);
} catch (TemplateProcessingException e) {
// Do nothing.
}
((Map<String, Object>) arguments.getExpressionEvaluationRoot()).put("pageTitle", pageTitle);
((Map<String, Object>) arguments.getExpressionEvaluationRoot()).put("additionalCss", element.getAttributeValue("additionalCss"));
extensionManager.processAttributeValues(arguments, element);
//the commit at https://github.com/thymeleaf/thymeleaf/commit/b214d9b5660369c41538e023d4b8d7223ebcbc22 along with
//the referenced issue at https://github.com/thymeleaf/thymeleaf/issues/205
// return new FragmentAndTarget(HEAD_PARTIAL_PATH, WholeFragmentSpec.INSTANCE);
return new ArrayList<Node>();
}
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:30,代码来源:HeadProcessor.java
示例20: convertResultIntoDom
import org.thymeleaf.dom.Node; //导入依赖的package包/类
private HtmlElements convertResultIntoDom(final String path, final String htmlString) {
List<Node> nodes;
if(isFragment(htmlString)) {
nodes = parser.parseFragment(this.getConfiguration(), htmlString);
} else {
Document doc = parser.parseTemplate(this.getConfiguration(), path, new StringReader(htmlString));
nodes = doc.getChildren();
}
Element root = new Element("#document");
root.setChildren(nodes);
return new HtmlElements(root);
}
开发者ID:connect-group,项目名称:thymeleaf-tdd,代码行数:15,代码来源:ThymeleafTestEngine.java
注:本文中的org.thymeleaf.dom.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论