public void validate(Element element, ConfigElementImplementationRegistry registry) throws Exception { XPathFactory xPathFactory = XPathFactory.instance(); List<String> tasks = ConfigUtil.allTasks(registry); for (String task : tasks) { List<Element> taskNodes = xPathFactory.compile("//" + task, Filters.element()).evaluate(element); for (Element taskNode : taskNodes) { List<Element> list = xPathFactory.compile("oncancel", Filters.element()).evaluate(taskNode); if (list.size() > 1) { throw new Exception("Task [" + task + "] should not contain more than 1 oncancel task"); } } } } }
/** * Set filtering mask. * * @param mask the new filtering mask */ public void setFilterMask(int mask) { setDefaultMask(); filterMask &= mask; }
/** * Filter out JDOM objects according to a filtering mask. * * @param mask Mask of JDOM objects to allow. */ public ContentFilter(int mask) { setFilterMask(mask); }
/** * Return a Filter that matches any {@link Element} data with the specified * name and Namespace. * * @param name The name of Elements to match. * @param ns The Namespace to match * @return a Filter that matches any {@link Element} data with the specified * name and Namespace. */ public static final Filter<Element> element(String name, Namespace ns) { return new ElementFilter(name, ns); }
/** * Return a Filter that matches any {@link Attribute} data with the * specified name. * * @param name The name for all the Attributes to have (these can be in any * Namespace). * @return a Filter that matches any {@link Attribute} data with the * specified name. */ public static final Filter<Attribute> attribute(String name) { return new AttributeFilter(name); }
@Override public final Filter<?> negate() { if (this instanceof NegateFilter) { return ((NegateFilter)this).getBaseFilter(); } return new NegateFilter(this); }
@Override public <R> Filter<R> refine(Filter<R> filter) { return new AndFilter<R>(this, filter); } }
@Override public Object filter(Object content) { if (filter.matches(content)) { return null; } return content; }
@Override public final boolean matches(Object content) { return filter(content) != null; }
/** * Return a Filter that matches any data of the specified Class. * * @param <F> The generic type of the content returned by this Filter * @param clazz the Class type to match in the filter * @return a Filter that matches any data of the specified Class. */ public static final <F> Filter<F> fclass(Class<F> clazz) { return new ClassFilter<F>(clazz); }
XPathFactory xPathFactory = XPathFactory.instance(); for (String attributeName : encryptedAttributes) { XPathExpression<Element> xpathExpression = xPathFactory.compile(String.format("//*[@%s]", attributeName), Filters.element()); List<Element> encryptedPasswordElements = xpathExpression.evaluate(document); for (Element element : encryptedPasswordElements) { XPathExpression<Element> xpathExpression = xPathFactory.compile(String.format("//%s", nodeName), Filters.element()); List<Element> encryptedNode = xpathExpression.evaluate(document); for (Element element : encryptedNode) {
/** * Return a Filter that matches any {@link Element} data with the specified * name. * * @param name The name of Elements to match. * @return a Filter that matches any {@link Element} data with the specified * name. */ public static final Filter<Element> element(String name) { return new ElementFilter(name, Namespace.NO_NAMESPACE); }
/** * Return a Filter that matches any {@link Attribute} data with the * specified name and namespace. * * @param name The name for all the Attributes to have. * @param ns The Namespace for all the Attributes to have. * @return a Filter that matches any {@link Attribute} data with the * specified name and namespace. */ public static final Filter<Attribute> attribute(String name, Namespace ns) { return new AttributeFilter(name, ns); }
/** * Default constructor that allows any legal JDOM objects. */ public ContentFilter() { setDefaultMask(); }
@Override public final Filter<T> and(Filter<?> filter) { return new AndFilter<T>(filter, this); }
/** * Return a Filter that matches any {@link Element} data with the specified * Namespace. * * @param ns The Namespace to match * @return a Filter that matches any {@link Element} data with the specified * Namespace. */ public static final Filter<Element> element(Namespace ns) { return new ElementFilter(null, ns); }
/** * Return a Filter that matches any {@link Attribute} data with the * specified namespace. * * @param ns The Namespace for all the Attributes to have. * @return a Filter that matches any {@link Attribute} data with the * specified namespace. */ public static final Filter<Attribute> attribute(Namespace ns) { return new AttributeFilter(ns); }
/** * Set whether all JDOM objects are visible or not. * * @param allVisible <code>true</code> all JDOM objects are visible, * <code>false</code> all JDOM objects are hidden. */ public ContentFilter(boolean allVisible) { if (allVisible) { setDefaultMask(); } else { filterMask &= ~filterMask; } }