commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Sklyut <>
Subject RE: JXPath question
Date Tue, 04 May 2004 13:40:35 GMT
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 []
Sent: Tuesday, May 04, 2004 8:10 AM
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...

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

Thank you. Paychex, Inc.

To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message