comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Java and xmlrpc? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4304527fb69e181
* Can Java Programmer Learn C++ Quickly? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec
* Parse Array of Objects - string delimiter java - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
* Beginning EJB - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d49babfdb472b21c
* Anybody familiar with the Triangle Comipiler? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fbcaab1f73c71be2
* Threads and modal dialog behaviour question - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a5f146a46cb92ad
* JSF version of JSTL forEach? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/12c3510dbb3c55d4
* "static" prefix - to parallel "this" prefix - 2 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157
* Switching views? - 2 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f8fe75655599bd11
* JFreeChart : problem with width of labels - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/10d042f3ee61eef2
* How do i serialize... - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2cd83849aed5600
* A little optimization question: Local var allocation - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6b24661ed590053
* Data::Dumper for Java? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3714236a937906c
* JDO Question : Is it possible to get unique values like DISTINCT in SQL? - 1 
messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e48b52e65e122b13
* java.lang.String.CASE_INSENSITIVE_ORDER.compareTo() - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7f41cc1663df63c
* How to restrict direct access to JSP files, only allow access via servlet? - 
1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/514c912d89045a82

==============================================================================
TOPIC: Java and xmlrpc?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4304527fb69e181
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 9:38 am
From: Martin Egholm Nielsen  

Hi Shakah (and others),

> Sorry, didn't see your post. If you're still interested...
Sure I am - thanks alot! Haven't tried it yet, though. But it makes a 
lot of sense...
How many external libs are required? Hopefully not the huge and almighty
xalan.jar etc.?

I'm hoping for a solution that I can fit in an embedded system...

Is there a way to have the rpc-server share the connection/stream with 
an ordinary webserver? That is, I have this simple webserver for 
displaying some regular html, and I would like to overlay the rpc part 
somehow...

Regards,
  Martin Egholm

 > client-side (stand-alone Java app):
 > org.apache.xmlrpc.XmlRpcClientLite xrc_ = new
 > org.apache.xmlrpc.XmlRpcClientLite("http://www.acme.com/xmlrpcurl";) ;
 >
 > java.util.Vector vParams = new java.util.Vector() ;
 > java.util.Hashtable ht = new java.util.Hashtable() ;
 > ht.put("environment", sEnvironment) ;
 > ht.put("authData", sAuthData) ;
 > vParams.addElement(ht) ;
 >
 > String sToken = (String) xrc_.execute("myserver.attach", vParams) ;
 >
 > server-side (Tomcat, actually in a JSP):
 > // ...XML/RPC handler class
 > public static class MyHandler {
 > public String attach(java.util.Hashtable h)
 > throws java.security.NoSuchAlgorithmException
 > ,org.apache.xmlrpc.XmlRpcException {
 > try {
 > // ...the required args
 > String sEnvironment = (String) h.get("environment") ;
 > String sAuthData = (String) h.get("authData") ;
 >
 > // ...etc
 >
 > return "return value" ;
 > }
 > catch(NullPointerException x) {
 > throw new org.apache.xmlrpc.XmlRpcException(-2, "missing
 > \"environment\" or \"authData\" parameters?") ;
 > }
 > catch(ClassCastException x) {
 > throw new org.apache.xmlrpc.XmlRpcException(-2, "unexpected
 > \"environment\" or \"authData\" parameter types?") ;
 > }
 > }
 > }
 >
 > // ...one-time init
 > private static org.apache.xmlrpc.XmlRpcServer xrs = null ;
 > if(null==xrs) {
 > xrs = new org.apache.xmlrpc.XmlRpcServer() ;
 > xrs.addHandler("myserver", new MyHandler()) ;
 >   }
 >


> To clarify the "one-time init" code snippet -- the JSP more-or-less
> does:
> 
> if(null!=request.getContentType() &&
> request.getContentType().equals("text/xml")) {
> if(null==xrs) {
> xrs = new org.apache.xmlrpc.XmlRpcServer() ;
> xrs.addHandler("myserver", new MyHandler()) ;
> }
> 
> byte [] abResult = xrs.execute(request.getInputStream()) ;
> 
> response.setContentType("text/xml") ;
> response.setContentLength(abResult.length) ;
> out.clear() ;
> out.write(new String(abResult)) ;
>     out.flush() ;
>   }
> 




==============================================================================
TOPIC: Can Java Programmer Learn C++ Quickly?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 3:54 am
From: Sudsy  

Ann wrote:
> "Rhino" <[EMAIL PROTECTED]> wrote in message
>>real C++ experience and not much C experience for that matter.
> 
> 
> Did you consider C# instead of C++?

Why on earth would you propose considering a proprietary language?
This /is/ c.l.j.p after all. Where's the ASCII symbol for a flat
again?  ;-)

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.




== 2 of 2 ==
Date: Wed, Dec 8 2004 10:54 am
From: bugbear  

Rhino wrote:

> 
> However, the core Java statements are "borrowed" from C and C++ has often
> been called "C with classes". It seems to me that it shouldn't take very
> long to get up to speed on C++ if I am already fluent with Java and have at
> least some knowledge of C.

Two things will hurt you. Badly.

1) Memory management - disciplined and careful use
of constructors and destructors will help here, although
the whole idiom of carefully KEEPING references
around so you use them do deallocate memory will be
extremely "backwards" to a java programmer.

2) Libraries. Java is a tiny and simple langugage. Most of
the complexity and learning is in the assorted libraries.
Java has the advantage of a single, large, set of libraries,
so it's worth learning this. In C++, the libraries are more
varied, and less universal.

You won't be able to design an "industry grade" C++ program
until approx 12 months of study/use IMHO.

     BugBear




==============================================================================
TOPIC: Parse Array of Objects - string delimiter java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 9:54 am
From: "Boudewijn Dijkstra"  

"Sébastien Auvray" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> marvado a écrit :
>> seems to work,
>> all suggestions are valid for me
>> thank you !
>>
>> "Boudewijn Dijkstra" <[EMAIL PROTECTED]> wrote in message 
>> news:[EMAIL PROTECTED]
>>
>>>"Jim Cheng" <[EMAIL PROTECTED]> schreef in bericht 
>>>news:[EMAIL PROTECTED]
>>>
>>>>Pedro is asking fir a String (comma delimitted) including the name, desc, 
>>>>and age.
>>>>So the following does not work.
>>>>
>>>>>---------------still not tested ---------------
>>>>>String catlist;
>>>>>
>>>>>for (int j = 0; j < Cat.length; j++)
>>>>>{
>>>>> if(j!=0) catlist += ",";
>>>>> catlist += Cat[j].cName;
>>>>>}
>>>>>
>>>>>
>>>>
>>>>try:
>>>>
>>>>String catlist;
>>>>
>>>>for (int j = 0; j < Cat.length; j++)
>>>>{
>>>> if(j!=0) catlist += ",";
>>>> catlist += Cat[j].cName +","+ Cat[j].cDesc +","+ cat[j].cAge;
>>>>}
>>>
>>>StringBuffer buf = new StringBuffer(cat.length * 30);
>>>
>>>buf.append(cat[0].cName).append(',').append(cat[0].cDesc)
>>> .append(',').append(cat[0].cAge);
>>>for (int j = 1; j < cat.length; j++)
>>>{
>>> buf.append(',').append(cat[j].cName).append(',')
>>>   .append(cat[j].cDesc).append(',').append(cat[j].cAge);
>>>}
>>>
>>>String catlist = buf.toString();
>>>
>>>
>>
>>
>>
> Hi !
> It could also be beautiful to override Cat.toString, and use 
> Collection.toString()...
>
> i.e.
> for Cat
> String toString()
> {
>   return new 
> StringBuffer(cName).append(',').append(cDesc).append(',').append(cAge)
> }

In this case it would be unnesscary to explicitly use StringBuffer, the 
following statement is just as effecient and a lot more readable:
  return cName + ',' + cDesc + ',' + cAge;







==============================================================================
TOPIC: Beginning EJB
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d49babfdb472b21c
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 9:56 am
From: Michael Borgwardt 
 

Darryl L. Pierce wrote:
> How will 3.0 make working with remote objects easier? Sorry to ask so 
> many questions, but from where I stand the way the EJB 2.x specification 
> works is quite nice and efficient. It hides the actual creation of the 
> EJB reference while giving a clean representation of the business 
> methods of the remote object to the client. From the client's 
> perspective, you cannot tell that you're dealing with a remote object. 
> So, when I hear someone calling that "painful" it makes me wonder how 
> they would do things differently to alleviate that pain...

The pain is not in the client code, but in the bean code. EJB 3.0 removes most
of the horrible redundancies by making use of the metadata annotation introduced
in Java 1.5:

http://www.caucho.com/resin-3.0/ejb3/tutorial/cmp-basic-field/index.xtp

------------------
The EJB 3.0 draft is primarily a process of removing features superfluous to 
supporting 
persistent objects.

     * No home interfaces
     * No local interfaces
     * No instance pooling
     * No special create or remove methods
     * No special find or select methods
     * Deployment descriptor is optional

EJB 3.0 relies on JDK 1.5 annotations to configure entities in a maintainable, 
self-documenting way.

     * Only one Java class needed per table (no interface needed)
     * Annotation per field
     * Annotation directly in Java class
     * Direct java instance (no proxy or stub needed)
------------------




==============================================================================
TOPIC: Anybody familiar with the Triangle Comipiler?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fbcaab1f73c71be2
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 4:00 am
From: Sudsy  

Diphay Z wrote:
> Firstly, thanks for you reply. As described on the textbook, ...

Homework questions are not appropriate to this newsgroup. If your
professor or TA can't help then they're not doing their job, eh?

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.




== 2 of 2 ==
Date: Wed, Dec 8 2004 11:54 am
From: Daniel Sjöblom  

Diphay Z wrote:
> Firstly, thanks for you reply. As described on the textbook, the for
> loop is executed as follows. First, the expressions E1 and E2 are
> evaluated, yielding the integers m and n (say), respectively. Then the
> subcommand C is executed repeatedly, with identifier I bound in
> successive iterations to each integer in the range m through n. If m >
> n, C is not executed at all. (The scope of I is C, which may use the
> value of I but may not update it. The types of E1 and E2 must be
> Integer.) 

In that case, the for loop can be compiled as I specified in my previous 
post. Obviously, the syntax may differ in your particular code generator.

-- 
Daniel Sjöblom
Remove _NOSPAM to reply by mail




==============================================================================
TOPIC: Threads and modal dialog behaviour question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a5f146a46cb92ad
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 10:06 am
From: Aloys Oberthür  

Babu Kalakrishnan wrote:
> Aloys Oberthür wrote:
> 
>> I have a question on modal dialogs in (non-event-dispatching)Threads. 
>> I do set a flag in the actionPerformed() method of a modal dialog and 
>> the object which displayed the dialog in the first place can question 
>> this flag after "returning" from show(). I would have expected this to 
>> be not timing dependant, but I see it is not which I do not understand
>>
>>
>> that's the dialog in essence:
>>
>> class ModalerDialog extends JDialog implements ActionListener {
>>   boolean flagSuccessful = false;
>> ...
>>
>>   public void actionPerformed(ActionEvent aE) {
>>     String cmd = aEvt.getActionCommand();
>>
>>     if(cmd.equals("one")) {
>>       flagSuccessful = true;
>>       this.setVisible(false);
>>     }
>>     else if(cmd.equals("two")) {
>>       flagSuccessful = false;
>>       this.setVisible(false);
>>     }
>>   }
>>
>>   public boolean isSuccessful() {
>>     return flagSuccessful;
>>   }
>> }
>>
>>
>> and that is the Thread launched within the actionPerformed()-method of 
>> a  menu ActionListener (see // comments)
>>
>> Thread t = new Thread() {
>>   public void run() {
>>
>>     ModalerDialog md = new ModalerDialog(owner, true);
>>     md.show();
> 
> 
> If "md" is really a modal dialog, I would expect this thread to stop
> right here, and continue on to the next line only after the dialog has
> been hidden / disposed off. That's how modal dialogs are expected to
> behave.
> 
>>
>>     boolean b = md.isSuccessful();  // now on "one" false
>>     try {
>>      Thread.sleep(250);
>>     }
>>     catch (InterruptedException e1) {}
>>     b = = md.isSuccessful();        // and now on "one" true ????
>>
>>     if(md.isSuccessful())
>>       md.dispose();
>>     else {
>>       md.dispose();
>>       owner.showStartupDialog();
>>     }
>>   }
>> };
>> t.start();
>>
> 
> Couldn't understand what your comments meant either.
> 
> BK
It is true, that the Thread stops and displays the modal dialog. But 
although I first set the flag within the dialogs actionPerformed method 
and then set the dialog to not visible I get two results in the calling 
Thread depending on when I invove md.isSuccessful().


The comments referred to the actionCommand, I meant that the command 
"one" is the one, where successful is set to true in the 
actionPerformed() method above.

Aloys




==============================================================================
TOPIC: JSF version of JSTL forEach?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/12c3510dbb3c55d4
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 10:13 am
From: Andrea Desole  

The Abrasive Sponge wrote:
> 
> Don't have an answer, but have a question:

that's a help :-)


> You don't like dataTable? how come?

dataTable renders a table element, which is often enough, but sometimes 
I need something else. With the jstl forEach you can write whatever text 
and component you want. I think it's much more flexible.




==============================================================================
TOPIC: "static" prefix - to parallel "this" prefix
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 9:20 am
From: "Chris Uppal"  

Darryl L. Pierce wrote:

> > The name of the class.
>
> But you're not specifying the name of the class here. You're specifying
> the context of the variable in question. That it just happens to *also*
> be the classname is just a coincidence, and doing that doesn't harm the
> code or the intention at all.

Most of the uses of the classname are redundant.  To see that, change the name
of the class.  All the uses of the classname (within the body of the class)
that have to change with it are redundant.

    -- chris






== 2 of 2 ==
Date: Wed, Dec 8 2004 9:19 am
From: "Chris Uppal"  

Tim Tyler wrote:

> > Personally, I like the idea but think it would work still better with a
> > different keyword such as 'thisClass', see my post in the above thread
> > for
> > details.
>
> The idea of eliminating constructor names is appealing.
>
> However, I'm not sure what syntax would be best for that.
>
> About the only alternative I considered for "static." was "class.".
>
> It would *have* to be an existing keyword (or a symbol?) - unless you were
> prepared for name clashes with identifiers in existing code.

Well, "goto" is a reserved word, IIRC, maybe we could use that ;-)

Actually, I'd be quite happy to break existing code that used "thisClass"; it's
unlikely to be in use as a method name, and shouldn't be in use as a class name
or name of a public field, and all other uses -- if any -- are easy to change.

> I also think that "this." should be available to refer to static
> data within static methods - and that there should be a corresponding
> static object associated with the class that is accessible to the
> programmer - i.e. that Java should behave more like Smalltalk,
> with everything being an object - and having a "this" reference.

I agree that a Smalltalk-like class concept would be far preferable to the Java
model (which achieves neither clarity nor simplicity nor flexibility -- i.e.
it's a looser).  But I can't see that ever happening, as you say, to much
inertia.  But I don't think it's a very good idea to try to make the Java model
look like the ST one with "tricks" like allowing "this" in static contexts.
IMO, it would cause more confusion than it saves.  "The whole hog or none"
seems to apply here.

I would like to eliminate all that bloody redundancy, though.

    -- chris







==============================================================================
TOPIC: Switching views?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f8fe75655599bd11
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 9:19 am
From: "Chris Uppal"  

Dan Antion wrote:

> Can anybody offer some advice as to the best way to switch from one view
> to another.  These wouldn't be views on the same object, but different
> views on different objects that need to be displayed in the same
> physical area.

(Oddly, this came up just a couple of days ago)

I think that you are looking for a WizardCardContainer (Presenter.'Wizard card
container').  Add all your "variable" sub-components as children, and then
switch between them by sending #ensureVisible to the presenters.

    -- chris






== 2 of 2 ==
Date: Wed, Dec 8 2004 9:25 am
From: "Chris Uppal"  

I wrote:
> ....

Damn, sorry.  Wrong NG.

    -- chris






==============================================================================
TOPIC: JFreeChart : problem with width of labels
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/10d042f3ee61eef2
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 1:25 am
From: [EMAIL PROTECTED] (Grand Paradis) 

(sorry for my english)
Hi
I have an horizontal Bar Chart, with labels at the left of each bar.
But the space allocated with these labels is too short, and labels are
written in several lines. How can I control space allocated with such
labels?

Thanks



== 2 of 2 ==
Date: Wed, Dec 8 2004 11:25 am
From: Gerbrand van Dieijen  

Grand Paradis wrote:
> (sorry for my english)
> Hi
> I have an horizontal Bar Chart, with labels at the left of each bar.
> But the space allocated with these labels is too short, and labels are
> written in several lines. How can I control space allocated with such
> labels?
> 
> Thanks

Hello,

There's a forum on the JFreeChart's website (http://www.jfree.org), 
which is probably a better place to ask the question.
I got an(other) answer on a question quite fast.




==============================================================================
TOPIC: How do i serialize...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2cd83849aed5600
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 1:27 am
From: [EMAIL PROTECTED] 

Hi all,

I have a serializable class with a field 'age' of type 'byte'.
It is serializable and the serialized data is stored somewhere.

Now I have a new version on the class. Only change is type of the
'age' field is now 'int', lets say. How do i read the data which
was serialized above, and serialize it to the new version?

In short:
version 1 classes    -->      version 2 classes
version 1 data       --?      version 2 data

Thanks,
Amit




== 2 of 2 ==
Date: Wed, Dec 8 2004 4:49 am
From: Alan Gutierrez  

On 2004-12-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a serializable class with a field 'age' of type 'byte'.
> It is serializable and the serialized data is stored somewhere.
>
> Now I have a new version on the class. Only change is type of the
> 'age' field is now 'int', lets say. How do i read the data which
> was serialized above, and serialize it to the new version?
>
> In short:
> version 1 classes    -->      version 2 classes
> version 1 data       --?      version 2 data

    Two ways:

    First, read up on version control in the Java Serialzation
    Specification, and tell me what you come up with. With versioning in
    place, it is legal to add fields, so you could get creative.

    http://java.sun.com/developer/technicalArticles/Programming/serialization/ 
    http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/version.html

    Second, try serializing your old classes using XStream. XStream
    serializes to XML. If it is simply a change of the width of a
    primative type, then XStream will do the right thing.
    
    If you make a more complicated change to the object, maybe something
    like replacing age with a birthdate, you can serialize to XML via
    XStream, transform the XML using XSLT, and deserialize using
    XStream. One of the bloggers I read was raving about this (forgot
    who).
    
    http://xstream.codehaus.org/    - XStream
    http://saxon.sourceforge.net/   - Saxon (XSLT)

--
Alan Gutierrez - [EMAIL PROTECTED]




==============================================================================
TOPIC: A little optimization question: Local var allocation
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6b24661ed590053
==============================================================================

== 1 of 2 ==
Date: Wed, Dec 8 2004 11:21 am
From: Chris Berg  

On Wed, 08 Dec 2004 05:47:07 +0200, Daniel Sjöblom
<[EMAIL PROTECTED]> wrote:

>
>In this case the two approaches compile to identical bytecode (which you 
>could have verified yourself), so there is not much to discuss. Even if 

How do I verify that?

>they didn't, worrying about this kind of microoptimization is utterly 
>futile. A better improvement to #1, #2 would be a more readable version:
>
>String str;
>while ((str = dis.readLine()) !=  null)
>{
>     ... something
>}

This is your own taste. Personally, I don't like concatenations like
that; a program does not necessarily get more readable by reducing the
number of characters or lines. I usualy stick to the principle of one
thing happening on each line. But if you prefer it like that, fine.
Just modify "A better improvement..." to "I think a better
improvement..."

Unless, of course, if your version actually runs faster? It appears to
have one less reference to the string than mine !!

Chris




== 2 of 2 ==
Date: Wed, Dec 8 2004 11:27 am
From: Michael Borgwardt 
 

Chris Berg wrote:
>>In this case the two approaches compile to identical bytecode (which you 
>>could have verified yourself), so there is not much to discuss. Even if 
> 
> 
> How do I verify that?

With the javap tool.

>>they didn't, worrying about this kind of microoptimization is utterly 
>>futile. A better improvement to #1, #2 would be a more readable version:
>>
>>String str;
>>while ((str = dis.readLine()) !=  null)
>>{
>>    ... something
>>}
> 
> 
> This is your own taste. Personally, I don't like concatenations like
> that; a program does not necessarily get more readable by reducing the
> number of characters or lines.

It's a well-known idiom that most programmers will recognize.


> Unless, of course, if your version actually runs faster?

Again: you should NOT change code to something less clear because of
some microoptimazion. But I don't think it's any faster either.




==============================================================================
TOPIC: Data::Dumper for Java?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3714236a937906c
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 4:29 am
From: Alan Gutierrez  

On 2004-11-30, Sam <[EMAIL PROTECTED]> wrote:
> Hello,
>
> if I have something like
>
> whatever_class inst = new whatever_class();
> inst.member_1 = value_1;
> ..
> inst.member_n = value_n;
>
> is there any possibility to find out (without explizit asking) what the
> types and/or values from inst ?
>
> I have to say that I'm new to JAVA and I was wondering if there is something
> similar that I know from Perl with the module Data::Dumper.
>
> e.g. in Perl:
> Data::Dumper($inst) would result in something like that
> { member_1 => value_1,
> ....
>   member_n => value_n
> }
>
> I doubt that there is something similar available (or even possible) but I
> just wanted to ask.

    As mentioned elsewhere, you can use the facilities of the
    java.lang.reflect package to determine the types and values of inst.

    Reflection is probably what you want.

    http://java.sun.com/docs/books/tutorial/reflect/

    If for some reason, you really need the data to be in a string
    format, then I recommend using the XStream library to serialize the
    objects to XML, then you can use W3DOM, DOM4J, SAX, or XPath to poke
    around a text repesentation of the document. Actually, I'd recommend
    using DOM4J since it supports XPath and a Java friendly tree API.

    http://xstream.codehaus.org/
    http://www.dom4j.org/

    (And try to use Java naming conventions, and I promise I'll use
        underbars in my Perl code.)

--
Alan Gutierrez - [EMAIL PROTECTED]




==============================================================================
TOPIC: JDO Question : Is it possible to get unique values like DISTINCT in SQL?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e48b52e65e122b13
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 11:34 am
From: Gerbrand van Dieijen  

Klixx0r wrote:
> Hi all,
> 
> I use DISTINCT in my SQL queries to get unique values where there 
> are duplicates in my DB tables. As JDO is a layer on top on JDBC 
> and it has its own query syntax (I don't think it allows SQL) ... I 
> was wondering if something like the effect of DISTINCT is possible?
> 
> Like if I had a field in my persitance enabled class called 
> customerName, and it 5 instances had values of 
> "A","B","B","C","D" ... i would want it to get all of them but only 
> one of the "B". Is this possible with JDO?
> 


You could get a list of unique object by:
List list=(List)pm.newQuery(Customer.class,true)

SortedSet unqueset=new TreeSet(<my own Comparator>,list)

The comparator class can be constructed as such that Customers with the 
same name are equal:
int compareTo(customer1, customer2) {
    return customer2.getName().compareTo(customer1.getName())
}

JDO doesn't have a DISTINCT however. I think this is because it is less 
needed, because you can't/don't have to use joints anyway. (like SELECT 
Customer.name from Customer,Account where 
Customer.NAME=Account.CustomerName).

It's best to specify in the JDO xml file package.jdo that CustomerName 
has to be unique for the class Customer.




==============================================================================
TOPIC: java.lang.String.CASE_INSENSITIVE_ORDER.compareTo()
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7f41cc1663df63c
==============================================================================

== 1 of 3 ==
Date: Wed, Dec 8 2004 11:50 am
From: "Suresh"  

Hi friends,

I found the following code snip from the java source 1.4.2, which I dont
understand much. Could someone please explain the reason for making a 3rd
comparision with lowercase when the comparision with uppercase fails ??? Is
there some really good reason for this ??



Thanks.


    public static final Comparator CASE_INSENSITIVE_ORDER
                                         = new CaseInsensitiveComparator();
    private static class CaseInsensitiveComparator
                         implements Comparator, java.io.Serializable {
 // use serialVersionUID from JDK 1.2.2 for interoperability
 private static final long serialVersionUID = 8575799808933029326L;

        public int compare(Object o1, Object o2) {
            String s1 = (String) o1;
            String s2 = (String) o2;
            int n1=s1.length(), n2=s2.length();
            for (int i1=0, i2=0; i1<n1 && i2<n2; i1++, i2++) {
                char c1 = s1.charAt(i1);
                char c2 = s2.charAt(i2);
                if (c1 != c2) {
                    c1 = Character.toUpperCase(c1);
                    c2 = Character.toUpperCase(c2);
                    if (c1 != c2) {
                        c1 = Character.toLowerCase(c1);            // ******
Why compare the lower case ??
                        c2 = Character.toLowerCase(c2);            // ******
when uppercase should be enough !!!
                        if (c1 != c2) {
                            return c1 - c2;
                        }
                    }
                }
            }
            return n1 - n2;
        }
    }





== 2 of 3 ==
Date: Wed, Dec 8 2004 3:03 am
From: Michael Borgwardt 
 

Suresh wrote:
> I found the following code snip from the java source 1.4.2, which I dont
> understand much. Could someone please explain the reason for making a 3rd
> comparision with lowercase when the comparision with uppercase fails ??? Is
> there some really good reason for this ??

There are a lot of weird characters with special case rules, it's probably
necessary for some of them.



== 3 of 3 ==
Date: Wed, Dec 8 2004 3:09 am
From: Gordon Beaton  

On Wed, 8 Dec 2004 11:50:01 +0100, Suresh wrote:
> I found the following code snip from the java source 1.4.2, which I
> dont understand much. Could someone please explain the reason for
> making a 3rd comparision with lowercase when the comparision with
> uppercase fails ??? Is there some really good reason for this ??

Off hand, I believe this has to do with the fact that not all Unicode
characters have uppercase and lowercase versions, or that the mapping
is not always unique.

Some information here:
  http://www.unicode.org/faq/casemap_charprop.html

/gordon (not an expert)

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==============================================================================
TOPIC: How to restrict direct access to JSP files, only allow access via 
servlet?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/514c912d89045a82
==============================================================================

== 1 of 1 ==
Date: Wed, Dec 8 2004 5:01 am
From: Alan Gutierrez  

On 2004-12-07, Ryan Stewart <[EMAIL PROTECTED]> wrote:
> "Anan" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> How to restrict direct access to JSP files, but allow access only via
>> servlet?
>> Is it possible via .htaccess? If so, e.g. of a snippet on how to do
>> it? Any other ways? Thanks.

> Put all JSPs in WEB-INF.

    That can't be a good idea. I've put data in WEB-INF, but I'd never
    think to put JSP resources there. Is this a common practice?

--
Alan Gutierrez - [EMAIL PROTECTED]



==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to