incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1358111 [9/13] - in /incubator/isis/trunk/framework/core/commons: ./ src/main/java/org/apache/isis/core/commons/authentication/ src/main/java/org/apache/isis/core/commons/components/ src/main/java/org/apache/isis/core/commons/config/ src/m...
Date Fri, 06 Jul 2012 10:51:21 GMT
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MapUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MapUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MapUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MapUtils.java Fri Jul  6 10:51:16 2012
@@ -1,53 +1,53 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public final class MapUtils {
-
-    private MapUtils() {
-    }
-
-    /**
-     * Converts a list of objects [a, 1, b, 2] into a map {a -> 1; b -> 2}
-     */
-    public static Map<String, String> asMap(final String... paramArgs) {
-        final HashMap<String, String> map = new HashMap<String, String>();
-        boolean param = true;
-        String paramStr = null;
-        for (final String paramArg : paramArgs) {
-            if (param) {
-                paramStr = paramArg;
-            } else {
-                final String arg = paramArg;
-                map.put(paramStr, arg);
-                paramStr = null;
-            }
-            param = !param;
-        }
-        if (paramStr != null) {
-            throw new IllegalArgumentException("Must have equal number of parameters and arguments");
-        }
-        return map;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class MapUtils {
+
+    private MapUtils() {
+    }
+
+    /**
+     * Converts a list of objects [a, 1, b, 2] into a map {a -> 1; b -> 2}
+     */
+    public static Map<String, String> asMap(final String... paramArgs) {
+        final HashMap<String, String> map = new HashMap<String, String>();
+        boolean param = true;
+        String paramStr = null;
+        for (final String paramArg : paramArgs) {
+            if (param) {
+                paramStr = paramArg;
+            } else {
+                final String arg = paramArg;
+                map.put(paramStr, arg);
+                paramStr = null;
+            }
+            param = !param;
+        }
+        if (paramStr != null) {
+            throw new IllegalArgumentException("Must have equal number of parameters and arguments");
+        }
+        return map;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MethodUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MethodUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MethodUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/MethodUtils.java Fri Jul  6 10:51:16 2012
@@ -1,59 +1,59 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.lang.reflect.Method;
-
-public class MethodUtils {
-
-    private MethodUtils() {
-    }
-
-    public static Method getMethod(final Object object, final String methodName, final Class<?>... parameterClass) throws NoSuchMethodException {
-        return getMethod(object.getClass(), methodName, parameterClass);
-    }
-
-    public static Method getMethod(final Object object, final String methodName) throws NoSuchMethodException {
-        return getMethod(object.getClass(), methodName, new Class[0]);
-    }
-
-    public static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterClass) throws NoSuchMethodException {
-        return clazz.getMethod(methodName, parameterClass);
-    }
-
-    public static Method findMethodElseNull(final Class<?> clazz, final String methodName, final Class<?>... parameterClass) {
-        try {
-            return clazz.getMethod(methodName, parameterClass);
-        } catch (final NoSuchMethodException e) {
-            return null;
-        }
-    }
-
-    public static Method findMethodElseNull(final Class<?> clazz, final String[] candidateMethodNames, final Class<?>... parameterClass) {
-        for (final String candidateMethodName : candidateMethodNames) {
-            final Method method = findMethodElseNull(clazz, candidateMethodName, parameterClass);
-            if (method != null) {
-                return method;
-            }
-        }
-        return null;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.lang.reflect.Method;
+
+public class MethodUtils {
+
+    private MethodUtils() {
+    }
+
+    public static Method getMethod(final Object object, final String methodName, final Class<?>... parameterClass) throws NoSuchMethodException {
+        return getMethod(object.getClass(), methodName, parameterClass);
+    }
+
+    public static Method getMethod(final Object object, final String methodName) throws NoSuchMethodException {
+        return getMethod(object.getClass(), methodName, new Class[0]);
+    }
+
+    public static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterClass) throws NoSuchMethodException {
+        return clazz.getMethod(methodName, parameterClass);
+    }
+
+    public static Method findMethodElseNull(final Class<?> clazz, final String methodName, final Class<?>... parameterClass) {
+        try {
+            return clazz.getMethod(methodName, parameterClass);
+        } catch (final NoSuchMethodException e) {
+            return null;
+        }
+    }
+
+    public static Method findMethodElseNull(final Class<?> clazz, final String[] candidateMethodNames, final Class<?>... parameterClass) {
+        for (final String candidateMethodName : candidateMethodNames) {
+            final Method method = findMethodElseNull(clazz, candidateMethodName, parameterClass);
+            if (method != null) {
+                return method;
+            }
+        }
+        return null;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/NameUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/NameUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/NameUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/NameUtils.java Fri Jul  6 10:51:16 2012
@@ -1,171 +1,171 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-public final class NameUtils {
-
-    private static final char SPACE = ' ';
-
-    private NameUtils() {
-    }
-
-    /**
-     * Returns the name of a Java entity without any prefix. A prefix is defined
-     * as the first set of lowercase letters and the name is characters from,
-     * and including, the first upper case letter. If no upper case letter is
-     * found then an empty string is returned.
-     * 
-     * <p>
-     * Calling this method with the following Java names will produce these
-     * results:
-     * 
-     * <pre>
-     *                     getCarRegistration        -&gt; CarRegistration
-     *                     CityMayor -&gt; CityMayor
-     *                     isReady -&gt; Ready
-     * </pre>
-     * 
-     */
-    public static String javaBaseName(final String javaName) {
-        int pos = 0;
-
-        // find first upper case character
-        final int len = javaName.length();
-
-        while ((pos < len) && (javaName.charAt(pos) != '_') && Character.isLowerCase(javaName.charAt(pos))) {
-            pos++;
-        }
-
-        if (pos >= len) {
-            return "";
-        }
-
-        if (javaName.charAt(pos) == '_') {
-            pos++;
-        }
-
-        if (pos >= len) {
-            return "";
-        }
-
-        final String baseName = javaName.substring(pos);
-        final char firstChar = baseName.charAt(0);
-
-        if (Character.isLowerCase(firstChar)) {
-            return Character.toUpperCase(firstChar) + baseName.substring(1);
-        } else {
-            return baseName;
-        }
-    }
-
-    public static String javaBaseNameStripAccessorPrefixIfRequired(final String javaName) {
-        if (javaName.startsWith("is") || javaName.startsWith("get")) {
-            return javaBaseName(javaName);
-        } else {
-            return capitalizeName(javaName);
-        }
-    }
-
-    public static String capitalizeName(final String name) {
-        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
-    }
-
-    public static boolean startsWith(final String fullMethodName, final String prefix) {
-        final int length = prefix.length();
-        if (length >= fullMethodName.length()) {
-            return false;
-        } else {
-            final char startingCharacter = fullMethodName.charAt(length);
-            return fullMethodName.startsWith(prefix) && Character.isUpperCase(startingCharacter);
-        }
-    }
-
-    /**
-     * Return a lower case, non-spaced version of the specified name.
-     */
-    public static String simpleName(final String name) {
-        final int len = name.length();
-        final StringBuffer sb = new StringBuffer(len);
-        for (int pos = 0; pos < len; pos++) {
-            final char ch = name.charAt(pos);
-            if (ch == ' ') {
-                continue;
-            }
-            sb.append(Character.toLowerCase(ch));
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Returns a word spaced version of the specified name, so there are spaces
-     * between the words, where each word starts with a capital letter. E.g.,
-     * "NextAvailableDate" is returned as "Next Available Date".
-     */
-    public static String naturalName(final String name) {
-
-        final int length = name.length();
-
-        if (length <= 1) {
-            return name.toUpperCase();// ensure first character is upper case
-        }
-
-        final StringBuffer naturalName = new StringBuffer(length);
-
-        char previousCharacter;
-        char character = Character.toUpperCase(name.charAt(0));// ensure first
-                                                               // character is
-                                                               // upper case
-        naturalName.append(character);
-        char nextCharacter = name.charAt(1);
-
-        for (int pos = 2; pos < length; pos++) {
-            previousCharacter = character;
-            character = nextCharacter;
-            nextCharacter = name.charAt(pos);
-
-            if (previousCharacter != NameUtils.SPACE) {
-                if (Character.isUpperCase(character) && !Character.isUpperCase(previousCharacter)) {
-                    naturalName.append(NameUtils.SPACE);
-                }
-                if (Character.isUpperCase(character) && Character.isLowerCase(nextCharacter) && Character.isUpperCase(previousCharacter)) {
-                    naturalName.append(NameUtils.SPACE);
-                }
-                if (Character.isDigit(character) && !Character.isDigit(previousCharacter)) {
-                    naturalName.append(NameUtils.SPACE);
-                }
-            }
-            naturalName.append(character);
-        }
-        naturalName.append(nextCharacter);
-        return naturalName.toString();
-    }
-
-    public static String pluralName(final String name) {
-        String pluralName;
-        if (name.endsWith("y")) {
-            pluralName = name.substring(0, name.length() - 1) + "ies";
-        } else if (name.endsWith("s") || name.endsWith("x")) {
-            pluralName = name + "es";
-        } else {
-            pluralName = name + 's';
-        }
-        return pluralName;
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+public final class NameUtils {
+
+    private static final char SPACE = ' ';
+
+    private NameUtils() {
+    }
+
+    /**
+     * Returns the name of a Java entity without any prefix. A prefix is defined
+     * as the first set of lowercase letters and the name is characters from,
+     * and including, the first upper case letter. If no upper case letter is
+     * found then an empty string is returned.
+     * 
+     * <p>
+     * Calling this method with the following Java names will produce these
+     * results:
+     * 
+     * <pre>
+     *                     getCarRegistration        -&gt; CarRegistration
+     *                     CityMayor -&gt; CityMayor
+     *                     isReady -&gt; Ready
+     * </pre>
+     * 
+     */
+    public static String javaBaseName(final String javaName) {
+        int pos = 0;
+
+        // find first upper case character
+        final int len = javaName.length();
+
+        while ((pos < len) && (javaName.charAt(pos) != '_') && Character.isLowerCase(javaName.charAt(pos))) {
+            pos++;
+        }
+
+        if (pos >= len) {
+            return "";
+        }
+
+        if (javaName.charAt(pos) == '_') {
+            pos++;
+        }
+
+        if (pos >= len) {
+            return "";
+        }
+
+        final String baseName = javaName.substring(pos);
+        final char firstChar = baseName.charAt(0);
+
+        if (Character.isLowerCase(firstChar)) {
+            return Character.toUpperCase(firstChar) + baseName.substring(1);
+        } else {
+            return baseName;
+        }
+    }
+
+    public static String javaBaseNameStripAccessorPrefixIfRequired(final String javaName) {
+        if (javaName.startsWith("is") || javaName.startsWith("get")) {
+            return javaBaseName(javaName);
+        } else {
+            return capitalizeName(javaName);
+        }
+    }
+
+    public static String capitalizeName(final String name) {
+        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+    }
+
+    public static boolean startsWith(final String fullMethodName, final String prefix) {
+        final int length = prefix.length();
+        if (length >= fullMethodName.length()) {
+            return false;
+        } else {
+            final char startingCharacter = fullMethodName.charAt(length);
+            return fullMethodName.startsWith(prefix) && Character.isUpperCase(startingCharacter);
+        }
+    }
+
+    /**
+     * Return a lower case, non-spaced version of the specified name.
+     */
+    public static String simpleName(final String name) {
+        final int len = name.length();
+        final StringBuffer sb = new StringBuffer(len);
+        for (int pos = 0; pos < len; pos++) {
+            final char ch = name.charAt(pos);
+            if (ch == ' ') {
+                continue;
+            }
+            sb.append(Character.toLowerCase(ch));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Returns a word spaced version of the specified name, so there are spaces
+     * between the words, where each word starts with a capital letter. E.g.,
+     * "NextAvailableDate" is returned as "Next Available Date".
+     */
+    public static String naturalName(final String name) {
+
+        final int length = name.length();
+
+        if (length <= 1) {
+            return name.toUpperCase();// ensure first character is upper case
+        }
+
+        final StringBuffer naturalName = new StringBuffer(length);
+
+        char previousCharacter;
+        char character = Character.toUpperCase(name.charAt(0));// ensure first
+                                                               // character is
+                                                               // upper case
+        naturalName.append(character);
+        char nextCharacter = name.charAt(1);
+
+        for (int pos = 2; pos < length; pos++) {
+            previousCharacter = character;
+            character = nextCharacter;
+            nextCharacter = name.charAt(pos);
+
+            if (previousCharacter != NameUtils.SPACE) {
+                if (Character.isUpperCase(character) && !Character.isUpperCase(previousCharacter)) {
+                    naturalName.append(NameUtils.SPACE);
+                }
+                if (Character.isUpperCase(character) && Character.isLowerCase(nextCharacter) && Character.isUpperCase(previousCharacter)) {
+                    naturalName.append(NameUtils.SPACE);
+                }
+                if (Character.isDigit(character) && !Character.isDigit(previousCharacter)) {
+                    naturalName.append(NameUtils.SPACE);
+                }
+            }
+            naturalName.append(character);
+        }
+        naturalName.append(nextCharacter);
+        return naturalName.toString();
+    }
+
+    public static String pluralName(final String name) {
+        String pluralName;
+        if (name.endsWith("y")) {
+            pluralName = name.substring(0, name.length() - 1) + "ies";
+        } else if (name.endsWith("s") || name.endsWith("x")) {
+            pluralName = name + "es";
+        } else {
+            pluralName = name + 's';
+        }
+        return pluralName;
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/PathUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/PathUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/PathUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/PathUtils.java Fri Jul  6 10:51:16 2012
@@ -1,47 +1,47 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-public final class PathUtils {
-
-    private PathUtils() {
-    }
-
-    public static String combine(final String path, final String suffix) {
-        if (isEmpty(path) && isEmpty(suffix)) {
-            return "";
-        }
-        if (isEmpty(path)) {
-            return suffix;
-        }
-        if (isEmpty(suffix)) {
-            return path;
-        }
-        if (path.endsWith("/") || suffix.startsWith("/")) {
-            return path + suffix;
-        }
-        return path + "/" + suffix;
-    }
-
-    private static boolean isEmpty(final String str) {
-        return str == null || str.length() == 0;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+public final class PathUtils {
+
+    private PathUtils() {
+    }
+
+    public static String combine(final String path, final String suffix) {
+        if (isEmpty(path) && isEmpty(suffix)) {
+            return "";
+        }
+        if (isEmpty(path)) {
+            return suffix;
+        }
+        if (isEmpty(suffix)) {
+            return path;
+        }
+        if (path.endsWith("/") || suffix.startsWith("/")) {
+            return path + suffix;
+        }
+        return path + "/" + suffix;
+    }
+
+    private static boolean isEmpty(final String str) {
+        return str == null || str.length() == 0;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Resources.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Resources.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Resources.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Resources.java Fri Jul  6 10:51:16 2012
@@ -1,122 +1,122 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Properties;
-
-/**
- * Adapted from Ibatis Common.
- */
-public class Resources {
-
-    /**
-     * Returns the URL, or null if not available.
-     */
-    public static URL getResourceURL(final String resource) {
-
-        // try thread's classloader
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        URL url = classLoader.getResource(resource);
-        if (url != null) {
-            return url;
-        }
-
-        // try this class' classloader
-        classLoader = Resources.class.getClassLoader();
-        url = classLoader.getResource(resource);
-        if (url != null) {
-            return url;
-        }
-
-        // try system class loader (could return null)
-        // wrapping in a try...catch because when running tests by Maven for a
-        // non-existing
-        // resource, seems to bomb out. Is okay when run from Eclipse. A bit of
-        // a puzzle.
-        try {
-            return ClassLoader.getSystemResource(resource);
-        } catch (final NullPointerException ignore) {
-            return null;
-        }
-    }
-
-    public static InputStream getResourceAsStream(final String resource) {
-
-        // try thread's classloader
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        InputStream is = classLoader.getResourceAsStream(resource);
-        if (is != null) {
-            return is;
-        }
-
-        // try this class' classloader
-        classLoader = Resources.class.getClassLoader();
-        is = classLoader.getResourceAsStream(resource);
-        if (is != null) {
-            return is;
-        }
-
-        // try system class loader (could return null)
-        // have wrapped in a try...catch because for same reason as
-        // getResourceURL
-        try {
-            return ClassLoader.getSystemResourceAsStream(resource);
-        } catch (final NullPointerException ignore) {
-            return null;
-        }
-    }
-
-    public static File getResourceAsFile(final String resource) {
-        final URL url = getResourceURL(resource);
-        if (url == null) {
-            return null;
-        }
-
-        return new File(url.getFile());
-    }
-
-    public static Properties getResourceAsProperties(final String resource) {
-
-        final InputStream is = getResourceAsStream(resource);
-        if (is == null) {
-            return null;
-        }
-
-        final Properties props = new Properties();
-        try {
-            props.load(is);
-        } catch (final IOException ex) {
-            throw new RuntimeException(ex);
-        } finally {
-            try {
-                is.close();
-            } catch (final IOException ignore) {
-                // ignore
-            }
-        }
-
-        return props;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ * Adapted from Ibatis Common.
+ */
+public class Resources {
+
+    /**
+     * Returns the URL, or null if not available.
+     */
+    public static URL getResourceURL(final String resource) {
+
+        // try thread's classloader
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL url = classLoader.getResource(resource);
+        if (url != null) {
+            return url;
+        }
+
+        // try this class' classloader
+        classLoader = Resources.class.getClassLoader();
+        url = classLoader.getResource(resource);
+        if (url != null) {
+            return url;
+        }
+
+        // try system class loader (could return null)
+        // wrapping in a try...catch because when running tests by Maven for a
+        // non-existing
+        // resource, seems to bomb out. Is okay when run from Eclipse. A bit of
+        // a puzzle.
+        try {
+            return ClassLoader.getSystemResource(resource);
+        } catch (final NullPointerException ignore) {
+            return null;
+        }
+    }
+
+    public static InputStream getResourceAsStream(final String resource) {
+
+        // try thread's classloader
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        InputStream is = classLoader.getResourceAsStream(resource);
+        if (is != null) {
+            return is;
+        }
+
+        // try this class' classloader
+        classLoader = Resources.class.getClassLoader();
+        is = classLoader.getResourceAsStream(resource);
+        if (is != null) {
+            return is;
+        }
+
+        // try system class loader (could return null)
+        // have wrapped in a try...catch because for same reason as
+        // getResourceURL
+        try {
+            return ClassLoader.getSystemResourceAsStream(resource);
+        } catch (final NullPointerException ignore) {
+            return null;
+        }
+    }
+
+    public static File getResourceAsFile(final String resource) {
+        final URL url = getResourceURL(resource);
+        if (url == null) {
+            return null;
+        }
+
+        return new File(url.getFile());
+    }
+
+    public static Properties getResourceAsProperties(final String resource) {
+
+        final InputStream is = getResourceAsStream(resource);
+        if (is == null) {
+            return null;
+        }
+
+        final Properties props = new Properties();
+        try {
+            props.load(is);
+        } catch (final IOException ex) {
+            throw new RuntimeException(ex);
+        } finally {
+            try {
+                is.close();
+            } catch (final IOException ignore) {
+                // ignore
+            }
+        }
+
+        return props;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringBuilderUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringBuilderUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringBuilderUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringBuilderUtils.java Fri Jul  6 10:51:16 2012
@@ -1,36 +1,36 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-public class StringBuilderUtils {
-
-    public static void appendBuf(final StringBuilder buf, final String formatString, final Object... args) {
-        buf.append(String.format(formatString, args));
-    }
-
-    /**
-     * @deprecated - use a {@link StringBuilder} instead!
-     */
-    @Deprecated
-    public static void appendBuf(final StringBuffer buf, final String formatString, final Object... args) {
-        buf.append(String.format(formatString, args));
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+public class StringBuilderUtils {
+
+    public static void appendBuf(final StringBuilder buf, final String formatString, final Object... args) {
+        buf.append(String.format(formatString, args));
+    }
+
+    /**
+     * @deprecated - use a {@link StringBuilder} instead!
+     */
+    @Deprecated
+    public static void appendBuf(final StringBuffer buf, final String formatString, final Object... args) {
+        buf.append(String.format(formatString, args));
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/StringUtils.java Fri Jul  6 10:51:16 2012
@@ -1,360 +1,388 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import com.google.common.collect.Lists;
-
-public final class StringUtils {
-    private StringUtils() {
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // naturalName, naturalize, simpleName, camel, memberIdFor
-    // ////////////////////////////////////////////////////////////
-
-    public static String naturalName(final String name) {
-
-        int pos = 0;
-
-        // find first upper case character
-        while ((pos < name.length()) && Character.isLowerCase(name.charAt(pos))) {
-            pos++;
-        }
-
-        if (pos == name.length()) {
-            return "invalid name";
-        }
-        return naturalize(name, pos);
-    }
-
-    public static String naturalize(final String name) {
-        return naturalize(name, 0);
-    }
-
-    private static String naturalize(final String name, final int startingPosition) {
-        if (name.length() <= startingPosition) {
-            throw new IllegalArgumentException("string shorter than starting position provided");
-        }
-        final StringBuffer s = new StringBuffer(name.length() - startingPosition);
-        for (int j = startingPosition; j < name.length(); j++) { // process
-                                                                 // english name
-                                                                 // - add spaces
-            if ((j > startingPosition) && isStartOfNewWord(name.charAt(j), name.charAt(j - 1))) {
-                s.append(' ');
-            }
-            if (j == startingPosition) {
-                s.append(Character.toUpperCase(name.charAt(j)));
-            } else {
-                s.append(name.charAt(j));
-            }
-        }
-        final String str = s.toString();
-        return str;
-    }
-
-    private static boolean isStartOfNewWord(final char c, final char previousChar) {
-        return Character.isUpperCase(c) || Character.isDigit(c) && !Character.isDigit(previousChar);
-    }
-
-    public static String simpleName(final String str) {
-        final int lastDot = str.lastIndexOf('.');
-        if (lastDot == -1) {
-            return str;
-        }
-        if (lastDot == str.length() - 1) {
-            throw new IllegalArgumentException("Name cannot end in '.'");
-        }
-        return str.substring(lastDot + 1);
-    }
-
-    public static String camel(final String name) {
-        final StringBuffer b = new StringBuffer(name.length());
-        final StringTokenizer t = new StringTokenizer(name);
-        b.append(t.nextToken());
-        while (t.hasMoreTokens()) {
-            final String token = t.nextToken();
-            b.append(token.substring(0, 1).toUpperCase()); // replace spaces
-                                                           // with
-            // camelCase
-            b.append(token.substring(1));
-        }
-        return b.toString();
-    }
-
-    // TODO: combine with camel
-    public static String camelLowerFirst(final String name) {
-        final StringBuffer b = new StringBuffer(name.length());
-        final StringTokenizer t = new StringTokenizer(name);
-        b.append(lowerFirst(t.nextToken()));
-        while (t.hasMoreTokens()) {
-            final String token = t.nextToken();
-            b.append(token.substring(0, 1).toUpperCase()); // replace spaces
-                                                           // with camelCase
-            b.append(token.substring(1).toLowerCase());
-        }
-        return b.toString();
-    }
-
-    public static String pascal(final String name) {
-        return capitalize(camel(name));
-    }
-
-    public static String memberIdFor(final String member) {
-        return lowerLeading(camel(member));
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // capitalize, lowerFirst, firstWord
-    // ////////////////////////////////////////////////////////////
-
-    public static String capitalize(final String str) {
-        if (str == null || str.length() == 0) {
-            return str;
-        }
-        if (str.length() == 1) {
-            return str.toUpperCase();
-        }
-        return Character.toUpperCase(str.charAt(0)) + str.substring(1);
-    }
-
-    /**
-     * Simply forces first char to be lower case.
-     */
-    public static String lowerFirst(final String str) {
-        if (isNullOrEmpty(str)) {
-            return str;
-        }
-        if (str.length() == 1) {
-            return str.toLowerCase();
-        }
-        return str.substring(0, 1).toLowerCase() + str.substring(1);
-    }
-
-    public static String lowerLeading(final String str) {
-        return lowerFirst(str);
-    }
-
-    public static String firstWord(final String line) {
-        final String[] split = line.split(" ");
-        return split[0];
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // isNullOrEmpty, nullSafeEquals
-    // ////////////////////////////////////////////////////////////
-
-    public static boolean isNullOrEmpty(final String str) {
-        return str == null || str.isEmpty();
-    }
-
-    public static boolean nullSafeEquals(final String str1, final String str2) {
-        if (str1 == null || str2 == null) {
-            return false;
-        }
-        return str1.equals(str2);
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // in, combine, combinePaths, splitOnCommas
-    // ////////////////////////////////////////////////////////////
-
-    public static boolean in(final String str, final String[] strings) {
-        for (final String strCandidate : strings) {
-            if (strCandidate.equals(str)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static String combine(final List<String> list) {
-        final StringBuffer buf = new StringBuffer();
-        for (final String message : list) {
-            if (list.size() > 1) {
-                buf.append("; ");
-            }
-            buf.append(message);
-        }
-        return buf.toString();
-    }
-
-    public static String combinePaths(final String path, final String... furtherPaths) {
-        final StringBuilder buf = new StringBuilder(path);
-        for (final String furtherPath : furtherPaths) {
-            if (buf.charAt(buf.length() - 1) != File.separatorChar) {
-                buf.append(File.separatorChar);
-            }
-            buf.append(furtherPath);
-        }
-        return buf.toString();
-    }
-
-    public static List<String> splitOnCommas(final String commaSeparatedList) {
-        if (commaSeparatedList == null) {
-            return null;
-        }
-        final String removeLeadingWhiteSpace = removeLeadingWhiteSpace(commaSeparatedList);
-        // special handling
-        if (removeLeadingWhiteSpace.length() == 0) {
-            return Collections.emptyList();
-        }
-        final String[] splitAsArray = removeLeadingWhiteSpace.split("\\W*,\\W*");
-        return Arrays.asList(splitAsArray);
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // commaSeparatedClassNames
-    // ////////////////////////////////////////////////////////////
-
-    public static String commaSeparatedClassNames(final List<Object> objects) {
-        final StringBuilder buf = new StringBuilder();
-        int i = 0;
-        for (final Object object : objects) {
-            if (i++ > 0) {
-                buf.append(',');
-            }
-            buf.append(object.getClass().getName());
-        }
-        return buf.toString();
-    }
-
-    private static final char CARRIAGE_RETURN = '\n';
-    private static final char LINE_FEED = '\r';
-
-    /**
-     * Converts any <tt>\n</tt> to <tt>line.separator</tt>
-     * 
-     * @param string
-     * @return
-     */
-    public static String lineSeparated(final String string) {
-        final StringBuilder buf = new StringBuilder();
-        final String lineSeparator = System.getProperty("line.separator");
-        boolean lastWasLineFeed = false;
-        for (final char c : string.toCharArray()) {
-            final boolean isLineFeed = c == LINE_FEED;
-            final boolean isCarriageReturn = c == CARRIAGE_RETURN;
-            if (isCarriageReturn) {
-                buf.append(lineSeparator);
-                lastWasLineFeed = false;
-            } else {
-                if (lastWasLineFeed) {
-                    buf.append(LINE_FEED);
-                }
-                if (isLineFeed) {
-                    lastWasLineFeed = true;
-                } else {
-                    buf.append(c);
-                    lastWasLineFeed = false;
-                }
-            }
-        }
-        if (lastWasLineFeed) {
-            buf.append(LINE_FEED);
-        }
-        return buf.toString();
-    }
-
-    // ////////////////////////////////////////////////////////////
-    // removeTabs, removeLeadingWhiteSpace, stripLeadingSlash, stripNewLines,
-    // normalize
-    // ////////////////////////////////////////////////////////////
-
-    public static String removeTabs(final String text) {
-        // quick return - jvm java should always return here
-        if (text.indexOf('\t') == -1) {
-            return text;
-        }
-        final StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < text.length(); i++) {
-            // a bit clunky to stay with j# api
-            if (text.charAt(i) != '\t') {
-                buf.append(text.charAt(i));
-            }
-        }
-        return buf.toString();
-    }
-
-    public static String removeLeadingWhiteSpace(final String str) {
-        if (str == null) {
-            return null;
-        }
-        return str.replaceAll("^\\W*", "");
-    }
-
-    public static String stripNewLines(final String str) {
-        return str.replaceAll("[\r\n]", "");
-    }
-
-    public static String stripLeadingSlash(final String path) {
-        if (!path.startsWith("/")) {
-            return path;
-        }
-        if (path.length() < 2) {
-            return "";
-        }
-        return path.substring(1);
-    }
-
-    /**
-     * Condenses any whitespace to a single character
-     * 
-     * @param str
-     * @return
-     */
-    public static String normalized(final String str) {
-        if (str == null) {
-            return null;
-        }
-        return str.replaceAll("\\s+", " ");
-    }
-
-    public static String[] normalized(final String... strings) {
-        final List<String> stringList = Lists.newArrayList();
-        for (final String string : strings) {
-            stringList.add(normalized(string));
-        }
-        return stringList.toArray(new String[] {});
-    }
-
-    public static String removePrefix(final String name, final String prefix) {
-        if (name.startsWith(prefix)) {
-            return name.substring(prefix.length());
-        } else {
-            return name;
-        }
-    }
-
-    public static <T> T coalesce(final T... strings) {
-        for (final T str : strings) {
-            if (str != null) {
-                return str;
-            }
-        }
-        return null;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public final class StringUtils {
+    private StringUtils() {
+    }
+
+    private static Function<String, String> LOWER_CASE_THEN_CAPITALIZE = new Function<String, String>() {
+        @Override
+        public String apply(String input) {
+            return StringUtils.capitalize(input.toLowerCase());
+        }
+    };
+
+    private static Function<String, String> UPPER_CASE = new Function<String, String>() {
+        @Override
+        public String apply(String input) {
+            return input.toUpperCase();
+        }
+    };
+
+    // ////////////////////////////////////////////////////////////
+    // naturalName, naturalize, simpleName, camel, memberIdFor
+    // ////////////////////////////////////////////////////////////
+
+    public static String naturalName(final String name) {
+
+        int pos = 0;
+
+        // find first upper case character
+        while ((pos < name.length()) && Character.isLowerCase(name.charAt(pos))) {
+            pos++;
+        }
+
+        if (pos == name.length()) {
+            return "invalid name";
+        }
+        return naturalize(name, pos);
+    }
+
+    public static String naturalize(final String name) {
+        return naturalize(name, 0);
+    }
+
+    private static String naturalize(final String name, final int startingPosition) {
+        if (name.length() <= startingPosition) {
+            throw new IllegalArgumentException("string shorter than starting position provided");
+        }
+        final StringBuffer s = new StringBuffer(name.length() - startingPosition);
+        for (int j = startingPosition; j < name.length(); j++) { // process
+                                                                 // english name
+                                                                 // - add spaces
+            if ((j > startingPosition) && isStartOfNewWord(name.charAt(j), name.charAt(j - 1))) {
+                s.append(' ');
+            }
+            if (j == startingPosition) {
+                s.append(Character.toUpperCase(name.charAt(j)));
+            } else {
+                s.append(name.charAt(j));
+            }
+        }
+        final String str = s.toString();
+        return str;
+    }
+
+    private static boolean isStartOfNewWord(final char c, final char previousChar) {
+        return Character.isUpperCase(c) || Character.isDigit(c) && !Character.isDigit(previousChar);
+    }
+
+    public static String simpleName(final String str) {
+        final int lastDot = str.lastIndexOf('.');
+        if (lastDot == -1) {
+            return str;
+        }
+        if (lastDot == str.length() - 1) {
+            throw new IllegalArgumentException("Name cannot end in '.'");
+        }
+        return str.substring(lastDot + 1);
+    }
+
+    public static String camel(final String name) {
+        final StringBuffer b = new StringBuffer(name.length());
+        final StringTokenizer t = new StringTokenizer(name);
+        b.append(t.nextToken());
+        while (t.hasMoreTokens()) {
+            final String token = t.nextToken();
+            b.append(token.substring(0, 1).toUpperCase()); // replace spaces
+                                                           // with
+            // camelCase
+            b.append(token.substring(1));
+        }
+        return b.toString();
+    }
+
+    // TODO: combine with camel
+    public static String camelLowerFirst(final String name) {
+        final StringBuffer b = new StringBuffer(name.length());
+        final StringTokenizer t = new StringTokenizer(name);
+        b.append(lowerFirst(t.nextToken()));
+        while (t.hasMoreTokens()) {
+            final String token = t.nextToken();
+            b.append(token.substring(0, 1).toUpperCase()); // replace spaces
+                                                           // with camelCase
+            b.append(token.substring(1).toLowerCase());
+        }
+        return b.toString();
+    }
+
+    public static String pascal(final String name) {
+        return capitalize(camel(name));
+    }
+
+    public static String memberIdFor(final String member) {
+        return lowerLeading(camel(member));
+    }
+
+    // ////////////////////////////////////////////////////////////
+    // capitalize, lowerFirst, firstWord
+    // ////////////////////////////////////////////////////////////
+
+    public static String capitalize(final String str) {
+        if (str == null || str.length() == 0) {
+            return str;
+        }
+        if (str.length() == 1) {
+            return str.toUpperCase();
+        }
+        return Character.toUpperCase(str.charAt(0)) + str.substring(1);
+    }
+
+    /**
+     * Simply forces first char to be lower case.
+     */
+    public static String lowerFirst(final String str) {
+        if (isNullOrEmpty(str)) {
+            return str;
+        }
+        if (str.length() == 1) {
+            return str.toLowerCase();
+        }
+        return str.substring(0, 1).toLowerCase() + str.substring(1);
+    }
+
+    public static String lowerLeading(final String str) {
+        return lowerFirst(str);
+    }
+
+    public static String firstWord(final String line) {
+        final String[] split = line.split(" ");
+        return split[0];
+    }
+
+    // ////////////////////////////////////////////////////////////
+    // isNullOrEmpty, nullSafeEquals
+    // ////////////////////////////////////////////////////////////
+
+    public static boolean isNullOrEmpty(final String str) {
+        return str == null || str.isEmpty();
+    }
+
+    public static boolean nullSafeEquals(final String str1, final String str2) {
+        if (str1 == null || str2 == null) {
+            return false;
+        }
+        return str1.equals(str2);
+    }
+
+    // ////////////////////////////////////////////////////////////
+    // in, combine, combinePaths, splitOnCommas
+    // ////////////////////////////////////////////////////////////
+
+    public static boolean in(final String str, final String[] strings) {
+        for (final String strCandidate : strings) {
+            if (strCandidate.equals(str)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String combine(final List<String> list) {
+        final StringBuffer buf = new StringBuffer();
+        for (final String message : list) {
+            if (list.size() > 1) {
+                buf.append("; ");
+            }
+            buf.append(message);
+        }
+        return buf.toString();
+    }
+
+    public static String combinePaths(final String path, final String... furtherPaths) {
+        final StringBuilder buf = new StringBuilder(path);
+        for (final String furtherPath : furtherPaths) {
+            if (buf.charAt(buf.length() - 1) != File.separatorChar) {
+                buf.append(File.separatorChar);
+            }
+            buf.append(furtherPath);
+        }
+        return buf.toString();
+    }
+
+    public static List<String> splitOnCommas(final String commaSeparatedList) {
+        if (commaSeparatedList == null) {
+            return null;
+        }
+        final String removeLeadingWhiteSpace = removeLeadingWhiteSpace(commaSeparatedList);
+        // special handling
+        if (removeLeadingWhiteSpace.length() == 0) {
+            return Collections.emptyList();
+        }
+        final String[] splitAsArray = removeLeadingWhiteSpace.split("\\W*,\\W*");
+        return Arrays.asList(splitAsArray);
+    }
+
+    // ////////////////////////////////////////////////////////////
+    // commaSeparatedClassNames
+    // ////////////////////////////////////////////////////////////
+
+    public static String commaSeparatedClassNames(final List<Object> objects) {
+        final StringBuilder buf = new StringBuilder();
+        int i = 0;
+        for (final Object object : objects) {
+            if (i++ > 0) {
+                buf.append(',');
+            }
+            buf.append(object.getClass().getName());
+        }
+        return buf.toString();
+    }
+
+    private static final char CARRIAGE_RETURN = '\n';
+    private static final char LINE_FEED = '\r';
+
+    /**
+     * Converts any <tt>\n</tt> to <tt>line.separator</tt>
+     * 
+     * @param string
+     * @return
+     */
+    public static String lineSeparated(final String string) {
+        final StringBuilder buf = new StringBuilder();
+        final String lineSeparator = System.getProperty("line.separator");
+        boolean lastWasLineFeed = false;
+        for (final char c : string.toCharArray()) {
+            final boolean isLineFeed = c == LINE_FEED;
+            final boolean isCarriageReturn = c == CARRIAGE_RETURN;
+            if (isCarriageReturn) {
+                buf.append(lineSeparator);
+                lastWasLineFeed = false;
+            } else {
+                if (lastWasLineFeed) {
+                    buf.append(LINE_FEED);
+                }
+                if (isLineFeed) {
+                    lastWasLineFeed = true;
+                } else {
+                    buf.append(c);
+                    lastWasLineFeed = false;
+                }
+            }
+        }
+        if (lastWasLineFeed) {
+            buf.append(LINE_FEED);
+        }
+        return buf.toString();
+    }
+
+    // ////////////////////////////////////////////////////////////
+    // removeTabs, removeLeadingWhiteSpace, stripLeadingSlash, stripNewLines,
+    // normalize
+    // ////////////////////////////////////////////////////////////
+
+    public static String removeTabs(final String text) {
+        // quick return - jvm java should always return here
+        if (text.indexOf('\t') == -1) {
+            return text;
+        }
+        final StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < text.length(); i++) {
+            // a bit clunky to stay with j# api
+            if (text.charAt(i) != '\t') {
+                buf.append(text.charAt(i));
+            }
+        }
+        return buf.toString();
+    }
+
+    public static String removeLeadingWhiteSpace(final String str) {
+        if (str == null) {
+            return null;
+        }
+        return str.replaceAll("^\\W*", "");
+    }
+
+    public static String stripNewLines(final String str) {
+        return str.replaceAll("[\r\n]", "");
+    }
+
+    public static String stripLeadingSlash(final String path) {
+        if (!path.startsWith("/")) {
+            return path;
+        }
+        if (path.length() < 2) {
+            return "";
+        }
+        return path.substring(1);
+    }
+
+    /**
+     * Condenses any whitespace to a single character
+     * 
+     * @param str
+     * @return
+     */
+    public static String normalized(final String str) {
+        if (str == null) {
+            return null;
+        }
+        return str.replaceAll("\\s+", " ");
+    }
+
+    public static String[] normalized(final String... strings) {
+        final List<String> stringList = Lists.newArrayList();
+        for (final String string : strings) {
+            stringList.add(normalized(string));
+        }
+        return stringList.toArray(new String[] {});
+    }
+
+    public static String removePrefix(final String name, final String prefix) {
+        if (name.startsWith(prefix)) {
+            return name.substring(prefix.length());
+        } else {
+            return name;
+        }
+    }
+
+    public static <T> T coalesce(final T... strings) {
+        for (final T str : strings) {
+            if (str != null) {
+                return str;
+            }
+        }
+        return null;
+    }
+
+    public static String enumTitle(String string) {
+        return Joiner.on(" ").join(Iterables.transform(Splitter.on("_").split(string), LOWER_CASE_THEN_CAPITALIZE));
+    }
+
+    public static String enumDeTitle(String string) {
+        return Joiner.on("_").join(Iterables.transform(Splitter.on(" ").split(string), UPPER_CASE));
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Threads.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Threads.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Threads.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/Threads.java Fri Jul  6 10:51:16 2012
@@ -1,33 +1,33 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-public class Threads {
-
-    private Threads() {
-    }
-
-    public static Thread startThread(final Runnable target, final String name) {
-        final Thread thread = new Thread(target, name);
-        thread.start();
-        return thread;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+public class Threads {
+
+    private Threads() {
+    }
+
+    public static Thread startThread(final Runnable target, final String name) {
+        final Thread thread = new Thread(target, name);
+        thread.start();
+        return thread;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ThrowableUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ThrowableUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ThrowableUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ThrowableUtils.java Fri Jul  6 10:51:16 2012
@@ -1,43 +1,43 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-public final class ThrowableUtils {
-
-    public static String stackTraceFor(final Throwable exception) {
-        ByteArrayOutputStream baos = null;
-        try {
-            baos = new ByteArrayOutputStream();
-            exception.printStackTrace(new PrintStream(baos));
-            return baos.toString();
-        } finally {
-            if (baos != null) {
-                try {
-                    baos.close();
-                } catch (final IOException ignore) {
-                }
-            }
-        }
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public final class ThrowableUtils {
+
+    public static String stackTraceFor(final Throwable exception) {
+        ByteArrayOutputStream baos = null;
+        try {
+            baos = new ByteArrayOutputStream();
+            exception.printStackTrace(new PrintStream(baos));
+            return baos.toString();
+        } finally {
+            if (baos != null) {
+                try {
+                    baos.close();
+                } catch (final IOException ignore) {
+                }
+            }
+        }
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ToString.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ToString.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ToString.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/ToString.java Fri Jul  6 10:51:16 2012
@@ -1,181 +1,181 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public final class ToString {
-
-    public static String createName(final Object forObject) {
-        final StringBuffer buffer = new StringBuffer();
-        createName(forObject, buffer);
-        return buffer.toString();
-    }
-
-    private static void createName(final Object forObject, final StringBuffer string) {
-        string.append(name(forObject));
-        string.append("@");
-        string.append(Integer.toHexString(forObject.hashCode()));
-    }
-
-    public static String name(final Object forObject) {
-        final String name = forObject.getClass().getName();
-        return name.substring(name.lastIndexOf('.') + 1);
-    }
-
-    public static String timestamp(final Date date) {
-        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
-        return date == null ? "" : simpleDateFormat.format(date);
-    }
-
-    public static ToString createWithIdentifier(final Object object) {
-        return new ToString(object);
-    }
-
-    public static ToString createAnonymous(final Object object) {
-        final ToString string = new ToString();
-        string.append(name(object));
-        string.append("[");
-        return string;
-    }
-
-    private boolean addComma = false;
-    private final StringBuffer buf;
-    private boolean useLineBreaks;
-
-    private ToString() {
-        buf = new StringBuffer();
-    }
-
-    public ToString(final Object forObject) {
-        buf = new StringBuffer();
-        createName(forObject, buf);
-        buf.append("[");
-    }
-
-    public ToString(final Object forObject, final int id) {
-        buf = new StringBuffer();
-        buf.append(name(forObject));
-        buf.append("#");
-        buf.append(id);
-        buf.append("[");
-    }
-
-    public ToString(final Object forObject, final String text) {
-        this(forObject);
-        buf.append(text);
-        addComma = text.length() > 0;
-    }
-
-    public ToString append(final String text) {
-        buf.append(text);
-        return this;
-    }
-
-    public ToString append(final String name, final boolean flag) {
-        append(name, flag ? "true" : "false");
-        return this;
-    }
-
-    public ToString append(final String name, final byte number) {
-        append(name, Byte.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final double number) {
-        append(name, Double.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final float number) {
-        append(name, Float.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final int number) {
-        append(name, Integer.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final long number) {
-        append(name, Long.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final Object object) {
-        append(name, object == null ? "null" : object.toString());
-        return this;
-    }
-
-    public ToString append(final String name, final short number) {
-        append(name, Short.toString(number));
-        return this;
-    }
-
-    public ToString append(final String name, final String string) {
-        if (addComma) {
-            this.buf.append(',');
-            if (useLineBreaks) {
-                this.buf.append("\n\t");
-            }
-        } else {
-            addComma = true;
-        }
-        this.buf.append(name);
-        this.buf.append('=');
-        this.buf.append(string);
-
-        return this;
-    }
-
-    public ToString appendAsHex(final String name, final long number) {
-        append(name, "#" + Long.toHexString(number));
-        return this;
-    }
-
-    public void appendAsTimestamp(final String name, final Date date) {
-        final String dateString = timestamp(date);
-        append(name, dateString);
-    }
-
-    public void appendTruncated(final String name, final String string, final int maxLength) {
-        if (string.length() > maxLength) {
-            append(name, string.substring(0, maxLength));
-            append("...");
-        } else {
-            append(name, string);
-        }
-    }
-
-    public void setAddComma() {
-        this.addComma = true;
-    }
-
-    public void setUseLineBreaks(final boolean useLineBreaks) {
-        this.useLineBreaks = useLineBreaks;
-    }
-
-    @Override
-    public String toString() {
-        buf.append(']');
-        return buf.toString();
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public final class ToString {
+
+    public static String createName(final Object forObject) {
+        final StringBuffer buffer = new StringBuffer();
+        createName(forObject, buffer);
+        return buffer.toString();
+    }
+
+    private static void createName(final Object forObject, final StringBuffer string) {
+        string.append(name(forObject));
+        string.append("@");
+        string.append(Integer.toHexString(forObject.hashCode()));
+    }
+
+    public static String name(final Object forObject) {
+        final String name = forObject.getClass().getName();
+        return name.substring(name.lastIndexOf('.') + 1);
+    }
+
+    public static String timestamp(final Date date) {
+        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
+        return date == null ? "" : simpleDateFormat.format(date);
+    }
+
+    public static ToString createWithIdentifier(final Object object) {
+        return new ToString(object);
+    }
+
+    public static ToString createAnonymous(final Object object) {
+        final ToString string = new ToString();
+        string.append(name(object));
+        string.append("[");
+        return string;
+    }
+
+    private boolean addComma = false;
+    private final StringBuffer buf;
+    private boolean useLineBreaks;
+
+    private ToString() {
+        buf = new StringBuffer();
+    }
+
+    public ToString(final Object forObject) {
+        buf = new StringBuffer();
+        createName(forObject, buf);
+        buf.append("[");
+    }
+
+    public ToString(final Object forObject, final int id) {
+        buf = new StringBuffer();
+        buf.append(name(forObject));
+        buf.append("#");
+        buf.append(id);
+        buf.append("[");
+    }
+
+    public ToString(final Object forObject, final String text) {
+        this(forObject);
+        buf.append(text);
+        addComma = text.length() > 0;
+    }
+
+    public ToString append(final String text) {
+        buf.append(text);
+        return this;
+    }
+
+    public ToString append(final String name, final boolean flag) {
+        append(name, flag ? "true" : "false");
+        return this;
+    }
+
+    public ToString append(final String name, final byte number) {
+        append(name, Byte.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final double number) {
+        append(name, Double.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final float number) {
+        append(name, Float.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final int number) {
+        append(name, Integer.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final long number) {
+        append(name, Long.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final Object object) {
+        append(name, object == null ? "null" : object.toString());
+        return this;
+    }
+
+    public ToString append(final String name, final short number) {
+        append(name, Short.toString(number));
+        return this;
+    }
+
+    public ToString append(final String name, final String string) {
+        if (addComma) {
+            this.buf.append(',');
+            if (useLineBreaks) {
+                this.buf.append("\n\t");
+            }
+        } else {
+            addComma = true;
+        }
+        this.buf.append(name);
+        this.buf.append('=');
+        this.buf.append(string);
+
+        return this;
+    }
+
+    public ToString appendAsHex(final String name, final long number) {
+        append(name, "#" + Long.toHexString(number));
+        return this;
+    }
+
+    public void appendAsTimestamp(final String name, final Date date) {
+        final String dateString = timestamp(date);
+        append(name, dateString);
+    }
+
+    public void appendTruncated(final String name, final String string, final int maxLength) {
+        if (string.length() > maxLength) {
+            append(name, string.substring(0, maxLength));
+            append("...");
+        } else {
+            append(name, string);
+        }
+    }
+
+    public void setAddComma() {
+        this.addComma = true;
+    }
+
+    public void setUseLineBreaks(final boolean useLineBreaks) {
+        this.useLineBreaks = useLineBreaks;
+    }
+
+    @Override
+    public String toString() {
+        buf.append(']');
+        return buf.toString();
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/WrapperUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/WrapperUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/WrapperUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/WrapperUtils.java Fri Jul  6 10:51:16 2012
@@ -1,61 +1,61 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.lang;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public final class WrapperUtils {
-
-    private WrapperUtils() {
-    }
-
-    private static Map<Class<?>, Class<?>> wrapperClasses = new HashMap<Class<?>, Class<?>>();
-
-    static {
-        wrapperClasses.put(boolean.class, Boolean.class);
-        wrapperClasses.put(byte.class, Byte.class);
-        wrapperClasses.put(char.class, Character.class);
-        wrapperClasses.put(short.class, Short.class);
-        wrapperClasses.put(int.class, Integer.class);
-        wrapperClasses.put(long.class, Long.class);
-        wrapperClasses.put(float.class, Float.class);
-        wrapperClasses.put(double.class, Double.class);
-    }
-
-    public static Class<?> wrap(final Class<?> primitiveClass) {
-        return wrapperClasses.get(primitiveClass);
-    }
-
-    public static Class<?>[] wrapAsNecessary(final Class<?>[] classes) {
-        final List<Class<?>> wrappedClasses = new ArrayList<Class<?>>();
-        for (final Class<?> cls : classes) {
-            if (cls.isPrimitive()) {
-                wrappedClasses.add(wrap(cls));
-            } else {
-                wrappedClasses.add(cls);
-            }
-        }
-        return wrappedClasses.toArray(new Class[] {});
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.lang;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public final class WrapperUtils {
+
+    private WrapperUtils() {
+    }
+
+    private static Map<Class<?>, Class<?>> wrapperClasses = new HashMap<Class<?>, Class<?>>();
+
+    static {
+        wrapperClasses.put(boolean.class, Boolean.class);
+        wrapperClasses.put(byte.class, Byte.class);
+        wrapperClasses.put(char.class, Character.class);
+        wrapperClasses.put(short.class, Short.class);
+        wrapperClasses.put(int.class, Integer.class);
+        wrapperClasses.put(long.class, Long.class);
+        wrapperClasses.put(float.class, Float.class);
+        wrapperClasses.put(double.class, Double.class);
+    }
+
+    public static Class<?> wrap(final Class<?> primitiveClass) {
+        return wrapperClasses.get(primitiveClass);
+    }
+
+    public static Class<?>[] wrapAsNecessary(final Class<?>[] classes) {
+        final List<Class<?>> wrappedClasses = new ArrayList<Class<?>>();
+        for (final Class<?> cls : classes) {
+            if (cls.isPrimitive()) {
+                wrappedClasses.add(wrap(cls));
+            } else {
+                wrappedClasses.add(cls);
+            }
+        }
+        return wrappedClasses.toArray(new Class[] {});
+    }
+
+}



Mime
View raw message