org.directwebremoting.io
Class Item

java.lang.Object
  extended by org.directwebremoting.io.Item

public class Item
extends java.lang.Object

Analogous to a Map.Entry that we use to pass objects that have been stored in a StoreProvider to the Internet. TODO: Consider if we should add version field to this so we can add some sort of pessimistic locking to updates.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
Item(java.util.Map.Entry<java.lang.String,java.lang.Object> entry)
          Create an Item with its ID and data from a Map.Entry
Item(java.lang.String itemId, java.lang.Object data)
          Create an Item with its ID and data.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getData()
          The object that is referred to by the itemId.
 java.lang.String getItemId()
          Accessor for the primary key for this Object.
 java.lang.String getLabel()
          Items need labels to support dojo.data.api.Read.getLabel() By default we just use the itemId, however if the data implements ExposeToString then consider Object.toString() to be safe for Internet use.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Item

public Item(java.lang.String itemId,
            java.lang.Object data)
Create an Item with its ID and data.


Item

public Item(java.util.Map.Entry<java.lang.String,java.lang.Object> entry)
Create an Item with its ID and data from a Map.Entry

Method Detail

getItemId

public java.lang.String getItemId()
Accessor for the primary key for this Object. Clearly not all database primary keys are Strings, my current feeling is that the majority of database primary keys can either be simply mapped to strings, or are a bad idea anyway.

Warning: It would be a bad idea to expose database primary keys directly to the Internet anyway, so some form of mapping is required.

Returns:
The primary key for this Object

getData

public java.lang.Object getData()
The object that is referred to by the itemId.

Returns:
The real data

getLabel

public java.lang.String getLabel()
Items need labels to support dojo.data.api.Read.getLabel() By default we just use the itemId, however if the data implements ExposeToString then consider Object.toString() to be safe for Internet use.

Returns:
A label for this object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2008