jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1056269 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
Date Fri, 07 Jan 2011 11:35:10 GMT
Author: angela
Date: Fri Jan  7 11:35:10 2011
New Revision: 1056269

URL: http://svn.apache.org/viewvc?rev=1056269&view=rev
Log:
override annotations and generify namespace maps

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java?rev=1056269&r1=1056268&r2=1056269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
Fri Jan  7 11:35:10 2011
@@ -68,7 +68,7 @@ public class ImportHandler extends Defau
      * to instantiate the local namespace context in
      * {@link #startElement(String, String, String, Attributes)}.
      */
-    private Map localNamespaceMappings;
+    private Map<String, String> localNamespaceMappings;
 
     public ImportHandler(Importer importer, Session session)
             throws RepositoryException {
@@ -82,6 +82,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void warning(SAXParseException e) throws SAXException {
         // log exception and carry on...
         log.warn("warning encountered at line: " + e.getLineNumber()
@@ -92,6 +93,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void error(SAXParseException e) throws SAXException {
         // log exception and carry on...
         log.error("error encountered at line: " + e.getLineNumber()
@@ -102,6 +104,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void fatalError(SAXParseException e) throws SAXException {
         // log and re-throw exception
         log.error("fatal error encountered at line: " + e.getLineNumber()
@@ -115,6 +118,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void endDocument() throws SAXException {
         // delegate to target handler
         if (targetHandler != null) {
@@ -134,6 +138,7 @@ public class ImportHandler extends Defau
      * @param prefix namespace prefix
      * @param uri namespace URI
      */
+    @Override
     public void startPrefixMapping(String prefix, String uri)
             throws SAXException {
         localNamespaceMappings.put(prefix, uri);
@@ -147,6 +152,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void startElement(String namespaceURI, String localName, String qName,
                              Attributes atts) throws SAXException {
         if (targetHandler == null) {
@@ -172,6 +178,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void characters(char[] ch, int start, int length) throws SAXException {
         // delegate to target handler
         targetHandler.characters(ch, start, length);
@@ -182,6 +189,7 @@ public class ImportHandler extends Defau
      * handler to end the current namespace context.
      * {@inheritDoc}
      */
+    @Override
     public void endElement(String namespaceURI, String localName, String qName)
             throws SAXException {
         targetHandler.endElement(namespaceURI, localName, qName);
@@ -191,6 +199,7 @@ public class ImportHandler extends Defau
     /**
      * {@inheritDoc}
      */
+    @Override
     public void setDocumentLocator(Locator locator) {
         this.locator = locator;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java?rev=1056269&r1=1056268&r2=1056269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
Fri Jan  7 11:35:10 2011
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.commons;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.jcr.NamespaceException;
@@ -72,11 +71,11 @@ public class NamespaceHelper {
      * @return namespace mappings
      * @throws RepositoryException if the namespaces could not be retrieved
      */
-    public Map getNamespaces() throws RepositoryException {
-        Map namespaces = new HashMap();
+    public Map<String, String> getNamespaces() throws RepositoryException {
+        Map<String, String> namespaces = new HashMap<String, String>();
         String[] prefixes = session.getNamespacePrefixes();
-        for (int i = 0; i < prefixes.length; i++) {
-            namespaces.put(prefixes[i], session.getNamespaceURI(prefixes[i]));
+        for (String prefixe : prefixes) {
+            namespaces.put(prefixe, session.getNamespaceURI(prefixe));
         }
         return namespaces;
     }
@@ -103,7 +102,7 @@ public class NamespaceHelper {
      * session, or <code>null</code> if the namespace does not exist.
      *
      * @see Session#getNamespaceURI(String)
-     * @param uri namespace URI
+     * @param prefix namespace prefix
      * @return namespace prefix, or <code>null</code>
      * @throws RepositoryException if the namespace could not be retrieved
      */
@@ -231,12 +230,10 @@ public class NamespaceHelper {
      * @param namespaces namespace mappings
      * @throws RepositoryException if the namespaces could not be registered
      */
-    public void registerNamespaces(Map namespaces) throws RepositoryException {
-        Iterator iterator = namespaces.entrySet().iterator();
-        while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            registerNamespace(
-                    (String) entry.getKey(), (String) entry.getValue());
+    public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException
{
+        for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) {
+            Map.Entry<String, String> entry = stringStringEntry;
+            registerNamespace(entry.getKey(), entry.getValue());
         }
     }
 



Mime
View raw message