@Override public String queryDocumentByUri(String uri) throws XQException { String query = "for $doc in fn:doc(\"" + uri + "\")\n" + "return $doc\n"; XQExpression xqe = xqConn.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); String result = null; if (xqs.next()) { result = xqs.getItemAsString(null); } return result; }
private void fireCloseEvent() { XQConnectionEvent event = new XQConnectionEvent(this); for (XQConnectionEventListener listener: listeners) { listener.connectionClosed(event); } }
private void fireErrorEvent(XQException error) { XQConnectionEvent event = new XQConnectionEvent(this, error); for (XQConnectionEventListener listener: listeners) { listener.connectionErrorOccurred(event); } }
@Override public <T> ResultCursor<T> executeXQuery(String query, XQStaticContext ctx) throws XQException { // implement it? what for..? throw new XQException("Not implemented on the server side. Use another executeXQuery method taking Properties as a parameter instead"); }
private Object getItemValue(XQItem item) throws XQException { try { return item.getNode(); } catch (XQException e) { return item.getAtomicValue(); } }
@Override public Object makeObject() throws Exception { return connection.prepareExpression(xquery); }
@Override public void dispose() { try { connection.close(); } catch (XQException e) { logger.warn(e.getMessage()); } }
@Override public String queryDocumentFromCollection() throws XQException { String query = "for $doc in fn:collection()\n" + "return $doc\n"; XQExpression xqe = xqConn.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); String result = null; if (xqs.next()) { result = xqs.getItemAsString(null); } return result; }
@Override public XQItemType getItemType() throws XQException { if (closed) { throw new XQException(ex_item_closed); } if (!positioned) { throw new XQException("not positioned on the Item"); } return type; }
@Override public Object getObject() throws XQException { if (closed) { throw new XQException(ex_item_closed); } return value; }
@Override public void setCopyNamespacesModePreserve(int mode) throws XQException { if (mode != COPY_NAMESPACES_MODE_PRESERVE && mode != COPY_NAMESPACES_MODE_NO_PRESERVE) { throw new XQException("Wrong copy namespace mode preserve value: " + mode); } this.copyNamespacesModePreserve = mode; }
protected void checkAccess(boolean checkPosition) throws XQException { if (checkPosition && !positioned) { throw new XQException("Not positioned on an Item"); } if (accessed) { throw new XQException("Item has been already accessed"); } }
@Override public void setDefaultElementTypeNamespace(String uri) throws XQException { if (uri == null) { throw new XQException("Default element type namespace URI is null"); } defaultElementTypeNamespace = uri; }
@Override public void setDefaultCollation(String uri) throws XQException { if (uri == null) { throw new XQException("Default collation URI is null"); } this.defaultCollationUri = uri; }
@Override public void setQueryLanguageTypeAndVersion(int langType) throws XQException { if (langType != LANGTYPE_XQUERY && langType != LANGTYPE_XQUERYX) { throw new XQException("Wrong language type and version value: " + langType); } // we do not support XQueryX, don't see how it can be set.. this.queryLanguageTypeAndVersion = langType; }
@Override public void setQueryTimeout(int seconds) throws XQException { if (seconds < 0) { throw new XQException("Wrong query timeout value: " + seconds); } this.queryTimeout = seconds; }
/** {@inheritDoc} */ @Override public XQConnection getConnection(Connection connection) throws XQException { // will work only if the Connection provided is an // another connection to the underlying cache throw new XQException("method not supported"); }
@Override public void setCopyNamespacesModeInherit(int mode) throws XQException { if (mode != COPY_NAMESPACES_MODE_INHERIT && mode != COPY_NAMESPACES_MODE_NO_INHERIT) { throw new XQException("Wrong copy namespace mode inherit value: " + mode); } this.copyNamespacesModeInherit = mode; }
@Override public void setBaseURI(String baseUri) throws XQException { if (baseUri == null) { throw new XQException("Base URI is null"); } this.baseUri = baseUri; }
@Override public void setBindingMode(int bindingMode) throws XQException { if (bindingMode != BINDING_MODE_IMMEDIATE && bindingMode != BINDING_MODE_DEFERRED) { throw new XQException("Wrong binding mode value: " + bindingMode); } this.bindingMode = bindingMode; }