Open Business Objects for EDI
v3.6.0

com.americancoders.edi
Class DataTokenizer

java.lang.Object
  |
  +--com.americancoders.edi.DataTokenizer
All Implemented Interfaces:
IDataTokenizer

public class DataTokenizer
extends java.lang.Object
implements IDataTokenizer

class to assist in tokenizing input transaction sets
similar to the java.lang.StringTokenizer. It seemed that StringTokenizer couldn't return a zero-length element between 2 tokens - such as token(*) and string in is (***) it would not find 2 zero-length tokens.

OBOE - Open Business Objects for EDI

Part of the OBOE Basic Extended Package
An EDI and XML Translator Written In Java
Copyright 1998-2009 - American Coders, LTD - Raleigh NC USA
All rights reserved
American Coders, Ltd
P. O. Box 97462
Raleigh, NC 27624 USA
1-919-846-2014
http://www.americancoders.com

Version:
3.6.0
Author:
Joe McVerry - American Coders, Ltd.

Field Summary
protected  java.util.Vector allTokens
          where all the substrings are stored
protected  int currentPos
          current position within tokenized string
protected  java.lang.String escapeCharacters
          escape characters to allow tokens in the text
protected  int positionInStream
           
protected  int stringLength
          length of field
protected  java.lang.String tokens
          what breaks up fields
protected  java.lang.String tokenString
          current tokenized string
 
Constructor Summary
DataTokenizer(java.lang.String inString, java.lang.String inTokens, java.lang.String inEscapeCharacters)
          constructor
 
Method Summary
 int countTokens()
          how many tokens in list
 int getPositionInStream()
          returns the byte offset position of the token in the overall input stream
 java.lang.String getTokenAt(int pos)
          gets the token in tokenized string at a specifiec position
 java.lang.String getTokenString()
           
 boolean hasMoreElements()
          indicates if there are more data elements to parse
 java.lang.String nextToken()
          to get next token
 void setPositionInStream(int positionInStream)
          sets the byte offset position of the token in the input stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentPos

protected int currentPos
current position within tokenized string


stringLength

protected int stringLength
length of field


tokenString

protected java.lang.String tokenString
current tokenized string


tokens

protected java.lang.String tokens
what breaks up fields


escapeCharacters

protected java.lang.String escapeCharacters
escape characters to allow tokens in the text


allTokens

protected java.util.Vector allTokens
where all the substrings are stored


positionInStream

protected int positionInStream
Constructor Detail

DataTokenizer

public DataTokenizer(java.lang.String inString,
                     java.lang.String inTokens,
                     java.lang.String inEscapeCharacters)
constructor

Parameters:
inString - - string to be tokenized
inTokens - - list of tokens
inEscapeCharacters - - list of characters to escape and allow tokens in the text. pass an empty string or null if no escape characters used
Method Detail

nextToken

public java.lang.String nextToken()
to get next token

Specified by:
nextToken in interface IDataTokenizer
Returns:
String - the next token

getTokenAt

public java.lang.String getTokenAt(int pos)
gets the token in tokenized string at a specifiec position

Specified by:
getTokenAt in interface IDataTokenizer
Parameters:
pos - int position, if < 0 or > the total returns null
Returns:
String

hasMoreElements

public boolean hasMoreElements()
indicates if there are more data elements to parse

Specified by:
hasMoreElements in interface IDataTokenizer
Returns:
boolean more to parse?

countTokens

public int countTokens()
how many tokens in list

Specified by:
countTokens in interface IDataTokenizer
Returns:
int - a count

getTokenString

public java.lang.String getTokenString()

getPositionInStream

public int getPositionInStream()
Description copied from interface: IDataTokenizer
returns the byte offset position of the token in the overall input stream

Specified by:
getPositionInStream in interface IDataTokenizer
Returns:
int

setPositionInStream

public void setPositionInStream(int positionInStream)
Description copied from interface: IDataTokenizer
sets the byte offset position of the token in the input stream

Specified by:
setPositionInStream in interface IDataTokenizer

Open Business Objects for EDI
v3.6.0


OBOE is a trademark or registered trademark of American Coders, Ltd. in the US and other countries.
Copyright 1999-2004 American Coders, Ltd.
POB 97462
Raleigh NC 27624 USA
All Rights Reserved.