Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 249254 - [ds tooling] Provide type-specific validation of <property> element
Summary: [ds tooling] Provide type-specific validation of <property> element
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Chris Aniszczyk CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-30 22:04 EDT by Simon Archer CLA
Modified: 2008-10-19 14:22 EDT (History)
2 users (show)

See Also:


Attachments
DSErrorReporter updates (10.65 KB, text/plain)
2008-10-03 18:28 EDT, Rafael Oliveira Nóbrega CLA
no flags Details
DSErrorReporter updates (6.04 KB, patch)
2008-10-07 16:37 EDT, Rafael Oliveira Nóbrega CLA
caniszczyk: iplog+
Details | Diff
mylyn/context/zip (1.29 KB, application/octet-stream)
2008-10-19 14:21 EDT, Chris Aniszczyk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Archer CLA 2008-09-30 22:04:41 EDT
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>
Comment 1 Rafael Oliveira Nóbrega CLA 2008-10-03 13:55:25 EDT
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? :)
Comment 2 Simon Archer CLA 2008-10-03 14:07:34 EDT
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.
Comment 3 Chris Aniszczyk CLA 2008-10-03 17:53:53 EDT
Let me know when you're ready with the patch Rafael.
Comment 4 Rafael Oliveira Nóbrega CLA 2008-10-03 18:28:31 EDT
Created attachment 114243 [details]
DSErrorReporter updates

validation for property's specific type values.
Comment 5 Rafael Oliveira Nóbrega CLA 2008-10-07 16:37:28 EDT
Created attachment 114482 [details]
DSErrorReporter updates

I created this new patch because the last one was out-of-sync. :)
Comment 6 Chris Aniszczyk CLA 2008-10-19 14:21:55 EDT
done.

> 20091019

Thanks Rafael!
Comment 7 Chris Aniszczyk CLA 2008-10-19 14:21:59 EDT
Created attachment 115518 [details]
mylyn/context/zip