org.cip4.jdflib.util
Class SScanf

java.lang.Object
  extended by java.io.Reader
      extended by org.cip4.jdflib.cformat.ScanfReader
          extended by org.cip4.jdflib.util.SScanf
All Implemented Interfaces:
Closeable, Readable, Iterator<Object>

public class SScanf
extends ScanfReader
implements Iterator<Object>

Author:
prosirai

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
SScanf(String theString, String format)
          creates a scanf reader for a given string and format and returns the approriate object valid format identifiers %f - returns Double %i - returns Integer %d - returns Integer %x - returns Integer %o - returns Integer %c - returns String %s - returns String
 
Method Summary
 boolean hasNext()
           
 Object next()
          returns the next Object (@see the constructor), null if the string has been completely parsed or an invalid format is scanned
 void remove()
          NOT IMPLEMENTED - the iterator is only forward
 double scanDouble(ScanfFormat fmt)
          Scan and return a double, using a pre-allocated ScanfFormat object.
 String scanString(ScanfFormat fmt)
          Scan and return a String, using a pre-allocated ScanfFormat object.
 Vector<Object> sscanf()
          scan a string using C++ sscanf functionality
static Vector<Object> sscanf(String theString, String format)
          convenience static function - see the constructor for details
 
Methods inherited from class org.cip4.jdflib.cformat.ScanfReader
clearLookAheadChar, close, getCharNumber, getLineNumber, getLookAheadChar, lookAheadCharValid, read, scanChar, scanChar, scanChar, scanChars, scanChars, scanChars, scanDec, scanDec, scanDec, scanDouble, scanDouble, scanFloat, scanFloat, scanFloat, scanHex, scanHex, scanHex, scanInt, scanInt, scanInt, scanLong, scanLong, scanLong, scanOct, scanOct, scanOct, scanString, scanString, setCharNumber, setLineNumber, useCstandard, useCstandard
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SScanf

public SScanf(String theString,
              String format)
creates a scanf reader for a given string and format and returns the approriate object valid format identifiers %f - returns Double %i - returns Integer %d - returns Integer %x - returns Integer %o - returns Integer %c - returns String %s - returns String

Parameters:
theString - the String to scan
format - the formatting String to apply according to c++ sscanf rools
Method Detail

sscanf

public Vector<Object> sscanf()
scan a string using C++ sscanf functionality

Returns:

scanDouble

public double scanDouble(ScanfFormat fmt)
                  throws IOException,
                         ScanfMatchException,
                         IllegalArgumentException
Description copied from class: ScanfReader
Scan and return a double, using a pre-allocated ScanfFormat object. This saves the overhead of parsing the format from a string.

Overrides:
scanDouble in class ScanfReader
Parameters:
fmt - Format object
Returns:
Scanned double value
Throws:
ScanfMatchException - Input did not match format
EOFException - End of file
IOException - Other input error
IllegalArgumentException - Error in format specification
See Also:
org.cip4.jdflib.cformat.ScanfReader#scanDouble(org.cip4.jdflib.cformat .ScanfFormat)

scanString

public String scanString(ScanfFormat fmt)
                  throws IOException,
                         IllegalArgumentException
Description copied from class: ScanfReader
Scan and return a String, using a pre-allocated ScanfFormat object. This saves the overhead of parsing the format from a string.

Overrides:
scanString in class ScanfReader
Parameters:
fmt - Format object
Returns:
Scanned String
Throws:
ScanfMatchException - Input did not match format
EOFException - End of file
IOException - Other input error
IllegalArgumentException - Error in format specification
See Also:
org.cip4.jdflib.cformat.ScanfReader#scanString(org.cip4.jdflib.cformat .ScanfFormat)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Object>
See Also:
Iterator.hasNext()

next

public Object next()
returns the next Object (@see the constructor), null if the string has been completely parsed or an invalid format is scanned

Specified by:
next in interface Iterator<Object>

remove

public void remove()
NOT IMPLEMENTED - the iterator is only forward

Specified by:
remove in interface Iterator<Object>
See Also:
Iterator.remove()

sscanf

public static Vector<Object> sscanf(String theString,
                                    String format)
convenience static function - see the constructor for details

Parameters:
theString -
format -
Returns:
Vector of scanned objects - see constructor for details


Copyright © 2013. All Rights Reserved.