Package | com.ericfeminella.collections |
Class | public class StringTokenizer |
Implements | IEnumeration, Iterator |
StringTokenizer
provides an Iterator
and IEnumeration
implementation, thus making it
easy to implement as either interface.
Additionally, StringTokenizer
provides two static
factory methods for creating an instance as either implementaton
These convenience factory methods are createIterator
and createEnumeration
var tokens:StringTokenizer = StringTokenizer("hello world", " "); while ( tokens.hasMoreTokens() ) { trace( tokens.nextToken() ); } // outputs: // hello // world
See also
Property | Defined by | ||
---|---|---|---|
cursor : int
Stores the current position (cursor) in the tokens array from
which calls to
nextToken(); are based on
| StringTokenizer | ||
delimiter : String
Defines the delimiter from which the
source String
tokens are to be extracted
| StringTokenizer | ||
source : String
The source
String from which tokens are extracted
from based on the specified delimiter
| StringTokenizer | ||
tokens : Array
Defines the token
Array which contains each token
String extracted by the StringTokenizer instance
| StringTokenizer |
Method | Defined by | ||
---|---|---|---|
StringTokenizer(source:String, delimiter:String)
Creates a new instance of
StringTokenizer and
processes the source String into an array of tokens based
on the specified delimiter
| StringTokenizer | ||
countTokens():int
Retrieves the length of tokens extracted from the source
String
| StringTokenizer | ||
createEnumeration(source:String, delimiter:String):IEnumeration
[static]
Static Factory method which creates a new
IEnumeration
StringTokenizer implementation
| StringTokenizer | ||
createIterator(source:String, delimiter:String):Iterator
[static]
Static Factory method which creates a new
Iterator
StringTokenizer implementation
| StringTokenizer | ||
hasMoreElements():Boolean
IEnumeration implementation which determines if
there are more tokens which have yet to be retrieved via calls
to nextToken
| StringTokenizer | ||
hasMoreTokens():Boolean
Determines if there are more tokens which have yet to be
retrieved via calls to
nextToken
| StringTokenizer | ||
hasNext():Boolean
Iterator implementation which determines if
there are more tokens which have yet to be retrieved via
calls to nextToken
| StringTokenizer | ||
next():*
Retrieves the next element in the
StringTokenizer
instance
| StringTokenizer | ||
nextElement():*
Retrieves the next token in the
StringTokenizer
instance
| StringTokenizer | ||
nextToken():String
Retrieves the next token in the
StringTokenizer
instance. | StringTokenizer | ||
position():int
Determines the current position within the token
| StringTokenizer | ||
remove():void
Remove must be implemented to provide a standard iterator
implementation.
| StringTokenizer | ||
reset():void
Resets the position of the
StringTokenizer to
zero
| StringTokenizer |
cursor | property |
protected var cursor:int
Stores the current position (cursor) in the tokens array from
which calls to nextToken();
are based on
delimiter | property |
protected var delimiter:String
Defines the delimiter from which the source
String
tokens are to be extracted
source | property |
protected var source:String
The source String
from which tokens are extracted
from based on the specified delimiter
tokens | property |
protected var tokens:Array
Defines the token Array
which contains each token
String extracted by the StringTokenizer
instance
StringTokenizer | () | constructor |
public function StringTokenizer(source:String, delimiter:String)
Creates a new instance of StringTokenizer
and
processes the source String into an array of tokens based
on the specified delimiter
source:String — source String from which the tokens are to be extracted
|
|
delimiter:String — delimiter on which the tokens are extracted
|
var tokens:StringTokenizer = new StringTokenizer("This is a test", " "); trace( tokens.countTokens() );
countTokens | () | method |
public function countTokens():int
Retrieves the length of tokens extracted from the source String
Returnsint — the length of tokens in the source
|
createEnumeration | () | method |
public static function createEnumeration(source:String, delimiter:String):IEnumeration
Static Factory method which creates a new IEnumeration
StringTokenizer implementation
source:String — the source String from which the tokens are to be extracted
|
|
delimiter:String — the delimiter on which the tokens are extracted
|
IEnumeration —
a new StringTokenizer as an IEnumeration
|
var tokens:IEnumeration = StringTokenizer.createEnumeration("This is a test", " "); while ( tokens.hasMoreElements() ) { trace( tokens.nextElement() ); }
createIterator | () | method |
public static function createIterator(source:String, delimiter:String):Iterator
Static Factory method which creates a new Iterator
StringTokenizer implementation
source:String — the source String from which the tokens are to be extracted
|
|
delimiter:String — the delimiter on which the tokens are extracted
|
Iterator —
a new StringTokenizer as an Iterator
|
var tokens:Iterator = StringTokenizer.createIterator("This is a test", " "); while ( tokens.hasNext() ) { trace( tokens.next() ); }
hasMoreElements | () | method |
public function hasMoreElements():Boolean
IEnumeration
implementation which determines if
there are more tokens which have yet to be retrieved via calls
to nextToken
Boolean — true if more tokens remain, otherwise false
|
hasMoreTokens | () | method |
public function hasMoreTokens():Boolean
Determines if there are more tokens which have yet to be
retrieved via calls to nextToken
Boolean — true if more tokens remain, otherwise false
|
hasNext | () | method |
public function hasNext():Boolean
Iterator
implementation which determines if
there are more tokens which have yet to be retrieved via
calls to nextToken
Boolean — true if more tokens remain, otherwise false
|
next | () | method |
public function next():*
Retrieves the next element in the StringTokenizer
instance
* — the next token based on the current position
|
nextElement | () | method |
public function nextElement():*
Retrieves the next token in the StringTokenizer
instance
* — the next token in the source String
|
nextToken | () | method |
public function nextToken():String
Retrieves the next token in the StringTokenizer
instance.
If the current position of the StringTokenizer
instance is greater than or equal to the length of the source
a null value is returned
String — the next token in the source String
|
position | () | method |
public function position():int
Determines the current position within the token
Returnsint — the current index of the token
|
remove | () | method |
public function remove():void
Remove must be implemented to provide a standard iterator implementation.
Typically this method would not provide an actual implementation as a concrete iterator is not to perform modifications, but rather simply provide a mechanism for iterating the object, thus being considered as read-only. Therefore concrete implementationx should throw an Exception
— |
reset | () | method |
public function reset():void
Resets the position of the StringTokenizer
to
zero