Search in sources :

Example 56 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method setName.

@Override
public void setName(final QNm name) throws OperationNotSupportedException, DocumentException {
    if (mIsWtx) {
        moveRtx();
        final XdmNodeWriteTrx wtx = (XdmNodeWriteTrx) mRtx;
        if (wtx.isNameNode()) {
            try {
                wtx.setName(name);
            } catch (final SirixException e) {
                throw new DocumentException(e);
            }
        } else {
            throw new DocumentException("Node has no name!");
        }
    } else {
        final XdmNodeWriteTrx wtx = getWtx();
        try {
            wtx.setName(name);
        } catch (final SirixException e) {
            wtx.rollback();
            wtx.close();
            throw new DocumentException(e);
        }
    }
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 57 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class SubtreeBuilder method text.

@Override
public void text(final Atomic content) throws DocumentException {
    try {
        processText(content.stringValue());
        mSubtreeProcessor.notifyText(new DBNode(mWtx, mCollection));
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 58 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class NodeWrapper method expandString.

/**
 * Filter text nodes.
 *
 * @return concatenated String of text node values
 */
private String expandString() {
    final FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
    try {
        final NodeReadTrx rtx = createRtxAndMove();
        final FilterAxis axis = new FilterAxis(new DescendantAxis(rtx), new TextFilter(rtx));
        while (axis.hasNext()) {
            axis.next();
            fsb.append(rtx.getValue());
        }
        rtx.close();
    } catch (final SirixException exc) {
        LOGGER.error(exc.toString());
    }
    return fsb.condense().toString();
}
Also used : TextFilter(org.sirix.axis.filter.TextFilter) FastStringBuffer(net.sf.saxon.tree.util.FastStringBuffer) NodeReadTrx(org.sirix.api.NodeReadTrx) SirixException(org.sirix.exception.SirixException) DescendantAxis(org.sirix.axis.DescendantAxis) FilterAxis(org.sirix.axis.filter.FilterAxis)

Example 59 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class NodeWrapper method getDeclaredNamespaces.

@Override
public int[] getDeclaredNamespaces(final int[] buffer) {
    int[] retVal = null;
    if (mNodeKind == Kind.ELEMENT) {
        try {
            final NodeReadTrx rtx = createRtxAndMove();
            final int count = rtx.getNamespaceCount();
            if (count == 0) {
                retVal = EMPTY_NAMESPACE_LIST;
            } else {
                retVal = (buffer == null || count > buffer.length ? new int[count] : buffer);
                final NamePool pool = getNamePool();
                int n = 0;
                try {
                    for (int i = 0; i < count; i++) {
                        rtx.moveTo(i);
                        final String prefix = getPrefix();
                        final String uri = getURI();
                        rtx.moveTo(mKey);
                        retVal[n++] = pool.allocateNamespaceCode(prefix, uri);
                    }
                    rtx.close();
                } catch (final SirixException exc) {
                    LOGGER.error(exc.toString());
                }
                /*
					 * If the supplied array is larger than required, then the first
					 * unused entry will be set to -1.
					 */
                if (count < retVal.length) {
                    retVal[count] = -1;
                }
            }
        } catch (final SirixException e) {
            throw new IllegalStateException(e.getCause());
        }
    }
    return retVal;
}
Also used : NodeReadTrx(org.sirix.api.NodeReadTrx) SirixException(org.sirix.exception.SirixException) NamePool(net.sf.saxon.om.NamePool)

Example 60 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class NodeWrapper method hasChildNodes.

@Override
public boolean hasChildNodes() {
    boolean hasChildNodes = false;
    try {
        final NodeReadTrx rtx = createRtxAndMove();
        if (rtx.getChildCount() > 0) {
            hasChildNodes = true;
        }
        rtx.close();
    } catch (final SirixException exc) {
        LOGGER.error(exc.toString());
    }
    return hasChildNodes;
}
Also used : NodeReadTrx(org.sirix.api.NodeReadTrx) SirixException(org.sirix.exception.SirixException)

Aggregations

SirixException (org.sirix.exception.SirixException)74 DocumentException (org.brackit.xquery.xdm.DocumentException)25 IOException (java.io.IOException)18 Database (org.sirix.api.Database)17 JaxRxException (org.jaxrx.core.JaxRxException)14 NodeReadTrx (org.sirix.api.NodeReadTrx)13 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)13 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)12 Session (org.sirix.api.Session)12 ResourceManager (org.sirix.api.ResourceManager)10 WebApplicationException (javax.ws.rs.WebApplicationException)8 Path (java.nio.file.Path)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 QNm (org.brackit.xquery.atomic.QNm)7 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)6 OutputStream (java.io.OutputStream)5 SubtreeListener (org.brackit.xquery.node.parser.SubtreeListener)5 AbstractTemporalNode (org.brackit.xquery.xdm.AbstractTemporalNode)5 StreamingOutput (javax.ws.rs.core.StreamingOutput)4 DatabaseConfiguration (org.sirix.access.conf.DatabaseConfiguration)4