@Override public String toString() { if (itemBuffer.isEmpty()) { return line + ":" + pos + ": Buffer empty"; } if (itemBuffer.size() < 2) { return line + ":" + pos + ": " + current(); } return line + ":" + pos + ": " + current() + ", " + next(); } }
@Override public String toString() { if (itemBuffer.isEmpty()) { return line + ":" + pos + ": Buffer empty"; } if (itemBuffer.size() < 2) { return line + ":" + pos + ": " + current(); } return line + ":" + pos + ": " + current() + ", " + next(); } }
/** * Checks if the next characters, starting from the current, match the given string. * * @param string the string to check * @param consume determines if the matched string should be consumed immediately * @return <tt>true</tt> if the next characters of the input match the given string, <tt>false</tt> * otherwise */ protected boolean canConsumeThisString(String string, boolean consume) { if (string == null) { return false; } for (int i = 0; i < string.length(); i++) { if (!input.next(i).is(string.charAt(i))) { return false; } } if (consume) { input.consume(string.length()); } return true; }
/** * Checks if the next characters, starting from the current, match the given string. * * @param string the string to check * @param consume determines if the matched string should be consumed immediately * @return <tt>true</tt> if the next characters of the input match the given string, <tt>false</tt> * otherwise */ protected boolean canConsumeThisString(String string, boolean consume) { if (string == null) { return false; } for (int i = 0; i < string.length(); i++) { if (!input.next(i).is(string.charAt(i))) { return false; } } if (consume) { input.consume(string.length()); } return true; }
/** * Determines if the underlying input is looking at the start of a number. * <p> * By default this is either indicated by a digit or by '-' followed by a digit or a '.' followed by a digit. * * @return <tt>true</tt> if the current input is the start of a numeric constant, <tt>false</tt> otherwise */ @SuppressWarnings("squid:S1067") protected boolean isAtStartOfNumber() { return input.current().isDigit() || input.current().is('-') && input.next().isDigit() || input.current().is('-') && input.next().is('.') && input.next(2).isDigit() || input.current().is('.') && input.next().isDigit(); }
/** * Determines if the underlying input is looking at the start of a number. * <p> * By default this is either indicated by a digit or by '-' followed by a digit or a '.' followed by a digit. * * @return <tt>true</tt> if the current input is the start of a numeric constant, <tt>false</tt> otherwise */ @SuppressWarnings("squid:S1067") protected boolean isAtStartOfNumber() { return input.current().isDigit() || input.current().is('-') && input.next().isDigit() || input.current().is('-') && input.next().is('.') && input.next(2).isDigit() || input.current().is('.') && input.next().isDigit(); }
protected boolean isAtBinaryAND(LookaheadReader reader) { return reader.current().is('&') && reader.next().is('&'); }
private boolean isAtOR(LookaheadReader reader) { return reader.current().is('o', 'O') && reader.next().is('r', 'R'); }
private boolean isAtBinaryAND(LookaheadReader reader) { return reader.current().is('&') && reader.next().is('&'); }
@Override protected boolean isIdentifierChar(Char current) { if (super.isIdentifierChar(current)) { return true; } // CSS selectors can contain "-", "." or "#" as long as it is not the last character of the token return (current.is('-') || current.is('.') || current.is('#')) && !input.next().isWhitepace(); }
@Override protected boolean isAtStartOfIdentifier() { if (super.isAtStartOfIdentifier()) { return true; } // Support vendor specific and class selectors like -moz-border-radius or .test return (input.current().is('-') || input.current().is('.')) && input.next().isLetter(); }
/** * Determines if the underlying input is looking at a bracket. * <p> * By default all supplied <tt>brackets</tt> are checked. If <tt>treatSinglePipeAsBracket</tt> is true, a * single '|' is also treated as bracket. * * @param inSymbol determines if we're already parsing a symbol or just trying to decide what the next token is * @return <tt>true</tt> if the current input is an opening or closing bracket */ @SuppressWarnings("squid:S1067") protected boolean isAtBracket(boolean inSymbol) { return input.current().is(brackets) || !inSymbol && treatSinglePipeAsBracket && input.current().is('|') && !input.next().is('|'); }
@SuppressWarnings("unchecked") private C parseTag() { StringBuilder tag = new StringBuilder(); tag.append(reader.consume()); tag.append(reader.consume()); while (!reader.current().isEndOfInput() && !(reader.current().is('|') && reader.next().is('|'))) { tag.append(reader.consume()); } tag.append(reader.consume()); tag.append(reader.consume()); QueryTag queryTag = QueryTag.parse(tag.toString()); if (queryTag.getType() != null && Strings.isFilled(queryTag.getValue())) { QueryTagHandler<C> handler = ctx.getPart(queryTag.getType(), QueryTagHandler.class); if (handler != null) { return handler.generateConstraint(factory, descriptor, queryTag.getValue()); } } return null; }
/** * Determines if the underlying input is looking at a bracket. * <p> * By default all supplied <tt>brackets</tt> are checked. If <tt>treatSinglePipeAsBracket</tt> is true, a * single '|' is also treated as bracket. * * @param inSymbol determines if we're already parsing a symbol or just trying to decide what the next token is * @return <tt>true</tt> if the current input is an opening or closing bracket */ @SuppressWarnings("squid:S1067") protected boolean isAtBracket(boolean inSymbol) { return input.current().is(brackets) || !inSymbol && treatSinglePipeAsBracket && input.current().is('|') && !input.next().is('|'); }
private boolean isAtOperator() { if (reader.current().is('=', ':')) { return true; } if (reader.current().is('!') && reader.next().is('=')) { return true; } return reader.current().is('<', '>'); } }
private String readOp() { if (isNotEqual()) { reader.consume(2); return "<>"; } if (reader.current().is('<') && reader.next().is('=')) { reader.consume(2); return "<="; } if (reader.current().is('>') && reader.next().is('=')) { reader.consume(2); return ">="; } if (reader.current().is('=') || reader.current().is(':')) { reader.consume(); return "="; } if (reader.current().is('>')) { reader.consume(); return ">"; } if (reader.current().is('<')) { reader.consume(); return "<"; } else { throw new IllegalStateException(reader.current().toString()); } }