[jboss-svn-commits] JBoss Common SVN: r2960 - in jbossxb/trunk/src: test/java/org/jboss/test/xb/builder/object and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 16 11:50:36 EST 2009


Author: alex.loubyansky at jboss.com
Date: 2009-01-16 11:50:36 -0500 (Fri, 16 Jan 2009)
New Revision: 2960

Added:
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/support/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/support/Root.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/test/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacementUnitTestCase.java
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/test/
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacement_testPropertyReplacement.xml
Modified:
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java
Log:
JBXB-164

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java	2009-01-16 10:46:42 UTC (rev 2959)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java	2009-01-16 16:50:36 UTC (rev 2960)
@@ -24,6 +24,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.namespace.NamespaceContext;
 
+import org.jboss.util.StringPropertyReplacer;
 import org.jboss.xb.binding.metadata.ValueMetaData;
 
 /**
@@ -45,10 +46,18 @@
                            NamespaceContext nsCtx,
                            String value)
    {
-      if(value != null && binding.isNormalizeSpace())
-         value = value.trim();
+      TypeBinding type = binding.getType();
+
+      if(value != null)
+      {
+         if(binding.isNormalizeSpace())
+            value = value.trim();
+
+         SchemaBinding schema = binding.getSchema();
+         if(schema.isReplacePropertyRefs())
+            value = StringPropertyReplacer.replaceProperties(value);
+      }
       
-      TypeBinding type = binding.getType();
       ValueMetaData valueMetaData = binding.getValueMetaData();
       return type == null ? value : type.getCharactersHandler().unmarshal(attrName, type, nsCtx, valueMetaData, value);
    }

Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/support/Root.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/support/Root.java	                        (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/support/Root.java	2009-01-16 16:50:36 UTC (rev 2960)
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+package org.jboss.test.xb.builder.object.propertyrefs.support;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A Root.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(normalizeSpace=true, replacePropertyRefs=true)
+public class Root
+{
+   private int min;
+   private int max;
+   private int value;
+   
+   @XmlAttribute
+   public int getMin()
+   {
+      return min;
+   }
+   
+   public void setMin(int min)
+   {
+      this.min = min;
+   }
+   
+   public int getMax()
+   {
+      return max;
+   }
+   
+   public void setMax(int max)
+   {
+      this.max = max;
+   }
+   
+   @XmlValue
+   public int getValue()
+   {
+      return value;
+   }
+   
+   public void setValue(int value)
+   {
+      this.value = value;
+   }
+}

Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacementUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacementUnitTestCase.java	                        (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacementUnitTestCase.java	2009-01-16 16:50:36 UTC (rev 2960)
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.jboss.test.xb.builder.object.propertyrefs.test;
+
+import org.jboss.test.xb.builder.AbstractBuilderTest;
+import org.jboss.test.xb.builder.object.propertyrefs.support.Root;
+
+/**
+ * A PropertyReplacementUnitTestCase.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyReplacementUnitTestCase extends AbstractBuilderTest
+{
+   public PropertyReplacementUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPropertyReplacement() throws Exception
+   {
+      String minName = getClass().getName() + "_" + getName() + ".min";
+      String maxName = getClass().getName() + "_" + getName() + ".max";
+      String valName = getClass().getName() + "_" + getName() + ".val";
+      
+      System.setProperty(minName, "1");
+      System.setProperty(maxName, "3");
+      System.setProperty(valName, "2");
+
+      Root root = unmarshalObject(Root.class);
+      assertEquals(1, root.getMin());
+      assertEquals(3, root.getMax());
+      assertEquals(2, root.getValue());
+   }
+}

Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacement_testPropertyReplacement.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacement_testPropertyReplacement.xml	                        (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/propertyrefs/test/PropertyReplacement_testPropertyReplacement.xml	2009-01-16 16:50:36 UTC (rev 2960)
@@ -0,0 +1,4 @@
+<root min="${org.jboss.test.xb.builder.object.propertyrefs.test.PropertyReplacementUnitTestCase_testPropertyReplacement.min}">
+   <max>${org.jboss.test.xb.builder.object.propertyrefs.test.PropertyReplacementUnitTestCase_testPropertyReplacement.max}</max>
+   ${org.jboss.test.xb.builder.object.propertyrefs.test.PropertyReplacementUnitTestCase_testPropertyReplacement.val}
+</root>
\ No newline at end of file




More information about the jboss-svn-commits mailing list