textbender.a.r.page
Class PageVisit

java.lang.Object
  extended by PageVisit

@ThreadSafe
public final class PageVisit
extends Object

A single page visit (or refresh) in a browser.


Field Summary
static int MEDIAN_GENE_COUNT
          An estimate of the median gene count, per page.
 
Constructor Summary
PageVisit(RhiWindow _w, File _f, VersionedFile _fV, ToolbarApplet _a)
          Waits for page to become ready, and creates a PageVisit.
 
Method Summary
 ToolbarApplet applet()
          The toolbar applet.
 HTMLDocument document()
          The page as a DOM document.
 PageVisitEDT edt()
          Facilities restricted to the AWT event dispatch thread.
 File file()
          Returns the source of the page as a local file, or null if the source is not a local file.
 List<Element> geneList()
          Sparse list of genes, indexed by g-index.
 Object getReleaseReason()
          Returns the reason why the page vist is coming to an end.
 List<Element> gList()
          List of gene meta-data ('g') elements, ordered by g-index.
 boolean isPageSilent()
          Returns true if the page is remote, and therefore blocks LiveConnect JavaScript messages to the page daemon.
 MultiMap<String,Element> locusToGeneMap()
          Map of genes, keyed by locus.
 Spool preSpool()
          Spool unwound before this instance is released.
 File serializedPage()
          Returns a serialized copy of the page.
 void setReleaseReason(Object newReleaseReason)
          Sets the releaseReason.
 Spool spool()
          Spool unwound as this instance is released.
 InPageFactory transfer_inPageFactory()
          This page as a region-transfer source.
 User user()
          The user.
 VersionedFile versionedFile()
          Returns the source of the page as a versioned file, or null if the source is not a versioned file.
 RhiWindow window()
          Browser window visiting the page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEDIAN_GENE_COUNT

public static final int MEDIAN_GENE_COUNT
An estimate of the median gene count, per page.

See Also:
Constant Field Values
Constructor Detail

PageVisit

PageVisit(RhiWindow _w,
          File _f,
          VersionedFile _fV,
          ToolbarApplet _a)
    throws IOException,
           TextbenderException
Waits for page to become ready, and creates a PageVisit.

Launches a desk daemon (from the browser's own VM) if none was already running. It will be left running after the page is released. (Avoid clearing its classloader during testing. Use a separate browser to load the desk daemon, initially. And before clearing the cache in any other browser, back out of the recombinant text page first, so the page daemon's listeners can deregister.)

Parameters:
_w - browser window, per window()
_f - file, per file()
_fV - versioned file, per versionedFile()
_a - toolbar applet, per applet()
Throws:
IOException - if serializedPage cannot be created, or RemoteException if an in-page tool cannot connect with desk daemon
TextbenderException - per findMetaData
Method Detail

applet

public ToolbarApplet applet()
The toolbar applet.


document

public HTMLDocument document()
The page as a DOM document. The return value is equivalent to (HTMLDocument)window().getDocument(). It is cached here for efficiency.


edt

public PageVisitEDT edt()
Facilities restricted to the AWT event dispatch thread.


file

public File file()
Returns the source of the page as a local file, or null if the source is not a local file.

See Also:
serializedPage(), versionedFile()

geneList

public List<Element> geneList()
Sparse list of genes, indexed by g-index.


getReleaseReason

public Object getReleaseReason()
Returns the reason why the page vist is coming to an end. Specific reasons are defined by processes that cause page exit; none are defined here.

Returns:
the reason, or null if there is no special reason

setReleaseReason

public void setReleaseReason(Object newReleaseReason)
Sets the releaseReason.

Throws:
IllegalStateException - if reason already set
See Also:
getReleaseReason()

gList

public List<Element> gList()
List of gene meta-data ('g') elements, ordered by g-index.


isPageSilent

public boolean isPageSilent()
Returns true if the page is remote, and therefore blocks LiveConnect JavaScript messages to the page daemon. Messages (method calls etc.) are blocked because of same-origin restrictions on JavaScript, Remote-origin JavaScript cannot message the local-origin page daemon without getting an exception like this:
sun.plugin.liveconnect.OriginNotAllowedException: JavaScript is not from the same origin as the Java code, caller=http://zelea.com, callee=file:/home/mike/var/tmp-public/textbender-demo/textbender.jar

The main casualty is event dispatch; remote pages cannot forward events to the page daemon. They are effectively silent.


locusToGeneMap

public MultiMap<String,Element> locusToGeneMap()
Map of genes, keyed by locus. Where there are multiple genes per locus, the map stores them in document order.


preSpool

public Spool preSpool()
Spool unwound before this instance is released. Useful for any hold whose release depends on other holds (but which is depended on, in turn, by no other hold). This spool is nothing but a fudge, to work around order dependencies during release.

See Also:
spool()

serializedPage

public File serializedPage()
Returns a serialized copy of the page. If the source of the page is a local file, returns the same as file(); otherwise returns a file containing a serialization of the page. In the latter case, the file is automatically deleted at page exit.

Note: In the latter case, the serialization will include any markup added by content and user scripts during boot; such as injected applets.


spool

public Spool spool()
Spool unwound as this instance is released.

See Also:
preSpool(), PageVisitEDT.spool()

transfer_inPageFactory

public InPageFactory transfer_inPageFactory()
This page as a region-transfer source.


user

public User user()
The user.


versionedFile

public VersionedFile versionedFile()
Returns the source of the page as a versioned file, or null if the source is not a versioned file.

See Also:
file()

window

public RhiWindow window()
Browser window visiting the page.