summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/gnu/xml/xpath/UnionExpr.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/xml/xpath/UnionExpr.java')
-rw-r--r--libjava/classpath/gnu/xml/xpath/UnionExpr.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/libjava/classpath/gnu/xml/xpath/UnionExpr.java b/libjava/classpath/gnu/xml/xpath/UnionExpr.java
index 5078713b693..03ae5c06d70 100644
--- a/libjava/classpath/gnu/xml/xpath/UnionExpr.java
+++ b/libjava/classpath/gnu/xml/xpath/UnionExpr.java
@@ -74,20 +74,29 @@ public final class UnionExpr
return false;
}
+ @Override
public Object evaluate(Node context, int pos, int len)
{
Object left = lhs.evaluate(context, pos, len);
Object right = rhs.evaluate(context, pos, len);
+ List<Node> list;
if (left instanceof Collection && right instanceof Collection)
{
- Set set = new HashSet();
- set.addAll ((Collection) left);
- set.addAll ((Collection) right);
- List list = new ArrayList(set);
+ Set<Node> set = new HashSet<Node>();
+ /* Suppression is safe as addAll will check the types
+ of the elements and throw a ClassCastException as necessary */
+ @SuppressWarnings("unchecked")
+ Collection<Node> l = (Collection<Node>) left;
+ @SuppressWarnings("unchecked")
+ Collection<Node> r = (Collection<Node>) right;
+ set.addAll (l);
+ set.addAll (r);
+ list = new ArrayList<Node>(set);
Collections.sort(list, documentOrderComparator);
- return list;
}
- return Collections.EMPTY_SET;
+ else
+ list = Collections.emptyList();
+ return list;
}
public Expr clone(Object context)
OpenPOWER on IntegriCloud