/// <summary> /// Parse a Double from the specified String starting at the index specified /// by the ParsePosition. The String is compared to the strings of this /// ChoiceFormat and if a match occurs, the answer is the lower bound of the /// corresponding range. If the string is successfully parsed, the index of /// the ParsePosition is updated to the index following the parsed text. /// </summary> /// /// <param name="string">the String to parse</param> /// <param name="position">the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred</param> /// <returns>a Double resulting from the parse, or Double.NaN if there is an /// error</returns> public override object Parse(String str0, ParsePosition position) { int offset = position.GetIndex(); for (int i = 0; i < choiceFormats.Length; i++) { if (ILOG.J2CsMapping.Util.StringUtil.StartsWith(str0, choiceFormats[i], offset)) { position.SetIndex(offset + choiceFormats[i].Length); return((double)(choiceLimits[i])); } } position.SetErrorIndex(offset); return((double)(System.Double.NaN)); }
/// <summary> /// Parse the message argument from the specified String starting at the /// index specified by the ParsePosition. If the string is successfully /// parsed, the index of the ParsePosition is updated to the index following /// the parsed text. /// </summary> /// /// <param name="string">the String to parse</param> /// <param name="position">the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred</param> /// <returns>the array of Object arguments resulting from the parse, or null /// if there is an error</returns> public Object[] Parse(String str0, ParsePosition position) { if (str0 == null) { return(new Object[0]); } ParsePosition internalPos = new ParsePosition(0); int offset = position.GetIndex(); Object[] result = new Object[maxArgumentIndex + 1]; for (int i = 0; i <= maxOffset; i++) { String sub = strings[i]; if (!ILOG.J2CsMapping.Util.StringUtil.StartsWith(str0, sub, offset)) { position.SetErrorIndex(offset); return(null); } offset += sub.Length; Object parse; Format format = formats[i]; if (format == null) { if (i + 1 < strings.Length) { int next = ILOG.J2CsMapping.Util.StringUtil.IndexOf(str0, strings[i + 1], offset); if (next == -1) { position.SetErrorIndex(offset); return(null); } parse = str0.Substring(offset, (next) - (offset)); offset = next; } else { parse = str0.Substring(offset); offset = str0.Length; } } else { internalPos.SetIndex(offset); parse = format.ParseObject(str0, internalPos); if (internalPos.GetErrorIndex() != -1) { position.SetErrorIndex(offset); return(null); } offset = internalPos.GetIndex(); } result[argumentNumbers[i]] = parse; } if (maxOffset + 1 < strings.Length) { String sub_0 = strings[maxOffset + 1]; if (!ILOG.J2CsMapping.Util.StringUtil.StartsWith(str0, sub_0, offset)) { position.SetErrorIndex(offset); return(null); } offset += sub_0.Length; } position.SetIndex(offset); return(result); }