webfunds.ricardian
Class SOXServer

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.ricardian.SOXServer

public class SOXServer
extends Encodable
implements Diagnostics

SOX Server File. Every SOX server has a file on the web somewhere which indicates various static paramaters. Somewhere there has to be a bridge between contract and server: Contract --> SOX Server file --> Issuer Server For the moment, this is it. NOTE that this might be better in SOX hierarchy. It should also have its own IniFile format reader.

See Also:
Serialized Form

Field Summary
protected  java.io.PrintWriter bug
           
protected  byte[] fileData
           
protected  java.lang.String fix
           
protected  java.lang.String originalName
           
protected  IniFileReader serverFile
           
static int VERSION
          The version of the encoded object: 1 - first Encodable version.
 
Constructor Summary
SOXServer(byte[] data)
           
SOXServer(byte[] fileData, java.lang.String name, java.io.PrintWriter bug)
           
SOXServer(java.io.InputStream is)
           
 
Method Summary
 void decode(java.io.InputStream is)
           
 void encode(java.io.OutputStream os)
           
 boolean equals(java.lang.Object obj)
           
 java.io.PrintWriter err()
          Do stack trace prints to err(), should always return something.
 java.lang.String[] getAllNames()
          Get all the names of the server file.
 java.lang.String[] getArray(java.lang.String item)
           
 java.lang.String[] getArray(java.lang.String section, java.lang.String item)
           
 java.net.URL[] getCachedSOXFileLocation()
           
 java.io.PrintWriter getDebug()
          Returns a debug writer, if any is set.
 java.lang.String getField(java.lang.String item)
           
 java.lang.String getField(java.lang.String section, java.lang.String item)
           
static SOXServer getInstance(byte[] server)
          Take the data and make a SOXServer object.
static SOXServer getInstance(java.io.File serverfile, java.io.PrintWriter bug)
          Create a SOXServer given the file.
static SOXServer getInstance(java.net.URL url, java.io.PrintWriter bug)
          Create a SOXServer object given an URL
 Issuer getIssuer(Contract con)
          Return an Issuer.
 java.lang.String getName()
          Get the name of the server.
static SOXServer getNewSOXServerFile(java.net.URL[] urls)
          With a bunch of URLs, go out and get a SOX Server file from the net.
 java.net.URL[] getServerLocation()
           
 java.net.URL[] getSOXFileLocation()
           
 int getVersion()
          Get the version number of the server file.
protected  void init()
           
protected  void init2()
           
 void logmsg(java.lang.String s)
           
static void main(java.lang.String[] arg)
           
protected  void refreshServerData()
          Go out on the net and see if it is changed? Not implemented yet, see the DirSOXStore.
 void saveAsFile(java.io.File dir)
           
 void saveAsFile(java.io.File dir, java.lang.String name)
          This file doesn't need to differentiate itself from other files, so it saves itself as name.
 void setField(java.lang.String section, java.lang.String item, java.lang.String value)
           
 java.lang.String toString()
           
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final int VERSION
The version of the encoded object: 1 - first Encodable version.

bug

protected java.io.PrintWriter bug

fix

protected java.lang.String fix

fileData

protected byte[] fileData

serverFile

protected IniFileReader serverFile

originalName

protected java.lang.String originalName
Constructor Detail

SOXServer

public SOXServer(byte[] fileData,
                 java.lang.String name,
                 java.io.PrintWriter bug)
          throws SOXServerException

SOXServer

public SOXServer(byte[] data)
          throws SOXPacketException

SOXServer

public SOXServer(java.io.InputStream is)
          throws SOXPacketException
Method Detail

logmsg

public void logmsg(java.lang.String s)
Specified by:
logmsg in interface Diagnostics

getDebug

public java.io.PrintWriter getDebug()
Description copied from interface: Diagnostics
Returns a debug writer, if any is set.
Specified by:
getDebug in interface Diagnostics

err

public java.io.PrintWriter err()
Description copied from interface: Diagnostics
Do stack trace prints to err(), should always return something.
Specified by:
err in interface Diagnostics

init2

protected void init2()
              throws SOXPacketException

init

protected void init()
             throws SOXServerException

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Overrides:
encode in class Encodable

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   SOXPacketException
Overrides:
decode in class Encodable

getInstance

public static SOXServer getInstance(java.io.File serverfile,
                                    java.io.PrintWriter bug)
                             throws SOXServerException
Create a SOXServer given the file.
Parameters:
file - name for SOXServer file

getInstance

public static SOXServer getInstance(java.net.URL url,
                                    java.io.PrintWriter bug)
                             throws SOXServerException,
                                    SOXLaterException
Create a SOXServer object given an URL
Parameters:
url - URL to read the object from

getInstance

public static SOXServer getInstance(byte[] server)
                             throws SOXServerException
Take the data and make a SOXServer object. There is no constructor for this.
Returns:
a SOXServer made from the file data

getIssuer

public Issuer getIssuer(Contract con)
                 throws SOXIssuerException,
                        SOXLaterException
Return an Issuer. Ready to go? Tested? Probably.

getName

public java.lang.String getName()
Get the name of the server. This should be useful for a filename.
Returns:
unique name of the server

getAllNames

public java.lang.String[] getAllNames()
Get all the names of the server file. These will be mostly the URLs where the file can be found.
Returns:
list of names

getServerLocation

public java.net.URL[] getServerLocation()

setField

public void setField(java.lang.String section,
                     java.lang.String item,
                     java.lang.String value)

getField

public java.lang.String getField(java.lang.String item)

getArray

public java.lang.String[] getArray(java.lang.String item)

getField

public java.lang.String getField(java.lang.String section,
                                 java.lang.String item)

getArray

public java.lang.String[] getArray(java.lang.String section,
                                   java.lang.String item)

getVersion

public int getVersion()
Get the version number of the server file. Useful for seeing which is the most recent copy of the file, a la DNS.
Returns:
current version number of the server, 0 if failed

saveAsFile

public void saveAsFile(java.io.File dir)
                throws java.io.IOException

saveAsFile

public void saveAsFile(java.io.File dir,
                       java.lang.String name)
                throws java.io.IOException
This file doesn't need to differentiate itself from other files, so it saves itself as name. Caller can add a suffix.

getCachedSOXFileLocation

public java.net.URL[] getCachedSOXFileLocation()

getSOXFileLocation

public java.net.URL[] getSOXFileLocation()

getNewSOXServerFile

public static SOXServer getNewSOXServerFile(java.net.URL[] urls)
                                     throws SOXServerException
With a bunch of URLs, go out and get a SOX Server file from the net. Should be called using the contract data by a Store.

refreshServerData

protected void refreshServerData()
Go out on the net and see if it is changed? Not implemented yet, see the DirSOXStore.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

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

main

public static void main(java.lang.String[] arg)
                 throws java.io.IOException