[jboss-svn-commits] JBoss Common SVN: r2520 - common-core/trunk/src/main/java/org/jboss/util/propertyeditor.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Aug 30 12:11:39 EDT 2007


Author: dimitris at jboss.org
Date: 2007-08-30 12:11:39 -0400 (Thu, 30 Aug 2007)
New Revision: 2520

Modified:
   common-core/trunk/src/main/java/org/jboss/util/propertyeditor/PropertiesEditor.java
Log:
JBCOMMON-32 - org.jboss.util.propertyeditor.PropertiesEditor should preserve the string text

Modified: common-core/trunk/src/main/java/org/jboss/util/propertyeditor/PropertiesEditor.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/util/propertyeditor/PropertiesEditor.java	2007-08-29 12:54:40 UTC (rev 2519)
+++ common-core/trunk/src/main/java/org/jboss/util/propertyeditor/PropertiesEditor.java	2007-08-30 16:11:39 UTC (rev 2520)
@@ -1,32 +1,28 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.util.propertyeditor;
 
-import java.beans.PropertyEditorSupport;
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.StringWriter;
-import java.io.PrintWriter;
 import java.util.Iterator;
 import java.util.Properties;
 
@@ -40,16 +36,10 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public class PropertiesEditor extends PropertyEditorSupport
+public class PropertiesEditor extends TextPropertyEditorSupport
 {
-
    /**
-    * To be consistent with the Properties.load and .store methods.
-    */
-   private static final String ENC = "ISO-8859-1";
-
-   /**
-    * Initializes a Properties object with text value
+    * Returns a Properties object initialized with current getAsText value
     * interpretted as a .properties file contents. This replaces any
     * references of the form ${x} with the corresponding system property. 
     *
@@ -57,13 +47,14 @@
     *
     * @throws NestedRuntimeException  An IOException occured.
     */
-   public void setAsText(String propsText)
+   public Object getValue()
    {
       try
       {
          // Load the current key=value properties into a Properties object
+         String propsText = getAsText();
          Properties rawProps = new Properties(System.getProperties());
-         ByteArrayInputStream bais = new ByteArrayInputStream(propsText.getBytes(ENC));
+         ByteArrayInputStream bais = new ByteArrayInputStream(propsText.getBytes());
          rawProps.load(bais);
          // Now go through the rawProps and replace any ${x} refs
          Properties props = new Properties();
@@ -77,30 +68,11 @@
          }
          rawProps.clear();
 
-         setValue(props);
+         return props;
       }
       catch (IOException e)
       {
          throw new NestedRuntimeException(e);
       }
    }
-
-   /**
-    * Returns the properties as text.
-    */
-   public String getAsText()
-   {
-      try
-      {
-         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-         Properties p = (Properties)getValue();
-         p.store(baos, null);
-         return baos.toString(ENC);
-      }
-      catch (IOException e)
-      {
-         throw new NestedRuntimeException(e);
-      }
-   }
-
 }




More information about the jboss-svn-commits mailing list