Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/objects/PropertyMetaData.java

Diff revisions: vs.
  @@ -1,83 +1,83 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.aokeyhole.objects;
3 -
4 - import org.litesoft.aokeyhole.objects.support.*;
5 - import org.litesoft.aokeyhole.toolkit.*;
6 -
7 - public abstract class PropertyMetaData extends AbstractConfigMetaData implements ValueStringConverter {
8 - public static final PropertyMetaData[] EMPTY_ARRAY = new PropertyMetaData[0];
9 -
10 - public static final String TYPE = "Property";
11 -
12 - private String mName;
13 - private String mDisplayLabel;
14 - private DataType mDataType;
15 - private Required mRequired;
16 - private Object mInitialValue;
17 -
18 - protected PropertyMetaData( String pName, String pDisplayLabel, DataType pDataType, Required pRequired, Object pInitialValue ) {
19 - super( TYPE );
20 -
21 - mName = noNull( pName, "Name" );
22 - mDisplayLabel = noNull( pDisplayLabel, "DisplayLabel" );
23 - mDataType = noNull( pDataType, "DataType" );
24 - mRequired = (pRequired != null) ? pRequired : Required.NO;
25 - mInitialValue = pInitialValue;
26 - }
27 -
28 - public String getName() {
29 - return mName;
30 - }
31 -
32 - public String getDisplayLabel() {
33 - return mDisplayLabel;
34 - }
35 -
36 - public DataType getDataType() {
37 - return mDataType;
38 - }
39 -
40 - public Required getRequired() {
41 - return mRequired;
42 - }
43 -
44 - public Object getInitialValue() {
45 - return mInitialValue;
46 - }
47 -
48 - public String[] getValidOptions() {
49 - return null;
50 - }
51 -
52 - @Override
53 - public Object validateAndNormalize( Object pValue )
54 - throws ParseException {
55 - return pValue;
56 - }
57 -
58 - @Override
59 - public String valueToString( Object pValue ) {
60 - return (pValue == null) ? "" : pValue.toString();
61 - }
62 -
63 - protected String noNull( String pOrig, String pWhat ) {
64 - if ( pOrig == null ) {
65 - throw new IllegalStateException( pWhat + " may Not be null" );
66 - }
67 -
68 - return pOrig;
69 - }
70 -
71 - protected DataType noNull( DataType pOrig, String pWhat ) {
72 - if ( pOrig == null ) {
73 - throw new IllegalStateException( pWhat + " may Not be null" );
74 - }
75 -
76 - return pOrig;
77 - }
78 -
79 - @Override
80 - public String toString() {
81 - return mName + (mRequired.isData() ? "*" : "");
82 - }
83 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.aokeyhole.objects;
3 +
4 + import org.litesoft.aokeyhole.objects.support.*;
5 + import org.litesoft.aokeyhole.toolkit.*;
6 +
7 + public abstract class PropertyMetaData extends AbstractConfigMetaData implements ValueStringConverter {
8 + public static final PropertyMetaData[] EMPTY_ARRAY = new PropertyMetaData[0];
9 +
10 + public static final String TYPE = "Property";
11 +
12 + private String mName;
13 + private String mDisplayLabel;
14 + private DataType mDataType;
15 + private Required mRequired;
16 + private Object mInitialValue;
17 +
18 + protected PropertyMetaData( String pName, String pDisplayLabel, DataType pDataType, Required pRequired, Object pInitialValue ) {
19 + super( TYPE );
20 +
21 + mName = noNull( pName, "Name" );
22 + mDisplayLabel = noNull( pDisplayLabel, "DisplayLabel" );
23 + mDataType = noNull( pDataType, "DataType" );
24 + mRequired = (pRequired != null) ? pRequired : Required.NO;
25 + mInitialValue = pInitialValue;
26 + }
27 +
28 + public String getName() {
29 + return mName;
30 + }
31 +
32 + public String getDisplayLabel() {
33 + return mDisplayLabel;
34 + }
35 +
36 + public DataType getDataType() {
37 + return mDataType;
38 + }
39 +
40 + public Required getRequired() {
41 + return mRequired;
42 + }
43 +
44 + public Object getInitialValue() {
45 + return mInitialValue;
46 + }
47 +
48 + public String[] getValidOptions() {
49 + return null;
50 + }
51 +
52 + @Override
53 + public Object validateAndNormalize( Object pValue )
54 + throws ParseException {
55 + return pValue;
56 + }
57 +
58 + @Override
59 + public String valueToString( Object pValue ) {
60 + return (pValue == null) ? "" : pValue.toString();
61 + }
62 +
63 + protected String noNull( String pOrig, String pWhat ) {
64 + if ( pOrig == null ) {
65 + throw new IllegalStateException( pWhat + " may Not be null" );
66 + }
67 +
68 + return pOrig;
69 + }
70 +
71 + protected DataType noNull( DataType pOrig, String pWhat ) {
72 + if ( pOrig == null ) {
73 + throw new IllegalStateException( pWhat + " may Not be null" );
74 + }
75 +
76 + return pOrig;
77 + }
78 +
79 + @Override
80 + public String toString() {
81 + return mName + (mRequired.isData() ? "*" : "");
82 + }
83 + }