org.jaffa.tools.patternmetaengine
Class FindSection

java.lang.Object
  extended byorg.jaffa.tools.patternmetaengine.FindSection

public class FindSection
extends Object

Class for finding a section of text in a string based on a start and end string

Author:
PaulE

Constructor Summary
FindSection(String source, String startStr, String endStr)
          Creates a new instance of FindSection
 
Method Summary
 boolean found()
          Was the section found in source
 int getEndPos()
          Get end position of section.
 String getFullSection()
          Get the found section, null if not found
 String getSection()
          Get the found section, null if not found
 String getSectionHead()
          This returns the text that preceeds the found section.
 String getSectionTail()
          This returns the text that follows the found section.
 int getStartPos()
          Get start position of section.
static void main(String[] args)
          Test rig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindSection

public FindSection(String source,
                   String startStr,
                   String endStr)
Creates a new instance of FindSection

Parameters:
source - Text to be searched
startStr - Start phrase to look for
endStr - End phrase to look for
Method Detail

found

public boolean found()
Was the section found in source

Returns:
true if found

getStartPos

public int getStartPos()
Get start position of section. This is the location where the 'start string' is found.

Returns:
start postion of section, returns -1 if section not found

getEndPos

public int getEndPos()
Get end position of section. This is the location after the 'end' string's location.

Returns:
end postion of section, returns -1 if section not found

getSection

public String getSection()
Get the found section, null if not found

Returns:
The section text excluding the start and end strings

getFullSection

public String getFullSection()
Get the found section, null if not found

Returns:
The section text including the start and end strings

getSectionHead

public String getSectionHead()
This returns the text that preceeds the found section. If there is no section found, this returns the source string. Note: getSectionHead() + getFullSection() + getSectionTail() == source

Returns:
Header string, null if the section was the first thing in the source string

getSectionTail

public String getSectionTail()
This returns the text that follows the found section. If there is no section found, this returns null. Note: getSectionHead() + getFullSection() + getSectionTail() == source

Returns:
Tail string, null if the section was not found or the last thing in the source string

main

public static void main(String[] args)
Test rig

Parameters:
args - the command line arguments


Copyright © 2002-2004 JAFFA Project.