Package org.opentransactions.otapi

Examples of org.opentransactions.otapi.StringMap


        // First Lets Check if we already have a password image. (we don't need annother one)
        if (otapi.Exists("moneychanger", "settings.dat")) {

            Storable storable = null;
            StringMap stringMap = null;

            storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_STRING_MAP, "moneychanger", "settings.dat");

            if (null != storable) {

                stringMap = StringMap.ot_dynamic_cast(storable);
                imagePath = stringMap.GetValue("ImagePath");

                File f = new File(imagePath);
                if (f.exists()) {
                    // Good we have a password Image
                    bHaveImage = true;
                }
            }
        }

        // We don't have an image... lets get it from the user, then save it.
        if (!bHaveImage) {

            for (;;) {
                imagePath = passwordImage.GetPasswordImageFromUser("passwordImage");
               
                if (passwordImage.GetIfUserCancelled()) {
                    bHaveImage = false;
                    break;
                }

                File f = new File(imagePath);
                if (f.exists()) {
                    bHaveImage = true;
                    // Good we have a password Image
                    break;
                }
            }
           
            if (!bHaveImage)
            {
                return false;
            }

            StringMap stringMap = null// we are about to create this object
            Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_STRING_MAP);

            if (storable != null) {
                stringMap = StringMap.ot_dynamic_cast(storable);
                System.out.println("stringMap:" + stringMap);

                if (stringMap != null) {
                    //stringMap.SetValue("ImagePath", "~/.ot/default.gif");
                    stringMap.SetValue("ImagePath", imagePath);
                    bHaveImage = otapi.StoreObject(stringMap, "moneychanger", "settings.dat");
                }
            }
        }
View Full Code Here


        System.out.println("getRegisteredAssets - serverID:" + serverID + " nymID:" + nymID);

        List registeredAssetsList = null;

        String strEncodedObj = null; // output will go here.
        StringMap stringMap = null// we are about to create this object

        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;

        // When the server reply comes back, get the payload from it:

        if (Utility.VerifyStringVal(strResponse)) {
            strReplyMap = otapiJNI.OTAPI_Basic_Message_GetPayload(strResponse);
        }
        System.out.println("strResponse is " + strResponse);

        //  Pass the payload (the StringMap from the server's reply) to otapi.DecodeObject:

        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();
                            }
View Full Code Here

TOP

Related Classes of org.opentransactions.otapi.StringMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.