org.skunk.swing.text.syntax
Class SyntaxContent

java.lang.Object
  |
  +--javax.swing.text.GapVector
        |
        +--javax.swing.text.GapContent
              |
              +--org.skunk.swing.text.syntax.SyntaxContent
All Implemented Interfaces:
javax.swing.text.AbstractDocument.Content, java.io.Serializable

public class SyntaxContent
extends javax.swing.text.GapContent

See Also:
Serialized Form

Constructor Summary
SyntaxContent()
          constructs a new SyntaxContent object, with a Flexicizer SyntaxTokenizer.
SyntaxContent(int initialLength)
          constructs a new SyntaxContent object with the given initial length.
SyntaxContent(SyntaxTokenizer tokenizer)
          constructs a new SyntaxContent object with the given SyntaxTokenizer.
 
Method Summary
 FileMode getFileMode()
          returns the file mode of this tokenizer.
 GappedIntArray getStyleBuffer()
          gives access to the style buffer
 SyntaxTokenizer getSyntaxTokenizer()
          gives access to the syntax tokenizer
 javax.swing.undo.UndoableEdit insertString(int where, java.lang.String str)
          insert string into the content at the given offset.
 boolean isTokenizing()
          says whether tokenization is on.
 javax.swing.undo.UndoableEdit remove(int where, int nitems)
          removes characters from the content.
 void setFileMode(FileMode mode)
          sets the file mode.
protected  void setSyntaxDocument(SyntaxDocument syntaxDocument)
          gives the content object a reference to the document.
 void setSyntaxTokenizer(SyntaxTokenizer syntaxTokenizer)
          applies a syntax tokenizer.
 void setTokenizing(boolean tokenizing)
          sets tokenization on.
 
Methods inherited from class javax.swing.text.GapContent
allocateArray, createPosition, getArray, getArrayLength, getChars, getGapEnd, getGapStart, getPositionsInRange, getString, length, replace, resetMarksAtZero, shiftEnd, shiftGap, shiftGapEndUp, shiftGapStartDown, updateUndoPositions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyntaxContent

public SyntaxContent()
constructs a new SyntaxContent object, with a Flexicizer SyntaxTokenizer.

SyntaxContent

public SyntaxContent(int initialLength)
constructs a new SyntaxContent object with the given initial length.
Parameters:
initialLength - the initial length

SyntaxContent

public SyntaxContent(SyntaxTokenizer tokenizer)
constructs a new SyntaxContent object with the given SyntaxTokenizer.
Parameters:
tokenizer - the SyntaxTokenizer to install
Method Detail

getStyleBuffer

public GappedIntArray getStyleBuffer()
gives access to the style buffer

getSyntaxTokenizer

public SyntaxTokenizer getSyntaxTokenizer()
gives access to the syntax tokenizer

setSyntaxTokenizer

public void setSyntaxTokenizer(SyntaxTokenizer syntaxTokenizer)
applies a syntax tokenizer.
Parameters:
syntaxTokenizer - the tokenizer

setSyntaxDocument

protected void setSyntaxDocument(SyntaxDocument syntaxDocument)
gives the content object a reference to the document. A hack, but it needs this at present to call the tokenizer's tokenize() method.
Parameters:
syntaxDocument - the SyntaxDocument which owns this content object

setFileMode

public void setFileMode(FileMode mode)
sets the file mode.
Parameters:
mode - the file mode

getFileMode

public FileMode getFileMode()
returns the file mode of this tokenizer.
Returns:
the file mode, or null if the tokenizer currently has no mode

isTokenizing

public boolean isTokenizing()
says whether tokenization is on. If it returns true, the syntaxDocument and syntaxTokenizer must both be non-null
Returns:
whether tokenization is on.

setTokenizing

public void setTokenizing(boolean tokenizing)
sets tokenization on. If there is no tokenizer installed, or if the syntaxDocument is null, isTokenizing() will return false, regardless of the value set here.
Parameters:
tokenizing - whether to tokenize

insertString

public javax.swing.undo.UndoableEdit insertString(int where,
                                                  java.lang.String str)
                                           throws javax.swing.text.BadLocationException
insert string into the content at the given offset. overridden to allocate space in the style buffer for the insert, and to tokenize the document.
Overrides:
insertString in class javax.swing.text.GapContent
Parameters:
where - the offset into the document where the insert should begin
str - the string to insert
Throws:
javax.swing.text.BadLocationException - if the offset is greater than the document length

remove

public javax.swing.undo.UndoableEdit remove(int where,
                                            int nitems)
                                     throws javax.swing.text.BadLocationException
removes characters from the content. overridden to deallocate space from the styleBuffer, and to tokenize the document.
Overrides:
remove in class javax.swing.text.GapContent
Parameters:
where - the offset of the removal
nitems - the number of characters to remove
Throws:
javax.swing.text.BadLocationException - if the parameters are out of bounds