GreenPepper Seeds of GreenPepper
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Type conversion  XML
Forum Index -> Development
Author Message
clapointe


Joined: 23/07/2006 11:51:18
Messages: 116
Offline

With the implementation of type auto conversion, I changed two things in type converters

First the name of the method in the TypeConverter interface was changed from convert to parse so it would match the name of the self converting method.


Then When I wrote:

Rules of conversion

From example to fixture

1 First GreenPepper will verify if the type is can self convert ie public static T parse(String)
2 If not, look for a registered TypeConverter that can handles the type.
3 An UnsupportedOperationException will be thrown

|rule for | Type conversion|
|type | parse with? |
|Type no converter no self | error |
|Type no converter with Self | self.parse |
|Type with converter no Self | converter.parse|
|Type with converter with self | Expected: self.parse Received: converter.parse|

From fixture return value to String

1 First GreenPepper will verify if the type is can self revert ie public static String toString(T)
2 If not, look for a registered TypeConverter that can handles the type.
3 Use the toString() method on the data itself.

|rule for|Type conversion |
|type| toString with ? |
|Type no converter no self | class.toString |
|Type no converter with Self | self.toString |
|Type with converter no Self | converter.toString |
|Type with converter with self | Expected: self.toString Received: converter.toString|
 


I was suprised to see the code was looking for the converter before looking for self conversion.
I believe the order should be self convert, then registered converter.

I will change the TypeConversion class for the next release.

Opinons?

---
Remember. Green is good!
praveen


Joined: 18/05/2009 08:44:40
Messages: 11
Offline

I am using BigDecimal in my code.I have overridden parse and also toString method in my class for converting the String from page to code as Bigdecimal value and vice versa.But i am getting the UnsupportedOperationException and then i tried with TypeConverter by writing my own converter for BigDecimal.Even for this i am getting UnsupportedOperationException .

How can i register my own converter class to the green pepper fixture ?


Thanks
Praveen
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team