diff --git a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java index f602668..b1e4472 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -33,7 +33,7 @@ public class PrettyPrintXMLWriter implements XMLWriter { private PrintWriter writer; - private LinkedList elementStack = new LinkedList(); + private LinkedList elementStack = new LinkedList<>(); private boolean tagInProgress; diff --git a/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java index 6309b16..3b88703 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java @@ -35,7 +35,7 @@ public class SerializerXMLWriter implements XMLWriter { private final String namespace; - private final Stack elements = new Stack(); + private final Stack elements = new Stack<>(); private List exceptions; @@ -95,7 +95,7 @@ public void endElement() { */ private void storeException(IOException e) { if (exceptions == null) { - exceptions = new ArrayList(); + exceptions = new ArrayList<>(); } exceptions.add(e); } diff --git a/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java b/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java index 0e851f2..8e60d59 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java @@ -77,7 +77,7 @@ * @since 1.0 * */ -class StringUtils { +final class StringUtils { /** *

* StringUtils instances should NOT be constructed in standard programming. Instead, the class should @@ -100,7 +100,7 @@ private StringUtils() {} * @return true if the String is null, or length zero */ public static boolean isEmpty(String str) { - return ((str == null) || (str.isEmpty())); + return (str == null) || (str.isEmpty()); } // Splitting diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java index 41aa4ac..aed5cd9 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java @@ -282,7 +282,7 @@ public XmlReader(InputStream is, String httpContentType) throws IOException { */ public XmlReader(InputStream is, String httpContentType, boolean lenient, String defaultEncoding) throws IOException, XmlStreamReaderException { - _defaultEncoding = (defaultEncoding == null) ? _staticDefaultEncoding : defaultEncoding; + _defaultEncoding = defaultEncoding == null ? _staticDefaultEncoding : defaultEncoding; try { doHttpStream(is, httpContentType, lenient); } catch (XmlStreamReaderException ex) { @@ -346,7 +346,7 @@ private void doLenientDetection(String httpContentType, XmlStreamReaderException encoding = ex.getContentTypeEncoding(); } if (encoding == null) { - encoding = (_defaultEncoding == null) ? UTF_8 : _defaultEncoding; + encoding = _defaultEncoding == null ? UTF_8 : _defaultEncoding; } prepareReader(ex.getInputStream(), encoding); } @@ -409,7 +409,7 @@ private String calculateRawEncoding(String bomEnc, String xmlGuessEnc, String xm String encoding; if (bomEnc == null) { if (xmlGuessEnc == null || xmlEnc == null) { - encoding = (_defaultEncoding == null) ? UTF_8 : _defaultEncoding; + encoding = _defaultEncoding == null ? UTF_8 : _defaultEncoding; } else if (xmlEnc.equals(UTF_16) && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) { encoding = xmlGuessEnc; } else { @@ -460,7 +460,7 @@ private String calculateHttpEncoding( if (appXml) { encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, is); } else { - encoding = (_defaultEncoding == null) ? US_ASCII : _defaultEncoding; + encoding = _defaultEncoding == null ? US_ASCII : _defaultEncoding; } } else if (bomEnc != null && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) { throw new XmlStreamReaderException( @@ -506,7 +506,7 @@ private static String getContentTypeMime(String httpContentType) { String mime = null; if (httpContentType != null) { int i = httpContentType.indexOf(";"); - mime = ((i == -1) ? httpContentType : httpContentType.substring(0, i)).trim(); + mime = (i == -1 ? httpContentType : httpContentType.substring(0, i)).trim(); } return mime; } @@ -521,8 +521,8 @@ private static String getContentTypeEncoding(String httpContentType) { if (i > -1) { String postMime = httpContentType.substring(i + 1); Matcher m = CHARSET_PATTERN.matcher(postMime); - encoding = (m.find()) ? m.group(1) : null; - encoding = (encoding != null) ? encoding.toUpperCase(Locale.ENGLISH) : null; + encoding = m.find() ? m.group(1) : null; + encoding = encoding != null ? encoding.toUpperCase(Locale.ENGLISH) : null; } } return encoding; diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java index 89885d1..24f5b83 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java @@ -117,7 +117,7 @@ public Xpp3Dom(Xpp3Dom src, String name) { int childCount = src.getChildCount(); - childList = new ArrayList(childCount); + childList = new ArrayList<>(childCount); setValue(src.getValue()); @@ -164,7 +164,7 @@ public String[] getAttributeNames() { } public String getAttribute(String name) { - return (null != attributes) ? attributes.get(name) : null; + return null != attributes ? attributes.get(name) : null; } /** @@ -191,7 +191,7 @@ public void setAttribute(String name, String value) { throw new NullPointerException("Attribute name can not be null"); } if (null == attributes) { - attributes = new HashMap(); + attributes = new HashMap<>(); } attributes.put(name, value); @@ -244,7 +244,7 @@ private List getChildrenAsList(String name) { for (Xpp3Dom configuration : childList) { if (name.equals(configuration.getName())) { if (children == null) { - children = new ArrayList(); + children = new ArrayList<>(); } children.add(configuration); } @@ -320,7 +320,7 @@ public void writeToSerializer(String namespace, XmlSerializer serializer) throws // document - not the desired behaviour! SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer); Xpp3DomWriter.write(xmlWriter, this); - if (xmlWriter.getExceptions().size() > 0) { + if (!xmlWriter.getExceptions().isEmpty()) { throw (IOException) xmlWriter.getExceptions().get(0); } } @@ -418,14 +418,14 @@ private static void mergeIntoXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolea dominant.addChild(aDominantChildren); } } else { - Map> commonChildren = new HashMap>(); + Map> commonChildren = new HashMap<>(); for (Xpp3Dom recChild : recessive.childList) { if (commonChildren.containsKey(recChild.name)) { continue; } List dominantChildren = dominant.getChildrenAsList(recChild.name); - if (dominantChildren.size() > 0) { + if (!dominantChildren.isEmpty()) { commonChildren.put(recChild.name, dominantChildren.iterator()); } } @@ -524,8 +524,7 @@ public int hashCode() { result = 37 * result + (name != null ? name.hashCode() : 0); result = 37 * result + (value != null ? value.hashCode() : 0); result = 37 * result + (attributes != null ? attributes.hashCode() : 0); - result = 37 * result + (childList != null ? childList.hashCode() : 0); - return result; + return 37 * result + (childList != null ? childList.hashCode() : 0); } @Override @@ -548,10 +547,10 @@ public String toUnescapedString() { } public static boolean isNotEmpty(String str) { - return ((str != null) && (str.length() > 0)); + return (str != null) && (str.length() > 0); } public static boolean isEmpty(String str) { - return ((str == null) || (str.trim().length() == 0)); + return (str == null) || (str.trim().length() == 0); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java index f337bcd..fc1e771 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java @@ -71,7 +71,7 @@ public void writeToSerializer(String namespace, XmlSerializer serializer, Xpp3Do // document - not the desired behaviour! SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer); Xpp3DomWriter.write(xmlWriter, dom); - if (xmlWriter.getExceptions().size() > 0) { + if (!xmlWriter.getExceptions().isEmpty()) { throw (IOException) xmlWriter.getExceptions().get(0); } } @@ -241,7 +241,7 @@ public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) { */ @Deprecated public static boolean isNotEmpty(String str) { - return (str != null && str.length() > 0); + return str != null && str.length() > 0; } /** @@ -251,6 +251,6 @@ public static boolean isNotEmpty(String str) { */ @Deprecated public static boolean isEmpty(String str) { - return (str == null || str.length() == 0); + return str == null || str.length() == 0; } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java b/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java index 8af68d3..6b48503 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java @@ -74,7 +74,9 @@ private String newString(char[] cbuf, int off, int len) { * diminishing hash quality for long strings but for XML parsing it should be good enough ... */ private static int fastHash(char ch[], int off, int len) { - if (len == 0) return 0; + if (len == 0) { + return 0; + } // assert len >0 int hash = ch[off]; // hash at beginning // try { @@ -83,11 +85,15 @@ private static int fastHash(char ch[], int off, int len) { // aie.printStackTrace(); //should never happen ... // throw new RuntimeException("this is violation of pre-condition"); // } - if (len > 16) hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning - if (len > 8) hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ... - // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value - // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ... - // assert hash >= 0; + if (len > 16) { + hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning + } + if (len > 8) { + hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ... + // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value + // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ... + // assert hash >= 0; + } return hash; } diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java index 2b223d3..709ad77 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java @@ -73,7 +73,7 @@ private String newString(char[] cbuf, int off, int len) { } private String newStringIntern(char[] cbuf, int off, int len) { - return (new String(cbuf, off, len)).intern(); + return new String(cbuf, off, len).intern(); } private static final boolean TRACE_SIZING = false; @@ -134,13 +134,19 @@ private void ensureElementsCapacity() { String[] arr = null; // resue arr local variable slot arr = new String[newSize]; - if (needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize); + if (needsCopying) { + System.arraycopy(elName, 0, arr, 0, elStackSize); + } elName = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(elPrefix, 0, arr, 0, elStackSize); + if (needsCopying) { + System.arraycopy(elPrefix, 0, arr, 0, elStackSize); + } elPrefix = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(elUri, 0, arr, 0, elStackSize); + if (needsCopying) { + System.arraycopy(elUri, 0, arr, 0, elStackSize); + } elUri = arr; int[] iarr = new int[newSize]; @@ -216,24 +222,34 @@ private void ensureAttributesCapacity(int size) { String[] arr = null; arr = new String[newSize]; - if (needsCopying) System.arraycopy(attributeName, 0, arr, 0, attrPosSize); + if (needsCopying) { + System.arraycopy(attributeName, 0, arr, 0, attrPosSize); + } attributeName = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize); + if (needsCopying) { + System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize); + } attributePrefix = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(attributeUri, 0, arr, 0, attrPosSize); + if (needsCopying) { + System.arraycopy(attributeUri, 0, arr, 0, attrPosSize); + } attributeUri = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(attributeValue, 0, arr, 0, attrPosSize); + if (needsCopying) { + System.arraycopy(attributeValue, 0, arr, 0, attrPosSize); + } attributeValue = arr; if (!allStringsInterned) { final int[] iarr = new int[newSize]; - if (needsCopying) System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize); + if (needsCopying) { + System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize); + } attributeNameHash = iarr; } @@ -282,8 +298,10 @@ private void ensureNamespacesCapacity(int size) { // simplistic implementation of hash function that has constant time to compute - so it also means // diminishing hash quality for long strings but for XML parsing it should be good enough ... - private static final int fastHash(char ch[], int off, int len) { - if (len == 0) return 0; + private static int fastHash(char ch[], int off, int len) { + if (len == 0) { + return 0; + } // assert len >0 int hash = ch[off]; // hash at beginning // try { @@ -292,11 +310,15 @@ private static final int fastHash(char ch[], int off, int len) { // aie.printStackTrace(); //should never happen ... // throw new RuntimeException("this is violation of pre-condition"); // } - if (len > 16) hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning - if (len > 8) hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ... - // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value - // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ... - // assert hash >= 0; + if (len > 16) { + hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning + } + if (len > 8) { + hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ... + // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value + // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ... + // assert hash >= 0; + } return hash; } @@ -491,22 +513,25 @@ public void setupFromTemplate() { */ @Override public void setFeature(String name, boolean state) throws XmlPullParserException { - if (name == null) throw new IllegalArgumentException("feature name should not be null"); + if (name == null) { + throw new IllegalArgumentException("feature name should not be null"); + } if (FEATURE_PROCESS_NAMESPACES.equals(name)) { - if (eventType != START_DOCUMENT) + if (eventType != START_DOCUMENT) { throw new XmlPullParserException( "namespace processing feature can only be changed before parsing", this, null); + } processNamespaces = state; // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) { // if(type != START_DOCUMENT) throw new XmlPullParserException( // "namespace reporting feature can only be changed before parsing", this, null); // reportNsAttribs = state; } else if (FEATURE_NAMES_INTERNED.equals(name)) { - if (state != false) { + if (state) { throw new XmlPullParserException("interning names in this implementation is not supported"); } } else if (FEATURE_PROCESS_DOCDECL.equals(name)) { - if (state != false) { + if (state) { throw new XmlPullParserException("processing DOCDECL is not supported"); } // } else if(REPORT_DOCDECL.equals(name)) { @@ -527,7 +552,9 @@ public void setFeature(String name, boolean state) throws XmlPullParserException */ @Override public boolean getFeature(String name) { - if (name == null) throw new IllegalArgumentException("feature name should not be null"); + if (name == null) { + throw new IllegalArgumentException("feature name should not be null"); + } if (FEATURE_PROCESS_NAMESPACES.equals(name)) { return processNamespaces; // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) { @@ -556,7 +583,9 @@ public void setProperty(String name, Object value) throws XmlPullParserException @Override public Object getProperty(String name) { - if (name == null) throw new IllegalArgumentException("property name should not be null"); + if (name == null) { + throw new IllegalArgumentException("property name should not be null"); + } if (PROPERTY_XMLDECL_VERSION.equals(name)) { return xmlDeclVersion; } else if (PROPERTY_XMLDECL_STANDALONE.equals(name)) { @@ -651,8 +680,9 @@ public int getNamespaceCount(int depth) throws XmlPullParserException { } // int maxDepth = eventType == END_TAG ? this.depth + 1 : this.depth; // if(depth < 0 || depth > maxDepth) throw new IllegalArgumentException( - if (depth < 0 || depth > this.depth) + if (depth < 0 || depth > this.depth) { throw new IllegalArgumentException("namespace count may be for depth 0.." + this.depth + " not " + depth); + } return elNamespaceCount[depth]; } @@ -717,7 +747,9 @@ private static int findFragment(int bufMinPos, char[] b, int start, int end) { // end="+end); if (start < bufMinPos) { start = bufMinPos; - if (start > end) start = end; + if (start > end) { + start = end; + } return start; } if (end - start > 65) { @@ -725,9 +757,13 @@ private static int findFragment(int bufMinPos, char[] b, int start, int end) { } int i = start + 1; while (--i > bufMinPos) { - if ((end - i) > 65) break; + if ((end - i) > 65) { + break; + } final char c = b[i]; - if (c == '<' && (start - i) > 10) break; + if (c == '<' && (start - i) > 10) { + break; + } } return i; } @@ -744,7 +780,9 @@ public String getPositionDescription() { if (start < pos) { fragment = new String(buf, start, pos - start); } - if (bufAbsoluteStart > 0 || start > 0) fragment = "..." + fragment; + if (bufAbsoluteStart > 0 || start > 0) { + fragment = "..." + fragment; + } } // return " at line "+tokenizerPosRow // +" and column "+(tokenizerPosCol-1) @@ -768,12 +806,16 @@ public boolean isWhitespace() throws XmlPullParserException { if (eventType == TEXT || eventType == CDSECT) { if (usePC) { for (int i = pcStart; i < pcEnd; i++) { - if (!isS(pc[i])) return false; + if (!isS(pc[i])) { + return false; + } } return true; } else { for (int i = posStart; i < posEnd; i++) { - if (!isS(buf[i])) return false; + if (!isS(buf[i])) { + return false; + } } return true; } @@ -906,77 +948,103 @@ public String getPrefix() { @Override public boolean isEmptyElementTag() throws XmlPullParserException { - if (eventType != START_TAG) + if (eventType != START_TAG) { throw new XmlPullParserException("parser must be on START_TAG to check for empty element", this, null); + } return emptyElementTag; } @Override public int getAttributeCount() { - if (eventType != START_TAG) return -1; + if (eventType != START_TAG) { + return -1; + } return attributeCount; } @Override public String getAttributeNamespace(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (!processNamespaces) return NO_NAMESPACE; - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (!processNamespaces) { + return NO_NAMESPACE; + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return attributeUri[index]; } @Override public String getAttributeName(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return attributeName[index]; } @Override public String getAttributePrefix(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (!processNamespaces) return null; - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (!processNamespaces) { + return null; + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return attributePrefix[index]; } @Override public String getAttributeType(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return "CDATA"; } @Override public boolean isAttributeDefault(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return false; } @Override public String getAttributeValue(int index) { - if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes"); - if (index < 0 || index >= attributeCount) + if (eventType != START_TAG) { + throw new IndexOutOfBoundsException("only START_TAG can have attributes"); + } + if (index < 0 || index >= attributeCount) { throw new IndexOutOfBoundsException( "attribute position must be 0.." + (attributeCount - 1) + " and not " + index); + } return attributeValue[index]; } @Override public String getAttributeValue(String namespace, String name) { - if (eventType != START_TAG) + if (eventType != START_TAG) { throw new IndexOutOfBoundsException("only START_TAG can have attributes" + getPositionDescription()); + } if (name == null) { throw new IllegalArgumentException("attribute name can not be null"); } @@ -998,9 +1066,10 @@ public String getAttributeValue(String namespace, String name) { if (namespace != null && namespace.length() == 0) { namespace = null; } - if (namespace != null) + if (namespace != null) { throw new IllegalArgumentException( "when namespaces processing is disabled attribute namespace must be null"); + } for (int i = 0; i < attributeCount; ++i) { if (name.equals(attributeName[i])) { return attributeValue[i]; @@ -1210,7 +1279,9 @@ private int nextImpl() throws XmlPullParserException, IOException { if (ch == '-') { // note: if(tokenize == false) posStart/End is NOT changed!!!! parseComment(); - if (tokenize) return eventType = COMMENT; + if (tokenize) { + return eventType = COMMENT; + } if (!usePC && hadCharData) { needsMerging = true; } else { @@ -1222,7 +1293,9 @@ private int nextImpl() throws XmlPullParserException, IOException { // int oldStart = posStart + bufAbsoluteStart; // int oldEnd = posEnd + bufAbsoluteStart; parseCDSect(hadCharData); - if (tokenize) return eventType = CDSECT; + if (tokenize) { + return eventType = CDSECT; + } final int cdStart = posStart; final int cdEnd = posEnd; final int cdLen = cdEnd - cdStart; @@ -1277,7 +1350,9 @@ private int nextImpl() throws XmlPullParserException, IOException { } } else if (ch == '?') { parsePI(); - if (tokenize) return eventType = PROCESSING_INSTRUCTION; + if (tokenize) { + return eventType = PROCESSING_INSTRUCTION; + } if (!usePC && hadCharData) { needsMerging = true; } else { @@ -1306,7 +1381,9 @@ private int nextImpl() throws XmlPullParserException, IOException { final int oldStart = posStart + bufAbsoluteStart; final int oldEnd = posEnd + bufAbsoluteStart; parseEntityRef(); - if (tokenize) return eventType = ENTITY_REF; + if (tokenize) { + return eventType = ENTITY_REF; + } // check if replacement text can be resolved !!! if (resolvedEntityRefCharBuf == BUF_NOT_RESOLVED) { if (entityRefName == null) { @@ -1390,18 +1467,24 @@ private int nextImpl() throws XmlPullParserException, IOException { } } // assert usePC == true; - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { // if(!usePC) { joinPC(); } else { if(pcEnd >= pc.length) ensurePC(); } if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -1491,10 +1574,14 @@ private int parseProlog() throws XmlPullParserException, IOException { } seenDocdecl = true; parseDocdecl(); - if (tokenize) return eventType = DOCDECL; + if (tokenize) { + return eventType = DOCDECL; + } } else if (ch == '-') { parseComment(); - if (tokenize) return eventType = COMMENT; + if (tokenize) { + return eventType = COMMENT; + } } else { throw new XmlPullParserException("unexpected markup = pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -1586,7 +1679,9 @@ private int parseEpilog() throws XmlPullParserException, IOException { // check if it is 'xml' // deal with XMLDecl parsePI(); - if (tokenize) return eventType = PROCESSING_INSTRUCTION; + if (tokenize) { + return eventType = PROCESSING_INSTRUCTION; + } } else if (ch == '!') { ch = more(); @@ -1595,10 +1690,14 @@ private int parseEpilog() throws XmlPullParserException, IOException { } if (ch == 'D') { parseDocdecl(); // FIXME - if (tokenize) return eventType = DOCDECL; + if (tokenize) { + return eventType = DOCDECL; + } } else if (ch == '-') { parseComment(); - if (tokenize) return eventType = COMMENT; + if (tokenize) { + return eventType = COMMENT; + } } else { throw new XmlPullParserException("unexpected markup = pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -1748,16 +1853,20 @@ public int parseStartTag() throws XmlPullParserException, IOException { final int nameStart = pos - 1 + bufAbsoluteStart; int colonPos = -1; char ch = buf[pos - 1]; - if (ch == ':' && processNamespaces) + if (ch == ':' && processNamespaces) { throw new XmlPullParserException( "when namespaces processing enabled colon can not be at element name start", this, null); + } while (true) { ch = more(); - if (!isNameChar(ch)) break; + if (!isNameChar(ch)) { + break; + } if (ch == ':' && processNamespaces) { - if (colonPos != -1) + if (colonPos != -1) { throw new XmlPullParserException( "only one colon is allowed in name of element when namespaces are enabled", this, null); + } colonPos = pos - 1 + bufAbsoluteStart; } } @@ -1805,11 +1914,14 @@ public int parseStartTag() throws XmlPullParserException, IOException { if (ch == '>') { break; } else if (ch == '/') { - if (emptyElementTag) throw new XmlPullParserException("repeated / in tag declaration", this, null); + if (emptyElementTag) { + throw new XmlPullParserException("repeated / in tag declaration", this, null); + } emptyElementTag = true; ch = more(); - if (ch != '>') + if (ch != '>') { throw new XmlPullParserException("expected > to end empty tag not " + printable(ch), this, null); + } break; } else if (isNameStartChar(ch)) { ch = parseAttribute(); @@ -1866,9 +1978,13 @@ public int parseStartTag() throws XmlPullParserException, IOException { // prepare data for nice error message? String attr1 = attributeName[j]; - if (attributeUri[j] != null) attr1 = attributeUri[j] + ":" + attr1; + if (attributeUri[j] != null) { + attr1 = attributeUri[j] + ":" + attr1; + } String attr2 = attributeName[i]; - if (attributeUri[i] != null) attr2 = attributeUri[i] + ":" + attr2; + if (attributeUri[i] != null) { + attr2 = attributeUri[i] + ":" + attr2; + } throw new XmlPullParserException( "duplicated attributes " + attr1 + " and " + attr2, this, null); } @@ -1881,10 +1997,10 @@ public int parseStartTag() throws XmlPullParserException, IOException { // check raw attribute uniqueness constraint!!! for (int i = 1; i < attributeCount; i++) { for (int j = 0; j < i; j++) { - if ((allStringsInterned && attributeName[j].equals(attributeName[i]) + if (allStringsInterned && attributeName[j].equals(attributeName[i]) || (!allStringsInterned && attributeNameHash[j] == attributeNameHash[i] - && attributeName[j].equals(attributeName[i])))) { + && attributeName[j].equals(attributeName[i]))) { // prepare data for nice error message? final String attr1 = attributeName[j]; @@ -1910,9 +2026,10 @@ private char parseAttribute() throws XmlPullParserException, IOException { final int nameStart = pos - 1 + bufAbsoluteStart; int colonPos = -1; char ch = buf[pos - 1]; - if (ch == ':' && processNamespaces) + if (ch == ':' && processNamespaces) { throw new XmlPullParserException( "when namespaces processing enabled colon can not be at attribute name start", this, null); + } boolean startsWithXmlns = processNamespaces && ch == 'x'; int xmlnsPos = 0; @@ -1923,28 +2040,38 @@ private char parseAttribute() throws XmlPullParserException, IOException { if (startsWithXmlns && xmlnsPos < 5) { ++xmlnsPos; if (xmlnsPos == 1) { - if (ch != 'm') startsWithXmlns = false; + if (ch != 'm') { + startsWithXmlns = false; + } } else if (xmlnsPos == 2) { - if (ch != 'l') startsWithXmlns = false; + if (ch != 'l') { + startsWithXmlns = false; + } } else if (xmlnsPos == 3) { - if (ch != 'n') startsWithXmlns = false; + if (ch != 'n') { + startsWithXmlns = false; + } } else if (xmlnsPos == 4) { - if (ch != 's') startsWithXmlns = false; + if (ch != 's') { + startsWithXmlns = false; + } } else if (xmlnsPos == 5) { - if (ch != ':') + if (ch != ':') { throw new XmlPullParserException( "after xmlns in attribute name must be colon" + "when namespaces are enabled", this, null); + } // colonPos = pos - 1 + bufAbsoluteStart; } } if (ch == ':') { - if (colonPos != -1) + if (colonPos != -1) { throw new XmlPullParserException( "only one colon is allowed in attribute name" + " when namespaces are enabled", this, null); + } colonPos = pos - 1 + bufAbsoluteStart; } } @@ -1958,7 +2085,9 @@ private char parseAttribute() throws XmlPullParserException, IOException { String prefix = null; // work on prefixes and namespace URI if (processNamespaces) { - if (xmlnsPos < 4) startsWithXmlns = false; + if (xmlnsPos < 4) { + startsWithXmlns = false; + } if (startsWithXmlns) { if (colonPos != -1) { // prefix = attributePrefix[ attributeCount ] = null; @@ -2007,7 +2136,9 @@ private char parseAttribute() throws XmlPullParserException, IOException { while (isS(ch)) { ch = more(); } // skip additional spaces - if (ch != '=') throw new XmlPullParserException("expected = after attribute name", this, null); + if (ch != '=') { + throw new XmlPullParserException("expected = after attribute name", this, null); + } ch = more(); while (isS(ch)) { ch = more(); @@ -2016,9 +2147,10 @@ private char parseAttribute() throws XmlPullParserException, IOException { // [10] AttValue ::= '"' ([^<&"] | Reference)* '"' // | "'" ([^<&'] | Reference)* "'" final char delimit = ch; - if (delimit != '"' && delimit != '\'') + if (delimit != '"' && delimit != '\'') { throw new XmlPullParserException( "attribute value must start with quotation or apostrophe not " + printable(delimit), this, null); + } // parse until delimit or < and resolve Reference // [67] Reference ::= EntityRef | CharRef // int valueStart = pos + bufAbsoluteStart; @@ -2053,14 +2185,18 @@ private char parseAttribute() throws XmlPullParserException, IOException { } } // assert usePC == true; - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } if (ch != '\n' || !normalizedCR) { pc[pcEnd++] = ' '; // '\n'; } } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } } @@ -2160,7 +2296,7 @@ private int parseCharOrPredefinedEntityRef() throws XmlPullParserException, IOEx char charRef = 0; ch = more(); StringBuilder sb = new StringBuilder(); - boolean isHex = (ch == 'x'); + boolean isHex = ch == 'x'; if (isHex) { // encoded in hex @@ -2300,8 +2436,12 @@ private void parseEntityRefInDocDecl() throws XmlPullParserException, IOExceptio joinPC(); } - if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) return; - if (tokenize) text = null; + if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) { + return; + } + if (tokenize) { + text = null; + } } /** @@ -2323,7 +2463,9 @@ private void parseEntityRef() throws XmlPullParserException, IOException { if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) { return; } - if (tokenize) text = null; + if (tokenize) { + text = null; + } } /** @@ -2351,9 +2493,13 @@ private char[] lookuEntityReplacement(int entityNameLen) { if (hash == entityNameHash[i] && entityNameLen == entityNameBuf[i].length) { final char[] entityBuf = entityNameBuf[i]; for (int j = 0; j < entityNameLen; j++) { - if (buf[posStart + j] != entityBuf[j]) continue LOOP; + if (buf[posStart + j] != entityBuf[j]) { + continue LOOP; + } + } + if (tokenize) { + text = entityReplacement[i]; } - if (tokenize) text = entityReplacement[i]; return entityReplacementBuf[i]; } } @@ -2362,7 +2508,9 @@ private char[] lookuEntityReplacement(int entityNameLen) { for (int i = entityEnd - 1; i >= 0; --i) { // take advantage that interning for newString is enforced if (entityRefName == entityName[i]) { - if (tokenize) text = entityReplacement[i]; + if (tokenize) { + text = entityReplacement[i]; + } return entityReplacementBuf[i]; } } @@ -2375,8 +2523,12 @@ private void parseComment() throws XmlPullParserException, IOException { // ASSUMPTION: seen = pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = cch; if (cch2 != 0) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = cch2; } } @@ -2478,7 +2638,9 @@ private boolean parsePI() throws XmlPullParserException, IOException { // [16] PI ::= '' Char*)))? '?>' // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) // ASSUMPTION: seen = pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -2821,17 +2991,29 @@ private void parseXmlDeclWithVersion(int versionStart, int versionEnd) throws Xm private void parseDocdecl() throws XmlPullParserException, IOException { // ASSUMPTION: seen ' && bracketLevel == 0) break; - else if (ch == '&') { + if (ch == '[') { + ++bracketLevel; + } else if (ch == ']') { + --bracketLevel; + } else if (ch == '>' && bracketLevel == 0) { + break; + } else if (ch == '&') { extractEntityRefInDocDecl(); continue; } @@ -2865,17 +3050,23 @@ else if (ch == '&') { } } // assert usePC == true; - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -2939,17 +3130,29 @@ private void parseCDSect(boolean hadCharData) throws XmlPullParserException, IOE // ASSUMPTION: seen = pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } else if (ch == '\n') { if (!normalizedCR && usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = '\n'; } normalizedCR = false; } else { if (usePC) { - if (pcEnd >= pc.length) ensurePC(pcEnd); + if (pcEnd >= pc.length) { + ensurePC(pcEnd); + } pc[pcEnd++] = ch; } normalizedCR = false; @@ -3044,7 +3253,9 @@ private void parseCDSect(boolean hadCharData) throws XmlPullParserException, IOE } private void fillBuf() throws IOException, XmlPullParserException { - if (reader == null) throw new XmlPullParserException("reader must be set before parsing is started"); + if (reader == null) { + throw new XmlPullParserException("reader must be set before parsing is started"); + } // see if we are in compaction area if (bufEnd > bufSoftLimit) { @@ -3057,15 +3268,18 @@ private void fillBuf() throws IOException, XmlPullParserException { // TODO: look on trashing // //assert bufStart > 0 System.arraycopy(buf, bufStart, buf, 0, bufEnd - bufStart); - if (TRACE_SIZING) + if (TRACE_SIZING) { System.out.println("TRACE_SIZING fillBuf() compacting " + bufStart + " bufEnd=" + bufEnd + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:" + new String(buf, bufStart, Math.min(bufEnd - bufStart, 100))); + } } else { final int newSize = 2 * buf.length; final char[] newBuf = new char[newSize]; - if (TRACE_SIZING) System.out.println("TRACE_SIZING fillBuf() " + buf.length + " => " + newSize); + if (TRACE_SIZING) { + System.out.println("TRACE_SIZING fillBuf() " + buf.length + " => " + newSize); + } System.arraycopy(buf, bufStart, newBuf, 0, bufEnd - bufStart); buf = newBuf; if (bufLoadFactor > 0) { @@ -3080,19 +3294,21 @@ private void fillBuf() throws IOException, XmlPullParserException { posEnd -= bufStart; bufAbsoluteStart += bufStart; bufStart = 0; - if (TRACE_SIZING) + if (TRACE_SIZING) { System.out.println("TRACE_SIZING fillBuf() after bufEnd=" + bufEnd + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:" + new String(buf, 0, Math.min(bufEnd, 100))); + } } // at least one character must be read or error final int len = Math.min(buf.length - bufEnd, READ_CHUNK_SIZE); final int ret = reader.read(buf, bufEnd, len); if (ret > 0) { bufEnd += ret; - if (TRACE_SIZING) + if (TRACE_SIZING) { System.out.println("TRACE_SIZING fillBuf() after filling in buffer" + " buf first 100 chars:" + new String(buf, 0, Math.min(bufEnd, 100))); + } return; } @@ -3102,7 +3318,6 @@ private void fillBuf() throws IOException, XmlPullParserException { } else { if (seenRoot && depth == 0) { // inside parsing epilog!!! reachedEnd = true; - return; } else { StringBuilder expectedTagStack = new StringBuilder(); if (depth > 0) { @@ -3173,7 +3388,9 @@ private char more() throws IOException, XmlPullParserException { if (pos >= bufEnd) { fillBuf(); // this return value should be ignored as it is used in epilog parsing ... - if (reachedEnd) throw new EOFException("no more data available" + getPositionDescription()); + if (reachedEnd) { + throw new EOFException("no more data available" + getPositionDescription()); + } } final char ch = buf[pos++]; // line/columnNumber @@ -3201,8 +3418,9 @@ private void ensurePC(int end) { // assert end >= pc.length; final int newSize = end > READ_CHUNK_SIZE ? 2 * end : 2 * READ_CHUNK_SIZE; final char[] newPC = new char[newSize]; - if (TRACE_SIZING) + if (TRACE_SIZING) { System.out.println("TRACE_SIZING ensurePC() " + pc.length + " ==> " + newSize + " end=" + end); + } System.arraycopy(pc, 0, newPC, 0, pcEnd); pc = newPC; // assert end < pc.length; @@ -3213,8 +3431,10 @@ private void joinPC() { // assert posEnd > posStart; final int len = posEnd - posStart; final int newEnd = pcEnd + len + 1; - if (newEnd >= pc.length) ensurePC(newEnd); // add 1 for extra space for one char - // assert newEnd < pc.length; + if (newEnd >= pc.length) { + ensurePC(newEnd); // add 1 for extra space for one char + // assert newEnd < pc.length; + } System.arraycopy(buf, posStart, pc, pcEnd, len); pcEnd += len; usePC = true; @@ -3266,18 +3486,32 @@ private static void setNameStart(char ch) static { setNameStart(':'); - for (char ch = 'A'; ch <= 'Z'; ++ch) setNameStart(ch); + for (char ch = 'A'; ch <= 'Z'; ++ch) { + setNameStart(ch); + } setNameStart('_'); - for (char ch = 'a'; ch <= 'z'; ++ch) setNameStart(ch); - for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch) setNameStart(ch); - for (char ch = '\u0370'; ch <= '\u037d'; ++ch) setNameStart(ch); - for (char ch = '\u037f'; ch < '\u0400'; ++ch) setNameStart(ch); + for (char ch = 'a'; ch <= 'z'; ++ch) { + setNameStart(ch); + } + for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch) { + setNameStart(ch); + } + for (char ch = '\u0370'; ch <= '\u037d'; ++ch) { + setNameStart(ch); + } + for (char ch = '\u037f'; ch < '\u0400'; ++ch) { + setNameStart(ch); + } setName('-'); setName('.'); - for (char ch = '0'; ch <= '9'; ++ch) setName(ch); + for (char ch = '0'; ch <= '9'; ++ch) { + setName(ch); + } setName('\u00b7'); - for (char ch = '\u0300'; ch <= '\u036f'; ++ch) setName(ch); + for (char ch = '\u0300'; ch <= '\u036f'; ++ch) { + setName(ch); + } } // protected boolean isNameStartChar( char ch ) @@ -3333,7 +3567,7 @@ private static boolean isNameChar(char ch) { } private static boolean isS(char ch) { - return (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'); + return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; // || (supportXml11 && (ch == '\u0085' || ch == '\u2028'); } @@ -3362,14 +3596,15 @@ private static String printable(int ch) { } private static String printable(String s) { - if (s == null) return null; + if (s == null) { + return null; + } final int sLen = s.codePointCount(0, s.length()); StringBuilder buf = new StringBuilder(sLen + 10); for (int i = 0; i < sLen; ++i) { buf.append(printable(s.codePointAt(i))); } - s = buf.toString(); - return s; + return buf.toString(); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java index 54e48dc..0b6841b 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java @@ -170,10 +170,14 @@ protected void ensureElementsCapacity() { String[] arr = null; // reuse arr local variable slot arr = new String[newSize]; - if (needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize); + if (needsCopying) { + System.arraycopy(elName, 0, arr, 0, elStackSize); + } elName = arr; arr = new String[newSize]; - if (needsCopying) System.arraycopy(elNamespace, 0, arr, 0, elStackSize); + if (needsCopying) { + System.arraycopy(elNamespace, 0, arr, 0, elStackSize); + } elNamespace = arr; final int[] iarr = new int[newSize]; @@ -265,7 +269,9 @@ public boolean getFeature(String name) throws IllegalArgumentException { * recomputes buffer after user requested changes. */ protected void rebuildIndentationBuf() { - if (doIndent == false) return; + if (!doIndent) { + return; + } final int maxIndent = 65; // hardcoded maximum indentation size in characters int bufSize = 0; offsetNewLine = 0; @@ -300,7 +306,7 @@ protected void rebuildIndentationBuf() { // if(doIndent) writeIndent(); protected void writeIndent() throws IOException { final int start = writeLineSeparator ? 0 : offsetNewLine; - final int level = (depth > maxIndentLevel) ? maxIndentLevel : depth; + final int level = depth > maxIndentLevel ? maxIndentLevel : depth; out.write(indentationBuf, start, (level * indentationJump) + offsetNewLine); } @@ -361,7 +367,9 @@ public void setOutput(Writer writer) { @Override public void setOutput(OutputStream os, String encoding) throws IOException { - if (os == null) throw new IllegalArgumentException("output stream can not be null"); + if (os == null) { + throw new IllegalArgumentException("output stream can not be null"); + } reset(); if (encoding != null) { out = new OutputStreamWriter(os, encoding); @@ -423,7 +431,9 @@ public void endDocument() throws IOException { @Override public void setPrefix(String prefix, String namespace) throws IOException { - if (startTagIncomplete) closeStartTag(); + if (startTagIncomplete) { + closeStartTag(); + } // assert prefix != null; // assert namespace != null; if (prefix == null) { @@ -487,8 +497,9 @@ public String getPrefix(String namespace, boolean generatePrefix) { final String prefix = namespacePrefix[i]; // now check that prefix is still in scope for (int p = namespaceEnd - 1; p > i; --p) { - if (prefix == namespacePrefix[p]) + if (prefix == namespacePrefix[p]) { continue; // too bad - prefix is redeclared with different namespace + } } return prefix; } @@ -562,12 +573,16 @@ public XmlSerializer startTag(String namespace, String name) throws IOException } //// assert namespace != null; - if (checkNamesInterned && namesInterned) checkInterning(namespace); - elNamespace[depth] = (namesInterned || namespace == null) ? namespace : namespace.intern(); + if (checkNamesInterned && namesInterned) { + checkInterning(namespace); + } + elNamespace[depth] = namesInterned || namespace == null ? namespace : namespace.intern(); // assert name != null; // elName[ depth ] = name; - if (checkNamesInterned && namesInterned) checkInterning(name); - elName[depth] = (namesInterned || name == null) ? name : name.intern(); + if (checkNamesInterned && namesInterned) { + checkInterning(name); + } + elName[depth] = namesInterned || name == null ? name : name.intern(); if (out == null) { throw new IllegalStateException("setOutput() must called set before serialization can start"); } @@ -776,24 +791,36 @@ public XmlSerializer endTag(String namespace, String name) throws IOException { @Override public XmlSerializer text(String text) throws IOException { // assert text != null; - if (startTagIncomplete || setPrefixCalled) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } writeElementContent(text, out); return this; } @Override public XmlSerializer text(char[] buf, int start, int len) throws IOException { - if (startTagIncomplete || setPrefixCalled) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } writeElementContent(buf, start, len, out); return this; } @Override public void cdsect(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } out.write(""); @@ -801,8 +828,12 @@ public void cdsect(String text) throws IOException { @Override public void entityRef(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } out.write('&'); out.write(text); // escape? out.write(';'); @@ -810,8 +841,12 @@ public void entityRef(String text) throws IOException { @Override public void processingInstruction(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } out.write(""); @@ -819,8 +854,12 @@ public void processingInstruction(String text) throws IOException { @Override public void comment(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } out.write(""); @@ -828,8 +867,12 @@ public void comment(String text) throws IOException { @Override public void docdecl(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } out.write(""); @@ -837,8 +880,12 @@ public void docdecl(String text) throws IOException { @Override public void ignorableWhitespace(String text) throws IOException { - if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); - if (doIndent && seenTag) seenTag = false; + if (startTagIncomplete || setPrefixCalled || seenBracket) { + closeStartTag(); + } + if (doIndent && seenTag) { + seenTag = false; + } if (text.length() == 0) { throw new IllegalArgumentException("empty string is not allowed for ignorable whitespace" + getLocation()); } @@ -847,7 +894,9 @@ public void ignorableWhitespace(String text) throws IOException { @Override public void flush() throws IOException { - if (!finished && startTagIncomplete) closeStartTag(); + if (!finished && startTagIncomplete) { + closeStartTag(); + } out.flush(); } @@ -865,23 +914,31 @@ protected void writeAttributeValue(String value, Writer out) throws IOException for (int i = 0; i < value.length(); i++) { char ch = value.charAt(i); if (ch == '&') { - if (i > pos) out.write(value.substring(pos, i)); + if (i > pos) { + out.write(value.substring(pos, i)); + } out.write("&"); pos = i + 1; } if (ch == '<') { - if (i > pos) out.write(value.substring(pos, i)); + if (i > pos) { + out.write(value.substring(pos, i)); + } out.write("<"); pos = i + 1; } else if (ch == quot) { - if (i > pos) out.write(value.substring(pos, i)); + if (i > pos) { + out.write(value.substring(pos, i)); + } out.write(quotEntity); pos = i + 1; } else if (ch < 32) { // in XML 1.0 only legal character are #x9 | #xA | #xD // and they must be escaped otherwise in attribute value they are normalized to spaces if (ch == 13 || ch == 10 || ch == 9) { - if (i > pos) out.write(value.substring(pos, i)); + if (i > pos) { + out.write(value.substring(pos, i)); + } out.write("&#"); out.write(Integer.toString(ch)); out.write(';'); @@ -927,15 +984,21 @@ protected void writeElementContent(String text, Writer out) throws IOException { } } else { if (ch == '&') { - if (i > pos) out.write(text.substring(pos, i)); + if (i > pos) { + out.write(text.substring(pos, i)); + } out.write("&"); pos = i + 1; } else if (ch == '<') { - if (i > pos) out.write(text.substring(pos, i)); + if (i > pos) { + out.write(text.substring(pos, i)); + } out.write("<"); pos = i + 1; } else if (seenBracketBracket && ch == '>') { - if (i > pos) out.write(text.substring(pos, i)); + if (i > pos) { + out.write(text.substring(pos, i)); + } out.write(">"); pos = i + 1; } else if (ch < 32) { @@ -951,7 +1014,9 @@ protected void writeElementContent(String text, Writer out) throws IOException { // pos = i + 1; } else { // skip special char - if (i > pos) out.write(text.substring(pos, i)); + if (i > pos) { + out.write(text.substring(pos, i)); + } pos = i + 1; } } @@ -1040,8 +1105,10 @@ protected void writeElementContent(char[] buf, int off, int len, Writer out) thr } // simple utility method -- good for debugging - protected static final String printable(String s) { - if (s == null) return "null"; + protected static String printable(String s) { + if (s == null) { + return "null"; + } StringBuilder retval = new StringBuilder(s.length() + 16); retval.append("'"); char ch; @@ -1052,7 +1119,7 @@ protected static final String printable(String s) { return retval.toString(); } - protected static final String printable(char ch) { + protected static String printable(char ch) { StringBuilder retval = new StringBuilder(); addPrintable(retval, ch); return retval.toString(); diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java index c5d8bd9..5af9636 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -160,7 +160,7 @@ void testendElementAlreadyClosed() { writer.endElement(); // Tag.DIV already closed, and there is no other outer tag! fail("Should throw a NoSuchElementException"); } catch (NoSuchElementException e) { - assert (true); + assert true; } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java index 2e59ab9..4d444e3 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -66,7 +66,7 @@ private static void checkXmlContent(String xml, String encoding) throws IOExcept private static void checkXmlWriter(String text, String encoding) throws IOException { String xml = createXmlContent(text, encoding); - String effectiveEncoding = (encoding == null) ? "UTF-8" : encoding; + String effectiveEncoding = encoding == null ? "UTF-8" : encoding; checkXmlContent(xml, effectiveEncoding); } diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java index 2e1fd7f..e63b1f6 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java @@ -47,8 +47,7 @@ void setUp() { void testibm_not_wf_P24_ibm24n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n01.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with a required field missing. The VersionNum is missing in the VersionInfo in the XMLDecl."); } catch (XmlPullParserException e) { @@ -70,8 +69,7 @@ void testibm_not_wf_P24_ibm24n01xml() throws IOException { void testibm_not_wf_P24_ibm24n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n02.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with a required field missing. The white space is missing between the key word \"xml\" and the VersionInfo in the XMLDecl."); } catch (XmlPullParserException e) { @@ -92,8 +90,7 @@ void testibm_not_wf_P24_ibm24n02xml() throws IOException { void testibm_not_wf_P24_ibm24n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n03.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with a required field missing. The \"=\" (equal sign) is missing between the key word \"version\" and the VersionNum."); } catch (XmlPullParserException e) { @@ -114,8 +111,7 @@ void testibm_not_wf_P24_ibm24n03xml() throws IOException { void testibm_not_wf_P24_ibm24n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n04.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with wrong field ordering. The VersionNum occurs before \"=\" and \"version\"."); } catch (XmlPullParserException e) { @@ -136,8 +132,7 @@ void testibm_not_wf_P24_ibm24n04xml() throws IOException { void testibm_not_wf_P24_ibm24n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n05.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with wrong field ordering. The \"=\" occurs after \"version\" and the VersionNum."); } catch (XmlPullParserException e) { @@ -158,8 +153,7 @@ void testibm_not_wf_P24_ibm24n05xml() throws IOException { void testibm_not_wf_P24_ibm24n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n06.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests VersionInfo with the wrong key word \"Version\"."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected v in version and not V")); @@ -179,8 +173,7 @@ void testibm_not_wf_P24_ibm24n06xml() throws IOException { void testibm_not_wf_P24_ibm24n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n07.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests VersionInfo with the wrong key word \"versioN\"."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected n in version and not N")); @@ -200,8 +193,7 @@ void testibm_not_wf_P24_ibm24n07xml() throws IOException { void testibm_not_wf_P24_ibm24n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n08.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with mismatched quotes around the VersionNum. version = '1.0\" is used as the VersionInfo."); } catch (XmlPullParserException e) { @@ -222,8 +214,7 @@ void testibm_not_wf_P24_ibm24n08xml() throws IOException { void testibm_not_wf_P24_ibm24n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n09.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests VersionInfo with mismatched quotes around the VersionNum. The closing bracket for the VersionNum is missing."); } catch (XmlPullParserException e) { diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java index c4150ed..c392aba 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java @@ -56,8 +56,7 @@ void setUp() { void testibm_not_wf_P02_ibm02n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n01.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x00"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x0 found in comment")); @@ -77,8 +76,7 @@ void testibm_not_wf_P02_ibm02n01xml() throws IOException { void testibm_not_wf_P02_ibm02n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n02.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x01"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1 found in comment")); @@ -98,8 +96,7 @@ void testibm_not_wf_P02_ibm02n02xml() throws IOException { void testibm_not_wf_P02_ibm02n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n03.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x02"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x2 found in comment")); @@ -119,8 +116,7 @@ void testibm_not_wf_P02_ibm02n03xml() throws IOException { void testibm_not_wf_P02_ibm02n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n04.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x03"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x3 found in comment")); @@ -140,8 +136,7 @@ void testibm_not_wf_P02_ibm02n04xml() throws IOException { void testibm_not_wf_P02_ibm02n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n05.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x04"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x4 found in comment")); @@ -161,8 +156,7 @@ void testibm_not_wf_P02_ibm02n05xml() throws IOException { void testibm_not_wf_P02_ibm02n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n06.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x05"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x5 found in comment")); @@ -182,8 +176,7 @@ void testibm_not_wf_P02_ibm02n06xml() throws IOException { void testibm_not_wf_P02_ibm02n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x06"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x6 found in comment")); @@ -203,8 +196,7 @@ void testibm_not_wf_P02_ibm02n07xml() throws IOException { void testibm_not_wf_P02_ibm02n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n08.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x07"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x7 found in comment")); @@ -224,8 +216,7 @@ void testibm_not_wf_P02_ibm02n08xml() throws IOException { void testibm_not_wf_P02_ibm02n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n09.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x08"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x8 found in comment")); @@ -245,8 +236,7 @@ void testibm_not_wf_P02_ibm02n09xml() throws IOException { void testibm_not_wf_P02_ibm02n10xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n10.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x0B"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xb found in comment")); @@ -266,8 +256,7 @@ void testibm_not_wf_P02_ibm02n10xml() throws IOException { void testibm_not_wf_P02_ibm02n11xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n11.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x0C"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xc found in comment")); @@ -287,8 +276,7 @@ void testibm_not_wf_P02_ibm02n11xml() throws IOException { void testibm_not_wf_P02_ibm02n12xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n12.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x0E"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xe found in comment")); @@ -308,8 +296,7 @@ void testibm_not_wf_P02_ibm02n12xml() throws IOException { void testibm_not_wf_P02_ibm02n13xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n13.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x0F"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xf found in comment")); @@ -329,8 +316,7 @@ void testibm_not_wf_P02_ibm02n13xml() throws IOException { void testibm_not_wf_P02_ibm02n14xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n14.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x10"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x10 found in comment")); @@ -350,8 +336,7 @@ void testibm_not_wf_P02_ibm02n14xml() throws IOException { void testibm_not_wf_P02_ibm02n15xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n15.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x11"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x11 found in comment")); @@ -371,8 +356,7 @@ void testibm_not_wf_P02_ibm02n15xml() throws IOException { void testibm_not_wf_P02_ibm02n16xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n16.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x12"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x12 found in comment")); @@ -392,8 +376,7 @@ void testibm_not_wf_P02_ibm02n16xml() throws IOException { void testibm_not_wf_P02_ibm02n17xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n17.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x13"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x13 found in comment")); @@ -413,8 +396,7 @@ void testibm_not_wf_P02_ibm02n17xml() throws IOException { void testibm_not_wf_P02_ibm02n18xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n18.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x14"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x14 found in comment")); @@ -434,8 +416,7 @@ void testibm_not_wf_P02_ibm02n18xml() throws IOException { void testibm_not_wf_P02_ibm02n19xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n19.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x15"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x15 found in comment")); @@ -455,8 +436,7 @@ void testibm_not_wf_P02_ibm02n19xml() throws IOException { void testibm_not_wf_P02_ibm02n20xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n20.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x16"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x16 found in comment")); @@ -476,8 +456,7 @@ void testibm_not_wf_P02_ibm02n20xml() throws IOException { void testibm_not_wf_P02_ibm02n21xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n21.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x17"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x17 found in comment")); @@ -497,8 +476,7 @@ void testibm_not_wf_P02_ibm02n21xml() throws IOException { void testibm_not_wf_P02_ibm02n22xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n22.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x18"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x18 found in comment")); @@ -518,8 +496,7 @@ void testibm_not_wf_P02_ibm02n22xml() throws IOException { void testibm_not_wf_P02_ibm02n23xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n23.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x19"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x19 found in comment")); @@ -539,8 +516,7 @@ void testibm_not_wf_P02_ibm02n23xml() throws IOException { void testibm_not_wf_P02_ibm02n24xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n24.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1A"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1a found in comment")); @@ -560,8 +536,7 @@ void testibm_not_wf_P02_ibm02n24xml() throws IOException { void testibm_not_wf_P02_ibm02n25xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n25.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1B"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1b found in comment")); @@ -581,8 +556,7 @@ void testibm_not_wf_P02_ibm02n25xml() throws IOException { void testibm_not_wf_P02_ibm02n26xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n26.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1C"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1c found in comment")); @@ -602,8 +576,7 @@ void testibm_not_wf_P02_ibm02n26xml() throws IOException { void testibm_not_wf_P02_ibm02n27xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n27.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1D"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1d found in comment")); @@ -623,8 +596,7 @@ void testibm_not_wf_P02_ibm02n27xml() throws IOException { void testibm_not_wf_P02_ibm02n28xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n28.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1E"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1e found in comment")); @@ -644,8 +616,7 @@ void testibm_not_wf_P02_ibm02n28xml() throws IOException { void testibm_not_wf_P02_ibm02n29xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n29.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #x1F"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0x1f found in comment")); @@ -670,8 +641,7 @@ public void testibm_not_wf_P02_ibm02n30xml() throws IOException { Paths.get(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"), Charset.forName("ISO-8859-15"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #xD800"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xd800 found in comment")); @@ -695,8 +665,7 @@ public void testibm_not_wf_P02_ibm02n31xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n31.xml")); InputStreamReader reader = new InputStreamReader(is, "ISO-8859-15")) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #xDFFF"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xdfff found in comment")); @@ -717,8 +686,7 @@ void testibm_not_wf_P02_ibm02n32xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n32.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #xFFFE"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xfffe found in comment")); @@ -739,8 +707,7 @@ void testibm_not_wf_P02_ibm02n33xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n33.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests a comment which contains an illegal Char: #xFFFF"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("Illegal character 0xffff found in comment")); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java index cfc2c53..aa6f42b 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java @@ -49,8 +49,7 @@ void setUp() { void testibm_not_wf_P32_ibm32n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n01.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests SDDecl with a required field missing. The leading white space is missing with the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -71,8 +70,7 @@ void testibm_not_wf_P32_ibm32n01xml() throws IOException { void testibm_not_wf_P32_ibm32n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n02.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests SDDecl with a required field missing. The \"=\" sign is missing in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -93,8 +91,7 @@ void testibm_not_wf_P32_ibm32n02xml() throws IOException { void testibm_not_wf_P32_ibm32n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n03.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests SDDecl with wrong key word. The word \"Standalone\" occurs in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("unexpected character S")); @@ -114,8 +111,7 @@ void testibm_not_wf_P32_ibm32n03xml() throws IOException { void testibm_not_wf_P32_ibm32n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n04.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests SDDecl with wrong key word. The word \"Yes\" occurs in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not Y")); @@ -136,8 +132,7 @@ void testibm_not_wf_P32_ibm32n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n05.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests SDDecl with wrong key word. The word \"YES\" occurs in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not Y")); @@ -157,8 +152,7 @@ void testibm_not_wf_P32_ibm32n05xml() throws IOException { void testibm_not_wf_P32_ibm32n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n06.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests SDDecl with wrong key word. The word \"No\" occurs in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not N")); @@ -178,8 +172,7 @@ void testibm_not_wf_P32_ibm32n06xml() throws IOException { void testibm_not_wf_P32_ibm32n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n07.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("Tests SDDecl with wrong key word. The word \"NO\" occurs in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not N")); @@ -199,8 +192,7 @@ void testibm_not_wf_P32_ibm32n07xml() throws IOException { void testibm_not_wf_P32_ibm32n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n08.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests SDDecl with wrong field ordering. The \"=\" sign occurs after the key word \"yes\" in the SDDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -224,8 +216,7 @@ void testibm_not_wf_P32_ibm32n08xml() throws IOException { public void testibm_not_wf_P32_ibm32n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n09.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "This is test violates WFC: Entity Declared in P68. The standalone document declaration has the value yes, BUT there is an external markup declaration of an entity (other than amp, lt, gt, apos, quot), and references to this entity appear in the document."); } catch (XmlPullParserException e) { diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java index c08b114..41c5ede 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java @@ -48,8 +48,7 @@ void setUp() { void testibm_not_wf_P66_ibm66n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n01.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#002f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -70,8 +69,7 @@ void testibm_not_wf_P66_ibm66n01xml() throws IOException { void testibm_not_wf_P66_ibm66n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n02.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with the semicolon character missing. The semicolon character is missing at the end of the CharRef in the attribute value in the STag of element \"root\"."); } catch (XmlPullParserException e) { @@ -92,8 +90,7 @@ void testibm_not_wf_P66_ibm66n02xml() throws IOException { void testibm_not_wf_P66_ibm66n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n03.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"49\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -114,8 +111,7 @@ void testibm_not_wf_P66_ibm66n03xml() throws IOException { void testibm_not_wf_P66_ibm66n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n04.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#5~0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -138,8 +134,7 @@ void testibm_not_wf_P66_ibm66n04xml() throws IOException { void testibm_not_wf_P66_ibm66n05xml() throws FileNotFoundException, IOException, XmlPullParserException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n05.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#x002g\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -160,8 +155,7 @@ void testibm_not_wf_P66_ibm66n05xml() throws FileNotFoundException, IOException, void testibm_not_wf_P66_ibm66n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n06.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#x006G\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -182,8 +176,7 @@ void testibm_not_wf_P66_ibm66n06xml() throws IOException { void testibm_not_wf_P66_ibm66n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n07.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#0=2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -204,8 +197,7 @@ void testibm_not_wf_P66_ibm66n07xml() throws IOException { void testibm_not_wf_P66_ibm66n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n08.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#56.0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -226,8 +218,7 @@ void testibm_not_wf_P66_ibm66n08xml() throws IOException { void testibm_not_wf_P66_ibm66n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n09.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#x00/2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -248,8 +239,7 @@ void testibm_not_wf_P66_ibm66n09xml() throws IOException { void testibm_not_wf_P66_ibm66n10xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n10.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#51)\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -270,8 +260,7 @@ void testibm_not_wf_P66_ibm66n10xml() throws IOException { void testibm_not_wf_P66_ibm66n11xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n11.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#00 2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); } catch (XmlPullParserException e) { @@ -292,8 +281,7 @@ void testibm_not_wf_P66_ibm66n11xml() throws IOException { void testibm_not_wf_P66_ibm66n12xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n12.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#x0000\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -314,8 +302,7 @@ void testibm_not_wf_P66_ibm66n12xml() throws IOException { void testibm_not_wf_P66_ibm66n13xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n13.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#x001f\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -336,8 +323,7 @@ void testibm_not_wf_P66_ibm66n13xml() throws IOException { void testibm_not_wf_P66_ibm66n14xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n14.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#xfffe\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { @@ -358,8 +344,7 @@ void testibm_not_wf_P66_ibm66n14xml() throws IOException { void testibm_not_wf_P66_ibm66n15xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n15.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests CharRef with an illegal character referred to. The \"#xffff\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); } catch (XmlPullParserException e) { diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java index a2b2c16..18c0020 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java @@ -47,8 +47,7 @@ void setUp() { void testibm_not_wf_P80_ibm80n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n01.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with a required field missing. The leading white space is missing in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -69,8 +68,7 @@ void testibm_not_wf_P80_ibm80n01xml() throws IOException { void testibm_not_wf_P80_ibm80n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n02.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with a required field missing. The \"=\" sign is missing in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -91,8 +89,7 @@ void testibm_not_wf_P80_ibm80n02xml() throws IOException { void testibm_not_wf_P80_ibm80n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n03.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with a required field missing. The double quoted EncName are missing in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -114,8 +111,7 @@ void testibm_not_wf_P80_ibm80n03xml() throws IOException { void testibm_not_wf_P80_ibm80n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n04.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with wrong field ordering. The string \"encoding=\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -136,8 +132,7 @@ void testibm_not_wf_P80_ibm80n04xml() throws IOException { void testibm_not_wf_P80_ibm80n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n05.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with wrong field ordering. The \"encoding\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { @@ -158,8 +153,7 @@ void testibm_not_wf_P80_ibm80n05xml() throws IOException { void testibm_not_wf_P80_ibm80n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n06.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail( "Tests EncodingDecl with wrong key word. The string \"Encoding\" is used as the key word in the EncodingDecl in the XMLDecl."); } catch (XmlPullParserException e) { diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java index 6cead6d..39d4633 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java @@ -870,8 +870,7 @@ void encodingISO88591setInputReader() throws IOException { ReaderFactory.newXmlReader(new File("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); @@ -891,8 +890,7 @@ void encodingISO88591SetInputStream() throws IOException { Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(input, null); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); @@ -920,8 +918,7 @@ void encodingISO88591setStringReader() throws IOException { MXParser parser = new MXParser(); String xmlFileContents = readAllFrom(reader); parser.setInput(new StringReader(xmlFileContents)); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); @@ -947,8 +944,7 @@ void encodingISO88591newReader() throws IOException { StandardCharsets.UTF_8)) { MXParser parser = new MXParser(); parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); @@ -970,8 +966,7 @@ void encodingISO88591setInputStreamEncoded() throws IOException { Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(input, StandardCharsets.UTF_8.name()); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); @@ -990,8 +985,7 @@ void encodingUTF8newXmlReader() throws IOException { try (Reader reader = new XmlStreamReader(new File("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} assertTrue(true); } catch (XmlPullParserException e) { fail("should not raise exception: " + e); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java index ab26ab0..3ef379d 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java @@ -50,8 +50,7 @@ void setUp() { void testhst_bh_001() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "001.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("decimal charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("character reference (with hex value FF000000F6) is invalid")); @@ -71,8 +70,7 @@ void testhst_bh_001() throws IOException { void testhst_bh_002() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "002.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("hex charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("character reference (with decimal value 4294967542) is invalid")); @@ -92,8 +90,7 @@ void testhst_bh_002() throws IOException { void testhst_bh_003() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "003.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("decimal charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("character reference (with hex value FFFFFFFF000000F6) is invalid")); @@ -113,8 +110,7 @@ void testhst_bh_003() throws IOException { void testhst_bh_004() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "004.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("hex charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow"); } catch (XmlPullParserException e) { assertTrue(e.getMessage() @@ -138,8 +134,7 @@ void testhst_bh_004() throws IOException { public void testhst_bh_005() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "005.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("xmlns:xml is an attribute as far as validation is concerned and must be declared"); } catch (XmlPullParserException e) { assertTrue(true); @@ -162,8 +157,7 @@ public void testhst_bh_005() throws IOException { public void testhst_bh_006() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "006.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("xmlns:foo is an attribute as far as validation is concerned and must be declared"); } catch (XmlPullParserException e) { assertTrue(true); @@ -183,8 +177,7 @@ public void testhst_bh_006() throws IOException { void testhst_lhs_007() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "007.xml"))) { parser.setInput(is, null); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("UTF-8 BOM plus xml decl of ISO-8859-1 incompatible"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("UTF-8 BOM plus xml decl of ISO-8859-1 is incompatible")); @@ -204,8 +197,7 @@ void testhst_lhs_007() throws IOException { void testhst_lhs_008() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "008.xml"))) { parser.setInput(is, null); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("UTF-16 BOM plus xml decl of UTF-8 (using UTF-16 coding) incompatible"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("UTF-16 BOM in a UTF-8 encoded file is incompatible")); @@ -225,8 +217,7 @@ void testhst_lhs_008() throws IOException { void testhst_lhs_009() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "009.xml"))) { parser.setInput(is, null); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {} fail("UTF-16 BOM plus xml decl of UTF-8 (using UTF-8 coding) incompatible"); } catch (XmlPullParserException e) { assertTrue(e.getMessage().contains("UTF-16 BOM in a UTF-8 encoded file is incompatible"), e.getMessage());