Community
Participate
Working Groups
Using Eclipse 3.5M2. While bug 248453 covers the structural validation of the <property> element, it would be nice if type-specific validation was provided too. Since XML is static in nature this should not be too difficult. 1. Validate that the "value" is legal per the specified "type". So this would be illegal since "Hello" cannot be parsed as Integer. Validation for each of the legal types should be possible. <property name="foo" type="Integer" value="Hello"/> 2. For similar reasons above, the following is illegal: <property name="foo" type="Integer">Hello</property> 3. The OSGi spec says that when you use the body to define multiple values, each item must be on its OWN LINE. So the following is illegal since multiple values per line are illegal (or even because "80 8080 9443" cannot be parsed as an Integer): <property name="ports" type="Integer"> 80 8080 9443 </property> As is this: <property name="ports" type="Integer">80 8080 9443</property> But the following is fine: <property name="ports" type="Integer"> 80 8080 9443 </property> As is this: <property name="ports" type="Integer">80 8080 9443 </property>
done! (Waiting to get a sync code to attach a patch.) For each value of property, do: If(!Boolean && !Character){ //Can't use for these because Booleans has a default value (false) and there's no String constructor to Char. class.forName(...) constructor.getParameterType().equals("java.lang.String") constructor.newInstace(value) catch(exception) reportInvalidType() if(Boolean) if(value != true and false) reportInvalidType() if(Char) if(value.length() > 1) reportInvalidType() Is that ok? :)
That sounds good to me. Apart from properties of type "String", the value for a property must never be an empty string. I believe that this is already being handled; see 248453#c10.
Let me know when you're ready with the patch Rafael.
Created attachment 114243 [details] DSErrorReporter updates validation for property's specific type values.
Created attachment 114482 [details] DSErrorReporter updates I created this new patch because the last one was out-of-sync. :)
done. > 20091019 Thanks Rafael!
Created attachment 115518 [details] mylyn/context/zip