org.comedia.text
Class CAbstractHighlighter

java.lang.Object
  |
  +--org.comedia.text.CAbstractHighlighter
Direct Known Subclasses:
CCppHighlighter, CJavaHighlighter, CPascalHighlighter, CXmlHighlighter

public abstract class CAbstractHighlighter
extends java.lang.Object

Presents an abstract highlighter for CSyntaxEditor. This highlighter is used to highlight a text while editing according mappings for different program languages.


Field Summary
protected  javax.swing.text.MutableAttributeSet commentAttr
          The comment attribute.
protected  javax.swing.text.MutableAttributeSet delimAttr
          The delimiters attribute.
protected  javax.swing.text.MutableAttributeSet identAttr
          The identificator attribute.
protected  javax.swing.text.MutableAttributeSet keywordAttr
          The keyword attribute.
protected  javax.swing.text.MutableAttributeSet numberAttr
          The number attribute.
protected  org.comedia.util.scanner.CScanner scanner
          The language syntax analizer.
protected  javax.swing.text.MutableAttributeSet stringAttr
          The string attribute.
protected  javax.swing.text.MutableAttributeSet whiteSpaceAttr
          The whitespace attribute.
 
Constructor Summary
CAbstractHighlighter()
          Construct this class with default parameters.
 
Method Summary
 javax.swing.text.AttributeSet getAttribute()
          Gets the attribute for the current token value.
 javax.swing.text.MutableAttributeSet getCommentAttribute()
          Gets an attribute for comments.
 javax.swing.text.MutableAttributeSet getDelimAttribute()
          Gets an attribute for delimiters.
 javax.swing.text.MutableAttributeSet getIdentAttribute()
          Gets an attribute for identifiers.
 javax.swing.text.MutableAttributeSet getKeywordAttribute()
          Gets an attribute for keywords.
 javax.swing.text.MutableAttributeSet getNumberAttribute()
          Gets an attribute for numbers.
 javax.swing.text.MutableAttributeSet getStringAttribute()
          Gets an attribute for strings.
 java.lang.String getToken()
          Gets the current token value.
 javax.swing.text.MutableAttributeSet getWhiteSpaceAttribute()
          Gets an attribute for whitespaces.
 java.lang.String gotoNextToken()
          Goes to the next token in the buffer.
 boolean isMultilineComment()
          Check if current is a multiline comment.
abstract  int locateUnclosedComment(java.lang.String text, int pos)
          Locates a last unclosed multiline comment before specified position.
protected  int locateUnclosedComment(java.lang.String text, int pos, java.lang.String startSymbol, java.lang.String endSymbol)
          Locates a last unclosed multiline comment before specified position.
 void setBuffer(java.lang.String buffer)
          Sets a buffer string.
 void setCommentAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for comments.
 void setDelimAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for delimiters.
 void setIdentAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for identifiers.
 void setKeywordAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for keywords.
 void setNumberAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for numbers.
 void setStringAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for strings.
 void setWhiteSpaceAttribute(javax.swing.text.MutableAttributeSet attrs)
          Sets an attribute for whitespaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

whiteSpaceAttr

protected javax.swing.text.MutableAttributeSet whiteSpaceAttr
The whitespace attribute.

identAttr

protected javax.swing.text.MutableAttributeSet identAttr
The identificator attribute.

commentAttr

protected javax.swing.text.MutableAttributeSet commentAttr
The comment attribute.

delimAttr

protected javax.swing.text.MutableAttributeSet delimAttr
The delimiters attribute.

keywordAttr

protected javax.swing.text.MutableAttributeSet keywordAttr
The keyword attribute.

stringAttr

protected javax.swing.text.MutableAttributeSet stringAttr
The string attribute.

numberAttr

protected javax.swing.text.MutableAttributeSet numberAttr
The number attribute.

scanner

protected org.comedia.util.scanner.CScanner scanner
The language syntax analizer.
Constructor Detail

CAbstractHighlighter

public CAbstractHighlighter()
Construct this class with default parameters.
Method Detail

getWhiteSpaceAttribute

public javax.swing.text.MutableAttributeSet getWhiteSpaceAttribute()
Gets an attribute for whitespaces.

setWhiteSpaceAttribute

public void setWhiteSpaceAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for whitespaces.
Parameters:
attrs - an attribute for whitespaces.

getIdentAttribute

public javax.swing.text.MutableAttributeSet getIdentAttribute()
Gets an attribute for identifiers.

setIdentAttribute

public void setIdentAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for identifiers.
Parameters:
attrs - an attribute for identifiers.

getCommentAttribute

public javax.swing.text.MutableAttributeSet getCommentAttribute()
Gets an attribute for comments.

setCommentAttribute

public void setCommentAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for comments.
Parameters:
attrs - an attribute for comments.

getDelimAttribute

public javax.swing.text.MutableAttributeSet getDelimAttribute()
Gets an attribute for delimiters.

setDelimAttribute

public void setDelimAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for delimiters.
Parameters:
attrs - an attribute for delimiters.

getKeywordAttribute

public javax.swing.text.MutableAttributeSet getKeywordAttribute()
Gets an attribute for keywords.

setKeywordAttribute

public void setKeywordAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for keywords.
Parameters:
attrs - an attribute for keywords.

getStringAttribute

public javax.swing.text.MutableAttributeSet getStringAttribute()
Gets an attribute for strings.

setStringAttribute

public void setStringAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for strings.
Parameters:
attrs - an attribute for strings.

getNumberAttribute

public javax.swing.text.MutableAttributeSet getNumberAttribute()
Gets an attribute for numbers.

setNumberAttribute

public void setNumberAttribute(javax.swing.text.MutableAttributeSet attrs)
Sets an attribute for numbers.
Parameters:
attrs - an attribute for numbers.

setBuffer

public void setBuffer(java.lang.String buffer)
Sets a buffer string.
Parameters:
buffer - a new buffer string.

gotoNextToken

public java.lang.String gotoNextToken()
Goes to the next token in the buffer.

getToken

public java.lang.String getToken()
Gets the current token value. result the current token value.

getAttribute

public javax.swing.text.AttributeSet getAttribute()
Gets the attribute for the current token value.
Parameters:
an - attribute for the current token value.

locateUnclosedComment

protected int locateUnclosedComment(java.lang.String text,
                                    int pos,
                                    java.lang.String startSymbol,
                                    java.lang.String endSymbol)
Locates a last unclosed multiline comment before specified position.
Parameters:
text - the text to search in.
pos - the last position
startSymbol - comment starting symbol.
endSymbol - comment end symbol.

locateUnclosedComment

public abstract int locateUnclosedComment(java.lang.String text,
                                          int pos)
Locates a last unclosed multiline comment before specified position.
Parameters:
text - the text to search in.
pos - the last position

isMultilineComment

public boolean isMultilineComment()
Check if current is a multiline comment.