Subversion Repository Public Repository

litesoft

Diff Revisions 830 vs 838 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/swing/mains/mementobeans/support/BeanAttributeProperties.java

Diff revisions: vs.
  @@ -1,5 +1,7 @@
1 1 package org.litesoft.aokeyhole.swing.mains.mementobeans.support;
2 2
3 + import java.util.*;
4 +
3 5 import org.litesoft.core.typeutils.*;
4 6
5 7 public enum BeanAttributeProperties
  @@ -26,63 +28,106 @@
26 28 NullEmpties
27 29 {
28 30 @Override
29 - public String getData( AttributeData pAttribute )
31 + public void setFlag( AttributeData pAttribute, boolean pValue )
30 32 {
31 - return flag( pAttribute.isNullEmpties() );
33 + pAttribute.mNullEmpties = pValue;
32 34 }
33 35
34 36 @Override
35 - public boolean shouldRecord( String pValue, String[] pAdditionalValues )
37 + public Boolean getFlag( AttributeData pAttribute )
36 38 {
37 - return flag( pValue );
39 + return pAttribute.isNullEmpties();
38 40 }
39 41 },
40 42 NullZeros
41 43 {
42 44 @Override
43 - public String getData( AttributeData pAttribute )
45 + public void setFlag( AttributeData pAttribute, boolean pValue )
44 46 {
45 - return flag( pAttribute.isNullZeros() );
47 + pAttribute.mNullZeros = pValue;
46 48 }
47 49
48 50 @Override
49 - public boolean shouldRecord( String pValue, String[] pAdditionalValues )
51 + public Boolean getFlag( AttributeData pAttribute )
50 52 {
51 - return flag( pValue );
53 + return pAttribute.isNullZeros();
52 54 }
53 55 },
54 56 NullFalses
55 57 {
56 58 @Override
57 - public String getData( AttributeData pAttribute )
59 + public void setFlag( AttributeData pAttribute, boolean pValue )
58 60 {
59 - return flag( pAttribute.isNullFalses() );
61 + pAttribute.mNullFalses = pValue;
60 62 }
61 63
62 64 @Override
63 - public boolean shouldRecord( String pValue, String[] pAdditionalValues )
65 + public Boolean getFlag( AttributeData pAttribute )
64 66 {
65 - return flag( pValue );
67 + return pAttribute.isNullFalses();
66 68 }
67 69 },
68 70 Repeating
69 71 {
70 72 @Override
71 - public String getData( AttributeData pAttribute )
73 + public void setFlag( AttributeData pAttribute, boolean pValue )
72 74 {
73 - return flag( pAttribute.isRepeating() );
75 + pAttribute.mRepeating = pValue;
74 76 }
75 77
76 78 @Override
77 - public boolean shouldRecord( String pValue, String[] pAdditionalValues )
79 + public Boolean getFlag( AttributeData pAttribute )
78 80 {
79 - return flag( pValue );
81 + return pAttribute.isRepeating();
80 82 }
81 83 };
82 84
83 - abstract public String getData( AttributeData pAttribute );
85 + private final String mMethodCall;
84 86
85 - abstract public boolean shouldRecord( String pValue, String[] pAdditionalValues );
87 + private BeanAttributeProperties()
88 + {
89 + mMethodCall = "." + name().substring( 0, 1 ).toLowerCase() + name().substring( 1 ) + "()";
90 + }
91 +
92 + public void appendFlag( AttributeData pAttribute, StringBuilder pSB )
93 + {
94 + Boolean zFlag = getFlag( pAttribute );
95 + if ( Boolean.TRUE.equals( zFlag ) )
96 + {
97 + pSB.append( mMethodCall );
98 + }
99 + }
100 +
101 + public void parseFlag( AttributeData pAttribute, StringBuilder pFlags )
102 + {
103 + int zAt = pFlags.indexOf( mMethodCall );
104 + boolean zFound = (zAt != -1);
105 + if ( zFound )
106 + {
107 + pFlags.delete( zAt, zAt + mMethodCall.length() );
108 + }
109 + setFlag( pAttribute, zFound );
110 + }
111 +
112 + public void setFlag( AttributeData pAttribute, boolean pValue )
113 + {
114 + // Default behavior is to NOT set the value!
115 + }
116 +
117 + public Boolean getFlag( AttributeData pAttribute )
118 + {
119 + return null; // Indicate that the Property does NOT have the flag!
120 + }
121 +
122 + public String getData( AttributeData pAttribute )
123 + {
124 + return flag( getFlag( pAttribute ) );
125 + }
126 +
127 + public boolean shouldRecord( String pValue, String[] pAdditionalValues )
128 + {
129 + return flag( pValue );
130 + }
86 131
87 132 public BeanAttributeProperties next()
88 133 {
  @@ -91,9 +136,21 @@
91 136 return (index < zValues.length) ? zValues[index] : null;
92 137 }
93 138
94 - protected String flag( boolean pFlag )
139 + public boolean isTrueIn( List<BeanPropertyBuilder> pProperties )
140 + {
141 + for ( BeanPropertyBuilder zProperty : pProperties )
142 + {
143 + if ( this.name().equals( zProperty.getName() ) )
144 + {
145 + return flag( zProperty.getValue() );
146 + }
147 + }
148 + return false;
149 + }
150 +
151 + protected String flag( Boolean pFlag )
95 152 {
96 - return pFlag ? "true" : null;
153 + return Boolean.TRUE.equals( pFlag ) ? "true" : null;
97 154 }
98 155
99 156 protected boolean flag( String pFlag )