]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/PrimitiveUtils.java
Fix ressource leak
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / PrimitiveUtils.java
index a37ae72257f590bd3c71110a5d0dcaff0c7cbe50..4268b8b030a1e8deceba3d79913ae09e12c8f7fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.argeo.slc.core.execution;
 
 /** Converts to and from primitive types. */
@@ -51,6 +50,8 @@ public class PrimitiveUtils {
        public static Class<?> typeAsClass(String type) {
                if (PrimitiveAccessor.TYPE_STRING.equals(type))
                        return String.class;
+               else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
+                       return char[].class;
                else if (PrimitiveAccessor.TYPE_INTEGER.equals(type))
                        return Integer.class;
                else if (PrimitiveAccessor.TYPE_LONG.equals(type))
@@ -69,6 +70,8 @@ public class PrimitiveUtils {
        public static String classAsType(Class<?> clss) {
                if (String.class.isAssignableFrom(clss))
                        return PrimitiveAccessor.TYPE_STRING;
+               else if (char[].class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_PASSWORD;
                else if (Integer.class.isAssignableFrom(clss))
                        return PrimitiveAccessor.TYPE_INTEGER;
                else if (Long.class.isAssignableFrom(clss))
@@ -83,9 +86,12 @@ public class PrimitiveUtils {
                        return null;
        }
 
+       /** Parse string as an object. Passwords are returned as String.*/
        public static Object convert(String type, String str) {
                if (PrimitiveAccessor.TYPE_STRING.equals(type)) {
                        return str;
+               } else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
+                       return str;
                } else if (PrimitiveAccessor.TYPE_INTEGER.equals(type)) {
                        return (Integer.parseInt(str));
                } else if (PrimitiveAccessor.TYPE_LONG.equals(type)) {