[Minor] code cleanup

This commit is contained in:
Robert von Burg 2014-09-14 12:19:49 +02:00
parent 75199bc6b7
commit 3fbf73fd15
13 changed files with 394 additions and 408 deletions

View File

@ -15,7 +15,6 @@
*/ */
package ch.eitchnet.xmlpers.api; package ch.eitchnet.xmlpers.api;
public interface ParserFactory<T> { public interface ParserFactory<T> {
public DomParser<T> getDomParser(); public DomParser<T> getDomParser();

View File

@ -15,7 +15,6 @@
*/ */
package ch.eitchnet.xmlpers.api; package ch.eitchnet.xmlpers.api;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>
* *
@ -23,10 +22,10 @@ package ch.eitchnet.xmlpers.api;
public interface PersistenceManager { public interface PersistenceManager {
public static final String DEFAULT_REALM = "defaultRealm"; //$NON-NLS-1$ public static final String DEFAULT_REALM = "defaultRealm"; //$NON-NLS-1$
public PersistenceContextFactoryDelegator getCtxFactory(); public PersistenceContextFactoryDelegator getCtxFactory();
public PersistenceTransaction openTx(); public PersistenceTransaction openTx();
public PersistenceTransaction openTx(String realm); public PersistenceTransaction openTx(String realm);
} }

View File

@ -48,11 +48,11 @@ public class LockableObject {
if (!this.lock.tryLock(tryLockTime, TimeUnit.MILLISECONDS)) { if (!this.lock.tryLock(tryLockTime, TimeUnit.MILLISECONDS)) {
String msg = "Failed to acquire lock after {0} for {1}"; //$NON-NLS-1$ String msg = "Failed to acquire lock after {0} for {1}"; //$NON-NLS-1$
msg = MessageFormat.format(msg, StringHelper.formatMillisecondsDuration(tryLockTime), this.toString()); msg = MessageFormat.format(msg, StringHelper.formatMillisecondsDuration(tryLockTime), toString());
throw new XmlPersistenceException(msg); throw new XmlPersistenceException(msg);
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("locked " + this.toString()); //$NON-NLS-1$ logger.debug("locked " + toString()); //$NON-NLS-1$
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new XmlPersistenceException("Thread interrupted: " + e.getMessage(), e); //$NON-NLS-1$ throw new XmlPersistenceException("Thread interrupted: " + e.getMessage(), e); //$NON-NLS-1$
} }
@ -64,6 +64,6 @@ public class LockableObject {
public void unlock() { public void unlock() {
this.lock.unlock(); this.lock.unlock();
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("unlocking " + this.toString()); //$NON-NLS-1$ logger.debug("unlocking " + toString()); //$NON-NLS-1$
} }
} }

View File

@ -72,7 +72,7 @@ public class SubTypeRef extends ObjectRef {
public File getPath(PathBuilder pathBuilder) { public File getPath(PathBuilder pathBuilder) {
return pathBuilder.getSubTypePath(this.type, this.subType); return pathBuilder.getSubTypePath(this.type, this.subType);
} }
@Override @Override
public <T> PersistenceContext<T> createPersistenceContext(PersistenceTransaction tx) { public <T> PersistenceContext<T> createPersistenceContext(PersistenceTransaction tx) {
String msg = MessageFormat.format("{0} is not a leaf and can thus not have a Persistence Context", getName()); //$NON-NLS-1$ String msg = MessageFormat.format("{0} is not a leaf and can thus not have a Persistence Context", getName()); //$NON-NLS-1$

View File

@ -1,39 +1,36 @@
package javanet.staxutils; package javanet.staxutils;
/** /**
* Characters that represent line breaks and indentation. These are represented * Characters that represent line breaks and indentation. These are represented as String-valued JavaBean properties.
* as String-valued JavaBean properties.
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public interface Indentation { public interface Indentation {
/** Two spaces; the default indentation. */ /** Two spaces; the default indentation. */
public static final String DEFAULT_INDENT = " "; public static final String DEFAULT_INDENT = " ";
/** /**
* Set the characters used for one level of indentation. The default is * Set the characters used for one level of indentation. The default is {@link #DEFAULT_INDENT}. "\t" is a popular
* {@link #DEFAULT_INDENT}. "\t" is a popular alternative. * alternative.
*/ */
void setIndent(String indent); void setIndent(String indent);
/** The characters used for one level of indentation. */ /** The characters used for one level of indentation. */
String getIndent(); String getIndent();
/** /**
* "\n"; the normalized representation of end-of-line in <a * "\n"; the normalized representation of end-of-line in <a
* href="http://www.w3.org/TR/xml11/#sec-line-ends">XML</a>. * href="http://www.w3.org/TR/xml11/#sec-line-ends">XML</a>.
*/ */
public static final String NORMAL_END_OF_LINE = "\n"; public static final String NORMAL_END_OF_LINE = "\n";
/** /**
* Set the characters that introduce a new line. The default is * Set the characters that introduce a new line. The default is {@link #NORMAL_END_OF_LINE}.
* {@link #NORMAL_END_OF_LINE}. * {@link IndentingXMLStreamWriter#getLineSeparator}() is a popular alternative.
* {@link IndentingXMLStreamWriter#getLineSeparator}() is a popular */
* alternative. public void setNewLine(String newLine);
*/
public void setNewLine(String newLine);
/** The characters that introduce a new line. */ /** The characters that introduce a new line. */
String getNewLine(); String getNewLine();
} }

View File

@ -37,9 +37,8 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
/** /**
* A filter that indents an XML stream. To apply it, construct a filter that * A filter that indents an XML stream. To apply it, construct a filter that contains another {@link XMLStreamWriter},
* contains another {@link XMLStreamWriter}, which you pass to the constructor. * which you pass to the constructor. Then call methods of the filter instead of the contained stream. For example:
* Then call methods of the filter instead of the contained stream. For example:
* *
* <pre> * <pre>
* {@link XMLStreamWriter} stream = ... * {@link XMLStreamWriter} stream = ...
@ -49,22 +48,19 @@ import javax.xml.stream.XMLStreamWriter;
* </pre> * </pre>
* *
* <p> * <p>
* The filter inserts characters to format the document as an outline, with * The filter inserts characters to format the document as an outline, with nested elements indented. Basically, it
* nested elements indented. Basically, it inserts a line break and whitespace * inserts a line break and whitespace before:
* before:
* <ul> * <ul>
* <li>each DTD, processing instruction or comment that's not preceded by data</li> * <li>each DTD, processing instruction or comment that's not preceded by data</li>
* <li>each starting tag that's not preceded by data</li> * <li>each starting tag that's not preceded by data</li>
* <li>each ending tag that's preceded by nested elements but not data</li> * <li>each ending tag that's preceded by nested elements but not data</li>
* </ul> * </ul>
* This works well with 'data-oriented' XML, wherein each element contains * This works well with 'data-oriented' XML, wherein each element contains either data or nested elements but not both.
* either data or nested elements but not both. It can work badly with other * It can work badly with other styles of XML. For example, the data in a 'mixed content' document are apt to be
* styles of XML. For example, the data in a 'mixed content' document are apt to * polluted with indentation characters.
* be polluted with indentation characters.
* <p> * <p>
* Indentation can be adjusted by setting the newLine and indent properties. But * Indentation can be adjusted by setting the newLine and indent properties. But set them to whitespace only, for best
* set them to whitespace only, for best results. Non-whitespace is apt to cause * results. Non-whitespace is apt to cause problems, for example when this class attempts to insert newLine before the
* problems, for example when this class attempts to insert newLine before the
* root element. * root element.
* *
* @author <a href="mailto:jk2006@engineer.com">John Kristian</a> * @author <a href="mailto:jk2006@engineer.com">John Kristian</a>
@ -72,307 +68,303 @@ import javax.xml.stream.XMLStreamWriter;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class IndentingXMLStreamWriter extends StreamWriterDelegate implements Indentation { public class IndentingXMLStreamWriter extends StreamWriterDelegate implements Indentation {
public IndentingXMLStreamWriter(XMLStreamWriter out) { public IndentingXMLStreamWriter(XMLStreamWriter out) {
this(out, DEFAULT_INDENT, NORMAL_END_OF_LINE); this(out, DEFAULT_INDENT, NORMAL_END_OF_LINE);
} }
public IndentingXMLStreamWriter(XMLStreamWriter out, String indent) {
this(out, indent, NORMAL_END_OF_LINE);
}
public IndentingXMLStreamWriter(XMLStreamWriter out, String indent, String newLine) {
super(out);
setIndent(indent);
setNewLine(newLine);
}
/** How deeply nested the current scope is. The root element is depth 1. */ public IndentingXMLStreamWriter(XMLStreamWriter out, String indent) {
private int depth = 0; // document scope this(out, indent, NORMAL_END_OF_LINE);
}
/** stack[depth] indicates what's been written into the current scope. */ public IndentingXMLStreamWriter(XMLStreamWriter out, String indent, String newLine) {
private int[] stack = new int[] { 0, 0, 0, 0 }; // nothing written yet super(out);
setIndent(indent);
setNewLine(newLine);
}
private static final int WROTE_MARKUP = 1; /** How deeply nested the current scope is. The root element is depth 1. */
private int depth = 0; // document scope
private static final int WROTE_DATA = 2; /** stack[depth] indicates what's been written into the current scope. */
private int[] stack = new int[] { 0, 0, 0, 0 }; // nothing written yet
private String indent = DEFAULT_INDENT; private static final int WROTE_MARKUP = 1;
private String newLine = NORMAL_END_OF_LINE; private static final int WROTE_DATA = 2;
/** newLine followed by copies of indent. */ private String indent = DEFAULT_INDENT;
private char[] linePrefix = null;
@Override private String newLine = NORMAL_END_OF_LINE;
/** newLine followed by copies of indent. */
private char[] linePrefix = null;
@Override
public void setIndent(String indent) { public void setIndent(String indent) {
if (!indent.equals(this.indent)) { if (!indent.equals(this.indent)) {
this.indent = indent; this.indent = indent;
this.linePrefix = null; this.linePrefix = null;
} }
} }
@Override @Override
public String getIndent() { public String getIndent() {
return this.indent; return this.indent;
} }
@Override @Override
public void setNewLine(String newLine) { public void setNewLine(String newLine) {
if (!newLine.equals(this.newLine)) { if (!newLine.equals(this.newLine)) {
this.newLine = newLine; this.newLine = newLine;
this.linePrefix = null; this.linePrefix = null;
} }
} }
/** /**
* @return System.getProperty("line.separator"); or * @return System.getProperty("line.separator"); or {@link #NORMAL_END_OF_LINE} if that fails.
* {@link #NORMAL_END_OF_LINE} if that fails. */
*/ public static String getLineSeparator() {
public static String getLineSeparator() { try {
try { return System.getProperty("line.separator");
return System.getProperty("line.separator"); } catch (SecurityException ignored) {
} catch (SecurityException ignored) { //
// }
} return NORMAL_END_OF_LINE;
return NORMAL_END_OF_LINE; }
}
@Override @Override
public String getNewLine() { public String getNewLine() {
return this.newLine; return this.newLine;
} }
@Override @Override
public void writeStartDocument() throws XMLStreamException { public void writeStartDocument() throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeStartDocument(); this.out.writeStartDocument();
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeStartDocument(String version) throws XMLStreamException { public void writeStartDocument(String version) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeStartDocument(version); this.out.writeStartDocument(version);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeStartDocument(String encoding, String version) throws XMLStreamException { public void writeStartDocument(String encoding, String version) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeStartDocument(encoding, version); this.out.writeStartDocument(encoding, version);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeDTD(String dtd) throws XMLStreamException { public void writeDTD(String dtd) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeDTD(dtd); this.out.writeDTD(dtd);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeProcessingInstruction(String target) throws XMLStreamException { public void writeProcessingInstruction(String target) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeProcessingInstruction(target); this.out.writeProcessingInstruction(target);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeProcessingInstruction(String target, String data) throws XMLStreamException { public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeProcessingInstruction(target, data); this.out.writeProcessingInstruction(target, data);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeComment(String data) throws XMLStreamException { public void writeComment(String data) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeComment(data); this.out.writeComment(data);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeEmptyElement(String localName) throws XMLStreamException { public void writeEmptyElement(String localName) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeEmptyElement(localName); this.out.writeEmptyElement(localName);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException { public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
beforeMarkup(); beforeMarkup();
this.out.writeEmptyElement(namespaceURI, localName); this.out.writeEmptyElement(namespaceURI, localName);
afterMarkup(); afterMarkup();
} }
@Override @Override
public void writeEmptyElement(String prefix, String localName, String namespaceURI) public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
throws XMLStreamException { beforeMarkup();
beforeMarkup(); this.out.writeEmptyElement(prefix, localName, namespaceURI);
this.out.writeEmptyElement(prefix, localName, namespaceURI); afterMarkup();
afterMarkup(); }
}
@Override @Override
public void writeStartElement(String localName) throws XMLStreamException { public void writeStartElement(String localName) throws XMLStreamException {
beforeStartElement(); beforeStartElement();
this.out.writeStartElement(localName); this.out.writeStartElement(localName);
afterStartElement(); afterStartElement();
} }
@Override @Override
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException { public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
beforeStartElement(); beforeStartElement();
this.out.writeStartElement(namespaceURI, localName); this.out.writeStartElement(namespaceURI, localName);
afterStartElement(); afterStartElement();
} }
@Override @Override
public void writeStartElement(String prefix, String localName, String namespaceURI) public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
throws XMLStreamException { beforeStartElement();
beforeStartElement(); this.out.writeStartElement(prefix, localName, namespaceURI);
this.out.writeStartElement(prefix, localName, namespaceURI); afterStartElement();
afterStartElement(); }
}
@Override @Override
public void writeCharacters(String text) throws XMLStreamException { public void writeCharacters(String text) throws XMLStreamException {
this.out.writeCharacters(text); this.out.writeCharacters(text);
afterData(); afterData();
} }
@Override @Override
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException { public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
this.out.writeCharacters(text, start, len); this.out.writeCharacters(text, start, len);
afterData(); afterData();
} }
@Override @Override
public void writeCData(String data) throws XMLStreamException { public void writeCData(String data) throws XMLStreamException {
this.out.writeCData(data); this.out.writeCData(data);
afterData(); afterData();
} }
@Override @Override
public void writeEntityRef(String name) throws XMLStreamException { public void writeEntityRef(String name) throws XMLStreamException {
this.out.writeEntityRef(name); this.out.writeEntityRef(name);
afterData(); afterData();
} }
@Override @Override
public void writeEndElement() throws XMLStreamException { public void writeEndElement() throws XMLStreamException {
beforeEndElement(); beforeEndElement();
this.out.writeEndElement(); this.out.writeEndElement();
afterEndElement(); afterEndElement();
} }
@Override @Override
public void writeEndDocument() throws XMLStreamException { public void writeEndDocument() throws XMLStreamException {
try { try {
while (this.depth > 0) { while (this.depth > 0) {
writeEndElement(); // indented writeEndElement(); // indented
} }
} catch (Exception ignored) { } catch (Exception ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
} }
this.out.writeEndDocument(); this.out.writeEndDocument();
afterEndDocument(); afterEndDocument();
} }
/** Prepare to write markup, by writing a new line and indentation. */ /** Prepare to write markup, by writing a new line and indentation. */
protected void beforeMarkup() { protected void beforeMarkup() {
int soFar = this.stack[this.depth]; int soFar = this.stack[this.depth];
if ((soFar & WROTE_DATA) == 0 // no data in this scope if ((soFar & WROTE_DATA) == 0 // no data in this scope
&& (this.depth > 0 || soFar != 0)) // not the first line && (this.depth > 0 || soFar != 0)) // not the first line
{ {
try { try {
writeNewLine(this.depth); writeNewLine(this.depth);
if (this.depth > 0 && getIndent().length() > 0) { if (this.depth > 0 && getIndent().length() > 0) {
afterMarkup(); // indentation was written afterMarkup(); // indentation was written
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
/** Note that markup or indentation was written. */ /** Note that markup or indentation was written. */
protected void afterMarkup() { protected void afterMarkup() {
this.stack[this.depth] |= WROTE_MARKUP; this.stack[this.depth] |= WROTE_MARKUP;
} }
/** Note that data were written. */ /** Note that data were written. */
protected void afterData() { protected void afterData() {
this.stack[this.depth] |= WROTE_DATA; this.stack[this.depth] |= WROTE_DATA;
} }
/** Prepare to start an element, by allocating stack space. */ /** Prepare to start an element, by allocating stack space. */
protected void beforeStartElement() { protected void beforeStartElement() {
beforeMarkup(); beforeMarkup();
if (this.stack.length <= this.depth + 1) { if (this.stack.length <= this.depth + 1) {
// Allocate more space for the stack: // Allocate more space for the stack:
int[] newStack = new int[this.stack.length * 2]; int[] newStack = new int[this.stack.length * 2];
System.arraycopy(this.stack, 0, newStack, 0, this.stack.length); System.arraycopy(this.stack, 0, newStack, 0, this.stack.length);
this.stack = newStack; this.stack = newStack;
} }
this.stack[this.depth + 1] = 0; // nothing written yet this.stack[this.depth + 1] = 0; // nothing written yet
} }
/** Note that an element was started. */ /** Note that an element was started. */
protected void afterStartElement() { protected void afterStartElement() {
afterMarkup(); afterMarkup();
++this.depth; ++this.depth;
} }
/** Prepare to end an element, by writing a new line and indentation. */ /** Prepare to end an element, by writing a new line and indentation. */
protected void beforeEndElement() { protected void beforeEndElement() {
if (this.depth > 0 && this.stack[this.depth] == WROTE_MARKUP) { // but not data if (this.depth > 0 && this.stack[this.depth] == WROTE_MARKUP) { // but not data
try { try {
writeNewLine(this.depth - 1); writeNewLine(this.depth - 1);
} catch (Exception ignored) { } catch (Exception ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
} }
} }
} }
/** Note that an element was ended. */ /** Note that an element was ended. */
protected void afterEndElement() { protected void afterEndElement() {
if (this.depth > 0) { if (this.depth > 0) {
--this.depth; --this.depth;
} }
} }
/** Note that a document was ended. */ /** Note that a document was ended. */
protected void afterEndDocument() { protected void afterEndDocument() {
if (this.stack[this.depth = 0] == WROTE_MARKUP) { // but not data if (this.stack[this.depth = 0] == WROTE_MARKUP) { // but not data
try { try {
writeNewLine(0); writeNewLine(0);
} catch (Exception ignored) { } catch (Exception ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
} }
} }
this.stack[this.depth] = 0; // start fresh this.stack[this.depth] = 0; // start fresh
} }
/** Write a line separator followed by indentation. */ /** Write a line separator followed by indentation. */
protected void writeNewLine(int indentation) throws XMLStreamException { protected void writeNewLine(int indentation) throws XMLStreamException {
final int newLineLength = getNewLine().length(); final int newLineLength = getNewLine().length();
final int prefixLength = newLineLength + (getIndent().length() * indentation); final int prefixLength = newLineLength + (getIndent().length() * indentation);
if (prefixLength > 0) { if (prefixLength > 0) {
if (this.linePrefix == null) { if (this.linePrefix == null) {
this.linePrefix = (getNewLine() + getIndent()).toCharArray(); this.linePrefix = (getNewLine() + getIndent()).toCharArray();
} }
while (prefixLength > this.linePrefix.length) { while (prefixLength > this.linePrefix.length) {
// make linePrefix longer: // make linePrefix longer:
char[] newPrefix = new char[newLineLength char[] newPrefix = new char[newLineLength + ((this.linePrefix.length - newLineLength) * 2)];
+ ((this.linePrefix.length - newLineLength) * 2)]; System.arraycopy(this.linePrefix, 0, newPrefix, 0, this.linePrefix.length);
System.arraycopy(this.linePrefix, 0, newPrefix, 0, this.linePrefix.length); System.arraycopy(this.linePrefix, newLineLength, newPrefix, this.linePrefix.length,
System.arraycopy(this.linePrefix, newLineLength, newPrefix, this.linePrefix.length, this.linePrefix.length - newLineLength);
this.linePrefix.length - newLineLength); this.linePrefix = newPrefix;
this.linePrefix = newPrefix; }
} this.out.writeCharacters(this.linePrefix, 0, prefixLength);
this.out.writeCharacters(this.linePrefix, 0, prefixLength); }
} }
}
} }

View File

@ -36,182 +36,178 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
/** /**
* Abstract class for writing filtered XML streams. This class provides methods * Abstract class for writing filtered XML streams. This class provides methods that merely delegate to the contained
* that merely delegate to the contained stream. Subclasses should override some * stream. Subclasses should override some of these methods, and may also provide additional methods and fields.
* of these methods, and may also provide additional methods and fields.
* *
* @author <a href="mailto:jk2006@engineer.com">John Kristian</a> * @author <a href="mailto:jk2006@engineer.com">John Kristian</a>
*/ */
public abstract class StreamWriterDelegate implements XMLStreamWriter { public abstract class StreamWriterDelegate implements XMLStreamWriter {
protected StreamWriterDelegate(XMLStreamWriter out) { protected StreamWriterDelegate(XMLStreamWriter out) {
this.out = out; this.out = out;
} }
protected XMLStreamWriter out; protected XMLStreamWriter out;
@Override @Override
public Object getProperty(String name) throws IllegalArgumentException { public Object getProperty(String name) throws IllegalArgumentException {
return this.out.getProperty(name); return this.out.getProperty(name);
} }
@Override @Override
public NamespaceContext getNamespaceContext() { public NamespaceContext getNamespaceContext() {
return this.out.getNamespaceContext(); return this.out.getNamespaceContext();
} }
@Override @Override
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
this.out.setNamespaceContext(context); this.out.setNamespaceContext(context);
} }
@Override @Override
public void setDefaultNamespace(String uri) throws XMLStreamException { public void setDefaultNamespace(String uri) throws XMLStreamException {
this.out.setDefaultNamespace(uri); this.out.setDefaultNamespace(uri);
} }
@Override @Override
public void writeStartDocument() throws XMLStreamException { public void writeStartDocument() throws XMLStreamException {
this.out.writeStartDocument(); this.out.writeStartDocument();
} }
@Override @Override
public void writeStartDocument(String version) throws XMLStreamException { public void writeStartDocument(String version) throws XMLStreamException {
this.out.writeStartDocument(version); this.out.writeStartDocument(version);
} }
@Override @Override
public void writeStartDocument(String encoding, String version) throws XMLStreamException { public void writeStartDocument(String encoding, String version) throws XMLStreamException {
this.out.writeStartDocument(encoding, version); this.out.writeStartDocument(encoding, version);
} }
@Override @Override
public void writeDTD(String dtd) throws XMLStreamException { public void writeDTD(String dtd) throws XMLStreamException {
this.out.writeDTD(dtd); this.out.writeDTD(dtd);
} }
@Override @Override
public void writeProcessingInstruction(String target) throws XMLStreamException { public void writeProcessingInstruction(String target) throws XMLStreamException {
this.out.writeProcessingInstruction(target); this.out.writeProcessingInstruction(target);
} }
@Override @Override
public void writeProcessingInstruction(String target, String data) throws XMLStreamException { public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
this.out.writeProcessingInstruction(target, data); this.out.writeProcessingInstruction(target, data);
} }
@Override @Override
public void writeComment(String data) throws XMLStreamException { public void writeComment(String data) throws XMLStreamException {
this.out.writeComment(data); this.out.writeComment(data);
} }
@Override @Override
public void writeEmptyElement(String localName) throws XMLStreamException { public void writeEmptyElement(String localName) throws XMLStreamException {
this.out.writeEmptyElement(localName); this.out.writeEmptyElement(localName);
} }
@Override @Override
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException { public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
this.out.writeEmptyElement(namespaceURI, localName); this.out.writeEmptyElement(namespaceURI, localName);
} }
@Override @Override
public void writeEmptyElement(String prefix, String localName, String namespaceURI) public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
throws XMLStreamException { this.out.writeEmptyElement(prefix, localName, namespaceURI);
this.out.writeEmptyElement(prefix, localName, namespaceURI); }
}
@Override @Override
public void writeStartElement(String localName) throws XMLStreamException { public void writeStartElement(String localName) throws XMLStreamException {
this.out.writeStartElement(localName); this.out.writeStartElement(localName);
} }
@Override @Override
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException { public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
this.out.writeStartElement(namespaceURI, localName); this.out.writeStartElement(namespaceURI, localName);
} }
@Override @Override
public void writeStartElement(String prefix, String localName, String namespaceURI) public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
throws XMLStreamException { this.out.writeStartElement(prefix, localName, namespaceURI);
this.out.writeStartElement(prefix, localName, namespaceURI); }
}
@Override @Override
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException { public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
this.out.writeDefaultNamespace(namespaceURI); this.out.writeDefaultNamespace(namespaceURI);
} }
@Override @Override
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException { public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
this.out.writeNamespace(prefix, namespaceURI); this.out.writeNamespace(prefix, namespaceURI);
} }
@Override @Override
public String getPrefix(String uri) throws XMLStreamException { public String getPrefix(String uri) throws XMLStreamException {
return this.out.getPrefix(uri); return this.out.getPrefix(uri);
} }
@Override @Override
public void setPrefix(String prefix, String uri) throws XMLStreamException { public void setPrefix(String prefix, String uri) throws XMLStreamException {
this.out.setPrefix(prefix, uri); this.out.setPrefix(prefix, uri);
} }
@Override @Override
public void writeAttribute(String localName, String value) throws XMLStreamException { public void writeAttribute(String localName, String value) throws XMLStreamException {
this.out.writeAttribute(localName, value); this.out.writeAttribute(localName, value);
} }
@Override @Override
public void writeAttribute(String namespaceURI, String localName, String value) public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
throws XMLStreamException { this.out.writeAttribute(namespaceURI, localName, value);
this.out.writeAttribute(namespaceURI, localName, value); }
}
@Override @Override
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) public void writeAttribute(String prefix, String namespaceURI, String localName, String value)
throws XMLStreamException { throws XMLStreamException {
this.out.writeAttribute(prefix, namespaceURI, localName, value); this.out.writeAttribute(prefix, namespaceURI, localName, value);
} }
@Override @Override
public void writeCharacters(String text) throws XMLStreamException { public void writeCharacters(String text) throws XMLStreamException {
this.out.writeCharacters(text); this.out.writeCharacters(text);
} }
@Override @Override
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException { public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
this.out.writeCharacters(text, start, len); this.out.writeCharacters(text, start, len);
} }
@Override @Override
public void writeCData(String data) throws XMLStreamException { public void writeCData(String data) throws XMLStreamException {
this.out.writeCData(data); this.out.writeCData(data);
} }
@Override @Override
public void writeEntityRef(String name) throws XMLStreamException { public void writeEntityRef(String name) throws XMLStreamException {
this.out.writeEntityRef(name); this.out.writeEntityRef(name);
} }
@Override @Override
public void writeEndElement() throws XMLStreamException { public void writeEndElement() throws XMLStreamException {
this.out.writeEndElement(); this.out.writeEndElement();
} }
@Override @Override
public void writeEndDocument() throws XMLStreamException { public void writeEndDocument() throws XMLStreamException {
this.out.writeEndDocument(); this.out.writeEndDocument();
} }
@Override @Override
public void flush() throws XMLStreamException { public void flush() throws XMLStreamException {
this.out.flush(); this.out.flush();
} }
@Override @Override
public void close() throws XMLStreamException { public void close() throws XMLStreamException {
this.out.close(); this.out.close();
} }
} }

View File

@ -60,7 +60,7 @@ public class LockingTest extends AbstractPersistenceTest {
properties.setProperty(PersistenceConstants.PROP_LOCK_TIME_MILLIS, Long.toString(500L)); properties.setProperty(PersistenceConstants.PROP_LOCK_TIME_MILLIS, Long.toString(500L));
setup(properties); setup(properties);
this.waitForWorkersTime = LockableObject.getLockTime() + this.getWaitForWorkersTime() + 300L; this.waitForWorkersTime = LockableObject.getLockTime() + getWaitForWorkersTime() + 300L;
} }
@Test @Test
@ -128,10 +128,10 @@ public class LockingTest extends AbstractPersistenceTest {
private int runWorkers(List<? extends AbstractWorker> workers) throws InterruptedException { private int runWorkers(List<? extends AbstractWorker> workers) throws InterruptedException {
this.setRun(true); setRun(true);
for (AbstractWorker worker : workers) { for (AbstractWorker worker : workers) {
worker.join(this.getWaitForWorkersTime() + 2000L); worker.join(getWaitForWorkersTime() + 2000L);
} }
int nrOfSuccess = 0; int nrOfSuccess = 0;
@ -169,7 +169,7 @@ public class LockingTest extends AbstractPersistenceTest {
public void run() { public void run() {
logger.info("Waiting for ok to work..."); //$NON-NLS-1$ logger.info("Waiting for ok to work..."); //$NON-NLS-1$
while (!LockingTest.this.isRun()) { while (!isRun()) {
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@ -47,8 +47,8 @@ import org.xml.sax.helpers.DefaultHandler;
import ch.eitchnet.utils.exceptions.XmlException; import ch.eitchnet.utils.exceptions.XmlException;
import ch.eitchnet.utils.helper.XmlHelper; import ch.eitchnet.utils.helper.XmlHelper;
import ch.eitchnet.xmlpers.test.model.ModelBuilder; import ch.eitchnet.xmlpers.test.model.ModelBuilder;
import ch.eitchnet.xmlpers.test.model.MyParameter;
import ch.eitchnet.xmlpers.test.model.MyModel; import ch.eitchnet.xmlpers.test.model.MyModel;
import ch.eitchnet.xmlpers.test.model.MyParameter;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>

View File

@ -23,8 +23,8 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import ch.eitchnet.xmlpers.api.DomParser; import ch.eitchnet.xmlpers.api.DomParser;
import ch.eitchnet.xmlpers.test.model.MyParameter;
import ch.eitchnet.xmlpers.test.model.MyModel; import ch.eitchnet.xmlpers.test.model.MyModel;
import ch.eitchnet.xmlpers.test.model.MyParameter;
import ch.eitchnet.xmlpers.util.DomUtil; import ch.eitchnet.xmlpers.util.DomUtil;
public class MyModelDomParser implements DomParser<MyModel> { public class MyModelDomParser implements DomParser<MyModel> {

View File

@ -23,8 +23,8 @@ import org.xml.sax.helpers.DefaultHandler;
import ch.eitchnet.xmlpers.api.SaxParser; import ch.eitchnet.xmlpers.api.SaxParser;
import ch.eitchnet.xmlpers.api.XmlPersistenceStreamWriter; import ch.eitchnet.xmlpers.api.XmlPersistenceStreamWriter;
import ch.eitchnet.xmlpers.test.model.MyParameter;
import ch.eitchnet.xmlpers.test.model.MyModel; import ch.eitchnet.xmlpers.test.model.MyModel;
import ch.eitchnet.xmlpers.test.model.MyParameter;
class MyModelSaxParser extends DefaultHandler implements SaxParser<MyModel> { class MyModelSaxParser extends DefaultHandler implements SaxParser<MyModel> {

View File

@ -46,7 +46,7 @@ public class ModelBuilder {
public static MyModel createResource() { public static MyModel createResource() {
return createResource(RES_ID, RES_NAME, RES_TYPE); return createResource(RES_ID, RES_NAME, RES_TYPE);
} }
public static MyModel createResource(String id) { public static MyModel createResource(String id) {
return createResource(id, RES_NAME, RES_TYPE); return createResource(id, RES_NAME, RES_TYPE);
} }

View File

@ -73,7 +73,8 @@ public class MyModel {
} }
/** /**
* @param id the id to set * @param id
* the id to set
*/ */
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
@ -87,7 +88,8 @@ public class MyModel {
} }
/** /**
* @param name the name to set * @param name
* the name to set
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
@ -101,7 +103,8 @@ public class MyModel {
} }
/** /**
* @param type the type to set * @param type
* the type to set
*/ */
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;