Skip to content
Browse files

Ran Eclipse's 'cleanup' function over the source

  • Loading branch information...
1 parent d3c50d3 commit 235887f517bde066e6a194bf0653a4e03a1b8c4c Martin Kleppmann committed Feb 28, 2009
Showing with 595 additions and 301 deletions.
  1. +12 −12 src/fc/test/junit/XasTest.java
  2. +3 −3 src/fc/test/junit/XmlData.java
  3. +2 −0 src/fc/util/ByteArray.java
  4. +2 −0 src/fc/util/Debug.java
  5. +2 −0 src/fc/util/ImmutableArrayList.java
  6. +1 −0 src/fc/util/Measurer.java
  7. +1 −0 src/fc/util/Queue.java
  8. +8 −2 src/fc/util/RaInputStream.java
  9. +1 −0 src/fc/util/RingBuffer.java
  10. +3 −0 src/fc/util/Utf8Reader.java
  11. +3 −0 src/fc/util/Util.java
  12. +18 −18 src/fc/util/log/AbstractLogger.java
  13. +3 −0 src/fc/util/log/GroupLogger.java
  14. +18 −18 src/fc/util/log/Log.java
  15. +1 −0 src/fc/util/log/StreamLogger.java
  16. +9 −7 src/fc/xml/diff/Diff.java
  17. +10 −7 src/fc/xml/diff/GlMatcher.java
  18. +7 −23 src/fc/xml/diff/Patch.java
  19. +1 −0 src/fc/xml/diff/Segment.java
  20. +19 −15 src/fc/xml/diff/benchmark/BenchMark.java
  21. +23 −18 src/fc/xml/diff/benchmark/SynteticDirTree.java
  22. +2 −1 src/fc/xml/diff/benchmark/UseCases.java
  23. +3 −0 src/fc/xml/diff/encode/ListOfMatchedEvents.java
  24. +0 −1 src/fc/xml/diff/encode/RefTreeByIdEncoder.java
  25. +4 −2 src/fc/xml/diff/encode/RefTreeEncoder.java
  26. +1 −0 src/fc/xml/diff/encode/XmlDiffEncoder.java
  27. +27 −15 src/fc/xml/diff/test/DirTreeGenerator.java
  28. +4 −1 src/fc/xml/diff/test/RootSuite.java
  29. +3 −0 src/fc/xml/xas/AttributeNode.java
  30. +2 −0 src/fc/xml/xas/Comment.java
  31. +3 −0 src/fc/xml/xas/Doctype.java
  32. +3 −0 src/fc/xml/xas/EndDocument.java
  33. +3 −0 src/fc/xml/xas/EndTag.java
  34. +2 −0 src/fc/xml/xas/EntityRef.java
  35. +3 −0 src/fc/xml/xas/FragmentPointer.java
  36. +3 −0 src/fc/xml/xas/ItemList.java
  37. +9 −5 src/fc/xml/xas/MutableFragmentPointer.java
  38. +3 −0 src/fc/xml/xas/NullItem.java
  39. +3 −0 src/fc/xml/xas/Pi.java
  40. +3 −0 src/fc/xml/xas/PrefixNode.java
  41. +3 −0 src/fc/xml/xas/Qname.java
  42. +1 −0 src/fc/xml/xas/SerializedFragment.java
  43. +3 −0 src/fc/xml/xas/StartDocument.java
  44. +3 −2 src/fc/xml/xas/StartTag.java
  45. +3 −0 src/fc/xml/xas/Text.java
  46. +1 −0 src/fc/xml/xas/WrapperItem.java
  47. +5 −0 src/fc/xml/xas/XasFragment.java
  48. +4 −3 src/fc/xml/xas/XmlOutput.java
  49. +2 −1 src/fc/xml/xas/XmlPullTarget.java
  50. +1 −0 src/fc/xml/xas/compat/XasBridgeTarget.java
  51. +3 −0 src/fc/xml/xas/index/DeweyKey.java
  52. +3 −0 src/fc/xml/xas/index/GlobalPointer.java
  53. +2 −0 src/fc/xml/xas/index/Index.java
  54. +1 −0 src/fc/xml/xas/index/KeyIterator.java
  55. +39 −35 src/fc/xml/xas/index/LazyFragment.java
  56. +3 −0 src/fc/xml/xas/index/LazyPointer.java
  57. +4 −0 src/fc/xml/xas/index/SeekableSource.java
  58. +4 −2 src/fc/xml/xas/index/VersionNode.java
  59. +21 −11 src/fc/xml/xas/index/VersionedPointer.java
  60. +0 −1 src/fc/xml/xas/transform/CoalesceContent.java
  61. +0 −1 src/fc/xml/xas/transform/NsPrefixFixer.java
  62. +3 −2 src/fc/xml/xas/typing/Codec.java
  63. +6 −5 src/fc/xml/xas/typing/DecodeSource.java
  64. +3 −0 src/fc/xml/xas/typing/ParsedPrimitive.java
  65. +3 −0 src/fc/xml/xas/typing/TypedItem.java
  66. +3 −2 src/fc/xml/xas/typing/XmlCodec.java
  67. +1 −2 src/fc/xml/xmlr/ChangeBuffer.java
  68. +25 −11 src/fc/xml/xmlr/ChangeTree.java
  69. +18 −6 src/fc/xml/xmlr/DerefRefTree.java
  70. +3 −0 src/fc/xml/xmlr/RefTreeNodeImpl.java
  71. +9 −1 src/fc/xml/xmlr/RefTrees.java
  72. +11 −10 src/fc/xml/xmlr/XmlrDebug.java
  73. +0 −2 src/fc/xml/xmlr/XmlrUtil.java
  74. +6 −0 src/fc/xml/xmlr/model/StringKey.java
  75. +1 −0 src/fc/xml/xmlr/model/TransientKey.java
  76. +4 −0 src/fc/xml/xmlr/model/TreeModel.java
  77. +14 −6 src/fc/xml/xmlr/tdm/Diff.java
  78. +40 −5 src/fc/xml/xmlr/tdm/Merge.java
  79. +1 −2 src/fc/xml/xmlr/test/DeweyKeyedRefTree.java
  80. +19 −11 src/fc/xml/xmlr/test/RandomDirectoryTree.java
  81. +2 −0 src/fc/xml/xmlr/test/RootSuite.java
  82. +3 −0 src/fc/xml/xmlr/test/TestChangeTree.java
  83. +0 −1 src/fc/xml/xmlr/test/TestDeweyTrees.java
  84. +3 −0 src/fc/xml/xmlr/test/XasTests.java
  85. +3 −0 src/fc/xml/xmlr/xas/DeweyKey.java
  86. +0 −1 src/fc/xml/xmlr/xas/DeweyRefNode.java
  87. +0 −2 src/fc/xml/xmlr/xas/DeweyXasSource.java
  88. +2 −0 src/fc/xml/xmlr/xas/IdAttributeXasSource.java
  89. +9 −2 src/fc/xml/xmlr/xas/MutableDeweyRefTree.java
  90. +1 −1 src/fc/xml/xmlr/xas/RefNodeItem.java
  91. +1 −0 src/fc/xml/xmlr/xas/RefTreeItem.java
  92. +1 −1 src/fc/xml/xmlr/xas/XasSerialization.java
  93. +1 −0 src/fuegocore/message/encoding/SequenceCache.java
  94. +2 −3 src/fuegocore/message/encoding/XebuParser.java
  95. +1 −0 src/fuegocore/util/ByteBuffer.java
  96. +1 −0 src/fuegocore/util/Queue.java
  97. +2 −0 src/fuegocore/util/RootSuite.java
  98. +1 −0 src/fuegocore/util/tests/QueueTest.java
  99. +1 −0 src/fuegocore/util/tests/XasData.java
  100. +1 −6 src/fuegocore/util/tests/XasTest.java
  101. +5 −0 src/fuegocore/util/xas/ChainedContentDecoder.java
  102. +1 −0 src/fuegocore/util/xas/CoalescedEventSequence.java
  103. +0 −5 src/fuegocore/util/xas/CodecIndustry.java
  104. +1 −0 src/fuegocore/util/xas/ContentDecoder.java
  105. +1 −0 src/fuegocore/util/xas/DataEventSequence.java
  106. +2 −0 src/fuegocore/util/xas/DefaultXmlParser.java
  107. +2 −0 src/fuegocore/util/xas/DefaultXmlSerializer.java
  108. +3 −0 src/fuegocore/util/xas/Event.java
  109. +6 −0 src/fuegocore/util/xas/EventList.java
  110. +1 −0 src/fuegocore/util/xas/EventSerializer.java
  111. +14 −10 src/fuegocore/util/xas/EventStream.java
  112. +3 −0 src/fuegocore/util/xas/TransformedEventStream.java
  113. +3 −0 src/fuegocore/util/xas/TypedEventStream.java
  114. +1 −0 src/fuegocore/util/xas/XasExtUtil.java
  115. +1 −0 src/fuegocore/util/xas/XmlReader.java
  116. +1 −0 src/fuegocore/util/xas/XmlSchemaContentDecoder.java
  117. +2 −0 src/fuegocore/util/xas/codec/DefaultCodecFactory.java
  118. +2 −0 src/fuegocore/util/xas/codec/EventSequenceCodecFactory.java
  119. +1 −0 src/fuegocore/util/xas/codec/EventSequenceDecoder.java
  120. +2 −0 src/fuegocore/util/xas/codec/HashtableCodecFactory.java
  121. +1 −0 src/fuegocore/util/xas/codec/HashtableDecoder.java
  122. +2 −0 src/fuegocore/util/xas/codec/VectorCodecFactory.java
  123. +1 −0 src/fuegocore/util/xas/codec/VectorDecoder.java
View
24 src/fc/test/junit/XasTest.java
@@ -12,7 +12,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -22,6 +21,7 @@
import fc.util.Util;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.xml.xas.FormatFactory;
import fc.xml.xas.Item;
import fc.xml.xas.ItemList;
@@ -40,7 +40,6 @@
import fc.xml.xas.typing.Codec;
import fc.xml.xas.typing.DecodeSource;
import fc.xml.xas.typing.PrimitiveSource;
-import fc.xml.xas.typing.TypingUtil;
import fc.xml.xas.typing.XmlCodec;
public class XasTest extends TestCase {
@@ -49,6 +48,7 @@
List<ItemList> typeds;
+ @Override
protected void setUp() throws IOException {
fragments = XmlData.getData();
typeds = XmlData.getTypedData();
@@ -58,10 +58,10 @@ protected void setUp() throws IOException {
public void testTreeify() {
- Log.log("Begin test", Log.DEBUG);
+ Log.log("Begin test", LogLevels.DEBUG);
for (XasFragment f : fragments) {
f.treeify();
- Log.log("Fragment", Log.DEBUG, f);
+ Log.log("Fragment", LogLevels.DEBUG, f);
}
}
@@ -118,7 +118,7 @@ private void ioRoundTrip(XasFragment f) throws IOException {
public void testIoRoundTrip() throws IOException {
- Log.log("Begin test", Log.DEBUG);
+ Log.log("Begin test", LogLevels.DEBUG);
for (XasFragment f : fragments) {
ioRoundTrip(f);
// ioRoundTrip(f.flattenPure());
@@ -128,7 +128,7 @@ public void testIoRoundTrip() throws IOException {
public void testTyping() throws IOException {
- Log.log("Begin test", Log.DEBUG);
+ Log.log("Begin test", LogLevels.DEBUG);
for (String type : XasUtil.factoryTypes()) {
for (ItemList source : typeds) {
Log.debug("Source fragment", source);
@@ -139,7 +139,7 @@ public void testTyping() throws IOException {
XasUtil.copy(source.source(), serTarget);
serTarget.flush();
byte[] result = bout.toByteArray();
- Log.log("Document", Log.DEBUG, Util.toPrintable(result));
+ Log.log("Document", LogLevels.DEBUG, Util.toPrintable(result));
ByteArrayInputStream bin = new ByteArrayInputStream(result);
ParserSource parserSource = factory.createSource(bin);
ItemSource primitiveSource = new PrimitiveSource(parserSource, type, "UTF-8");
@@ -155,7 +155,7 @@ public void testTyping() throws IOException {
public void testQuery() throws IOException {
- Log.log("Begin test", Log.DEBUG);
+ Log.log("Begin test", LogLevels.DEBUG);
for (Queryable fragment : XmlData.getTrees()) {
if (fragment instanceof Iterable) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -165,7 +165,7 @@ public void testQuery() throws IOException {
xout.append(i);
}
xout.flush();
- Log.log("Document", Log.DEBUG, new String(bout.toByteArray(), "UTF-8"));
+ Log.log("Document", LogLevels.DEBUG, new String(bout.toByteArray(), "UTF-8"));
}
int[] k0 = new int[] {};
int[] k1 = new int[] { 0 };
@@ -195,7 +195,7 @@ public void testQuery() throws IOException {
public void testModify() throws IOException {
- Log.log("Begin test", Log.DEBUG);
+ Log.log("Begin test", LogLevels.DEBUG);
for (Queryable fragment : XmlData.getTrees()) {
boolean isVer = fragment instanceof VersionedDocument;
int[] k001 = new int[] { 0, 0, 1 };
@@ -236,8 +236,8 @@ public void testModify() throws IOException {
xout.append(i);
}
xout.flush();
- Log.log("Fragment", Log.DEBUG, fragment);
- Log.log("Result", Log.DEBUG, new String(bout.toByteArray(), "UTF-8"));
+ Log.log("Fragment", LogLevels.DEBUG, fragment);
+ Log.log("Result", LogLevels.DEBUG, new String(bout.toByteArray(), "UTF-8"));
}
}
}
View
6 src/fc/test/junit/XmlData.java
@@ -26,19 +26,16 @@
import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.kxml2.io.KXmlParser;
-import fc.util.Util;
import fc.xml.xas.EndDocument;
import fc.xml.xas.EndTag;
import fc.xml.xas.Item;
import fc.xml.xas.ItemList;
import fc.xml.xas.ItemSource;
import fc.xml.xas.ItemTarget;
-import fc.xml.xas.MutableFragmentPointer;
import fc.xml.xas.Qname;
import fc.xml.xas.Queryable;
import fc.xml.xas.StartDocument;
import fc.xml.xas.StartTag;
-import fc.xml.xas.Text;
import fc.xml.xas.XasFragment;
import fc.xml.xas.XasUtil;
import fc.xml.xas.XmlPullSource;
@@ -245,11 +242,13 @@ public Person(String name, int age, Calendar birthday) {
}
+ @Override
public int hashCode() {
return name.hashCode() ^ age ^ birthday.hashCode();
}
+ @Override
public boolean equals(Object o) {
if (o instanceof Person) {
Person p = (Person) o;
@@ -260,6 +259,7 @@ public boolean equals(Object o) {
}
+ @Override
public String toString() {
return "Person(name=" + name + ",age=" + age + ",birthday=" + birthday + ")";
}
View
2 src/fc/util/ByteArray.java
@@ -94,6 +94,7 @@ public ByteArray intern() {
}
+ @Override
public int hashCode() {
if (hash == 0) {
for (int i = 0; i < data.length; i++) {
@@ -104,6 +105,7 @@ public int hashCode() {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
View
2 src/fc/util/Debug.java
@@ -322,6 +322,7 @@ public static Object sinceFmt(Object handle) {
final long l = since(handle);
return new Object() {
+ @Override
public String toString() {
return l == -1 ? "n/a" : String.valueOf(l) + " msec";
}
@@ -387,6 +388,7 @@ public static Object getFmt(Object handle) {
final long l = get(handle);
return new Object() {
+ @Override
public String toString() {
return l == NO_VALUE ? "n/a" : String.valueOf(l);
}
View
2 src/fc/util/ImmutableArrayList.java
@@ -59,6 +59,7 @@ public boolean contains(Object o) {
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < len; i++) {
@@ -114,6 +115,7 @@ public void clear() {
}
+ @Override
public boolean equals(Object o) {
throw new UnsupportedOperationException();
}
View
1 src/fc/util/Measurer.java
@@ -154,6 +154,7 @@ public Enumeration keys() {
* @deprecated A drop-in replacement is {@link #outputSummary(PrintStream)} but
* {@link #outputFull(PrintStream)} is preferable
*/
+ @Deprecated
public void output(PrintStream out) {
outputSummary(out);
}
View
1 src/fc/util/Queue.java
@@ -97,6 +97,7 @@ public boolean empty() {
}
+ @Override
public String toString() {
Node node = head;
StringBuffer result = new StringBuffer("[");
View
10 src/fc/util/RaInputStream.java
@@ -14,6 +14,7 @@
import java.io.RandomAccessFile;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
/**
* @author Tancred Lindholm
@@ -48,6 +49,7 @@ public RandomAccessFile swapFile(RandomAccessFile f2) throws IOException {
}
+ @Override
public int read() throws IOException {
if (left <= 0) {
left = file.read(buffer);
@@ -64,11 +66,13 @@ public int read() throws IOException {
}
+ @Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
+ @Override
public int read(byte[] b, int off, int len) throws IOException {
if (left > 0) {
// First, return any bytes left in internal buffer
@@ -107,15 +111,16 @@ public int read(byte[] b, int off, int len) throws IOException {
}
+ @Override
public void close() throws IOException {
file.close();
}
public void seek(long pos) throws IOException {
- if (Log.isEnabled(Log.TRACE)) {
+ if (Log.isEnabled(LogLevels.TRACE)) {
Log.log("seek(" + pos + "), bOff=" + currentFilePos + " offset=" + offset +
- ", length=" + left, Log.TRACE);
+ ", length=" + left, LogLevels.TRACE);
}
if (pos == currentFilePos - left) // Check quickly for NOP seek
return;
@@ -140,6 +145,7 @@ public void seek(long pos) throws IOException {
}
+ @Override
public String toString() {
try {
return "RaInputStream(" + (currentFilePos - left) + ", " + file.length() + ")";
View
1 src/fc/util/RingBuffer.java
@@ -180,6 +180,7 @@ public void removeFirst(int amount) {
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder("RingBuffer(");
for (int i = 0; i < size(); i++) {
View
3 src/fc/util/Utf8Reader.java
@@ -40,6 +40,7 @@ public Utf8Reader(SeekableInputStream in) {
}
+ @Override
public int read(char[] cbuf, int off, int len) throws IOException {
int olen = len;
len = len > MAX_CHUNK ? MAX_CHUNK : len;
@@ -52,11 +53,13 @@ public int read(char[] cbuf, int off, int len) throws IOException {
}
+ @Override
public void close() throws IOException {
in.close();
}
+ @Override
public int read() throws IOException {
return nextChar();
}
View
3 src/fc/util/Util.java
@@ -279,14 +279,17 @@ public static final boolean isEmpty(String s) {
public static final OutputStream SINK = new OutputStream() {
// NOTE: Overriding all variants to avoid calling write(byte) n times
+ @Override
public void write(int b) throws IOException {
}
+ @Override
public void write(byte[] b, int off, int len) throws IOException {
}
+ @Override
public void write(byte[] b) throws IOException {
}
View
36 src/fc/util/log/AbstractLogger.java
@@ -31,14 +31,14 @@
* values for this property are given by each log level in {@link LogLevels}. It may be freely
* changed at run time with the changes being visible in the object's behavior.
*/
- protected int minLevel = Logger.INFO;
+ protected int minLevel = LogLevels.INFO;
protected AbstractLogger() {
String level = System.getProperty(PROPERTY_LEVEL);
if (level != null) {
- for (int i = 0; i < Logger.names.length; i++) {
- if (level.equals(Logger.names[i])) {
+ for (int i = 0; i < LogLevels.names.length; i++) {
+ if (level.equals(LogLevels.names[i])) {
minLevel = i;
break;
}
@@ -95,77 +95,77 @@ public void log(Object message, int level, Throwable cause) {
public void debug(Object message) {
- log(message, Log.DEBUG);
+ log(message, LogLevels.DEBUG);
}
public void debug(Object message, Throwable cause) {
- log(message, Log.DEBUG, cause);
+ log(message, LogLevels.DEBUG, cause);
}
public void debug(Object message, Object data) {
- log(message, Log.DEBUG, data);
+ log(message, LogLevels.DEBUG, data);
}
public void info(Object message) {
- log(message, Log.INFO);
+ log(message, LogLevels.INFO);
}
public void info(Object message, Throwable cause) {
- log(message, Log.INFO, cause);
+ log(message, LogLevels.INFO, cause);
}
public void info(Object message, Object data) {
- log(message, Log.INFO, data);
+ log(message, LogLevels.INFO, data);
}
public void warning(Object message) {
- log(message, Log.WARNING);
+ log(message, LogLevels.WARNING);
}
public void warning(Object message, Throwable cause) {
- log(message, Log.WARNING, cause);
+ log(message, LogLevels.WARNING, cause);
}
public void warning(Object message, Object data) {
- log(message, Log.WARNING, data);
+ log(message, LogLevels.WARNING, data);
}
public void error(Object message) {
- log(message, Log.ERROR);
+ log(message, LogLevels.ERROR);
}
public void error(Object message, Throwable cause) {
- log(message, Log.ERROR, cause);
+ log(message, LogLevels.ERROR, cause);
}
public void error(Object message, Object data) {
- log(message, Log.ERROR, data);
+ log(message, LogLevels.ERROR, data);
}
public void fatal(Object message) {
- log(message, Log.FATALERROR);
+ log(message, LogLevels.FATALERROR);
}
public void fatal(Object message, Throwable cause) {
- log(message, Log.FATALERROR, cause);
+ log(message, LogLevels.FATALERROR, cause);
}
public void fatal(Object message, Object data) {
- log(message, Log.FATALERROR, data);
+ log(message, LogLevels.FATALERROR, data);
}
View
3 src/fc/util/log/GroupLogger.java
@@ -77,6 +77,7 @@ public boolean isInstalled() {
/**
* Call the current group's logger's corresponding method.
*/
+ @Override
public boolean isEnabled(int level) {
ThreadGroup group = Thread.currentThread().getThreadGroup();
Logger logger = loggers.get(group);
@@ -91,6 +92,7 @@ public boolean isEnabled(int level) {
/**
* Call the current group's logger's corresponding method.
*/
+ @Override
public void log(Object message, int level) {
ThreadGroup group = Thread.currentThread().getThreadGroup();
Logger logger = loggers.get(group);
@@ -112,6 +114,7 @@ public void log(Object message, int level, Object data) {
}
+ @Override
public OutputStream getLogStream(int level) {
ThreadGroup group = Thread.currentThread().getThreadGroup();
Logger logger = loggers.get(group);
View
36 src/fc/util/log/Log.java
@@ -109,92 +109,92 @@ public static void log(Object message, int level, Object data) {
public static void trace(Object message) {
- log(message, Log.TRACE);
+ log(message, LogLevels.TRACE);
}
public static void trace(Object message, Throwable cause) {
- log(message, Log.TRACE, cause);
+ log(message, LogLevels.TRACE, cause);
}
public static void trace(Object message, Object data) {
- log(message, Log.TRACE, data);
+ log(message, LogLevels.TRACE, data);
}
public static void debug(Object message) {
- log(message, Log.DEBUG);
+ log(message, LogLevels.DEBUG);
}
public static void debug(Object message, Throwable cause) {
- log(message, Log.DEBUG, cause);
+ log(message, LogLevels.DEBUG, cause);
}
public static void debug(Object message, Object data) {
- log(message, Log.DEBUG, data);
+ log(message, LogLevels.DEBUG, data);
}
public static void info(Object message) {
- log(message, Log.INFO);
+ log(message, LogLevels.INFO);
}
public static void info(Object message, Throwable cause) {
- log(message, Log.INFO, cause);
+ log(message, LogLevels.INFO, cause);
}
public static void info(Object message, Object data) {
- log(message, Log.INFO, data);
+ log(message, LogLevels.INFO, data);
}
public static void warning(Object message) {
- log(message, Log.WARNING);
+ log(message, LogLevels.WARNING);
}
public static void warning(Object message, Throwable cause) {
- log(message, Log.WARNING, cause);
+ log(message, LogLevels.WARNING, cause);
}
public static void warning(Object message, Object data) {
- log(message, Log.WARNING, data);
+ log(message, LogLevels.WARNING, data);
}
public static void error(Object message) {
- log(message, Log.ERROR);
+ log(message, LogLevels.ERROR);
}
public static void error(Object message, Throwable cause) {
- log(message, Log.ERROR, cause);
+ log(message, LogLevels.ERROR, cause);
}
public static void error(Object message, Object data) {
- log(message, Log.ERROR, data);
+ log(message, LogLevels.ERROR, data);
}
public static void fatal(Object message) {
- log(message, Log.FATALERROR);
+ log(message, LogLevels.FATALERROR);
}
public static void fatal(Object message, Throwable cause) {
- log(message, Log.FATALERROR, cause);
+ log(message, LogLevels.FATALERROR, cause);
}
public static void fatal(Object message, Object data) {
- log(message, Log.FATALERROR, data);
+ log(message, LogLevels.FATALERROR, data);
}
View
1 src/fc/util/log/StreamLogger.java
@@ -124,6 +124,7 @@ public OutputStream getLogStream(int level) {
return new FilterOutputStream(out) {
+ @Override
public void close() throws IOException {
flush();
StreamLogger.this.out.println("<<EOS");
View
16 src/fc/xml/diff/Diff.java
@@ -25,6 +25,7 @@
import org.xmlpull.v1.XmlPullParser;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.util.log.StreamLogger;
import fc.xml.diff.encode.AlignEncoder;
import fc.xml.diff.encode.DiffEncoder;
@@ -64,7 +65,7 @@ public static void main(String[] args) throws IOException {
try {
encoder = encoderName != null ? Class.forName(encoderName) : null;
} catch (ClassNotFoundException ex) {
- Log.log("Cannot locate encoder " + encoderName, Log.FATALERROR);
+ Log.log("Cannot locate encoder " + encoderName, LogLevels.FATALERROR);
}
}
if (filterName != null) {
@@ -73,12 +74,12 @@ public static void main(String[] args) throws IOException {
try {
filter = filterName != null ? Class.forName(filterName) : null;
} catch (ClassNotFoundException ex) {
- Log.log("Cannot locate filter " + filterName, Log.FATALERROR);
+ Log.log("Cannot locate filter " + filterName, LogLevels.FATALERROR);
}
}
if (args.length < 2) {
Log.log("Usage [-Dencoder={xml,ref,align,<class>}] [-Dfilter={simple,<class>}] "
- + "base.xml new.xml [out.xml]", Log.ERROR);
+ + "base.xml new.xml [out.xml]", LogLevels.ERROR);
System.exit(1);
}
OutputStream dout = System.out;
@@ -88,7 +89,7 @@ public static void main(String[] args) throws IOException {
if (args.length > 2 && !"-".equals(args[2])) dout = new FileOutputStream(args[2]);
diff(base, updated, dout, filter, encoder, null /* options */, true);
} catch (IOException ex) {
- Log.log("I/O error while diffing", Log.ERROR, ex);
+ Log.log("I/O error while diffing", LogLevels.ERROR, ex);
} finally {
if (dout != System.out) dout.close();
}
@@ -130,9 +131,9 @@ public static boolean diff(ItemSource baseEs, XmlPullParser baseParser, ItemSour
}
if (isEmpty) {
Log.log("Documents identical " + " (" + base.size() + " XAS events in " +
- (_stop - _start) + "ms).", Log.INFO);
+ (_stop - _start) + "ms).", LogLevels.INFO);
} else {
- Log.log("Documents differ.", Log.INFO);
+ Log.log("Documents differ.", LogLevels.INFO);
// Log.log("Match list is "+ml,Log.DEBUG);
}
@@ -147,7 +148,8 @@ public static boolean diff(InputStream bases, InputStream docs, OutputStream dou
throws IOException {
ItemSource docpa = IoUtil.getXmlParser(docs);
ItemSource basepa = IoUtil.getXmlParser(bases);
- Log.log("Comparing by filter " + (filter == null ? "<none>" : filter.getName()), Log.INFO);
+ Log.log("Comparing by filter " + (filter == null ? "<none>" : filter.getName()),
+ LogLevels.INFO);
return diff(IoUtil.getEventSequence(basepa, filter), null, // FIXME-20061113-3:
// Passing
View
17 src/fc/xml/diff/GlMatcher.java
@@ -20,6 +20,7 @@
import java.util.ListIterator;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
/**
* Rolling window matcher. Should be wickedly fast for small changes. Inspired by rsync algorithms.
@@ -78,7 +79,7 @@ public GlMatcher(HashAlgorithm<E> ha) {
// Test position() consistency
private static final <E> boolean _testPositionConsistency(List<Segment<E>> ml) {
- Log.log("testing position list consistency", Log.INFO);
+ Log.log("testing position list consistency", LogLevels.INFO);
int pos = 0;
for (Segment<E> s : ml) {
if (pos != s.getPosition()) return false;
@@ -229,10 +230,10 @@ protected void findChunks(List<Segment<E>> currentOps, List<Segment<E>> base, in
// Flush any collated inserts
if (collatedIns != null && (scanpos == -1 || !i.hasNext() || match != null)) {
int origin = collatedIns.getOffset();
- collatedIns = collatedIns.createIns(origin + m.getOffset(),
- m.getInsert().subList(origin,
- origin + collatedLen),
- origin + m.getPosition());
+ collatedIns = Segment.createIns(
+ origin + m.getOffset(),
+ m.getInsert().subList(origin, origin + collatedLen),
+ origin + m.getPosition());
i.add(collatedIns);
collatedIns = null;
}
@@ -282,7 +283,8 @@ protected void findChunks(List<Segment<E>> currentOps, List<Segment<E>> base, in
if (tokenBoundaries != null) {
int start = -1, end = -1, regionMax = region.getOffset() + region.getLength(), regionMin = region.getOffset();
Log.log("Unaligned match is " +
- region.getInsert().subList(offlen[0], offlen[0] + offlen[1]), Log.INFO);
+ region.getInsert().subList(offlen[0], offlen[0] + offlen[1]),
+ LogLevels.INFO);
// Try alignment on token boundaries
// Determine low
{
@@ -325,7 +327,8 @@ protected void findChunks(List<Segment<E>> currentOps, List<Segment<E>> base, in
assert (region.getLength() == region.getInsert().size());
// Log.log("=== off "+offlen[0]+", len="+offlen[1],Log.INFO);
Log.log("Aligned match is " +
- region.getInsert().subList(offlen[0], offlen[0] + offlen[1]), Log.INFO);
+ region.getInsert().subList(offlen[0], offlen[0] + offlen[1]),
+ LogLevels.INFO);
}
baseRegions.remove(i); // NOTE: i.remove() is wrong; watch out
// for this
View
30 src/fc/xml/diff/Patch.java
@@ -16,37 +16,23 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.Stack;
-
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.util.log.StreamLogger;
-import fc.xml.diff.encode.XmlDiffEncoder;
-import fc.xml.xas.AttributeNode;
-import fc.xml.xas.IdentityTransform;
import fc.xml.xas.Item;
import fc.xml.xas.ItemSource;
import fc.xml.xas.ItemTarget;
-import fc.xml.xas.ItemTransform;
import fc.xml.xas.ParserSource;
-import fc.xml.xas.StartTag;
import fc.xml.xas.TransformSource;
import fc.xml.xas.TransformTarget;
-import fc.xml.xas.XasDebug;
-import fc.xml.xas.XasUtil;
import fc.xml.xas.XmlOutput;
import fc.xml.xas.transform.CoalesceContent;
import fc.xml.xas.transform.DataItems;
import fc.xml.xas.transform.NsPrefixFixer;
import fc.xml.xmlr.IdAddressableRefTree;
import fc.xml.xmlr.NodeNotFoundException;
-import fc.xml.xmlr.NodeReference;
import fc.xml.xmlr.RefTree;
import fc.xml.xmlr.RefTrees;
-import fc.xml.xmlr.TreeReference;
-import fc.xml.xmlr.model.StringKey;
import fc.xml.xmlr.model.TransientKey;
import fc.xml.xmlr.model.TreeModel;
import fc.xml.xmlr.model.TreeModels;
@@ -56,8 +42,6 @@
import fc.xml.xmlr.xas.MutableDeweyRefTree;
import fc.xml.xmlr.xas.PeekableItemSource;
import fc.xml.xmlr.xas.RefItem;
-import fc.xml.xmlr.xas.RefNodeItem;
-import fc.xml.xmlr.xas.RefTreeItem;
import fc.xml.xmlr.xas.ReferenceItemTransform;
import fc.xml.xmlr.xas.XasSerialization;
@@ -141,19 +125,19 @@ public static void patch(File basef, File patchf, OutputStream pout) {
XasSerialization.writeTree(patched, wr, baseXpCC);
// End verify
} catch (NodeNotFoundException ex) {
- Log.log("Patch references illegal node " + ex.getId(), Log.ERROR, ex);
+ Log.log("Patch references illegal node " + ex.getId(), LogLevels.ERROR, ex);
} catch (FileNotFoundException ex) {
- Log.log(ex.getMessage(), Log.ERROR);
+ Log.log(ex.getMessage(), LogLevels.ERROR);
} catch (IOException ex) {
- Log.log("Patch I/O exception", Log.FATALERROR, ex);
+ Log.log("Patch I/O exception", LogLevels.FATALERROR, ex);
} finally {
try {
for (InputStream in : new InputStream[] { vBaseIn, vDiffIn })
if (in != null) {
in.close();
}
} catch (IOException ex1) {
- Log.log("Can't close an input file stream", Log.FATALERROR, ex1);
+ Log.log("Can't close an input file stream", LogLevels.FATALERROR, ex1);
}
}
}
@@ -170,15 +154,15 @@ private static TransformSource makeInputFilter(ItemSource s) {
public static void main(String[] args) throws IOException {
Log.setLogger(new StreamLogger(System.err));
if (args.length < 2) {
- Log.log("Usage base.xml diff.xml [patched.xml]", Log.ERROR);
+ Log.log("Usage base.xml diff.xml [patched.xml]", LogLevels.ERROR);
System.exit(1);
}
OutputStream dout = System.out;
try {
if (args.length > 2 && !"-".equals(args[2])) dout = new FileOutputStream(args[2]);
patch(new File(args[0]), new File(args[1]), dout);
} catch (IOException ex) {
- Log.log("IO error while patching", Log.ERROR, ex);
+ Log.log("IO error while patching", LogLevels.ERROR, ex);
} finally {
if (dout != System.out) dout.close();
}
View
1 src/fc/xml/diff/Segment.java
@@ -85,6 +85,7 @@ public int getInsertLen() {
}
+ @Override
public String toString() {
String insstr = ins != null ? ins.toString() : null;
if (insstr != null && insstr.length() > 48)
View
34 src/fc/xml/diff/benchmark/BenchMark.java
@@ -26,6 +26,7 @@
import junit.framework.TestCase;
import fc.util.IOUtil;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
public class BenchMark extends TestCase {
@@ -44,11 +45,11 @@ public BenchMark(String[] settings, String name) {
}
System.setProperties(setup);
} catch (IOException ex) {
- Log.log("Can't load settings", Log.FATALERROR);
+ Log.log("Can't load settings", LogLevels.FATALERROR);
}
workDir = new File(setup.getProperty("workdir", "+tmp-test"));
if (!workDir.exists() && !workDir.mkdir())
- Log.log("Can't create workdir " + workDir, Log.FATALERROR);
+ Log.log("Can't create workdir " + workDir, LogLevels.FATALERROR);
}
@@ -78,22 +79,23 @@ protected void exec(final String program, final String[] args, final boolean std
}
final Thread runner = new Thread() {
+ @Override
public void run() {
try {
main.invoke(null, new Object[] { args });
} catch (InvocationTargetException ex) {
if (ex.getCause() instanceof ThreadDeath) Log.log(
"Killed by timeout",
- Log.WARNING);
- else Log.log("Exception executing " + program, Log.ERROR, ex);
+ LogLevels.WARNING);
+ else Log.log("Exception executing " + program, LogLevels.ERROR, ex);
} catch (IllegalArgumentException ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
} catch (IllegalAccessException ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
} catch (ThreadDeath ex) {
- Log.log("Killed by timeout", Log.WARNING);
+ Log.log("Killed by timeout", LogLevels.WARNING);
} catch (Throwable ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
}
}
};
@@ -124,11 +126,11 @@ public void run() {
}
}
} catch (SecurityException ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
} catch (NoSuchMethodException ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
} catch (ClassNotFoundException ex) {
- Log.log("Exception executing " + program, Log.ERROR, ex);
+ Log.log("Exception executing " + program, LogLevels.ERROR, ex);
}
} else {
// Log.log("SPAWN: "+program+" to "+timeout,Log.INFO);
@@ -145,11 +147,12 @@ public void run() {
final Thread mainThread = Thread.currentThread();
Thread watchDog = new Thread() {
+ @Override
public void run() {
try {
// Log.log("Watchdog sleeping " + timeout, Log.INFO);
Thread.sleep(timeout);
- Log.log("Interrupting process.", Log.WARNING);
+ Log.log("Interrupting process.", LogLevels.WARNING);
mainThread.interrupt();// mainThread.interrupt();
} catch (InterruptedException ex) {
; // Log.log("Watchdog done " + timeout, Log.INFO);
@@ -159,20 +162,21 @@ public void run() {
watchDog.start();
(new Thread() {
+ @Override
public void run() {
OutputStream lout = System.out;
try {
if (logFile != null) lout = new FileOutputStream(logFile);
IOUtil.copyStream(stderr ? p.getErrorStream() : p.getInputStream(), lout);
} catch (IOException ex) {
- Log.log("Error copying process out", Log.ERROR);
+ Log.log("Error copying process out", LogLevels.ERROR);
} finally {
if (logFile != null) {
try {
lout.flush();
lout.close();
} catch (IOException ex) {
- Log.log("Cannot close log-out", Log.ERROR);
+ Log.log("Cannot close log-out", LogLevels.ERROR);
}
}
}
@@ -184,7 +188,7 @@ public void run() {
getSetProperty("killed", 0);
// Log.log("Ending wait4",Log.INFO);
} catch (InterruptedException ex) {
- Log.log("Timeout of " + program + ", now I kill it", Log.WARNING);
+ Log.log("Timeout of " + program + ", now I kill it", LogLevels.WARNING);
p.destroy();
getSetProperty("killed", 1);
}
View
41 src/fc/xml/diff/benchmark/SynteticDirTree.java
@@ -19,6 +19,7 @@
import fc.util.Util;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.util.log.SysoutLogger;
import fc.xml.diff.IoUtil;
import fc.xml.diff.test.DirTreeGenerator;
@@ -79,7 +80,7 @@ public void start() {
String patcher = getSetProperty("patcher", "!fc.xml.diff.Patch");
String harvester = getSetProperty("reporter", null);
String baseName = getSetProperty("basefile", "b.xml");
- Log.log("basename=" + baseName, Log.INFO);
+ Log.log("basename=" + baseName, LogLevels.INFO);
String newName = getSetProperty("newfile", "n.xml");
String diffName = getSetProperty("deltafile", "d.xml");
String diffLogFile = getSetProperty("difflog", null);
@@ -100,7 +101,8 @@ public void start() {
try {
DirTreeGenerator.permutateTree(dt, edits, pdf, DELTREEP, rnd);
} catch (Exception ex) {
- Log.log("Dirtree generator bombed; not computing this lap", Log.ERROR, ex);
+ Log.log("Dirtree generator bombed; not computing this lap",
+ LogLevels.ERROR, ex);
continue;
}
// Flush trees to disk
@@ -114,14 +116,15 @@ public void start() {
IoUtil.writeRefTree(dt, newf, new DirTreeGenerator.DirTreeModel());
deltaf = new File(workDir, diffName);
} catch (IOException ex) {
- Log.log("Error writing test trees. WorkDir=" + workDir, Log.FATALERROR, ex);
+ Log.log("Error writing test trees. WorkDir=" + workDir,
+ LogLevels.FATALERROR, ex);
}
long dstart = 0, dend = -1;
try {
// Do a match test
// Calm down
if (deltaf.exists() && !deltaf.delete())
- Log.log("Cannot remove old " + deltaf, Log.ERROR);
+ Log.log("Cannot remove old " + deltaf, LogLevels.ERROR);
/*
* for( int i=0;i<10;i++) try { System.gc(); Thread.sleep(100); } catch(
* InterruptedException ex){};
@@ -132,12 +135,12 @@ public void start() {
deltaf.toString() }, true, diffLogFile, timeout);
dend = System.currentTimeMillis();
if (--forceStop == 0) {
- Log.log("===FORCED TEST STOP===", Log.INFO);
+ Log.log("===FORCED TEST STOP===", LogLevels.INFO);
return;
}
- Log.log("Done in " + (dend - dstart) + " msec", Log.INFO);
+ Log.log("Done in " + (dend - dstart) + " msec", LogLevels.INFO);
} catch (Exception ex) {
- Log.log("FAILED: ", Log.ERROR, ex);
+ Log.log("FAILED: ", LogLevels.ERROR, ex);
}
if (verify) verifyDiff(patcher, basef, newf, deltaf);
try {
@@ -149,7 +152,7 @@ public void start() {
exec(harvester, new String[] {}, false, null, Long.MAX_VALUE);
}
} catch (IOException ex) {
- Log.log("Reporter excepted", Log.ERROR, ex);
+ Log.log("Reporter excepted", LogLevels.ERROR, ex);
}
dt.reset(); // Forget edits in this lap
} // endfor edits
@@ -169,7 +172,7 @@ private void verifyDiff(String patcher, File basef, File newf, File deltaf) {
try {
File patchf = new File(workDir, "p.xml");
if (patchf.exists() && !patchf.delete())
- Log.log("Cannot remove old " + patchf, Log.ERROR);
+ Log.log("Cannot remove old " + patchf, LogLevels.ERROR);
exec(patcher, new String[] { basef.toString(), deltaf.toString(), patchf.toString() },
true, null, Long.MAX_VALUE);
vPatchIn = new FileInputStream(patchf);
@@ -187,15 +190,15 @@ private void verifyDiff(String patcher, File basef, File newf, File deltaf) {
refTreeCmp(pT.getRoot(), nT.getRoot(), nT, null);
// End verify
} catch (IOException ex) {
- Log.log("Verify IOExcepted", Log.FATALERROR, ex);
+ Log.log("Verify IOExcepted", LogLevels.FATALERROR, ex);
} finally {
try {
for (InputStream in : new InputStream[] { vPatchIn, vNewIn })
if (in != null) {
in.close();
}
} catch (IOException ex1) {
- Log.log("Can't close a verify stream", Log.FATALERROR, ex1);
+ Log.log("Can't close a verify stream", LogLevels.FATALERROR, ex1);
}
}
}
@@ -207,32 +210,34 @@ public static void refTreeCmp(RefTreeNode n1, RefTreeNode n2, IdAddressableRefTr
Object c2 = n2.getContent();
if (n1.isNodeRef()) {
RefTreeNode refd = base.getNode(n1.getId());
- if (refd == null) Log.log("Broken noderef " + n1.getId(), Log.FATALERROR);
+ if (refd == null) Log.log("Broken noderef " + n1.getId(), LogLevels.FATALERROR);
c1 = refd.getContent();
} else if (n2.isNodeRef()) {
- Log.log("May not have refs", Log.FATALERROR);
+ Log.log("May not have refs", LogLevels.FATALERROR);
/*
* if (!n2.getId().equals(n1.getId())) Log.log("Mismatching n2 noderef: " + n1.getId() +
* "," + n2.getId(), Log.FATALERROR);
*/
}
if (!Util.equals(c1, c2)) {
if (rtId != null)
- Log.log("The following error occured when comparing in treeref " + rtId, Log.ERROR);
+ Log.log("The following error occured when comparing in treeref " + rtId,
+ LogLevels.ERROR);
String c1s = n1.isNodeRef() ? "#node ref " + n1.getId() : c1.toString();
- Log.log("Mismatching content " + "\nP:" + c1s + "\nF:" + c2.toString(), Log.FATALERROR);
+ Log.log("Mismatching content " + "\nP:" + c1s + "\nF:" + c2.toString(),
+ LogLevels.FATALERROR);
}
for (Iterator i = n1.getChildIterator(), j = n2.getChildIterator(); i.hasNext() &&
j.hasNext();) {
RefTreeNode cn1 = (RefTreeNode) i.next(), cn2 = (RefTreeNode) j.next();
if (cn1.isTreeRef()) {
RefTreeNode refd = base.getNode(cn1.getId());
- if (refd == null) Log.log("Broken treeref " + cn1.getId(), Log.FATALERROR);
+ if (refd == null) Log.log("Broken treeref " + cn1.getId(), LogLevels.FATALERROR);
refTreeCmp(refd, cn2, base, cn1.getId());
} else if (cn2.isTreeRef()) {
- Log.log("May not have refs", Log.FATALERROR);
+ Log.log("May not have refs", LogLevels.FATALERROR);
} else refTreeCmp(cn1, cn2, base, null);
- if (i.hasNext() != j.hasNext()) Log.log("Differing child count", Log.FATALERROR);
+ if (i.hasNext() != j.hasNext()) Log.log("Differing child count", LogLevels.FATALERROR);
}
}
View
3 src/fc/xml/diff/benchmark/UseCases.java
@@ -21,6 +21,7 @@
import java.util.TreeMap;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import junit.framework.Assert;
public class UseCases extends BenchMark {
@@ -124,7 +125,7 @@ protected void doDiff(File basef, File newf, File deltaf) throws IOException {
(long) (1000 * getSetProperty("timeout", 1000000000.0)));
} catch (Exception ex) {
fail++;
- Log.log("FAILED: ", Log.ERROR, ex);
+ Log.log("FAILED: ", LogLevels.ERROR, ex);
return;
}
System.setProperty("lap.time", String.valueOf(System.currentTimeMillis() - now));
View
3 src/fc/xml/diff/encode/ListOfMatchedEvents.java
@@ -100,6 +100,7 @@ public int getCurrentPosition() {
}
+ @Override
public boolean equals(Object obj) {
throw new UnsupportedOperationException();
/*
@@ -108,11 +109,13 @@ public boolean equals(Object obj) {
}
+ @Override
public String toString() {
return el.toString();
}
+ @Override
public int hashCode() {
return el.hashCode();
}
View
1 src/fc/xml/diff/encode/RefTreeByIdEncoder.java
@@ -13,7 +13,6 @@
import java.io.OutputStream;
import java.util.List;
-import fc.util.log.Log;
import fc.xml.diff.Segment;
import fc.xml.xas.Item;
import fc.xml.xas.Qname;
View
6 src/fc/xml/diff/encode/RefTreeEncoder.java
@@ -20,6 +20,7 @@
import fc.util.StringUtil;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.xml.diff.Segment;
import fc.xml.xas.EndDocument;
import fc.xml.xas.Item;
@@ -295,14 +296,14 @@ public NumericXPath(NumericXPath base) {
public void moveto(int target) {
int _op = pos;
if (target < pos) {
- Log.log("Backing: target=" + target + ", pos=" + pos, Log.FATALERROR,
+ Log.log("Backing: target=" + target + ", pos=" + pos, LogLevels.FATALERROR,
new Throwable());
}
assert (target >= pos); // Never go back.
for (; pos < target; pos++) {
Item e = es.get(pos);
if (e == null && es.get(pos - 1) == null)
- Log.log("Moved >1 beyond ED(). This should not happen...", Log.WARNING);
+ Log.log("Moved >1 beyond ED(). This should not happen...", LogLevels.WARNING);
int type = e == null ? -1 : e.getType(); // Allow moving beyond
// ED
lastWasText = isTextLike(e);
@@ -354,6 +355,7 @@ public void forwardNextDown() {
};
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i++) {
View
1 src/fc/xml/diff/encode/XmlDiffEncoder.java
@@ -29,6 +29,7 @@
public class XmlDiffEncoder extends RefTreeEncoder {
+ @Override
protected ItemSource getOuputTransform(ItemSource is) {
return new TransformSource(new TransformSource(is, new RefEStoDiffES()),
new NsPrefixFixer());
View
42 src/fc/xml/diff/test/DirTreeGenerator.java
@@ -24,6 +24,7 @@
import fc.util.Util;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.xml.xas.AttributeNode;
import fc.xml.xas.Item;
import fc.xml.xas.ItemTarget;
@@ -101,9 +102,9 @@ public int compare(Object o1, Object o2) {
int dscan = treeNodes.size();
while (((DirectoryEntry) rndDirNode.getContent()).getType() == DirectoryEntry.FILE) {
pos = nextPos(pos, treeNodes);
- rndDirNode = (RefTreeNode) t.getNode(StringKey.createKey((String) pos));
+ rndDirNode = t.getNode(StringKey.createKey((String) pos));
dscan--;
- if (dscan < 0) Log.log("No dir found", Log.ASSERTFAILED);
+ if (dscan < 0) Log.log("No dir found", LogLevels.ASSERTFAILED);
}
// treeNodes.remove(rndId);
// Log.log("Picked "+rndId,Log.INFO);
@@ -151,7 +152,7 @@ public int compare(Object o1, Object o2) {
try {
t.delete(rndNode.getId());
} catch (IllegalArgumentException ex) {
- Log.log("Ignoring ChangeTree delete bug", Log.WARNING);
+ Log.log("Ignoring ChangeTree delete bug", LogLevels.WARNING);
break;
}
treeSet(t, rndNode, treeNodes, '-');
@@ -193,7 +194,7 @@ public int compare(Object o1, Object o2) {
t.move(moveNode, rndDirNode.getId());
break;
default:
- Log.log("Invalid op " + op, Log.ASSERTFAILED);
+ Log.log("Invalid op " + op, LogLevels.ASSERTFAILED);
}
if (redo) {
// Log.log("Redoing failed "+op,Log.INFO);
@@ -202,12 +203,12 @@ public int compare(Object o1, Object o2) {
if (redos > 10) {
redo = false;
redos = 0;
- Log.log("10 redos failed, giving up", Log.INFO);
+ Log.log("10 redos failed, giving up", LogLevels.INFO);
}
}
pos = nextPos(pos, treeNodes).toString();
} catch (NodeNotFoundException ex) {
- Log.log("Selected nonexisting node", Log.FATALERROR);
+ Log.log("Selected nonexisting node", LogLevels.FATALERROR);
}
} // End for
}
@@ -222,7 +223,7 @@ private static void treeSet(fc.xml.xmlr.MutableRefTree t, RefTreeNode root, Set
s.remove(root.getId().toString());
break;
default:
- Log.log("Invalid op " + op, Log.ASSERTFAILED);
+ Log.log("Invalid op " + op, LogLevels.ASSERTFAILED);
}
for (Iterator i = root.getChildIterator(); i.hasNext();) {
treeSet(t, (RefTreeNode) i.next(), s, op);
@@ -267,7 +268,7 @@ public static MutableRefTree randomDirTree(long nodes, long nodesPerDir, double
}
}
} catch (NodeNotFoundException ex) {
- Log.log("Tree construction error", Log.ASSERTFAILED, ex);
+ Log.log("Tree construction error", LogLevels.ASSERTFAILED, ex);
}
return t;
}
@@ -374,11 +375,13 @@ public MutableRefTree(RefTree initTree) {
// The MutableRefTree iface ------
+ @Override
public RefTreeNode getNode(Key id) {
return (RefTreeNode) index.get(id);
}
+ @Override
public void delete(Key id) throws NodeNotFoundException {
RefTreeNodeImpl n = (RefTreeNodeImpl) index.get(id);
if (n == null) throw new NodeNotFoundException(id);
@@ -396,36 +399,40 @@ public void delete(Key id) throws NodeNotFoundException {
}
+ @Override
public Key insert(Key parentId, long pos, Key newId, Object content)
throws NodeNotFoundException {
- if (content == null || pos != MutableRefTree.DEFAULT_POSITION)
- Log.log("Invalid op", Log.ASSERTFAILED);
+ if (content == null || pos != fc.xml.xmlr.MutableRefTree.DEFAULT_POSITION)
+ Log.log("Invalid op", LogLevels.ASSERTFAILED);
RefTreeNodeImpl n = (RefTreeNodeImpl) index.get(parentId);
if (n == null) throw new NodeNotFoundException(parentId);
RefTreeNodeImpl newNode = new RefTreeNodeImpl(n, newId, content);
- if (index.put(newId, newNode) != null) Log.log("Duplicate id", Log.ASSERTFAILED);
+ if (index.put(newId, newNode) != null) Log.log("Duplicate id", LogLevels.ASSERTFAILED);
n.addChild(newNode);
return newId;
}
+ @Override
public Key move(Key nodeId, Key parentId, long pos) throws NodeNotFoundException {
- if (pos != MutableRefTree.DEFAULT_POSITION) Log.log("Invalid op", Log.ASSERTFAILED);
+ if (pos != fc.xml.xmlr.MutableRefTree.DEFAULT_POSITION)
+ Log.log("Invalid op", LogLevels.ASSERTFAILED);
RefTreeNodeImpl n = (RefTreeNodeImpl) index.get(nodeId);
if (n == null) throw new NodeNotFoundException(nodeId);
RefTreeNodeImpl pNew = (RefTreeNodeImpl) index.get(parentId);
if (pNew == null) throw new NodeNotFoundException(parentId);
RefTreeNodeImpl p = (RefTreeNodeImpl) n.getParent();
- if (p == null) Log.log("Tried to move root", Log.ASSERTFAILED);
+ if (p == null) Log.log("Tried to move root", LogLevels.ASSERTFAILED);
p.removeChild(n);
pNew.addChild(n);
// n.setParent(pNew);
return n.getId();
}
+ @Override
public boolean update(Key nodeId, Object content) throws NodeNotFoundException {
- if (content == null) Log.log("Invalid op", Log.ASSERTFAILED);
+ if (content == null) Log.log("Invalid op", LogLevels.ASSERTFAILED);
RefTreeNodeImpl n = (RefTreeNodeImpl) index.get(nodeId);
if (n == null) throw new NodeNotFoundException(nodeId);
if (!content.equals(n.getContent())) {
@@ -442,7 +449,8 @@ public RefTreeNode getRoot() {
private void init(RefTreeNode root) {
- if (index.put(root.getId(), root) != null) Log.log("Duplicate ids", Log.ASSERTFAILED);
+ if (index.put(root.getId(), root) != null)
+ Log.log("Duplicate ids", LogLevels.ASSERTFAILED);
for (Iterator i = root.getChildIterator(); i.hasNext();)
init((RefTreeNode) i.next());
}
@@ -456,6 +464,7 @@ private void init(RefTreeNode root) {
public static final Qname NAME_ATTR = new Qname("", "name");
+ @Override
public void append(Item i) throws IOException {
if (i.getType() == Item.START_TAG) {
StartTag t = (StartTag) i;
@@ -593,13 +602,15 @@ public int getType() {
}
+ @Override
public boolean equals(Object o) {
return o instanceof DirectoryEntry &&
(Util.equals(((DirectoryEntry) o).getId(), getId()) &&
Util.equals(((DirectoryEntry) o).getName(), getName()) && ((DirectoryEntry) o).getType() == getType());
}
+ @Override
public int hashCode() {
return type ^ (name == null ? 0 : name.hashCode()) ^ id.hashCode();
}
@@ -646,6 +657,7 @@ public String getLinkId() {
}
+ @Override
public String toString() {
return (type == FILE ? "file" : (type == DIR ? "dir" : "tree ")) + "{name=" + name +
",...}";
View
5 src/fc/xml/diff/test/RootSuite.java
@@ -15,16 +15,19 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import fc.util.log.Log;
+import fc.util.log.LogLevels;
import fc.util.log.SysoutLogger;
import fc.xml.diff.benchmark.SynteticDirTree;
import fc.xml.diff.benchmark.UseCases;
public class RootSuite extends TestCase {
+ @Override
public void setUp() throws Exception {
}
+ @Override
public void tearDown() throws Exception {
//
}
@@ -45,7 +48,7 @@ public static Test suite() throws IOException {
public void testFixTests() {
- Log.log("Fixing incompatible property setting between tests", Log.WARNING);
+ Log.log("Fixing incompatible property setting between tests", LogLevels.WARNING);
System.setProperty("basefile", "b.xml");
System.setProperty("newfile", "n.xml");
System.setProperty("deltafile", "d.xml");
View
3 src/fc/xml/xas/AttributeNode.java
@@ -58,6 +58,7 @@ void setNext(AttributeNode next) {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -74,6 +75,7 @@ public boolean equals(Object o) {
}
+ @Override
public int hashCode() {
return 37 * name.hashCode() + (value == null ? 0 : value.hashCode());
}
@@ -85,6 +87,7 @@ public int compareTo(AttributeNode a) {
}
+ @Override
public String toString() {
StringBuilder result = new StringBuilder(String.valueOf(name) + "=\"" + value + "\"");
if (next != null) {
View
2 src/fc/xml/xas/Comment.java
@@ -26,6 +26,7 @@ public String getText() {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -38,6 +39,7 @@ public boolean equals(Object o) {
}
+ @Override
public String toString() {
return "C(" + text + ")";
}
View
3 src/fc/xml/xas/Doctype.java
@@ -67,6 +67,7 @@ public void outputSystemLiteral(Writer writer) throws IOException {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -80,11 +81,13 @@ public boolean equals(Object o) {
}
+ @Override
public int hashCode() {
return 37 * (37 * name.hashCode() + systemId.hashCode()) + Util.hashCode(publicId);
}
+ @Override
public String toString() {
return "DTD(" + name + (publicId != null ? " PUBLIC=" + publicId : "") + " SYSTEM=" +
systemId + ")";
View
3 src/fc/xml/xas/EndDocument.java
@@ -24,16 +24,19 @@ private EndDocument() {
}
+ @Override
public String toString() {
return "ED()";
}
+ @Override
public boolean equals(Object o) {
return o == instance;
}
+ @Override
public int hashCode() {
return END_DOCUMENT;
}
View
3 src/fc/xml/xas/EndTag.java
@@ -26,6 +26,7 @@ public Qname getName() {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -38,11 +39,13 @@ public boolean equals(Object o) {
}
+ @Override
public int hashCode() {
return 37 * END_TAG + name.hashCode();
}
+ @Override
public String toString() {
return "ET(" + name + ")";
}
View
2 src/fc/xml/xas/EntityRef.java
@@ -26,6 +26,7 @@ public String getName() {
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -44,6 +45,7 @@ public int hashCode() {
}
+ @Override
public String toString() {
return "ER(" + name + ")";
}
View
3 src/fc/xml/xas/FragmentPointer.java
@@ -152,19 +152,22 @@ public void advanceLevel() {
}
+ @Override
public String toString() {
return "P(" + index + "," + System.identityHashCode(fragment) + ")";
// return "P(" + index + ", " + fragment + ")";
}
+ @Override
public boolean equals(Object o) {
return o != null &&
o == this ||
((o instanceof FragmentPointer) && ((FragmentPointer) o).fragment == fragment && ((FragmentPointer) o).index == index);
}