Package sunlabs.brazil.template
Class ChangedTemplate
- java.lang.Object
-
- sunlabs.brazil.template.Template
-
- sunlabs.brazil.template.ChangedTemplate
-
- All Implemented Interfaces:
java.io.Serializable
,TemplateInterface
public class ChangedTemplate extends Template implements java.io.Serializable
ThisTemplate
adds an icon to HREFs to indicate when the file being referred to is new, changed, or unchanged with respect to the user's session.In order for the
ChangedTemplate
to work, the following must happen.- All files whose HREFs should be rewritten must pass through the
ChangedTemplate
. All HREFs seen between<changed>
and</changed>
tags will be rewritten so that an appropriate icon appears next to the HREF. - All files whose last-accessed time is being tracked must also pass
through this
ChangedTemplate
. Whenever theChangedTemplate
sees a file that was named in some previously seen<changed>
section, that file's last-accessed time will be updated. Only the files named in a<changed>
section are tracked.
ChangedTemplate
may have to keep track of a lot of data per session, specifically, the names of all the files being tracked and the last time the user accessed them.The
ChangedTemplate
examines the property "fileName", set (for example) by theFileHandler
, in order to update the last-accessed time of a file as it passes by. If the "fileName" property is not set, the last-accessed time will not be updated.The
ChangedTemplate
also assumes that all local HREFs it sees can be directly translated into the corresponding file name based on the "root" property and the URL of the current file. Getting that file name is necessary so its last-modified time (on disk) can be compared to its last-accessed time (per session).The
ChangedTemplate
uses the following properties:- fileName
- A request property containing the full path name of the current file,
used to keep track of the last time that file was accessed by the
current user. A
Handler
or other code may set this property if it wishes the file to be tracked. - root
- The root of the document hierarchy. An HREF must resolve to a file in this hierarchy so its last-modified time can be checked. If the file does not exist, the HREF will not be rewritten.
- always
- If this property is present, the
ChangedTemplate
always rewrites the HREFs, instead of just when they appear within the<changed>
and</changed>
tags. - new
- The HTML to substitute into the document if the HREF refers to a file that has never been accessed by the user. If absent, the HREF for new files will not be rewritten.
- changed
- The HTML to substitute into the document if the HREF refers to a file that has changed since the last time it was accessed by the user. If absent, the HREF for changed files will not be rewritten.
- unchanged
- The HTML to substitute into the document if the HREF refers to a file that has not changed since the last time it was accessed by the user. If absent, the HREF for unchanged files will not be rewritten.
- Version:
- Author:
- Colin Stevens (colin.stevens@sun.com)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ChangedTemplate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
done(RewriteContext hr)
Called after all tags have been processed, one final chance.boolean
init(RewriteContext hr)
Records that this file has just been accessed.void
tag_a(RewriteContext hr)
void
tag_changed(RewriteContext hr)
void
tag_slash_changed(RewriteContext hr)
-
-
-
Method Detail
-
init
public boolean init(RewriteContext hr)
Records that this file has just been accessed.- Specified by:
init
in interfaceTemplateInterface
- Overrides:
init
in classTemplate
-
done
public boolean done(RewriteContext hr)
Description copied from class:Template
Called after all tags have been processed, one final chance.- Specified by:
done
in interfaceTemplateInterface
- Overrides:
done
in classTemplate
-
tag_changed
public void tag_changed(RewriteContext hr)
-
tag_slash_changed
public void tag_slash_changed(RewriteContext hr)
-
tag_a
public void tag_a(RewriteContext hr)
-
-