commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul McClure" <pmccl...@paychex.com>
Subject Re: JXPath question
Date Tue, 04 May 2004 14:41:44 GMT
Thanks for the reply Dmitry,
    Is it possible to use an extension function in a path, like this:
          getValue("A / B / vt:asOf(C, $today) / D)

My graph would have paths like this:
          A / B / C / D / E / F
                      |
                 C is not a normal Java Bean property - but must be 
accessed as 'getCAsOf(Date)' - which returns a C object that has a D 
property that is a normal Java Bean Property, and so on...

thanks,
Paul

Dmitry Sklyut wrote:

>Take a look at "Custom Extension Functions":
>
>Collections of custom extension functions can be implemented as Functions
>objects or as Java classes, whose methods become extenstion functions. 
>
>Let's say the following class implements various formatting operations: 
>
>                                                                       
> public class Formats {
>    public static String date(Date d, String pattern){
>        return new SimpleDateFormat(pattern).format(d);
>    }
>    ...
> }
>We can register this class with a JXPathContext: 
>
>                                                                       
> context.setFunctions(new ClassFunctions(Formats.class, "format"));
> ...
>
> context.getVariables().declareVariable("today", new Date());
> String today =
>     (String)context.getValue("format:date($today, 'MM/dd/yyyy')");
>You can also register whole packages of Java classes using PackageFunctions.
>
>
>Also, see FunctionLibrary , which is a class that allows you to register
>multiple sets of extension functions with the same JXPathContext. 
>
>
>-----Original Message-----
>From: Paul McClure [mailto:pmcclure@paychex.com]
>Sent: Tuesday, May 04, 2004 8:10 AM
>To: commons-user@jakarta.apache.org
>Subject: JXPath question
>
>
>I am using JXPath to access an object graph and it is working well in 
>most cases. My problem is that my graph has some objects that are only 
>valid for a certain period of time. So these properties are accessed by 
>date - for example, a property 'foo' would have the getter 
>getFooAsOf(Date dt). There are many types of objects in the graph, but 
>all of them subclass a common base class. They all follow the naming 
>convention above.
>Has anybody used JXPath for this kind of situation - I have not found a 
>way to add the "ValidTime" properties. I'm looking at a custom 
>JXPathBeanInfo class but not getting very far...
>thanks,
>Paul
>
>
>-----------------------------------------
>The information contained in this message may be privileged, confidential,
>and protected from disclosure. If the reader of this message is not the
>intended recipient, or any employee or agent responsible for delivering this
>message to the intended recipient, you are hereby notified that any
>dissemination, distribution, or copying of this communication is strictly
>prohibited. If you have received this communication in error, please notify
>us immediately by replying to the message and deleting it from your
>computer. 
>
>Thank you. Paychex, Inc.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>


-----------------------------------------
The information contained in this message may be privileged, confidential, and protected from
disclosure. If the reader of this message is not the intended recipient, or any employee or
agent responsible for delivering this message to the intended recipient, you are hereby notified
that any dissemination, distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify us immediately by replying
to the message and deleting it from your computer. 

Thank you. Paychex, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message