Sun Message Library for SWIFT API

com.stc.swift.builder
Class SwiftHRFReader

java.lang.Object
  extended by com.stc.swift.builder.SwiftHRFReader
All Implemented Interfaces:
SwiftReader
Direct Known Subclasses:
SwiftHRFFieldSpecReader, SwiftHRFSpecReader

public abstract class SwiftHRFReader
extends java.lang.Object
implements SwiftReader

Read in a text file as lines of charactors, check the following:


Constructor Summary
SwiftHRFReader(SwiftHRFHeuristics rules)
           
 
Method Summary
 java.lang.String filterOutTags(java.lang.String text, java.lang.String[] tags)
           
 java.lang.String[] getDelimitedMultiValues(java.lang.String line, java.lang.String delim, java.util.regex.Pattern patt)
          convenient wrapper - get multiple values and filter out deleted values (contents quoted by and )
 java.lang.String[] getDelimitedMultiValues(java.lang.String line, java.lang.String delim, java.util.regex.Pattern patt, boolean stripDEL)
          given a line and delim, split the line by delim, and extract value from each component by applying the regex - pattern, if stripDEL is true, also filter out the ... from the component before applying the pattern;
abstract  void parse(java.io.File input)
          parse the html file input
 java.util.List parseFormatSection(java.lang.String line)
          return a list of multiple values - list of String[];
 java.lang.String readNextElement(java.io.LineNumberReader reader, java.lang.String currLine, java.lang.String openTag, java.lang.String closeTag, int srchLimitOpen, int srchLimitClose, boolean inclusive, java.lang.String[] lastLine, java.lang.String terminator)
          given open and close tags and a current line of text processed, return the string that is enveloped with open and close tag
 java.lang.String readNextElement(java.lang.String currLine, java.lang.String openTag, java.lang.String closeTag, int srchLimitOpen, int srchLimitClose, boolean inclusive, java.lang.String[] lastLine, java.lang.String terminator)
          given open and close tags and a current line of text processed, return the string that is enveloped with open and close tag
 java.lang.String readTagWithValue(java.io.LineNumberReader reader, java.lang.String curLine, java.lang.String tagOpen, java.lang.String tagClose, java.lang.String value)
          read until a line contains the pattern, also contains the keyword;
 java.lang.String readUtil(java.io.LineNumberReader reader, java.lang.String curLine, java.lang.String pattern)
          read until a line contains the pattern;
 java.lang.String readUtil(java.io.LineNumberReader reader, java.lang.String curLine, java.lang.String tag, boolean open, boolean inclusive, java.lang.String[] lastLineRead)
          read lines until the line contains the given tag found;
 java.lang.String readUtil(java.lang.String curLine, java.lang.String pattern)
           
 java.lang.String readUtil(java.lang.String curLine, java.lang.String tag, boolean open, boolean inclusive, java.lang.String[] lastLineRead)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwiftHRFReader

public SwiftHRFReader(SwiftHRFHeuristics rules)
Method Detail

parse

public abstract void parse(java.io.File input)
                    throws java.lang.Exception
Description copied from interface: SwiftReader
parse the html file input

Specified by:
parse in interface SwiftReader
Throws:
java.lang.Exception

getDelimitedMultiValues

public java.lang.String[] getDelimitedMultiValues(java.lang.String line,
                                                  java.lang.String delim,
                                                  java.util.regex.Pattern patt)
convenient wrapper - get multiple values and filter out deleted values (contents quoted by and )

Parameters:
line -
delim -
patt -
Returns:

getDelimitedMultiValues

public java.lang.String[] getDelimitedMultiValues(java.lang.String line,
                                                  java.lang.String delim,
                                                  java.util.regex.Pattern patt,
                                                  boolean stripDEL)
given a line and delim, split the line by delim, and extract value from each component by applying the regex - pattern, if stripDEL is true, also filter out the ... from the component before applying the pattern;

Parameters:
line -
delim -
patt -
stripDEL -
Returns:

parseFormatSection

public java.util.List parseFormatSection(java.lang.String line)
return a list of multiple values - list of String[];

Parameters:
line -
Returns:

filterOutTags

public java.lang.String filterOutTags(java.lang.String text,
                                      java.lang.String[] tags)

readNextElement

public java.lang.String readNextElement(java.lang.String currLine,
                                        java.lang.String openTag,
                                        java.lang.String closeTag,
                                        int srchLimitOpen,
                                        int srchLimitClose,
                                        boolean inclusive,
                                        java.lang.String[] lastLine,
                                        java.lang.String terminator)
                                 throws java.io.IOException
Description copied from interface: SwiftReader
given open and close tags and a current line of text processed, return the string that is enveloped with open and close tag

Specified by:
readNextElement in interface SwiftReader
Parameters:
currLine - - current line where the search for open tag starts with;
openTag - - open tag
closeTag - - close tag
srchLimitOpen - - # lines to search for the open tag
srchLimitClose - - # lines to search for the close tag
inclusive - - true include the tags in the result, false otherwise;
lastLine - - the last line read when the search process finishes;
Returns:
the string that is enveloped by the tags, NULL - failed to find one within the limits;
Throws:
java.io.IOException - - if there is IO error during line reading;

readNextElement

public java.lang.String readNextElement(java.io.LineNumberReader reader,
                                        java.lang.String currLine,
                                        java.lang.String openTag,
                                        java.lang.String closeTag,
                                        int srchLimitOpen,
                                        int srchLimitClose,
                                        boolean inclusive,
                                        java.lang.String[] lastLine,
                                        java.lang.String terminator)
                                 throws java.io.IOException
given open and close tags and a current line of text processed, return the string that is enveloped with open and close tag

Parameters:
currLine - - current line where the search for open tag starts with;
openTag - - open tag
closeTag - - close tag
srchLimitOpen - - # lines to search for the open tag
srchLimitClose - - # lines to search for the close tag
inclusive - - true include the tags in the result, false otherwise;
lastLine - - the last line read when the search process finishes;
termiantor - - a string if found in the line processed - the process will terminate and return;
Returns:
the string that is enveloped by the tags, NULL - failed to find one within the limits;
Throws:
java.io.IOException - - if there is IO error during line reading;

readUtil

public java.lang.String readUtil(java.lang.String curLine,
                                 java.lang.String tag,
                                 boolean open,
                                 boolean inclusive,
                                 java.lang.String[] lastLineRead)
                          throws java.io.IOException
Throws:
java.io.IOException

readUtil

public java.lang.String readUtil(java.io.LineNumberReader reader,
                                 java.lang.String curLine,
                                 java.lang.String tag,
                                 boolean open,
                                 boolean inclusive,
                                 java.lang.String[] lastLineRead)
                          throws java.io.IOException
read lines until the line contains the given tag found;

Parameters:
curLine - - the starting line for the search;
tag - - the tag to be detected in the text lines;
open - - true if the tag is an HTML open tag (such as ) false - it is an close tag;
inclusive - - true, the returned text includes the tag, false, otherwise;
Returns:
- the text from the line that contains the tag, when open = true, the text before the tag will be trimed (following the inclusive flag), when open = false, trim the text after the tag; if return is null, not found;
Throws:
java.io.IOException

readUtil

public java.lang.String readUtil(java.lang.String curLine,
                                 java.lang.String pattern)
                          throws java.io.IOException
Throws:
java.io.IOException

readTagWithValue

public java.lang.String readTagWithValue(java.io.LineNumberReader reader,
                                         java.lang.String curLine,
                                         java.lang.String tagOpen,
                                         java.lang.String tagClose,
                                         java.lang.String value)
                                  throws java.io.IOException
read until a line contains the pattern, also contains the keyword;

Parameters:
pattern -
Returns:
- the line containing the pattern
Throws:
java.io.IOException

readUtil

public java.lang.String readUtil(java.io.LineNumberReader reader,
                                 java.lang.String curLine,
                                 java.lang.String pattern)
                          throws java.io.IOException
read until a line contains the pattern;

Parameters:
pattern -
Returns:
- the line containing the pattern
Throws:
java.io.IOException

Sun Message Library for SWIFT API

Copyright © 2008 Sun Microsystems, Inc. All rights reserved.