jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1166240 [2/2] - in /jackrabbit/sandbox/jackrabbit-mk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-jcr2spi/src/main/java/org/a...
Date Wed, 07 Sep 2011 15:54:45 GMT
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceExtractor.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceExtractor.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceExtractor.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceExtractor.java
Wed Sep  7 15:54:44 2011
@@ -45,7 +45,7 @@ public class NamespaceExtractor {
     private static final Logger log = LoggerFactory.getLogger(NamespaceExtractor.class);
 
     private final NamespaceMapping mapping = new NamespaceMapping();
-    private final Map basePrefixes = new HashMap();
+    private final Map<String, Integer> basePrefixes = new HashMap<String, Integer>();
     private final String defaultBasePrefix;
 
     /**
@@ -94,7 +94,7 @@ public class NamespaceExtractor {
                 // if prefix already used
                 if (mapping.hasPrefix(prefix)){
                     int c;
-                    Integer co = (Integer) basePrefixes.get(prefix);
+                    Integer co = basePrefixes.get(prefix);
                     if (co == null) {
                         basePrefixes.put(prefix, 1);
                         c = 1;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
Wed Sep  7 15:54:44 2011
@@ -350,8 +350,8 @@ public class NodeTypeDefDiff {
 
     private static String toString(List<? extends ChildItemDefDiff> childItemDefDiffs)
{
         StringBuilder sb = new StringBuilder();
-        for (Iterator diffs = childItemDefDiffs.iterator(); diffs.hasNext();) {
-            ChildItemDefDiff propDefDiff = (ChildItemDefDiff) diffs.next();
+        for (Iterator<? extends ChildItemDefDiff> diffs = childItemDefDiffs.iterator();
diffs.hasNext();) {
+            ChildItemDefDiff propDefDiff = diffs.next();
             sb.append("\t\t").append(propDefDiff);
             if (diffs.hasNext()) {
                 sb.append(',');

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java
Wed Sep  7 15:54:44 2011
@@ -93,14 +93,14 @@ public class NodeTypeTemplateImpl implem
 
         NodeDefinition[] nodeDefs = def.getDeclaredChildNodeDefinitions();
         if (nodeDefs != null) {
-            List list = getNodeDefinitionTemplates();
+            List<NodeDefinitionTemplate> list = getNodeDefinitionTemplates();
             for (NodeDefinition nodeDef : nodeDefs) {
                 list.add(new NodeDefinitionTemplateImpl(nodeDef, resolver));
             }
         }
         PropertyDefinition[] propDefs = def.getDeclaredPropertyDefinitions();
         if (propDefs != null) {
-            List list = getPropertyDefinitionTemplates();
+            List<PropertyDefinitionTemplate> list = getPropertyDefinitionTemplates();
             for (PropertyDefinition propDef : propDefs) {
                 list.add(new PropertyDefinitionTemplateImpl(propDef, resolver));
             }
@@ -164,7 +164,7 @@ public class NodeTypeTemplateImpl implem
     }
 
     @Override
-    public final List getPropertyDefinitionTemplates() {
+    public final List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates()
{
         if (propertyDefinitionTemplates == null) {
             propertyDefinitionTemplates = new LinkedList<PropertyDefinitionTemplate>();
         }
@@ -172,7 +172,7 @@ public class NodeTypeTemplateImpl implem
     }
 
     @Override
-    public final List getNodeDefinitionTemplates() {
+    public final List<NodeDefinitionTemplate> getNodeDefinitionTemplates() {
         if (nodeDefinitionTemplates == null) {
             nodeDefinitionTemplates = new LinkedList<NodeDefinitionTemplate>();
         }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java
Wed Sep  7 15:54:44 2011
@@ -87,7 +87,7 @@ public abstract class NAryQueryNode<T ex
             return false;
         }
         // JCR-1650 search the operand without relying on Object#equals(Object)
-        Iterator it = operands.iterator();
+        Iterator<T> it = operands.iterator();
         while (it.hasNext()) {
             if (it.next() == operand) {
                 it.remove();
@@ -152,7 +152,7 @@ public abstract class NAryQueryNode<T ex
      */
     public boolean equals(Object obj) {
         if (obj instanceof NAryQueryNode) {
-            NAryQueryNode other = (NAryQueryNode) obj;
+            NAryQueryNode<?> other = (NAryQueryNode<?>) obj;
             return operands == null ? other.operands == null : operands.equals(other.operands);
         }
         return false;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PropertyFunctionQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PropertyFunctionQueryNode.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PropertyFunctionQueryNode.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PropertyFunctionQueryNode.java
Wed Sep  7 15:54:44 2011
@@ -46,10 +46,10 @@ public class PropertyFunctionQueryNode e
     /**
      * The set of supported function names.
      */
-    private static final Set SUPPORTED_FUNCTION_NAMES;
+    private static final Set<String> SUPPORTED_FUNCTION_NAMES;
 
     static {
-        Set tmp = new HashSet();
+        Set<String> tmp = new HashSet<String>();
         tmp.add(UPPER_CASE);
         tmp.add(LOWER_CASE);
         SUPPORTED_FUNCTION_NAMES = Collections.unmodifiableSet(tmp);
@@ -71,8 +71,7 @@ public class PropertyFunctionQueryNode e
      * @throws IllegalArgumentException if {@code functionName} is not a
      *                                  supported function.
      */
-    protected PropertyFunctionQueryNode(QueryNode parent, String functionName)
-            throws IllegalArgumentException {
+    protected PropertyFunctionQueryNode(QueryNode parent, String functionName) throws IllegalArgumentException
{
         super(parent);
         if (!SUPPORTED_FUNCTION_NAMES.contains(functionName)) {
             throw new IllegalArgumentException("unknown function name");

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryConstants.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryConstants.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryConstants.java
Wed Sep  7 15:54:44 2011
@@ -303,10 +303,10 @@ public interface QueryConstants {
      * Operation names
      */
     ConstantNameProvider OPERATION_NAMES = new ConstantNameProvider() {
-        private final Map operationNames;
+        private final Map<Integer, String> operationNames;
 
         {
-            Map map = new HashMap();
+            Map<Integer, String> map = new HashMap<Integer, String>();
             map.put(OPERATION_BETWEEN, OP_NAME_BETWEEN);
             map.put(OPERATION_EQ_VALUE, OP_NAME_EQ_VALUE);
             map.put(OPERATION_EQ_GENERAL, OP_NAME_EQ_GENERAL);
@@ -331,7 +331,7 @@ public interface QueryConstants {
 
         @Override
         public String getName(int constant) {
-            String name = (String) operationNames.get(constant);
+            String name = operationNames.get(constant);
             return name == null? OP_NAME_UNKNOWN : name;
         }
     };
@@ -340,10 +340,9 @@ public interface QueryConstants {
      * Type names
      */
     ConstantNameProvider TYPE_NAMES = new ConstantNameProvider() {
-        private final Map typeNames;
-
+        private final Map<Integer, String> typeNames;
         {
-            Map map = new HashMap();
+            Map<Integer, String> map = new HashMap<Integer, String>();
             map.put(TYPE_DATE, TYPE_NAME_DATE);
             map.put(TYPE_DOUBLE, TYPE_NAME_DOUBLE);
             map.put(TYPE_LONG, TYPE_NAME_LONG);
@@ -355,7 +354,7 @@ public interface QueryConstants {
 
         @Override
         public String getName(int constant) {
-            String name = (String) typeNames.get(constant);
+            String name = typeNames.get(constant);
             return name == null? TYPE_NAME_UNKNOWN : name;
         }
     };

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryRootNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryRootNode.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryRootNode.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryRootNode.java
Wed Sep  7 15:54:44 2011
@@ -36,7 +36,7 @@ public class QueryRootNode extends Query
      * The list of property names (as {@link org.apache.jackrabbit.spi.Name}s
      * to select.
      */
-    private final List selectProperties = new ArrayList();
+    private final List<Name> selectProperties = new ArrayList<Name>();
 
     /**
      * The list of property names to order the result nodes. Might be null
@@ -85,7 +85,7 @@ public class QueryRootNode extends Query
      * @return an array of select properties.
      */
     public Name[] getSelectProperties() {
-        return (Name[]) selectProperties.toArray(new Name[selectProperties.size()]);
+        return selectProperties.toArray(new Name[selectProperties.size()]);
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeBuilderRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeBuilderRegistry.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeBuilderRegistry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeBuilderRegistry.java
Wed Sep  7 15:54:44 2011
@@ -42,23 +42,23 @@ public final class QueryTreeBuilderRegis
     /**
      * List of {@code QueryTreeBuilder} instances known to the classloader.
      */
-    private static final List BUILDERS = new ArrayList();
+    private static final List<QueryTreeBuilder> BUILDERS = new ArrayList<QueryTreeBuilder>();
 
     /**
      * Set of languages known to the registered builders.
      */
-    private static final Set LANGUAGES;
+    private static final Set<String> LANGUAGES;
 
     private QueryTreeBuilderRegistry() {
     }
 
     static {
-        Set languages = new HashSet();
+        Set<String> languages = new HashSet<String>();
         try {
-            Iterator it = ServiceRegistry.lookupProviders(QueryTreeBuilder.class,
+            Iterator<QueryTreeBuilder> it = ServiceRegistry.lookupProviders(QueryTreeBuilder.class,
                     QueryTreeBuilderRegistry.class.getClassLoader());
             while (it.hasNext()) {
-                QueryTreeBuilder qtb = (QueryTreeBuilder) it.next();
+                QueryTreeBuilder qtb = it.next();
                 BUILDERS.add(qtb);
                 languages.addAll(Arrays.asList(qtb.getSupportedLanguages()));
             }
@@ -94,6 +94,6 @@ public final class QueryTreeBuilderRegis
      * @return String array containing the names of the supported languages.
      */
     public static String[] getSupportedLanguages() {
-        return (String[]) LANGUAGES.toArray(new String[LANGUAGES.size()]);
+        return LANGUAGES.toArray(new String[LANGUAGES.size()]);
     }
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java
Wed Sep  7 15:54:44 2011
@@ -53,7 +53,7 @@ public class QueryObjectModelTree extend
     /**
      * All selectors available in this query object model. Key=Name
      */
-    private final Map selectors = new HashMap();
+    private final Map<Name, SelectorImpl> selectors = new HashMap<Name, SelectorImpl>();
 
     public QueryObjectModelTree(NamePathResolver resolver,
                                 SourceImpl source,
@@ -127,7 +127,7 @@ public class QueryObjectModelTree extend
      * @return the selector or {@code null} if there is no such selector.
      */
     public SelectorImpl getSelector(Name name) {
-        return (SelectorImpl) selectors.get(name);
+        return selectors.get(name);
     }
 
     //-----------------------< AbstractQOMNode >--------------------------------

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
Wed Sep  7 15:54:44 2011
@@ -58,6 +58,8 @@ import java.util.NoSuchElementException;
 import java.util.Map;
 import java.io.StringReader;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * Implements the query builder for the JCR SQL syntax.
  */
@@ -77,7 +79,8 @@ public class JCRSQLQueryBuilder implemen
     /**
      * Map of reusable JCRSQL parser instances indexed by NamespaceResolver.
      */
-    private static final Map parsers = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
+    private static final Map<NameResolver, JCRSQLParser> parsers =
+            cast(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
     /**
      * The root node of the sql query syntax tree
@@ -107,7 +110,7 @@ public class JCRSQLQueryBuilder implemen
     /**
      * List of PathQueryNode constraints that need to be merged
      */
-    private final List pathConstraints = new ArrayList();
+    private final List<MergingPathQueryNode> pathConstraints = new ArrayList<MergingPathQueryNode>();
 
     /**
      * The query node factory.
@@ -148,7 +151,7 @@ public class JCRSQLQueryBuilder implemen
             // get parser
             JCRSQLParser parser;
             synchronized (parsers) {
-                parser = (JCRSQLParser) parsers.get(resolver);
+                parser = parsers.get(resolver);
                 if (parser == null) {
                     parser = new JCRSQLParser(new StringReader(statement));
                     parser.setNameResolver(resolver);
@@ -241,7 +244,7 @@ public class JCRSQLQueryBuilder implemen
                         throw new IllegalArgumentException("Invalid combination of jcr:path
clauses");
                     } else {
                         pathConstraints.remove(path);
-                        MergingPathQueryNode[] paths = (MergingPathQueryNode[]) pathConstraints.toArray(new
MergingPathQueryNode[pathConstraints.size()]);
+                        MergingPathQueryNode[] paths = pathConstraints.toArray(new MergingPathQueryNode[pathConstraints.size()]);
                         paths = path.doMerge(paths);
                         pathConstraints.clear();
                         pathConstraints.addAll(Arrays.asList(paths));
@@ -250,7 +253,7 @@ public class JCRSQLQueryBuilder implemen
             } catch (NoSuchElementException e) {
                 throw new IllegalArgumentException("Invalid combination of jcr:path clauses");
             }
-            MergingPathQueryNode path = (MergingPathQueryNode) pathConstraints.get(0);
+            MergingPathQueryNode path = pathConstraints.get(0);
             LocationStepQueryNode[] steps = path.getPathSteps();
             for (LocationStepQueryNode step1 : steps) {
                 LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
@@ -326,7 +329,7 @@ public class JCRSQLQueryBuilder implemen
 
     @Override
     public Object visit(ASTPredicate node, Object data) {
-        NAryQueryNode parent = (NAryQueryNode) data;
+        NAryQueryNode<QueryNode> parent = cast(data);
 
         int type = node.getOperationType();
         QueryNode predicateNode;
@@ -469,7 +472,7 @@ public class JCRSQLQueryBuilder implemen
 
     @Override
     public Object visit(ASTOrExpression node, Object data) {
-        NAryQueryNode parent = (NAryQueryNode) data;
+        NAryQueryNode<QueryNode> parent = cast(data);
         OrQueryNode orQuery = factory.createOrQueryNode(parent);
         // pass to operands
         node.childrenAccept(this, orQuery);
@@ -482,7 +485,7 @@ public class JCRSQLQueryBuilder implemen
 
     @Override
     public Object visit(ASTAndExpression node, Object data) {
-        NAryQueryNode parent = (NAryQueryNode) data;
+        NAryQueryNode<QueryNode> parent = cast(data);
         AndQueryNode andQuery = factory.createAndQueryNode(parent);
         // pass to operands
         node.childrenAccept(this, andQuery);
@@ -495,7 +498,7 @@ public class JCRSQLQueryBuilder implemen
 
     @Override
     public Object visit(ASTNotExpression node, Object data) {
-        NAryQueryNode parent = (NAryQueryNode) data;
+        NAryQueryNode<QueryNode> parent = cast(data);
         NotQueryNode notQuery = factory.createNotQueryNode(parent);
         // pass to operand
         node.childrenAccept(this, notQuery);
@@ -581,7 +584,7 @@ public class JCRSQLQueryBuilder implemen
 
     @Override
     public Object visit(ASTContainsExpression node, Object data) {
-        NAryQueryNode parent = (NAryQueryNode) data;
+        NAryQueryNode<QueryNode> parent = cast(data);
         try {
             Path relPath = null;
             if (node.getPropertyName() != null) {
@@ -977,12 +980,12 @@ public class JCRSQLQueryBuilder implemen
             // compact this
             MergingPathQueryNode compacted = new MergingPathQueryNode(
                     QueryNode.TYPE_OR, getValidJcrSystemNodeTypeNames());
-            for (Iterator it = operands.iterator(); it.hasNext();) {
-                LocationStepQueryNode step = (LocationStepQueryNode) it.next();
+            for (Iterator<LocationStepQueryNode> it = operands.iterator(); it.hasNext();)
{
+                LocationStepQueryNode step = it.next();
                 if (step.getIncludeDescendants() && step.getNameTest() == null) {
                     // check if has next
                     if (it.hasNext()) {
-                        LocationStepQueryNode next = (LocationStepQueryNode) it.next();
+                        LocationStepQueryNode next = it.next();
                         next.setIncludeDescendants(true);
                         compacted.addPathStep(next);
                     } else {
@@ -998,11 +1001,11 @@ public class JCRSQLQueryBuilder implemen
                 // loop over the steps and compare the names
                 if (node.operands.size() == compacted.operands.size()) {
                     boolean match = true;
-                    Iterator compactedSteps = compacted.operands.iterator();
-                    Iterator otherSteps = node.operands.iterator();
+                    Iterator<LocationStepQueryNode> compactedSteps = compacted.operands.iterator();
+                    Iterator<LocationStepQueryNode> otherSteps = node.operands.iterator();
                     while (match && compactedSteps.hasNext()) {
-                        LocationStepQueryNode n1 = (LocationStepQueryNode) compactedSteps.next();
-                        LocationStepQueryNode n2 = (LocationStepQueryNode) otherSteps.next();
+                        LocationStepQueryNode n1 = compactedSteps.next();
+                        LocationStepQueryNode n2 = otherSteps.next();
                         match &= n1.getNameTest() == null ? n2.getNameTest() == null
: n1.getNameTest().equals(n2.getNameTest());
                     }
                     if (match) {
@@ -1015,10 +1018,10 @@ public class JCRSQLQueryBuilder implemen
                 throw new NoSuchElementException("Merging not possible with any node.");
             }
             // construct new list
-            List mergedList = new ArrayList(Arrays.asList(nodes));
+            List<MergingPathQueryNode> mergedList = new ArrayList<MergingPathQueryNode>(Arrays.asList(nodes));
             mergedList.remove(matchedNode);
             mergedList.add(compacted);
-            return (MergingPathQueryNode[]) mergedList.toArray(new MergingPathQueryNode[mergedList.size()]);
+            return mergedList.toArray(new MergingPathQueryNode[mergedList.size()]);
         }
 
         /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java
Wed Sep  7 15:54:44 2011
@@ -87,19 +87,19 @@ class QueryFormat implements QueryNodeVi
     /**
      * List of exception objects created while creating the SQL string
      */
-    private final List exceptions = new ArrayList();
+    private final List<Exception> exceptions = new ArrayList<Exception>();
 
     /**
      * List of node types
      */
-    private final List nodeTypes = new ArrayList();
+    private final List<Name> nodeTypes = new ArrayList<Name>();
 
     private QueryFormat(QueryRootNode root, NameResolver resolver)
             throws RepositoryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
         if (!exceptions.isEmpty()) {
-            Exception e = (Exception) exceptions.get(0);
+            Exception e = exceptions.get(0);
             throw new InvalidQueryException(e.getMessage(), e);
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
Wed Sep  7 15:54:44 2011
@@ -91,14 +91,14 @@ class QueryFormat implements QueryNodeVi
     /**
      * List of exception objects created while creating the XPath string
      */
-    private final List exceptions = new ArrayList();
+    private final List<Exception> exceptions = new ArrayList<Exception>();
 
     private QueryFormat(QueryRootNode root, NameResolver resolver)
             throws RepositoryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
         if (!exceptions.isEmpty()) {
-            Exception e = (Exception) exceptions.get(0);
+            Exception e = exceptions.get(0);
             throw new InvalidQueryException(e.getMessage(), e);
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java?rev=1166240&r1=1166239&r2=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
Wed Sep  7 15:54:44 2011
@@ -105,6 +105,7 @@ import static org.apache.jackrabbit.spi.
 import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTTYPENAME;
 import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTUNARYMINUS;
 import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTXPATH2;
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
 
 /**
  * Query builder that translates a XPath statement into a query tree structure.
@@ -282,7 +283,7 @@ public class XPathQueryBuilder implement
     /**
      * Map of reusable XPath parser instances indexed by NamespaceResolver.
      */
-    private static final Map parsers = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
+    private static final Map<NameResolver, XPath> parsers = cast(new ReferenceMap(ReferenceMap.WEAK,
ReferenceMap.WEAK));
 
     /**
      * The root {@code QueryNode}
@@ -297,7 +298,7 @@ public class XPathQueryBuilder implement
     /**
      * List of exceptions that are created while building the query tree
      */
-    private final List exceptions = new ArrayList();
+    private final List<Exception> exceptions = new ArrayList<Exception>();
 
     /**
      * Temporary relative path
@@ -331,7 +332,7 @@ public class XPathQueryBuilder implement
             // get parser
             XPath parser;
             synchronized (parsers) {
-                parser = (XPath) parsers.get(resolver);
+                parser = parsers.get(resolver);
                 if (parser == null) {
                     parser = new XPath(new StringReader(statement));
                     parsers.put(resolver, parser);
@@ -353,7 +354,7 @@ public class XPathQueryBuilder implement
         }
         if (!exceptions.isEmpty()) {
             // simply report the first one
-            Exception e = (Exception) exceptions.get(0);
+            Exception e = exceptions.get(0);
             if (e instanceof InvalidQueryException) {
                 // just re-throw
                 throw (InvalidQueryException) e;
@@ -446,7 +447,7 @@ public class XPathQueryBuilder implement
                         applyRelativePath(isNull);
                         node.childrenAccept(this, isNull);
                         NotQueryNode notNode = (NotQueryNode) queryNode;
-                        NAryQueryNode parent = (NAryQueryNode) notNode.getParent();
+                        NAryQueryNode<QueryNode> parent = cast(notNode.getParent());
                         parent.removeOperand(notNode);
                         parent.addOperand(isNull);
                     } else {
@@ -454,11 +455,13 @@ public class XPathQueryBuilder implement
                         RelationQueryNode notNull = factory.createRelationQueryNode(queryNode,
OPERATION_NOT_NULL);
                         applyRelativePath(notNull);
                         node.childrenAccept(this, notNull);
-                        ((NAryQueryNode) queryNode).addOperand(notNull);
+                        NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                        naryQueryNode.addOperand(notNull);
                     }
                 } else {
                     if (queryNode.getType() == QueryNode.TYPE_PATH) {
-                        createLocationStep(node, (NAryQueryNode) queryNode);
+                        NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                        createLocationStep(node, naryQueryNode);
                     } else if (queryNode.getType() == QueryNode.TYPE_TEXTSEARCH
                             || queryNode.getType() == QueryNode.TYPE_RELATION) {
                         node.childrenAccept(this, queryNode);
@@ -520,21 +523,22 @@ public class XPathQueryBuilder implement
                 }
                 break;
             case JJTOREXPR:
-                NAryQueryNode parent = (NAryQueryNode) queryNode;
+                NAryQueryNode<QueryNode> parent = cast(queryNode);
                 QueryNode orQueryNode = factory.createOrQueryNode(parent);
                 parent.addOperand(orQueryNode);
                 // traverse
                 node.childrenAccept(this, orQueryNode);
                 break;
             case JJTANDEXPR:
-                parent = (NAryQueryNode) queryNode;
+                parent = cast(queryNode);
                 QueryNode andQueryNode = factory.createAndQueryNode(parent);
                 parent.addOperand(andQueryNode);
                 // traverse
                 node.childrenAccept(this, andQueryNode);
                 break;
             case JJTCOMPARISONEXPR:
-                createExpression(node, (NAryQueryNode) queryNode);
+                NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                createExpression(node, naryQueryNode);
                 break;
             case JJTSTRINGLITERAL:
             case JJTDECIMALLITERAL:
@@ -658,7 +662,7 @@ public class XPathQueryBuilder implement
      * @param parent the parent {@code PathQueryNode}.
      * @return the created {@code LocationStepQueryNode}.
      */
-    private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode parent)
{
+    private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode<QueryNode>
parent) {
         LocationStepQueryNode queryNode = null;
         boolean descendant = false;
         Node p = node.jjtGetParent();
@@ -740,7 +744,7 @@ public class XPathQueryBuilder implement
      * @param node      a comparison expression node.
      * @param queryNode the current {@code QueryNode}.
      */
-    private void createExpression(SimpleNode node, NAryQueryNode queryNode) {
+    private void createExpression(SimpleNode node, NAryQueryNode<QueryNode> queryNode)
{
         if (node.getId() != JJTCOMPARISONEXPR) {
             throw new IllegalArgumentException("node must be of type ComparisonExpr");
         }
@@ -857,7 +861,8 @@ public class XPathQueryBuilder implement
             if (FN_NOT.equals(funName) || FN_NOT_10.equals(funName)) {
                 if (queryNode instanceof NAryQueryNode) {
                     QueryNode not = factory.createNotQueryNode(queryNode);
-                    ((NAryQueryNode) queryNode).addOperand(not);
+                    NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                    naryQueryNode.addOperand(not);
                     // todo is this needed?
                     queryNode = not;
                     // traverse
@@ -906,7 +911,8 @@ public class XPathQueryBuilder implement
                             // assign property name
                             SimpleNode path = (SimpleNode) node.jjtGetChild(1);
                             path.jjtAccept(this, contains);
-                            ((NAryQueryNode) queryNode).addOperand(contains);
+                            NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                            naryQueryNode.addOperand(contains);
                         } else {
                             exceptions.add(new InvalidQueryException("Wrong argument type
for jcr:contains"));
                         }
@@ -920,7 +926,8 @@ public class XPathQueryBuilder implement
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
                         RelationQueryNode like = factory.createRelationQueryNode(queryNode,
OPERATION_LIKE);
-                        ((NAryQueryNode) queryNode).addOperand(like);
+                        NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                        naryQueryNode.addOperand(like);
 
                         // assign property name
                         node.jjtGetChild(1).jjtAccept(this, like);
@@ -995,7 +1002,8 @@ public class XPathQueryBuilder implement
                         // remember if descendant axis
                         descendant = loc.getIncludeDescendants();
                         queryNode = loc.getParent();
-                        ((NAryQueryNode) queryNode).removeOperand(loc);
+                        NAryQueryNode<QueryNode> naryQueryNode = cast(queryNode);
+                        naryQueryNode.removeOperand(loc);
                     }
                     if (queryNode.getType() == QueryNode.TYPE_PATH) {
                         PathQueryNode pathNode = (PathQueryNode) queryNode;
@@ -1052,7 +1060,7 @@ public class XPathQueryBuilder implement
             } else if (REP_SIMILAR.equals(funName)) {
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
-                        NAryQueryNode parent = (NAryQueryNode) queryNode;
+                        NAryQueryNode<QueryNode> parent = cast(queryNode);
                         RelationQueryNode rel = factory.createRelationQueryNode(parent, OPERATION_SIMILAR);
                         parent.addOperand(rel);
                         // assign path
@@ -1077,7 +1085,7 @@ public class XPathQueryBuilder implement
                     && queryNode.getType() != QueryNode.TYPE_PATH) {
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode instanceof NAryQueryNode) {
-                        NAryQueryNode parent = (NAryQueryNode) queryNode;
+                        NAryQueryNode<QueryNode> parent = cast(queryNode);
                         RelationQueryNode rel = factory.createRelationQueryNode(parent, OPERATION_SPELLCHECK);
                         parent.addOperand(rel);
 

Copied: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/Unchecked.java
(from r1165747, jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/Unchecked.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/Unchecked.java?p2=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/Unchecked.java&p1=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/Unchecked.java&r1=1165747&r2=1166240&rev=1166240&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/Unchecked.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/Unchecked.java
Wed Sep  7 15:54:44 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.jcr2spi.util;
+package org.apache.jackrabbit.spi.commons.util;
 
 public final class Unchecked {
     private Unchecked() {}



Mime
View raw message