예제 #1
0
 /// <summary>
 /// Parse String with given pattern on ParsePosition to Data object
 /// </summary>
 /// <param name="s"></param>
 /// <param name="pos"></param>
 /// <returns></returns>
 public java.util.Date parse(String s, ParsePosition pos)
 {
     DateTime date = DateTime.ParseExact(s.substring(pos.getIndex()), pattern, CultureInfo.InvariantCulture);
     return new java.util.Date(date.getTime());
 }
예제 #2
0
파일: Format.cs 프로젝트: sailesh341/JavApi
 /*
  * Gets private field value by reflection.
  *
  * @param fieldName the field name to be set @param target the object which
  * field to be gotten
  *
 internal static Object getInternalField(String fieldName, Object target) {
     Object value = AccessController
             .doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
                     Object result = null;
                     java.lang.reflect.Field field = null;
                     try {
                         field = target.getClass().getDeclaredField(
                                 fieldName);
                         field.setAccessible(true);
                         result = field.get(target);
                     } catch (Exception e1) {
                         return null;
                     }
                     return result;
                 }
             });
     return value;
 }*/
 protected internal static bool upTo(String s, ParsePosition position,
         java.lang.StringBuffer buffer, char stop)
 {
     int index = position.getIndex(), length = s.length();
     bool lastQuote = false, quote = false;
     while (index < length) {
         char ch = s.charAt(index++);
         if (ch == '\'') {
             if (lastQuote) {
                 buffer.append('\'');
             }
             quote = !quote;
             lastQuote = true;
         } else if (ch == stop && !quote) {
             position.setIndex(index);
             return true;
         } else {
             lastQuote = false;
             buffer.append(ch);
         }
     }
     position.setIndex(index);
     return false;
 }
예제 #3
0
파일: Format.cs 프로젝트: sailesh341/JavApi
 protected internal static bool upToWithQuotes(String s, ParsePosition position,
         java.lang.StringBuffer buffer, char stop, char start)
 {
     int index = position.getIndex(), length = s.length(), count = 1;
     bool quote = false;
     while (index < length) {
         char ch = s.charAt(index++);
         if (ch == '\'') {
             quote = !quote;
         }
         if (!quote) {
             if (ch == stop) {
                 count--;
             }
             if (count == 0) {
                 position.setIndex(index);
                 return true;
             }
             if (ch == start) {
                 count++;
             }
         }
         buffer.append(ch);
     }
     // text.07=Unmatched braces in the pattern
     throw new java.lang.IllegalArgumentException("Unmatched braces in the pattern"); //$NON-NLS-1$
 }
예제 #4
0
파일: Format.cs 프로젝트: sailesh341/JavApi
 /**
  * Parses the specified string starting at the index specified by
  * {@code position}. If the string is successfully parsed then the index of
  * the {@code ParsePosition} is updated to the index following the parsed
  * text. On error, the index is unchanged and the error index of
  * {@code ParsePosition} is set to the index where the error occurred.
  *
  * @param string
  *            the string to parse.
  * @param position
  *            input/output parameter, specifies the start index in
  *            {@code string} from where to start parsing. If parsing is
  *            successful, it is updated with the index following the parsed
  *            text; on error, the index is unchanged and the error index is
  *            set to the index where the error occurred.
  * @return the object resulting from the parse or {@code null} if there is
  *         an error.
  */
 public abstract Object parseObject(String s, ParsePosition position);
예제 #5
0
파일: Format.cs 프로젝트: sailesh341/JavApi
 /**
  * Parses the specified string using the rules of this format.
  *
  * @param string
  *            the string to parse.
  * @return the object resulting from the parse.
  * @throws ParseException
  *            if an error occurs during parsing.
  */
 public Object parseObject(String s)
 {
     //throws ParseException {
     ParsePosition position = new ParsePosition(0);
     Object result = parseObject(s, position);
     if (position.getIndex() == 0) {
         // text.1C=Format.parseObject(String) parse failure
         throw new ParseException("Format.parseObject(String) parse failure", position.getErrorIndex()); //$NON-NLS-1$
     }
     return result;
 }
예제 #6
0
        /// <summary>
        /// Parse String with given pattern on ParsePosition to Data object
        /// </summary>
        /// <param name="s"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public java.util.Date parse(String s, ParsePosition pos)
        {
            DateTime date = DateTime.ParseExact(s.substring(pos.getIndex()), pattern, CultureInfo.InvariantCulture);

            return(new java.util.Date(date.getTime()));
        }
예제 #7
0
 public override Object parseObject(String s, ParsePosition position)
 {
     throw new java.lang.UnsupportedOperationException("Not yet implemented");
 }
예제 #8
0
파일: Format.cs 프로젝트: minam365/JavApi
 /*
  * Parses the specified string starting at the index specified by
  * {@code position}. If the string is successfully parsed then the index of
  * the {@code ParsePosition} is updated to the index following the parsed
  * text. On error, the index is unchanged and the error index of
  * {@code ParsePosition} is set to the index where the error occurred.
  *
  * @param string
  *            the string to parse.
  * @param position
  *            input/output parameter, specifies the start index in
  *            {@code string} from where to start parsing. If parsing is
  *            successful, it is updated with the index following the parsed
  *            text; on error, the index is unchanged and the error index is
  *            set to the index where the error occurred.
  * @return the object resulting from the parse or {@code null} if there is
  *         an error.
  */
 public abstract Object parseObject(String s, ParsePosition position);