long multiplier = 1;
long parsedMultiplier = 1;
  public Number parse (String str, ParsePosition pos)  {    /*     * Our strategy is simple: copy the text into separate buffers: one for the int part,     * one for the fraction part and for the exponential part.     * We translate or omit locale-specific information.       * If exponential is sufficiently big we merge the fraction and int part and     * remove the '.' and then we use Long to convert the number. In the other     * case, we use Double to convert the full number.     */		boolean is_neg = false;		int index = pos.getIndex();    StringBuffer int_buf = new StringBuffer ();    // We have to check both prefixes, because one might be empty.  We    // want to pick the longest prefix that matches.		boolean got_pos = str.startsWith(positivePrefix, index);    String np = (negativePrefix != null		 ? negativePrefix		 : positivePrefix + symbols.getMinusSign());		boolean got_neg = str.startsWith(np, index);    if (got_pos && got_neg)      {			// By checking this way, we preserve ambiguity in the case			// where the negative format differs only in suffix.  We			// check this again later.	if (np.length() > positivePrefix.length())	  {				is_neg = true;				index += np.length();	  }	else				index += positivePrefix.length();      }    else if (got_neg)      {			is_neg = true;			index += np.length();      }    else if (got_pos)			index += positivePrefix.length();    else      {	pos.setErrorIndex (index);			return null;		}		// FIXME: handle Inf and NaN.    // FIXME: do we have to respect minimum digits?    // What about multiplier?    StringBuffer buf = int_buf;    StringBuffer frac_buf = null;    StringBuffer exp_buf = null;		int start_index = index;		int max = str.length();    int exp_index = -1;    int last = index + maximumIntegerDigits;     if (maximumFractionDigits > 0)      last += maximumFractionDigits + 1;        if (useExponentialNotation)      last += minExponentDigits + 1;    if (last > 0 && max > last)      max = last;		char zero = symbols.getZeroDigit();		int last_group = -1;		boolean int_part = true;		boolean exp_part = false;    for (; index < max; ++index)      {			char c = str.charAt(index);			// FIXME: what about grouping size?	if (groupingUsed && c == symbols.getGroupingSeparator())	  {	    if (last_group != -1 		&& groupingSize != 0  		&& (index - last_group) % groupingSize != 0)	      {					pos.setErrorIndex(index);					return null;				}	    last_group = index+1;	  }	else if (c >= zero && c <= zero + 9)	  {				buf.append((char) (c - zero + '0'));	  }	else if (parseIntegerOnly)				break;	else if (c == symbols.getDecimalSeparator())	  {	    if (last_group != -1 		&& groupingSize != 0 		&& (index - last_group) % groupingSize != 0)	      {					pos.setErrorIndex(index);					return null;				}	    buf = frac_buf = new StringBuffer();	    frac_buf.append('.');				int_part = false;	  }	else if (c == symbols.getExponential())	  {	    buf = exp_buf = new StringBuffer();				int_part = false;				exp_part = true;	    exp_index = index+1;	  }	else if (exp_part		 && (c == '+' || c == '-' || c == symbols.getMinusSign()))	  {				// For exponential notation.				buf.append(c);	  }	else				break;		}    if (index == start_index)      {			// Didn't see any digits.			pos.setErrorIndex(index);			return null;		}		// Check the suffix.  We must do this before converting the		// buffer to a number to handle the case of a number which is		// the most negative Long.		boolean got_pos_suf = str.startsWith(positiveSuffix, index);		String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix);		boolean got_neg_suf = str.startsWith(ns, index);    if (is_neg)      {	if (! got_neg_suf)	  {				pos.setErrorIndex(index);				return null;			}      }    else if (got_pos && got_neg && got_neg_suf)      {			is_neg = true;      }    else if (got_pos != got_pos_suf && got_neg != got_neg_suf)      {			pos.setErrorIndex(index);			return null;		}		String suffix = is_neg ? ns : positiveSuffix;    long multiplier = 1;    boolean use_long;		if (is_neg)      int_buf.insert(0, '-');    // Now handle the exponential part if there is one.    if (exp_buf != null)      {	int exponent_value;	try	  {	    exponent_value = Integer.parseInt(exp_buf.toString());	  }	catch (NumberFormatException x1)	  {	    pos.setErrorIndex(exp_index);	    return null;	  }	if (frac_buf == null)	  {	    // We only have to add some zeros to the int part.	    // Build a multiplier.	    for (int i = 0; i < exponent_value; i++)	      int_buf.append('0');	    	    use_long = true;	  }	else	  {	    boolean long_sufficient;	    if (exponent_value < frac_buf.length()-1)	      {		int lastNonNull = -1;		/* We have to check the fraction buffer: it may only be full of '0'		 * or be sufficiently filled with it to convert the number into Long.		 */		for (int i = 1; i < frac_buf.length(); i++)		  if (frac_buf.charAt(i) != '0')		    lastNonNull = i;		long_sufficient = (lastNonNull < 0 || lastNonNull <= exponent_value);	      }	    else	      long_sufficient = true;	    	    if (long_sufficient)	      {		for (int i = 1; i < frac_buf.length() && i < exponent_value; i++)		  int_buf.append(frac_buf.charAt(i));		for (int i = frac_buf.length()-1; i < exponent_value; i++)		  int_buf.append('0');		use_long = true;	      }	    else	      {		/*		 * A long type is not sufficient, we build the full buffer to		 * be parsed by Double.		 */		int_buf.append(frac_buf);		int_buf.append('E');		int_buf.append(exp_buf);		use_long = false;	      }	  }      }    else      {	if (frac_buf != null)	  {	    /* Check whether the fraction buffer contains only '0' */	    int i;	    for (i = 1; i < frac_buf.length(); i++)	      if (frac_buf.charAt(i) != '0')		break;	   	    if (i != frac_buf.length())	      {		use_long = false;		int_buf.append(frac_buf);	      }	    else	      use_long = true;	  }	else	  use_long = true;      }    String t = int_buf.toString();		Number result = null;    if (use_long)      {	try	  {	    result = new Long (t);	  }	catch (NumberFormatException x1)	  {	  }      }    else      {	try	  {	    result = new Double (t);			}	catch (NumberFormatException x2)	  {		}      }    if (result == null)      {			pos.setErrorIndex(index);			return null;		}		pos.setIndex(index + suffix.length());		return result;	}