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

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

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

revision 1.1.2.5 by gnu_andrew, Tue Sep 20 18:46:35 2005 UTC revision 1.1.2.6 by gnu_andrew, Wed Nov 2 00:44:03 2005 UTC
# Line 899  public class DefaultStyledDocument exten Line 899  public class DefaultStyledDocument exten
899    
900    /**    /**
901     * Returns the paragraph element for the specified position.     * Returns the paragraph element for the specified position.
902       * If the position is outside the bounds of the document's root element,
903       * then the closest element is returned. That is the last paragraph if
904       * <code>position >= endIndex</code> or the first paragraph if
905       * <code>position < startIndex</code>.
906     *     *
907     * @param position the position for which to query the paragraph element     * @param position the position for which to query the paragraph element
908     *     *
# Line 907  public class DefaultStyledDocument exten Line 911  public class DefaultStyledDocument exten
911    public Element getParagraphElement(int position)    public Element getParagraphElement(int position)
912    {    {
913      BranchElement root = (BranchElement) getDefaultRootElement();      BranchElement root = (BranchElement) getDefaultRootElement();
914        int start = root.getStartOffset();
915        int end = root.getEndOffset();
916        if (position >= end)
917          position = end - 1;
918        else if (position < start)
919          position = start;
920    
921      Element par = root.positionToElement(position);      Element par = root.positionToElement(position);
922    
923        assert par != null : "The paragraph element must not be null";
924      return par;      return par;
925    }    }
926    
# Line 1060  public class DefaultStyledDocument exten Line 1073  public class DefaultStyledDocument exten
1073        }        }
1074      catch (BadLocationException ex)      catch (BadLocationException ex)
1075        {        {
1076          throw new AssertionError("BadLocationException must not be thrown "          AssertionError ae = new AssertionError("Unexpected bad location");
1077                                   + "here.");          ae.initCause(ex);
1078            throw ae;
1079        }        }
1080    
1081      int len = 0;      int len = 0;

Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.6

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