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

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

HIGHLIGHTS:

  • add SimultorProviders? hierarchy
  • start Framsticks server over SSH
  • FJF compatible with Framsticks 4.0rc3
  • reading and writing of standard.expt
  • a proof-of-concept implementation of StandardExperiment?

CHANGELOG:
Optionally return FreeAccess? from registry.

Add SimulatorRange?.

StandardExperiment? with genotypes circulation.

Automate registration around StandardState?.

More improvements to StandardExperiment?.

Skeleton version of StandardExperiment?.

Test saving of StandardState?.

Standard experiment state is being loaded.

More development towards StandardState? reading.

Work on reading standard experiment state.

Add classes for standard experiment.

Update example standard.expt

Add FreeAccess? and FreeObject?.

Made compatible with version 4.0rc3

Change deserialization policy.

Improve SSH support.

Working running simulator over SSH.

Fix joining bug in Experiment.

Working version of SimulatorRunner?.

Add more SimulatorProviders?.

Working PrimeExperimentTest? with 4.0rc3

Add references to deserialization.

Add OpaqueObject? and it's serialization.

Add deserialization of dictionaries.

Partial implementation of deserialization.

Add more tests for deserialization.

Prepare tests for deserialization.

Add proper result to prime experiment test.

Minor fixes to simulators providers.

Draft version of SimulatorProvider?.

Add SimulatorProvider? interface.

File size: 3.1 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}
114
Note: See TracBrowser for help on using the repository browser.