Permalink
Browse files

Reformatted all the code to match my style

Reformatting and re-indenting once and for all, to avoid polluting the
history again in future! Sorry, it had to be -- I can't face staring at
2-space indents in Java.
  • Loading branch information...
Martin Kleppmann
Martin Kleppmann committed Feb 28, 2009
1 parent d5641b7 commit d3c50d39166af9ade39661d726775007c9575291
Showing with 36,014 additions and 35,664 deletions.
  1. +21 −25 src/fc/test/XmlTest.java
  2. +101 −102 src/fc/test/bench/XmlMemory.java
  3. +77 −83 src/fc/test/bench/XmlPass.java
  4. +155 −155 src/fc/test/junit/XasTest.java
  5. +259 −264 src/fc/test/junit/XmlData.java
  6. +62 −42 src/fc/util/AbstractDictionary.java
  7. +16 −21 src/fc/util/BaInputStream.java
  8. +120 −123 src/fc/util/BinaryData.java
  9. +93 −88 src/fc/util/ByteArray.java
  10. +7 −11 src/fc/util/ByteArrayStream.java
  11. +80 −77 src/fc/util/CompareUtil.java
  12. +313 −296 src/fc/util/Debug.java
  13. +94 −103 src/fc/util/ExtUtil.java
  14. +33 −35 src/fc/util/IOExceptionTrap.java
  15. +247 −234 src/fc/util/IOUtil.java
  16. +171 −136 src/fc/util/ImmutableArrayList.java
  17. +27 −19 src/fc/util/MagicInputStream.java
  18. +214 −192 src/fc/util/Measurer.java
  19. +63 −52 src/fc/util/NonListableSet.java
  20. +16 −17 src/fc/util/Pair.java
  21. +86 −87 src/fc/util/Queue.java
  22. +108 −100 src/fc/util/RaInputStream.java
  23. +156 −149 src/fc/util/RingBuffer.java
  24. +24 −18 src/fc/util/SeekableInputStream.java
  25. +22 −20 src/fc/util/Stack.java
  26. +239 −234 src/fc/util/StringUtil.java
  27. +90 −96 src/fc/util/Utf8Reader.java
  28. +199 −197 src/fc/util/Util.java
  29. +110 −98 src/fc/util/log/AbstractLogger.java
  30. +61 −47 src/fc/util/log/CommonsLogger.java
  31. +65 −65 src/fc/util/log/GroupLogger.java
  32. +126 −112 src/fc/util/log/Log.java
  33. +23 −32 src/fc/util/log/LogLevels.java
  34. +169 −171 src/fc/util/log/Logger.java
  35. +89 −90 src/fc/util/log/StreamLogger.java
  36. +9 −13 src/fc/util/log/SysoutLogger.java
  37. +123 −134 src/fc/xml/diff/Diff.java
  38. +401 −402 src/fc/xml/diff/GlMatcher.java
  39. +10 −9 src/fc/xml/diff/HashAlgorithm.java
  40. +226 −227 src/fc/xml/diff/IoUtil.java
  41. +119 −119 src/fc/xml/diff/Patch.java
  42. +7 −8 src/fc/xml/diff/Preamble.java
  43. +93 −80 src/fc/xml/diff/Segment.java
  44. +184 −187 src/fc/xml/diff/benchmark/BenchMark.java
  45. +200 −211 src/fc/xml/diff/benchmark/SynteticDirTree.java
  46. +133 −131 src/fc/xml/diff/benchmark/UseCases.java
  47. +75 −85 src/fc/xml/diff/encode/AlignEncoder.java
  48. +9 −10 src/fc/xml/diff/encode/DefaultPosTranformer.java
  49. +7 −10 src/fc/xml/diff/encode/DiffEncoder.java
  50. +100 −94 src/fc/xml/diff/encode/ListOfMatchedEvents.java
  51. +15 −16 src/fc/xml/diff/encode/ListPosTransformer.java
  52. +7 −8 src/fc/xml/diff/encode/PosTransformer.java
  53. +49 −52 src/fc/xml/diff/encode/RefTreeByIdEncoder.java
  54. +334 −319 src/fc/xml/diff/encode/RefTreeEncoder.java
  55. +136 −135 src/fc/xml/diff/encode/XmlDiffEncoder.java
  56. +539 −566 src/fc/xml/diff/test/DirTreeGenerator.java
  57. +25 −25 src/fc/xml/diff/test/RootSuite.java
  58. +15 −18 src/fc/xml/xas/AppendableItem.java
  59. +60 −52 src/fc/xml/xas/AttributeNode.java
  60. +28 −25 src/fc/xml/xas/Comment.java
  61. +56 −50 src/fc/xml/xas/Doctype.java
  62. +20 −17 src/fc/xml/xas/EndDocument.java
  63. +29 −26 src/fc/xml/xas/EndTag.java
  64. +28 −25 src/fc/xml/xas/EntityRef.java
  65. +12 −14 src/fc/xml/xas/FormatFactory.java
  66. +116 −112 src/fc/xml/xas/FragmentItem.java
  67. +41 −37 src/fc/xml/xas/FragmentIterator.java
  68. +124 −111 src/fc/xml/xas/FragmentPointer.java
  69. +20 −21 src/fc/xml/xas/IdentityTransform.java
  70. +50 −39 src/fc/xml/xas/Item.java
  71. +75 −61 src/fc/xml/xas/ItemList.java
  72. +13 −17 src/fc/xml/xas/ItemSource.java
  73. +14 −16 src/fc/xml/xas/ItemTarget.java
  74. +18 −20 src/fc/xml/xas/ItemTransform.java
  75. +165 −162 src/fc/xml/xas/MutableFragmentPointer.java
  76. +60 −67 src/fc/xml/xas/MutablePointer.java
  77. +28 −23 src/fc/xml/xas/NullItem.java
  78. +18 −23 src/fc/xml/xas/ParserSource.java
  79. +34 −31 src/fc/xml/xas/Pi.java
  80. +21 −23 src/fc/xml/xas/Pointer.java
  81. +96 −91 src/fc/xml/xas/PrefixNode.java
  82. +41 −36 src/fc/xml/xas/Qname.java
  83. +17 −22 src/fc/xml/xas/Queryable.java
  84. +19 −20 src/fc/xml/xas/SerializableItem.java
  85. +47 −48 src/fc/xml/xas/SerializedFragment.java
  86. +22 −29 src/fc/xml/xas/SerializerTarget.java
  87. +20 −17 src/fc/xml/xas/StartDocument.java
  88. +449 −415 src/fc/xml/xas/StartTag.java
  89. +34 −30 src/fc/xml/xas/TargetOutputStream.java
  90. +29 −26 src/fc/xml/xas/Text.java
  91. +24 −25 src/fc/xml/xas/TransformSource.java
  92. +20 −21 src/fc/xml/xas/TransformTarget.java
  93. +97 −103 src/fc/xml/xas/Verifier.java
  94. +18 −17 src/fc/xml/xas/WrapperItem.java
  95. +27 −26 src/fc/xml/xas/XasDebug.java
  96. +243 −227 src/fc/xml/xas/XasFragment.java
  97. +194 −187 src/fc/xml/xas/XasUtil.java
  98. +16 −16 src/fc/xml/xas/XmlFormatFactory.java
  99. +242 −241 src/fc/xml/xas/XmlOutput.java
  100. +27 −25 src/fc/xml/xas/XmlPullFactory.java
  101. +178 −179 src/fc/xml/xas/XmlPullSource.java
  102. +157 −155 src/fc/xml/xas/XmlPullTarget.java
  103. +188 −208 src/fc/xml/xas/compat/SaxReader.java
  104. +198 −194 src/fc/xml/xas/compat/SaxToItems.java
  105. +211 −202 src/fc/xml/xas/compat/SaxWriter.java
  106. +75 −76 src/fc/xml/xas/compat/XasBridgeSource.java
  107. +22 −22 src/fc/xml/xas/compat/XasBridgeTarget.java
  108. +327 −315 src/fc/xml/xas/index/DeweyKey.java
  109. +28 −27 src/fc/xml/xas/index/Document.java
  110. +125 −114 src/fc/xml/xas/index/GlobalPointer.java
  111. +217 −198 src/fc/xml/xas/index/Index.java
  112. +58 −57 src/fc/xml/xas/index/KeyIterator.java
  113. +396 −403 src/fc/xml/xas/index/LazyFragment.java
  114. +30 −29 src/fc/xml/xas/index/LazyPointer.java
  115. +57 −48 src/fc/xml/xas/index/SeekableKXmlSource.java
  116. +5 −7 src/fc/xml/xas/index/SeekableParserSource.java
  117. +53 −48 src/fc/xml/xas/index/SeekableSource.java
  118. +189 −195 src/fc/xml/xas/index/VersionNode.java
  119. +39 −35 src/fc/xml/xas/index/VersionedDocument.java
  120. +29 −28 src/fc/xml/xas/index/VersionedEntry.java
  121. +174 −170 src/fc/xml/xas/index/VersionedPointer.java
  122. +62 −65 src/fc/xml/xas/transform/CoalesceContent.java
  123. +44 −49 src/fc/xml/xas/transform/DataItems.java
  124. +47 −49 src/fc/xml/xas/transform/NsPrefixFixer.java
  125. +74 −70 src/fc/xml/xas/typing/Codec.java
  126. +105 −103 src/fc/xml/xas/typing/DecodeSource.java
  127. +84 −81 src/fc/xml/xas/typing/ParsedPrimitive.java
  128. +23 −23 src/fc/xml/xas/typing/PrimitiveCodec.java
  129. +73 −77 src/fc/xml/xas/typing/PrimitiveSource.java
  130. +77 −73 src/fc/xml/xas/typing/TypedItem.java
  131. +83 −81 src/fc/xml/xas/typing/TypingUtil.java
  132. +52 −59 src/fc/xml/xas/typing/UnparsedPrimitive.java
  133. +19 −19 src/fc/xml/xas/typing/ValueCodec.java
  134. +168 −169 src/fc/xml/xas/typing/XmlCodec.java
  135. +58 −56 src/fc/xml/xmlr/AbstractMutableRefTree.java
  136. +19 −19 src/fc/xml/xmlr/BatchMutable.java
  137. +488 −477 src/fc/xml/xmlr/ChangeBuffer.java
  138. +571 −516 src/fc/xml/xmlr/ChangeTree.java
  139. +346 −313 src/fc/xml/xmlr/DerefRefTree.java
  140. +49 −39 src/fc/xml/xmlr/IdAddressableRefTree.java
  141. +69 −62 src/fc/xml/xmlr/IdAddressableRefTreeImpl.java
  142. +14 −14 src/fc/xml/xmlr/Key.java
  143. +90 −84 src/fc/xml/xmlr/KeyMap.java
  144. +130 −120 src/fc/xml/xmlr/MutableRefTree.java
  145. +158 −159 src/fc/xml/xmlr/MutableRefTreeImpl.java
  146. +56 −46 src/fc/xml/xmlr/NodeNotFoundException.java
  147. +41 −36 src/fc/xml/xmlr/NodeReference.java
  148. +24 −22 src/fc/xml/xmlr/RefTree.java
  149. +21 −18 src/fc/xml/xmlr/RefTreeImpl.java
  150. +75 −65 src/fc/xml/xmlr/RefTreeNode.java
  151. +270 −246 src/fc/xml/xmlr/RefTreeNodeImpl.java
  152. +1,102 −1,045 src/fc/xml/xmlr/RefTrees.java
  153. +15 −15 src/fc/xml/xmlr/Reference.java
  154. +325 −284 src/fc/xml/xmlr/RekeyedRefTree.java
  155. +42 −37 src/fc/xml/xmlr/TreeReference.java
  156. +282 −260 src/fc/xml/xmlr/XmlrDebug.java
  157. +86 −151 src/fc/xml/xmlr/XmlrUtil.java
  158. +77 −71 src/fc/xml/xmlr/model/IdentificationModel.java
  159. +83 −66 src/fc/xml/xmlr/model/KeyIdentificationModel.java
  160. +47 −49 src/fc/xml/xmlr/model/KeyModel.java
  161. +39 −42 src/fc/xml/xmlr/model/NodeModel.java
  162. +106 −97 src/fc/xml/xmlr/model/StringKey.java
  163. +22 −21 src/fc/xml/xmlr/model/TransientKey.java
  164. +188 −172 src/fc/xml/xmlr/model/TreeModel.java
  165. +54 −54 src/fc/xml/xmlr/model/TreeModels.java
  166. +108 −103 src/fc/xml/xmlr/model/XasCodec.java
  167. +811 −765 src/fc/xml/xmlr/tdm/Diff.java
  168. +557 −521 src/fc/xml/xmlr/tdm/Merge.java
  169. +64 −58 src/fc/xml/xmlr/tdm/Patch.java
  170. +132 −119 src/fc/xml/xmlr/test/DeweyKeyedRefTree.java
  171. +873 −827 src/fc/xml/xmlr/test/RandomDirectoryTree.java
  172. +48 −44 src/fc/xml/xmlr/test/RootSuite.java
  173. +219 −228 src/fc/xml/xmlr/test/TestChangeTree.java
  174. +117 −110 src/fc/xml/xmlr/test/TestDeweyTrees.java
  175. +85 −83 src/fc/xml/xmlr/test/TestMutableTree.java
  176. +292 −326 src/fc/xml/xmlr/test/TestRefTrees.java
  177. +6 −8 src/fc/xml/xmlr/test/TreeUtil.java
  178. +270 −251 src/fc/xml/xmlr/test/XasTests.java
  179. +249 −213 src/fc/xml/xmlr/xas/DeweyKey.java
  180. +224 −208 src/fc/xml/xmlr/xas/DeweyRefNode.java
  181. +135 −129 src/fc/xml/xmlr/xas/DeweyXasSource.java
  182. +227 −205 src/fc/xml/xmlr/xas/IdAttributeXasSource.java
  183. +13 −14 src/fc/xml/xmlr/xas/MalformedXml.java
  184. +416 −421 src/fc/xml/xmlr/xas/MutableDeweyRefTree.java
  185. +92 −84 src/fc/xml/xmlr/xas/PeekableItemSource.java
  186. +65 −52 src/fc/xml/xmlr/xas/RandomAccessSource.java
  187. +191 −179 src/fc/xml/xmlr/xas/RefItem.java
  188. +114 −107 src/fc/xml/xmlr/xas/RefNodeItem.java
  189. +87 −80 src/fc/xml/xmlr/xas/RefTreeItem.java
  190. +25 −23 src/fc/xml/xmlr/xas/ReferenceItemTransform.java
  191. +39 −40 src/fc/xml/xmlr/xas/UniformXasCodec.java
  192. +183 −167 src/fc/xml/xmlr/xas/XasRefTree.java
  193. +319 −295 src/fc/xml/xmlr/xas/XasSerialization.java
  194. +80 −73 src/fuegocore/message/encoding/CachePair.java
  195. +19 −20 src/fuegocore/message/encoding/CoaMachine.java
  196. +52 −63 src/fuegocore/message/encoding/DoaMachine.java
  197. +24 −31 src/fuegocore/message/encoding/EoaMachine.java
  198. +40 −40 src/fuegocore/message/encoding/IdentityDoaMachine.java
  199. +25 −32 src/fuegocore/message/encoding/IdentityEoaMachine.java
  200. +193 −206 src/fuegocore/message/encoding/OutCache.java
  201. +30 −35 src/fuegocore/message/encoding/OutTokenCache.java
  202. +145 −144 src/fuegocore/message/encoding/SequenceCache.java
  203. +26 −27 src/fuegocore/message/encoding/TokenCacheCodecFactory.java
  204. +172 −169 src/fuegocore/message/encoding/XebuCodecFactory.java
  205. +43 −63 src/fuegocore/message/encoding/XebuConstants.java
  206. +1,088 −1,099 src/fuegocore/message/encoding/XebuParser.java
  207. +821 −826 src/fuegocore/message/encoding/XebuSerializer.java
  208. +183 −182 src/fuegocore/message/encoding/XebuUtil.java
  209. +26 −33 src/fuegocore/message/tests/CacheTest.java
  210. +15 −17 src/fuegocore/message/tests/MessageSuite.java
  211. +507 −536 src/fuegocore/message/tests/XebuTest.java
  212. +163 −169 src/fuegocore/util/Base64.java
  213. +512 −534 src/fuegocore/util/ByteBuffer.java
  214. +121 −130 src/fuegocore/util/ExtUtil.java
  215. +26 −19 src/fuegocore/util/MagicInputStream.java
  216. +86 −87 src/fuegocore/util/Queue.java
  217. +54 −63 src/fuegocore/util/RootSuite.java
  218. +107 −123 src/fuegocore/util/TimeMeasurer.java
  219. +161 −168 src/fuegocore/util/Util.java
  220. +44 −46 src/fuegocore/util/tests/Condition.java
  221. +38 −40 src/fuegocore/util/tests/QueueTest.java
  222. +279 −326 src/fuegocore/util/tests/TestConsole.java
  223. +15 −16 src/fuegocore/util/tests/UtilSuite.java
  224. +32 −40 src/fuegocore/util/tests/UtilTest.java
  225. +324 −330 src/fuegocore/util/tests/XasData.java
  226. +81 −85 src/fuegocore/util/tests/XasTest.java
  227. +49 −47 src/fuegocore/util/xas/ChainedContentDecoder.java
  228. +28 −34 src/fuegocore/util/xas/ChainedContentEncoder.java
  229. +37 −40 src/fuegocore/util/xas/CoalescedEventSequence.java
  230. +65 −74 src/fuegocore/util/xas/CodecFactory.java
  231. +107 −120 src/fuegocore/util/xas/CodecIndustry.java
  232. +97 −113 src/fuegocore/util/xas/ContentCodecFactory.java
  233. +157 −166 src/fuegocore/util/xas/ContentDecoder.java
  234. +34 −39 src/fuegocore/util/xas/ContentEncoder.java
  235. +47 −52 src/fuegocore/util/xas/DataEventSequence.java
  236. +34 −37 src/fuegocore/util/xas/DefaultXmlParser.java
  237. +38 −39 src/fuegocore/util/xas/DefaultXmlSerializer.java
  238. +194 −200 src/fuegocore/util/xas/Event.java
  239. +289 −270 src/fuegocore/util/xas/EventList.java
  240. +61 −72 src/fuegocore/util/xas/EventSequence.java
  241. +118 −103 src/fuegocore/util/xas/EventSerializer.java
  242. +248 −245 src/fuegocore/util/xas/EventStream.java
  243. +64 −60 src/fuegocore/util/xas/ForgetfulEventStream.java
  244. +19 −19 src/fuegocore/util/xas/Qname.java
  245. +48 −57 src/fuegocore/util/xas/SaxBridge.java
  246. +225 −249 src/fuegocore/util/xas/SaxReader.java
  247. +154 −159 src/fuegocore/util/xas/SaxWriter.java
  248. +120 −118 src/fuegocore/util/xas/TransformedEventStream.java
  249. +237 −231 src/fuegocore/util/xas/TypedEventStream.java
  250. +21 −28 src/fuegocore/util/xas/TypedXmlParser.java
  251. +24 −30 src/fuegocore/util/xas/TypedXmlSerializer.java
  252. +296 −319 src/fuegocore/util/xas/XasExtUtil.java
  253. +136 −159 src/fuegocore/util/xas/XasUtil.java
  254. +59 −63 src/fuegocore/util/xas/XmlCodecFactory.java
  255. +418 −448 src/fuegocore/util/xas/XmlReader.java
  256. +103 −112 src/fuegocore/util/xas/XmlSchemaContentDecoder.java
  257. +118 −124 src/fuegocore/util/xas/XmlSchemaContentEncoder.java
  258. +357 −346 src/fuegocore/util/xas/XmlTee.java
  259. +257 −248 src/fuegocore/util/xas/XmlWriter.java
  260. +16 −18 src/fuegocore/util/xas/codec/DefaultCodecFactory.java
  261. +34 −35 src/fuegocore/util/xas/codec/EventSequenceCodecFactory.java
  262. +42 −50 src/fuegocore/util/xas/codec/EventSequenceDecoder.java
  263. +25 −29 src/fuegocore/util/xas/codec/EventSequenceEncoder.java
  264. +34 −34 src/fuegocore/util/xas/codec/HashtableCodecFactory.java
  265. +29 −36 src/fuegocore/util/xas/codec/HashtableDecoder.java
  266. +42 −48 src/fuegocore/util/xas/codec/HashtableEncoder.java
  267. +33 −34 src/fuegocore/util/xas/codec/VectorCodecFactory.java
  268. +26 −33 src/fuegocore/util/xas/codec/VectorDecoder.java
  269. +34 −39 src/fuegocore/util/xas/codec/VectorEncoder.java
  270. +1,453 −1,337 src/net/iharder/Base64.java
  271. +465 −582 src/org/kxml2/io/KXmlParser.java
  272. +151 −208 src/org/kxml2/io/KXmlSerializer.java
View
@@ -1,12 +1,10 @@
/*
* Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
+ *
+ * This file is a part of Fuego middleware. Fuego middleware is free software; you can redistribute
+ * it and/or modify it under the terms of the MIT license, included as the file MIT-LICENSE in the
+ * Fuego middleware source distribution. If you did not receive the MIT license with the
+ * distribution, write to the Fuego Core project at fuego-xas-users@hoslab.cs.helsinki.fi.
*/
package fc.test;
@@ -24,24 +22,22 @@
public class XmlTest {
- public static void main (String[] args) {
- try {
- for (String fileName : args) {
- XmlPullParser parser = new KXmlParser();
- ItemSource is =
- new XmlPullSource(parser,
- new FileInputStream(fileName));
- ItemTarget it = new XmlOutput(System.out, "ISO-8859-1");
- for (Item i = is.next(); i != null; i = is.next()) {
- System.out.println(i);
- it.append(i);
- }
- System.out.println();
- System.out.println();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
+ public static void main(String[] args) {
+ try {
+ for (String fileName : args) {
+ XmlPullParser parser = new KXmlParser();
+ ItemSource is = new XmlPullSource(parser, new FileInputStream(fileName));
+ ItemTarget it = new XmlOutput(System.out, "ISO-8859-1");
+ for (Item i = is.next(); i != null; i = is.next()) {
+ System.out.println(i);
+ it.append(i);
+ }
+ System.out.println();
+ System.out.println();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
}
@@ -1,12 +1,10 @@
/*
* Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
+ *
+ * This file is a part of Fuego middleware. Fuego middleware is free software; you can redistribute
+ * it and/or modify it under the terms of the MIT license, included as the file MIT-LICENSE in the
+ * Fuego middleware source distribution. If you did not receive the MIT license with the
+ * distribution, write to the Fuego Core project at fuego-xas-users@hoslab.cs.helsinki.fi.
*/
package fc.test.bench;
@@ -38,107 +36,108 @@
private static Object result = null;
- private static void saxParse (String fileName) throws Exception {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- SAXParser parser = factory.newSAXParser();
- XMLReader reader = parser.getXMLReader();
- DefaultHandler2 handler = new DefaultHandler2();
- reader.setContentHandler(handler);
- reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- handler);
- reader.parse(fileName);
+
+ private static void saxParse(String fileName) throws Exception {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ SAXParser parser = factory.newSAXParser();
+ XMLReader reader = parser.getXMLReader();
+ DefaultHandler2 handler = new DefaultHandler2();
+ reader.setContentHandler(handler);
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
+ reader.parse(fileName);
}
- private static void domParse (String fileName) throws Exception {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document document = builder.parse(fileName);
- Stack<Node> stack = new Stack<Node>();
- stack.push(document);
- while (!stack.isEmpty()) {
- Node node = stack.pop();
- switch (node.getNodeType()) {
- case Node.DOCUMENT_NODE: {
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int n = nodes.getLength();
- for (int i = n - 1; i >= 0; i-- ) {
- stack.push(nodes.item(i));
- }
- }
- }
- case Node.ELEMENT_NODE: {
- NamedNodeMap atts = node.getAttributes();
- if (atts != null) {
- int n = atts.getLength();
- for (int i = 0; i < n; i++ ) {
- Attr att = (Attr) atts.item(i);
- result = att.getNodeName();
- }
- }
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int l = nodes.getLength();
- for (int i = l - 1; i >= 0; i-- ) {
- stack.push(nodes.item(i));
- }
- }
- }
- }
- }
- result = document;
+
+ private static void domParse(String fileName) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(fileName);
+ Stack<Node> stack = new Stack<Node>();
+ stack.push(document);
+ while (!stack.isEmpty()) {
+ Node node = stack.pop();
+ switch (node.getNodeType()) {
+ case Node.DOCUMENT_NODE: {
+ NodeList nodes = node.getChildNodes();
+ if (nodes != null) {
+ int n = nodes.getLength();
+ for (int i = n - 1; i >= 0; i--) {
+ stack.push(nodes.item(i));
+ }
+ }
+ }
+ case Node.ELEMENT_NODE: {
+ NamedNodeMap atts = node.getAttributes();
+ if (atts != null) {
+ int n = atts.getLength();
+ for (int i = 0; i < n; i++) {
+ Attr att = (Attr) atts.item(i);
+ result = att.getNodeName();
+ }
+ }
+ NodeList nodes = node.getChildNodes();
+ if (nodes != null) {
+ int l = nodes.getLength();
+ for (int i = l - 1; i >= 0; i--) {
+ stack.push(nodes.item(i));
+ }
+ }
+ }
+ }
+ }
+ result = document;
}
- private static void xasParse (String fileName) throws Exception {
- InputStream in = new FileInputStream(fileName);
- KXmlParser parser = new KXmlParser();
- XmlPullSource source = new XmlPullSource(parser, in);
- ItemList list = new ItemList();
- Item item;
- while ((item = source.next()) != null) {
- list.append(item);
- }
- result = list;
+
+ private static void xasParse(String fileName) throws Exception {
+ InputStream in = new FileInputStream(fileName);
+ KXmlParser parser = new KXmlParser();
+ XmlPullSource source = new XmlPullSource(parser, in);
+ ItemList list = new ItemList();
+ Item item;
+ while ((item = source.next()) != null) {
+ list.append(item);
+ }
+ result = list;
}
- public static void main (String[] args) {
- try {
- if (args.length != 2) {
- System.err.println("Usage: XmlMemory (sax|dom|xas) <file>");
- System.exit(1);
- }
- long beginMemory = 0;
- int end = 10;
- for (int i = 0; i < end; i++ ) {
- result = null;
- Util.runGc();
- beginMemory = Util.usedMemory();
- if (args[0].equals("sax")) {
- saxParse(args[1]);
- } else if (args[0].equals("dom")) {
- domParse(args[1]);
- } else if (args[0].equals("xas")) {
- xasParse(args[1]);
- } else {
- System.err.println("Usage: XmlMemory (sax|dom|xas) <file>");
- System.exit(1);
- }
- long spentMemory = Util.usedMemory();
- Util.runGc();
- long endMemory = Util.usedMemory();
- System.out.println("Total memory spent: "
- + (spentMemory - beginMemory));
- System.out.println("Object size: " + (endMemory - beginMemory));
- System.out
- .println("Result: " + System.identityHashCode(result));
- }
- // System.in.read();
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
+
+ public static void main(String[] args) {
+ try {
+ if (args.length != 2) {
+ System.err.println("Usage: XmlMemory (sax|dom|xas) <file>");
+ System.exit(1);
+ }
+ long beginMemory = 0;
+ int end = 10;
+ for (int i = 0; i < end; i++) {
+ result = null;
+ Util.runGc();
+ beginMemory = Util.usedMemory();
+ if (args[0].equals("sax")) {
+ saxParse(args[1]);
+ } else if (args[0].equals("dom")) {
+ domParse(args[1]);
+ } else if (args[0].equals("xas")) {
+ xasParse(args[1]);
+ } else {
+ System.err.println("Usage: XmlMemory (sax|dom|xas) <file>");
+ System.exit(1);
+ }
+ long spentMemory = Util.usedMemory();
+ Util.runGc();
+ long endMemory = Util.usedMemory();
+ System.out.println("Total memory spent: " + (spentMemory - beginMemory));
+ System.out.println("Object size: " + (endMemory - beginMemory));
+ System.out.println("Result: " + System.identityHashCode(result));
+ }
+ // System.in.read();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(1);
+ }
}
}
Oops, something went wrong.

0 comments on commit d3c50d3

Please sign in to comment.