source: java/main/src/main/java/com/framsticks/params/PropertiesAccess.java @ 105

Last change on this file since 105 was 105, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File size: 3.0 KB
Line 
1package com.framsticks.params;
2
3import com.framsticks.params.types.EventParam;
4import com.framsticks.params.types.ProcedureParam;
5
6/**
7 * The Class PropertiesAccess.
8 *
9 * @author Jarek Szymczak <name.surname@gmail.com> (please replace name and
10 *         surname with my personal data)
11 *
12 * @author Piotr Śniegowski
13 */
14public class PropertiesAccess extends SimpleAbstractAccess {
15
16        protected PropertiesObject properties;
17
18        @Override
19        public PropertiesObject createAccessee() {
20                return new PropertiesObject(framsClass.getId());
21        }
22
23        public PropertiesAccess(FramsClass framsClass) {
24                super(framsClass);
25        }
26
27        @Override
28        public void clearValues() {
29                assert properties != null;
30                properties.clear();
31        }
32
33        @Override
34        public <T> T get(ValueParam param, Class<T> type) {
35                assert properties != null;
36                assert param != null;
37                Object object = properties.get(param.getId(), Object.class);
38                if (object == null) {
39                        return null;
40                }
41                try {
42                        return type.cast(object);
43                } catch (ClassCastException e) {
44                        throw (ClassCastException) new ClassCastException("property " + param + " type is " + object.getClass().getName() + ", not " + type.getName()).initCause(e);
45                }
46        }
47
48        @Override
49        protected <T> void internalSet(ValueParam param, T value) {
50                properties.set(param.getId(), value);
51        }
52
53        /**
54         * Sets the new values to operate on. It does not check whether the values
55         * which are set through this method are correct. If set values are not
56         * correct exceptions might occurred while getting / setting the parameters
57         * values
58         *
59         * @param object
60         *            the properties with parameters values
61         */
62        @Override
63        public PropertiesAccess select(Object object) {
64                properties = ParamsUtil.selectObjectForAccess(this, object, PropertiesObject.class);
65                return this;
66        }
67
68        /** covariant */
69        @Override
70        public PropertiesObject getSelected() {
71                return properties;
72        }
73
74        @Override
75        public PropertiesAccess cloneAccess() {
76                return new PropertiesAccess(framsClass);
77        }
78
79        @Override
80        public void tryAutoAppend(Object object) {
81                throw new InvalidOperationException();
82        }
83
84        @Override
85        public Object call(String id, Object... arguments) {
86                throw new InvalidOperationException().msg("properties access does not support calling methods").arg("id", id);
87        }
88
89        @Override
90        public Object call(ProcedureParam param, Object... arguments) {
91                throw new InvalidOperationException().msg("properties access does not support calling methods").arg("param", param);
92        }
93
94        @Override
95        public void reg(EventParam param, EventListener<?> listener) {
96                throw new InvalidOperationException().msg("properties access does not support registering events").arg("param", param).arg("access", this);
97        }
98
99        @Override
100        public void regRemove(EventParam param, EventListener<?> listener) {
101                throw new InvalidOperationException().msg("properties access does not support registering events").arg("param", param).arg("access", this);
102        }
103
104        @Override
105        public String toString() {
106                StringBuilder b = new StringBuilder();
107                b.append(framsClass);
108                if (getSelected() != null) {
109                        b.append("(").append(getSelected().size()).append(")");
110                }
111                return b.toString();
112        }
113}
Note: See TracBrowser for help on using the repository browser.