<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>So you
actually extended the Element class, huh?</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>I was
thinking about doing that.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003>Currently, I have a bunch of static methods in a Util
class in my project.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>The
syntax is a little longer that way...</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003>boolean value = Util.getXMLBoolean(element,
"TAGNAME");</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>I
think I'd rather extend Element as you did.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>Just a
organizational question...</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>What
do you call your extended Element and where is it in your package
hierarchy?</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>I've
seen people create things like "EnhancedElement" or "MynameElement" and put them
in a com.myname.toolkit or com.myname.util package.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=309213815-15072003></SPAN></FONT><FONT face=Arial
color=#0000ff size=2><SPAN class=309213815-15072003></SPAN></FONT><FONT
face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=309213815-15072003></SPAN></FONT><FONT face=Arial
color=#0000ff size=2><SPAN class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>As for
your internationalization problem, y</SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=309213815-15072003>ou might want to look at
java.text.DecimalFormat.parse()</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003>Supposedly, you can get set it up to work with
different locales.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>You'd
have to somehow know what locale the data was coming from before you parsed
it.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=309213815-15072003>You
might be able to represent a float in exponential notation, I think that it's
standardized on a '.' instead of a ','</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003>...</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=309213815-15072003>Krick</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Phill_Perryman@Mitel.COM
[mailto:Phill_Perryman@Mitel.COM]<BR><B>Sent:</B> Tuesday, July 15, 2003 11:01
AM<BR><B>To:</B> William Krick<BR><B>Subject:</B> Re: [jdom-interest] new
element methods?<BR><BR></FONT></DIV><BR><FONT face=sans-serif size=2>I would
agree up to the point you have the float. Is there an accepted way to
represent a float which does not have an "." or "," in it.</FONT>
<BR><BR><FONT face=sans-serif size=2>My biggest problem is that a file created
in Europe would have 1.234,00 whereas a uk file would have 1,234.00. Parse
will assume the local machine format and so a file sent from one machine to
another will fail. I am only storing currency at the moment so I am storing it
as</FONT> <BR><BR><FONT face=sans-serif size=2>return (getInt(attName, 0)/100)
(it may be ugly but it works)</FONT> <BR><BR><FONT face=sans-serif size=2>My
extended Element class already has them but I have a</FONT> <BR><BR><FONT
face=sans-serif size=2>getInt(String name, int default) {</FONT> <BR><FONT
face="Courier New" size=2>int result;<BR> try{<BR>
result = Integer.parseInt(getChildTextTrim(name));<BR>
}<BR> catch(Exception ex){<BR> result =
default;<BR> }<BR> return result;<BR> }</FONT>
<BR><FONT face=sans-serif size=2><BR>I would be in favour of adding these in s
I personally use them quite a lot.</FONT> <BR><BR><FONT face=sans-serif
size=2><BR>/Phill<BR>IS Dept, Software
Engineer.<BR>phill_perryman@mitel.com<BR>http://www.mitel.com<BR>Tel: +44 1291
436023</FONT> <BR><BR><BR>
<TABLE width="100%">
<TBODY>
<TR vAlign=top>
<TD>
<TD><FONT face=sans-serif size=1><B>"William Krick"
<wkrick@eio-online.com></B></FONT> <BR><FONT face=sans-serif
size=1>Sent by: jdom-interest-admin@jdom.org</FONT>
<P><FONT face=sans-serif size=1>15/07/2003 15:07</FONT> <BR></P>
<TD><FONT face=Arial size=1> </FONT><BR><FONT
face=sans-serif size=1> To:
<jdom-interest@jdom.org></FONT> <BR><FONT
face=sans-serif size=1> cc:
</FONT> <BR><FONT face=sans-serif size=1>
Subject: [jdom-interest] new
element methods?</FONT></TR></TBODY></TABLE><BR><BR><BR><FONT
face="Courier New" size=2>I was wondering if it might be useful to add some
methods to Element...<BR><BR> getInt(java.lang.String
name)<BR><BR> getFloat(java.lang.String
name)<BR><BR> getBoolean(java.lang.String
name)<BR><BR> getString(java.lang.String
name)<BR> <BR> etc...<BR><BR>...that are essentially aliases
for...<BR><BR> getChildTextTrim(java.lang.String name) <BR><BR>...but
with added code that tries to parse the child text string<BR>to the
appropriate type...<BR><BR><BR> public boolean getBoolean(String
name){<BR> boolean result;<BR> try{<BR>
result = getChildTextTrim(name).equalsIgnoreCase("true");<BR>
}<BR> catch(Exception ex){<BR> result =
false;<BR> }<BR> return
result;<BR> }<BR><BR> public String getString(String
name){<BR> String result = getChildTextTrim(name);<BR>
if(result == null)<BR> return "";<BR>
return result;<BR> }<BR><BR> public int getInt(String
name){<BR> int result;<BR> try{<BR>
result = Integer.parseInt(getChildTextTrim(name));<BR>
}<BR> catch(Exception ex){<BR> result =
0;<BR> }<BR> return
result;<BR> }<BR><BR> public float getFloat(String name){<BR>
float result;<BR> try{<BR> result =
Float.parseFloat(getChildTextTrim(name));<BR> }<BR>
catch(Exception ex){<BR> result = 0f;<BR>
}<BR> return
result;<BR> }<BR><BR> etc...<BR><BR><BR>...<BR>Krick<BR>_______________________________________________<BR>To
control your jdom-interest
membership:<BR>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com<BR></FONT><BR><BR></BLOCKQUOTE></BODY></HTML>