litesoft
@ 939
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
package org.litesoft.GWT.client.localstorage; import org.litesoft.commonfoundation.annotations.*; /** * Specification for the HTML5 Local Storage api. * <p/> * Note: The setItem() and removeItem() methods must be atomic with respect to failure. * In the case of failure, the method does nothing. That is, changes to the data storage * area must either be successful, or the data storage area must not be changed at all. */ public interface Html5LocalStorage { /** * Return the number of key/value pairs currently present. */ int length(); /** * The key(<code>index</code>) method will return the name of the nth key in the list. * The order of keys is user-agent defined, but MUST BE CONSISTENT * so long as the number of keys doesn't change. (Thus, adding or * removing a key may change the order of the keys, but merely changing * the value of an existing key must not.) If <code>index</code> is greater than or equal * to the number of key/value pairs, then this method must return null. * * @param index of the key name to retrieve (index < 0 has un-specified behavior). * * @return key name if index is in range, null if index too large. */ String key( int index ); /** * The getItem(<code>key</code>) method will return the current value associated with the given <code>key</code>. * If the given <code>key</code> does not exist then a null is returned. * * @param key non-null key to lookup (any whitespace in the key has un-specified behavior). * * @return non-null value associated with <code>key</code> or null if <code>key</code> has no association. */ String getItem( @NotNull String key ); /** * The setItem(key, value) method atomically stores the passed key/value pair by either * adding or updating as is appropriate if it can. * It first checks if there is already an entry for key. * If there is not, then the new key/value pair is added. * If there is, then the existing value is replaced/updated with the new value. * There are two reasons that the new key/value pair might not be able to be stored: either the * the user has disabled storage for the site, or the quota has been exceeded. * * @param key non-null key to store (any whitespace in the key has un-specified behavior). * @param value non-null value to store/associate with the key. * * @return true if the key/value pair was successfully stored. */ boolean setItem( @NotNull String key, @NotNull String value ); /** * The removeItem(key) method will cause the key/value pair with * the given key to be removed, if it exists. If no entry with that * key exists, the method does nothing. * * @param key non-null key to remove (any whitespace in the key has un-specified behavior). */ void removeItem( @NotNull String key ); /** * The clear() method will atomically remove all the key/value * pairs, if there are any. If there are no key/value * pairs when it checks, then the method does nothing. */ void clear(); } |