Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

pspdash
Class MimeHTMLArchiver  view MimeHTMLArchiver download MimeHTMLArchiver.java

java.lang.Object
  extended bypspdash.MimeHTMLArchiver

public class MimeHTMLArchiver
extends java.lang.Object

Class for creating MIME Encoded HTML archives of dashboard content. For more information on MIME Encoded HTML archives, see http://www.ietf.org/rfc/rfc2110.txt Current bug: if the item named by the starting URI is a dashboard form or a page containing a link to "excel.iqy", the excel file will become the root page instead.


Field Summary
protected  java.lang.String base
           
protected  java.lang.String boundary
           
protected static java.lang.String CRLF
           
protected  pspdash.data.DataRepository data
           
protected static java.text.SimpleDateFormat dateFormat
           
protected  int itemNumber
           
protected  java.io.PrintWriter out
           
protected  java.io.OutputStream outStream
           
protected  java.util.HashMap safeUriMap
           
protected  java.util.HashSet seenURIs
           
protected  TinyWebServer webServer
           
 
Constructor Summary
protected MimeHTMLArchiver(TinyWebServer webServer, pspdash.data.DataRepository data)
           
 
Method Summary
static void archive(TinyWebServer webServer, pspdash.data.DataRepository data, java.io.OutputStream outStream, java.lang.String startingUri)
           
private  java.lang.String createBoundary()
          Create a randomly generated MIME-part boundary.
protected  void deleteScriptElement(java.lang.StringBuffer result, int scriptStart)
           
protected  int findEndTagEnd(java.lang.StringBuffer html, int pos, java.lang.String tag)
          Locate the end of an html tag with the given name.
protected  int findFormScriptStart(java.lang.StringBuffer html)
           
protected  java.lang.String getCharset(java.lang.String contentType)
           
protected  java.lang.String getContentType(java.lang.String header)
          Extract the content type from the given HTTP response headers.
protected  java.lang.String getExportURI(java.lang.String uri)
           
protected static void getForAttr(java.lang.String text, java.lang.String attr, java.util.ArrayList v)
           
protected  int getHeaderLength(byte[] result)
          Determine the length (in bytes) of the header in an HTTP response.
static java.lang.String getPrefixFromURI(java.lang.String uri)
           
protected  java.util.ArrayList getReferencedItems(java.lang.String html)
           
protected  java.lang.String getSafeURL(java.lang.String uri)
           
protected  void handleDashboardForm(java.lang.String uri, java.lang.String contentType, java.lang.StringBuffer result)
           
protected  void handleHTML(java.lang.String uri, byte[] contents, int headerLength, java.lang.String contentType)
           
protected  void hideNonPrintingElements(java.lang.StringBuffer html)
           
protected  boolean isDashboardForm(java.lang.StringBuffer html)
           
protected  java.lang.String makeExcelURL(java.lang.String url)
           
protected  int minPos(int a, int b)
           
protected  java.lang.String newString(byte[] bytes, int offset, int len, java.lang.String enc)
           
protected  java.lang.String normalizeHTML(java.lang.String html)
           
protected  void run(java.io.OutputStream outStream, java.lang.String startingURI)
           
protected  void stripHTMLComments(java.lang.StringBuffer html)
           
protected  void unhideElements(java.lang.StringBuffer content)
           
protected  java.lang.String writeExcelPart(java.lang.String forUri, java.lang.StringBuffer content)
           
protected  void writeItemAndRecurse(java.lang.String uri)
          Add an item to the MIME archive, and recursively add any items it refers to.
protected  void writeMimeEnding()
          Write the closing boundary of the MIME-HTML file.
protected  void writeMimeHeader()
          Write the header of the MIME-HTML file.
protected  void writeMimePart(java.lang.String uri, java.lang.String contentType, byte[] contents, int headerLength)
           
protected  void writeMimePart(java.lang.String uri, java.lang.String contentType, java.lang.StringBuffer content)
           
protected  void writePartHeader(java.lang.String uri, java.lang.String contentType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

protected java.lang.String base

boundary

protected java.lang.String boundary

seenURIs

protected java.util.HashSet seenURIs

safeUriMap

protected java.util.HashMap safeUriMap

itemNumber

protected int itemNumber

outStream

protected java.io.OutputStream outStream

out

protected java.io.PrintWriter out

webServer

protected TinyWebServer webServer

data

protected pspdash.data.DataRepository data

CRLF

protected static final java.lang.String CRLF
See Also:
Constant Field Values

dateFormat

protected static final java.text.SimpleDateFormat dateFormat
Constructor Detail

MimeHTMLArchiver

protected MimeHTMLArchiver(TinyWebServer webServer,
                           pspdash.data.DataRepository data)
Method Detail

archive

public static void archive(TinyWebServer webServer,
                           pspdash.data.DataRepository data,
                           java.io.OutputStream outStream,
                           java.lang.String startingUri)
                    throws java.io.IOException

run

protected void run(java.io.OutputStream outStream,
                   java.lang.String startingURI)
            throws java.io.IOException

createBoundary

private java.lang.String createBoundary()
Create a randomly generated MIME-part boundary.


writeMimeHeader

protected void writeMimeHeader()
Write the header of the MIME-HTML file.


writeMimeEnding

protected void writeMimeEnding()
Write the closing boundary of the MIME-HTML file.


writeItemAndRecurse

protected void writeItemAndRecurse(java.lang.String uri)
Add an item to the MIME archive, and recursively add any items it refers to.


getExportURI

protected java.lang.String getExportURI(java.lang.String uri)

writeMimePart

protected void writeMimePart(java.lang.String uri,
                             java.lang.String contentType,
                             byte[] contents,
                             int headerLength)
                      throws java.io.IOException

writeMimePart

protected void writeMimePart(java.lang.String uri,
                             java.lang.String contentType,
                             java.lang.StringBuffer content)
                      throws java.io.IOException

writePartHeader

protected void writePartHeader(java.lang.String uri,
                               java.lang.String contentType)

getHeaderLength

protected int getHeaderLength(byte[] result)
Determine the length (in bytes) of the header in an HTTP response.


getContentType

protected java.lang.String getContentType(java.lang.String header)
Extract the content type from the given HTTP response headers.


handleHTML

protected void handleHTML(java.lang.String uri,
                          byte[] contents,
                          int headerLength,
                          java.lang.String contentType)

getSafeURL

protected java.lang.String getSafeURL(java.lang.String uri)

findFormScriptStart

protected int findFormScriptStart(java.lang.StringBuffer html)

isDashboardForm

protected boolean isDashboardForm(java.lang.StringBuffer html)

handleDashboardForm

protected void handleDashboardForm(java.lang.String uri,
                                   java.lang.String contentType,
                                   java.lang.StringBuffer result)
                            throws java.io.IOException

writeExcelPart

protected java.lang.String writeExcelPart(java.lang.String forUri,
                                          java.lang.StringBuffer content)
                                   throws java.io.IOException

hideNonPrintingElements

protected void hideNonPrintingElements(java.lang.StringBuffer html)

findEndTagEnd

protected int findEndTagEnd(java.lang.StringBuffer html,
                            int pos,
                            java.lang.String tag)
Locate the end of an html tag with the given name. This attempts to locate a closing tag ""; if this fails, it simply looks for ">".


minPos

protected int minPos(int a,
                     int b)

unhideElements

protected void unhideElements(java.lang.StringBuffer content)

getPrefixFromURI

public static java.lang.String getPrefixFromURI(java.lang.String uri)

makeExcelURL

protected java.lang.String makeExcelURL(java.lang.String url)

deleteScriptElement

protected void deleteScriptElement(java.lang.StringBuffer result,
                                   int scriptStart)

newString

protected java.lang.String newString(byte[] bytes,
                                     int offset,
                                     int len,
                                     java.lang.String enc)

getReferencedItems

protected java.util.ArrayList getReferencedItems(java.lang.String html)

normalizeHTML

protected java.lang.String normalizeHTML(java.lang.String html)

stripHTMLComments

protected void stripHTMLComments(java.lang.StringBuffer html)

getForAttr

protected static void getForAttr(java.lang.String text,
                                 java.lang.String attr,
                                 java.util.ArrayList v)

getCharset

protected java.lang.String getCharset(java.lang.String contentType)