cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1585094 - /cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
Date Sat, 05 Apr 2014 13:28:52 GMT
Author: aadamchik
Date: Sat Apr  5 13:28:52 2014
New Revision: 1585094

URL: http://svn.apache.org/r1585094
Log:
java 6 annotations

Modified:
    cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java

Modified: cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java?rev=1585094&r1=1585093&r2=1585094&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
(original)
+++ cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
Sat Apr  5 13:28:52 2014
@@ -39,7 +39,8 @@ import org.xml.sax.helpers.DefaultHandle
  * 
  * @since 3.1
  */
-// there's no guarantee this will survive the further version upgrades, but for now all
+// there's no guarantee this will survive the further version upgrades, but for
+// now all
 // the code here seems like version-agnostic
 public abstract class BaseUpgradeHandler implements UpgradeHandler {
 
@@ -56,7 +57,7 @@ public abstract class BaseUpgradeHandler
 
         this.projectSource = projectSource;
     }
-    
+
     /**
      * Creates a single common EntityResolver for all project DataMaps, setting
      * it as a namespace for all of them. This is needed for resolving cross-map
@@ -70,10 +71,12 @@ public abstract class BaseUpgradeHandler
         }
     }
 
+    @Override
     public Resource getProjectSource() {
         return projectSource;
     }
 
+    @Override
     public UpgradeMetaData getUpgradeMetaData() {
         // no attempts at thread-safety... shouldn't be needed for upgrades
         if (metaData == null) {
@@ -83,25 +86,27 @@ public abstract class BaseUpgradeHandler
         return metaData;
     }
 
+    @Override
     public Resource performUpgrade() throws ConfigurationException {
         UpgradeMetaData metaData = getUpgradeMetaData();
         switch (metaData.getUpgradeType()) {
-            case DOWNGRADE_NEEDED:
-                throw new ConfigurationException("Downgrade can not be performed");
-            case INTERMEDIATE_UPGRADE_NEEDED:
-                throw new ConfigurationException(
-                        "Upgrade can not be performed - intermediate version upgrade needed");
-            case UPGRADE_NEEDED:
-                return doPerformUpgrade(metaData);
-            default:
-                return getProjectSource();
+        case DOWNGRADE_NEEDED:
+            throw new ConfigurationException("Downgrade can not be performed");
+        case INTERMEDIATE_UPGRADE_NEEDED:
+            throw new ConfigurationException("Upgrade can not be performed - intermediate
version upgrade needed");
+        case UPGRADE_NEEDED:
+            return doPerformUpgrade(metaData);
+        default:
+            return getProjectSource();
         }
     }
 
     /**
-     * Does the actual project upgrade, assuming the caller already verified that the
-     * upgrade is possible.
-     * @param metaData object describing the type of upgrade
+     * Does the actual project upgrade, assuming the caller already verified
+     * that the upgrade is possible.
+     * 
+     * @param metaData
+     *            object describing the type of upgrade
      */
     protected abstract Resource doPerformUpgrade(UpgradeMetaData metaData) throws ConfigurationException;
 
@@ -111,7 +116,8 @@ public abstract class BaseUpgradeHandler
     protected abstract UpgradeMetaData loadMetaData();
 
     /**
-     * A default method for quick extraction of the project version from an XML file.
+     * A default method for quick extraction of the project version from an XML
+     * file.
      */
     protected String loadProjectVersion() {
 
@@ -127,30 +133,22 @@ public abstract class BaseUpgradeHandler
             parser.setContentHandler(rootHandler);
             parser.setErrorHandler(rootHandler);
             parser.parse(new InputSource(in));
-        }
-        catch (SAXException e) {
-            // expected ... handler will terminate as soon as it finds a root tag.
-        }
-        catch (Exception e) {
-            throw new ConfigurationException(
-                    "Error reading configuration from %s",
-                    e,
-                    url);
-        }
-        finally {
+        } catch (SAXException e) {
+            // expected ... handler will terminate as soon as it finds a root
+            // tag.
+        } catch (Exception e) {
+            throw new ConfigurationException("Error reading configuration from %s", e, url);
+        } finally {
             try {
                 if (in != null) {
                     in.close();
                 }
-            }
-            catch (IOException ioex) {
+            } catch (IOException ioex) {
                 // ignoring...
             }
         }
 
-        return rootHandler.projectVersion != null
-                ? rootHandler.projectVersion
-                : UNKNOWN_VERSION;
+        return rootHandler.projectVersion != null ? rootHandler.projectVersion : UNKNOWN_VERSION;
     }
 
     /**
@@ -181,8 +179,7 @@ public abstract class BaseUpgradeHandler
             if (nextChar == '.' && !dotProcessed) {
                 dotProcessed = true;
                 buffer.append('.');
-            }
-            else if (Character.isDigit(nextChar)) {
+            } else if (Character.isDigit(nextChar)) {
                 buffer.append(nextChar);
             }
         }
@@ -195,15 +192,12 @@ public abstract class BaseUpgradeHandler
         private String projectVersion;
 
         @Override
-        public void startElement(
-                String uri,
-                String localName,
-                String qName,
-                Attributes attributes) throws SAXException {
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
 
             this.projectVersion = attributes.getValue("", "project-version");
 
-            // bail right away - we are not interested in reading this to the end
+            // bail right away - we are not interested in reading this to the
+            // end
             throw new SAXException("finished");
         }
     }



Mime
View raw message