OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 83 Rev 180
Line 150... Line 150...
150
 
150
 
151
        }
151
        }
152
        return this.lastItem.nextNodes(currentNodes);
152
        return this.lastItem.nextNodes(currentNodes);
153
    }
153
    }
154
 
154
 
-
 
155
    public final List<String> selectValues(final Object n) {
-
 
156
        return this.selectValues(Collections.singletonList(n));
-
 
157
    }
-
 
158
 
-
 
159
    /**
-
 
160
     * Return the string-value properties of the selected nodes.
-
 
161
     * 
-
 
162
     * @param nodes the context.
-
 
163
     * @return the string values.
-
 
164
     * @see <a href="https://www.w3.org/TR/xpath-datamodel/#dm-string-value">string-value</a>
-
 
165
     */
-
 
166
    public final List<String> selectValues(final List<?> nodes) {
-
 
167
        final List<T> lastNodes = this.selectNodes(nodes);
-
 
168
        return this.lastItem.getValues(lastNodes);
-
 
169
    }
-
 
170
 
155
    // encapsulate differences about JDOM nodes
171
    // encapsulate differences about JDOM nodes
156
    static abstract class Node<T> {
172
    static abstract class Node<T> {
157
 
173
 
158
        static final Node<Element> elem = new ElementNode();
174
        static final Node<Element> elem = new ElementNode();
159
        static final Node<Attribute> attr = new AttributeNode();
175
        static final Node<Attribute> attr = new AttributeNode();
Line 181... Line 197...
181
        public abstract <S> void nextNodes(final List<S> res, final T node, final Step<S> step);
197
        public abstract <S> void nextNodes(final List<S> res, final T node, final Step<S> step);
182
 
198
 
183
        // viva jdom who doesn't have a common interface for getName() and getNS()
199
        // viva jdom who doesn't have a common interface for getName() and getNS()
184
        abstract T filter(final T elem, final String name, final String ns);
200
        abstract T filter(final T elem, final String name, final String ns);
185
 
201
 
-
 
202
        // Returns the XPath 1.0 string value of the passed node
-
 
203
        protected abstract String getValue(T n);
-
 
204
 
186
        @Override
205
        @Override
187
        public final String toString() {
206
        public final String toString() {
188
            return this.getClass().getSimpleName();
207
            return this.getClass().getSimpleName();
189
        }
208
        }
190
    }
209
    }
Line 207... Line 226...
207
                return null;
226
                return null;
208
            if (ns != null && !ns.equals(elem.getNamespacePrefix()))
227
            if (ns != null && !ns.equals(elem.getNamespacePrefix()))
209
                return null;
228
                return null;
210
            return elem;
229
            return elem;
211
        }
230
        }
-
 
231
 
-
 
232
        @Override
-
 
233
        protected String getValue(Attribute n) {
-
 
234
            return n.getValue();
-
 
235
        }
212
    }
236
    }
213
 
237
 
214
    static class ElementNode extends Node<Element> {
238
    static class ElementNode extends Node<Element> {
215
 
239
 
216
        @SuppressWarnings("unchecked")
240
        @SuppressWarnings("unchecked")
Line 255... Line 279...
255
                return null;
279
                return null;
256
            if (ns != null && !ns.equals(elem.getNamespacePrefix()))
280
            if (ns != null && !ns.equals(elem.getNamespacePrefix()))
257
                return null;
281
                return null;
258
            return elem;
282
            return elem;
259
        }
283
        }
-
 
284
 
-
 
285
        @Override
-
 
286
        protected String getValue(Element n) {
-
 
287
            return n.getValue();
-
 
288
        }
260
    }
289
    }
261
}
290
}