/[classpath]/classpath/javax/swing/text/Segment.java
ViewVC logotype

Diff of /classpath/javax/swing/text/Segment.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Sat Jul 31 23:18:08 2004 UTC revision 1.6 by mark, Sat Sep 4 17:14:01 2004 UTC
# Line 39  package javax.swing.text; Line 39  package javax.swing.text;
39    
40  import java.text.CharacterIterator;  import java.text.CharacterIterator;
41    
   
42  public class Segment  public class Segment
43    implements Cloneable, CharacterIterator    implements Cloneable, CharacterIterator
44  {  {
45    private boolean partialReturn;    private boolean partialReturn;
46      private int current;
47        
48    public char[] array;    public char[] array;
49    public int count;    public int count;
# Line 74  public class Segment Line 74  public class Segment
74    
75    public char current()    public char current()
76    {    {
77      return array[getIndex()];      if (count == 0
78            || current >= getEndIndex())
79          return DONE;
80        
81        return array[current];
82    }    }
83    
84    public char first()    public char first()
85    {    {
86      offset = getBeginIndex();      if (count == 0)
87      return array[offset];        return DONE;
88    
89        current = getBeginIndex();
90        return array[current];
91    }    }
92    
93    public int getBeginIndex()    public int getBeginIndex()
# Line 95  public class Segment Line 102  public class Segment
102    
103    public int getIndex()    public int getIndex()
104    {    {
105      return offset;      return current;
106    }    }
107    
108    public char last()    public char last()
109    {    {
110      offset = getEndIndex() - 1;      if (count == 0)
111      return array[offset];        return DONE;
112        
113        current = getEndIndex() - 1;
114        return array[current];
115    }    }
116    
117    public char next()    public char next()
118    {    {
119      offset++;      if (count == 0)
120      return array[offset];        return DONE;
121    
122        if ((current + 1) >= getEndIndex())
123          {
124            current = getEndIndex();
125            return DONE;
126          }
127        
128        current++;
129        return array[current];
130    }    }
131    
132    public char previous()    public char previous()
133    {    {
134      offset--;      if (count == 0
135      return array[offset];          || current == getBeginIndex())
136          return DONE;
137        
138        current--;
139        return array[current];
140    }    }
141    
142    public char setIndex(int position)    public char setIndex(int position)
143    {    {
144      offset = position;      if (position < getBeginIndex()
145      return array[offset];          || position > getEndIndex())
146          throw new IllegalArgumentException();
147    
148        current = position;
149    
150        if (position == getEndIndex())
151          return DONE;
152        
153        return array[current];
154    }    }
155    
156    public String toString()    public String toString()

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26