LEFT | RIGHT |
1 // © 2017 and later: Unicode, Inc. and others. | 1 // © 2017 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 package com.ibm.icu.impl.number; | 3 package com.ibm.icu.impl.number; |
4 | 4 |
5 import java.text.AttributedCharacterIterator; | 5 import java.text.AttributedCharacterIterator; |
6 import java.text.FieldPosition; | 6 import java.text.FieldPosition; |
7 import java.util.ArrayDeque; | 7 import java.util.ArrayDeque; |
8 import java.util.Arrays; | 8 import java.util.Arrays; |
9 import java.util.Deque; | 9 import java.util.Deque; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 protected static final ThreadLocal<ModifierHolder> threadLocalModifierHolder = | 24 protected static final ThreadLocal<ModifierHolder> threadLocalModifierHolder = |
25 new ThreadLocal<ModifierHolder>() { | 25 new ThreadLocal<ModifierHolder>() { |
26 @Override | 26 @Override |
27 protected ModifierHolder initialValue() { | 27 protected ModifierHolder initialValue() { |
28 return new ModifierHolder(); | 28 return new ModifierHolder(); |
29 } | 29 } |
30 }; | 30 }; |
31 | 31 |
32 public String format(FormatQuantity... inputs) { | 32 public String format(FormatQuantity... inputs) { |
33 // Setup | 33 // Setup |
34 Deque<FormatQuantity> inputDeque = new ArrayDeque<>(); | 34 Deque<FormatQuantity> inputDeque = new ArrayDeque<FormatQuantity>(); |
35 inputDeque.addAll(Arrays.asList(inputs)); | 35 inputDeque.addAll(Arrays.asList(inputs)); |
36 ModifierHolder modDeque = threadLocalModifierHolder.get().clear(); | 36 ModifierHolder modDeque = threadLocalModifierHolder.get().clear(); |
37 NumberStringBuilder sb = threadLocalStringBuilder.get().clear(); | 37 NumberStringBuilder sb = threadLocalStringBuilder.get().clear(); |
38 | 38 |
39 // Primary "recursion" step, calling the implementation's process method | 39 // Primary "recursion" step, calling the implementation's process method |
40 int length = process(inputDeque, modDeque, sb, 0); | 40 int length = process(inputDeque, modDeque, sb, 0); |
41 | 41 |
42 // Resolve remaining affixes | 42 // Resolve remaining affixes |
43 length += modDeque.applyAll(sb, 0, length); | 43 length += modDeque.applyAll(sb, 0, length); |
44 return sb.toString(); | 44 return sb.toString(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 // Instead of Dequeue<BigDecimal>, it could be Deque<Quantity> where | 270 // Instead of Dequeue<BigDecimal>, it could be Deque<Quantity> where |
271 // we control the API of Quantity | 271 // we control the API of Quantity |
272 public abstract int process( | 272 public abstract int process( |
273 Deque<FormatQuantity> inputs, | 273 Deque<FormatQuantity> inputs, |
274 ModifierHolder outputMods, | 274 ModifierHolder outputMods, |
275 NumberStringBuilder outputString, | 275 NumberStringBuilder outputString, |
276 int startIndex); | 276 int startIndex); |
277 } | 277 } |
LEFT | RIGHT |