[Minor] fixed compiler warnings

This commit is contained in:
Robert von Burg 2013-09-15 21:43:52 +02:00
parent c7ba5054de
commit f9c613ca46
2 changed files with 194 additions and 138 deletions

View File

@ -101,21 +101,24 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
/** newLine followed by copies of indent. */
private char[] linePrefix = null;
public void setIndent(String indent) {
@Override
public void setIndent(String indent) {
if (!indent.equals(this.indent)) {
this.indent = indent;
linePrefix = null;
this.linePrefix = null;
}
}
public String getIndent() {
return indent;
@Override
public String getIndent() {
return this.indent;
}
public void setNewLine(String newLine) {
@Override
public void setNewLine(String newLine) {
if (!newLine.equals(this.newLine)) {
this.newLine = newLine;
linePrefix = null;
this.linePrefix = null;
}
}
@ -127,141 +130,162 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
try {
return System.getProperty("line.separator");
} catch (SecurityException ignored) {
//
}
return NORMAL_END_OF_LINE;
}
public String getNewLine() {
return newLine;
@Override
public String getNewLine() {
return this.newLine;
}
public void writeStartDocument() throws XMLStreamException {
@Override
public void writeStartDocument() throws XMLStreamException {
beforeMarkup();
out.writeStartDocument();
this.out.writeStartDocument();
afterMarkup();
}
public void writeStartDocument(String version) throws XMLStreamException {
@Override
public void writeStartDocument(String version) throws XMLStreamException {
beforeMarkup();
out.writeStartDocument(version);
this.out.writeStartDocument(version);
afterMarkup();
}
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
@Override
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
beforeMarkup();
out.writeStartDocument(encoding, version);
this.out.writeStartDocument(encoding, version);
afterMarkup();
}
public void writeDTD(String dtd) throws XMLStreamException {
@Override
public void writeDTD(String dtd) throws XMLStreamException {
beforeMarkup();
out.writeDTD(dtd);
this.out.writeDTD(dtd);
afterMarkup();
}
public void writeProcessingInstruction(String target) throws XMLStreamException {
@Override
public void writeProcessingInstruction(String target) throws XMLStreamException {
beforeMarkup();
out.writeProcessingInstruction(target);
this.out.writeProcessingInstruction(target);
afterMarkup();
}
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
@Override
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
beforeMarkup();
out.writeProcessingInstruction(target, data);
this.out.writeProcessingInstruction(target, data);
afterMarkup();
}
public void writeComment(String data) throws XMLStreamException {
@Override
public void writeComment(String data) throws XMLStreamException {
beforeMarkup();
out.writeComment(data);
this.out.writeComment(data);
afterMarkup();
}
public void writeEmptyElement(String localName) throws XMLStreamException {
@Override
public void writeEmptyElement(String localName) throws XMLStreamException {
beforeMarkup();
out.writeEmptyElement(localName);
this.out.writeEmptyElement(localName);
afterMarkup();
}
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
@Override
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
beforeMarkup();
out.writeEmptyElement(namespaceURI, localName);
this.out.writeEmptyElement(namespaceURI, localName);
afterMarkup();
}
public void writeEmptyElement(String prefix, String localName, String namespaceURI)
@Override
public void writeEmptyElement(String prefix, String localName, String namespaceURI)
throws XMLStreamException {
beforeMarkup();
out.writeEmptyElement(prefix, localName, namespaceURI);
this.out.writeEmptyElement(prefix, localName, namespaceURI);
afterMarkup();
}
public void writeStartElement(String localName) throws XMLStreamException {
@Override
public void writeStartElement(String localName) throws XMLStreamException {
beforeStartElement();
out.writeStartElement(localName);
this.out.writeStartElement(localName);
afterStartElement();
}
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
@Override
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
beforeStartElement();
out.writeStartElement(namespaceURI, localName);
this.out.writeStartElement(namespaceURI, localName);
afterStartElement();
}
public void writeStartElement(String prefix, String localName, String namespaceURI)
@Override
public void writeStartElement(String prefix, String localName, String namespaceURI)
throws XMLStreamException {
beforeStartElement();
out.writeStartElement(prefix, localName, namespaceURI);
this.out.writeStartElement(prefix, localName, namespaceURI);
afterStartElement();
}
public void writeCharacters(String text) throws XMLStreamException {
out.writeCharacters(text);
@Override
public void writeCharacters(String text) throws XMLStreamException {
this.out.writeCharacters(text);
afterData();
}
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
out.writeCharacters(text, start, len);
@Override
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
this.out.writeCharacters(text, start, len);
afterData();
}
public void writeCData(String data) throws XMLStreamException {
out.writeCData(data);
@Override
public void writeCData(String data) throws XMLStreamException {
this.out.writeCData(data);
afterData();
}
public void writeEntityRef(String name) throws XMLStreamException {
out.writeEntityRef(name);
@Override
public void writeEntityRef(String name) throws XMLStreamException {
this.out.writeEntityRef(name);
afterData();
}
public void writeEndElement() throws XMLStreamException {
@Override
public void writeEndElement() throws XMLStreamException {
beforeEndElement();
out.writeEndElement();
this.out.writeEndElement();
afterEndElement();
}
public void writeEndDocument() throws XMLStreamException {
@Override
public void writeEndDocument() throws XMLStreamException {
try {
while (depth > 0) {
while (this.depth > 0) {
writeEndElement(); // indented
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
out.writeEndDocument();
this.out.writeEndDocument();
afterEndDocument();
}
/** Prepare to write markup, by writing a new line and indentation. */
protected void beforeMarkup() {
int soFar = stack[depth];
int soFar = this.stack[this.depth];
if ((soFar & WROTE_DATA) == 0 // no data in this scope
&& (depth > 0 || soFar != 0)) // not the first line
&& (this.depth > 0 || soFar != 0)) // not the first line
{
try {
writeNewLine(depth);
if (depth > 0 && getIndent().length() > 0) {
writeNewLine(this.depth);
if (this.depth > 0 && getIndent().length() > 0) {
afterMarkup(); // indentation was written
}
} catch (Exception e) {
@ -272,37 +296,37 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
/** Note that markup or indentation was written. */
protected void afterMarkup() {
stack[depth] |= WROTE_MARKUP;
this.stack[this.depth] |= WROTE_MARKUP;
}
/** Note that data were written. */
protected void afterData() {
stack[depth] |= WROTE_DATA;
this.stack[this.depth] |= WROTE_DATA;
}
/** Prepare to start an element, by allocating stack space. */
protected void beforeStartElement() {
beforeMarkup();
if (stack.length <= depth + 1) {
if (this.stack.length <= this.depth + 1) {
// Allocate more space for the stack:
int[] newStack = new int[stack.length * 2];
System.arraycopy(stack, 0, newStack, 0, stack.length);
stack = newStack;
int[] newStack = new int[this.stack.length * 2];
System.arraycopy(this.stack, 0, newStack, 0, this.stack.length);
this.stack = newStack;
}
stack[depth + 1] = 0; // nothing written yet
this.stack[this.depth + 1] = 0; // nothing written yet
}
/** Note that an element was started. */
protected void afterStartElement() {
afterMarkup();
++depth;
++this.depth;
}
/** Prepare to end an element, by writing a new line and indentation. */
protected void beforeEndElement() {
if (depth > 0 && stack[depth] == WROTE_MARKUP) { // but not data
if (this.depth > 0 && this.stack[this.depth] == WROTE_MARKUP) { // but not data
try {
writeNewLine(depth - 1);
writeNewLine(this.depth - 1);
} catch (Exception ignored) {
ignored.printStackTrace();
}
@ -311,21 +335,21 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
/** Note that an element was ended. */
protected void afterEndElement() {
if (depth > 0) {
--depth;
if (this.depth > 0) {
--this.depth;
}
}
/** Note that a document was ended. */
protected void afterEndDocument() {
if (stack[depth = 0] == WROTE_MARKUP) { // but not data
if (this.stack[this.depth = 0] == WROTE_MARKUP) { // but not data
try {
writeNewLine(0);
} catch (Exception ignored) {
ignored.printStackTrace();
}
}
stack[depth] = 0; // start fresh
this.stack[this.depth] = 0; // start fresh
}
/** Write a line separator followed by indentation. */
@ -333,19 +357,19 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
final int newLineLength = getNewLine().length();
final int prefixLength = newLineLength + (getIndent().length() * indentation);
if (prefixLength > 0) {
if (linePrefix == null) {
linePrefix = (getNewLine() + getIndent()).toCharArray();
if (this.linePrefix == null) {
this.linePrefix = (getNewLine() + getIndent()).toCharArray();
}
while (prefixLength > linePrefix.length) {
while (prefixLength > this.linePrefix.length) {
// make linePrefix longer:
char[] newPrefix = new char[newLineLength
+ ((linePrefix.length - newLineLength) * 2)];
System.arraycopy(linePrefix, 0, newPrefix, 0, linePrefix.length);
System.arraycopy(linePrefix, newLineLength, newPrefix, linePrefix.length,
linePrefix.length - newLineLength);
linePrefix = newPrefix;
+ ((this.linePrefix.length - newLineLength) * 2)];
System.arraycopy(this.linePrefix, 0, newPrefix, 0, this.linePrefix.length);
System.arraycopy(this.linePrefix, newLineLength, newPrefix, this.linePrefix.length,
this.linePrefix.length - newLineLength);
this.linePrefix = newPrefix;
}
out.writeCharacters(linePrefix, 0, prefixLength);
this.out.writeCharacters(this.linePrefix, 0, prefixLength);
}
}

View File

@ -50,136 +50,168 @@ public abstract class StreamWriterDelegate implements XMLStreamWriter {
protected XMLStreamWriter out;
public Object getProperty(String name) throws IllegalArgumentException {
return out.getProperty(name);
@Override
public Object getProperty(String name) throws IllegalArgumentException {
return this.out.getProperty(name);
}
public NamespaceContext getNamespaceContext() {
return out.getNamespaceContext();
@Override
public NamespaceContext getNamespaceContext() {
return this.out.getNamespaceContext();
}
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
out.setNamespaceContext(context);
@Override
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
this.out.setNamespaceContext(context);
}
public void setDefaultNamespace(String uri) throws XMLStreamException {
out.setDefaultNamespace(uri);
@Override
public void setDefaultNamespace(String uri) throws XMLStreamException {
this.out.setDefaultNamespace(uri);
}
public void writeStartDocument() throws XMLStreamException {
out.writeStartDocument();
@Override
public void writeStartDocument() throws XMLStreamException {
this.out.writeStartDocument();
}
public void writeStartDocument(String version) throws XMLStreamException {
out.writeStartDocument(version);
@Override
public void writeStartDocument(String version) throws XMLStreamException {
this.out.writeStartDocument(version);
}
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
out.writeStartDocument(encoding, version);
@Override
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
this.out.writeStartDocument(encoding, version);
}
public void writeDTD(String dtd) throws XMLStreamException {
out.writeDTD(dtd);
@Override
public void writeDTD(String dtd) throws XMLStreamException {
this.out.writeDTD(dtd);
}
public void writeProcessingInstruction(String target) throws XMLStreamException {
out.writeProcessingInstruction(target);
@Override
public void writeProcessingInstruction(String target) throws XMLStreamException {
this.out.writeProcessingInstruction(target);
}
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
out.writeProcessingInstruction(target, data);
@Override
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
this.out.writeProcessingInstruction(target, data);
}
public void writeComment(String data) throws XMLStreamException {
out.writeComment(data);
@Override
public void writeComment(String data) throws XMLStreamException {
this.out.writeComment(data);
}
public void writeEmptyElement(String localName) throws XMLStreamException {
out.writeEmptyElement(localName);
@Override
public void writeEmptyElement(String localName) throws XMLStreamException {
this.out.writeEmptyElement(localName);
}
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
out.writeEmptyElement(namespaceURI, localName);
@Override
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
this.out.writeEmptyElement(namespaceURI, localName);
}
public void writeEmptyElement(String prefix, String localName, String namespaceURI)
@Override
public void writeEmptyElement(String prefix, String localName, String namespaceURI)
throws XMLStreamException {
out.writeEmptyElement(prefix, localName, namespaceURI);
this.out.writeEmptyElement(prefix, localName, namespaceURI);
}
public void writeStartElement(String localName) throws XMLStreamException {
out.writeStartElement(localName);
@Override
public void writeStartElement(String localName) throws XMLStreamException {
this.out.writeStartElement(localName);
}
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
out.writeStartElement(namespaceURI, localName);
@Override
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
this.out.writeStartElement(namespaceURI, localName);
}
public void writeStartElement(String prefix, String localName, String namespaceURI)
@Override
public void writeStartElement(String prefix, String localName, String namespaceURI)
throws XMLStreamException {
out.writeStartElement(prefix, localName, namespaceURI);
this.out.writeStartElement(prefix, localName, namespaceURI);
}
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
out.writeDefaultNamespace(namespaceURI);
@Override
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
this.out.writeDefaultNamespace(namespaceURI);
}
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
out.writeNamespace(prefix, namespaceURI);
@Override
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
this.out.writeNamespace(prefix, namespaceURI);
}
public String getPrefix(String uri) throws XMLStreamException {
return out.getPrefix(uri);
@Override
public String getPrefix(String uri) throws XMLStreamException {
return this.out.getPrefix(uri);
}
public void setPrefix(String prefix, String uri) throws XMLStreamException {
out.setPrefix(prefix, uri);
@Override
public void setPrefix(String prefix, String uri) throws XMLStreamException {
this.out.setPrefix(prefix, uri);
}
public void writeAttribute(String localName, String value) throws XMLStreamException {
out.writeAttribute(localName, value);
@Override
public void writeAttribute(String localName, String value) throws XMLStreamException {
this.out.writeAttribute(localName, value);
}
public void writeAttribute(String namespaceURI, String localName, String value)
@Override
public void writeAttribute(String namespaceURI, String localName, String value)
throws XMLStreamException {
out.writeAttribute(namespaceURI, localName, value);
this.out.writeAttribute(namespaceURI, localName, value);
}
public void writeAttribute(String prefix, String namespaceURI, String localName, String value)
@Override
public void writeAttribute(String prefix, String namespaceURI, String localName, String value)
throws XMLStreamException {
out.writeAttribute(prefix, namespaceURI, localName, value);
this.out.writeAttribute(prefix, namespaceURI, localName, value);
}
public void writeCharacters(String text) throws XMLStreamException {
out.writeCharacters(text);
@Override
public void writeCharacters(String text) throws XMLStreamException {
this.out.writeCharacters(text);
}
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
out.writeCharacters(text, start, len);
@Override
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
this.out.writeCharacters(text, start, len);
}
public void writeCData(String data) throws XMLStreamException {
out.writeCData(data);
@Override
public void writeCData(String data) throws XMLStreamException {
this.out.writeCData(data);
}
public void writeEntityRef(String name) throws XMLStreamException {
out.writeEntityRef(name);
@Override
public void writeEntityRef(String name) throws XMLStreamException {
this.out.writeEntityRef(name);
}
public void writeEndElement() throws XMLStreamException {
out.writeEndElement();
@Override
public void writeEndElement() throws XMLStreamException {
this.out.writeEndElement();
}
public void writeEndDocument() throws XMLStreamException {
out.writeEndDocument();
@Override
public void writeEndDocument() throws XMLStreamException {
this.out.writeEndDocument();
}
public void flush() throws XMLStreamException {
out.flush();
@Override
public void flush() throws XMLStreamException {
this.out.flush();
}
public void close() throws XMLStreamException {
out.close();
@Override
public void close() throws XMLStreamException {
this.out.close();
}
}