Hi Carmen-

Really appreciate the link.  I used the library, and got it to work
(kind of).  There seems to be a lot of warnings with it, as well as
odd results with the hash table.  Specifically, this is the code I am
using from Alan's class:

I'm wondering if you have anyone has any hints on simplifying this
code to simply return an Array List of the attributes in the SImpleDB
using the minimum of code.

Thanks!

public List     select( String selectExpression, String nextToken ) throws
Exception {
                TreeMap uriParams       = createStandardParams( "Select" );
                uriParams.put( "SelectExpression",              
selectExpression );

                if ( nextToken != null )
                        uriParams.put( "NextToken",             nextToken );

                uriParams.put( "Signature",     getSignature( uriParams ) );

                /* Make the call */
                URL url = getUrl( uriParams );
                HttpURLConnection con = (HttpURLConnection) 
url.openConnection();
                if (con.getResponseCode() >= 300) {
                        handleErrorAndThrow( getString(con.getErrorStream(), 
"utf-8") );
                }

                String  resp    = getString(con.getInputStream(), "utf-8");
                readResponse( resp );

                List<HashMap> resultList = new ArrayList<HashMap>();

                List itemList = getElements(resp, "Item");
                for (int x = 0; x < itemList.size(); x++) {
                        String i = itemList.get(x).toString();

                        HashMap<String, String[]> map = new HashMap<String, 
String[]>();

                        List nameId = getElements(i, "Name");
                        map.put("ItemName", new 
String[]{nameId.get(0).toString()});

                        List attributes = getElements(i, "Attribute");
                        for (int xx = 0; xx < attributes.size(); xx++) {
                                String t = attributes.get(xx).toString();

                                String key = t.substring(t.indexOf("<Name>") + 
6, t.indexOf("</
Name>"));
                                String val = t.substring(t.indexOf("<Value>") + 
7, t.indexOf("</
Value>"));

                                if ( map.containsKey(key) ){
                                        String[] oldA = (String[])map.get(key);
                                        String[] newA = new String[ oldA.length 
+ 1 ];
                                        System.arraycopy(oldA, 0, newA, 0, 
oldA.length );
                                        newA[ newA.length - 1 ] = val;
                                        map.put( key, newA );
                                }else{
                                        map.put(key, new String[]{val} );
                                }
                        }

                        resultList.add(map);
                }

                return resultList;
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to