Thanks Kieran.
To change the topic, does anyone have any tools they really like? I
know I learned about some really cool products on this list. I'm
thinking of FireBug and Selenium, which Chuck mentioned in passing.
FireBug has become indispensable.
Maybe this could be another survey, but it's always nice to get
turned onto something new by a developer who knows what he's doing.
So, any indispensable plugins, editors, 3rd party libs, etc. you use
and like and want to give props to?
I think mine would have to be LaunchBar, it's a great way to view
javadoc files on your computer. I've got it set to index the J2SE
API and the WebObjects API. Apple-space brings it up, and then
typing "NSMUTAA" [return] opens the javadoc for NSMutableArray in
Safari. Very very handy.
--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952
On Jul 12, 2007, at 5:15 AM, Kieran Kelleher wrote:
Actually I have been using
org.apache.commons.lang.text.StrTokenizer for parsing and it works
beautifully with both "Excel CSV" and "Normal CSV" formats without
having to differentiate. Lightweight and easy and convenient since
I already have org.apache.commons.lang in my Foundation framework.
Hey try it on your badly formatted client file, it might handle it!
import org.apache.commons.lang.text.StrTokenizer;
StrTokenizer.getCSVInstance();
For writing CSV files, I have used ostermiller utils CSV
http://ostermiller.org/utils/CSV.html
On Jul 12, 2007, at 1:13 AM, Sam Barnum wrote:
And if you're considering rolling your own CSV parser, I'd
recommend using this instead:
http://opencsv.sourceforge.net/
It handles the escaping of quotes correctly, and commas inside
quoted values. I've had good luck with it, except from a client
who can't seem to reliably generate a correctly formatted csv file...
On Jul 11, 2007, at 8:07 PM, Chuck Hill wrote:
On Jul 11, 2007, at 7:50 PM, Kieran Kelleher wrote:
Chuck/Francis,
This is one approach I had been considering, so since you are
both right, I'll now definitely choose that approach! .... I
just needed to make sure I was not missing some more generic
elegant way in eof.
I already have a DataMapping helper class that maps between
target eo attribute keys and the csv field names. I'll upgrade
that class to have a dictionary of optional ValueConverter
classes for each destination key/keypath.
What I did was to create a NullFormatter so that I did not have
to worry about optionality:
import java.text.*;
/**
* A null object formatter that just returns its input. Useful
for when the API needs a formatter
* but there is no formatting to do.
*/
public class NullFormatter extends Format
{
/** Convenience instance. **/
public static final NullFormatter Formatter = new
NullFormatter();
public NullFormatter()
{
super();
}
public StringBuffer format(Object object, StringBuffer
stringBuffer, FieldPosition fieldPosition)
{
stringBuffer.append(object);
return stringBuffer;
}
public Object parseObject(String string, ParsePosition position)
{
position.setIndex(string.length());
return string;
}
}
As always, thanks for the listening hears and constructive input,
As always, you are most welcome.
Chuck
On Jul 11, 2007, at 8:57 PM, Chuck Hill wrote:
A more generic and reusable solution would be to write
CSVReader that takes a file reference, an array of key paths
and an array of formatters to read CSV column strings, convert
them if needed (with formatter) and set it (with key path and
Key Value Coding). I've done this kind of thing in the past,
and it's very handy. You can even create custom formatters to
convert strings to special data (i.e. BooleanFormat,
InetAddressFormat, etc.).
Interesting, that is precisely what I was about to suggest. I
do the exact same thing. We must therefor be correct. Grin.
It is definitely a more flexible solution and a better design
for the problem at hand.
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/sam%
40360works.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%
40mac.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]