From: Matt B. <gud...@ya...> - 2007-01-08 18:51:05
|
I don't have any negative opinion here... in fact I thought about the trimming option myself. ;) If you want me to give you a reason to dislike me I could point out that () are actually parentheses rather than parantheses though. Sorry. :( -Matt B --- Matt Sgarlata <Mat...@wh...> wrote: > Right now the TextToNumberConverter is configurable > with these properties: > > Converter textConverter (specifies how one textual > format is converted > into another, e.g. String -> StringBuffer) > Converter numberConverter (specifies how one number > is converted into > another, e.g. -> Double -> Long) > char[] symbolsToIgnore = { '(', ')', ' ', '\t', > '\r', '\n' } > > Based on whether symbolsToIgnore includes opening > and closing > parantheses the converter decides whether or not > values in parantheses > should be negated. In fact, there is even an > internal transient > property called negateValuesInParantheses that is > set based on the > values in symbolsToIgnore. I think this behavior is > backwards. It is > not at all obvious that in order to turn on the > ability to make "(1000)" > become -1000L I need to set the symbolsToIgnore to > the char[] array { ' > ', '\t', '\r', '\n' }. > > I would like to get rid of this public > symbolsToIgnore array and add new > configuration properties as follows: > > handlePercentages (default true) - determines > whether text value ending > in % should be divided by 100 when converted to a > number. so, 100% > becomes 1 and 10% becomes .1 > ignoreWhitespace (default true) - automatically > remove all whitespace > before attempting the conversion. this would be > useful if, for example, > a user enters " 3" instead of "3" in a form on > accident. > negateValuesInParantheses (default true) - if a > number begins and ends > with (), automatically treat it as a negative > number. if this value is > set to false, an exception would most likely be > thrown when converting > the text to a number (unless there's some locale > where they use ( to be > the thousands separator or something, lol) > > Like it? Hate it? I need this ASAP for work so I > am planning on coding > it today. > > Matt > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > morph-developer mailing list > mor...@li... > https://lists.sourceforge.net/lists/listinfo/morph-developer > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |