Linkable.Analysis
Class RefLinker

java.lang.Object
  |
  +--Linkable.Analysis.RefLinker

public class RefLinker
extends java.lang.Object


Field Summary
private static boolean DEBUG
           
private static java.lang.String doc
           
private static java.lang.StringBuffer document
           
private static int kz
           
private static java.lang.String ME
           
 
Constructor Summary
RefLinker()
           
 
Method Summary
private static java.util.Vector[] getContexts(Reference[] refList)
          from a list of references extracts all the context information that will be needed to reference link a source document.
static java.lang.String getLinkedText(java.lang.String doc, Reference[] refList, java.lang.String url)
           
private static java.lang.String getURLS(Reference r)
          extracts the online locations, if any, for a given work.
private static java.lang.StringBuffer insertBaseURL(java.lang.String document, java.lang.String url)
          Reads in the XML document and inserts a Base URL to the original network address, so that images, etc.
private static int insertLinks(int k, java.util.Vector v, Reference[] refList)
          Given the position in the document of a context, and a list of anchors (references) in that context, stick in the s
private static java.lang.String linkText(java.util.Vector[] contexts, Reference[] refList)
          does the "heavy lifting" of inserting reflinks into the text, while making a single pass over the text.
private static int locateAnchor(int k, java.lang.String anchor)
          Finds where this anchor occurs next in the document, as text.
private static int punt(int k, java.lang.String s)
          recovers from a situation where the context cannot be found in the document starting at position k probably because it keeps running into tagged elements.
private static int scanForward(int k, java.util.Vector v)
          finds where in the document this context is and returns an index to its position.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME

DEBUG

private static final boolean DEBUG

document

private static java.lang.StringBuffer document

doc

private static java.lang.String doc

kz

private static int kz
Constructor Detail

RefLinker

public RefLinker()
Method Detail

getLinkedText

public static java.lang.String getLinkedText(java.lang.String doc,
                                             Reference[] refList,
                                             java.lang.String url)

getContexts

private static java.util.Vector[] getContexts(Reference[] refList)
from a list of references extracts all the context information that will be needed to reference link a source document.
Parameters:
The - reference list (Reference[])

linkText

private static java.lang.String linkText(java.util.Vector[] contexts,
                                         Reference[] refList)
does the "heavy lifting" of inserting reflinks into the text, while making a single pass over the text. The text is kept in a StringBuffer during processing to allow for efficient insertions and the like. It is converted to a string just before returning.
Parameters:
An - ordered array of contexts, each element a Vector of Context objects, one per reference contained in the context
the - array of Reference objects for this document

scanForward

private static int scanForward(int k,
                               java.util.Vector v)
finds where in the document this context is and returns an index to its position. It is a serious error if the context cannot be found, because it was taken from this document at one point in the past. However, this time the text has tags in it
Parameters:
integer - position at which to start scanning. This will be the character following the previously replaced anchor.
Vector - of Context objects, all of which are for the same context, but for different anchors within the context. Assert: this vector is not null.

insertLinks

private static int insertLinks(int k,
                               java.util.Vector v,
                               Reference[] refList)
Given the position in the document of a context, and a list of anchors (references) in that context, stick in the s
Parameters:
int - position of context in document
Vector - of Context objects, one per reference in this context
the - array of references for this document

punt

private static int punt(int k,
                        java.lang.String s)
recovers from a situation where the context cannot be found in the document starting at position k probably because it keeps running into tagged elements.
Parameters:
position - in the global document StringBuffer at which to scan forwards for the context
the - context

getURLS

private static java.lang.String getURLS(Reference r)
extracts the online locations, if any, for a given work.
Parameters:
The - Reference to the work

insertBaseURL

private static java.lang.StringBuffer insertBaseURL(java.lang.String document,
                                                    java.lang.String url)
Reads in the XML document and inserts a Base URL to the original network address, so that images, etc. can be fetched.
Parameters:
The - xhtml document
The - base URL

locateAnchor

private static int locateAnchor(int k,
                                java.lang.String anchor)
Finds where this anchor occurs next in the document, as text.
Parameters:
Where - in "document" to begin looking
The - anchor