/** called from StartTag.parseAttributes(int maxErrorCount) */ static Attributes construct(final Source source, final int startTagBegin, final int attributesBegin, final int maxEnd, final StartTagType startTagType, final String tagName, final int maxErrorCount) { return construct(source,"Attributes for StartTag",ParsingState.BETWEEN_ATTRIBUTES,startTagBegin,attributesBegin,maxEnd,startTagType,tagName,maxErrorCount); }
/** called from Source.parseAttributes(int pos, int maxEnd, int maxErrorCount) */ static Attributes construct(final Source source, final int begin, final int maxEnd, final int maxErrorCount) { return construct(source,"Attributes",ParsingState.BETWEEN_ATTRIBUTES,begin,-1,maxEnd,StartTagType.NORMAL,null,maxErrorCount); }
/** called from StartTagType.parseAttributes(Source, int startTagBegin, String tagName) */ static Attributes construct(final Source source, final int startTagBegin, final StartTagType startTagType, final String tagName) { return construct(source,"StartTag",ParsingState.AFTER_TAG_NAME,startTagBegin,-1,-1,startTagType,tagName,defaultMaxErrorCount); }
/** * Internal method for the parsing of {@link Attributes}. * <br />(<a href="TagType.html#ImplementationAssistance">implementation assistance</a> method) * <p> * Intended for use from within the {@link #constructTagAt(Source,int) constructTagAt(Source, int pos)} method. * <p> * The returned {@link Attributes} segment begins at <code>startTagBegin+1+tagName.length()</code>, * and ends straight after the last attribute found before the tag's {@linkplain #getClosingDelimiter() closing delimiter}. * <p> * Only returns <code>null</code> if the segment contains a major syntactical error * or more than the {@linkplain Attributes#getDefaultMaxErrorCount() default maximum} number of * minor syntactical errors. * * @param source the {@link Source} document. * @param startTagBegin the position in the source document at which the start tag is to begin. * @param tagName the {@linkplain StartTag#getName() name} of the start tag to be constructed. * @return the {@link Attributes} of the start tag to be constructed, or <code>null</code> if too many errors occur while parsing. */ protected final Attributes parseAttributes(final Source source, final int startTagBegin, final String tagName) { return Attributes.construct(source,startTagBegin,this,tagName); } }
/** * Parses any {@link Attributes} starting at the specified position. * This method is only used in the unusual situation where attributes exist outside of a start tag. * The {@link StartTag#getAttributes()} method should be used in normal situations. * <p> * Only returns <code>null</code> if the segment contains a major syntactical error * or more than the specified number of minor syntactical errors. * <p> * The <code>maxErrorCount</code> argument overrides the {@linkplain Attributes#getDefaultMaxErrorCount() default maximum error count}. * <p> * See {@link #parseAttributes(int pos, int maxEnd)} for more information. * * @param pos the position in the source document at the beginning of the attribute list, may be out of bounds. * @param maxEnd the maximum end position of the attribute list, or -1 if no maximum. * @param maxErrorCount the maximum number of minor errors allowed while parsing. * @return the {@link Attributes} starting at the specified position, or <code>null</code> if too many errors occur while parsing or the specified position is out of bounds. * @see StartTag#getAttributes() * @see #parseAttributes(int pos, int MaxEnd) */ public Attributes parseAttributes(final int pos, final int maxEnd, final int maxErrorCount) { return Attributes.construct(this,pos,maxEnd,maxErrorCount); }
/** * Parses the attributes specified in this start tag, regardless of the type of start tag. * This method is only required in the unusual situation where attributes exist in a start tag whose * {@linkplain #getStartTagType() type} doesn't {@linkplain StartTagType#hasAttributes() have attributes}. * <p> * See the documentation of the {@link #parseAttributes()} method for more information. * * @param maxErrorCount the maximum number of minor errors allowed while parsing * @return the attributes specified in this start tag, or <code>null</code> if too many errors occur while parsing. * @see #getAttributes() */ public Attributes parseAttributes(final int maxErrorCount) { if (attributes!=null) return attributes; final int maxEnd=end-startTagType.getClosingDelimiter().length(); int attributesBegin=begin+1+name.length(); // skip any non-name characters directly after the name (which are quite common) while (!isXMLNameStartChar(source.charAt(attributesBegin))) { attributesBegin++; if (attributesBegin==maxEnd) return null; } Attributes attributes=Attributes.construct(source,begin,attributesBegin,maxEnd,startTagType,name,maxErrorCount); if (attributes!=null) attributes.setStartTag(this); return attributes; }