FileDocCategorySizeDatePackage
NumberListParser.javaAPI DocphoneME MR2 API (J2ME)3151Wed May 02 18:00:36 BST 2007com.sun.perseus.parser

NumberListParser

public class NumberListParser extends NumberParser
The NumberListParser class converts attributes conforming to the SVG Tiny definition of coordinate or number list (see Basic Data Types)..
version
$Id: NumberListParser.java,v 1.2 2006/04/21 06:40:19 st125089 Exp $

Fields Summary
Constructors Summary
Methods Summary
public float[]parseNumberList(java.lang.String listStr, char sep)

param
listStr the string containing the list of numbers
param
sep the separator between number values
return
An array of numbers

        setString(listStr);

        current = read();
        skipSpaces();
        
        boolean requireMore = false;
        float[] numbers = null;
        int cur = 0;
        for (;;) {
            if (current != -1) {
                float v = parseNumber(false);
                if (numbers == null) {
                    numbers = new float[1];
                } else if (numbers.length <= cur) {
                    float[] tmpNumbers = new float[numbers.length * 2];
                    System.arraycopy(numbers, 0, tmpNumbers, 0, numbers.length);
                    numbers = tmpNumbers;
                }
                numbers[cur++] = v;
            } else {
                if (!requireMore) {
                    break;
                } else {
                    throw new IllegalArgumentException();
                }
            }
            skipSpaces();
            requireMore = (current == sep);
            skipSepSpaces(sep);
        }
      
        if (numbers != null && cur != numbers.length) {
            float[] tmpNumbers = new float[cur];
            System.arraycopy(numbers, 0, tmpNumbers, 0, cur);
            numbers = tmpNumbers;
        }

        return numbers;
    
public float[]parseNumberList(java.lang.String listStr)

param
listStr the string containing the list of numbers
return
An array of numbers

        return parseNumberList(listStr, ',");