Subversion Repository Public Repository

litesoft

Diff Revisions 859 vs 862 for /trunk/Java/core/Anywhere/src/org/litesoft/core/simpletypes/temporal/nonpublic/CalendarSupport.java

Diff revisions: vs.
  @@ -64,7 +64,7 @@
64 64 void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource );
65 65 }
66 66
67 - private static final class LiteralChunk implements Chunk
67 + protected static final class LiteralChunk implements Chunk
68 68 {
69 69 private String mLiteral;
70 70
  @@ -104,67 +104,89 @@
104 104 }
105 105 };
106 106
107 - protected static final Chunk M_Chunk = new Chunk()
107 + protected static abstract class MonthChunk implements Chunk
108 108 {
109 109 @Override
110 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
110 + public final void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
111 111 {
112 - pSB.append( pYMDsource.getMonth() );
112 + appendMonthTo(pYMDsource, pSB);
113 + }
114 +
115 + public abstract void appendMonthTo( CalendarAccessorYM pYMsource, StringBuilder pSB );
116 + }
117 +
118 + protected static final MonthChunk M_Chunk = new MonthChunk()
119 + {
120 + @Override
121 + public void appendMonthTo( CalendarAccessorYM pYMsource, StringBuilder pSB )
122 + {
123 + pSB.append( pYMsource.getMonth() );
113 124 }
114 125 };
115 126
116 - protected static final Chunk MM_Chunk = new Chunk()
127 + protected static final MonthChunk MM_Chunk = new MonthChunk()
117 128 {
118 129 @Override
119 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
130 + public void appendMonthTo( CalendarAccessorYM pYMsource, StringBuilder pSB )
120 131 {
121 - pSB.append( Integers.zeroPadIt( 2, pYMDsource.getMonth() ) );
132 + pSB.append( Integers.zeroPadIt( 2, pYMsource.getMonth() ) );
122 133 }
123 134 };
124 135
125 - protected static final Chunk MMMM_Chunk = new Chunk()
136 + protected static final MonthChunk MMMM_Chunk = new MonthChunk()
126 137 {
127 138 @Override
128 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
139 + public void appendMonthTo( CalendarAccessorYM pYMsource, StringBuilder pSB )
129 140 {
130 - pSB.append( Month.nameFromMonthNumber( pYMDsource.getMonth() ) );
141 + pSB.append( Month.nameFromMonthNumber( pYMsource.getMonth() ) );
131 142 }
132 143 };
133 144
134 - protected static final Chunk MMM_Chunk = new Chunk()
145 + protected static final MonthChunk MMM_Chunk = new MonthChunk()
135 146 {
136 147 @Override
137 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
148 + public void appendMonthTo( CalendarAccessorYM pYMsource, StringBuilder pSB )
138 149 {
139 - pSB.append( Month.shortNameFromMonthNumber( pYMDsource.getMonth() ) );
150 + pSB.append( Month.shortNameFromMonthNumber( pYMsource.getMonth() ) );
140 151 }
141 152 };
142 153
143 - protected static final Chunk y_Chunk = new Chunk()
154 + protected static abstract class YearChunk implements Chunk
144 155 {
145 156 @Override
146 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
157 + public final void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
158 + {
159 + appendYearTo( pYMDsource, pSB );
160 + }
161 +
162 + public abstract void appendYearTo( CalendarAccessorY pYsource, StringBuilder pSB );
163 + }
164 +
165 + protected static final YearChunk y_Chunk = new YearChunk()
166 + {
167 + @Override
168 + public void appendYearTo( CalendarAccessorY pYsource, StringBuilder pSB )
147 169 {
148 - pSB.append( pYMDsource.getYear() );
170 + pSB.append( pYsource.getYear() );
149 171 }
150 172 };
151 173
152 - protected static final Chunk yy_Chunk = new Chunk()
174 + protected static final YearChunk yy_Chunk = new YearChunk()
153 175 {
154 176 @Override
155 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
177 + public void appendYearTo( CalendarAccessorY pYsource, StringBuilder pSB )
156 178 {
157 - String zYear = Integers.zeroPadIt( 2, pYMDsource.getYear() );
179 + String zYear = Integers.zeroPadIt( 2, pYsource.getYear() );
158 180 pSB.append( (zYear.length() == 2) ? zYear : zYear.substring( zYear.length() - 2 ) );
159 181 }
160 182 };
161 183
162 - protected static final Chunk yyyy_Chunk = new Chunk()
184 + protected static final YearChunk yyyy_Chunk = new YearChunk()
163 185 {
164 186 @Override
165 - public void appendTo( StringBuilder pSB, CalendarAccessorYMD pYMDsource )
187 + public void appendYearTo( CalendarAccessorY pYsource, StringBuilder pSB )
166 188 {
167 - String zYear = Integers.zeroPadIt( 4, pYMDsource.getYear() );
189 + String zYear = Integers.zeroPadIt( 4, pYsource.getYear() );
168 190 pSB.append( (zYear.length() == 4) ? zYear : zYear.substring( zYear.length() - 4 ) );
169 191 }
170 192 };