Skip to main content
Package: com.phoenix_int.aserver.util Class Hierarchy
Implemented Interfaces
  • Parser

Declaration
This is a utility class for loading data files and extracting data. Sample Usage:
NOTES:
  • This class works by remembering what things have changed, but not actually performing the changes until the file is written out. This prevents changes to one place in the file from messing up something elsewhere.
  • Note however that there is a requirement that no changes overlap or are repeated. For example, you may not set the value of one token twice (the results of which are undefined). Neither may you change a token, then change the delimiters and change another token that includes part of the first. The same holds true for adding and removing lines. You may not add or remove lines to sections of the file previously altered.

Nested Class Summary

Field Summary

Constructor Summary

Method Summary

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

RESIZE_DISALLOW

Don’t allow the length of an array to change See Also:

RESIZE_ROWS

See Also:

LAST

See Also:

RANDOM_ACCESS

Deprecated in favor of Parser.Mode.RANDOM

BUFFERED

Deprecated in favor of Parser.Mode.BUFFERED

AUTOMATIC

Deprecated in favor of Parser.Mode.AUTOMATIC

FILE_SIZE_LIMIT

Deprecated in favor of Parser.Mode.FILE_SIZE_LIMIT cut-off limit of file size to use buffers for row files See Also:

Constructor Detail

PHXFileParser

Throws:
  • java.io.IOException

PHXFileParser

Parameters:
  • fileName - the file to load
Throws:
  • java.io.IOException - if there is a problem opening the file

PHXFileParser

Throws:
  • java.io.IOException

PHXFileParser

Throws:
  • java.io.IOException

PHXFileParser

Throws:
  • java.io.IOException

PHXFileParser

Throws:
  • java.io.IOException

PHXFileParser

Deprecated in favor of PHXFileParser(String, Parser.Mode) Parameters:
  • fileName - the file to load
  • method - the method used to parse the file. RANDOM_ACCESS will scan the data file as needed. BUFFERED will read the file into a buffer prior to parsing. RANDOM_ACCESS is better for large files, but will be slower for small (<50k) files. BUFFERED is also preferable for parsing many variables from a file or for performing large numbers of searches.
Throws:
  • java.io.IOException - if there is a problem opening the file

PHXFileParser

Parameters:
  • store - The source of lines for the file parser.
  • fileName - The name of the file for errors and advisories. This parameter is not used for any actual processing

Method Detail

getLineStore

Gets the underlying line store object for this parser Returns:
  • the line store used by the parser

getFileName

Retrieves the name of the file that is being parsed Returns:
  • the name of the file

writeTo

Throws:
  • java.io.IOException

writeTo

Throws:
  • java.io.IOException

writeTo

Throws:
  • java.io.IOException

writeTo

Writes out the data to a file Specified by:
  • writeTo in interface Parser
Parameters:
  • fw - the stream to save to
Throws:
  • java.io.IOException - thrown if the file cannot be written to

close

Description copied from interface: Parser Close the parser Specified by:
  • close in interface Parser

closeFile

Close the PHXRandomAccessFileLineStore

resetDelimiters

Resets the delimiters to whitespace

getDelimiters

setDelimiters

Sets the current delimiter set Parameters:
  • delimiters - the delimiters to use for parsing

getDecimalSeparator

Gets decimal separator character for floating point literals Returns:
  • decimal separator character

setDecimalSeparator

Sets decimal separator character for floating point literals Parameters:
  • separator - decimal separator to use when parsing floating point literals

markBeginning

Marks the starting point from which to start counting rows and fields. Position is marked relative to the last marked position. Parameters:
  • row - the row where the new beginning will occur. This row becomes row 1.
Throws:

markEnd

Marks the ending point of the file. Position is marked relative to the last marked position. Parameters:
  • row - the row where the new ending will occur. This row becomes the last row.
Throws:

markBeginningOffset

Marks the starting point from which to start counting rows and fields. Position is marked relative to the last marked position. Parameters:
  • offset - the offset from the current starting line
Throws:
  • java.lang.IllegalArgumentException - thrown if the specified offset moves past the end or beginning of the file

markBeginning

Same as markBeginning with an occurrence value of 1 Parameters:
  • string - the pattern that marks the new first line
  • isRegex - if true, the pattern is a regular expression
Throws:

markBeginning

Same as markBeginning where the pattern is a regex and occurrence value is 1 Parameters:
  • string - the pattern that marks the new first line
Throws:

markBeginning

Marks the starting point from which to start counting rows and fields. Position is marked relative to the last marked position. Parameters:
  • string - the search pattern
  • occurrence - the number of times to search for the pattern. may be negative to search from end
  • isRegex - if true, the string is a regular expression.
Throws:

markBeginning

Marks the starting point from which to start counting rows and fields. Position is marked relative to the last marked position. Parameters:
  • string - the search pattern
  • occurrence - the number of times to search for the pattern. may be negative to search from end
Throws:

markEndOffset

Marks the ending point from which to start counting rows and fields. Position is marked relative to the previously marked position. Parameters:
  • offset - the offset from the current starting line
Throws:
  • java.lang.IllegalArgumentException - thrown if the specified offset moves past the end or beginning of the file

markEnd

Same as markEnd with an occurrence value of 1 Parameters:
  • string - the pattern that marks the new first line
  • isRegex - if true, the pattern is a regular expression
Throws:

markEnd

Marks the ending point from which to start counting rows and fields. Position is marked relative to the last marked position. Parameters:
  • string - the pattern that marks the new last line
  • isRegex - if true, the pattern is a regular expression
  • occurrence - the number of times to search for regex value may be negative to search from beginning
Throws:

markEnd

Marks the ending point from which to start counting rows and fields. Position is marked relative to the last marked position. Search string is a regex. Parameters:
  • string - the pattern that marks the new last line
  • occurrence - the number of times to search for regex value may be negative to search from end
Throws:

markBeginningFromEnd

Marks the starting point from which to start counting rows. Position is marked relative to the previously marked position. Parameters:
  • string - the pattern that marks the new first line
  • isRegex - if true, the pattern is a regular expression
Throws:

markEndFromEnd

Marks the starting point from which to start counting rows and fields. Position is marked relative to the previously marked position. Parameters:
  • string - the pattern that marks the new first line
  • isRegex - if true, the pattern is a regular expression
Throws:

clearMarks

Resets the file to its whole size by removing the starting and ending marks if they existed

getToken

Gets the token relative to a search string. Indexing starts at 1. Parameters:
  • string - the value to search for
  • occurrence - the number of times to match the search
  • rowOffset - row relative to the search results where the token is found
  • field - the field in the specified row for the token
Returns:
  • the token found
Throws:

getToken

Gets the token relative to a search string. Indexing starts at 1. Parameters:
  • string - the value to search for
  • rowOffset - row relative to the search results where the token is found
  • field - the field in the specified row for the token
Returns:
  • the token found
Throws:

getToken

Gets the token at the specified row and field. Indexing starts at 1. Parameters:
  • row - the row that the token is on
  • field - the field in the specified row for the token
Returns:
  • the token found at row, field
Throws:

getToken

Gets the token at the specified row and column. Indexing starts at 1. Parameters:
  • row - the row that the token is on
  • startCol - the start column
  • endCol - the end column
Returns:
  • the token between startCol and endCol on row row
Throws:

getToken

Gets an array of tokens at the specified row and between start and end fields (all inclusive). Indexing starts at 1. Eg: if line = “IP = 1.5, 2.5, 3.5, 4.5”, then getToken(row, 2, 4, " \t,=") would return [1.5,2.5,3.5]. Parameters:
  • row - the row that the tokens are on
  • startField - the start field (inclusive)
  • endField - the end field (inclusive)
  • delimiter - the delimiters
Returns:
  • the token between startField and endField (all inclusive) on row row
Throws:

setToken

Gets the token relative to a search string. Indexing starts at 1. Parameters:
  • string - the value to search for
  • occurrence - the number of times to match the search
  • rowOffset - row relative to the search results where the token is found
  • field - the field in the specified row for the token
  • replacement - the string to substitute into the field
Throws:

setToken

Gets the token relative to a search string. Indexing starts at 1. Parameters:
  • string - the value to search for
  • rowOffset - row relative to the search results where the token is found
  • field - the field in the specified row for the token
  • replacement - the string to substitute into the field
Throws:

setToken

Replaces the token at the specified row and field. Indexing starts at 1. Parameters:
  • row - the row that the token is on
  • field - the field in the specified row for the token
  • replacement - the string to substitute into the field
Throws:

setToken

Replaces the token at the specified row and column. Indexing starts at 1. Parameters:
  • row - the row that the token is on
  • startCol - the start column
  • endCol - the end column
  • replacement - the string to substitute into the field
Throws:

addLines

addLines

removeLines

countTokens

Counts the number of tokens on a specified row Parameters:
  • row - the row to count tokens
Returns:
  • the number of tokens on the specified row
Throws:

getColumnArray

Gets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • endRow - the row for the last element in the array
  • field - the field in the specified row for the token
Returns:
  • an array of String tokens
Throws:

getRowArray

Gets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startCol - the field for the first element in the array
  • endCol - the field for the last element in the array
  • row - the row to extract tokens from
Returns:
  • an array of String tokens
Throws:

getMatrixArray

Gets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • startField - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endField - the field for the last element in the array
Returns:
  • an array of String tokens
Throws:

getMatrixArray2d

Gets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • startField - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endField - the field for the last element in the array
Returns:
  • an array of String tokens
Throws:

getMatrixArray

Gets an array of tokens for the specified range. Indexing starts at 1. Columns are actual columns and not field indexes. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the column for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the column for the last element in the array
  • fieldWidth - UNUSED. How wide one field is.
Returns:
  • an array of String tokens
Throws:

setMatrixArray

Sets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the field for the last element in the array
  • array - the values
Throws:

setMatrixArray

Sets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the field for the last element in the array
  • array - the values
  • resizeStyle - How to resize (RESIZE_DISALLOW, RESIZE_ROWS)
Throws:

setMatrixArray2d

Sets an array of tokens for the specified range. Indexing starts at 1. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the field for the last element in the array
  • array - the values
  • resizeStyle - How to resize (RESIZE_DISALLOW, RESIZE_ROWS)
Throws:

setMatrixArray

Sets an array of tokens for the specified range. Indexing starts at 1. Columns are specified instead of fields. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the field for the last element in the array
  • fieldWidth - UNUSED. How wide one field is.
  • array - the values
Throws:

setMatrixArray

Sets an array of tokens for the specified range. Indexing starts at 1. Columns are specified instead of fields. Parameters:
  • startRow - the row for the first element in the array
  • startCol - the field for the first element in the array
  • endRow - the row for the last element in the array
  • endCol - the field for the last element in the array
  • fieldWidth - UNUSED. How wide one field is.
  • array - the values
  • resizeStyle - How to resize (RESIZE_DISALLOW, RESIZE_ROWS)
Throws:

main