com.shimari.fxtp
Class FXTP

java.lang.Object
  extended bycom.shimari.fxtp.FXTP
All Implemented Interfaces:
Component

public class FXTP
extends java.lang.Object
implements Component

This interface provides an API into the ideosphere.com server; it has been developed independently by Justin Wells. The API is built on top of the FXTP protocol, and operates by connecting to the FXTP server (typically, ideosphere.com:7001). This interface manages the underlying connection to the server for you, does all the parsing, and provides access to key objects and methods.

Actual connections will be opened as-needed by this interface, and closed after a minute of disuse. There are caches for User and Claim objects within this interface; you can clear these caches explicitly when you require a fresh copy of the object. Otherwise the cache is refreshed after a minute or two.

Remember that the FX server is run on a free/voluntary basis, so try not to hit it too hard. In that spirit, this class has some built in throttles, and opens a maximum of one connection to the server at a time. Please don't abuse that, or the server operators might disable access to the FXTP protocol.


Constructor Summary
FXTP(Config conf)
           
 
Method Summary
 java.lang.String cancelOrder(FXTP_Order order, java.lang.String password)
          Cancel an order via the FXTP server.
 FXTP_Claim getClaim(java.lang.String claimName)
          Get an FXTP_Claim object.
 java.util.List getTicker(int maxResults, java.lang.Integer id, java.lang.String symbol, int days)
          Get a ticker from the FXTP server.
 FXTP_User getUser(FXTP_UserId userId)
          Get an FXTP_User object.
 FXTP_User getUser(java.lang.Integer id)
          Lookup a user.
 FXTP_UserId getUserId(int id)
          Call getUser(FXTP_UserId)
 FXTP_UserId getUserId(java.lang.Integer id)
          Resolve an integer id to a full userid.
 FXTP_UserId getUserId(java.lang.String nym)
          Resolve a nym to a userid.
 void init(Registry components)
           
 void refresh(FXTP_UserId id)
          Clear a specific user from the cache
 void refresh(java.lang.Integer id)
          Clear a specific user from the cache
 void refresh(java.lang.String claimName)
          Clear a specific claim from the cache
 java.lang.String submitOrder(FXTP_Order order, java.lang.String password)
          Submit an order to the FXTP server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FXTP

public FXTP(Config conf)
     throws ConfigException
Method Detail

init

public void init(Registry components)
          throws ConfigException
Specified by:
init in interface Component
Throws:
ConfigException

refresh

public void refresh(java.lang.String claimName)
Clear a specific claim from the cache


refresh

public void refresh(java.lang.Integer id)
Clear a specific user from the cache


refresh

public void refresh(FXTP_UserId id)
Clear a specific user from the cache


getUser

public FXTP_User getUser(java.lang.Integer id)
                  throws FXTP_Exception
Lookup a user. Try the cache first and see if we have it already, if not grab it from the server. If you don't want it from the cache, call clearCache(id) first.

Throws:
FXTP_Exception

getUserId

public FXTP_UserId getUserId(java.lang.String nym)
                      throws FXTP_Exception
Resolve a nym to a userid. This only works if we happen to have seen this particular nym before in some previously looked up claim order book, ticker, etc.

Throws:
FXTP_Exception

getUserId

public FXTP_UserId getUserId(java.lang.Integer id)
                      throws FXTP_Exception
Resolve an integer id to a full userid. We try from a local cache first, and if it's not in the cache we fetch it from the server.

Throws:
FXTP_Exception

getUser

public FXTP_User getUser(FXTP_UserId userId)
                  throws FXTP_Exception
Get an FXTP_User object. First we'll try the local cache; if we don't have it already we'll get it from the server. If you need it to be fresh, call clearCache(userId) first.

Throws:
FXTP_Exception

getUserId

public FXTP_UserId getUserId(int id)
                      throws FXTP_Exception
Call getUser(FXTP_UserId)

Throws:
FXTP_Exception

getClaim

public FXTP_Claim getClaim(java.lang.String claimName)
                    throws FXTP_Exception
Get an FXTP_Claim object. First we'll try the local cache; if we don't find it there we'll hit the server. If you need a fresh copy call clearCache(claimName) first.

Throws:
FXTP_Exception

submitOrder

public java.lang.String submitOrder(FXTP_Order order,
                                    java.lang.String password)
                             throws FXTP_Exception
Submit an order to the FXTP server. The result of order processing will be explained in the returned string.

Throws:
FXTP_Exception

cancelOrder

public java.lang.String cancelOrder(FXTP_Order order,
                                    java.lang.String password)
                             throws FXTP_Exception
Cancel an order via the FXTP server. The result of order processing will be explained in the returned string.

Throws:
FXTP_Exception

getTicker

public java.util.List getTicker(int maxResults,
                                java.lang.Integer id,
                                java.lang.String symbol,
                                int days)
                         throws FXTP_Exception
Get a ticker from the FXTP server. You must specify maxResults and the number of days to look back. The id and symbol may be null, in which case any id/symbol will be returned.

Throws:
FXTP_Exception