TinyLine
v2.0

com.tinyline.util
Class TinyUtils

java.lang.Object
  extended bycom.tinyline.util.TinyUtils

public final class TinyUtils
extends java.lang.Object

The TinyUtils class implements parsers with support for basic data types and objects.

Version:
2.1

Author:
Andrew Girow

Field Summary
static int num_error
          The error of the last parsing operation.
static int NUMBER_ERR_FORMAT
          The last parsing operation failed.
static int NUMBER_ERR_OK
          The last parsing operation passed OK.
 
Constructor Summary
TinyUtils()
           
 
Method Summary
 int[] parseDashArray(char[] r, int len)
          Parses dasharray of fixed point numbers from a list of comma-separated (with optional white space) lengths of alternating dashes and gaps.
static int parseDoubleFix(char[] buffer, int position, int count)
          Parses the content of the input buffer and converts it to a double fixed point number.
static int parseDoubleFix(TinyString str)
          Parses the content of the input string and converts it to a double fixed point number.
static int parseFix(char[] buffer, int position, int count)
          Parses the content of the input buffer and converts it to a fixed point number.
static int parseFix(TinyString str)
          Parses the content of the input string and converts it to a fixed point number.
static int parseInt(char[] buffer, int position, int endpos, int radix)
          Parses the content of the input buffer and converts it to an integer number.
static int parseInt(TinyString str)
          Parses the content of the input string and converts it to a integer number.
 TinyVector parseNumbers(char[] r, int len)
          Parses the list of numbers.
 TinyPath parsePath(char[] r, int len, boolean flag)
          Parses TinyPath object from a path data input buffer that contains the moveto, line, curve (both cubic and quadratic Béziers) and closepath instructions.
 TinyPoint parsePoint(char[] r, int len)
          Parses the TinyPoint value from a list of two numbers 'x' and 'y', separated by whitespace and/or a comma.
 TinyVector parsePoints(char[] r, int len)
          Parses TinyVector of TinyPont objects from a list of numbers 'x' and 'y', separated by whitespaces and/or a commas.
 TinyRect parseRect(char[] r, int len)
          Parses the TinyRect value from a list of four numbers 'x', 'y', 'width' and 'height', separated by whitespace and/or a comma.
 TinyColor parseRGB(char[] r, int len)
          Parses the input buffer into a TinyColor value using the functional notation.
 TinyPath parseSpline(char[] r, int len)
          Parses the spline path.
 TinyVector parseTransfroms(char[] r, int len)
          Parses TinyVector of TinyTransforms from a list of transform definitions, which are applied in the order provided.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_ERR_OK

public static final int NUMBER_ERR_OK
The last parsing operation passed OK.

See Also:
Constant Field Values

NUMBER_ERR_FORMAT

public static final int NUMBER_ERR_FORMAT
The last parsing operation failed. Wrong number format.

See Also:
Constant Field Values

num_error

public static int num_error
The error of the last parsing operation.

Constructor Detail

TinyUtils

public TinyUtils()
Method Detail

parseRGB

public TinyColor parseRGB(char[] r,
                          int len)
Parses the input buffer into a TinyColor value using the functional notation. For example, "255, 255, 255" or "100%,100%,100%" gives the white TinyColor value.

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyColor value or null.

parseRect

public TinyRect parseRect(char[] r,
                          int len)
Parses the TinyRect value from a list of four numbers 'x', 'y', 'width' and 'height', separated by whitespace and/or a comma. For example, " 0, 0, 250, 400"

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyRect object or null.

parsePoint

public TinyPoint parsePoint(char[] r,
                            int len)
Parses the TinyPoint value from a list of two numbers 'x' and 'y', separated by whitespace and/or a comma. For example, "100, 100".

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyRect object or null.

parsePoints

public TinyVector parsePoints(char[] r,
                              int len)
Parses TinyVector of TinyPont objects from a list of numbers 'x' and 'y', separated by whitespaces and/or a commas. For example, "350,75 379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161".

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyVector object or null.

parseDashArray

public int[] parseDashArray(char[] r,
                            int len)
Parses dasharray of fixed point numbers from a list of comma-separated (with optional white space) lengths of alternating dashes and gaps. For example, "5,3,2,5,3,2".

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The dasharray or null.

parseNumbers

public TinyVector parseNumbers(char[] r,
                               int len)
Parses the list of numbers. Parses a semicolon-separated list of number values


parseSpline

public TinyPath parseSpline(char[] r,
                            int len)
Parses the spline path. Parses a set of Bézier control points, defining a cubic Bézier function that controls interval pacing. The input buffer value is a semicolon separated list of control point descriptions. Each control point description is a set of four values: x1 y1 x2 y2, describing the Bézier control points for one segment.

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyPath object or null.

parsePath

public TinyPath parsePath(char[] r,
                          int len,
                          boolean flag)
Parses TinyPath object from a path data input buffer that contains the moveto, line, curve (both cubic and quadratic Béziers) and closepath instructions. For example, "M 100 100 L 300 100 L 200 300 z". . *

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
flag - The flag is true if the path data is a glyph outline.
Returns:
The TinyPath object or null.

parseTransfroms

public TinyVector parseTransfroms(char[] r,
                                  int len)
Parses TinyVector of TinyTransforms from a list of transform definitions, which are applied in the order provided. The individual transform definitions are separated by whitespace and/or a comma. For example, "translate(-10,-20) scale(2) rotate(45) translate(5,10)". . *

Parameters:
r - The input buffer.
len - The number of chars of the input buffer.
Returns:
The TinyVector object or null.

parseFix

public static final int parseFix(TinyString str)
Parses the content of the input string and converts it to a fixed point number.

Parameters:
str - The input string.
Returns:
The fixed point number. In the case of erroror returns 0 and sets the error into NUMBER_ERR_FORMAT.

parseDoubleFix

public static final int parseDoubleFix(TinyString str)
Parses the content of the input string and converts it to a double fixed point number.

Parameters:
str - The input string.
Returns:
The double fixed point number. In the case of erroror returns 0 and sets the error into NUMBER_ERR_FORMAT.

parseInt

public static final int parseInt(TinyString str)
Parses the content of the input string and converts it to a integer number.

Parameters:
str - The input string.
Returns:
The integer number. In the case of erroror returns 0 and sets the error into NUMBER_ERR_FORMAT.

parseFix

public static final int parseFix(char[] buffer,
                                 int position,
                                 int count)
Parses the content of the input buffer and converts it to a fixed point number.

Parameters:
buffer - The input buffer (not copied).
position - Offset of the first char of the input buffer.
count - Number of chars of the input buffer.
Returns:
The fixed point number. In the case of erroror returns 0 and sets the error into NUMBER_ERR_FORMAT.

parseDoubleFix

public static final int parseDoubleFix(char[] buffer,
                                       int position,
                                       int count)
Parses the content of the input buffer and converts it to a double fixed point number.

Parameters:
buffer - The input buffer (not copied).
position - Offset of the first char of the input buffer.
count - Number of chars of the input buffer.
Returns:
The double fixed point number. In the case of erroror returns 0 and sets the error into NUMBER_ERR_FORMAT.

parseInt

public static int parseInt(char[] buffer,
                           int position,
                           int endpos,
                           int radix)
Parses the content of the input buffer and converts it to an integer number.

Parameters:
buffer - The input buffer containing the integer representation to be parsed.
position - The (start) offset of the first char of the input buffer.
endpos - The end offset of the input buffer.
radix - the radix to be used while parsing s.
Returns:
The integer represented by the string argument in the specified radix. Returns 0 in the case of error and sets the error into NUMBER_ERR_FORMAT

TinyLine
v2.0

Provided under the terms of the TinyLine License Agreement that has been included with this distribution