Interface Content


@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface Content
Interface to describe a sequence of character content that can be edited.
  • Method Summary

    Modifier and Type
    Method
    Description
    createPosition(int offset)
    Creates a position within the content.
    void
    getChars(int where, int len, Segment chars)
    Retrieves a portion of the content into the specified Segment.
    int
    The length in characters of the content.
    getString(int where, int len)
    Fetches a string of characters contained in the content sequence.
    void
    insertChars(int where, char[] ch, int start, int length)
    Inserts a sequence of characters into the content at a given offset.
    void
    remove(int where, int nitems)
    Removes some portion of the content sequence.
  • Method Details

    • createPosition

      Position createPosition(int offset) throws BadLocationException
      Creates a position within the content. The position offset is changed as the content is edited.
      Parameters:
      offset - The offset in the content >= 0
      Returns:
      A new Position.
      Throws:
      BadLocationException - For an invalid offset
    • getLength

      int getLength()
      The length in characters of the content.
      Returns:
      The length >= 0
    • insertChars

      void insertChars(int where, char[] ch, int start, int length) throws BadLocationException
      Inserts a sequence of characters into the content at a given offset.
      Parameters:
      where - Offset into the content to make the insertion >= 0
      ch - The char buffer to insert from.
      start - Start of useful data in the char buffer.
      length - Length of useful data in the char buffer.
      Throws:
      BadLocationException - thrown if the offset indicated by the where argument is not contained in the boundaries of the content character sequence.
    • remove

      void remove(int where, int nitems) throws BadLocationException
      Removes some portion of the content sequence.
      Parameters:
      where - The offset into the sequence to make the removal >= 0.
      nitems - The number of items in the sequence to be removed >= 0.
      Throws:
      BadLocationException - Thrown if the area covered by the where and nitems parameters is not contained in the content character sequence.
    • getString

      String getString(int where, int len) throws BadLocationException
      Fetches a string of characters contained in the content sequence.
      Parameters:
      where - Offset into the sequence to fetch >= 0.
      len - Number of characters to copy >= 0.
      Returns:
      The extracted String.
      Throws:
      BadLocationException - Thrown if the area covered by the arguments is not contained in the content character sequence.
    • getChars

      void getChars(int where, int len, Segment chars) throws BadLocationException
      Retrieves a portion of the content into the specified Segment. If the desired content spans the gap, we copy the content. If the desired content does not span the gap, the actual store is returned to avoid the copy since it is contiguous.
      Parameters:
      where - The starting position >= 0, where + len <= length()
      len - The number of characters to be retrieved >= 0
      chars - The Segment object to return the characters into.
      Throws:
      BadLocationException - If the specified position or length are invalid.