Linkable.API
Class Surrogate

java.lang.Object
  |
  +--Linkable.API.Surrogate

public class Surrogate
extends java.lang.Object

This class is the primary class in the Linkable.API package. The Surrogate's methods comprise the Reference Linking API. The public methods called by reference linking applications are: constructor (there are three types), getLinkedText, getReferenceList, getCurrentCitationList, getMyData, and save.


Field Summary
(package private)  RefLinkAnalyzer a
           
private static boolean DEBUG
           
private  java.lang.String docID
           
private  java.util.Vector knownCitations
           
private  java.lang.String localMetaData
           
private  java.lang.String localURL
           
private static java.lang.String ME
           
private  BibData myData
           
private  java.lang.String myURL
           
private  java.lang.String pubDate
           
private  Reference[] refList
           
 
Constructor Summary
Surrogate(java.lang.String url)
          Constructor - make a surrogate for the item at this network address
Surrogate(java.lang.String _localURL, java.lang.String netURL)
          Constructor - make a surrogate for the item at the local address specified by the first string, with the network address in the second string (needed for processing local copies of archives)
Surrogate(java.lang.String dir, java.lang.String urn, java.lang.String doi)
          Surrogate reconstructor - reads data in from files, does not analyze.
 
Method Summary
 void addCitation(Citation c)
           
static Citation buildCitation(Reference r)
           
private  Surrogate errorExit(SurrogateException se)
           
 byte[] getCitationID(BibData b)
           
 java.util.Vector getCitationList()
           
 byte[] getCurrentCitationList()
           
private  java.lang.String getDOI(java.lang.String remoteURL)
           
private  java.lang.String getHEAD(java.lang.String url)
           
 byte[] getLinkedText()
          returns an XML file which includes the original contents of the Item plus reference anchors located inside a element, for further processing.
 byte[] getMyData()
           
 byte[] getReferenceList()
           
 Reference[] getReferences()
           
 byte[] getRefID(BibData b)
           
private  RefLinkAnalyzer getRefLinkAnalyzer(java.lang.String localURL)
          constructs an analyzer for the item, depending on its MIME type.
 BibData[] getRelatedPapers()
           
private  java.lang.String jtidyVersion(java.lang.String url)
           
private  boolean reconstruct(java.lang.String dir, java.lang.String urn)
          reconstruct - Reconstruct the Surrogate found in the specified location
 boolean save()
          save - this Surrogate should be saved to persistent store as several XML files.
 boolean save(java.lang.String doi)
           
 boolean saveData(java.lang.String filename, byte[] data)
           
 java.lang.String toString()
           
 java.lang.String toXML(java.lang.String pad)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME

DEBUG

private static final boolean DEBUG

myData

private BibData myData

refList

private Reference[] refList

knownCitations

private java.util.Vector knownCitations

myURL

private java.lang.String myURL

localURL

private java.lang.String localURL

docID

private java.lang.String docID

localMetaData

private java.lang.String localMetaData

pubDate

private java.lang.String pubDate

a

RefLinkAnalyzer a
Constructor Detail

Surrogate

public Surrogate(java.lang.String url)
Constructor - make a surrogate for the item at this network address
Parameters:
is - the String giving the network location of the item

Surrogate

public Surrogate(java.lang.String _localURL,
                 java.lang.String netURL)
Constructor - make a surrogate for the item at the local address specified by the first string, with the network address in the second string (needed for processing local copies of archives)
Parameters:
String - giving the file: url of local copy of the item
String - giving the network url of the item

Surrogate

public Surrogate(java.lang.String dir,
                 java.lang.String urn,
                 java.lang.String doi)
Surrogate reconstructor - reads data in from files, does not analyze. At least one of the optional arguments must be specified. The first non-null parameter is used.
Parameters:
- - The directory name of the repository containing the surrogate to be reconstructed, ending with "/Surrogate"
- - The URN of the surrogate to be reconstructed. Will be looked up in the hash table. It is an error of a surrogate for this URN already exists in memory. (TBD)
- - doi of the surrogate to be reconstructed. A default repository name will be built for it. (TBD)
Method Detail

errorExit

private Surrogate errorExit(SurrogateException se)

getLinkedText

public byte[] getLinkedText()
returns an XML file which includes the original contents of the Item plus reference anchors located inside a element, for further processing.

getReferenceList

public byte[] getReferenceList()

getCurrentCitationList

public byte[] getCurrentCitationList()

getMyData

public byte[] getMyData()

getRefID

public byte[] getRefID(BibData b)

getCitationID

public byte[] getCitationID(BibData b)

getRelatedPapers

public BibData[] getRelatedPapers()

toXML

public java.lang.String toXML(java.lang.String pad)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

save

public boolean save()
save - this Surrogate should be saved to persistent store as several XML files. As a side effect update the fileIndex in CreationDatabase
Parameters:
(optional) - doi is the archive and item name, e.g. "foo/bar" of where to write out the data for the Surrogate.
Returns:
true if all went well.

save

public boolean save(java.lang.String doi)

reconstruct

private boolean reconstruct(java.lang.String dir,
                            java.lang.String urn)
                     throws SurrogateException
reconstruct - Reconstruct the Surrogate found in the specified location
Parameters:
- - String giving the directory (ending with "/") which contains the Surrogate files. These files are read in and used to populated the fields of this surrogate object. throws SurrogateException if the surrogate's directory is unreadable

buildCitation

public static Citation buildCitation(Reference r)

addCitation

public void addCitation(Citation c)

getReferences

public Reference[] getReferences()

getCitationList

public java.util.Vector getCitationList()

getRefLinkAnalyzer

private RefLinkAnalyzer getRefLinkAnalyzer(java.lang.String localURL)
                                    throws SurrogateException
constructs an analyzer for the item, depending on its MIME type. Sad to say, MIMEtype for xhtml files is "text/html" also. 2000-08-04: better to just use the file extension (sigh)
Parameters:
localURL - is where a local copy (or reachable remote copy) can be found of the item to be parsed/analyzed.
Throws:
SurrogateException - if the item cannot be opened.

getHEAD

private java.lang.String getHEAD(java.lang.String url)

getDOI

private java.lang.String getDOI(java.lang.String remoteURL)
                         throws SurrogateException

saveData

public boolean saveData(java.lang.String filename,
                        byte[] data)

jtidyVersion

private java.lang.String jtidyVersion(java.lang.String url)