< prev index next >

src/java.base/share/classes/java/text/CharacterIteratorFieldDelegate.java

Print this page




  95     public void formatted(int fieldID, Format.Field attr, Object value,
  96                           int start, int end, StringBuffer buffer) {
  97         formatted(attr, value, start, end, buffer);
  98     }
  99 
 100     /**
 101      * Returns an <code>AttributedCharacterIterator</code> that can be used
 102      * to iterate over the resulting formatted String.
 103      *
 104      * @pararm string Result of formatting.
 105      */
 106     public AttributedCharacterIterator getIterator(String string) {
 107         // Add the last AttributedCharacterIterator if necessary
 108         // assert(size <= string.length());
 109         if (string.length() > size) {
 110             attributedStrings.add(new AttributedString(
 111                                   string.substring(size)));
 112             size = string.length();
 113         }
 114         int iCount = attributedStrings.size();
 115         AttributedCharacterIterator iterators[] = new
 116                                     AttributedCharacterIterator[iCount];
 117 
 118         for (int counter = 0; counter < iCount; counter++) {
 119             iterators[counter] = attributedStrings.
 120                                   get(counter).getIterator();
 121         }
 122         return new AttributedString(iterators).getIterator();
 123     }
 124 }


  95     public void formatted(int fieldID, Format.Field attr, Object value,
  96                           int start, int end, StringBuffer buffer) {
  97         formatted(attr, value, start, end, buffer);
  98     }
  99 
 100     /**
 101      * Returns an <code>AttributedCharacterIterator</code> that can be used
 102      * to iterate over the resulting formatted String.
 103      *
 104      * @pararm string Result of formatting.
 105      */
 106     public AttributedCharacterIterator getIterator(String string) {
 107         // Add the last AttributedCharacterIterator if necessary
 108         // assert(size <= string.length());
 109         if (string.length() > size) {
 110             attributedStrings.add(new AttributedString(
 111                                   string.substring(size)));
 112             size = string.length();
 113         }
 114         int iCount = attributedStrings.size();
 115         AttributedCharacterIterator[] iterators = new
 116                                     AttributedCharacterIterator[iCount];
 117 
 118         for (int counter = 0; counter < iCount; counter++) {
 119             iterators[counter] = attributedStrings.
 120                                   get(counter).getIterator();
 121         }
 122         return new AttributedString(iterators).getIterator();
 123     }
 124 }
< prev index next >