|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.wrq.vhi.script.api.AttributeEventHandler
AttributeFormatting.DateAttributeHandler
public class DateAttributeHandler
This example illustrates how to use an event handler to read and reformat an attribute before it is sent to the client application. This is done by:
defaultReadAttribute
method provided by
the event object to read the attribute as it is displayed
by the host application, andDateFormatter
instance to reformat the date into the desired form.The source code for the DateFormatter
class is
stored in the shared examples directory. The Jar file containing
the class is copied into this example's lib directory by the
ant build file.
What's different about this example is that the date formatter instance
is created as a static variable within this class. When this class is
loaded, the formatter
static variable is created. The initialization
parameters for the formatter tell it the host date syntax, and the era within
which two-digit years are assumed to fall.
If you wanted to handle other two-digit dates with different separator
characters, or within a different era, you would define a different attribute
(or field) handler which would create a different DateFormatter
instance initialized to handle that other kind of date.
When you look at the source code for the DateFormatter
class, notice that the instance variables are all defined as final
.
This means that the only data changed by that class's methods are either
parameters or local to each method; the methods are thread-safe.
Field Summary | |
---|---|
static java.lang.String |
description
|
private static DateFormatter |
formatter
This instance of DateFormatter
is used to reformat dates in this application. |
Fields inherited from interface com.wrq.vhi.script.api.EventHandler |
---|
DEFAULT_TIMEOUT |
Constructor Summary | |
---|---|
DateAttributeHandler()
|
Method Summary | |
---|---|
java.lang.String |
readAttribute(com.wrq.vhi.script.api.ReadAttributeEvent event)
Called by the Host Integrator server to read the attribute. |
Methods inherited from class com.wrq.vhi.script.api.AttributeEventHandler |
---|
writeAttribute |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String description
private static final DateFormatter formatter
DateFormatter
is used to reformat dates in this application.
The first two-digit year is assumed to be 1970. Dates from "70" to "99" are assumed to be 1970-1999; dates from "00" to "69" are assumed to be 2000 to 2069.
The month, day, and year displayed by the host application are separated by "-" characters.
Constructor Detail |
---|
public DateAttributeHandler()
Method Detail |
---|
public java.lang.String readAttribute(com.wrq.vhi.script.api.ReadAttributeEvent event) throws com.wrq.apptrieve.agent.ApptrieveException
This attribute converts a single month, day, year string into a standard output form, and also converts 2- to 4-digit years.
readAttribute
in class com.wrq.vhi.script.api.AttributeEventHandler
event
- the event instance
com.wrq.apptrieve.agent.ApptrieveException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |