- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中javax.xml.xquery.XQItemAccessor
类的一些代码示例,展示了XQItemAccessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XQItemAccessor
类的具体详情如下:
包路径:javax.xml.xquery.XQItemAccessor
类名称:XQItemAccessor
[英]This interface represents a common interface for accessing the values of an XQuery item. All the get functions raise an exception if the underlying sequence object is not positioned on an item (e.g. if the sequence is positioned before the first item or after the last item).
Example -
XQPreparedExpression expr = conn.prepareExpression("for $i ..");
XQSequence result = expr.executeQuery();
// create the ItemTypes for string and integer
XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING);
XQItemType intType = conn.createAtomicType(XQItemType.XQBASETYPE_INTEGER);
// posititioned before the first item
while (result.next())
{
// If string or any of its subtypes, then get the string value out
if (result.instanceOf(strType))
String str = result.getAtomicValue();
else if (result.instanceOf(intType))
// if it is exactly an int
int intval = result.getInt();
...
// Alternatively, you can get the exact type out.
XQItemType type = result.getItemType();
// Now perform the comparison..
if (type.equals(intType))
{ ... };
}
See also:
xs:unsignedByte
, then calling the getObject()
method will return a Java object of type java.lang.Short
.getObject()
or getNode()
method will return a Java object of type org.w3.dom.Element
.XQPreparedExpression expr = conn.prepareExpression("for $i ..");
XQSequence result = expr.executeQuery();
// create the ItemTypes for string and integer
XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING);
XQItemType intType = conn.createAtomicType(XQItemType.XQBASETYPE_INTEGER);
// posititioned before the first item
while (result.next())
{
// If string or any of its subtypes, then get the string value out
if (result.instanceOf(strType))
String str = result.getAtomicValue();
else if (result.instanceOf(intType))
// if it is exactly an int
int intval = result.getInt();
...
// Alternatively, you can get the exact type out.
XQItemType type = result.getItemType();
// Now perform the comparison..
if (type.equals(intType))
{ ... };
}
另请参见:
*表6-XQuery原子类型和相应的Java对象类型,XQuery API for Java(XQJ)1.0,用于将XQuery原子类型映射到Java对象类型。例如,如果返回的XQuery值是xs:unsignedByte
类型,那么调用getObject()
方法将返回java.lang.Short
类型的Java对象。
*表7-XQuery节点类型和相应的Java对象类型XQuery API for Java(XQJ)1.0,用于将XQuery节点类型映射到相应的Java对象类型。例如,如果返回的XQuery值是一个元素节点,那么调用getObject()
或getNode()
方法将返回org.w3.dom.Element
类型的Java对象。
代码示例来源:origin: dsukhoroslov/bagri
protected Collection<String> fetchQueryResults(String query, Map<String, Object> params, Properties props) throws Exception {
List<String> result = new ArrayList<>();
try (ResultCursor<XQItemAccessor> cursor = query(query, params, props)) {
for (XQItemAccessor item: cursor) {
result.add(item.getAtomicValue());
}
}
return result;
}
代码示例来源:origin: dsukhoroslov/bagri
if (command.equals(cmd_store_document)) {
XQItemAccessor item = getBoundItem(params, "uri");
String uri = item.getAtomicValue();
item = getBoundItem(params, "doc");
String xml = item.getItemAsString(null);
} else if (command.equals(cmd_remove_document)) {
XQItemAccessor item = getBoundItem(params, "uri");
String uri = item.getAtomicValue();
dMgr.removeDocument(uri, null);
return Collections.emptyIterator();
代码示例来源:origin: dsukhoroslov/bagri
public void run() {
QueryManagement queryMgr = getQueryManager();
try (ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(params.query, params.params, params.props)) {
int idx = 0;
for (XQItemAccessor item: cursor) {
if (idx > 0) {
output.write(splitter);
}
String chunk = item.getItemAsString(null);
logger.trace("postQuery; idx: {}; chunk: {}", idx, chunk);
output.write(chunk);
idx++;
}
} catch (Exception ex) {
// XDMException, IOException. handle it somehow ?
logger.error("postQuery.error", ex);
throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR);
} finally {
try {
output.close();
} catch (IOException ex) {
//
}
}
}
}.start();
代码示例来源:origin: dsukhoroslov/bagri
protected void checkCursorResult(ResultCursor<XQItemAccessor> results, String expected) throws Exception {
try {
Iterator<XQItemAccessor> iter = results.iterator();
assertTrue(iter.hasNext());
if (expected == null) {
assertNotNull(iter.next().getObject());
} else {
Properties props = new Properties();
props.setProperty("method", "text");
XQItem item = (XQItem) iter.next();
assertEquals(expected, item.getItemAsString(props));
}
assertFalse(iter.hasNext());
} finally {
results.close();
}
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public XQSequenceType getStaticVariableType(QName name) throws XQException {
checkState(ex_expression_closed);
if (name == null) {
throw new XQException("name is null");
}
if (getVarNames().contains(name)) {
// where can I get var type??
XQItemType type;
XQItemAccessor acc = (XQItemAccessor) getBindings().get(name);
if (acc != null) {
type = acc.getItemType();
} else {
type = connection.createItemType();
}
return new BagriXQSequenceType(type, OCC_ZERO_OR_MORE);
}
throw new XQException("Static variable [" + name + "] does not exist");
}
代码示例来源:origin: dsukhoroslov/bagri
private Collection<String> toCollection(ResultCursor<XQItemAccessor> cursor) throws BagriException {
if (cursor == null) {
return null;
}
try {
List<String> result = new ArrayList<>();
for (XQItemAccessor item: cursor) {
result.add(item.getAtomicValue());
}
return result;
} catch (XQException ex) {
throw new BagriException(ex, BagriException.ecQuery);
}
}
代码示例来源:origin: dsukhoroslov/bagri
DocumentKey fraKey = factory.newDocumentKey(uri, revision, version);
try {
String fragment = item.getAtomicValue();
String fUri = baseUri + ".r" + revision + ".v" + version + ext;
Document doc = loadDocument(fraKey, fUri, fragment, srcFormat, createdAt, createdBy, txStart, collections, props);
我正在尝试关注 this tutorial .我想我不是从使用可下载项目开始,而是从我之前做过的一个简单的“spring MVC - Maven - eclipse”项目开始。这个项目运行良好。 因此
我觉得 Java EE 6 规范有些困惑。有几组注释。 我们有javax.ejb注释如 @Stateful和 @Stateless用于创建 EJB。 还有一个@javax.annotation.Man
我正在开发一个依赖于“javax.lang”和“javax.annotation”的java项目。我安装了jre/jdk,类路径上还有很多其他javax.*,我每天都用Java进行开发。但是,这两个包
我正在尝试将一个值添加到 JsonValue 列表中。可以这样做吗? 一些背景知识,我正在从 Rest API 检索 Json 响应,在此 Json 中是一个如下名称列表: { “名称”:{名称1,名
我正在开发一个 JSF2、Icefaces 网络应用程序。我有以下看法: 当我保存上面的 时出现以下异常. Application caught instance of
我遇到了一个小问题,我的代码中有一个异常。 我有一个基本框架类: import java.awt.BorderLayout; import java.awt.Color; import java.aw
我正在使用 Apache Derby 并具有以下代码: DBConnectionFactory.java package edu.unsw.comp9321.jdbc; import java.sql
javax.mail 和 javax.mail-api 有什么区别? 我从 maven 存储库中找到了那些。 什么时候应该使用它们? javax.mail-api自带的软件包,但我无法使用,所以我下载
我是 Java 的新手,正在尝试进入 WebServices。我在某处找到了两个示例,但对可用选项感到困惑。 首先,带注解的javax.jws.WebService 似乎工作正常,但javax.xml
在升级了一些 Glassfish/Grizzly 依赖项之后(为了与最新版本的 Azure SDK IOT 设备客户端兼容),我开始出现错误,因为 com.google.common.EventBus
我收到了一个遗留 JSP 系统,其中 Eclipse 在每次出现以下代码时都会标记“导入 javax.event 无法解析”错误: 这是我的java版本: shakir@anduril:~$ jav
我使用以下代码获取连接到系统的 USB 设备的制造商代码。我添加了 jsr80-1.0.1 jar 。我收到以下错误 javax.usb.UsbException: Properties file j
我正在学习 EJB,当尝试使用 junit 测试它时,出现以下错误 cd.espoirmur.Ejb.InterfaceEjbLocal_80488159 Jun 03, 2016 10:33:58
我必须处理一个需要提供数据源作为参数的 API。问题是我从提供 EntityManager 或 PersistentContext 的上下文访问它,它们似乎没有通过其方法公开任何数据源。如何以编程方式
据我所知,Java ServletContext 和上下文对象在 Java EE 程序开发中很常见。但是,我不太确定它们之间有什么区别,尤其是上下文类的用法。 据我了解,ServletContext
我在一个简单的 tomcat jsp 项目中遇到了这个错误。我在谷歌上阅读的文章暗示我应该在我的项目中包含 servlet-api.jar。我就是这样做的,但没有用。有人对此有任何想法吗?我的 JRE
我想对我的实体进行一些 Bean 验证,以便我可以适本地映射错误以发送回客户端。 我知道 javax.validation.constraints 注释用于实现此目的。我的问题是,对于模式生成,我需要
想法:2018.3 jetty :9.4.11 我按照 IDEA 中给出的说明下载了 jrebel 文件夹 在 Debug模式下运行 Jetty 服务器时出现以下错误。 HTTP ERROR 500
我正在开发一个主要使用无状态 session bean (SLSB) 的 EJB3 应用程序。他们使用容器管理事务 (CMT)。 我希望 bean 知道事务(用于日志记录等)。我可以实现 javax.
我正在使用 OSGI 开发 Web 应用程序。我有一个我找不到的 Maven 配置错误。这是完整的源代码: http://uploading.com/files/8e5c9888/SH_27_test
我是一名优秀的程序员,十分优秀!