console
Class ParsingOutputStreamTask

java.lang.Object
  extended by java.lang.Thread
      extended by console.StreamTask
          extended by console.SimpleOutputStreamTask
              extended by console.ParsingOutputStreamTask
All Implemented Interfaces:
java.lang.Runnable

public class ParsingOutputStreamTask
extends SimpleOutputStreamTask

ParsingOutputStreamTask is an outputting thread using an error parrser and an ANSI escaped sequencies parser. User can set parsers either at the moment of class's creating or after class' creation. If some parser is not defined - the class does not use that parser. A char's sequence from an InputStream (size == SimpleOutputStreamTask.BufferSize) is divided by line's breaks (if any), because the error parser might work with individual lines only, not the whole sequence - in common case InputStream can produce really many individual lines. On the other hand, each individual line is output in EDT (AWT-EventQueue). So, if InputStream produces a lot of lines - most of the time EDT processes them, and not other events of the jEdit's interface: it will hang until all the generated lines will be processed. However, this can be avoided if the output are not the individual lines, but an array of them. In this case, the number of events that must be processed EDT, sharply reduced. For this reason after processing of each individual line ParsingOutputStreamTask tries flush one to the cache. If the cache is full (CACHE_SIZE_LIMIT) or current style attributes are changed then the whole cache is flushed to output.


Nested Class Summary
 
Nested classes/interfaces inherited from class console.SimpleOutputStreamTask
SimpleOutputStreamTask.WLTypes
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class console.SimpleOutputStreamTask
BufferSize, defaultColor, in, lineBuffer, output, SleepDelayMSec
 
Fields inherited from class console.StreamTask
abortFlag, finishFlag
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ParsingOutputStreamTask(java.io.InputStream in, Output output, java.awt.Color defaultColor, java.awt.Color backgroundColor, CommandOutputParser extErrorParser, AnsiEscapeParser extAnsiParser)
          Create instance using external parsers.
ParsingOutputStreamTask(java.io.InputStream in, Output output, java.awt.Color defaultColor, java.awt.Color backgroundColor, org.gjt.sp.jedit.View view, errorlist.DefaultErrorSource des, java.lang.String currentDirectory)
          Create instance using given View and DefaultErrorSource.
ParsingOutputStreamTask(java.io.InputStream in, Output output, java.awt.Color defaultColor, Console console, java.lang.String currentDirectory)
          Create instance using default Console's parameters.
 
Method Summary
protected  void actionInsideWaitingLoop(java.io.InputStreamReader isr)
          Extended outputting: working process outputs nothing a long time.
protected  void afterWorking()
          Run AFTER: - main working loop ends - "finalOutputing()" method (under "try" section)
protected  void finalOutputting()
          Dump remained data from internal buffer "lineBuffer" to output "output" with color "defaultColor".
protected  void outputData()
          Do followed: - exchanging and removing symbols in whole input line - splitting input line by line breaks
 boolean pop(boolean forced)
          Pop the cached data from the outputting cache to Output.
 void push(javax.swing.text.SimpleAttributeSet currentAttrs, java.lang.String str)
          Push a string to the outputting cache with a some AttributeSet.
 void setAnsiParser(AnsiEscapeParser extAnsiParser)
          Set given ansi parser.
 void setAnsiParser(java.awt.Color defaultColor, java.awt.Color backgroundColor)
          Create new ansi parser and set one.
 void setErrorParser(CommandOutputParser extErrorParser)
          Set given error parser..
 void setErrorParser(org.gjt.sp.jedit.View view, errorlist.DefaultErrorSource des, java.awt.Color defaultColor, java.lang.String currentDirectory)
          Create new error parser and set one.
 java.lang.String trim_cache()
          Remove a noncached data (placed AFTER the cache) from the cache.
 
Methods inherited from class console.SimpleOutputStreamTask
beforeWorking, exception_dumpToLog, exception_dumpToOwner, run, setWaitingLoop
 
Methods inherited from class console.StreamTask
abort, finish
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParsingOutputStreamTask

public ParsingOutputStreamTask(java.io.InputStream in,
                               Output output,
                               java.awt.Color defaultColor,
                               java.awt.Color backgroundColor,
                               org.gjt.sp.jedit.View view,
                               errorlist.DefaultErrorSource des,
                               java.lang.String currentDirectory)
Create instance using given View and DefaultErrorSource.

Parameters:
in - input stream, from which we receive data
output - instance implements Output
defaultColor - default foreground color
backgroundColor - default backgroundColor color
view - working jEdit's view
des - error source for error parser
currentDirectory - console's current (working) directory

ParsingOutputStreamTask

public ParsingOutputStreamTask(java.io.InputStream in,
                               Output output,
                               java.awt.Color defaultColor,
                               Console console,
                               java.lang.String currentDirectory)
Create instance using default Console's parameters.

Parameters:
in - input stream, from which we receive data
output - instance implements Output
defaultColor - default foreground color
console - console, which manipulates the input stream
currentDirectory - console's current (working) directory

ParsingOutputStreamTask

public ParsingOutputStreamTask(java.io.InputStream in,
                               Output output,
                               java.awt.Color defaultColor,
                               java.awt.Color backgroundColor,
                               CommandOutputParser extErrorParser,
                               AnsiEscapeParser extAnsiParser)
Create instance using external parsers.

Parameters:
in - input stream, from which we receive data
output - instance implements Output
defaultColor - default foreground color
backgroundColor - default backgroundColor color
extErrorParser - given error parser instance
extAnsiParser - given ansi parser instance
Method Detail

push

public void push(javax.swing.text.SimpleAttributeSet currentAttrs,
                 java.lang.String str)
Push a string to the outputting cache with a some AttributeSet. If the current value of AttributeSet is not a same as one previously saved then at first this method flushes the cached data and saves the current value of AttributeSet.

Parameters:
currentAttrs - current value of the AttributeSet
str - outputed string

pop

public boolean pop(boolean forced)
Pop the cached data from the outputting cache to Output. When "forced" is "true" the outputting cache is flushed by force.

Parameters:
forced - if "true" the cache is flushed by force
Returns:
if the cache is flushed successfully then return "true"

trim_cache

public java.lang.String trim_cache()
Remove a noncached data (placed AFTER the cache) from the cache.

Returns:
return a noncached data

actionInsideWaitingLoop

protected void actionInsideWaitingLoop(java.io.InputStreamReader isr)
                                throws java.lang.Exception
Extended outputting: working process outputs nothing a long time. In that case flush and a cached data and a noncached (unterminated string).

Overrides:
actionInsideWaitingLoop in class SimpleOutputStreamTask
Throws:
java.lang.Exception

afterWorking

protected void afterWorking()
                     throws java.lang.Exception
Description copied from class: SimpleOutputStreamTask
Run AFTER: - main working loop ends - "finalOutputing()" method (under "try" section)

Overrides:
afterWorking in class SimpleOutputStreamTask
Throws:
java.lang.Exception

finalOutputting

protected void finalOutputting()
Description copied from class: SimpleOutputStreamTask
Dump remained data from internal buffer "lineBuffer" to output "output" with color "defaultColor". Run AFTER main working loop ends, but BEFORE "afterWorking()" method. (under "finally" section)

Overrides:
finalOutputting in class SimpleOutputStreamTask

outputData

protected void outputData()
                   throws java.lang.Exception
Do followed: - exchanging and removing symbols in whole input line - splitting input line by line breaks

Overrides:
outputData in class SimpleOutputStreamTask
Throws:
java.lang.Exception

setAnsiParser

public void setAnsiParser(AnsiEscapeParser extAnsiParser)
Set given ansi parser. Setting parser to "null" turns off this parser.

Parameters:
extAnsiParser - given ansi parser instance

setAnsiParser

public void setAnsiParser(java.awt.Color defaultColor,
                          java.awt.Color backgroundColor)
Create new ansi parser and set one.

Parameters:
defaultColor - default foreground color
backgroundColor - default backgroundColor color

setErrorParser

public void setErrorParser(CommandOutputParser extErrorParser)
Set given error parser.. Setting parser to "null" turns off this parser.

Parameters:
extErrorParser - given error parser instance

setErrorParser

public void setErrorParser(org.gjt.sp.jedit.View view,
                           errorlist.DefaultErrorSource des,
                           java.awt.Color defaultColor,
                           java.lang.String currentDirectory)
Create new error parser and set one.

Parameters:
view - working jEdit's view
des - error source for error parser
defaultColor - default foreground color
currentDirectory - console's current (working) directory