Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Advanced-java] Dynamic Expression in Java


  • From: philion@xxxxxxxxxxxxxx (Paul Philion)
  • Subject: [Advanced-java] Dynamic Expression in Java
  • Date: Mon, 18 Mar 2002 11:23:56 -0500

Mike -

If you're interested in comparing two objects in a flexible way, take a look
at the java.lang.Comparable and java.util.Comparator interfaces.

You might also consider the Command design pattern from the GOF book.

If you are looking for something that will compile Java code, in-line, at
runtime (like Perl) or even something like C++ operator overloading, those
solutions aren't really applicable in Java. I would suggest taking a more
abstract look at *what* you are trying to accomplish, as opposed to *how* it
might be done.

Good luck,

- Paul Philion

----- Original Message -----
From: "Michael Shoemaker" <shoemaker_m@xxxxxxxxx>
To: <advanced-java@xxxxxxxxxxxxxxxx>
Cc: <kmehta@xxxxxxxxxxxxxxxxxxx>
Sent: Monday, March 18, 2002 9:16 AM
Subject: [Advanced-java] Dynamic Expression in Java


> Anyone know of a way to dynamically create an
> expression within java and have it executed.
>
> For example
>
> Object obj1 = // some object
> Object obj2 = // some object
> String strComp = "==";
>
> Now I need to dynamically generate the conditional.
>
> if (str1 strComp str2) {
>    // Do something useful
> }
>
> Thanks in advance.
>
>
> =====
> Mike Shoemaker
> Mike@xxxxxxxxxxxxxxxx
> Visit my website
> http://www.PavolDemitra.com
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
> _______________________________________________
> Advanced-java mailing list
> Advanced-java@xxxxxxxxxxxxxxxxxxxxxx
> http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
>