net.sf.latexdraw.parsers.svg.parsers
Class SVGNumberParser

java.lang.Object
  extended by net.sf.latexdraw.parsers.CodeParser
      extended by net.sf.latexdraw.parsers.svg.parsers.AbstractSVGParser
          extended by net.sf.latexdraw.parsers.svg.parsers.SVGNumberParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
SVGLengthParser, SVGPathParser

public class SVGNumberParser
extends AbstractSVGParser

Defines a SVG number parser.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

10/20/07

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
 
Fields inherited from class net.sf.latexdraw.parsers.CodeParser
codeCore, EOC
 
Constructor Summary
SVGNumberParser(java.lang.String code)
          The constructor.
 
Method Summary
protected  boolean isNumber(boolean unsigned)
           
 void parse()
          Launches the parsing.
 boolean parseFlag()
          Parses a flag (a boolean).
 double parseNumber(boolean unsigned)
          Parses a number (a double).
 java.lang.String parseNumberAsString(boolean unsigned)
          Parses a number (a double).
 
Methods inherited from class net.sf.latexdraw.parsers.svg.parsers.AbstractSVGParser
isComment, isWSP, skipComment, skipWSP, skipWSPComma
 
Methods inherited from class net.sf.latexdraw.parsers.CodeParser
getChar, getCharAt, getCode, getCodeCore, getLinePosition, getPosition, incLinePosition, initialise, isEOC, isEOL, nextChar, setCode, setCodeCore, setLinePosition, setPosition, skipWSPComments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGNumberParser

public SVGNumberParser(java.lang.String code)
The constructor.

Parameters:
code - The code to parse.
Method Detail

parseFlag

public boolean parseFlag()
                  throws java.text.ParseException
Parses a flag (a boolean).

Returns:
True or false.
Throws:
java.text.ParseException - If an error occurs.
Since:
0.1

parseNumberAsString

public java.lang.String parseNumberAsString(boolean unsigned)
                                     throws java.text.ParseException
Parses a number (a double).

Parameters:
unsigned - True: the parsed number must be unsigned.
Returns:
The parsed number as a string.
Throws:
java.text.ParseException - If an error occurs or if the parsed number is signed and unsigned is true.

parseNumber

public double parseNumber(boolean unsigned)
                   throws java.text.ParseException
Parses a number (a double).

Parameters:
unsigned - True: the parsed number must be unsigned.
Returns:
The parsed number.
Throws:
java.text.ParseException - If an error occurs or if the parsed number is signed and unsigned is true.

isNumber

protected boolean isNumber(boolean unsigned)
Parameters:
unsigned - True: the next number must not have a sign.
Returns:
True if the current character is the beginning of a number.

parse

public void parse()
           throws java.text.ParseException
Description copied from interface: Parser
Launches the parsing.

Throws:
java.text.ParseException - If an error occurs.