home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils text / MakeDocJ 3.3 / MakeDocJ.exe / Source / MakeDocJ.java < prev    next >
Encoding:
Java Source  |  2000-05-23  |  19.5 KB  |  622 lines

  1. /*
  2.  * MakeDocJ.java
  3.  *
  4.  * Copyright 2000 by BRiSK Software,
  5.  * 8702 Switzer Road, Overland Park, KS 66214
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of BRiSK Software. ("Confidential Information").
  10.  * You shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with BRiSK Software.
  13.  *
  14.  * $Id$
  15.  */
  16.  
  17. import java.io.*;
  18. import java.util.*;
  19.  
  20. import gnu.regexp.*;
  21.  
  22. /**
  23.  * <code>MakeDocJ</code> is the main application used to manipulate PilotDocs
  24.  * @author Jeffrey A. Krzysztow
  25.  * @author Pat Beirne
  26.  * @version 3.5.1
  27.  */
  28. public final class MakeDocJ {
  29.     private final static String version = "3.5.1";
  30.  
  31.     /**
  32.      * Decodes the PilotDoc file
  33.      * @param sourcePath      full path of the source PilotDoc file
  34.      * @param destinationPath full path of the destination text file
  35.      * @param convertEOL      how to convert end of line
  36.      * @param bookMarks       generate a file containing the internal bookmarks
  37.      * @throws IOException to the caller can handle any I/O errors
  38.      * @since 1.0
  39.      */
  40.     public static void decode(final String sourcePath,
  41.                               final String destinationPath,
  42.                               final int convertEOL,
  43.                               final boolean bookMarks) throws IOException {
  44.  
  45.         RandomAccessFile fin = null;
  46.         FileOutputStream fout = null;
  47.         try {
  48.             fin = new RandomAccessFile(sourcePath, "r");
  49.             fout = new FileOutputStream(destinationPath);
  50.         }
  51.         catch(FileNotFoundException e) {
  52.             System.err.println("the file " + sourcePath + " could not be found");
  53.             return;
  54.         }
  55.         catch(IOException e) {
  56.             System.err.println("the file " + destinationPath + " could not be created");
  57.             return;
  58.         }
  59.  
  60.         DatabaseHeader dbHeader = new DatabaseHeader();
  61.         dbHeader.read(fin);
  62.         if(dbHeader.creatorID != DatabaseHeader.ReaderID
  63.             && dbHeader.creatorID != DatabaseHeader.TealDocID
  64.             || dbHeader.typeID != DatabaseHeader.TEXt) {
  65.             System.err.println("file is unknown format");
  66.             System.err.println(dbHeader);
  67.             return;
  68.         }
  69.  
  70.         RecordIndex[] ri = new RecordIndex[dbHeader.numRecords];
  71.         for(int i = 0; i < dbHeader.numRecords; i++) {
  72.             ri[i] = new RecordIndex();
  73.             ri[i].read(fin);
  74.         }
  75.  
  76.         DocumentHeader docHeader = new DocumentHeader();
  77.         fin.seek(ri[0].fileOffset);
  78.         docHeader.read(fin);
  79.  
  80.         if(docHeader.version != DocumentHeader.UNCOMPRESSED && docHeader.version != DocumentHeader.COMPRESSED) {
  81.             System.err.println("WARNING: unknown file compression type: " + docHeader.version);
  82.         }
  83.  
  84.         boolean compressed = (docHeader.version == DocumentHeader.COMPRESSED);
  85.  
  86.         /////////////////////////////////////////////////////////////
  87.         // Handle the text (compressed or not)
  88.         PilotDocRecord textBuffer;
  89.         int dwRecLen;
  90.         for(int i = 1; i <= docHeader.numRecords; i++) {
  91.             System.out.print("\rconverting `" + dbHeader.name + "`: text record " + i + " of " + docHeader.numRecords);
  92.             if(i == ri.length - 1) {
  93.                 // for the last, use the file len
  94.                 dwRecLen = (int) fin.length() - ri[i].fileOffset;
  95.             }
  96.             else {
  97.                 dwRecLen = ri[i + 1].fileOffset - ri[i].fileOffset;
  98.             }
  99.             fin.seek(ri[i].fileOffset);
  100.             textBuffer = new PilotDocRecord(dwRecLen);
  101.             fin.read(textBuffer.buf);
  102.             if(compressed) {
  103.                 textBuffer.decompress();
  104.             }
  105.             if(convertEOL != PilotDocRecord.EOLLF) {
  106.                 textBuffer.convertEOL(convertEOL);
  107.             }
  108.  
  109.             fout.write(textBuffer.buf);
  110.         }
  111.  
  112.         /////////////////////////////////////////////////////////////
  113.         // Handle Bookmarks if any
  114.         if(bookMarks && docHeader.numRecords + 1 < dbHeader.numRecords) {
  115.             PrintWriter bout;
  116.             try {
  117.                 bout = new PrintWriter(new FileOutputStream(destinationPath + ".bm"));
  118.             }
  119.             catch(IOException e) {
  120.                 System.err.println("the file " + destinationPath + ".bm" + " could not be created");
  121.                 return;
  122.             }
  123.             BookMark bm = new BookMark();
  124.             for(int i = docHeader.numRecords + 1; i < dbHeader.numRecords; i++) {
  125.                 fin.seek(ri[i].fileOffset);
  126.                 bm.read(fin);
  127.                 bout.println(bm.name + "," + bm.fileOffset);
  128.             }
  129.             bout.close();
  130.         }
  131.         fin.close();
  132.         fout.close();
  133.     }
  134.  
  135.     /**
  136.      * Encodes a PilotDoc file
  137.      * @param sourcePath      full path of source text file
  138.      * @param destinationPath full path of destination PilotDoc file
  139.      * @param title           title to embed in PilotDoc
  140.      * @param compress        compress text in PilotDoc
  141.      * @param binary          process as binary file
  142.      * @param quiet           don't print as much information while processing
  143.      * @param docID           PilotDoc ID
  144.      * @param bookMarkPath    full path of bookmark file
  145.      * @param compressEOL     remove extra end of line characters
  146.      * @param makePrivate     make to PilotDoc private
  147.      * @throws IOException to the caller can handle any I/O errors
  148.      * @since 1.0
  149.      */
  150.     public static void encode(final String sourcePath,
  151.                               final String destinationPath,
  152.                               final String title,
  153.                               final boolean compress,
  154.                               final boolean binary,
  155.                               final boolean quiet,
  156.                               final int docID,
  157.                               final String bookMarkPath,
  158.                               final boolean compressEOL,
  159.                               final boolean makePrivate) throws IOException {
  160.  
  161.         boolean processBookMarks = false;
  162.         boolean deletePilotDoc = false;
  163.         Vector bookMarks = null;
  164.         PilotDocRecord textBuffer = null;
  165.         RandomAccessFile fout = null;
  166.         DocumentHeader docHeader = new DocumentHeader();
  167.         byte attribute = 0;
  168.         if(makePrivate) {
  169.             attribute |= RecordIndex.PRIVATE;
  170.         }
  171.         try {
  172.             FileInputStream fin = new FileInputStream(sourcePath);
  173.             docHeader.storyLen = fin.available();
  174.             textBuffer = new PilotDocRecord(docHeader.storyLen);    // allocate enough to hold entire file
  175.             fin.read(textBuffer.buf);    // read entire file
  176.             fin.close();
  177.             (new File(destinationPath)).delete();
  178.             fout = new RandomAccessFile(destinationPath, "rw");
  179.         }
  180.         catch(FileNotFoundException e) {
  181.             System.err.println("The file " + sourcePath + " could not be found");
  182.             return;
  183.         }
  184.         catch(IOException e) {
  185.             System.err.println("The file " + destinationPath + " could not be created");
  186.             return;
  187.         }
  188.  
  189.         ///////////////////////////////////////////////////
  190.         // deal with bookmarks if necessary
  191.         if(bookMarkPath != null) {
  192.             BookMarkHelperMD bmh = null;
  193.             processBookMarks = true;
  194.             bookMarks = new Vector(10, 10);
  195.             LineNumberReader finb;
  196.             try {
  197.                 finb = new LineNumberReader(new FileReader(bookMarkPath));
  198.             }
  199.             catch(FileNotFoundException e) {
  200.                 System.err.println("The file " + bookMarkPath + " could not be found");
  201.                 return;
  202.             }
  203.             String line;
  204.             StringTokenizer lineToken;
  205.             while((line = finb.readLine()) != null) {
  206.                 if(line.charAt(0) != '!') {
  207.                     lineToken = new StringTokenizer(line, ",");
  208.                     bmh = new BookMarkHelperMD();
  209.                     bmh.name = lineToken.nextToken();
  210.                     try {
  211.                         bmh.searchText = lineToken.nextToken();
  212.                         try {
  213.                             bmh.fileOffset = Integer.decode(bmh.searchText).intValue();
  214.                         }
  215.                         catch(NumberFormatException e) {
  216.                         }
  217.                     }
  218.                     catch(NoSuchElementException e) {
  219.                     }
  220.                     bookMarks.addElement(bmh);
  221.                 }
  222.             }
  223.             finb.close();
  224.         }
  225.  
  226.         System.out.println("Encoding `" + destinationPath + "` as `" + title + "`," +
  227.             (binary ? " binary," : "")  +
  228.             (compress ? "" : " not") + " compressed" +
  229.             (makePrivate ? "private" : ""));
  230.  
  231.         if(binary == false) {
  232.             textBuffer.removeBinary();
  233.         }
  234.         docHeader.storyLen = textBuffer.convertEOL(compressEOL);    // we know the "real" story length
  235.  
  236.         DatabaseHeader dbHeader = new DatabaseHeader();
  237.         dbHeader.name = title;
  238.         dbHeader.setModificationDate();
  239.         dbHeader.creatorID = docID;
  240.         dbHeader.typeID = DatabaseHeader.TEXt;
  241.  
  242.         docHeader.version = (compress ? DocumentHeader.COMPRESSED : DocumentHeader.UNCOMPRESSED);
  243.         docHeader.recordSize = DocumentHeader.textRecordSize;
  244.  
  245.         docHeader.numRecords = (short)(docHeader.storyLen / DocumentHeader.textRecordSize);
  246.         if(docHeader.numRecords * DocumentHeader.textRecordSize < docHeader.storyLen) {
  247.             docHeader.numRecords++;
  248.         }
  249.  
  250.         if(processBookMarks) {
  251.             dbHeader.numRecords = (short)(docHeader.numRecords + 1 + bookMarks.size());
  252.         }
  253.         else {
  254.             dbHeader.numRecords = (short)(docHeader.numRecords + 1);
  255.         }
  256.         dbHeader.write(fout);
  257.  
  258.         int bookMarkIndex = docHeader.numRecords + 1;    // this will only be used if we are bookmarking
  259.  
  260.         RecordIndex[] ri = new RecordIndex[dbHeader.numRecords];
  261.         ri[0] = new RecordIndex();
  262.         ri[0].attribute = attribute;
  263.         ri[0].write(fout);
  264.         for(int i = 1; i < dbHeader.numRecords; i++) {
  265.             ri[i] = new RecordIndex();
  266.             ri[i].fileOffset = 0;
  267.             ri[i].write(fout);
  268.         }
  269.  
  270.         ri[0].fileOffset = (int) fout.getFilePointer();
  271.  
  272.         docHeader.write(fout);
  273.  
  274.         int totalCompressedBytes = 0;
  275.         byte[] uncompressedBuffer = new byte[textBuffer.length()];
  276.         System.arraycopy(textBuffer.buf, 0, uncompressedBuffer, 0, textBuffer.length());
  277.         int processed = 0;
  278.         int compressed = 0;
  279.         int original = 0;
  280.  
  281.         for(int recNum = 1; recNum <= docHeader.numRecords; recNum++) {
  282.             ri[recNum].fileOffset = (int)fout.getFilePointer();
  283.             original = docHeader.recordSize;
  284.             if(original + processed > uncompressedBuffer.length) {
  285.                 original = uncompressedBuffer.length - processed;
  286.             }
  287.             textBuffer.assign(uncompressedBuffer, original, processed);
  288.             processed += original;
  289.             if(compress) {
  290.                 compressed = textBuffer.compress();
  291.                 totalCompressedBytes += compressed;
  292.             }
  293.             fout.write(textBuffer.buf);
  294.             System.out.print("\rconverting record " + recNum + " of " + docHeader.numRecords);
  295.             if(quiet == false && processed > 0 && compress) {
  296.                 System.out.print(" original " + original + " compressed to "
  297.                     + compressed + " ratio: " + (int)(100. * compressed / original + .5) + "%  ");
  298.             }
  299.         }
  300.  
  301.         System.out.println();
  302.         // process the bookmarks
  303.         if(processBookMarks) {
  304.             String uncompressedText = new String(uncompressedBuffer);
  305.             uncompressedBuffer = null;    // free the resouce
  306.             if(quiet == false) {
  307.                 System.out.println("Processing bookmarks");
  308.             }
  309.             BookMarkHelperMD bmh;
  310.             for(int bm = 0; bm < bookMarks.size(); bm++) {
  311.                 bmh = (BookMarkHelperMD)bookMarks.elementAt(bm);
  312.                 if(bmh.fileOffset == -1 && bmh.search(uncompressedText)) {
  313.                     if(quiet == false) {
  314.                         System.out.println("We found `" + bmh.name + "` bookmark");
  315.                     }
  316.                 }
  317.             }
  318.             for(int bm = 0; bm < bookMarks.size(); bm++) {
  319.                 if(((BookMarkHelperMD)bookMarks.elementAt(bm)).fileOffset == -1) {
  320.                     System.err.println("Bookmark " + ((BookMarkHelperMD)bookMarks.elementAt(bm)).name + " not found");
  321.                     deletePilotDoc = true;
  322.                 }
  323.                 else {
  324.                     ri[bookMarkIndex + bm].fileOffset = (int)fout.getFilePointer();
  325.                     ((BookMarkHelperMD)bookMarks.elementAt(bm)).write(fout);
  326.                 }
  327.             }
  328.         }
  329.  
  330.         // re-write the record index array, now with the correct file offsets
  331.         fout.seek(DatabaseHeader.getSize());
  332.         for(int i = 0; i < ri.length; i++) {
  333.             ri[i].write(fout);
  334.         }
  335.         fout.close();
  336.  
  337.         if(compress && quiet == false) {
  338.             System.out.println("Processed " + docHeader.storyLen +
  339.                 " bytes, compressed to " + totalCompressedBytes +
  340.                 " bytes, ratio: " + (int)(100. * totalCompressedBytes / docHeader.storyLen + .5) + "%");
  341.         }
  342.  
  343.         if(deletePilotDoc) {
  344.             System.err.println(">>>>>" + destinationPath + " is being DELETED<<<<<");
  345.             (new File(destinationPath)).delete();
  346.         }
  347.  
  348.     }
  349.  
  350.     /**
  351.      * Start of the application
  352.      * @param args arguments to MakeDocJ application
  353.      * @since 1.0
  354.      */
  355.     public static void main(String args[]) {
  356.         System.out.println("MakeDocJ v" + version);
  357.         if(args.length > 0) {
  358.             if(args[0].charAt(0) == '@') {
  359.                 String optionFile = args[0].substring(1);
  360.                 try {
  361.                     LineNumberReader optFile = new LineNumberReader(new FileReader(optionFile));
  362.                     String line;
  363.                     while((line = optFile.readLine()) != null) {
  364.                         if(line.length() > 0 && line.charAt(0) != '!') {
  365.                             Vector arguments = new Vector(5);
  366.                             int tokens = 0;
  367.                             boolean inQuoteArgument = false;
  368.                             boolean removeEndQuote = false;
  369.                             char curChar;
  370.                             int startToken = 0;
  371.                             for(int curCharPos = 0; curCharPos < line.length(); curCharPos++) {
  372.                                 curChar = line.charAt(curCharPos);
  373.                                 if(curChar == '"') {
  374.                                     if(inQuoteArgument) {
  375.                                         inQuoteArgument = false;
  376.                                     }
  377.                                     else {
  378.                                         inQuoteArgument = true;
  379.                                         startToken++;    // So we don't get quote
  380.                                         removeEndQuote = true;
  381.                                     }
  382.                                 }
  383.                                 if(curChar == ' ' && inQuoteArgument == false) {
  384.                                     if(removeEndQuote) {
  385.                                         removeEndQuote = false;
  386.                                         arguments.addElement(line.substring(startToken, curCharPos - 1));
  387.                                     }
  388.                                     else {
  389.                                         arguments.addElement(line.substring(startToken, curCharPos));
  390.                                     }
  391.                                     startToken = curCharPos + 1;
  392.                                 }
  393.                             }
  394.                             if(inQuoteArgument) {
  395.                                 System.err.println("Unmatching quotes in command line");
  396.                                 return;
  397.                             }
  398.                             else {
  399.                                 if(removeEndQuote) {
  400.                                     arguments.addElement(line.substring(startToken, line.length() - 1));
  401.                                 }
  402.                                 else {
  403.                                     arguments.addElement(line.substring(startToken, line.length()));
  404.                                 }
  405.                             }
  406.  
  407.                             String optArgs[] = new String[arguments.size()];
  408.                             Enumeration e = arguments.elements();
  409.                             for(int curToken = 0; e.hasMoreElements(); curToken++) {
  410.                                 optArgs[curToken] = (String)e.nextElement();
  411.                             }
  412.                             processArgs(optArgs);
  413.                             System.out.println();
  414.                         }
  415.                     }
  416.                 }
  417.                 catch(FileNotFoundException e) {
  418.                     System.err.println("the file " + optionFile + " could not be found");
  419.                     return;
  420.                 }
  421.                 catch(IOException e) {
  422.                     System.err.println("the file " + optionFile + " could not be processed");
  423.                     return;
  424.                 }
  425.             }
  426.             else {
  427.                 processArgs(args);
  428.             }
  429.         }
  430.         else {
  431.             usage();
  432.         }
  433.     }
  434.  
  435.     /**
  436.      * processes argument array
  437.      * @param args arguments to MakeDocJ application
  438.      * @since 2.1
  439.      */
  440.     private static void processArgs(String args[]) {
  441.         if(args.length < 3) {
  442.             usage();
  443.         }
  444.         else {
  445.             int argNum = -1;
  446.             boolean decode = false;            // default to compress
  447.             boolean binary = false;            // keep binary data
  448.             boolean quiet = false;            // report mucho information
  449.             boolean compress = true;        // we are compressing
  450.             boolean bookmarks = false;        // don't generate .bm file
  451.             boolean compressEOL = false;    // compress multi-linefeeds
  452.             boolean makePrivate = false;    // PilotDoc is private
  453.             int eolType = PilotDocRecord.EOLLF;    // UNIX => LF
  454.             int docID = DatabaseHeader.ReaderID;    // 'REAd' database creator ID, generic reader
  455.  
  456.             while(argNum++ < args.length && args[argNum].charAt(0) == '-' || args[argNum].charAt(0) == '\\' || args[argNum].charAt(0) == '/') {
  457.                 if(args[argNum].charAt(1) == '1') {        // DOS => CR/LF
  458.                     eolType = PilotDocRecord.EOLCRLF;
  459.                     continue;
  460.                 }
  461.                 if(args[argNum].charAt(1) == '2') {        // MAC => CR
  462.                     eolType = PilotDocRecord.EOLCR;
  463.                     continue;
  464.                 }
  465.                 if(args[argNum].charAt(1) == 'c') {
  466.                     compressEOL = true;
  467.                     continue;
  468.                 }
  469.                 if(args[argNum].charAt(1) == 'b') {
  470.                     bookmarks = true;
  471.                     continue;
  472.                 }
  473.                 if(args[argNum].charAt(1) == 'd') {
  474.                     decode = true;
  475.                     continue;
  476.                 }
  477.                 if(args[argNum].charAt(1) == 'i') {
  478.                     argNum++;
  479.                     byte[] id = args[argNum].getBytes();
  480.                     if(id.length != 4) {
  481.                         System.err.println(args[argNum] + " is incorrect length, must be 4 characters");
  482.                         System.exit(1);
  483.                     }
  484.                     else {
  485.                         docID = ((0xff & id[0]) << 24) + ((0xff & id[1]) << 16) + ((0xff & id[2]) << 8) + (0xff & id[3]);
  486.                     }
  487.                     continue;
  488.                 }
  489.                 if(args[argNum].charAt(1) == 'n') {
  490.                     compress = false;
  491.                     continue;
  492.                 }
  493.                 if(args[argNum].charAt(1) == 'p') {
  494.                     makePrivate = true;
  495.                     continue;
  496.                 }
  497.                 if(args[argNum].charAt(1) == 'q') {
  498.                     quiet = true;
  499.                     continue;
  500.                 }
  501.                 if(args[argNum].charAt(1) == 'r') {
  502.                     binary = false;
  503.                     continue;
  504.                 }
  505.                 if(args[argNum].charAt(1) == 't') {
  506.                     docID = DatabaseHeader.TealDocID;
  507.                     continue;
  508.                 }
  509.                 System.out.println("Unknown option `" + args[argNum].charAt(1) + "`");
  510.                 usage();
  511.                 return;
  512.             }
  513.  
  514.             try {
  515.                 if(decode) {
  516.                     decode(args[argNum], args[argNum + 1], eolType, bookmarks);
  517.                 }
  518.                 else {
  519.                     String bookMarkPath = null;
  520.                     try {
  521.                         bookMarkPath = args[argNum + 3];
  522.                     }
  523.                     catch(java.lang.ArrayIndexOutOfBoundsException e) {
  524.                         bookMarkPath = null;
  525.                     }
  526.                     encode(args[argNum], args[argNum + 1], args[argNum + 2],
  527.                         compress, binary, quiet, docID, bookMarkPath, compressEOL, makePrivate);
  528.                 }
  529.             }
  530.             catch(Exception e) {
  531.                 System.out.println(e.toString());
  532.             }
  533.         }
  534.     }
  535.  
  536.     /**
  537.      * @since 1.0
  538.      */
  539.     private static void usage() {
  540.         System.out.println("Usage: MakeDocJ [-options] ...");
  541.         System.out.println();
  542.         System.out.println("MakeDocJ [-options] <text-file> <PilotDOC-file> <story-name> [<bookmark-file>]");
  543.         System.out.println("  encode text file into PilotDOC format file");
  544.         System.out.println("    -c compress multi-linefeeds out of <text-file>");
  545.         System.out.println("    -i <database ID> four character database ID");
  546.         System.out.println("    -n builds the PilotDOC file without compression");
  547.         System.out.println("    -p sets the PilotDoc to private");
  548.         System.out.println("    -q quiet (i.e. minimal reporting during encoding process)");
  549.         System.out.println("    -r remove binary");
  550.         System.out.println("    -t database ID is TealDoc instead of generic reader");
  551.         System.out.println();
  552.         System.out.println("MakeDocJ -d [-options] <PilotDOC-file> <text-file>");
  553.         System.out.println("  decode PilotDOC format file into the text file");
  554.         System.out.println("    -1 end of line is CR/LF (i.e. DOS)");
  555.         System.out.println("    -2 end of line is CR    (i.e. MAC)");
  556.         System.out.println("    -b generate a bookmark file (<text-file>.bm) if there are any bookmarks");
  557.         System.out.println("    -d decodes the PilotDOC file into a text file");
  558.         System.out.println();
  559.         System.out.println("MakeDocJ @<options-file>");
  560.         System.out.println("  process <options-file> to get options");
  561.     }
  562. }
  563.  
  564. /**
  565.  * <code>BookMarkHelperMD</code> is used to help generate bookmarks in the PilotDoc
  566.  * @author Jeffrey A. Krzysztow
  567.  * @version 1.1
  568.  */
  569. class BookMarkHelperMD extends BookMark {
  570.     /**
  571.      * holds the regular expression text we will use in search
  572.      * @see search
  573.      * @since 1.0
  574.      */
  575.     public String searchText = null;
  576.  
  577.     /**
  578.      * searches text2Search for the seachText and sets the fileOffset from BookMark
  579.      * @param text2Search text to search
  580.      * @returns whether it found the text or not
  581.      * @since 1.0
  582.      */
  583.     public boolean search(String text2Search) {
  584.         boolean returnValue = false;
  585.         if(searchText == null) {
  586.             fileOffset = text2Search.indexOf(name);
  587.             if(fileOffset > -1) {
  588.                 returnValue = true;
  589.             }
  590.         }
  591.         else {
  592.             try {
  593.                 RE searchRE = new RE(searchText, RE.REG_MULTILINE);
  594.                 try {
  595.                     REMatch rem = searchRE.getMatch(text2Search);
  596.                     if(null != rem ){
  597.                         returnValue = true;
  598.                         fileOffset = rem.getStartIndex();
  599.                     }
  600.                 }
  601.                 catch(IllegalArgumentException e) {
  602.                     e.printStackTrace();
  603.                 }
  604.             }
  605.             catch(REException e){
  606.                 e.printStackTrace();
  607.             }
  608.         }
  609.         return(returnValue);
  610.     }
  611.  
  612.     /**
  613.      * override Object.toString()
  614.      * @since 1.0
  615.      */
  616.     public String toString() {
  617.         return ">> BookMarkHelperMD <<\nname = `" + name
  618.             + "`\nfileOffset = " + fileOffset
  619.             + "\nsearchText = " + searchText;
  620.     }
  621. }
  622.