Package java.text

Examples of java.text.ParsePosition


     * @throws MathParseException if the beginning of the specified string
     * cannot be parsed.
     */
    @Override
    public Vector3D parse(final String source) {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector3D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector3D.class);
        }
        return result;
    }
View Full Code Here


    }

    /** {@inheritDoc} */
    @Override
    public Vector2D parse(final String source) {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector2D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector2D.class);
        }
        return result;
    }
View Full Code Here

     * @return the parsed {@link Complex} object.
     * @throws MathParseException if the beginning of the specified string
     * cannot be parsed.
     */
    public Complex parse(String source) {
        ParsePosition parsePosition = new ParsePosition(0);
        Complex result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Complex.class);
        }
        return result;
    }
View Full Code Here

     * @return the parsed {@link RealVector} object.
     * @throws MathParseException if the beginning of the specified string
     * cannot be parsed.
     */
    public ArrayRealVector parse(String source) {
        final ParsePosition parsePosition = new ParsePosition(0);
        final ArrayRealVector result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         ArrayRealVector.class);
        }
        return result;
    }
View Full Code Here

     * @exception MathParseException if the beginning of the specified string
     *            cannot be parsed.
     */
    @Override
    public BigFraction parse(final String source) throws MathParseException {
        final ParsePosition parsePosition = new ParsePosition(0);
        final BigFraction result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source, parsePosition.getErrorIndex(), BigFraction.class);
        }
        return result;
    }
View Full Code Here

     * @exception MathParseException if the beginning of the specified string
     *            cannot be parsed.
     */
    @Override
    public Fraction parse(final String source) throws MathParseException {
        final ParsePosition parsePosition = new ParsePosition(0);
        final Fraction result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source, parsePosition.getErrorIndex(), Fraction.class);
        }
        return result;
    }
View Full Code Here

      value = value.replace('\u00a0', ' ');
     
      changed = true;
    }
   
    ParsePosition pp = new ParsePosition(0)
    Number num = (Number)fmt.parseObject(value, pp);  
   
    // The following determines whether the percent/currency symbol was left off.
    int typeIdx = _getType(pattern, type);
    if (num == null && (typeIdx == _CURRENCY_TYPE || typeIdx == _PERCENT_TYPE))
    {
      // For parsing 'value' as a Number when the percent/currency symbol is left off.
      NumberFormat nfmt = NumberFormat.getNumberInstance(locale);
      DecimalFormat ndf = (DecimalFormat)nfmt;
      ndf.setParseBigDecimal(true); // TODO What does this do?
      DecimalFormatSymbols ndfs = null;
     
      if (changed)
      {
        ndfs = ndf.getDecimalFormatSymbols();
        ndfs.setGroupingSeparator(' ');
        ndf.setDecimalFormatSymbols(ndfs);
      }
     
      // Assume the percent/currency symbol was left off, in which case we should
      // be able to parse 'value' as a Number.
      // An error occured, so the index of pp should still be 0.
      num = (Number)nfmt.parseObject(value, pp);     
      if (typeIdx == _PERCENT_TYPE && num != null)
        num = num.doubleValue() / 100.0;
    }
   
    // Change it back, since we could have been handed a cached reference. This
    // may not be thread-safe, but it probably doesn't have to be.
    if (changed)
    {
      dfs.setGroupingSeparator('\u00a0');
      df.setDecimalFormatSymbols(dfs);
    }

    if (pp.getIndex() != value.length())
    {
      // According to the comments in
      // trinidad-api\src\main\xrts\org\apache\myfaces\trinidad\resource\MessageBundle.xrts,
      // the substitution parameters are supposed to be:
      // {0} the label that identifies the component
View Full Code Here

     * @throws MathParseException if the beginning of the specified string
     * cannot be parsed.
     */
    @Override
    public Vector3D parse(final String source) throws MathParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector3D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector3D.class);
        }
        return result;
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override
    public Vector1D parse(final String source) throws MathParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector1D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector1D.class);
        }
        return result;
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override
    public Vector2D parse(final String source) throws MathParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector2D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector2D.class);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of java.text.ParsePosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.