StartTag getPreviousStartTag() { Tag tag=this; while (true) { tag=tag.getPreviousTag(); if (tag==null) return null; if (tag instanceof StartTag) return (StartTag)tag; } }
static final Tag getPreviousTag(final Source source, final int pos, final TagType tagType) { // returns null if pos is out of range. if (tagType==null) return getPreviousTag(source,pos); if (source.useSpecialTypesCache) return source.cache.getPreviousTag(pos,tagType); return getPreviousTagUncached(source,pos,tagType,ParseText.NO_BREAK); }
/** * Returns the {@link Tag} beginning at or immediately preceding (or {@linkplain Segment#encloses(int) enclosing}) the specified position in the source document. * <p> * See the {@link Tag} class documentation for more details about the behaviour of this method. * * @param pos the position in the source document from which to start the search, may be out of bounds. * @return the {@link Tag} beginning at or immediately preceding the specified position in the source document, or <code>null</code> if none exists or the specified position is out of bounds. */ public Tag getPreviousTag(final int pos) { return Tag.getPreviousTag(this,pos); }
EndTag getPreviousEndTag() { Tag tag=this; while (true) { tag=tag.getPreviousTag(); if (tag==null) return null; if (tag instanceof EndTag) return (EndTag)tag; } }
/** * Returns the {@link Tag} of the specified {@linkplain TagType type} beginning at or immediately preceding (or {@linkplain Segment#encloses(int) enclosing}) the specified position in the source document. * <p> * See the {@link Tag} class documentation for more details about the behaviour of this method. * * @param pos the position in the source document from which to start the search, may be out of bounds. * @param tagType the <code>TagType</code> to search for. * @return the {@link Tag} of the specified {@linkplain TagType type} beginning at or immediately preceding the specified position in the source document, or <code>null</code> if none exists or the specified position is out of bounds. */ public Tag getPreviousTag(final int pos, final TagType tagType) { return Tag.getPreviousTag(this,pos,tagType); }
/** * Returns the previous tag in the source document. * <p> * This method also returns {@linkplain TagType#isServerTag() server tags}. * <p> * The result of a call to this method is cached. * Performing a {@linkplain Source#fullSequentialParse() full sequential parse} prepopulates this cache. * <p> * If the result is not cached, a call to this method is equivalent to <code>source.</code>{@link Source#getPreviousTag(int) getPreviousTag}<code>(</code>{@link #getBegin() getBegin()}<code>-1)</code>. * <p> * See the {@link Tag} class documentation for more details about the behaviour of this method. * * @return the previous tag in the source document, or <code>null</code> if this is the first tag. */ public Tag getPreviousTag() { if (previousTag==NOT_CACHED) previousTag=getPreviousTag(source,begin-1); return previousTag; }
Tag getPreviousTag(final TagType tagType) { if (tagType==null) return getPreviousTag(); if (tagType==StartTagType.UNREGISTERED || tagType==EndTagType.UNREGISTERED) return getPreviousTag(source,begin-1,tagType); Tag tag=this; while (true) { if (tag.previousTag==NOT_CACHED) return getPreviousTag(source,tag.begin-1,tagType); tag=tag.previousTag; if (tag==null) return null; if (tag.getTagType()==tagType) return tag; } }
static StartTag getPrevious(final Source source, int pos) { final Tag tag=Tag.getPreviousTag(source,pos); if (tag==null) return null; if (tag instanceof StartTag) return (StartTag)tag; return tag.getPreviousStartTag(); }
static EndTag getPrevious(final Source source, int pos) { final Tag tag=Tag.getPreviousTag(source,pos); if (tag==null) return null; if (tag instanceof EndTag) return (EndTag)tag; return tag.getPreviousEndTag(); }
if (name==null) return (EndTag)Tag.getPreviousTag(source,pos,endTagType); if (name.length()==0) throw new IllegalArgumentException("name argument must not be zero length"); if (source.wasFullSequentialParseCalled()) { EndTag endTag=(EndTag)Tag.getPreviousTag(source,pos,endTagType); while (true) { if (endTag==null) return null;
if (source.wasFullSequentialParseCalled() && isXMLTagName) { StartTag startTag=(StartTag)Tag.getPreviousTag(source,pos,searchStartTagType); while (true) { if (startTag==null) return null;