Search in sources :

Example 6 with ValNodeDelegate

use of org.sirix.node.delegates.ValNodeDelegate in project sirix by sirixdb.

the class NodeFactoryImpl method createAttributeNode.

@Override
public AttributeNode createAttributeNode(@Nonnegative final long parentKey, @Nonnull final QNm name, @Nonnull final byte[] value, @Nonnegative final long pathNodeKey, final Optional<SirixDeweyID> id) throws SirixIOException {
    final long revision = mPageWriteTrx.getRevisionNumber();
    final int uriKey = mPageWriteTrx.createNameKey(name.getNamespaceURI(), Kind.NAMESPACE);
    final int prefixKey = name.getPrefix() != null && !name.getPrefix().isEmpty() ? mPageWriteTrx.createNameKey(name.getPrefix(), Kind.ATTRIBUTE) : -1;
    final int localNameKey = mPageWriteTrx.createNameKey(name.getLocalName(), Kind.ATTRIBUTE);
    final NodeDelegate nodeDel = new NodeDelegate(mPageWriteTrx.getActualRevisionRootPage().getMaxNodeKey() + 1, parentKey, 0, revision, id);
    final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, uriKey, prefixKey, localNameKey, pathNodeKey);
    final ValNodeDelegate valDel = new ValNodeDelegate(nodeDel, value, false);
    return (AttributeNode) mPageWriteTrx.createEntry(nodeDel.getNodeKey(), new AttributeNode(nodeDel, nameDel, valDel, name), PageKind.RECORDPAGE, -1, Optional.<UnorderedKeyValuePage>empty());
}
Also used : AttributeNode(org.sirix.node.AttributeNode) ValNodeDelegate(org.sirix.node.delegates.ValNodeDelegate) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) NodeDelegate(org.sirix.node.delegates.NodeDelegate) StructNodeDelegate(org.sirix.node.delegates.StructNodeDelegate) NameNodeDelegate(org.sirix.node.delegates.NameNodeDelegate) ValNodeDelegate(org.sirix.node.delegates.ValNodeDelegate) NameNodeDelegate(org.sirix.node.delegates.NameNodeDelegate)

Aggregations

NodeDelegate (org.sirix.node.delegates.NodeDelegate)6 ValNodeDelegate (org.sirix.node.delegates.ValNodeDelegate)6 NameNodeDelegate (org.sirix.node.delegates.NameNodeDelegate)5 StructNodeDelegate (org.sirix.node.delegates.StructNodeDelegate)5 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataInputStream (java.io.DataInputStream)2 DataOutputStream (java.io.DataOutputStream)2 Test (org.junit.Test)2 QNm (org.brackit.xquery.atomic.QNm)1 AttributeNode (org.sirix.node.AttributeNode)1 CommentNode (org.sirix.node.CommentNode)1 PINode (org.sirix.node.PINode)1 TextNode (org.sirix.node.TextNode)1