You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2003/12/11 21:06:03 UTC
cvs commit: xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common InvalidLexicalValueException.java XsTypeConverter.java
cezar 2003/12/11 12:06:03
Modified: v2/src/common/org/apache/xmlbeans/impl/common
InvalidLexicalValueException.java
XsTypeConverter.java
Log:
- added white space style methods for StringValue in the XMLStreamReaderExt interface.
- added Location info in the InvalidLexicalValueException
- catch limit cases in numerals parsing
CR: David Bau + info from Scott
DRT: passing
Revision Changes Path
1.2 +88 -0 xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java
Index: InvalidLexicalValueException.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InvalidLexicalValueException.java 2 Dec 2003 22:48:21 -0000 1.1
+++ InvalidLexicalValueException.java 11 Dec 2003 20:06:02 -0000 1.2
@@ -1,5 +1,63 @@
+/*
+* The Apache Software License, Version 1.1
+*
+*
+* Copyright (c) 2003 The Apache Software Foundation. All rights
+* reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by the
+* Apache Software Foundation (http://www.apache.org/)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Apache" and "Apache Software Foundation" must
+* not be used to endorse or promote products derived from this
+* software without prior written permission. For written
+* permission, please contact apache@apache.org.
+*
+* 5. Products derived from this software may not be called "Apache
+* XMLBeans", nor may "Apache" appear in their name, without prior
+* written permission of the Apache Software Foundation.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*
+* This software consists of voluntary contributions made by many
+* individuals on behalf of the Apache Software Foundation and was
+* originally based on software copyright (c) 2000-2003 BEA Systems
+* Inc., <http://www.bea.com/>. For more information on the Apache Software
+* Foundation, please see <http://www.apache.org/>.
+*/
+
package org.apache.xmlbeans.impl.common;
+import javax.xml.stream.Location;
+
/**
* Author: Cezar Andrei (cezar.andrei at bea.com)
* Date: Nov 24, 2003
@@ -7,6 +65,8 @@
public class InvalidLexicalValueException
extends RuntimeException
{
+ private Location _location;
+
public InvalidLexicalValueException()
{
super();
@@ -25,5 +85,33 @@
public InvalidLexicalValueException(Throwable cause)
{
super(cause);
+ }
+
+ public InvalidLexicalValueException(String msg, Location location)
+ {
+ super(msg);
+ setLocation(location);
+ }
+
+ public InvalidLexicalValueException(String msg, Throwable cause, Location location)
+ {
+ super(msg, cause);
+ setLocation(location);
+ }
+
+ public InvalidLexicalValueException(Throwable cause, Location location)
+ {
+ super(cause);
+ setLocation(location);
+ }
+
+ public Location getLocation()
+ {
+ return _location;
+ }
+
+ public void setLocation(Location location)
+ {
+ this._location = location;
}
}
1.5 +20 -0 xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/XsTypeConverter.java
Index: XsTypeConverter.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/XsTypeConverter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XsTypeConverter.java 2 Dec 2003 22:48:21 -0000 1.4
+++ XsTypeConverter.java 11 Dec 2003 20:06:02 -0000 1.5
@@ -85,6 +85,15 @@
//current jdk impl of parseFloat calls trim() on the string.
//Any other space is illegal anyway, whether there are one or more spaces.
//so no need to do a collapse pass through the string.
+ if (cs.length()>0)
+ {
+ char ch = cs.charAt(cs.length()-1);
+ if (ch=='f' || ch=='F')
+ {
+ if (cs.charAt(cs.length()-2)!='N')
+ throw new NumberFormatException("Invalid char '" + ch + "' in float.");
+ }
+ }
return Float.parseFloat(v);
}
catch (NumberFormatException e) {
@@ -132,6 +141,12 @@
//current jdk impl of parseDouble calls trim() on the string.
//Any other space is illegal anyway, whether there are one or more spaces.
//so no need to do a collapse pass through the string.
+ if (cs.length()>0)
+ {
+ char ch = cs.charAt(cs.length()-1);
+ if (ch=='d' || ch=='D')
+ throw new NumberFormatException("Invalid char '" + ch + "' in double.");
+ }
return Double.parseDouble(v);
}
catch (NumberFormatException e) {
@@ -205,6 +220,11 @@
public static BigInteger lexInteger(CharSequence cs)
throws NumberFormatException
{
+ if (cs.length()>1)
+ {
+ if (cs.charAt(0)=='+' && cs.charAt(1)=='-')
+ throw new NumberFormatException("Illegal char sequence '+-'");
+ }
final String v = cs.toString();
//TODO: consider special casing zero and one to return static values
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org