本文整理了Java中org.joox.Match.filter()
方法的一些代码示例,展示了Match.filter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Match.filter()
方法的具体详情如下:
包路径:org.joox.Match
类名称:Match
方法名:filter
[英]Reduce the current set of matched elements.
The selector provided to this method supports the following features:
tag names can be used to select XML elements by tag names (see Element#getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
The following features are not supported:
CSS selectors cannot be used (yet) to select XML elements from this method. Use #find(String) instead
XPath cannot be used. Use #xpath(String)instead
Namespaces cannot be used. Use #xpath(String) with #namespaces(Map) instead
[中]减少匹配元素的当前集合。
为此方法提供的选择器支持以下功能:
**可用于选择所有内容
*标记名可用于按标记名选择XML元素(请参见元素#getElementsByTagName(字符串))。标记名不知道名称空间。这意味着现有的名称空间将被忽略
不支持以下功能:
*CSS选择器还不能用来从这个方法中选择XML元素。改用#查找(字符串)
*无法使用XPath。改用#xpath(字符串)
*不能使用名称空间。将#xpath(字符串)与#名称空间(映射)一起使用
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private Iterable<Element> findLocalBeanById(Document doc, String id)
{
List<Element> elements = new LinkedList<>();
elements.addAll($(doc).children().filter(attr("id", id)).get());
if (elements.isEmpty())
{
elements.addAll($(doc).children().filter(attr("name", id)).get());
}
return elements;
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void fixAutoclosingElements(Document domDocument) {
try {
Match document = JOOX.$(domDocument);
Match lists = document.xpath(autoclosingElements).filter(new Filter() {
@Override
public boolean filter(Context context) {
return (context.element().getFirstChild() == null); // with no child element (so autoclosing)
}
});
for (org.w3c.dom.Element element : lists) {
if ("script".equals(element.getNodeName())) {
element.appendChild(document.document().createTextNode("// preserve auto-closing elements"));
} else {
element.appendChild(document.document().createComment("preserve auto-closing elements"));
}
}
} catch (Exception e) {
// nothing to do
}
}
代码示例来源:origin: windup/windup
private Iterable<Element> findLocalBeanById(Document doc, String id)
{
List<Element> elements = new LinkedList<>();
elements.addAll($(doc).children().filter(attr("id", id)).get());
if (elements.isEmpty())
{
elements.addAll($(doc).children().filter(attr("name", id)).get());
}
return elements;
}
代码示例来源:origin: windup/windup
private Map<String, String> extractProperties(Document doc, Element bean)
{
Map<String, String> properties = new HashMap<>();
for (Element p : $(bean).children("property").filter(attr("name", "hibernateProperties", "jpaProperties", "jpaPropertyMap")).get())
{
// first, check to see if it uses a ref attribute...
String propertyRef = $(p).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element ref : findLocalBeanById(doc, propertyRef))
{
properties.putAll(readProperties(ref));
}
}
else
{
properties.putAll(readProperties(p));
}
}
return properties;
}
代码示例来源:origin: windup/windup
private String extractJndiRefBeanName(Element bean)
{
for (Element dataSource : $(bean).children("property").filter(attr("name", "dataSource")).get())
{
// read ref...
String jndiRef = $(dataSource).attr("ref");
if (StringUtils.isBlank(jndiRef))
{
LOG.info("Looking at ref child of property tag...");
//look to see if the ref is a child of the property tag...
jndiRef = $(dataSource).child("ref").attr("bean");
}
if(StringUtils.isNotBlank(jndiRef)) {
return jndiRef;
}
}
return null;
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private Map<String, String> extractProperties(Document doc, Element bean)
{
Map<String, String> properties = new HashMap<>();
for (Element p : $(bean).children("property").filter(attr("name", "hibernateProperties", "jpaProperties", "jpaPropertyMap")).get())
{
// first, check to see if it uses a ref attribute...
String propertyRef = $(p).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element ref : findLocalBeanById(doc, propertyRef))
{
properties.putAll(readProperties(ref));
}
}
else
{
properties.putAll(readProperties(p));
}
}
return properties;
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private Map<String, String> extractHibernateJpaVendorJpaProperties(Document doc, Element bean)
{
Map<String, String> properties = new HashMap<>();
for (Element jpaVendorAdapterProperty : $(bean).children("property").filter(attr("name", "jpaVendorAdapter")).get())
{
String propertyRef = $(jpaVendorAdapterProperty).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element jpaVendorAdapter : findLocalBeanById(doc, propertyRef))
{
properties = extractProperties(doc, jpaVendorAdapter);
// read the hibernate dialect
for (Element p : $(jpaVendorAdapter).children("property").filter(attr("name", "databasePlatform")).get())
{
String dialect = $(p).attr("value");
if (StringUtils.isNotBlank(dialect))
{
if (!properties.containsKey("hibernate.dialect"))
{
properties.put("hibernate.dialect", dialect);
}
}
}
}
}
}
return properties;
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private String extractJndiRefBeanName(Element bean)
{
for (Element dataSource : $(bean).children("property").filter(attr("name", "dataSource")).get())
{
// read ref...
String jndiRef = $(dataSource).attr("ref");
if (StringUtils.isBlank(jndiRef))
{
LOG.info("Looking at ref child of property tag...");
//look to see if the ref is a child of the property tag...
jndiRef = $(dataSource).child("ref").attr("bean");
}
if(StringUtils.isNotBlank(jndiRef)) {
return jndiRef;
}
}
return null;
}
代码示例来源:origin: windup/windup
private Map<String, String> extractHibernateJpaVendorJpaProperties(Document doc, Element bean)
{
Map<String, String> properties = new HashMap<>();
for (Element jpaVendorAdapterProperty : $(bean).children("property").filter(attr("name", "jpaVendorAdapter")).get())
{
String propertyRef = $(jpaVendorAdapterProperty).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element jpaVendorAdapter : findLocalBeanById(doc, propertyRef))
{
properties = extractProperties(doc, jpaVendorAdapter);
// read the hibernate dialect
for (Element p : $(jpaVendorAdapter).children("property").filter(attr("name", "databasePlatform")).get())
{
String dialect = $(p).attr("value");
if (StringUtils.isNotBlank(dialect))
{
if (!properties.containsKey("hibernate.dialect"))
{
properties.put("hibernate.dialect", dialect);
}
}
}
}
}
}
return properties;
}
代码示例来源:origin: windup/windup
private String extractHibernateJpaVendorDatabase(Document doc, Element bean)
{
for (Element jpaVendorAdapterProperty : $(bean).children("property").filter(attr("name", "jpaVendorAdapter")).get())
{
String propertyRef = $(jpaVendorAdapterProperty).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element jpaVendorAdapter : findLocalBeanById(doc, propertyRef))
{
// check attribute on element
String propAttrValue = $(jpaVendorAdapter).attr("database");
if (StringUtils.isNotBlank(propAttrValue))
{
return propAttrValue;
}
// now look for the property "dataSource" off of that bean.
for (Element p : $(jpaVendorAdapter).children("property").filter(attr("name", "database")).get())
{
String value = $(p).attr("value");
if (StringUtils.isNotBlank(value))
{
return value;
}
}
}
}
}
return null;
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private String extractHibernateJpaVendorDatabase(Document doc, Element bean)
{
for (Element jpaVendorAdapterProperty : $(bean).children("property").filter(attr("name", "jpaVendorAdapter")).get())
{
String propertyRef = $(jpaVendorAdapterProperty).attr("ref");
if (StringUtils.isNotBlank(propertyRef))
{
// look for the properties referenced by a local bean..
for (Element jpaVendorAdapter : findLocalBeanById(doc, propertyRef))
{
// check attribute on element
String propAttrValue = $(jpaVendorAdapter).attr("database");
if (StringUtils.isNotBlank(propAttrValue))
{
return propAttrValue;
}
// now look for the property "dataSource" off of that bean.
for (Element p : $(jpaVendorAdapter).children("property").filter(attr("name", "database")).get())
{
String value = $(p).attr("value");
if (StringUtils.isNotBlank(value))
{
return value;
}
}
}
}
}
return null;
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
for (Element bean : $(doc).find("bean").filter(springid(payload.getSpringBeanName())))
代码示例来源:origin: windup/windup
for (Element bean : $(doc).find("bean").filter(springid(payload.getSpringBeanName())))
代码示例来源:origin: windup/windup
String expectedType = $(bean).children("property").filter(attr("name", "expectedType")).first().attr("value");
String jndiName = $(bean).children("property").filter(attr("name", "jndiName")).first().attr("value");
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
String expectedType = $(bean).children("property").filter(attr("name", "expectedType")).first().attr("value");
String jndiName = $(bean).children("property").filter(attr("name", "jndiName")).first().attr("value");
内容来源于网络,如有侵权,请联系作者删除!