org.jdom.filter.Filter Java Examples

The following examples show how to use org.jdom.filter.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSchemaBasedGrammar.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: ImmutableElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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);
    }
  });
}
 
Example #3
Source File: ImmutableElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Content> org.jdom.util.IteratorIterable<T> getDescendants(Filter<T> filter) {
  throw immutableError(this);
}
 
Example #4
Source File: ImmutableElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Content> List<T> removeContent(Filter<T> filter) {
  throw immutableError(this);
}
 
Example #5
Source File: Parent.java    From jclic with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns as a {@link java.util.List} the content of
 * this parent that matches the supplied filter. The returned list is
 * <b>"live"</b> and in document order. Any modifications to it affect
 * the element's actual contents. Modifications are checked for
 * conformance to XML 1.0 rules.
 * <p>
 * Sequential traversal through the List is best done with an Iterator
 * since the underlying implement of {@link java.util.List#size} may
 * require walking the entire list and indexed lookups may require
 * starting at the beginning each time.
 *
 * @param  filter filter to apply
 * @return a list of the content of the parent matching the filter
 * @throws IllegalStateException if parent is a Document
 *         and the root element is not set
 */
List getContent(Filter filter);
 
Example #6
Source File: Parent.java    From jclic with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes from this parent all child content matching the given filter
 * and returns a list of the detached children.
 *
 * @param  filter filter to apply
 * @return list of the detached children matching the filter
 */
List removeContent(Filter filter);
 
Example #7
Source File: Parent.java    From jclic with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an {@link java.util.Iterator} that walks over all descendants
 * in document order applying the Filter to return only elements that
 * match the filter rule.  With filters you can match only Elements,
 * only Comments, Elements or Comments, only Elements with a given name
 * and/or prefix, and so on.
 *
 * @param filter filter to select which descendants to see
 * @return an iterator to walk descendants that match a filter
 */
Iterator getDescendants(Filter filter);