source: java/main/src/main/java/com/framsticks/params/types/StringParam.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: 1.3 KB
Line 
1package com.framsticks.params.types;
2
3import com.framsticks.params.CastFailure;
4import com.framsticks.params.ParamBuilder;
5import com.framsticks.params.PrimitiveParam;
6import com.framsticks.params.ReassignResult;
7
8import javax.annotation.concurrent.Immutable;
9
10/**
11 * @author Piotr Sniegowski
12 */
13@Immutable
14public class StringParam extends PrimitiveParam<String> {
15
16
17
18        /**
19         * @param builder
20         */
21        public StringParam(ParamBuilder builder) {
22                super(builder);
23        }
24
25        @Override
26        public Class<?> getStorageType() {
27                return String.class;
28        }
29
30        @Override
31        public ReassignResult<String> reassign(Object newValue, Object oldValue) throws CastFailure {
32                if (newValue == null) {
33                        return new ReassignResult<String>(null);
34                }
35                if (newValue instanceof String) {
36                        return ReassignResult.create((String) newValue);
37                }
38                return ReassignResult.create(newValue.toString());
39                // return super.reassign(newValue, oldValue);
40        }
41
42        @Override
43        public String getFramsTypeName() {
44                return "s";
45        }
46
47        private static final String SEPARATOR = System.getProperty("line.separator");
48
49        @Override
50        public String serialize(Object value) {
51                if (value == null) {
52                        return "";
53                }
54                assert value instanceof String;
55                String s = (String) value;
56                return (s.contains(SEPARATOR) ? (s = "~" + SEPARATOR + s + "~") : s);
57        }
58}
Note: See TracBrowser for help on using the repository browser.