org.sirix.node.json.AbstractNullNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package org.sirix.node.json;
import org.sirix.node.delegates.NodeDelegate;
import org.sirix.node.delegates.StructNodeDelegate;
import org.sirix.node.interfaces.Node;
import org.sirix.node.interfaces.immutable.ImmutableJsonNode;
import org.sirix.node.xml.AbstractStructForwardingNode;
import java.math.BigInteger;
public abstract class AbstractNullNode extends AbstractStructForwardingNode implements ImmutableJsonNode {
private StructNodeDelegate structNodeDelegate;
private BigInteger hashCode;
public AbstractNullNode(StructNodeDelegate mStructNodeDel) {
this.structNodeDelegate = mStructNodeDel;
}
@Override
public BigInteger computeHash() {
BigInteger result = BigInteger.ONE;
result = BigInteger.valueOf(31).multiply(result).add(structNodeDelegate.getNodeDelegate().computeHash());
if (structNodeDelegate.isNotEmpty()) {
result = BigInteger.valueOf(31).multiply(result).add(structNodeDelegate.computeHash());
}
return Node.to128BitsAtMaximumBigInteger(result);
}
@Override
public void setHash(final BigInteger hash) {
if (hash != null) {
hashCode = Node.to128BitsAtMaximumBigInteger(hash);
} else {
hashCode = null;
}
}
@Override
public BigInteger getHash() {
if (hashCode == null) {
hashCode = computeHash();
}
return hashCode;
}
@Override
protected NodeDelegate delegate() {
return structNodeDelegate.getNodeDelegate();
}
@Override
protected StructNodeDelegate structDelegate() {
return structNodeDelegate;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy