Refine search
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { for (int idx = 0; idx < formatField.length(); ++idx) { final int sIdx = idx + pos.getIndex(); if (sIdx == source.length()) { pos.setErrorIndex(sIdx); return false; } if (formatField.charAt(idx) != source.charAt(sIdx)) { pos.setErrorIndex(sIdx); return false; } } pos.setIndex(formatField.length() + pos.getIndex()); return true; } }
/** * Moves to the next non-whitespace character and checks if this character is the specified * separator. If the separator is found, it is skipped. Otherwise, this method thrown a {@link * ParseException}. * * @param text The text to parse. * @param position In input, the position where to start parsing from. In output, the first * character after the separator. * @param separator The character to search. * @throws ParseException if the separator was not found. */ private void parseSeparator( final String text, final ParsePosition position, final char separator) throws ParseException { if (!parseOptionalSeparator(text, position, separator)) { position.setErrorIndex(position.getIndex()); throw unparsableString(text, position); } }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { final Matcher matcher = pattern.matcher(source.substring(pos.getIndex())); if (!matcher.lookingAt()) { pos.setErrorIndex(pos.getIndex()); return false; } pos.setIndex(pos.getIndex() + matcher.end(1)); setCalendar(parser, calendar, matcher.group(1)); return true; }
/** * Resets this cursor instance. * * @see Reusable */ public void reset() { super.setIndex(0); super.setErrorIndex(-1); } }
public class LengthCheckingDateFormat extends SimpleDateFormat { public LengthCheckingDateFormat(String pattern) { super(pattern); } @Override public Date parse(String s, ParsePosition p) { if (s == null || (s.length() - p.getIndex()) < toPattern().length()) { p.setErrorIndex(p.getIndex()); return null; } return super.parse(s, p); } }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { for (int idx = 0; idx < formatField.length(); ++idx) { final int sIdx = idx + pos.getIndex(); if (sIdx == source.length()) { pos.setErrorIndex(sIdx); return false; } if (formatField.charAt(idx) != source.charAt(sIdx)) { pos.setErrorIndex(sIdx); return false; } } pos.setIndex(formatField.length() + pos.getIndex()); return true; } }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { for (int idx = 0; idx < formatField.length(); ++idx) { final int sIdx = idx + pos.getIndex(); if (sIdx == source.length()) { pos.setErrorIndex(sIdx); return false; } if (formatField.charAt(idx) != source.charAt(sIdx)) { pos.setErrorIndex(sIdx); return false; } } pos.setIndex(formatField.length() + pos.getIndex()); return true; } }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { final Matcher matcher = pattern.matcher(source.substring(pos.getIndex())); if (!matcher.lookingAt()) { pos.setErrorIndex(pos.getIndex()); return false; } pos.setIndex(pos.getIndex() + matcher.end(1)); setCalendar(parser, calendar, matcher.group(1)); return true; }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { final Matcher matcher = pattern.matcher(source.substring(pos.getIndex())); if (!matcher.lookingAt()) { pos.setErrorIndex(pos.getIndex()); return false; } pos.setIndex(pos.getIndex() + matcher.end(1)); setCalendar(parser, calendar, matcher.group(1)); return true; }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
@Override boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) { int idx = pos.getIndex(); int last = source.length(); pos.setIndex(idx); } else { final int end = idx + maxWidth; if (pos.getIndex() == idx) { pos.setErrorIndex(idx); return false; final int value = Integer.parseInt(source.substring(pos.getIndex(), idx)); pos.setIndex(idx);
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
/** * Parses a string to produce a <code>BigInteger</code>. * @param source the string to parse * @param pos input/output parsing parameter. * @return a parsed <code>BigInteger</code> or null if string does not * contain a BigInteger at the specified position */ protected BigInteger parseNextBigInteger(final String source, final ParsePosition pos) { final int start = pos.getIndex(); int end = (source.charAt(start) == '-') ? (start + 1) : start; while((end < source.length()) && Character.isDigit(source.charAt(end))) { ++end; } try { BigInteger n = new BigInteger(source.substring(start, end)); pos.setIndex(end); return n; } catch (NumberFormatException nfe) { pos.setErrorIndex(start); return null; } }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }
/** * Parse <code>source</code> for an expected fixed string. * @param source the string to parse * @param expected expected string * @param pos input/output parsing parameter. * @return true if the expected string was there */ public static boolean parseFixedstring(final String source, final String expected, final ParsePosition pos) { final int startIndex = pos.getIndex(); final int endIndex = startIndex + expected.length(); if ((startIndex >= source.length()) || (endIndex > source.length()) || (source.substring(startIndex, endIndex).compareTo(expected) != 0)) { // set index back to start, error index should be the start index pos.setIndex(startIndex); pos.setErrorIndex(startIndex); return false; } // the string was here pos.setIndex(endIndex); return true; }
/** * <p>Parsing is not supported.</p> * * @param source the string to parse * @param pos the parsing position * @return <code>null</code> as not supported */ public Object parseObject(String source, ParsePosition pos) { pos.setIndex(0); pos.setErrorIndex(0); return null; }