use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.
the class Basket method getRegisteredAssets.
public static List getRegisteredAssets(String serverID, String nymID) {
System.out.println("getRegisteredAssets - serverID:" + serverID + " nymID:" + nymID);
List registeredAssetsList = null;
// output will go here.
String strEncodedObj = null;
// we are about to create this object
StringMap stringMap = null;
Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_STRING_MAP);
if (storable != null) {
stringMap = StringMap.ot_dynamic_cast(storable);
if (stringMap != null) {
// ADD ALL THE ASSET IDs HERE (To the string map, so you
// can ask the server about them...)
//
int count = otapiJNI.OTAPI_Basic_GetAssetTypeCount();
System.out.println(" count:" + count);
for (int i = 0; i < count; i++) {
String key = otapiJNI.OTAPI_Basic_GetAssetType_ID(i);
System.out.println("key:" + key);
stringMap.SetValue(key, "exists");
}
System.out.println(" BEFORE ENCODE,stringMap:" + stringMap);
strEncodedObj = otapi.EncodeObject(stringMap);
}
}
System.out.println(" fter ENCODE,strEncodedObj:" + strEncodedObj);
if (!Utility.VerifyStringVal(strEncodedObj)) {
System.out.println("strEncodedObj is null");
return null;
//Error;
}
// Then send the server message
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.QUERY_ASSET_TYPES, serverID, nymID, strEncodedObj);
System.out.println(" theRequest :" + theRequest);
String strResponse = theRequest.SendRequest(theRequest, "QUERY_ASSET_TYPES");
System.out.println(" strResponse:" + strResponse);
String strReplyMap = null;
if (Utility.VerifyStringVal(strResponse)) {
strReplyMap = otapiJNI.OTAPI_Basic_Message_GetPayload(strResponse);
}
System.out.println("strResponse is " + strResponse);
if (Utility.VerifyStringVal(strReplyMap)) {
StringMap stringMapOutput = null;
storable = otapi.DecodeObject(StoredObjectType.STORED_OBJ_STRING_MAP, strReplyMap);
if (storable != null) {
stringMapOutput = StringMap.ot_dynamic_cast(storable);
if (stringMapOutput != null) {
// Loop through string map. For each asset ID key, the value will
// say either "true" or "false".
int count = otapiJNI.OTAPI_Basic_GetAssetTypeCount();
for (int i = 0; i < count; i++) {
String key = otapiJNI.OTAPI_Basic_GetAssetType_ID(i);
System.out.println("key in output:" + key);
String isRegistered = stringMapOutput.GetValue(key);
System.out.println("isRegistered in output:" + isRegistered);
if ("true".equalsIgnoreCase(isRegistered)) {
if (registeredAssetsList == null) {
registeredAssetsList = new ArrayList();
}
registeredAssetsList.add(key);
}
}
}
}
}
System.out.println("registeredAssetsList is " + registeredAssetsList);
return registeredAssetsList;
}
use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.
the class Helpers method getMarketList.
public static MarketList getMarketList(String serverID) {
MarketList marketList = null;
Storable storable = null;
if (otapi.Exists("markets", serverID, "market_data.bin")) {
storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_MARKET_LIST, "markets", serverID, "market_data.bin");
if (storable == null) {
return null;
}
marketList = MarketList.ot_dynamic_cast(storable);
} else {
storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_MARKET_LIST);
if (storable == null) {
return null;
}
marketList = MarketList.ot_dynamic_cast(storable);
}
return marketList;
}
use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.
the class Helpers method getNYMTrades.
public static TradeListNym getNYMTrades(String serverID, String nymID) {
TradeListNym tradeListNym = null;
Storable storable = null;
if (otapi.Exists("nyms", "trades", serverID, nymID)) {
storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_TRADE_LIST_NYM, "nyms", "trades", serverID, nymID);
if (storable == null) {
return null;
}
tradeListNym = TradeListNym.ot_dynamic_cast(storable);
} else {
storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_TRADE_LIST_NYM);
if (storable == null) {
return null;
}
tradeListNym = TradeListNym.ot_dynamic_cast(storable);
}
return tradeListNym;
}
use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.
the class Helpers method getAddressBook.
public static AddressBook getAddressBook() {
AddressBook addressBook = null;
Storable storable = null;
if (otapi.Exists("moneychanger", "gui_contacts.dat")) {
storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_ADDRESS_BOOK, "moneychanger", "gui_contacts.dat");
if (storable == null) {
return null;
}
addressBook = AddressBook.ot_dynamic_cast(storable);
} else {
storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_ADDRESS_BOOK);
if (storable == null) {
return null;
}
addressBook = AddressBook.ot_dynamic_cast(storable);
}
return addressBook;
}
use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.
the class Helpers method getMarketOffer.
public static OfferListMarket getMarketOffer(String serverID, String marketID) {
OfferListMarket offerListMarket = null;
Storable storable = null;
if (otapi.Exists("markets", serverID, "offers", marketID + ".bin")) {
storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_OFFER_LIST_MARKET, "markets", serverID, "offers", marketID + ".bin");
if (storable == null) {
return null;
}
offerListMarket = OfferListMarket.ot_dynamic_cast(storable);
} else {
storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_OFFER_LIST_MARKET);
if (storable == null) {
return null;
}
offerListMarket = OfferListMarket.ot_dynamic_cast(storable);
}
return offerListMarket;
}
Aggregations