org.apache.xerces.impl.validation.datatypes.eTypes.Data.Number
Class mNumber

java.lang.Object
  |
  +--org.apache.xerces.impl.validation.datatypes.eTypes.Models.AbstractProperty
        |
        +--org.apache.xerces.impl.validation.datatypes.eTypes.Models.PartialOrder
              |
              +--org.apache.xerces.impl.validation.datatypes.eTypes.Data.Number.mNumber

public class mNumber
extends PartialOrder
implements StringProperty

This is the basic class for determining whether strings which represent numbers. obey certain syntactic constraints. The constraints are very close to the 'usual' definitions. They differ from XML definitions in that an XML Schema integer can contain a decimal point while mInteger cannot and an XML float (or double) need not contain a decimal or scientific notation, while mFloat and mDouble must have both. In addition, arbitrary length or precision numbers are not supported. However, they have been selected so that the string being validated can be reconstructed from the value and the properties: signed, fixed, integral, precision, scale. We supply 4 properites: 1) mInteger - does not have a decimal point and does not use scientific notation 2) mFixed - a number with a decimal point and without scientific notation 3) mFloat, mDouble - numbers written with a decimal point and scientific notation 4) mNumber - validates any of the above. Note 123e4 does not currently validate. Note that since the subProp's introduced here are immutable, setTwin is not overriden.

Version:
$Id: mNumber.java,v 1.1.2.1 2000/10/28 00:04:42 jeffreyr Exp $
Author:
Leonard C. Berman, Jeffrey Rodriguez

Inner classes inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Models.AbstractProperty
AbstractProperty.AbstractSummary
 
Field Summary
static int classNumberSubProperties
           
static int FIXED
           
static int INTEGRAL
           
static java.lang.reflect.Method isFixed
           
static java.lang.reflect.Method isIntegral
           
static java.lang.reflect.Method isSigned
           
static java.lang.reflect.Method precision
           
static int PRECISION
           
static java.lang.reflect.Method scale
           
static int SCALE
           
static int SIGNED
          constraint on the 'SIGNED'
subProp == true ==>> all numbers must have sign
subProp == false ==>> no numbers may have sign
 
Fields inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Models.PartialOrder
classNumberSubProperties, CLOSED_ABOVE, CLOSED_BELOW, MAX, MIN
 
Fields inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Models.AbstractProperty
classNumberSubProperties, ht, required
 
Fields inherited from interface org.apache.xerces.impl.validation.datatypes.eTypes.Interfaces.StringProperty
classNumberSubProperties, MAX_LEN, MIN_LEN, PATTERN
 
Constructor Summary
mNumber(java.lang.Number num)
           
mNumber(java.lang.String name)
           
 
Method Summary
 java.lang.Integer compareTo(java.lang.Object right)
          Returns false if this and right are not from the same class.
 void enableSubProp(java.lang.String name)
          The next method is included to remind developer's that they are responsible for setting the eval and merge functions for subProp's for classes which they define.
 java.lang.Number getValue()
           
static java.lang.Boolean isFixed(java.lang.Object obj, java.lang.Object constraint)
          Returns true if (a) matches decodeNonIntegerRE and (2) at least one digit must be present before or after the decimal point
static java.lang.Boolean isIntegral(java.lang.Object obj, java.lang.Object constraint)
           
static java.lang.Boolean isSigned(java.lang.Object obj, java.lang.Object constraint)
           
static void main(java.lang.String[] args)
           
static java.lang.Integer precision(java.lang.Object obj, java.lang.Object constraint)
          Note: does not verify that obj is a properly formatted number, merely that the part which matches decodeNonIntegerRE has proper form.
 void requireFixed(boolean newFixed)
           
 void requireIntegral(boolean newIntegral)
           
 void requireSigned(java.lang.Boolean newSigned)
           
static java.lang.Integer scale(java.lang.Object obj, java.lang.Object constraint)
          Note: does not verify that obj is a properly formatted number, merely that the part which matches decodeNonIntegerRE has proper form.
 boolean validate(java.lang.Object obj)
          Determines whether the string meets the syntactic requirements expressed through the fields: fixed, integral, signed, precision, and scale.
 boolean validate(java.lang.String str)
          Determines whether the string meets the syntactic requirements expressed through the fields: fixed, integral, signed, precision, and scale.
 
Methods inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Models.PartialOrder
getBound, getClosed, glb, gt, isBounded, isClosed, lt, lub, merge, merge, setBound, setClosed
 
Methods inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Models.AbstractProperty
accumulate, add2Report, clone, getJClass, getName, getPossible, getReport, getSubProp, getSubPropEval, getSubPropMerge, getSubPropName, getSubPropNameIndex, merge, msg, resetAccumulator, resetConstraint, resetInstance, setJClass, setName, setPossible, setRequired, setSubProp, setSubProp, setSubPropEval, setSubPropMerge, setSubPropName, toString, twin
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIXED

public static final int FIXED

INTEGRAL

public static final int INTEGRAL

PRECISION

public static final int PRECISION

SCALE

public static final int SCALE

SIGNED

public static final int SIGNED
constraint on the 'SIGNED'
subProp == true ==>> all numbers must have sign
subProp == false ==>> no numbers may have sign

classNumberSubProperties

public static final int classNumberSubProperties

isFixed

public static final java.lang.reflect.Method isFixed

isSigned

public static final java.lang.reflect.Method isSigned

isIntegral

public static final java.lang.reflect.Method isIntegral

scale

public static final java.lang.reflect.Method scale

precision

public static final java.lang.reflect.Method precision
Constructor Detail

mNumber

public mNumber(java.lang.Number num)

mNumber

public mNumber(java.lang.String name)
Method Detail

compareTo

public java.lang.Integer compareTo(java.lang.Object right)
Returns false if this and right are not from the same class. Note that this may not be what is expected. Also, the current implementation only compares to the precision of Double.
Overrides:
compareTo in class PartialOrder
Tags copied from interface: PO_IF
Parameters:
other - com.ibm.eTypes.Interfaces.PO_IF
Returns:
java.lang.Integer

enableSubProp

public void enableSubProp(java.lang.String name)
Description copied from class: AbstractProperty
The next method is included to remind developer's that they are responsible for setting the eval and merge functions for subProp's for classes which they define.
Overrides:
enableSubProp in class AbstractProperty

getValue

public final java.lang.Number getValue()

isFixed

public static final java.lang.Boolean isFixed(java.lang.Object obj,
                                              java.lang.Object constraint)
Returns true if (a) matches decodeNonIntegerRE and (2) at least one digit must be present before or after the decimal point

isIntegral

public static final java.lang.Boolean isIntegral(java.lang.Object obj,
                                                 java.lang.Object constraint)
Returns:
true if obj is a String of one or more digits

isSigned

public static final java.lang.Boolean isSigned(java.lang.Object obj,
                                               java.lang.Object constraint)
Returns:
true if first character of String is '+' or '-'

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException

precision

public static final java.lang.Integer precision(java.lang.Object obj,
                                                java.lang.Object constraint)
Note: does not verify that obj is a properly formatted number, merely that the part which matches decodeNonIntegerRE has proper form.
Parameters:
constraint - should be a java.lang.Number
Returns:
number of decimal digits in obj or null if this number is greater than constraint

requireFixed

public void requireFixed(boolean newFixed)
Parameters:
newFixed. - If true, number must contain a decimal point and no non-digits except and optional leading sign

requireIntegral

public void requireIntegral(boolean newIntegral)

requireSigned

public void requireSigned(java.lang.Boolean newSigned)

scale

public static final java.lang.Integer scale(java.lang.Object obj,
                                            java.lang.Object constraint)
Note: does not verify that obj is a properly formatted number, merely that the part which matches decodeNonIntegerRE has proper form.
Parameters:
constraint - should be a java.lang.Number
Returns:
number of decimal digits in fractional part of obj or null if precision > constraint

validate

public boolean validate(java.lang.Object obj)
Determines whether the string meets the syntactic requirements expressed through the fields: fixed, integral, signed, precision, and scale. On return, the values of these fields have been set to the numbers appropriate to the string. THEREFORE, if validate is called again, reset() should be called unless you want to know whether the second argument has the same syntactic restrictions as the first.
Overrides:
validate in class AbstractProperty

validate

public boolean validate(java.lang.String str)
Determines whether the string meets the syntactic requirements expressed through the fields: fixed, integral, signed, precision, and scale. On return, the values of these fields have been set to the numbers appropriate to the string. THEREFORE, if validate is called again, reset() should be called unless you want to know whether the second argument has the same syntactic restrictions as the first.


Copyright © 1999-2001 Apache XML Project. All Rights Reserved.