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

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

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

revision 1.19 by mark, Sat Jul 2 20:32:51 2005 UTC revision 1.20 by rabbit78, Fri Jul 29 10:47:16 2005 UTC
# Line 108  public abstract class AbstractDocument Line 108  public abstract class AbstractDocument
108    
109    public Position createPosition(final int offset) throws BadLocationException    public Position createPosition(final int offset) throws BadLocationException
110    {    {
111      if (offset < 0 || offset > getLength())      return content.createPosition(offset);
       throw new BadLocationException(getText(0, getLength()), offset);  
   
     return new Position()  
       {  
         public int getOffset()  
         {  
           return offset;  
         }  
       };  
112    }    }
113    
114    protected void fireChangedUpdate(DocumentEvent event)    protected void fireChangedUpdate(DocumentEvent event)
# Line 847  public abstract class AbstractDocument Line 838  public abstract class AbstractDocument
838    public class LeafElement extends AbstractElement    public class LeafElement extends AbstractElement
839    {    {
840      private static final long serialVersionUID = 5115368706941283802L;      private static final long serialVersionUID = 5115368706941283802L;
841      int start;  
842      int end;      /** Manages the start offset of this element. */
843        Position startPos;
844    
845        /** Manages the end offset of this element. */
846        Position endPos;
847    
848      public LeafElement(Element parent, AttributeSet attributes, int start,      public LeafElement(Element parent, AttributeSet attributes, int start,
849                         int end)                         int end)
850      {      {
851        super(parent, attributes);        super(parent, attributes);
852        this.start = start;        try
853        this.end = end;          {
854              startPos = parent.getDocument().createPosition(start);
855              endPos = parent.getDocument().createPosition(end);
856            }
857          catch (BadLocationException ex)
858            {
859              throw new AssertionError("BadLocationException must not be thrown "
860                                       + "here. start=" + start + ", end=" + end
861                                       + ", length=" + getLength());
862            }
863      }      }
864    
865      public Enumeration children()      public Enumeration children()
# Line 885  public abstract class AbstractDocument Line 889  public abstract class AbstractDocument
889    
890      public int getEndOffset()      public int getEndOffset()
891      {      {
892        return end;        return endPos.getOffset();
893      }      }
894    
895      public String getName()      public String getName()
# Line 895  public abstract class AbstractDocument Line 899  public abstract class AbstractDocument
899    
900      public int getStartOffset()      public int getStartOffset()
901      {      {
902        return start;        return startPos.getOffset();
903      }      }
904    
905      public boolean isLeaf()      public boolean isLeaf()

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

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