Subversion Repository Public Repository

litesoft

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package org.litesoft.GWT.client.localstorage;

import org.litesoft.commonfoundation.annotations.*;

public class Html5LocalStorageImpl implements Html5LocalStorage
{
    /**
     * Return the number of key/value pairs currently present.
     */
    @Override
    public native int length() /*-{
        return $wnd.localStorage.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.
     */
    @Override
    public native String key( int index ) /*-{
        $wnd.localStorage.key( 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.
     */
    @Override
    public native String getItem( @NotNull String key ) /*-{
        return $wnd.localStorage.getItem( 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.
     */
    @Override
    public native boolean setItem( @NotNull String key, @NotNull String value ) /*-{
        try
        {
            $wnd.localStorage.setItem( key, value );
            return true;
        }
        catch(err) // QuotaExceededError?
        {
            return false;
        }
    }-*/;

    /**
     * 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).
     */
    @Override
    public native void removeItem( @NotNull String key ) /*-{
        $wnd.localStorage.removeItem( 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.
     */
    @Override
    public native void clear() /*-{
        $wnd.localStorage.clear();
    }-*/;
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/localstorage/Html5LocalStorageImpl.java

Diff revisions: vs.
Revision Author Commited Message
939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

764 Diff Diff GeorgeS picture GeorgeS Thu 12 Jul, 2012 14:22:25 +0000
758 GeorgeS picture GeorgeS Wed 11 Jul, 2012 03:57:35 +0000

!