本文整理汇总了Java中org.jdom.filter.Filter类的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Filter类属于org.jdom.filter包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTypeContent
import org.jdom.filter.Filter; //导入依赖的package包/类
protected final org.jdom.Element findTypeContent(final String type, org.jdom.Element docRoot) {
@SuppressWarnings("unchecked")
List<org.jdom.Element> lst = docRoot.getContent(new Filter() {
@Override
public boolean matches(Object match) {
if (match instanceof org.jdom.Element) {
org.jdom.Element el = (org.jdom.Element)match;
if ("complexType".equals(el.getName()) && type.equals(el.getAttributeValue("name"))) { //NOI18N
return true;
}
}
return false;
}
});
if (lst.size() > 0) {
org.jdom.Element typeEl = lst.get(0);
return typeEl.getChild("all", docRoot.getNamespace()); //NOI18N
}
return null;
}
示例2: extractXMLelement
import org.jdom.filter.Filter; //导入依赖的package包/类
/**
* Extracts the contents of the named XML element from a parent
*
* @param parentElement The parent element
* @param theElement Name of the XML element to be extracted
* @return
* @throws IOException
* @throws JDOMException
*/
public static Element extractXMLelement(Element parentElement, String theElement) throws JDOMException, IOException {
Filter elementFilter = new ElementFilter();
List<Element> children = parentElement.getContent(elementFilter);
for (Element element : children) {
if (element.getName().equalsIgnoreCase(theElement)) {
return element;
}
Element child = extractXMLelement(element, theElement);
if (child != null) {
return child;
}
}
return null;
}
示例3: cleanTaggedValues
import org.jdom.filter.Filter; //导入依赖的package包/类
private static void cleanTaggedValues(StringBuffer xmiContents) throws IOException {
// filter for <UML:TaggedValue ../>
Filter taggedValueFilter = new Filter() {
public boolean matches(Object obj) {
if (obj instanceof Element) {
Element elem = (Element) obj;
if (elem.getName().equals("TaggedValue")) {
return elem.getAttribute("value") == null;
}
}
return false;
}
};
int removed = removeElementsByFilter(xmiContents, taggedValueFilter);
log.debug("Removed " + removed + " TaggedValue elements");
}
示例4: hasDocumentation
import org.jdom.filter.Filter; //导入依赖的package包/类
public boolean hasDocumentation() {
Filter filter = new DocumentationFilter();
Iterator docIt = element.getDescendants(filter);
if ( docIt.hasNext() ) {
return true;
} else {
return false;
}
}
示例5: getDocumentation
import org.jdom.filter.Filter; //导入依赖的package包/类
public Documentation getDocumentation () {
Filter filter = new DocumentationFilter();
Iterator docIt = element.getDescendants(filter);
Element documentation = (Element) docIt.next();
if ( documentation != null ) {
return new Documentation(documentation);
}
return null;
}
示例6: findProperty
import org.jdom.filter.Filter; //导入依赖的package包/类
public Element findProperty(Element group, String name) throws LASException {
Filter propertyFilter = new FindPropertyFilter(name);
Iterator propsIt = group.getDescendants(propertyFilter);
Element property=null;
if ( propsIt.hasNext() ) {
property = (Element) propsIt.next();
}
if ( propsIt.hasNext()) {
throw new LASException("More than one property with same name.");
}
return property;
}
示例7: findPropertyGroup
import org.jdom.filter.Filter; //导入依赖的package包/类
public Element findPropertyGroup(Element properties, String group) throws LASException {
// Finds properties below a particular element.
Filter propertyGroupFilter = new FindPropertyGroupFilter(group);
Iterator pgIt = properties.getDescendants(propertyGroupFilter);
Element propGroup = null;
if (pgIt.hasNext()) {
propGroup = (Element) pgIt.next();
}
// if ( pgIt.hasNext() ) {
// throw new LASException("More than one property group with name = "+group);
// }
// Just return the first...
return propGroup;
}
示例8: findPropertyGroupList
import org.jdom.filter.Filter; //导入依赖的package包/类
public ArrayList<Element> findPropertyGroupList(Element element, String group) {
ArrayList<Element> groups = new ArrayList<Element>();
Filter propertyGroupFilter = new FindPropertyGroupFilter(group);
for (Iterator pgIt = element.getDescendants(propertyGroupFilter); pgIt.hasNext(); ) {
groups.add((Element)pgIt.next());
}
return groups;
}
示例9: getCDATAExceptionStackTracesUnder
import org.jdom.filter.Filter; //导入依赖的package包/类
private List<CDATA> getCDATAExceptionStackTracesUnder(Element rootElement) {
Iterator it = rootElement.getDescendants(new Filter() {
public boolean matches(Object arg0) {
return arg0 instanceof CDATA;
}
});
List<CDATA> stackTraceElements = new ArrayList<CDATA>();
while (it.hasNext()) {
CDATA next = (CDATA) it.next();
stackTraceElements.add(next);
}
return stackTraceElements;
}
示例10: cleanUmlDiagrams
import org.jdom.filter.Filter; //导入依赖的package包/类
private static void cleanUmlDiagrams(StringBuffer xmiContents) throws IOException {
// filter for <UML:Diagram ../>
Filter diagramFilter = new Filter() {
public boolean matches(Object obj) {
if (obj instanceof Element) {
Element elem = (Element) obj;
return elem.getName().equals("Diagram");
}
return false;
}
};
int removed = removeElementsByFilter(xmiContents, diagramFilter);
log.debug("Removed " + removed + " Diagram elements");
}
示例11: checkDefaultPredicates
import org.jdom.filter.Filter; //导入依赖的package包/类
public static CQLQuery checkDefaultPredicates(CQLQuery original) throws Exception {
LOG.debug("Checking query for Attributes with no predicate defined");
StringWriter originalWriter = new StringWriter();
Utils.serializeObject(original, DataServiceConstants.CQL_QUERY_QNAME, originalWriter);
Element root = XMLUtilities.stringToDocument(originalWriter.getBuffer().toString()).getRootElement();
Filter attributeNoPredicateFilter = new Filter() {
public boolean matches(Object o) {
if (o instanceof Element) {
Element e = (Element) o;
if (e.getName().equals("Attribute") && e.getAttribute("predicate") == null) {
return true;
}
}
return false;
}
};
List<?> attributesWithNoPredicate = root.getContent(attributeNoPredicateFilter);
Iterator<?> attribIter = attributesWithNoPredicate.iterator();
while (attribIter.hasNext()) {
LOG.debug("Adding default predicate to an attribute");
Element elem = (Element) attribIter.next();
elem.setAttribute("predicate", "EQUAL_TO");
}
String xml = XMLUtilities.elementToString(root);
CQLQuery edited = Utils.deserializeObject(new StringReader(xml), CQLQuery.class);
return edited;
}
示例12: getContent
import org.jdom.filter.Filter; //导入依赖的package包/类
@Override
public <T extends Content> List<T> getContent(final Filter<T> filter) {
return (List<T>)ContainerUtil.filter(myContent, new Condition<Content>() {
@Override
public boolean value(Content content) {
return filter.matches(content);
}
});
}
示例13: addHttpsConnector
import org.jdom.filter.Filter; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "serial", "rawtypes" })
private void addHttpsConnector(String keyStorePassword,
File keyStoreLocation, Element serverElement) throws IOException,
ContainerException {
Iterator httpsConnectorElements = serverElement.getDescendants(new Filter() {
public boolean matches(Object o) {
if (o instanceof Element) {
Element e = (Element) o;
if (e.getName().equals("Connector")) {
if(e.getAttribute("schema")!=null && "https".equals(e.getAttribute("schema").getValue())){
return true;
}
}
}
return false;
}
});
// verify there is only one connector
if (!httpsConnectorElements.hasNext()) {
Element service=(Element)serverElement.getChildren("Service").get(0);
Element connector = new Element("Connector");
connector.setAttribute(new Attribute("acceptCount", "100"));
connector.setAttribute(new Attribute("clientAuth", "false"));
connector.setAttribute(new Attribute("debug", "0"));
connector.setAttribute(new Attribute("disableUploadTimeout", "true"));
connector.setAttribute(new Attribute("enableLookups", "false"));
connector.setAttribute(new Attribute("keystoreFile", keyStoreLocation.getCanonicalPath()));
connector.setAttribute(new Attribute("keystorePass", keyStorePassword));
connector.setAttribute(new Attribute("maxHttpHeaderSize", "8192"));
connector.setAttribute(new Attribute("maxSpareThreads", "75"));
connector.setAttribute(new Attribute("maxThreads", "150"));
connector.setAttribute(new Attribute("minSpareThreads", "25"));
connector.setAttribute(new Attribute("port", ""+httpsPortNumber));
connector.setAttribute(new Attribute("schema", "https"));
connector.setAttribute(new Attribute("secure", "true"));
connector.setAttribute(new Attribute("sslProtocol", "TLS"));
service.getChildren().add(connector);
}else{
throw new ContainerException("More than one HTTPS connector was found in the server configuration!");
}
}
示例14: startFixing
import org.jdom.filter.Filter; //导入依赖的package包/类
public void startFixing() {
List<File> classpathFiles = recursiveListFiles(new File(baseSearchDir),
new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().equals(".classpath");
}
});
for (File f : classpathFiles) {
if (f.isFile()) {
System.out.println("Working on " + f.getAbsolutePath());
try {
Document doc = fileToDocument(f);
List libElements = doc.getRootElement().getContent(new Filter() {
public boolean matches(Object o) {
if (o instanceof Element) {
Element e = (Element) o;
if (e.getName().equals("classpathentry") &&
"lib".equals(e.getAttributeValue("kind"))) {
return true;
}
}
return false;
}
});
Iterator libElemIter = libElements.iterator();
while (libElemIter.hasNext()) {
Element entryElem = (Element) libElemIter.next();
File projectBase = f.getParentFile();
String libPath = entryElem.getAttributeValue("path");
File libFile = new File(projectBase, libPath);
String libName = libFile.getName();
if (libName.startsWith("caGrid-") && libName.endsWith("-1.6-dev.jar")) {
System.out.println("Found a library to fix up (" + libPath + ")");
int endIndex = libPath.lastIndexOf("-1.6-dev.jar");
libPath = libPath.substring(0, endIndex);
libPath += "-1.4.jar";
System.out.println("\tFixed up to " + libPath);
entryElem.setAttribute("path", libPath);
}
}
saveDocument(doc, f);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
示例15: getDescendants
import org.jdom.filter.Filter; //导入依赖的package包/类
@Override
public <T extends Content> Iterator<T> getDescendants(Filter<T> filter) {
throw immutableError(this);
}