 (defn- keystr [x]
   (if (keyword? x) (name x) (str x)))
 
-(defn- make-attr-list [keyvals]
+(defn- make-attr-list
+  "Given a map of key=>value or key=>[values], return a List of
+  ItemAttribute objects."
+  [keyvals]
   (let [attrs (ArrayList.)]
     (doseq [[k v] keyvals]
       (if (coll? v)

        (.add attrs (ItemAttribute. (keystr k) (keystr v) true))))
    attrs))

(defn- parse-attr-list [attrs]
  (reduce (fn [m attr]
            (let [k (.getName attr), v (.getValue attr)]
              (assoc m k

    (.putAttributes item (make-attr-list keyvals))))

(defn get-attrs
  "Returns attributes (a map of key=>item or key=>collection).
  Arguments may be either an Item object by itself or strings naming a
  domain and an item."
  ([item] (parse-attr-list (.getAttributes item)))
  ([domain-name item-name]
     (let [item (get-item domain-name item-name)]
       (parse-attr-list (.getAttributes item)))))

(defn delete-item
  "Delete the item from the domain."
  [domain-name item-name]
  (.deleteItem (get-domain domain-name) (keystr item-name)))

(defn list-items
  "Get the list of Item objects, optionally filtered by a Query
  string."
  ([domain-name]
     (.getItemList (.listItems (get-domain domain-name))))
  ([domain-name query-string]
