javax.xml.xquery.XQException类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中javax.xml.xquery.XQException类的一些代码示例,展示了XQException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XQException类的具体详情如下:
包路径:javax.xml.xquery.XQException
类名称:XQException

XQException介绍

[英]An exception that provides information on XQJ, XQuery or other errors reported by an XQJ implementation.

Each XQException provides several kinds of information:

  • a string describing the error. This is used as the Java Exception message, available via the method getMessage.
  • the cause of the error. This is used as the Java Exception cause, available via the method getCause.
  • the vendor code identifying the error. Available via the method getVendorCode. Refer to the vendor documentation which specific codes can be returned.
  • a chain of XQException objects. If more than one error occurred the exceptions are referenced via this chain.

Note that XQException has a subclass XQQueryException providing more detailed information about errors that occurred during the processing of a query. An implementation throws a base XQException when an error occurs in the XQJ implementation. Further, implementations are encouraged to use the more detailed XQQueryException in case of an error reported by the XQuery engine.

It is possible that during the processing of a query that one or more errors could occur, each with their own potential causal relationship. This means that when an XQJ application catches an XQException, there is a possibility that there may be additional XQException objects chained to the original thrown XQException. To access the additional chained XQException objects, an application would recursively invoke getNextException until a null value is returned.

An XQException may have a causal relationship, which consists of one or more Throwable instances which caused the XQException to be thrown. The application may recursively call the method getCause, until a null value is returned, to navigate the chain of causes.
[中]提供有关XQJ、XQuery或XQJ实现报告的其他错误的信息的异常。
每个XQException都提供了几种信息:
*描述错误的字符串。这被用作Java异常消息,可通过[$1$]方法获得。
*错误的原因。这被用作Java异常原因,可通过[$2$]方法获得。
*识别错误的供应商代码。可通过[$3$]方法获得。请参阅供应商文件,以了解可以返回哪些特定代码。
*XQException对象链。如果发生了多个错误,则通过此链引用异常。
注意XQException有一个子类XQQueryException,它提供了有关查询处理过程中发生的错误的更详细信息。当XQJ实现中发生错误时,实现抛出一个基XQException。此外,如果XQuery引擎报告错误,建议实现使用更详细的XQQueryException
在查询处理过程中,可能会出现一个或多个错误,每个错误都有其潜在的因果关系。这意味着,当XQJ应用程序捕捉到XQException时,可能会有额外的XQException对象链接到原始抛出的XQException。要访问额外的链接XQException对象,应用程序将递归调用getNextException,直到返回null值。
XQException可能有因果关系,由一个或多个Throwable实例组成,这些实例导致XQException被抛出。应用程序可能会递归调用方法getCause,直到返回null值,以浏览原因链。

代码示例

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setDefaultElementTypeNamespace(String uri) throws XQException {
  
  if (uri == null) {
    throw new XQException("Default element type namespace URI is null");
  }  
  defaultElementTypeNamespace = uri;
}

代码示例来源:origin: dsukhoroslov/bagri

e.printStackTrace();
throw new XQException("result is empty");

代码示例来源:origin: dsukhoroslov/bagri

/**
 * a utility method to extract XQ exception information from the error stack provided 
 * 
 * @param ex the full error chain
 * @return XQ exception  
 */
public static XQException getXQException(Throwable ex) {
  int errorCode = 0;
  Throwable cause = null;
  String message = "";
  while (ex != null) {
    if (ex instanceof XQException) {
      return (XQException) ex;
    } else if (/*errorCode == 0 &&*/ ex instanceof BagriException) {
      // deeper is better!
      message += ex.getMessage() + "; ";
      errorCode = ((BagriException) ex).getErrorCode();
      cause = ex;
    }
    ex = ex.getCause();
  }
  XQException xqe = new XQException(message, String.valueOf(errorCode));
  xqe.initCause(cause);
  return xqe;
}

代码示例来源:origin: org.mule.modules/mule-module-xml

@Override
public void dispose()
{
  try
  {
    connection.close();
  }
  catch (XQException e)
  {
    logger.warn(e.getMessage());
  }
}

代码示例来源:origin: org.jboss.soa.bpel/riftsaw-bpel-runtime

} catch (XQException xqe) {
  Throwable cause = (xqe.getCause() != null) ? xqe.getCause() : xqe;

代码示例来源:origin: dsukhoroslov/bagri

ex.printStackTrace();
throw new XQException("result is empty");

代码示例来源:origin: dsukhoroslov/bagri

@ManagedOperation(description="Cancel currently running query started from the same JMX connection")
public void cancelQuery() {
  try {
    // are we in exec state now?
    XQProcessor xqp = ((BagriXQConnection) xqConn).getProcessor();
    xqp.cancelExecution();
  } catch (XQException ex) {
    logger.error("cancelQuery.error", ex); 
    throw new RuntimeException(ex.getMessage());
  } 
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setDefaultCollation(String uri) throws XQException {
  
  if (uri == null) {
    throw new XQException("Default collation URI is null");
  }  
  this.defaultCollationUri = uri;
}

代码示例来源:origin: dsukhoroslov/bagri

String em = ex.getMessage();
if (em == null) {
  em = ex.getClass().getName();

代码示例来源:origin: dsukhoroslov/bagri

@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;
}

代码示例来源:origin: dsukhoroslov/bagri

@ManagedOperation(description="Parse XQuery. Return array of parameter names, if any")
@ManagedOperationParameters({
  @ManagedOperationParameter(name = "query", description = "A query request provided in XQuery syntax"),
  @ManagedOperationParameter(name = "props", description = "Query processing properties")})
public String[] parseQuery(String query, Properties props) {
  XQPreparedExpression xqpExp = null;
  try {
    XQStaticContext ctx = xqConn.getStaticContext();
    props2Context(schemaManager.getEntity().getProperties(), ctx);
    props2Context(props, ctx);
    xqpExp = xqConn.prepareExpression(query, ctx);
    QName[] vars = xqpExp.getAllExternalVariables();
    String[] result = null;
    if (vars != null) {
      result = new String[vars.length];
      for (int i=0; i < vars.length; i++) {
        result[i] = vars[i].toString();
      }
    }
    xqpExp.close();
    return result;
  } catch (XQException ex) {
    logger.error("parseQuery.error", ex); 
    throw new RuntimeException(ex.getMessage());
  } 
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setQueryTimeout(int seconds) throws XQException {
  
  if (seconds < 0) {
    throw new XQException("Wrong query timeout value: " + seconds);
  }
  this.queryTimeout = seconds;
}

代码示例来源:origin: dsukhoroslov/bagri

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");
  }
}

代码示例来源:origin: dsukhoroslov/bagri

@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");
}

代码示例来源:origin: dsukhoroslov/bagri

@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;
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public Object getObject() throws XQException {
  
  if (closed) {
    throw new XQException(ex_item_closed);
  }
  return value;
}

代码示例来源:origin: dsukhoroslov/bagri

@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;
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setDefaultFunctionNamespace(String uri) throws XQException {
  
  if (uri == null) {
    throw new XQException("Default function namespace URI is null");
  }  
  defaultFunctionNamespace = uri;
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setDefaultOrderForEmptySequences(int order) throws XQException {
  if (order != DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST && order != DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST) {
    throw new XQException("Wrong default order for empty sequences value: " + order);
  }  
  this.defaultOrderForEmptySequences = order;
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public void setScrollability(int scrollability) throws XQException {
  
  if (scrollability != SCROLLTYPE_FORWARD_ONLY && scrollability != SCROLLTYPE_SCROLLABLE) {
    throw new XQException("Wrong scrollability value: " + scrollability);
  }  
  this.scrollability = scrollability;
}

相关文章