|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.archive.wayback.replay.TextDocument
public class TextDocument
Class which wraps functionality for converting a Resource(InputStream + HTTP headers) into a StringBuilder, performing several common URL resolution methods against that StringBuilder, inserting arbitrary Strings into the page, and then converting the page back to a byte array.
| Field Summary | |
|---|---|
java.lang.StringBuilder |
sb
the internal StringBuilder |
| Constructor Summary | |
|---|---|
TextDocument(Resource resource,
CaptureSearchResult result,
ResultURIConverter uriConverter)
|
|
| Method Summary | |
|---|---|
byte[] |
getBytes()
|
java.lang.String |
getCharSet()
|
protected java.lang.String |
getCharsetFromBytes(Resource resource)
Attempts to figure out the character set of the document using the excellent juniversalchardet library. |
protected java.lang.String |
getCharsetFromHeaders(Resource resource)
Attempt to divine the character encoding of the document from the Content-Type HTTP header (with a "charset=") |
protected java.lang.String |
getCharsetFromMeta(Resource resource)
Attempt to find a META tag in the HTML that hints at the character set used to write the document. |
java.lang.String |
getJSIncludeString(java.lang.String jsUrl)
|
protected java.lang.String |
guessCharset()
Use META tags, byte-character-detection, HTTP headers, hope, and prayer to figure out what character encoding is being used for the document. |
java.lang.String |
includeJspString(java.lang.String jspPath,
javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResults results,
CaptureSearchResult result,
Resource resource)
|
void |
insertAtEndOfBody(java.lang.String toInsert)
|
void |
insertAtStartOfBody(java.lang.String toInsert)
|
void |
insertAtStartOfHead(java.lang.String toInsert)
|
void |
readFully()
Read bytes from input stream, using best-guess for character encoding |
void |
readFully(java.lang.String charSet)
|
void |
resolveAllPageUrls()
Update all URLs inside the page, so they resolve correctly to absolute URLs within the Wayback service. |
void |
resolveASXRefUrls()
|
void |
resolveCSSUrls()
|
void |
resolvePageUrls()
Update URLs inside the page, so those URLs which must be correct at page load time resolve correctly to absolute URLs. |
void |
setCharSet(java.lang.String charSet)
|
void |
stripHTML()
|
void |
writeToOutputStream(java.io.OutputStream os)
Write the contents of the page to the client. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public java.lang.StringBuilder sb
| Constructor Detail |
|---|
public TextDocument(Resource resource,
CaptureSearchResult result,
ResultURIConverter uriConverter)
resource - result - uriConverter - | Method Detail |
|---|
protected java.lang.String getCharsetFromHeaders(Resource resource)
throws java.io.IOException
resource -
java.io.IOException
protected java.lang.String getCharsetFromMeta(Resource resource)
throws java.io.IOException
resource -
java.io.IOException
protected java.lang.String getCharsetFromBytes(Resource resource)
throws java.io.IOException
resource -
java.io.IOException
protected java.lang.String guessCharset()
throws java.io.IOException
resource -
java.io.IOExceptionpublic void resolvePageUrls()
public void resolveAllPageUrls()
public void resolveCSSUrls()
public void resolveASXRefUrls()
public void stripHTML()
public void readFully(java.lang.String charSet)
throws java.io.IOException
charSet -
java.io.IOException
public void readFully()
throws java.io.IOException
java.io.IOException
public byte[] getBytes()
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public void writeToOutputStream(java.io.OutputStream os)
throws java.io.IOException
os -
java.io.IOExceptionpublic void insertAtStartOfHead(java.lang.String toInsert)
toInsert - public void insertAtEndOfBody(java.lang.String toInsert)
toInsert - public void insertAtStartOfBody(java.lang.String toInsert)
toInsert -
public java.lang.String includeJspString(java.lang.String jspPath,
javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResults results,
CaptureSearchResult result,
Resource resource)
throws javax.servlet.ServletException,
java.io.IOException
jspPath - httpRequest - httpResponse - wbRequest - results -
java.io.IOException
javax.servlet.ServletException
java.text.ParseExceptionpublic java.lang.String getJSIncludeString(java.lang.String jsUrl)
jsUrl -
public java.lang.String getCharSet()
public void setCharSet(java.lang.String charSet)
charSet - the charSet to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||