Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[ADD] distributed-bundle.

  • Loading branch information...
commit b1a251c5011fb4072d03b9468c87a829b194a1ef 1 parent 01e26bf
@JohannesLichtenberger JohannesLichtenberger authored
Showing with 6,558 additions and 891 deletions.
  1. +3 −0  .gitignore
  2. +2 −1  bundles/sirix-core/src/main/java/org/sirix/access/AbsForwardingNodeReadTrx.java
  3. +4 −3 bundles/sirix-core/src/main/java/org/sirix/access/InsertSubtreeVisitor.java
  4. +4 −3 bundles/sirix-core/src/main/java/org/sirix/access/NodeReadTrx.java
  5. +1 −1  bundles/sirix-core/src/main/java/org/sirix/access/NodeWriteTrx.java
  6. +6 −6 bundles/sirix-core/src/main/java/org/sirix/access/PageReadTrx.java
  7. +9 −6 bundles/sirix-core/src/main/java/org/sirix/access/PageWriteTrx.java
  8. +1 −1  bundles/sirix-core/src/main/java/org/sirix/access/conf/ResourceConfiguration.java
  9. +2 −1  bundles/sirix-core/src/main/java/org/sirix/api/INodeReadTrx.java
  10. +2 −0  bundles/sirix-core/src/main/java/org/sirix/cache/GuavaCache.java
  11. +6 −2 bundles/sirix-core/src/main/java/org/sirix/diff/AbsDiff.java
  12. +0 −8 bundles/sirix-core/src/main/java/org/sirix/diff/ImplementationNotes
  13. +6 −0 bundles/sirix-core/src/main/java/org/sirix/indexes/PathSynopsis.java
  14. +41 −0 bundles/sirix-core/src/main/java/org/sirix/indexes/PathSynopsisNode.java
  15. +2 −2 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/BerkeleyFactory.java
  16. +7 −3 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/BerkeleyWriter.java
  17. +0 −7 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/TupleOutputSink.java
  18. +0 −57 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/AbstractPageBinding.java
  19. +38 −33 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/PageBinding.java
  20. +57 −0 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/SnappyPageBinding.java
  21. +1 −2  bundles/sirix-core/src/main/java/org/sirix/io/file/ByteBufferSinkAndSource.java
  22. +80 −0 bundles/sirix-core/src/main/java/org/sirix/node/AbsForwardingNode.java
  23. +0 −92 bundles/sirix-core/src/main/java/org/sirix/node/AbsNode.java
  24. +25 −37 bundles/sirix-core/src/main/java/org/sirix/node/{AbsStructNode.java → AbsStructForwardingNode.java}
  25. +13 −3 bundles/sirix-core/src/main/java/org/sirix/node/AttributeNode.java
  26. +6 −13 bundles/sirix-core/src/main/java/org/sirix/node/DeletedNode.java
  27. +24 −3 bundles/sirix-core/src/main/java/org/sirix/node/DocumentRootNode.java
  28. +92 −81 bundles/sirix-core/src/main/java/org/sirix/node/ENode.java
  29. +35 −13 bundles/sirix-core/src/main/java/org/sirix/node/ElementNode.java
  30. +23 −7 bundles/sirix-core/src/main/java/org/sirix/node/NamespaceNode.java
  31. +0 −5 bundles/sirix-core/src/main/java/org/sirix/node/NullNode.java
  32. +19 −2 bundles/sirix-core/src/main/java/org/sirix/node/TextNode.java
  33. +16 −67 bundles/sirix-core/src/main/java/org/sirix/node/delegates/NameNodeDelegate.java
  34. +24 −9 bundles/sirix-core/src/main/java/org/sirix/node/delegates/NodeDelegate.java
  35. +34 −123 bundles/sirix-core/src/main/java/org/sirix/node/delegates/StructNodeDelegate.java
  36. +11 −75 bundles/sirix-core/src/main/java/org/sirix/node/delegates/ValNodeDelegate.java
  37. +41 −0 bundles/sirix-core/src/main/java/org/sirix/node/interfaces/IKind.java
  38. +8 −8 bundles/sirix-core/src/main/java/org/sirix/node/interfaces/INode.java
  39. +1 −3 bundles/sirix-core/src/main/java/org/sirix/page/IndirectPage.java
  40. +15 −7 bundles/sirix-core/src/main/java/org/sirix/page/RevisionRootPage.java
  41. +1 −2  bundles/sirix-core/src/main/java/org/sirix/page/UberPage.java
  42. +22 −4 bundles/sirix-core/src/main/java/org/sirix/page/delegates/PageDelegate.java
  43. +6 −5 bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/AtomicValue.java
  44. +4 −5 bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/ItemList.java
  45. +1 −1  bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/comparators/AbsComparator.java
  46. +3 −3 bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/functions/Function.java
  47. +2 −2 bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/operators/AbsObAxis.java
  48. +2 −2 bundles/sirix-core/src/main/java/org/sirix/service/xml/xpath/parser/XPathParser.java
  49. +26 −21 bundles/sirix-core/src/main/java/org/sirix/settings/EFixed.java
  50. +1 −0  bundles/sirix-core/src/main/java/org/sirix/settings/ERevisioning.java
  51. +45 −0 bundles/sirix-core/src/main/java/org/sirix/utils/EKind.java
  52. +0 −1  bundles/sirix-core/src/main/java/org/sirix/utils/FastWeakHashMap.java
  53. +18 −15 bundles/sirix-core/src/main/java/org/sirix/utils/XMLToken.java
  54. +56 −32 bundles/sirix-core/src/test/java/org/sirix/TestHelper.java
  55. +0 −1  bundles/sirix-core/src/test/java/org/sirix/access/ThreadTest.java
  56. +1 −1  bundles/sirix-core/src/test/java/org/sirix/node/AttributeNodeTest.java
  57. +1 −1  bundles/sirix-core/src/test/java/org/sirix/node/DocumentRootNodeTest.java
  58. +1 −1  bundles/sirix-core/src/test/java/org/sirix/node/ElementNodeTest.java
  59. +0 −2  bundles/sirix-core/src/test/java/org/sirix/node/NamespaceNodeTest.java
  60. +1 −1  bundles/sirix-core/src/test/java/org/sirix/node/TextNodeTest.java
  61. +2 −3 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/expr/LiteralExprTest.java
  62. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/AbsOpAxisTest.java
  63. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/AddOpAxisTest.java
  64. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/DivOpAxisTest.java
  65. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/IDivOpAxisTest.java
  66. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/ModOpAxisTest.java
  67. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/MulOpAxisTest.java
  68. +2 −2 bundles/sirix-core/src/test/java/org/sirix/service/xml/xpath/operators/SubOpAxisTest.java
  69. +83 −0 bundles/sirix-distributed/pom.xml
  70. +5 −0 bundles/sirix-distributed/src/.svn/all-wcprops
  71. +34 −0 bundles/sirix-distributed/src/.svn/entries
  72. +5 −0 bundles/sirix-distributed/src/main/.svn/all-wcprops
  73. +37 −0 bundles/sirix-distributed/src/main/.svn/entries
  74. +11 −0 bundles/sirix-distributed/src/main/assembly/.svn/all-wcprops
  75. +62 −0 bundles/sirix-distributed/src/main/assembly/.svn/entries
  76. +24 −0 bundles/sirix-distributed/src/main/assembly/.svn/text-base/jarAssembly.xml.svn-base
  77. +24 −0 bundles/sirix-distributed/src/main/assembly/jarAssembly.xml
  78. +5 −0 bundles/sirix-distributed/src/main/java/.svn/all-wcprops
  79. +31 −0 bundles/sirix-distributed/src/main/java/.svn/entries
  80. +5 −0 bundles/sirix-distributed/src/main/java/org/.svn/all-wcprops
  81. +31 −0 bundles/sirix-distributed/src/main/java/org/.svn/entries
  82. +5 −0 bundles/sirix-distributed/src/main/java/org/sirix/networkdata/.svn/all-wcprops
  83. +28 −0 bundles/sirix-distributed/src/main/java/org/sirix/networkdata/.svn/entries
  84. +150 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/ExtractArticles.java
  85. +77 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/all-wcprops
  86. +436 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/entries
  87. +107 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/DateWritable.java.svn-base
  88. +96 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/ListWritable.java.svn-base
  89. +28 −0 ...es/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/RootElemAddition.java.svn-base
  90. +115 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/SortWiki.java.svn-base
  91. +116 −0 ...es/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLEventWritable.java.svn-base
  92. +66 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLInputFormat.java.svn-base
  93. +226 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLMap.java.svn-base
  94. +98 −0 ...les/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLOutputFormat.java.svn-base
  95. +354 −0 ...les/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLRecordReader.java.svn-base
  96. +110 −0 ...les/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLRecordWriter.java.svn-base
  97. +96 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/XMLReduce.java.svn-base
  98. +26 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/.svn/text-base/package-info.java.svn-base
  99. +107 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/DateWritable.java
  100. +96 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/ListWritable.java
  101. +28 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/RootElemAddition.java
  102. +115 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/SortWiki.java
  103. +116 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLEventWritable.java
  104. +66 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLInputFormat.java
  105. +226 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLMap.java
  106. +98 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLOutputFormat.java
  107. +354 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLRecordReader.java
  108. +110 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLRecordWriter.java
  109. +96 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/XMLReduce.java
  110. +26 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/hadoop/package-info.java
  111. +27 −0 bundles/sirix-distributed/src/main/java/org/sirix/wikipedia/package-info.java
  112. +11 −0 bundles/sirix-distributed/src/main/resources/.svn/all-wcprops
  113. +62 −0 bundles/sirix-distributed/src/main/resources/.svn/entries
  114. +30 −0 bundles/sirix-distributed/src/main/resources/.svn/text-base/wikipedia.xsl.svn-base
  115. +30 −0 bundles/sirix-distributed/src/main/resources/wikipedia.xsl
  116. +5 −0 bundles/sirix-distributed/src/test/.svn/all-wcprops
  117. +34 −0 bundles/sirix-distributed/src/test/.svn/entries
  118. +5 −0 bundles/sirix-distributed/src/test/java/.svn/all-wcprops
  119. +31 −0 bundles/sirix-distributed/src/test/java/.svn/entries
  120. +5 −0 bundles/sirix-distributed/src/test/java/org/.svn/all-wcprops
  121. +31 −0 bundles/sirix-distributed/src/test/java/org/.svn/entries
  122. +17 −0 bundles/sirix-distributed/src/test/java/org/sirix/wikipedia/hadoop/.svn/all-wcprops
  123. +96 −0 bundles/sirix-distributed/src/test/java/org/sirix/wikipedia/hadoop/.svn/entries
  124. +103 −0 bundles/sirix-distributed/src/test/java/org/sirix/wikipedia/hadoop/.svn/text-base/TestSortWiki.java.svn-base
  125. +102 −0 ...ix-distributed/src/test/java/org/sirix/wikipedia/hadoop/.svn/text-base/TestXSLTTransformation.java.svn-base
  126. +107 −0 bundles/sirix-distributed/src/test/java/org/sirix/wikipedia/hadoop/TestSortWiki.java
  127. +102 −0 bundles/sirix-distributed/src/test/java/org/sirix/wikipedia/hadoop/TestXSLTTransformation.java
  128. +29 −0 bundles/sirix-distributed/src/test/resources/.svn/all-wcprops
  129. +164 −0 bundles/sirix-distributed/src/test/resources/.svn/entries
  130. +48 −0 bundles/sirix-distributed/src/test/resources/.svn/text-base/testExpected.xml.svn-base
  131. +48 −0 bundles/sirix-distributed/src/test/resources/.svn/text-base/testInput.xml.svn-base
  132. +47 −0 bundles/sirix-distributed/src/test/resources/.svn/text-base/testXSLTInput.xml.svn-base
  133. +43 −0 bundles/sirix-distributed/src/test/resources/.svn/text-base/testXSLTOutput.xml.svn-base
  134. +48 −0 bundles/sirix-distributed/src/test/resources/testExpected.xml
  135. +48 −0 bundles/sirix-distributed/src/test/resources/testInput.xml
  136. +47 −0 bundles/sirix-distributed/src/test/resources/testXSLTInput.xml
  137. +43 −0 bundles/sirix-distributed/src/test/resources/testXSLTOutput.xml
  138. +5 −6 bundles/sirix-fs/src/main/java/org/sirix/fs/FileSystemWatcher.java
  139. +168 −0 bundles/sirix-gui/bin/pom.xml
  140. +61 −0 bundles/sirix-gui/bin/src/main/assembly/jarAssembly.xml
  141. +10 −0 bundles/sirix-gui/bin/src/main/resources/all/dbsettings.properties
  142. BIN  bundles/sirix-gui/bin/src/main/resources/all/tt/00000000.jdb
  143. 0  bundles/sirix-gui/bin/src/main/resources/all/tt/je.lck
  144. +40 −0 bundles/sirix-gui/bin/src/main/resources/data/miso-info.txt
  145. BIN  bundles/sirix-gui/bin/src/main/resources/data/miso-regular.ttf
  146. BIN  bundles/sirix-gui/bin/src/main/resources/images/idefix.jpeg
  147. BIN  bundles/sirix-gui/bin/src/main/resources/images/idefix.jpg
  148. +48 −0 bundles/sirix-gui/bin/src/main/resources/logback-test.xml
  149. +44 −0 bundles/sirix-gui/bin/src/main/resources/logback.xml
  150. +0 −3  bundles/sirix-gui/src/main/java/org/sirix/gui/view/model/TraverseCompareTree.java
  151. +20 −19 bundles/sirix-gui/src/main/java/org/sirix/gui/view/sunburst/EMoved.java
  152. +2 −37 bundles/sirix-gui/src/main/java/org/sirix/gui/view/sunburst/axis/DiffSunburstAxis.java
  153. +1 −17 bundles/sirix-gui/src/main/java/org/sirix/gui/view/sunburst/axis/SunburstDescendantAxis.java
  154. +1 −5 bundles/sirix-gui/src/main/java/org/sirix/gui/view/sunburst/model/SunburstModel.java
  155. +0 −3  bundles/sirix-saxon/src/main/java/org/sirix/saxon/evaluator/XPathEvaluator.java
View
3  .gitignore
@@ -19,3 +19,6 @@
doc
lib
target
+
+# Sirix project
+sirix-performance
View
3  bundles/sirix-core/src/main/java/org/sirix/access/AbsForwardingNodeReadTrx.java
@@ -11,6 +11,7 @@
import org.sirix.exception.TTIOException;
import org.sirix.node.interfaces.INode;
import org.sirix.node.interfaces.IStructNode;
+import org.sirix.service.xml.xpath.AtomicValue;
/**
* Forwards all methods to the delegate.
@@ -28,7 +29,7 @@ protected AbsForwardingNodeReadTrx() {
protected abstract INodeReadTrx delegate();
@Override
- public IItemList<INode> getItemList() {
+ public IItemList<AtomicValue> getItemList() {
return delegate().getItemList();
}
View
7 bundles/sirix-core/src/main/java/org/sirix/access/InsertSubtreeVisitor.java
@@ -74,7 +74,8 @@
* determines how to insert a node
*/
@Nonnull
- InsertSubtreeVisitor(final INodeReadTrx pRtx, final INodeWriteTrx pWtx, final EInsertPos pInsert) {
+ InsertSubtreeVisitor(final INodeReadTrx pRtx, final INodeWriteTrx pWtx,
+ final EInsertPos pInsert) {
mRtx = checkNotNull(pRtx);
mWtx = checkNotNull(pWtx);
mInsert = checkNotNull(pInsert);
@@ -82,7 +83,7 @@
}
@Override
- public EVisitResult visit(final ElementNode pNode) {
+ public EVisitResult visit(@Nonnull final ElementNode pNode) {
mRtx.moveTo(pNode.getNodeKey());
try {
mInsert.insertNode(mWtx, mRtx);
@@ -120,7 +121,7 @@ public EVisitResult visit(final ElementNode pNode) {
}
@Override
- public EVisitResult visit(final TextNode pNode) {
+ public EVisitResult visit(@Nonnull final TextNode pNode) {
mRtx.moveTo(pNode.getNodeKey());
try {
mInsert.insertNode(mWtx, mRtx);
View
7 bundles/sirix-core/src/main/java/org/sirix/access/NodeReadTrx.java
@@ -38,6 +38,7 @@
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
+import org.sirix.service.xml.xpath.AtomicValue;
import org.sirix.api.IItemList;
import org.sirix.api.INodeReadTrx;
import org.sirix.api.IPageReadTrx;
@@ -82,7 +83,7 @@
private boolean mClosed;
/** Read-transaction-exclusive item list. */
- private final ItemList<INode> mItemList;
+ private final ItemList mItemList;
/**
* Constructor.
@@ -109,7 +110,7 @@
throw new IllegalStateException("Node couldn't be fetched from persistent storage!");
}
mClosed = false;
- mItemList = new ItemList<>();
+ mItemList = new ItemList();
}
@Override
@@ -290,7 +291,7 @@ public final String nameForKey(final int pKey) {
}
@Override
- public final IItemList<INode> getItemList() {
+ public final IItemList<AtomicValue> getItemList() {
assertNotClosed();
return mItemList;
}
View
2  bundles/sirix-core/src/main/java/org/sirix/access/NodeWriteTrx.java
@@ -1446,7 +1446,7 @@ private void intermediateCommitIfRequired() throws AbsTTException {
*
* @return the page transaction.
*/
- public IPageWriteTrx getPageTransaction() {
+ public synchronized IPageWriteTrx getPageTransaction() {
return (IPageWriteTrx)mNodeReadRtx.getPageTransaction();
}
View
12 bundles/sirix-core/src/main/java/org/sirix/access/PageReadTrx.java
@@ -69,7 +69,7 @@
* transaction.
* </p>
*/
-class PageReadTrx implements IPageReadTrx {
+final class PageReadTrx implements IPageReadTrx {
/** Page reader exclusively assigned to this transaction. */
private final IReader mPageReader;
@@ -103,8 +103,9 @@
* @throws TTIOException
* if reading of the persistent storage fails
*/
- PageReadTrx(final Session pSession, final UberPage pUberPage,
- final long pRevision, final IReader pReader) throws TTIOException {
+ PageReadTrx(@Nonnull final Session pSession,
+ @Nonnull final UberPage pUberPage, @Nonnegative final long pRevision,
+ @Nonnull final IReader pReader) throws TTIOException {
checkArgument(pRevision >= 0, "Revision must be >= 0!");
mSession = checkNotNull(pSession);
mPageReader = checkNotNull(pReader);
@@ -112,7 +113,6 @@
mRootPage = loadRevRoot(pRevision);
assert mRootPage != null : "root page must not be null!";
mNamePage = initializeNamePage();
- ;
mCache = new GuavaCache(this);
}
@@ -295,8 +295,8 @@ public final UberPage getUberPage() {
}
if (refs.size() == revsToRestore
|| config.mRevisionKind == ERevisioning.FULL
- || config.mRevisionKind == ERevisioning.DIFFERENTIAL
- && refs.size() == 2) {
+ || (config.mRevisionKind == ERevisioning.DIFFERENTIAL
+ && refs.size() == 2)) {
break;
}
if (config.mRevisionKind == ERevisioning.DIFFERENTIAL) {
View
15 bundles/sirix-core/src/main/java/org/sirix/access/PageWriteTrx.java
@@ -75,6 +75,8 @@
/** Last references to the Nodepage, needed for pre/postcondition check. */
private PageContainer mNodePageCon;
+
+ private PageContainer mNamePageCon;
/** Last reference to the actual revRoot. */
private final RevisionRootPage mNewRoot;
@@ -179,10 +181,10 @@ public void removeNode(@Nonnull final INode pNode) throws TTIOException {
final INode delNode =
new DeletedNode(new NodeDelegate(pNode.getNodeKey(),
pNode.getParentKey(), pNode.getHash()));
- ((NodePage)mNodePageCon.getModified()).setNode(
- mPageRtx.nodePageOffset(pNode.getNodeKey()), delNode);
- ((NodePage)mNodePageCon.getComplete()).setNode(
- mPageRtx.nodePageOffset(pNode.getNodeKey()), delNode);
+ ((NodePage)mNodePageCon.getModified()).setNode(mPageRtx
+ .nodePageOffset(pNode.getNodeKey()), delNode);
+ ((NodePage)mNodePageCon.getComplete()).setNode(mPageRtx
+ .nodePageOffset(pNode.getNodeKey()), delNode);
finishNodeModification(pNode);
}
@@ -212,7 +214,7 @@ public void removeNode(@Nonnull final INode pNode) throws TTIOException {
}
@Override
- public String getName(final int pNameKey, final ENode pNodeKind) {
+ public String getName(final int pNameKey, @Nonnull final ENode pNodeKind) {
final NamePage currentNamePage =
(NamePage)mNewRoot.getNamePageReference().getPage();
// if currentNamePage == null -> state was commited and no prepareNodepage was invoked yet
@@ -234,7 +236,8 @@ public int createNameKey(@Nullable final String pName,
}
@Override
- public void commit(final PageReference pReference) throws AbsTTException {
+ public void commit(@Nullable final PageReference pReference)
+ throws AbsTTException {
IPage page = null;
// if reference is not null, get one from the persistent storage.
View
2  bundles/sirix-core/src/main/java/org/sirix/access/conf/ResourceConfiguration.java
@@ -128,7 +128,7 @@ public static int compareStructure(final File pFile) {
// FIXED STANDARD FIELDS
/** Standard storage. */
- public static final EStorage STORAGE = EStorage.File;
+ public static final EStorage STORAGE = EStorage.BerkeleyDB;
/** Standard Versioning Approach. */
public static final ERevisioning VERSIONING = ERevisioning.INCREMENTAL;
/** Type of hashing. */
View
3  bundles/sirix-core/src/main/java/org/sirix/api/INodeReadTrx.java
@@ -34,6 +34,7 @@
import org.sirix.node.NullNode;
import org.sirix.node.interfaces.INode;
import org.sirix.node.interfaces.IStructNode;
+import org.sirix.service.xml.xpath.AtomicValue;
/**
* <h1>IReadTransaction</h1>
@@ -295,7 +296,7 @@
*
* @return item list
*/
- IItemList<INode> getItemList();
+ IItemList<AtomicValue> getItemList();
/**
* Getting the current node.
View
2  bundles/sirix-core/src/main/java/org/sirix/cache/GuavaCache.java
@@ -8,6 +8,8 @@
import com.google.common.cache.RemovalNotification;
import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
View
8 bundles/sirix-core/src/main/java/org/sirix/diff/AbsDiff.java
@@ -42,7 +42,9 @@
import org.sirix.diff.DiffFactory.EDiffOptimized;
import org.sirix.exception.AbsTTException;
import org.sirix.node.ENode;
+import org.sirix.node.ElementNode;
import org.sirix.node.interfaces.IStructNode;
+import org.sirix.utils.EKind;
/**
* Abstract diff class which implements common functionality.
@@ -580,14 +582,16 @@ private void emitDiffs(final EDiff pDiff) {
* {@link INodeReadTrx} on new revision
* @param pOldRtx
* {@link INodeReadTrx} on old revision
- * @return true if nodes are "equal" according to their {@link QName}s, otherwise false
+ * @return {@code true} if nodes are "equal" according to their {@link QName}s, {@code false
*/
boolean checkName(final INodeReadTrx pNewRtx, final INodeReadTrx pOldRtx) {
boolean found = false;
if (pNewRtx.getNode().getKind() == pOldRtx.getNode().getKind()) {
switch (pNewRtx.getNode().getKind()) {
case ELEMENT_KIND:
- if (pNewRtx.getQNameOfCurrentNode().equals(pOldRtx.getQNameOfCurrentNode())) {
+ final ElementNode newElement = (ElementNode) pNewRtx.getNode();
+ final ElementNode oldElement = (ElementNode) pOldRtx.getNode();
+ if (newElement.getNameKey() == oldElement.getNameKey()) {
found = true;
}
break;
View
8 bundles/sirix-core/src/main/java/org/sirix/diff/ImplementationNotes
@@ -1,8 +0,0 @@
-Doesn't work when inserting a node with a name/value, then reverting
-and then inserting a node with the same name/value at the same level
-and comparing these two revisions since they both have the same node key
-and same QNames or text values and thus nodes are regarded as being deleted
-between the old node and the new node (if the new node is a right sibling).
-
-Proposed fix:
-Load maximum node key of newest revision and add 1 for the first added node.
View
6 bundles/sirix-core/src/main/java/org/sirix/indexes/PathSynopsis.java
@@ -0,0 +1,6 @@
+package org.sirix.indexes;
+
+public class PathSynopsis {
+
+
+}
View
41 bundles/sirix-core/src/main/java/org/sirix/indexes/PathSynopsisNode.java
@@ -0,0 +1,41 @@
+package org.sirix.indexes;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.sirix.api.visitor.EVisitResult;
+import org.sirix.api.visitor.IVisitor;
+import org.sirix.node.AbsStructForwardingNode;
+import org.sirix.node.ENode;
+import org.sirix.node.ElementNode;
+import org.sirix.node.delegates.NodeDelegate;
+import org.sirix.node.delegates.StructNodeDelegate;
+
+public class PathSynopsisNode extends AbsStructForwardingNode {
+
+ private final ElementNode mNode;
+
+ public PathSynopsisNode(final ElementNode pNode) {
+ mNode = checkNotNull(pNode);
+ }
+
+ @Override
+ public ENode getKind() {
+ return ENode.PATH_KIND;
+ }
+
+ @Override
+ public EVisitResult acceptVisitor(IVisitor pVisitor) {
+ return null;
+ }
+
+ @Override
+ protected StructNodeDelegate structDelegate() {
+ return mNode.getStructNodeDelegate();
+ }
+
+ @Override
+ protected NodeDelegate delegate() {
+ return mNode.getNodeDelegate();
+ }
+
+}
View
4 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/BerkeleyFactory.java
@@ -46,7 +46,7 @@
import org.sirix.io.IReader;
import org.sirix.io.IStorage;
import org.sirix.io.IWriter;
-import org.sirix.io.berkeley.binding.PageBinding;
+import org.sirix.io.berkeley.binding.SnappyPageBinding;
import org.sirix.page.delegates.PageDelegate;
/**
@@ -62,7 +62,7 @@
public final class BerkeleyFactory implements IStorage {
/** Binding for {@link PageDelegate}. */
- public static final PageBinding PAGE_VAL_B = new PageBinding();
+ public static final SnappyPageBinding PAGE_VAL_B = new SnappyPageBinding();
/** Binding for {@link Long}. */
public static final TupleBinding<Long> DATAINFO_VAL_B = TupleBinding.getPrimitiveBinding(Long.class);
View
10 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/BerkeleyWriter.java
@@ -28,6 +28,10 @@
package org.sirix.io.berkeley;
import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
@@ -98,7 +102,7 @@ public void close() throws TTIOException {
}
@Override
- public long write(final PageReference pageReference) throws TTIOException {
+ public long write(@Nonnull final PageReference pageReference) throws TTIOException {
final IPage page = pageReference.getPage();
final DatabaseEntry valueEntry = new DatabaseEntry();
@@ -129,7 +133,7 @@ public long write(final PageReference pageReference) throws TTIOException {
* @throws TTIOException
* if can't set last {@link NodePage}
*/
- private void setLastNodePage(final long pData) throws TTIOException {
+ private void setLastNodePage(@Nonnegative final long pData) throws TTIOException {
final DatabaseEntry keyEntry = new DatabaseEntry();
final DatabaseEntry valueEntry = new DatabaseEntry();
@@ -168,7 +172,7 @@ private long getLastNodePage() throws TTIOException {
}
@Override
- public void writeFirstReference(final PageReference pPageReference)
+ public void writeFirstReference(@Nonnull final PageReference pPageReference)
throws TTIOException {
write(pPageReference);
View
7 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/TupleOutputSink.java
@@ -30,10 +30,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.sleepycat.bind.tuple.TupleOutput;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
import javax.annotation.Nonnull;
import org.sirix.io.ITTSink;
@@ -50,9 +46,6 @@
/** {@link TupleOutput} to be wrapped. */
private final TupleOutput mOutput;
- // /** {@link OutputStream} reference to write to. */
- // private final OutputStream mOut;
-
/**
* Constructor.
*
View
57 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/AbstractPageBinding.java
@@ -1,57 +0,0 @@
-/**
- * Copyright (c) 2011, University of Konstanz, Distributed Systems Group
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the University of Konstanz nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.sirix.io.berkeley.binding;
-
-import org.sirix.io.berkeley.TupleInputSink;
-import org.sirix.io.berkeley.TupleOutputSink;
-import org.sirix.page.PagePersistenter;
-import org.sirix.page.interfaces.IPage;
-
-import com.sleepycat.bind.tuple.TupleBinding;
-import com.sleepycat.bind.tuple.TupleInput;
-import com.sleepycat.bind.tuple.TupleOutput;
-
-/**
- * Binding for storing {@link PageDelegate} objects within the Berkeley DB.
- *
- * @author Sebastian Graf, University of Konstanz
- *
- */
-public final class AbstractPageBinding extends TupleBinding<IPage> {
-
- @Override
- public IPage entryToObject(final TupleInput pInput) {
- return PagePersistenter.deserializePage(new TupleInputSink(pInput));
- }
-
- @Override
- public void objectToEntry(final IPage pPage, final TupleOutput pOutput) {
- PagePersistenter.serializePage(new TupleOutputSink(pOutput), pPage);
- }
-
-}
View
71 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/PageBinding.java
@@ -1,52 +1,57 @@
-package org.sirix.io.berkeley.binding;
-
-import com.sleepycat.bind.EntryBinding;
-import com.sleepycat.bind.tuple.TupleBase;
-import com.sleepycat.bind.tuple.TupleInput;
-import com.sleepycat.bind.tuple.TupleOutput;
-import com.sleepycat.je.DatabaseEntry;
+/**
+ * Copyright (c) 2011, University of Konstanz, Distributed Systems Group
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the University of Konstanz nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-import java.io.IOException;
+package org.sirix.io.berkeley.binding;
-import org.slf4j.LoggerFactory;
import org.sirix.io.berkeley.TupleInputSink;
import org.sirix.io.berkeley.TupleOutputSink;
import org.sirix.page.PagePersistenter;
import org.sirix.page.interfaces.IPage;
-import org.sirix.utils.LogWrapper;
-import org.xerial.snappy.Snappy;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
/**
- * Compresses pages with Snappy.
+ * Binding for storing {@link PageDelegate} objects within the Berkeley DB.
*
- * @author Johannes Lichtenberger, University of Konstanz
+ * @author Sebastian Graf, University of Konstanz
*
*/
-public class PageBinding extends TupleBase<IPage> implements EntryBinding<IPage> {
-
- /** {@link LogWrapper} instance. */
- private static final LogWrapper LOGWRAPPER = new LogWrapper(LoggerFactory.getLogger(PageBinding.class));
+public final class PageBinding extends TupleBinding<IPage> {
@Override
- public IPage entryToObject(final DatabaseEntry pEntry) {
- TupleInput tupleInput = null;
- try {
- tupleInput = new TupleInput(Snappy.uncompress(pEntry.getData()));
- } catch (final IOException e) {
- LOGWRAPPER.error(e.getMessage(), e);
- }
- return PagePersistenter.deserializePage(new TupleInputSink(tupleInput));
+ public IPage entryToObject(final TupleInput pInput) {
+ return PagePersistenter.deserializePage(new TupleInputSink(pInput));
}
@Override
- public void objectToEntry(final IPage pPage, final DatabaseEntry pEntry) {
- try {
- TupleOutput output = getTupleOutput(pPage);
- PagePersistenter.serializePage(new TupleOutputSink(output), pPage);
- pEntry.setData(Snappy.compress(output.getBufferBytes()));
- } catch (final IOException e) {
- LOGWRAPPER.error(e.getMessage(), e);
- }
+ public void objectToEntry(final IPage pPage, final TupleOutput pOutput) {
+ PagePersistenter.serializePage(new TupleOutputSink(pOutput), pPage);
}
}
View
57 bundles/sirix-core/src/main/java/org/sirix/io/berkeley/binding/SnappyPageBinding.java
@@ -0,0 +1,57 @@
+package org.sirix.io.berkeley.binding;
+
+import com.sleepycat.bind.EntryBinding;
+import com.sleepycat.bind.tuple.TupleBase;
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
+import com.sleepycat.je.DatabaseEntry;
+
+import java.io.IOException;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.LoggerFactory;
+import org.sirix.io.berkeley.TupleInputSink;
+import org.sirix.io.berkeley.TupleOutputSink;
+import org.sirix.page.PagePersistenter;
+import org.sirix.page.interfaces.IPage;
+import org.sirix.utils.LogWrapper;
+import org.xerial.snappy.Snappy;
+
+/**
+ * Compresses pages with Snappy.
+ *
+ * @author Johannes Lichtenberger, University of Konstanz
+ *
+ */
+public class SnappyPageBinding extends TupleBase<IPage> implements
+ EntryBinding<IPage> {
+
+ /** {@link LogWrapper} instance. */
+ private static final LogWrapper LOGWRAPPER = new LogWrapper(LoggerFactory
+ .getLogger(SnappyPageBinding.class));
+
+ @Override
+ public IPage entryToObject(@Nonnull final DatabaseEntry pEntry) {
+ TupleInput tupleInput = null;
+ try {
+ tupleInput = new TupleInput(Snappy.uncompress(pEntry.getData()));
+ } catch (final IOException e) {
+ LOGWRAPPER.error(e.getMessage(), e);
+ }
+ return PagePersistenter.deserializePage(new TupleInputSink(tupleInput));
+ }
+
+ @Override
+ public void objectToEntry(@Nonnull final IPage pPage,
+ @Nonnull final DatabaseEntry pEntry) {
+ try {
+ TupleOutput output = getTupleOutput(pPage);
+ PagePersistenter.serializePage(new TupleOutputSink(output), pPage);
+ pEntry.setData(Snappy.compress(output.getBufferBytes()));
+ } catch (final IOException e) {
+ LOGWRAPPER.error(e.getMessage(), e);
+ }
+ }
+
+}
View
3  bundles/sirix-core/src/main/java/org/sirix/io/file/ByteBufferSinkAndSource.java
@@ -31,7 +31,6 @@
import org.sirix.io.ITTSink;
import org.sirix.io.ITTSource;
-import org.sirix.utils.IConstants;
/**
* This class represents the byte input/output mechanism for File-access. After
@@ -45,7 +44,7 @@
/** Internal buffer. */
private ByteBuffer mBuffer;
-
+
/**
* Constructor.
*/
View
80 bundles/sirix-core/src/main/java/org/sirix/node/AbsForwardingNode.java
@@ -0,0 +1,80 @@
+package org.sirix.node;
+
+import com.google.common.collect.ForwardingObject;
+import org.sirix.node.delegates.NodeDelegate;
+import org.sirix.node.interfaces.INode;
+
+/**
+ * Skeletal implementation of {@link INode} interface.
+ *
+ * @author Johannes Lichtenberger, University of Konstanz
+ *
+ */
+public abstract class AbsForwardingNode extends ForwardingObject implements INode {
+
+ /** Constructor for use by subclasses. */
+ protected AbsForwardingNode() {
+ }
+
+ @Override
+ protected abstract NodeDelegate delegate();
+
+ /**
+ * Get a snapshot of the node delegate.
+ *
+ * @return new {@link NodeDelegate} instance (snapshot of the current one)
+ */
+ public NodeDelegate getNodeDelegate() {
+ return new NodeDelegate(delegate());
+ }
+
+ @Override
+ public int getTypeKey() {
+ return delegate().getTypeKey();
+ }
+
+ @Override
+ public void setTypeKey(final int pTypeKey) {
+ delegate().setTypeKey(pTypeKey);
+ }
+
+ @Override
+ public boolean hasParent() {
+ return delegate().hasParent();
+ }
+
+ @Override
+ public long getNodeKey() {
+ return delegate().getNodeKey();
+ }
+
+ @Override
+ public long getParentKey() {
+ return delegate().getParentKey();
+ }
+
+ @Override
+ public void setParentKey(final long pParentKey) {
+ delegate().setParentKey(pParentKey);
+ }
+
+ @Override
+ public long getHash() {
+ return delegate().getHash();
+ }
+
+ @Override
+ public void setHash(final long pHash) {
+ delegate().setHash(pHash);
+ }
+
+ @Override
+ public String toString() {
+ return delegate().toString();
+ }
+
+ @Override
+ public boolean isSameItem(final INode pOther) {
+ return delegate().isSameItem(pOther);
+ }
+}
View
92 bundles/sirix-core/src/main/java/org/sirix/node/AbsNode.java
@@ -1,92 +0,0 @@
-package org.sirix.node;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import org.sirix.node.delegates.NodeDelegate;
-import org.sirix.node.interfaces.INode;
-
-/**
- * Skeletal implementation of {@link INode} interface.
- *
- * @author Johannes Lichtenberger, University of Konstanz
- *
- */
-abstract class AbsNode implements INode {
-
- /** Delegate for common node information. */
- private final NodeDelegate mNodeDel;
-
- /**
- * Constructor.
- *
- * @param pNodeDelegate
- * {@link NodeDelegate} reference
- *
- */
- public AbsNode(final NodeDelegate pNodeDelegate) {
- mNodeDel = checkNotNull(pNodeDelegate);
- }
-
- /**
- * Getting the inlying {@link NodeDelegate}.
- *
- * @return the inlying {@link NodeDelegate} instance
- */
- NodeDelegate getNodeDelegate() {
- return mNodeDel;
- }
-
- @Override
- public int getTypeKey() {
- return mNodeDel.getTypeKey();
- }
-
- @Override
- public void setTypeKey(final int pTypeKey) {
- mNodeDel.setTypeKey(pTypeKey);
- }
-
- @Override
- public boolean hasParent() {
- return mNodeDel.hasParent();
- }
-
- @Override
- public long getNodeKey() {
- return mNodeDel.getNodeKey();
- }
-
- @Override
- public void setNodeKey(final long pNodeKey) {
- mNodeDel.setNodeKey(pNodeKey);
- }
-
- @Override
- public long getParentKey() {
- return mNodeDel.getParentKey();
- }
-
- @Override
- public void setParentKey(final long pParentKey) {
- mNodeDel.setParentKey(pParentKey);
- }
-
- @Override
- public long getHash() {
- return mNodeDel.getHash();
- }
-
- @Override
- public void setHash(final long pHash) {
- mNodeDel.setHash(pHash);
- }
-
- @Override
- public String toString() {
- return mNodeDel.toString();
- }
-
- @Override
- public boolean isSameItem(final INode pOther) {
- return mNodeDel.isSameItem(pOther);
- }
-}
View
62 ...in/java/org/sirix/node/AbsStructNode.java → ...g/sirix/node/AbsStructForwardingNode.java
@@ -1,8 +1,6 @@
package org.sirix.node;
-import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
-
import org.sirix.node.delegates.NodeDelegate;
import org.sirix.node.delegates.StructNodeDelegate;
import org.sirix.node.interfaces.IStructNode;
@@ -13,118 +11,108 @@
* @author Johannes Lichtenberger, University of Konstanz
*
*/
-abstract class AbsStructNode extends AbsNode implements IStructNode {
-
- /** Delegate for struct node information. */
- private final StructNodeDelegate mStructDel;
+public abstract class AbsStructForwardingNode extends AbsForwardingNode implements IStructNode {
- /**
- * Constructor.
- *
- * @param pNodeDelegate
- * {@link NodeDelegate} reference
- * @param pStructNodeDelegate
- * {@link StructNodeDelegate} reference
- */
- public AbsStructNode(final NodeDelegate pNodeDelegate, final StructNodeDelegate pStructNodeDelegate) {
- super(pNodeDelegate);
- mStructDel = checkNotNull(pStructNodeDelegate);
+ /** Constructor for use by subclasses. */
+ protected AbsStructForwardingNode() {
}
+ /** {@link StructNodeDelegate} instance. */
+ protected abstract StructNodeDelegate structDelegate();
+
/**
* Getting the inlying {@link NodeDelegate}.
*
* @return the inlying {@link NodeDelegate} instance
*/
- StructNodeDelegate getStructNodeDelegate() {
- return mStructDel;
+ public StructNodeDelegate getStructNodeDelegate() {
+ return new StructNodeDelegate(structDelegate());
}
@Override
public boolean hasFirstChild() {
- return mStructDel.hasFirstChild();
+ return structDelegate().hasFirstChild();
}
@Override
public boolean hasLeftSibling() {
- return mStructDel.hasLeftSibling();
+ return structDelegate().hasLeftSibling();
}
@Override
public boolean hasRightSibling() {
- return mStructDel.hasRightSibling();
+ return structDelegate().hasRightSibling();
}
@Override
public long getChildCount() {
- return mStructDel.getChildCount();
+ return structDelegate().getChildCount();
}
@Override
public long getFirstChildKey() {
- return mStructDel.getFirstChildKey();
+ return structDelegate().getFirstChildKey();
}
@Override
public long getLeftSiblingKey() {
- return mStructDel.getLeftSiblingKey();
+ return structDelegate().getLeftSiblingKey();
}
@Override
public long getRightSiblingKey() {
- return mStructDel.getRightSiblingKey();
+ return structDelegate().getRightSiblingKey();
}
@Override
public void setRightSiblingKey(final long pKey) {
- mStructDel.setRightSiblingKey(pKey);
+ structDelegate().setRightSiblingKey(pKey);
}
@Override
public void setLeftSiblingKey(final long pKey) {
- mStructDel.setLeftSiblingKey(pKey);
+ structDelegate().setLeftSiblingKey(pKey);
}
@Override
public void setFirstChildKey(final long pKey) {
- mStructDel.setFirstChildKey(pKey);
+ structDelegate().setFirstChildKey(pKey);
}
@Override
public void decrementChildCount() {
- mStructDel.decrementChildCount();
+ structDelegate().decrementChildCount();
}
@Override
public void incrementChildCount() {
- mStructDel.incrementChildCount();
+ structDelegate().incrementChildCount();
}
@Override
public long getDescendantCount() {
- return mStructDel.getDescendantCount();
+ return structDelegate().getDescendantCount();
}
@Override
public void decrementDescendantCount() {
- mStructDel.decrementDescendantCount();
-
+ structDelegate().decrementDescendantCount();
}
@Override
public void incrementDescendantCount() {
- mStructDel.incrementDescendantCount();
+ structDelegate().incrementDescendantCount();
}
@Override
public void setDescendantCount(final long pDescendantCount) {
- mStructDel.setDescendantCount(pDescendantCount);
+ structDelegate().setDescendantCount(pDescendantCount);
}
@Override
public String toString() {
return Objects.toStringHelper(this).add("nodeDelegate", super.toString()).add("structDelegate",
- mStructDel.toString()).toString();
+ structDelegate().toString()).toString();
}
}
View
16 bundles/sirix-core/src/main/java/org/sirix/node/AttributeNode.java
@@ -27,6 +27,8 @@
package org.sirix.node;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.base.Objects;
import org.sirix.api.visitor.EVisitResult;
import org.sirix.api.visitor.IVisitor;
@@ -44,13 +46,16 @@
* Node representing an attribute.
* </p>
*/
-public final class AttributeNode extends AbsNode implements IValNode, INameNode {
+public final class AttributeNode extends AbsForwardingNode implements IValNode, INameNode {
/** Delegate for name node information. */
private final NameNodeDelegate mNameDel;
/** Delegate for val node information. */
private final ValNodeDelegate mValDel;
+
+ /** Node delegate. */
+ private final NodeDelegate mDel;
/**
* Creating an attribute.
@@ -64,8 +69,8 @@
*
*/
public AttributeNode(final NodeDelegate pDel, final NameNodeDelegate pNameDel, final ValNodeDelegate pValDel) {
- super(pDel);
- mNameDel = pNameDel;
+ mDel = checkNotNull(pDel);
+ mNameDel = checkNotNull(pNameDel);
mValDel = pValDel;
}
@@ -203,4 +208,9 @@ ValNodeDelegate getValNodeDelegate() {
return mValDel;
}
+ @Override
+ protected NodeDelegate delegate() {
+ return mDel;
+ }
+
}
View
19 bundles/sirix-core/src/main/java/org/sirix/node/DeletedNode.java
@@ -27,6 +27,10 @@
package org.sirix.node;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnull;
+
import org.sirix.api.visitor.EVisitResult;
import org.sirix.api.visitor.IVisitor;
import org.sirix.node.delegates.NodeDelegate;
@@ -53,8 +57,8 @@
* @param paramParent
* parent of this key.
*/
- public DeletedNode(final NodeDelegate pDel) {
- mDel = pDel;
+ public DeletedNode(@Nonnull final NodeDelegate pDel) {
+ mDel = checkNotNull(pDel);
}
/**
@@ -77,17 +81,6 @@ public long getNodeKey() {
}
/**
- * Delegate method for setKey.
- *
- * @param pNodeKey
- * @see org.sirix.node.delegates.NodeDelegate#setNodeKey(long)
- */
- @Override
- public void setNodeKey(final long pNodeKey) {
- mDel.setNodeKey(pNodeKey);
- }
-
- /**
* Delegate method for getParentKey.
*
* @return
View
27 bundles/sirix-core/src/main/java/org/sirix/node/DocumentRootNode.java
@@ -27,6 +27,8 @@
package org.sirix.node;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import org.sirix.api.visitor.EVisitResult;
import org.sirix.api.visitor.IVisitor;
import org.sirix.node.delegates.NodeDelegate;
@@ -41,7 +43,14 @@
* removed.
* </p>
*/
-public final class DocumentRootNode extends AbsStructNode implements IStructNode {
+public final class DocumentRootNode extends AbsStructForwardingNode implements
+ IStructNode {
+
+ /** {@link NodeDelegate} reference. */
+ private final NodeDelegate mNodeDel;
+
+ /** {@link StructNodeDelegate} reference. */
+ private final StructNodeDelegate mStructNodeDel;
/**
* Constructor.
@@ -51,8 +60,10 @@
* @param pStructDel
* {@link StructNodeDelegate} reference
*/
- public DocumentRootNode(final NodeDelegate pNodeDel, final StructNodeDelegate pStructDel) {
- super(pNodeDel, pStructDel);
+ public DocumentRootNode(final NodeDelegate pNodeDel,
+ final StructNodeDelegate pStructDel) {
+ mNodeDel = checkNotNull(pNodeDel);
+ mStructNodeDel = checkNotNull(pStructDel);
}
@Override
@@ -69,4 +80,14 @@ public EVisitResult acceptVisitor(final IVisitor pVisitor) {
public String toString() {
return super.toString();
}
+
+ @Override
+ protected NodeDelegate delegate() {
+ return mNodeDel;
+ }
+
+ @Override
+ protected StructNodeDelegate structDelegate() {
+ return mStructNodeDel;
+ }
}
View
173 bundles/sirix-core/src/main/java/org/sirix/node/ENode.java
@@ -34,12 +34,17 @@
import java.util.List;
import java.util.Map;
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+
+import org.sirix.indexes.PathSynopsisNode;
import org.sirix.io.ITTSink;
import org.sirix.io.ITTSource;
import org.sirix.node.delegates.NameNodeDelegate;
import org.sirix.node.delegates.NodeDelegate;
import org.sirix.node.delegates.StructNodeDelegate;
import org.sirix.node.delegates.ValNodeDelegate;
+import org.sirix.node.interfaces.IKind;
import org.sirix.node.interfaces.INode;
import org.sirix.service.xml.xpath.AtomicValue;
import org.sirix.settings.EFixed;
@@ -51,7 +56,7 @@
* @author Johannes Lichtenberger, University of Konstanz
*
*/
-public enum ENode {
+public enum ENode implements IKind {
/** Unknown kind. */
UNKOWN_KIND((byte)0, null) {
@@ -64,44 +69,34 @@ public INode deserialize(final ITTSource pSource) {
public void serialize(final ITTSink pSink, final INode pToSerialize) {
throw new UnsupportedOperationException();
}
-
},
+
/** Node kind is element. */
ELEMENT_KIND((byte)1, ElementNode.class) {
@Override
public INode deserialize(final ITTSource pSource) {
-
final List<Long> attrKeys = new ArrayList<Long>();
final BiMap<Integer, Long> attrs = HashBiMap.<Integer, Long> create();
final List<Long> namespKeys = new ArrayList<Long>();
- // node delegate
+ // Node delegate.
final NodeDelegate nodeDel =
new NodeDelegate(pSource.readLong(), pSource.readLong(), pSource.readLong());
- // struct delegate
+ // Struct delegate.
final long currKey = nodeDel.getNodeKey();
- final long rightSibl = deserializeStructDel(pSource, currKey);
- final long leftSibl = deserializeStructDel(pSource, currKey);
- final long firstChild = deserializeStructDel(pSource, currKey);
+ final long rightSibl = readPointer(pSource, currKey);
+ final long leftSibl = readPointer(pSource, currKey);
+ final long firstChild = readPointer(pSource, currKey);
final long childCount = pSource.readLong();
final long descendantCount = pSource.readLong() + childCount;
final StructNodeDelegate structDel =
new StructNodeDelegate(nodeDel, firstChild, rightSibl, leftSibl, childCount, descendantCount);
- // long childCount;
- // final StructNodeDelegate structDel =
- // new StructNodeDelegate(nodeDel, pSource.readLong(), pSource.readLong(), pSource.readLong(),
- // childCount = pSource.readLong(), pSource.readLong() + childCount);
- //
- // final StructNodeDelegate structDel =
- // new StructNodeDelegate(nodeDel, pSource.readLong(), pSource.readLong(), pSource.readLong(),
- // pSource.readLong(), pSource.readLong());
-
- // name delegate
+ // Name delegate.
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, pSource.readInt(), pSource.readInt());
- // Attributes getting
+ // Attributes.
int attrCount = pSource.readInt();
for (int i = 0; i < attrCount; i++) {
final long nodeKey = pSource.readLong();
@@ -109,7 +104,7 @@ public INode deserialize(final ITTSource pSource) {
attrs.put(pSource.readInt(), nodeKey);
}
- // Namespace getting
+ // Namespaces.
int nsCount = pSource.readInt();
for (int i = 0; i < nsCount; i++) {
namespKeys.add(pSource.readLong());
@@ -134,28 +129,18 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
pSink.writeLong(node.getNamespaceKey(i));
}
}
-
- private long deserializeStructDel(final ITTSource pSource, final long pSelf) {
- boolean isNullKey = pSource.readByte() == (byte)1 ? true : false;
- if (isNullKey) {
- return EFixed.NULL_NODE_KEY.getStandardProperty();
- } else {
- final long pointer = pSource.readLong();
- assert pointer != 0;
- return pointer >= 0 ? pSelf - pointer : Math.abs(pointer - pSelf);
- }
- }
},
+
/** Node kind is attribute. */
ATTRIBUTE_KIND((byte)2, AttributeNode.class) {
@Override
public INode deserialize(final ITTSource pSource) {
- // node delegate
+ // Node delegate.
final NodeDelegate nodeDel =
new NodeDelegate(pSource.readLong(), pSource.readLong(), pSource.readLong());
- // name delegate
+ // Name delegate.
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, pSource.readInt(), pSource.readInt());
- // val delegate
+ // Val delegate.
final boolean isCompressed = pSource.readByte() == (byte)1 ? true : false;
final byte[] vals = new byte[pSource.readInt()];
for (int i = 0; i < vals.length; i++) {
@@ -175,25 +160,26 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
}
},
+
/** Node kind is text. */
TEXT_KIND((byte)3, TextNode.class) {
@Override
public INode deserialize(final ITTSource pSource) {
- // node delegate
+ // Node delegate.
final NodeDelegate nodeDel =
new NodeDelegate(pSource.readLong(), pSource.readLong(), pSource.readLong());
- // val delegate
+ // Val delegate.
final boolean isCompressed = pSource.readByte() == (byte)1 ? true : false;
final byte[] vals = new byte[pSource.readInt()];
for (int i = 0; i < vals.length; i++) {
vals[i] = pSource.readByte();
}
final ValNodeDelegate valDel = new ValNodeDelegate(nodeDel, vals, isCompressed);
- // struct delegate
+ // Struct delegate.
final StructNodeDelegate structDel =
new StructNodeDelegate(nodeDel, EFixed.NULL_NODE_KEY.getStandardProperty(), pSource.readLong(),
pSource.readLong(), 0L, 0L);
- // returning the data
+ // Returning an instance.
return new TextNode(nodeDel, valDel, structDel);
}
@@ -202,22 +188,20 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
TextNode node = (TextNode)pToSerialize;
serializeDelegate(node.getNodeDelegate(), pSink);
serializeValDelegate(node.getValNodeDelegate(), pSink);
- // serializeStrucDelegate(node.getStrucNodeDelegate(), pSink);
final StructNodeDelegate del = node.getStructNodeDelegate();
pSink.writeLong(del.getRightSiblingKey());
pSink.writeLong(del.getLeftSiblingKey());
}
-
},
+
/** Node kind is namespace. */
NAMESPACE_KIND((byte)13, NamespaceNode.class) {
-
@Override
public INode deserialize(final ITTSource pSource) {
- // node delegate
+ // Node delegate.
final NodeDelegate nodeDel =
new NodeDelegate(pSource.readLong(), pSource.readLong(), pSource.readLong());
- // name delegate
+ // Name delegate.
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, pSource.readInt(), pSource.readInt());
return new NamespaceNode(nodeDel, nameDel);
}
@@ -230,6 +214,7 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
}
},
+
/** Node kind is processing instruction. */
PROCESSING_KIND((byte)7, null) {
@Override
@@ -243,6 +228,7 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
}
},
+
/** Node kind is comment. */
COMMENT_KIND((byte)8, null) {
@Override
@@ -256,6 +242,7 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
}
},
+
/** Node kind is document root. */
ROOT_KIND((byte)9, DocumentRootNode.class) {
@Override
@@ -277,11 +264,9 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
pSink.writeLong(node.getFirstChildKey());
pSink.writeByte(node.hasFirstChild() ? (byte)1 : (byte)0);
pSink.writeLong(node.getDescendantCount());
- // serializeDelegate(node.getNodeDelegate(), pSink);
- // serializeStrucDelegate(node.getStrucNodeDelegate(), pSink);
}
-
},
+
/** Whitespace text. */
WHITESPACE_KIND((byte)4, null) {
@Override
@@ -295,6 +280,7 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
}
},
+
/** Node kind is deleted node. */
DELETE_KIND((byte)5, DeletedNode.class) {
@Override
@@ -310,8 +296,8 @@ public void serialize(final ITTSink pSink, final INode pToSerialize) {
DeletedNode node = (DeletedNode)pToSerialize;
serializeDelegate(node.getNodeDelegate(), pSink);
}
-
},
+
/** NullNode to support the Null Object pattern. */
NULL_KIND((byte)6, NullNode.class) {
@Override
@@ -336,6 +322,22 @@ public INode deserialize(final ITTSource pSource) {
public void serialize(final ITTSink pSink, final INode pToSerialize) {
throw new UnsupportedOperationException();
}
+ },
+
+ /** Node kind is path node. */
+ PATH_KIND((byte) 16, PathSynopsisNode.class) {
+ @Override
+ public INode deserialize(final ITTSource pSource) {
+
+ return null;
+ }
+
+ @Override
+ public void serialize(final ITTSink pSink, final INode pToSerialize) {
+ // TODO Auto-generated method stub
+
+ }
+ ;
};
/** Identifier. */
@@ -370,33 +372,15 @@ private ENode(final byte pId, final Class<? extends INode> pClass) {
mClass = pClass;
}
- /**
- * Getter for the identifier.
- *
- * @return the unique identifier
- */
+ @Override
public byte getId() {
return mId;
}
-
- /**
- * Deserializing a node out of a given {@link ITTSource}.
- *
- * @param pSource
- * of the data where the obj should be build up.
- * @return a resulting {@link INode} instance
- */
- public abstract INode deserialize(final ITTSource pSource);
-
- /**
- * Serializing a node out to a given {@link ITTSink}.
- *
- * @param pSink
- * where the data should be serialized to.
- * @param pToSerialize
- * the data to be serialized
- */
- public abstract void serialize(final ITTSink pSink, final INode pToSerialize);
+
+ @Override
+ public Class<? extends INode> getNodeClass() {
+ return mClass;
+ }
/**
* Public method to get the related node based on the identifier.
@@ -446,14 +430,41 @@ private static final void serializeStrucDelegate(final StructNodeDelegate pDel,
writePointer(pSink, pDel.getNodeKey(), pDel.getRightSiblingKey());
writePointer(pSink, pDel.getNodeKey(), pDel.getLeftSiblingKey());
writePointer(pSink, pDel.getNodeKey(), pDel.getFirstChildKey());
- // pSink.writeLong(pDel.getFirstChildKey());
- // pSink.writeLong(pDel.getRightSiblingKey());
- // pSink.writeLong(pDel.getLeftSiblingKey());
pSink.writeLong(pDel.getChildCount());
pSink.writeLong(pDel.getDescendantCount() - pDel.getChildCount());
}
+
+ /**
+ * Deserialize a structural node pointer (ranges).
+ *
+ * @param pSource
+ * input source
+ * @param pSelf
+ * the pointer
+ * @return the pointer
+ */
+ private static long readPointer(final ITTSource pSource, final long pSelf) {
+ boolean isNullKey = pSource.readByte() == (byte)1 ? true : false;
+ if (isNullKey) {
+ return EFixed.NULL_NODE_KEY.getStandardProperty();
+ } else {
+ final long pointer = pSource.readLong();
+ assert pointer != 0 : "May never be 0!";
+ return pointer > 0 ? pSelf - pointer : Math.abs(pointer - pSelf);
+ }
+ }
- private static final void writePointer(final ITTSink pSink, final long pSelf, final long pPointer) {
+ /**
+ * Write a structural node pointer (ranges).
+ *
+ * @param pSink
+ * output sink
+ * @param pSelf
+ * the pointer
+ * @param pPointer
+ * the pointer
+ */
+ private static final void writePointer(@Nonnull final ITTSink pSink, @Nonnegative final long pSelf, @Nonnegative final long pPointer) {
boolean isNullNodeKey = pPointer == EFixed.NULL_NODE_KEY.getStandardProperty() ? true : false;
pSink.writeByte(isNullNodeKey ? (byte)1 : (byte)0);
if (!isNullNodeKey) {
@@ -467,11 +478,11 @@ private static final void writePointer(final ITTSink pSink, final long pSelf, fi
* Serializing the {@link NameNodeDelegate} instance.
*
* @param pDel
- * to be serialize
+ * to be serialized
* @param pSink
- * to serialize to.
+ * to serialize to
*/
- private static final void serializeNameDelegate(final NameNodeDelegate pDel, final ITTSink pSink) {
+ private static final void serializeNameDelegate(@Nonnull final NameNodeDelegate pDel, @Nonnull final ITTSink pSink) {
pSink.writeInt(pDel.getNameKey());
pSink.writeInt(pDel.getURIKey());
}
@@ -480,11 +491,11 @@ private static final void serializeNameDelegate(final NameNodeDelegate pDel, fin
* Serializing the {@link ValNodeDelegate} instance.
*
* @param pDel
- * to be serialize
+ * to be serialized
* @param pSink
- * to serialize to.
+ * to serialize to
*/
- private static final void serializeValDelegate(final ValNodeDelegate pDel, final ITTSink pSink) {
+ private static final void serializeValDelegate(@Nonnull final ValNodeDelegate pDel, @Nonnull final ITTSink pSink) {
final boolean isCompressed = pDel.isCompressed();
pSink.writeByte(isCompressed ? (byte)1 : (byte)0);
final byte[] value = isCompressed ? pDel.getCompressed() : pDel.getRawValue();
View
48 bundles/sirix-core/src/main/java/org/sirix/node/ElementNode.java
@@ -52,7 +52,8 @@
* Node representing an XML element.
* </p>
*/
-public final class ElementNode extends AbsStructNode implements INameNode {
+public final class ElementNode extends AbsStructForwardingNode implements
+ INameNode {
/** Delegate for name node information. */
private final NameNodeDelegate mNameDel;
@@ -66,6 +67,12 @@
/** Keys of namespace declarations. */
private final List<Long> mNamespaceKeys;
+ /** {@link NodeDelegate} reference. */
+ private final NodeDelegate mNodeDel;
+
+ /** {@link StructNodeDelegate} reference. */
+ private final StructNodeDelegate mStructNodeDel;
+
/**
* Constructor
*
@@ -80,10 +87,14 @@
* @param pNamespaceKeys
* keys of namespaces to be set
*/
- public ElementNode(@Nonnull final NodeDelegate pNodeDel, @Nonnull final StructNodeDelegate pStructDel,
- @Nonnull final NameNodeDelegate pNameDel, @Nonnull final List<Long> pAttributeKeys,
- @Nonnull final BiMap<Integer, Long> pAttributes, @Nonnull final List<Long> pNamespaceKeys) {
- super(pNodeDel, pStructDel);
+ public ElementNode(@Nonnull final NodeDelegate pNodeDel,
+ @Nonnull final StructNodeDelegate pStructDel,
+ @Nonnull final NameNodeDelegate pNameDel,
+ @Nonnull final List<Long> pAttributeKeys,
+ @Nonnull final BiMap<Integer, Long> pAttributes,
+ @Nonnull final List<Long> pNamespaceKeys) {
+ mNodeDel = checkNotNull(pNodeDel);
+ mStructNodeDel = checkNotNull(pStructDel);
mNameDel = checkNotNull(pNameDel);
mAttributeKeys = checkNotNull(pAttributeKeys);
mAttributes = checkNotNull(pAttributes);
@@ -200,12 +211,12 @@ public int getURIKey() {
}
@Override
- public void setNameKey(int pNameKey) {
+ public void setNameKey(final int pNameKey) {
mNameDel.setNameKey(pNameKey);
}
@Override
- public void setURIKey(int pUriKey) {
+ public void setURIKey(final int pUriKey) {
mNameDel.setURIKey(pUriKey);
}
@@ -234,7 +245,8 @@ public EVisitResult acceptVisitor(final IVisitor pVisitor) {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((getNodeDelegate() == null) ? 0 : getNodeDelegate().hashCode());
+ result =
+ prime * result + ((delegate() == null) ? 0 : delegate().hashCode());
result = prime * result + ((mNameDel == null) ? 0 : mNameDel.hashCode());
return result;
}
@@ -248,7 +260,7 @@ public boolean equals(final Object pObj) {
if (getClass() != pObj.getClass())
return false;
ElementNode other = (ElementNode)pObj;
- return Objects.equal(getNodeDelegate(), other.getNodeDelegate())
+ return Objects.equal(delegate(), other.delegate())
&& Objects.equal(mNameDel, other.mNameDel);
}
@@ -270,12 +282,22 @@ public boolean equals(final Object pObj) {
return Collections.unmodifiableList(mNamespaceKeys);
}
+ @Override
+ protected NodeDelegate delegate() {
+ return mNodeDel;
+ }
+
+ @Override
+ protected StructNodeDelegate structDelegate() {
+ return mStructNodeDel;
+ }
+
/**
- * Getting the inlying {@link NameNodeDelegate}.
+ * Get name node delegate.
*
- * @return the inlying {@link NameNodeDelegate} instance
+ * @return snapshot of the name node delegate (new instance)
*/
- NameNodeDelegate getNameNodeDelegate() {
- return mNameDel;
+ public NameNodeDelegate getNameNodeDelegate() {
+ return new NameNodeDelegate(mNameDel);
}
}
View
30 bundles/sirix-core/src/main/java/org/sirix/node/NamespaceNode.java
@@ -27,6 +27,10 @@
package org.sirix.node;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnull;
+
import org.sirix.api.visitor.EVisitResult;
import org.sirix.api.visitor.IVisitor;
import org.sirix.node.delegates.NameNodeDelegate;
@@ -40,21 +44,26 @@
* Node representing a namespace.
* </p>
*/
-public final class NamespaceNode extends AbsNode implements INameNode {
+public final class NamespaceNode extends AbsForwardingNode implements INameNode {
/** Delegate for name node information. */
private final NameNodeDelegate mNameDel;
+ /** {@link NodeDelegate} reference. */
+ private final NodeDelegate mNodeDel;
+
/**
* Constructor.
*
* @param pDel
- * @param mIntBuilder
- * building int data
+ * {@link NodeDelegate} reference
+ * @param pNameDel
+ * {@link NameNodeDelegate} reference
*/
- public NamespaceNode(final NodeDelegate pDel, final NameNodeDelegate pNameDel) {
- super(pDel);
- mNameDel = pNameDel;
+ public NamespaceNode(@Nonnull final NodeDelegate pDel,
+ @Nonnull final NameNodeDelegate pNameDel) {
+ mNodeDel = checkNotNull(pDel);
+ mNameDel = checkNotNull(pNameDel);
}
@Override
@@ -91,7 +100,9 @@ public EVisitResult acceptVisitor(final IVisitor pVisitor) {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((getNodeDelegate() == null) ? 0 : getNodeDelegate().hashCode());
+ result =
+ prime * result
+ + ((getNodeDelegate() == null) ? 0 : getNodeDelegate().hashCode());
result = prime * result + ((mNameDel == null) ? 0 : mNameDel.hashCode());
return result;
}
@@ -135,4 +146,9 @@ public String toString() {
NameNodeDelegate getNameNodeDelegate() {
return mNameDel;
}
+
+ @Override
+ protected NodeDelegate delegate() {
+ return mNodeDel;
+ }
}
View
5 bundles/sirix-core/src/main/java/org/sirix/node/NullNode.java
@@ -93,11 +93,6 @@ public long getHash() {
}
@Override
- public void setNodeKey(final long pNodeKey) {
- throw new UnsupportedOperationException();
- }
-
- @Override
public long getNodeKey() {
return mNode.getNodeKey();
}
View
21 bundles/sirix-core/src/main/java/org/sirix/node/TextNode.java
@@ -48,11 +48,17 @@
* Node representing a text node.
* </p>
*/
-public final class TextNode extends AbsStructNode implements IValNode {
+public final class TextNode extends AbsStructForwardingNode implements IValNode {
/** Delegate for common value node information. */
private final ValNodeDelegate mValDel;
+
+ /** {@link NodeDelegate} reference. */
+ private final NodeDelegate mNodeDel;
+ /** {@link StructNodeDelegate} reference. */
+ private final StructNodeDelegate mStructNodeDel;
+
/** Value of the node. */
private byte[] mValue;
@@ -68,7 +74,8 @@
*/
public TextNode(@Nonnull final NodeDelegate pDel, @Nonnull final ValNodeDelegate pValDel,
@Nonnull final StructNodeDelegate pStructDel) {
- super(pDel, pStructDel);
+ mNodeDel = checkNotNull(pDel);
+ mStructNodeDel = checkNotNull(pStructDel);
mValDel = checkNotNull(pValDel);
}
@@ -189,4 +196,14 @@ public String toString() {
ValNodeDelegate getValNodeDelegate() {
return mValDel;
}
+
+ @Override
+ protected NodeDelegate delegate() {
+ return mNodeDel;
+ }
+
+ @Override
+ protected StructNodeDelegate structDelegate() {
+ return mStructNodeDel;
+ }
}
View
83 bundles/sirix-core/src/main/java/org/sirix/node/delegates/NameNodeDelegate.java
@@ -52,8 +52,10 @@
/** Node delegate, containing basic node information. */
private final NodeDelegate mDelegate;
+
/** Key of the name. The name contains the prefix as well. */
private int mNameKey;
+
/** URI of the related namespace. */
private int mUriKey;
@@ -67,107 +69,60 @@
* @param pUriKey
* urikey to be stored
*/
- public NameNodeDelegate(@Nonnull final NodeDelegate pDel, final int pNameKey, final int pUriKey) {
+ public NameNodeDelegate(@Nonnull final NodeDelegate pDel, final int pNameKey,
+ final int pUriKey) {
mDelegate = checkNotNull(pDel);
mNameKey = pNameKey;
mUriKey = pUriKey;
}
/**
- * Delegate method for setHash.
+ * Copy constructor.
*
- * @param pHash
- * @see org.sirix.node.delegates.NodeDelegate#setHash(long)
+ * @param pNameDel
+ * old name node delegate
*/
+ public NameNodeDelegate(@Nonnull NameNodeDelegate pNameDel) {
+ mDelegate = pNameDel.mDelegate;
+ mNameKey = pNameDel.mNameKey;
+ mUriKey = pNameDel.mUriKey;
+ }
+
@Override
public void setHash(final long pHash) {
mDelegate.setHash(pHash);
}
- /**
- * Delegate method for getHash.
- *
- * @return
- * @see org.sirix.node.delegates.NodeDelegate#getHash()
- */
@Override
public long getHash() {
return mDelegate.getHash();
}
- /**
- * Delegate method for setKey.
- *
- * @param pKey
- * key to set
- * @see org.sirix.node.delegates.NodeDelegate#setNodeKey(long)
- */
- @Override
- public void setNodeKey(final long pKey) {
- mDelegate.setNodeKey(pKey);
- }
-
- /**
- * Delegate method for getKey.
- *
- * @return
- * @see org.sirix.node.delegates.NodeDelegate#getNodeKey()
- */
@Override
public long getNodeKey() {
return mDelegate.getNodeKey();
}
- /**
- * Delegate method for getParentKey.
- *
- * @return
- * @see org.sirix.node.delegates.NodeDelegate#getParentKey()
- */
@Override
public long getParentKey() {
return mDelegate.getParentKey();
}
- /**
- * Delegate method for hasParent.
- *
- * @return
- * @see org.sirix.node.delegates.NodeDelegate#hasParent()
- */
@Override
public boolean hasParent() {
return mDelegate.hasParent();
}
- /**
- * Delegate method for getTypeKey.
- *
- * @return
- * @see org.sirix.node.delegates.NodeDelegate#getTypeKey()
- */
@Override
public int getTypeKey() {
return mDelegate.getTypeKey();
}
- /**
- * Delegate method for setParentKey.
- *
- * @param pNodeKey
- * @see org.sirix.node.delegates.NodeDelegate#setParentKey(long)
- */
@Override