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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.example.mockapp.client.mockdata;

import java.io.*;
import java.util.*;

import org.litesoft.bo.*;
import org.litesoft.core.simpletypes.temporal.*;

import com.google.gwt.user.client.rpc.*;

public abstract class MockBo implements BoAccessor, Serializable
{
    private HashMap<String, Attribute> mValues = new HashMap<String, Attribute>();

    private BoMetaData mMetaData;

    @Deprecated
    protected MockBo()
    {
    }

    public MockBo( BoAttribute[] pAttributes, Object... pAttributeValues )
    {
        assert pAttributes.length == pAttributeValues.length;
        mMetaData = new MockBoMetaData( pAttributes );
        for ( int i = 0; i < pAttributes.length; i++ )
        {
            String attributeName = pAttributes[i].getName();
            mValues.put( attributeName, new Attribute( attributeName, pAttributeValues[i] ) );
        }
    }

    public BoMetaData getBoMetaData()
    {
        return mMetaData;
    }

    @SuppressWarnings("unchecked")
    public <T> T getAttributeValue( String pAttributeName )
            throws NoSuchElementException
    {
        Attribute attribute = mValues.get( pAttributeName );

        if ( attribute == null )
        {
            throw new NoSuchElementException( "pAttributeName=" + pAttributeName );
        }

        return (T) attribute.getValue();
    }

    public void setAttributeValue( String pAttributeName, Object pValue )
            throws NoSuchElementException, AttributeIllegalArgumentException
    {
        if ( !mValues.containsKey( pAttributeName ) )
        {
            throw new NoSuchElementException( "pAttributeName=" + pAttributeName );
        }

        mValues.put( pAttributeName, new Attribute( pAttributeName, pValue ) );
    }

    @Override
    public String toString()
    {
        return getDisplayValue();
    }

    private static class Attribute implements Serializable
    {
        private final transient String mName;
        private final transient Object mValue;

        public Attribute( String pName, Object pValue )
        {
            mName = pName;
            mValue = pValue;
        }

        public String getName()
        {
            return mName;
        }

        public Object getValue()
        {
            return mValue;
        }

        @SuppressWarnings("unused")
        private SimpleDate mDate_UnusedForceIncludeClassDefForGwtSerialization;

        @SuppressWarnings("unused")
        private Boolean mBoolean_UnusedForceIncludeClassDefForGwtSerialization;

        @SuppressWarnings("unused")
        private Integer mInteger_UnusedForceIncludeClassDefForGwtSerialization;

        @SuppressWarnings("unused")
        private Long mLong_UnusedForceIncludeClassDefForGwtSerialization;

        @SuppressWarnings("unused")
        private String mString_UnusedForceIncludeClassDefForGwtSerialization;
    }

    @Deprecated
    public static final class Attribute_CustomFieldSerializer
    {
        public static void serialize( SerializationStreamWriter streamWriter, Attribute instance )
                throws SerializationException
        {
            streamWriter.writeString( instance.getName() );
            streamWriter.writeObject( instance.getValue() );
        }

        public static Attribute instantiate( SerializationStreamReader streamReader )
                throws SerializationException
        {
            return new Attribute( streamReader.readString(), streamReader.readObject() );
        }

        public static void deserialize( SerializationStreamReader streamReader, Attribute instance )
        {
            // NOOP
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/MockApp/src/com/example/mockapp/client/mockdata/MockBo.java

Diff revisions: vs.
Revision Author Commited Message
162 GeorgeS picture GeorgeS Fri 01 Apr, 2011 19:58:40 +0000