org.brains2b.thex.tasks
Class FindTask

java.lang.Object
  extended by org.brains2b.task.DefaultTask
      extended by org.brains2b.thex.tasks.FindTask
All Implemented Interfaces:
java.lang.Runnable, org.brains2b.task.Task

public class FindTask
extends org.brains2b.task.DefaultTask

Runnable Task to allow finding an array of bytes from a document and locate and mark the results

Also implements a static method to find the first offset of the byte[] within a BinaryDocument

Version:
$Revision: 1.2 $ $Date: 2010/01/15 03:53:05 $
Author:
dennis@brains2b.nl

Field Summary
 
Fields inherited from interface org.brains2b.task.Task
RESULT_ERROR, RESULT_OK, RESULT_WARNING
 
Constructor Summary
FindTask(javax.swing.text.JTextComponent t, byte[] b, int start, int end, javax.swing.text.Position.Bias direction, boolean findAll)
          Constructor for Task
 
Method Summary
static int find(BinaryDocument doc, byte[] bb, int start, int end)
          find the first occurence of byte[] in a BinaryDocument
 void run()
          run the find as defined by the constructor
 
Methods inherited from class org.brains2b.task.DefaultTask
addException, addMessage, addTaskListener, fireTaskEvent, getMax, getMessages, getMin, getPosition, getResult, isFinished, progress, progress, removeTaskListener, setFinished, setMax, setMin, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindTask

public FindTask(javax.swing.text.JTextComponent t,
                byte[] b,
                int start,
                int end,
                javax.swing.text.Position.Bias direction,
                boolean findAll)
Constructor for Task

Parameters:
t - JTextComponent the component that displays the BinaryDocument
b - byte[], the bytes to look for
start - int, the location to start looking from
end - int, the location after which the find can be terminated
direction - Bias, Position.Bias.Forward or Position.Bias.Backward, Position.Bias.Forward if null is supplied
findAll - boolean, if true all occurrences of the byte[] will be found, otherwise only the first occurance will be shown
Method Detail

run

public void run()
run the find as defined by the constructor


find

public static final int find(BinaryDocument doc,
                             byte[] bb,
                             int start,
                             int end)
find the first occurence of byte[] in a BinaryDocument

Parameters:
doc - BinaryDocument, the document to look in
bb - byte[], the bytes to look for
start - int, the location to start looking from
end - int, the location after which the find can be terminated
Returns:
int the first location at which the bytes[] where found in the document after start and before end