OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 73 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73 Rev 83
Line 35... Line 35...
35
 * 
35
 * 
36
 * @param <T> type of result.
36
 * @param <T> type of result.
37
 */
37
 */
38
public final class SimpleXMLPath<T> {
38
public final class SimpleXMLPath<T> {
39
 
39
 
-
 
40
    private static final SimpleXMLPath<Attribute> ALL_ATTRIBUTES = allAttributes(null, null);
-
 
41
    private static final SimpleXMLPath<Element> ALL_ELEMENTS = allElements(null, null);
-
 
42
 
40
    public static <T> SimpleXMLPath<T> create(final List<Step<?>> steps, final Step<T> lastStep) {
43
    public static <T> SimpleXMLPath<T> create(final List<Step<?>> steps, final Step<T> lastStep) {
41
        return new SimpleXMLPath<T>(Collections.unmodifiableList(new ArrayList<Step<?>>(steps)), lastStep);
44
        return new SimpleXMLPath<T>(Collections.unmodifiableList(new ArrayList<Step<?>>(steps)), lastStep);
42
    }
45
    }
43
 
46
 
44
    public static <T> SimpleXMLPath<T> create(final Step<T> lastStep) {
47
    public static <T> SimpleXMLPath<T> create(final Step<T> lastStep) {
Line 52... Line 55...
52
    public static <T> SimpleXMLPath<T> create(final Step<?> first, final Step<?> second, final Step<T> lastStep) {
55
    public static <T> SimpleXMLPath<T> create(final Step<?> first, final Step<?> second, final Step<T> lastStep) {
53
        return new SimpleXMLPath<T>(Arrays.<Step<?>> asList(first, second), lastStep);
56
        return new SimpleXMLPath<T>(Arrays.<Step<?>> asList(first, second), lastStep);
54
    }
57
    }
55
 
58
 
56
    /**
59
    /**
-
 
60
     * Create a path searching for all descendant attributes. The returned instance is immutable.
-
 
61
     * 
-
 
62
     * @return a path searching attributes in all {@link Axis#descendantOrSelf} elements.
-
 
63
     */
-
 
64
    public static SimpleXMLPath<Attribute> allAttributes() {
-
 
65
        return ALL_ATTRIBUTES;
-
 
66
    }
-
 
67
 
-
 
68
    /**
57
     * Create a path searching for all descendant attributes with the passed name and namespace.
69
     * Create a path searching for all descendant attributes with the passed name and namespace.
58
     * I.e. in XPath this would be ".//@ns:name".
70
     * I.e. in XPath this would be ".//@ns:name". The returned instance is immutable.
59
     * 
71
     * 
60
     * @param name the name of attributes.
72
     * @param name the name of attributes.
61
     * @param ns the namespace of attributes.
73
     * @param ns the namespace of attributes.
62
     * @return a path searching attributes in all {@link Axis#descendantOrSelf} elements.
74
     * @return a path searching attributes in all {@link Axis#descendantOrSelf} elements.
63
     */
75
     */
64
    public static SimpleXMLPath<Attribute> allAttributes(final String name, final String ns) {
76
    public static SimpleXMLPath<Attribute> allAttributes(final String name, final String ns) {
65
        return create(Step.createElementStep(Axis.descendantOrSelf, null), Step.createAttributeStep(name, ns));
77
        return create(Step.createElementStep(Axis.descendantOrSelf, null), Step.createAttributeStep(name, ns));
66
    }
78
    }
67
 
79
 
68
    /**
80
    /**
-
 
81
     * Create a path searching for all descendant elements. The returned instance is immutable.
-
 
82
     * 
-
 
83
     * @return a path searching all {@link Axis#descendantOrSelf} elements.
-
 
84
     */
-
 
85
    public static SimpleXMLPath<Element> allElements() {
-
 
86
        return ALL_ELEMENTS;
-
 
87
    }
-
 
88
 
-
 
89
    /**
69
     * Create a path searching for all descendant elements with the passed name and namespace. I.e.
90
     * Create a path searching for all descendant elements with the passed name and namespace. I.e.
70
     * in XPath this would be ".//ns:name".
91
     * in XPath this would be ".//ns:name". The returned instance is immutable.
71
     * 
92
     * 
72
     * @param name the name of elements.
93
     * @param name the name of elements.
73
     * @param ns the namespace of elements.
94
     * @param ns the namespace of elements.
74
     * @return a path searching all {@link Axis#descendantOrSelf} elements.
95
     * @return a path searching all {@link Axis#descendantOrSelf} elements.
75
     */
96
     */