Title: SIX Java API
1SIX Java API
- An API for the SIXP Server
2Overview
3Objectives
- Handles the communication
- Interprets the SIXP protocol
- Converts SIXP messages into Java classes and vice
versa - Passes responses as Java classes to the user
- Asynchronous communication
4Commands
Requests
Responses
- Login
- Logout
- Get
- Subscribe
- Get Field Set
- Unsubscribe
- Create
- Put
- Delete
- Login
- Logout
- Data
- --
- Get Field Set
- Unsubscribe
- Create
- Put
- Delete
- Exception
5Asynchronous response requires some kind of
identification
- The response itself, e.g. Login
- Usage of Cookies
- Subscription Id (only for Subscribe)
6Usage of Cookies
7Usage of Subscription Id
8Sending request to the Server
- SixEventHandler.send( SixRequest )
- SixHandler.send( SixRequest )
9Receive response from the Server
- The user implements the interface
SixResponseListener and receives data through the
processXXXResponse() methods.
SixResponseListener
User Appl
processXXXResponse()
SIXP Server
SixEventHandler
send()
10Receive response from the Server
- The user extends the helper class
SixResponseAdapter and overrides actual
processXXXResponse() - SixResponseAdapter implements SixResponseListener
with null action
public class MyReceiver extends
sixapi.SixResponseAdapter void
processDataResponse( SixDataRes res )
...
11Receive response from the Server
- The user uses the SixHandler (instead of
SixEventHandler) and implements
java.util.Observer. - All data is received through the update()
method.
java.util.Observer
User Appl
update()
SIXP Server
SixHandler
send()
12Kind of data response
Text data
E.g. News text such as information from
Nyhetsbyrån Direkt. java.io.BufferedReader r
response.getTextStream() String line while ( (
line r.readLine() ) ! null )
System.out.println( line )
Table data
E.g. financial information such as equities and
derivatives.
13Table data
- SixGetReq and SixSubscribeReq request the SIXP
Server to send a complete table - SixSubscribeReq also requests the SIXP Server to
send table updates - Tables and table updates are received as
SixDataRes objects - Table updates are smaller tables only containing
affected records (rows) and fields (columns) - Reading a table data (two ways)
Loop through all records get record data
loop through all fields get field data
Call traverse() and get a callback for each field
14Table data
A table can logically be described as a
multi-linked list
15Table data (Record)
- Record id
- Update kind
- REC_NEW
- REC_CHANGED
- REC_DELETED
- REC_UNCHANGED
- REC_FULL
- Number of fields
16Table data (Field)
- Field id
- Field Type
- FT_BOOL (Boolean) FT_FLOAT (Double)
- FT_BYTE (Integer) FT_STRING (String)
- FT_WORD (Integer) FT_TIMESTAMP (SixTimeStamp)
- FT_DWORD (Long) FT_SYMBOL (Integer)
- FT_SHORT (Long) FT_LINK (String)
- FT_LONG (Long)
- Data
- Object
17Field set information
The Field Set information is a table with fixed
format that describes the fields available in
another table. The field set response is a
kind of SixDataRes response. A record in the
field set corresponds to a field in the table it
describes. In the Java API, the API handles the
field set table data internally and offers
methods to get information for each record.
- name
- flags (key, sort, updateable, ...)
- key order (used if key field)
- sort order (used if more than one sort field)
- field type
- field length (in bytes)
18Error Handling
- Error when calling API methods
- Error detected within the API
- Error detected in the SIXP Server
19Error when calling the API
Errors detected by the API when calling a method
is normally thrown as a SixException (subclass
of java.lang.Exception). Example try
sixEventHandler.send( request ) catch (
sixapi.SixException err )
System.out.println( Error err )
20Receiving error response
Errors detected within the API or in the SIXP
Server are passed back to the user as an error
response. In processErrorResponse(), if using
SixEventHandler In update(), if using
SixHandler Example public void
processErrorResponse( SixException response
) System.out.println( Error response
)
21Differences from old APIs, e.g. NT API
- Data is delivered as application data, e.g.
SixDataRes, and not as plain byte stream data - No need for reading missing data from temporary
disk files - Changes in the protocol does normally not affect
the application - ...
22FAQ
Q What is included in the Java API? A Java
class files (sixapi.zip) and Documention
(javadocs.zip)
Q How do I get the Java API? A Visit
http//www2.six.se/java.htm or http//sixtrader.si
x.se
Q What do I need more? A Communication link to
a SIXP Server. Contact SIX for more
information.
23System.exit( 0 )