source: java/main/src/main/java/com/framsticks/params/types/StringParam.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: 1.2 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                assert value instanceof String;
52                String s = (String) value;
53                return (s.contains(SEPARATOR) ? (s = "~" + SEPARATOR + s + "~") : s);
54        }
55}
Note: See TracBrowser for help on using the repository browser.