equal
deleted
inserted
replaced
32 import java.nio.CharBuffer; |
32 import java.nio.CharBuffer; |
33 import java.nio.BufferOverflowException; |
33 import java.nio.BufferOverflowException; |
34 import java.nio.BufferUnderflowException; |
34 import java.nio.BufferUnderflowException; |
35 import java.lang.ref.WeakReference; |
35 import java.lang.ref.WeakReference; |
36 import java.nio.charset.CoderMalfunctionError; // javadoc |
36 import java.nio.charset.CoderMalfunctionError; // javadoc |
|
37 import java.util.Arrays; |
37 |
38 |
38 |
39 |
39 /** |
40 /** |
40 * An engine that can transform a sequence of $itypesPhrase$ into a sequence of |
41 * An engine that can transform a sequence of $itypesPhrase$ into a sequence of |
41 * $otypesPhrase$. |
42 * $otypesPhrase$. |
242 * |
243 * |
243 * @return This $coder$'s current replacement, |
244 * @return This $coder$'s current replacement, |
244 * which is never <tt>null</tt> and is never empty |
245 * which is never <tt>null</tt> and is never empty |
245 */ |
246 */ |
246 public final $replType$ replacement() { |
247 public final $replType$ replacement() { |
|
248 #if[decoder] |
247 return replacement; |
249 return replacement; |
|
250 #end[decoder] |
|
251 #if[encoder] |
|
252 return Arrays.copyOf(replacement, replacement.$replLength$); |
|
253 #end[encoder] |
248 } |
254 } |
249 |
255 |
250 /** |
256 /** |
251 * Changes this $coder$'s replacement value. |
257 * Changes this $coder$'s replacement value. |
252 * |
258 * |
278 int len = newReplacement.$replLength$; |
284 int len = newReplacement.$replLength$; |
279 if (len == 0) |
285 if (len == 0) |
280 throw new IllegalArgumentException("Empty replacement"); |
286 throw new IllegalArgumentException("Empty replacement"); |
281 if (len > max$ItypesPerOtype$) |
287 if (len > max$ItypesPerOtype$) |
282 throw new IllegalArgumentException("Replacement too long"); |
288 throw new IllegalArgumentException("Replacement too long"); |
|
289 #if[decoder] |
|
290 this.replacement = newReplacement; |
|
291 #end[decoder] |
283 #if[encoder] |
292 #if[encoder] |
284 if (!isLegalReplacement(newReplacement)) |
293 if (!isLegalReplacement(newReplacement)) |
285 throw new IllegalArgumentException("Illegal replacement"); |
294 throw new IllegalArgumentException("Illegal replacement"); |
|
295 this.replacement = Arrays.copyOf(newReplacement, newReplacement.$replLength$); |
286 #end[encoder] |
296 #end[encoder] |
287 this.replacement = newReplacement; |
297 implReplaceWith(this.replacement); |
288 implReplaceWith(newReplacement); |
|
289 return this; |
298 return this; |
290 } |
299 } |
291 |
300 |
292 /** |
301 /** |
293 * Reports a change to this $coder$'s replacement value. |
302 * Reports a change to this $coder$'s replacement value. |