Package org.archive.crawler.restlet
Class PagedRepresentation
java.lang.Object
org.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.CharacterRepresentation
org.archive.crawler.restlet.PagedRepresentation
public class PagedRepresentation
extends org.restlet.representation.CharacterRepresentation
Representation wrapping a FileRepresentation, displaying its contents
in batches of lines at a time, with forward and backward navigation.
- Author:
- gojomo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EnhDirectoryResource
wrapped EnhDirectoryResource; used to formulate self-linksprotected File
Fileprotected org.restlet.representation.FileRepresentation
wrapped FileRepresentationprotected int
desired line count; negative to go back from position; default 128text linesprotected long
position in file around which to fetch linesprotected org.apache.commons.lang.math.LongRange
position range [start-of-first-line, past-end-of-last-line] in fileprotected boolean
whether to display lines in reversed order (latest first)Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
-
Constructor Summary
ConstructorsConstructorDescriptionPagedRepresentation
(org.restlet.representation.FileRepresentation representation, EnhDirectoryResource resource, String pos, String lines, String reverse) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
emitBumper
(PrintWriter pw, boolean atTop) Emit a "start" or "EOF" bumper as appropriate to prominently indicate if page borders start- or end- of-file.protected void
Emit the navigational controls.protected String
getControlUri
(long pos, int lines, boolean reverse) Construct navigational URI for given parameters.highlightCrawlLogLine
(String line) Performs basic syntax highlighting of a crawl log line.protected void
Actually read the requested lines, and reverses if appropriate.void
Write the paged HTML.Methods inherited from class org.restlet.representation.CharacterRepresentation
getChannel, getStream, write, write
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
-
Field Details
-
fileRepresentation
protected org.restlet.representation.FileRepresentation fileRepresentationwrapped FileRepresentation -
dirResource
wrapped EnhDirectoryResource; used to formulate self-links -
position
protected long positionposition in file around which to fetch lines -
lineCount
protected int lineCountdesired line count; negative to go back from position; default 128 -
reversedOrder
protected boolean reversedOrderwhether to display lines in reversed order (latest first) -
lines
text lines -
range
protected org.apache.commons.lang.math.LongRange rangeposition range [start-of-first-line, past-end-of-last-line] in file -
file
File
-
-
Constructor Details
-
PagedRepresentation
public PagedRepresentation(org.restlet.representation.FileRepresentation representation, EnhDirectoryResource resource, String pos, String lines, String reverse)
-
-
Method Details
-
getReader
- Specified by:
getReader
in classorg.restlet.representation.Representation
- Throws:
IOException
-
loadLines
Actually read the requested lines, and reverses if appropriate. If at file start, refuses to show fewer lines than are possible ('bounces' against start).- Throws:
IOException
-
write
Write the paged HTML.- Specified by:
write
in classorg.restlet.representation.Representation
- Throws:
IOException
- See Also:
-
Representation.write(java.io.Writer)
-
highlightCrawlLogLine
Performs basic syntax highlighting of a crawl log line. Assumes the line is already HTML escaped. -
emitBumper
Emit a "start" or "EOF" bumper as appropriate to prominently indicate if page borders start- or end- of-file.- Parameters:
pw
- PrintWriteratTop
- boolean, true if at top of page
-
emitControls
Emit the navigational controls. TODO: ugh! templatize, reduce duplication as possible- Parameters:
pw
- PrintWriter
-
getControlUri
Construct navigational URI for given parameters.- Parameters:
pos
- desired position in filelines
- desired signed line countreverse
- if line ordering should be displayed in reverse- Returns:
- String URI appropriate to navigate to desired view
-