/** * Method is overridden for two main reasons: first, default method * does not display public/system id information, even if it exists, and * second, default implementation can not handle nested Location * information. */ public String getMessage() { String locMsg = getLocationDesc(); /* Better not use super's message if we do have location information, * since parent's message contains (part of) Location * info; something we can regenerate better... */ if (locMsg == null) { return super.getMessage(); } StringBuffer sb = new StringBuffer(mMsg.length() + locMsg.length() + 20); sb.append(mMsg); StringUtil.appendLF(sb); sb.append(" at "); sb.append(locMsg); return sb.toString(); }
public String tryToValidate(PrefixedName elemName) { // Do we have a follow state with that key? DFAState next = mState.findNext(elemName); if (next == null) { // Nope; let's show what we'd have expected instead... TreeSet names = mState.getNextNames(); if (names.size() == 0) { // expected end tag? return "Expected $END"; } // Either end tag, or another tag? if (mState.isAcceptingState()) { return "Expected <"+StringUtil.concatEntries(names, ">, <", null)+"> or $END"; } return "Expected <"+StringUtil.concatEntries(names, ">, <", "> or <")+">"; } mState = next; return null; }
case 'a': case 'A': if (StringUtil.equalEncodings(csName, "ASCII")) { return CS_US_ASCII; if (StringUtil.encodingStartsWith(csName, "cp")) { return "IBM" + StringUtil.trimEncoding(csName, true).substring(2); if (StringUtil.encodingStartsWith(csName, "cs")) { if (StringUtil.encodingStartsWith(csName, "csIBM")) { return StringUtil.trimEncoding(csName, true).substring(2); String type = StringUtil.trimEncoding(csName, true).substring(8); case 'i': case 'I': if (StringUtil.equalEncodings(csName, "ISO-8859-1") || StringUtil.equalEncodings(csName, "ISO-Latin1")) { return CS_ISO_LATIN1; if (StringUtil.encodingStartsWith(csName, "ISO-10646")) { if (StringUtil.equalEncodings(suffix, "UCS-Basic")) { return CS_US_ASCII; if (StringUtil.equalEncodings(suffix, "Unicode-Latin1")) { return CS_ISO_LATIN1;
/** * Method called when no validation is to be done, but value is still * to be normalized as much as it can. What this usually means is that * all regular space (parser earlier on converts other white space to * spaces, except for specific character entities; and these special * cases are NOT to be normalized). *<p> * The only exception is that CDATA will not do any normalization. But * for now, let's implement basic functionality that CDTA instance will * override * * @return Normalized value as a String, if any changes were done; * null if input was normalized */ public String normalize(DTDValidatorBase v, char[] cbuf, int start, int end) { return StringUtil.normalizeSpaces(cbuf, start, end); }
if (!StringUtil.isAllWhitespace(text, start, len)) { reportNwfStructure(ErrorConsts.WERR_PROLOG_NONWS_TEXT); reportInvalidContent(CHARACTERS); } else { // all-ws is ok... if (!StringUtil.isAllWhitespace(text, start, len)) { reportInvalidContent(CHARACTERS);
public static void appendLF(StringBuffer sb) { sb.append(getLF()); }
protected void verifyXmlEncoding(ReaderConfig cfg) throws XMLStreamException { String inputEnc = mInputEncoding; // Close enough? if (StringUtil.equalEncodings(inputEnc, mFoundEncoding)) { return; } /* Ok, maybe the difference is just with endianness indicator? * (UTF-16BE vs. UTF-16)? */ // !!! TBI XMLReporter rep = cfg.getXMLReporter(); if (rep != null) { Location loc = getLocation(); String msg = MessageFormat.format(ErrorConsts.W_MIXED_ENCODINGS, new Object[] { mFoundEncoding, inputEnc }); String type = ErrorConsts.WT_XML_DECL; /* 30-May-2008, tatus: Should wrap all the info as XMValidationProblem * since that's Woodstox' contract wrt. relatedInformation field. */ XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_WARNING, type); rep.report(msg, type, prob, loc); } }
boolean match; if (result == null) { match = StringUtil.matches(exp, valueChars, valueStart, valueEnd - valueStart); } else { match = exp.equals(result);
/** * Method called to do initial normalization of the default attribute * value, without trying to verify its validity. Thus, it's * called independent of whether we are fully validating the document. */ public void normalizeDefault() { String val = mDefValue.getValue(); if (val.length() > 0) { char[] cbuf = val.toCharArray(); String str = StringUtil.normalizeSpaces(cbuf, 0, cbuf.length); if (str != null) { mDefValue.setValue(str); } } }
if (!StringUtil.isAllWhitespace(text)) { reportNwfStructure(ErrorConsts.WERR_PROLOG_NONWS_TEXT); reportInvalidContent(CHARACTERS); } else { // all-ws is ok... if (!StringUtil.isAllWhitespace(text)) { reportInvalidContent(CHARACTERS);
public static void appendLF(StringBuffer sb) { sb.append(getLF()); }
protected void verifyXmlEncoding(ReaderConfig cfg) throws XMLStreamException { String inputEnc = mInputEncoding; // Close enough? if (StringUtil.equalEncodings(inputEnc, mFoundEncoding)) { return; } /* Ok, maybe the difference is just with endianness indicator? * (UTF-16BE vs. UTF-16)? */ // !!! TBI XMLReporter rep = cfg.getXMLReporter(); if (rep != null) { Location loc = getLocation(); rep.report(MessageFormat.format(ErrorConsts.W_MIXED_ENCODINGS, new Object[] { mFoundEncoding, inputEnc }), ErrorConsts.WT_XML_DECL, this, loc); } }
boolean match; if (result == null) { match = StringUtil.matches(exp, valueChars, valueStart, valueEnd - valueStart); } else { match = exp.equals(result);
case 'a': case 'A': if (StringUtil.equalEncodings(csName, "ASCII")) { return CS_US_ASCII; if (StringUtil.encodingStartsWith(csName, "cp")) { return "IBM" + StringUtil.trimEncoding(csName, true).substring(2); if (StringUtil.encodingStartsWith(csName, "cs")) { if (StringUtil.encodingStartsWith(csName, "csIBM")) { return StringUtil.trimEncoding(csName, true).substring(2); String type = StringUtil.trimEncoding(csName, true).substring(8); case 'i': case 'I': if (StringUtil.equalEncodings(csName, "ISO-8859-1") || StringUtil.equalEncodings(csName, "ISO-Latin1")) { return CS_ISO_LATIN1; if (StringUtil.encodingStartsWith(csName, "ISO-10646")) { if (StringUtil.equalEncodings(suffix, "UCS-Basic")) { return CS_US_ASCII; if (StringUtil.equalEncodings(suffix, "Unicode-Latin1")) { return CS_ISO_LATIN1;
public String fullyValid() { if (mState.isAcceptingState()) { return null; } TreeSet names = mState.getNextNames(); return "Expected <"+StringUtil.concatEntries(names, ">, <", "> or <")+">"; } }
StringUtil.appendLF(sb); sb.append(" from "); mContext.appendDesc(sb);
/** * Method that can be called to force space normalization (remove * leading/trailing spaces, replace non-spaces white space with * spaces, collapse spaces to one) on specified attribute. * Currently called by {@link InputElementStack} to force * normalization of Xml:id attribute */ public void normalizeSpacesInValue(int index) { // StringUtil has a method, but it works on char arrays... char[] attrCB = mValueBuilder.getCharBuffer(); String normValue = StringUtil.normalizeSpaces (attrCB, getValueStartOffset(index), getValueStartOffset(index+1)); if (normValue != null) { mAttributes[index].setValue(normValue); } }
if (!StringUtil.isAllWhitespace(text, start, len)) { reportNwfStructure(ErrorConsts.WERR_PROLOG_NONWS_TEXT); reportInvalidContent(CHARACTERS); } else { // all-ws is ok... if (!StringUtil.isAllWhitespace(text, start, len)) { reportInvalidContent(CHARACTERS);