|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
|
+--com.swfit.core.xhtml.XHTMLDocument
The XHTMLDocument is a XHTML document dummy that can either be read from
disk, from a url, or if the file does not exist, is put together from a XHTML skeleton.
Whenever the source file is changed, the source file is re-read - unless data has
been added. The purpose of this class is to store an often used XHTML documet
in memory. The XHTMLDocument should always consist of at least four
byte arrays of text - between which there can be inserted a title and two XHTML
body parts as chunks of bytes. The different chunks of bytes are never manipulated
directly, and only shallowly copied, so several instances of this class might just be
the same chunks of bytes arranged in different sequences. It is the responsibility
of the programmer to keep track of how the indexes change - and for that reason it
is a good habit to insert the XHTML data backwards (ie first the body parts, and
then the title parts).
Note I: To implement cacheing for both files and urls, we need to store some kind of info describing the state of the file. For regular files we store the file.lastModified () date, but for URLs we got a problem, since Apache will not send any Last-Modified header for *.shtml files. As a workaround we store the content length, and hope that will suffice.
Note II: We implement a cacheing mechanism for these text files, to make the rendering of XHTML pages more efficient.
| Field Summary | |
static int |
BUF_SIZE
How large a file should we read ? |
static java.lang.String |
DELIM
The String which splits a XHTML dummy file into separate parts. |
static int |
NEEDED_ELEMENTS
The XHTMLDocument should always consist of at least four
byte arrays of text - between which there can be inserted a title and two XHTML
body parts as chunks of bytes. |
static int |
NUM_BUF
How large a file should we read ? |
| Fields inherited from class java.util.Vector |
capacityIncrement, elementCount, elementData |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
XHTMLDocument()
Creates a new XHTMLDocument instance with no source file. |
|
| Method Summary | |
byte[][] |
allParts()
Returns all the data, both read and inserted, from this XHTMLDocument. |
XHTMLDocument |
copy()
Duplicates the current XHTMLDocument instance
without passing along the source file. |
static XHTMLDocument |
getStyleXHTMLDocument()
Cache XHTMLDocuments for quick access |
static XHTMLDocument |
getXHTMLDocument(java.io.File file)
|
static XHTMLDocument |
getXHTMLDocument(java.net.URL url)
|
void |
insert(byte[] bytes,
int i)
Inserts an array of bytes into this XHTMLDocument. |
void |
insert(java.lang.StringBuffer str_b,
int i)
Inserts a StringBuffer as an array of bytes into this XHTMLDocument. |
void |
insert(java.lang.String str,
int i)
Inserts a String as an array of bytes into this XHTMLDocument. |
void |
insertPartOne(java.lang.StringBuffer str_b)
|
void |
insertPartTwo(java.lang.StringBuffer str_b)
|
void |
insertTitle(java.lang.String str)
Inserts a StringBuffer as an array of bytes into this XHTMLDocument
at different places, keeping track of the indexes. |
int |
size()
Overrides the superclass method to make sure that the source data has been read from disk when the size is returnd. |
protected byte[][] |
skeletonBytes()
|
| Methods inherited from class java.util.Vector |
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, subList, toArray, toArray, toString, trimToSize |
| Methods inherited from class java.util.AbstractList |
iterator, listIterator, listIterator |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
iterator, listIterator, listIterator |
| Field Detail |
public static final int BUF_SIZE
public static final int NUM_BUF
public static final int NEEDED_ELEMENTS
XHTMLDocument should always consist of at least four
byte arrays of text - between which there can be inserted a title and two XHTML
body parts as chunks of bytes.public static final java.lang.String DELIM
String which splits a XHTML dummy file into separate parts.| Constructor Detail |
public XHTMLDocument()
XHTMLDocument instance with no source file.| Method Detail |
public static final XHTMLDocument getStyleXHTMLDocument()
public static final XHTMLDocument getXHTMLDocument(java.io.File file)
public static final XHTMLDocument getXHTMLDocument(java.net.URL url)
protected byte[][] skeletonBytes()
public final XHTMLDocument copy()
XHTMLDocument instance
without passing along the source file. The chunks of bytes are
shallow copies, so several instances of this class might just be
the same chunks of bytes.public final int size()
size in class java.util.VectorXHTMLDocument consists of.Vector.size()
public final void insertTitle(java.lang.String str)
throws java.io.IOException
StringBuffer as an array of bytes into this XHTMLDocument
at different places, keeping track of the indexes.
public final void insertPartOne(java.lang.StringBuffer str_b)
throws java.io.IOException
public final void insertPartTwo(java.lang.StringBuffer str_b)
throws java.io.IOException
public final void insert(java.lang.StringBuffer str_b,
int i)
throws java.io.IOException
StringBuffer as an array of bytes into this XHTMLDocument.
It is the responsibility of the programmer to keep track of how the indexes change
- and for that reason it is a good habit to insert the XHTML data backwards
(ie first the body parts, and then the title parts).
public final void insert(java.lang.String str,
int i)
throws java.io.IOException
String as an array of bytes into this XHTMLDocument.
It is the responsibility of the programmer to keep track of how the indexes change
- and for that reason it is a good habit to insert the XHTML data backwards
(ie first the body parts, and then the title parts).
public final void insert(byte[] bytes,
int i)
throws java.io.IOException
XHTMLDocument.
It is the responsibility of the programmer to keep track of how the indexes change
- and for that reason it is a good habit to insert the XHTML data backwards
(ie first the body parts, and then the title parts).
public final byte[][] allParts()
throws java.io.IOException
XHTMLDocument.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||