private static boolean reachedMaxErrorCount(final int errorCount, final Source source, final String logType, final String tagName, final int logBegin, final int maxErrorCount) { if (errorCount<=maxErrorCount) return false; if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"rejected because it contains too many errors"); return true; }
public RadioCheckboxFormControl(final Element element, final FormControlType formControlType) { super(element,formControlType,true); if (elementContainer.predefinedValue==null) { elementContainer.predefinedValue=CHECKBOX_NULL_DEFAULT_VALUE; if (element.source.logger.isErrorEnabled()) element.source.logger.error(element.source.getRowColumnVector(element.begin).appendTo(new StringBuilder(200)).append(": compulsory \"value\" attribute of ").append(formControlType).append(" control \"").append(name).append("\" is missing, assuming the value \"").append(CHECKBOX_NULL_DEFAULT_VALUE).append('"').toString()); } } public boolean setValue(final String value) {
private static boolean isInvalidEmptyElementTag(final StartTagType startTagType, final Source source, final int i, final String logType, final String tagName, final int logBegin) { // This checks whether we've found the characters "/>" but it wasn't recognised as the closing delimiter because isClosingSlashIgnored is true. if (startTagType!=StartTagType.NORMAL || !startTagType.atEndOfAttributes(source,i,false)) return false; if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"contains a '/' character before the closing '>', which is ignored because tags of this name cannot be empty-element tags"); return true; }
private void verifyName() { if (formControlType.isSubmit()) return; String missingOrBlank; if (name==null) return; if (name.length()!=0) return; final Source source=getElement().source; if (source.logger.isErrorEnabled()) source.logger.error(getElement().source.getRowColumnVector(getElement().begin).appendTo(new StringBuilder(200)).append(": compulsory \"name\" attribute of ").append(formControlType).append(" control is empty").toString()); }
protected Tag constructTagAt(final Source source, final int pos) { final int closingDelimiterPos=source.getParseText().indexOf('>',pos+1); if (closingDelimiterPos==-1) return null; final Tag tag=constructStartTag(source,pos,closingDelimiterPos+1,"",null); if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(tag.getBegin()).appendTo(new StringBuilder(200).append("Encountered possible StartTag at ")).append(" whose content does not match a registered StartTagType").toString()); return tag; } }
protected Tag constructTagAt(final Source source, final int pos) { final ParseText parseText=source.getParseText(); final int nameBegin=pos+getStartDelimiter().length(); final int nameEnd=parseText.indexOf(getClosingDelimiter(),nameBegin); final String name=source.getName(nameBegin,nameEnd); // throws IndexOutOfBoundsException if nameEnd==-1 final EndTag endTag=constructEndTag(source,pos,nameEnd+getClosingDelimiter().length(),name); if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(pos).appendTo(new StringBuilder(200).append("Encountered possible EndTag at ")).append(" whose content does not match a registered EndTagType").toString()); return endTag; } }
static final Tag getTagAt(final Source source, final int pos, final boolean serverTagOnly, final boolean assumeNoNestedTags) { final TagTypeRegister.ProspectiveTagTypeIterator prospectiveTagTypeIterator=new TagTypeRegister.ProspectiveTagTypeIterator(source,pos); // prospectiveTagTypeIterator is empty if pos is out of range. while (prospectiveTagTypeIterator.hasNext()) { final TagType tagType=prospectiveTagTypeIterator.next(); if (serverTagOnly && !tagType.isServerTag()) continue; if (!assumeNoNestedTags && !tagType.isValidPosition(source,pos,source.fullSequentialParseData)) continue; try { final Tag tag=tagType.constructTagAt(source,pos); if (tag!=null) return tag; } catch (IndexOutOfBoundsException ex) { if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(pos).appendTo(new StringBuilder(200).append("Tag at ")).append(" not recognised as type '").append(tagType.getDescription()).append("' because it has no end delimiter").toString()); } } return null; }
if (source.logger.isErrorEnabled() && !element.equals(endTag.element)) source.logger.error(source.getRowColumnVector(endTag.begin).appendTo(new StringBuilder(200).append("End tag ").append(endTag).append(" at ")).append(" terminates more than one element").toString());
name=getNamePrefix(); if (!parseText.containsAt(getClosingDelimiter(),startDelimiterEnd)) { if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(pos).appendTo(new StringBuilder(200).append("EndTag of expected format ").append(staticString).append(" at ")).append(" not recognised as type '").append(getDescription()).append("' because it is missing the closing delimiter").toString()); return null; 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()); return null;
final StartTag nextStartTag=source.getNextStartTag(end,name); if (nextStartTag==null || nextStartTag.begin>nextEndTag.begin) return nextEndTag; if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(begin).appendTo(new StringBuilder(200).append("StartTag at ")).append(" missing required end tag - invalid nested start tag encountered before end tag").toString()); if (getResult!=null) return (EndTag)getResult[0]; if (source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(begin).appendTo(new StringBuilder(200).append("StartTag at ")).append(" missing required end tag").toString()); return null;
if (formControlType==null) { if (FormControlType.isNonFormControl(typeAttributeValue)) return null; if (element.source.logger.isErrorEnabled()) element.source.logger.error(element.source.getRowColumnVector(element.begin).appendTo(new StringBuilder(200)).append(": INPUT control with unrecognised type \"").append(typeAttributeValue).append("\" assumed to be type \"text\"").toString()); formControlType=FormControlType.TEXT;
end=getEnd(source,nameEnd); if (end<0) { if (end==-1 && source.logger.isErrorEnabled()) source.logger.error(source.getRowColumnVector(pos).appendTo(new StringBuilder(200).append("StartTag ").append(name).append(" at ")).append(" not recognised as type '").append(getDescription()).append("' because it has no closing delimiter").toString()); return null;
if (isTerminatingCharacter) { if (i==maxEnd) { if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"terminated in the middle of a quoted attribute value",i); if (reachedMaxErrorCount(++errorCount,source,logType,tagName,logBegin,maxErrorCount)) return null; valueSegment=new Segment(source,currentBegin,i); parsingState=ParsingState.BETWEEN_ATTRIBUTES; } else if (ch=='<' && quote==' ') { if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"rejected because of '<' character in unquoted attribute value",i); return null; if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"rejected because of '<' character in attribute name",i); return null; if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"contains attribute name with invalid character",i); if (reachedMaxErrorCount(++errorCount,source,logType,tagName,logBegin,maxErrorCount)) return null; parsingState=ParsingState.START_VALUE; } else if (ch=='<') { if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"rejected because of '<' character after attribute name",i); return null; } else { if (quote!=' ') { if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"has missing whitespace after quoted attribute value",i); if (source.logger.isErrorEnabled()) log(source,logType,tagName,logBegin,"rejected because of '<' character",i); return null;
if (source.logger.isErrorEnabled()) source.logger.error("Child "+childElement.getDebugInfo()+" extends beyond end of parent "+getDebugInfo()); if (!INCLUDE_INCORRECTLY_NESTED_CHILDREN_IN_HIERARCHY) { pos=childElement.end;
private static String getString(final EncodingDetector encodingDetector) throws IOException { try { return Util.getString(encodingDetector.openReader()); // this closes the input stream } catch (IOException ex) { try { Logger logger=newLogger(); encodingDetector.getLoggerQueue().outputTo(logger); if (logger.isErrorEnabled()) logger.error("IOException constructing encoded source. Encoding: "+encodingDetector.getEncoding()+" - "+encodingDetector.getEncodingSpecificationInfo()+". PreliminaryEncoding: "+encodingDetector.getPreliminaryEncoding()+" - "+encodingDetector.getPreliminaryEncodingSpecificationInfo()); } catch (Exception ex2) {} // make sure attempting to log does not cause a new exception throw ex; } }