public ProspectiveTagTypeIterator(final Source source, final int pos) { // returns empty iterator if pos out of range final ParseText parseText=source.getParseText(); cursor=root; int posIndex=0; try { // find deepest node that matches the text at pos: while (true) { final TagTypeRegister child=cursor.getChild(parseText.charAt(pos+(posIndex++))); if (child==null) break; cursor=child; } } catch (IndexOutOfBoundsException ex) {} // not avoiding this exception is expensive but only happens in the very rare circumstance that the end of file is encountered in the middle of a potential tag. // go back up until we reach a node that contains a list of tag types: while (cursor.tagTypes==null) if ((cursor=cursor.parent)==null) break; }
static CharacterReference construct(final Source source, final int begin, final Config.UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettings) { try { if (source.getParseText().charAt(begin)!='&') return null; return (source.getParseText().charAt(begin+1)=='#') ? NumericCharacterReference.construct(source,begin,unterminatedCharacterReferenceSettings) : CharacterEntityReference.construct(source,begin,unterminatedCharacterReferenceSettings.characterEntityReferenceMaxCodePoint); } catch (IndexOutOfBoundsException ex) { return null; } }
@Override public boolean atEndOfAttributes(final Source source, final int pos, final boolean isClosingSlashIgnored) { final ParseText parseText = source.getParseText(); return parseText.charAt(pos) == '>' || (parseText.containsAt("/>", pos)); }
public boolean atEndOfAttributes(final Source source, final int pos, final boolean isClosingSlashIgnored) { final ParseText parseText=source.getParseText(); return parseText.charAt(pos)=='>' || (!isClosingSlashIgnored && parseText.containsAt("/>",pos)); } }
protected int getEnd(final Source source, int pos) { final ParseText parseText=source.getParseText(); boolean insideQuotes=false; do { final char c=parseText.charAt(pos); if (c=='"') { insideQuotes=!insideQuotes; } else if (c=='>' && !insideQuotes) { return pos+1; } } while ((++pos)<source.getEnd()); return -1; } }
protected int getEnd(final Source source, int pos) { final ParseText parseText=source.getParseText(); boolean insideQuotes=false; boolean insideSquareBrackets=false; do { final char c=parseText.charAt(pos); if (insideQuotes) { if (c=='"') insideQuotes=false; } else { switch (c) { case '>': if (!insideSquareBrackets) return pos+1; break; case '"': insideQuotes=true; break; case '[': insideSquareBrackets=true; break; case ']': insideSquareBrackets=false; break; } } } while ((++pos)<source.getEnd()); return -1; } }
private static List<Segment> addURLSegmentsFromCSS(final List<Segment> uriSegments, final Segment cssSegment) { final Source source=cssSegment.getSource(); final ParseText parseText=source.getParseText(); final int breakAtIndex=cssSegment.getEnd(); for (int pos=cssSegment.getBegin(); (pos=parseText.indexOf("url(",pos,breakAtIndex))!=-1;) { pos+=4; while (pos<breakAtIndex && Segment.isWhiteSpace(parseText.charAt(pos))) pos++; if (pos>=breakAtIndex) break; if (isQuote(parseText.charAt(pos))) { pos++; if (pos>=breakAtIndex) break; } final int uriBegin=pos; final int closingBracketPos=parseText.indexOf(')',uriBegin,breakAtIndex); if (closingBracketPos==-1) break; pos=closingBracketPos; while (Segment.isWhiteSpace(parseText.charAt(pos-1))) pos--; if (isQuote(parseText.charAt(pos-1))) pos--; final int uriEnd=pos; if (uriEnd<=uriBegin) break; uriSegments.add(new Segment(source,uriBegin,uriEnd)); pos=closingBracketPos; } return uriSegments; }
int codePointStringBegin=begin+2; boolean hex; if (hex=(parseText.charAt(codePointStringBegin)=='x')) codePointStringBegin++; final int unterminatedMaxCodePoint=hex ? unterminatedCharacterReferenceSettings.hexadecimalCharacterReferenceMaxCodePoint : unterminatedCharacterReferenceSettings.decimalCharacterReferenceMaxCodePoint; final int maxSourcePos=source.end-1; boolean unterminated=false; while (true) { final char ch=parseText.charAt(x); if (ch==';') { end=x+1;
boolean isInApos = false; for (int x = pos; x < text.length(); x++) { char c = text.charAt(x); switch (c) { case '>':
name=source.getName(nameBegin,nameEnd); int expectedClosingDelimiterPos=nameEnd; while (Segment.isWhiteSpace(parseText.charAt(expectedClosingDelimiterPos))) expectedClosingDelimiterPos++; if (!parseText.containsAt(getClosingDelimiter(),expectedClosingDelimiterPos)) { if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(pos).appendTo(new StringBuilder(200).append("EndTag ").append(name).append(" at ")).append(" not recognised as type '").append(getDescription()).append("' because its name and closing delimiter are separated by characters other than white space").toString());
name=source.getName(nameBegin,extendedNameEnd); nameEnd=extendedNameEnd; } else if (!nameCharAfterPrefixAllowed && Tag.isXMLNameChar(parseText.charAt(nameEnd))) { return null;
while (!isTerminatingCharacter) { if (i==maxEnd || startTagType.atEndOfAttributes(source,i,isClosingSlashIgnored)) isTerminatingCharacter=true; final char ch=parseText.charAt(i);