rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpie...@apache.org
Subject svn commit: r1100396 - in /incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave: jdbc/util/SqlFileParser.java portal/repository/impl/util/JpaUtil.java portal/util/LocalizationUtils.java portal/web/util/ModelKeys.java
Date Fri, 06 May 2011 21:51:59 GMT
Author: mpierce
Date: Fri May  6 21:51:58 2011
New Revision: 1100396

URL: http://svn.apache.org/viewvc?rev=1100396&view=rev
Log:
Various minor updates while reviewing code.


Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/SqlFileParser.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/SqlFileParser.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/SqlFileParser.java?rev=1100396&r1=1100395&r2=1100396&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/SqlFileParser.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/SqlFileParser.java
Fri May  6 21:51:58 2011
@@ -93,11 +93,20 @@ public class SqlFileParser {
     }
 
     private void processFile(File file, StringBuilder sql) throws IOException {
-        BufferedReader fileReader = new BufferedReader(new FileReader(file.getAbsoluteFile()));
-        String line = null;
-        while ((line = fileReader.readLine()) != null) {
-            processLine(sql, line);
-        }
+		  BufferedReader fileReader=null;
+		  try {
+				fileReader = new BufferedReader(new FileReader(file.getAbsoluteFile()));
+				String line = null;
+				while ((line = fileReader.readLine()) != null) {
+					 processLine(sql, line);
+				}
+		  }
+		  catch (IOException ioex) {
+				throw (ioex);
+		  }
+		  finally {
+				fileReader.close();
+		  }
     }
 
     private void processLine(StringBuilder sql, String line) throws IOException {

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java?rev=1100396&r1=1100395&r2=1100396&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
Fri May  6 21:51:58 2011
@@ -10,6 +10,9 @@ import java.util.List;
  *         Time: 10:13 PM
  */
 public class JpaUtil {
+	 //Private constructor for utility classes
+	 public JpaUtil () {;}
+
     public static <T> T getSingleResult(List<T> list) {
         if (list == null) {
             return null;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java?rev=1100396&r1=1100395&r2=1100396&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
Fri May  6 21:51:58 2011
@@ -36,6 +36,9 @@ import java.util.List;
 public class LocalizationUtils {
     static Logger _logger = LoggerFactory.getLogger(LocalizationUtils.class);
 
+	 //Private, empty constructor for class with only static methods.
+	 private LocalizationUtils() {};
+	 
     /**
      * Returns the first (best) match for an element given the set of locales, or null if
there are no suitable
      * elements.
@@ -45,11 +48,13 @@ public class LocalizationUtils {
      * @return a LocalizedString, or null if there are no valid entries
      */
     public static LocalizedString getLocalizedElement(LocalizedString[] elements, String[]
locales) {
-        if (elements == null)
+        if (elements == null) {
             return null;
+		  }
         elements = processElementsByLocales(elements, locales);
-        if (elements.length == 0)
+        if (elements.length == 0) {
             return null;
+		  }
         return elements[0];
     }
 
@@ -62,8 +67,9 @@ public class LocalizationUtils {
      * @return the sorted and filtered set of elements
      */
     public static LocalizedString[] processElementsByLocales(LocalizedString[] elements,
String[] locales) {
-        if (elements == null)
+        if (elements == null) {
             return null;
+		  }
         List<ULocale> localesList = getProcessedLocaleList(locales);
         Arrays.sort(elements, new LocaleComparator(localesList));
         return filter(elements, localesList);
@@ -76,8 +82,9 @@ public class LocalizationUtils {
      * @return a sorted array of LocalizedString objects
      */
     public static LocalizedString[] processElementsByDefaultLocales(LocalizedString[] elements)
{
-        if (elements == null)
+        if (elements == null) {
             return null;
+		  }
         List<ULocale> localesList = getDefaultLocaleList();
         Arrays.sort(elements, new LocaleComparator(localesList));
         return filter(elements, localesList);
@@ -96,27 +103,34 @@ public class LocalizationUtils {
 
         public int compare(LocalizedString o1, LocalizedString o2) {
             // check non-localized values for comparison
-            if (o1.getLang() != null && o2.getLang() == null)
+            if (o1.getLang() != null && o2.getLang() == null) {
                 return -1;
-            if (o1.getLang() == null && o2.getLang() != null)
+				}
+            if (o1.getLang() == null && o2.getLang() != null) {
                 return 1;
-            if (o1.getLang() == null && o2.getLang() == null)
+				}
+            if (o1.getLang() == null && o2.getLang() == null) {
                 return 0;
+				}
 
             // get index position of locales
             int o1i = -1;
             int o2i = -1;
             for (int i = 0; i < locales.size(); i++) {
-                if (o1.getLang().equalsIgnoreCase(locales.get(i).toLanguageTag()))
+                if (o1.getLang().equalsIgnoreCase(locales.get(i).toLanguageTag())) {
                     o1i = i;
-                if (o2.getLang().equalsIgnoreCase(locales.get(i).toLanguageTag()))
+					 }
+                if (o2.getLang().equalsIgnoreCase(locales.get(i).toLanguageTag())) {
                     o2i = i;
+					 }
             }
             // put non-matched after matched
-            if (o1i == -1 && o2i > -1)
+            if (o1i == -1 && o2i > -1) {
                 return 1;
-            if (o1i > -1 && o2i == -1)
+				}
+            if (o1i > -1 && o2i == -1) {
                 return -1;
+				}
 
             // order by match
             return o1i - o2i;
@@ -207,13 +221,16 @@ public class LocalizationUtils {
     public static boolean isValidLanguageTag(String tag) {
         try {
             ULocale locale = ULocale.forLanguageTag(tag);
-            if (locale.toLanguageTag() == null)
+            if (locale.toLanguageTag() == null) {
                 return false;
+				}
             // We don't accept "x" extensions (private use tags)
-            if (locale.getExtension("x".charAt(0)) != null)
+            if (locale.getExtension("x".charAt(0)) != null) {
                 return false;
-            if (!locale.toLanguageTag().equalsIgnoreCase(tag))
+				}
+            if (!locale.toLanguageTag().equalsIgnoreCase(tag)) {
                 return false;
+				}
             return true;
         } catch (Exception e) {
             return false;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1100396&r1=1100395&r2=1100396&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
Fri May  6 21:51:58 2011
@@ -20,6 +20,9 @@
 package org.apache.rave.portal.web.util;
 
 public class ModelKeys {
+	 //Private, empty constructor for utility class
+	 private ModelKeys () {;}
+
     public final static String PAGES = "pages"; // a list of pages available for the current
user
     public final static String ERROR_MESSAGE = "errorMessage"; // an error message to be
reported to the user
 }
\ No newline at end of file



Mime
View raw message