Author: cziegeler
Date: Fri Nov 30 10:53:38 2012
New Revision: 1415581

URL: http://svn.apache.org/viewvc?rev=1415581&view=rev
Log:
FELIX-3793 :  Property of type Character must use unicode value 

Modified:
    
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java
    
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java?rev=1415581&r1=1415580&r2=1415581&view=diff
==============================================================================
--- 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java
 (original)
+++ 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java
 Fri Nov 30 10:53:38 2012
@@ -375,6 +375,21 @@ public class Validator {
                             && property.getType() == PropertyType.Char) {
                 property.setType(PropertyType.Character);
             }
+            // check character property value
+            if ( property.getType() == PropertyType.Char || property.getType() 
== PropertyType.Character ) {
+                if ( property.getValue() != null ) {
+                    if ( property.getValue().length() != 1 ) {
+                        this.logError(property, "Value is not a character: " + 
property.getValue());
+                    }
+                }
+                if ( property.getMultiValue() != null ) {
+                    for(final String value : property.getMultiValue() ) {
+                        if ( value.length() != 1 ) {
+                            this.logError(property, "Value is not a character: 
" + value);
+                        }
+                    }
+                }
+            }
         }
         // TODO might want to check value
     }

Modified: 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=1415581&r1=1415580&r2=1415581&view=diff
==============================================================================
--- 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
 (original)
+++ 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
 Fri Nov 30 10:53:38 2012
@@ -339,7 +339,13 @@ public class ComponentDescriptorIO {
         if ( property.getType() != PropertyType.String ) {
             IOUtils.addAttribute(ai, PROPERTY_ATTR_TYPE, property.getType());
         }
-        IOUtils.addAttribute(ai, PROPERTY_ATTR_VALUE, property.getValue());
+        String value = property.getValue();
+        if ( value != null ) {
+            if ( property.getType() == PropertyType.Character || 
property.getType() == PropertyType.Char ) {
+                value = String.valueOf((int)value.charAt(0));
+            }
+            IOUtils.addAttribute(ai, PROPERTY_ATTR_VALUE, value);
+        }
 
         IOUtils.indent(contentHandler, 2);
         contentHandler.startElement(INNER_NAMESPACE_URI, 
ComponentDescriptorIO.PROPERTY, ComponentDescriptorIO.PROPERTY_QNAME, ai);
@@ -348,7 +354,11 @@ public class ComponentDescriptorIO {
             IOUtils.text(contentHandler, "\n");
             for (int i = 0; i < property.getMultiValue().length; i++) {
                 IOUtils.indent(contentHandler, 3);
-                IOUtils.text(contentHandler, property.getMultiValue()[i]);
+                value = property.getMultiValue()[i];
+                if ( property.getType() == PropertyType.Character || 
property.getType() == PropertyType.Char ) {
+                    value = String.valueOf((int)value.charAt(0));
+                }
+                IOUtils.text(contentHandler, value);
                 IOUtils.newline(contentHandler);
             }
             IOUtils.indent(contentHandler, 2);


Reply via email to