-
- All Known Implementing Classes:
- GapContent, StringContent
- Enclosing class:
- AbstractDocument
public static interface AbstractDocument.Content
Interface to describe a sequence of character content that can be edited. Implementations may or may not support a history mechanism which will be reflected by whether or not mutations return an UndoableEdit implementation.- See Also:
AbstractDocument
-
-
Method Summary
Methods Modifier and Type Method and Description Position
createPosition(int offset)
Creates a position within the content that will track change as the content is mutated.void
getChars(int where, int len, Segment txt)
Gets a sequence of characters and copies them into a Segment.String
getString(int where, int len)
Fetches a string of characters contained in the sequence.UndoableEdit
insertString(int where, String str)
Inserts a string of characters into the sequence.int
length()
Current length of the sequence of character content.UndoableEdit
remove(int where, int nitems)
Removes some portion of the sequence.
-
-
-
Method Detail
-
createPosition
Position createPosition(int offset) throws BadLocationException
Creates a position within the content that will track change as the content is mutated.- Parameters:
offset
- the offset in the content >= 0- Returns:
- a Position
- Throws:
BadLocationException
- for an invalid offset
-
length
int length()
Current length of the sequence of character content.- Returns:
- the length >= 0
-
insertString
UndoableEdit insertString(int where, String str) throws BadLocationException
Inserts a string of characters into the sequence.- Parameters:
where
- offset into the sequence to make the insertion >= 0str
- string to insert- Returns:
- if the implementation supports a history mechanism,
a reference to an
Edit
implementation will be returned, otherwise returnsnull
- Throws:
BadLocationException
- thrown if the area covered by the arguments is not contained in the character sequence
-
remove
UndoableEdit remove(int where, int nitems) throws BadLocationException
Removes some portion of the sequence.- Parameters:
where
- The offset into the sequence to make the insertion >= 0.nitems
- The number of items in the sequence to remove >= 0.- Returns:
- If the implementation supports a history mechansim, a reference to an Edit implementation will be returned, otherwise null.
- Throws:
BadLocationException
- Thrown if the area covered by the arguments is not contained in the character sequence.
-
getString
String getString(int where, int len) throws BadLocationException
Fetches a string of characters contained in the sequence.- Parameters:
where
- Offset into the sequence to fetch >= 0.len
- number of characters to copy >= 0.- Returns:
- the string
- Throws:
BadLocationException
- Thrown if the area covered by the arguments is not contained in the character sequence.
-
getChars
void getChars(int where, int len, Segment txt) throws BadLocationException
Gets a sequence of characters and copies them into a Segment.- Parameters:
where
- the starting offset >= 0len
- the number of characters >= 0txt
- the target location to copy into- Throws:
BadLocationException
- Thrown if the area covered by the arguments is not contained in the character sequence.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
05/11/2024 16:19:54 Cette version de la page est en cache (à la date du 05/11/2024 16:19:54) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 01/09/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/text/AbstractDocument.Content.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.