gpt4 book ai didi

javax.xml.xquery.XQItemType.getItemKind()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 20:29:40 24 4
gpt4 key购买 nike

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

XQItemType.getItemKind介绍

[英]Returns the kind of the item. One of the XQITEMKIND_* constants.
[中]返回项目的类型。XQITEMKIND_*常量之一。

代码示例

代码示例来源:origin: spring-projects/spring-integration-extensions

int itemKind = type.getItemKind();
return (
    itemKind == XQITEMKIND_ATTRIBUTE

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

@Override
public Node getNode() throws XQException {
  checkState(ex_item_closed);
  switch (type.getItemKind()) {
    case XQITEMKIND_ATTRIBUTE: 
    case XQITEMKIND_SCHEMA_ATTRIBUTE: return (org.w3c.dom.Attr) value;
    case XQITEMKIND_COMMENT: return (org.w3c.dom.Comment) value;
    case XQITEMKIND_DOCUMENT: return (org.w3c.dom.Document) value;
    case XQITEMKIND_ELEMENT: 
    case XQITEMKIND_DOCUMENT_ELEMENT: 
    case XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
    case XQITEMKIND_SCHEMA_ELEMENT: return (org.w3c.dom.Element) value;
    case XQITEMKIND_PI: return (org.w3c.dom.ProcessingInstruction) value;
    case XQITEMKIND_TEXT: return (org.w3c.dom.Text) value;
    default: 
      throw new XQException("ItemType is not Node: " + value.getClass().getName());
  }
}

代码示例来源:origin: spring-projects/spring-integration-extensions

/**
 * Gets the given text content as String if the type is a string base type
 * @param type
 * @param result
 * @return
 */
protected String convertToString(XQItemType type,XQResultSequence result) throws XQException {
  boolean skipBaseTypes = shouldSkipBaseType(type);
  String value = null;
  if(!skipBaseTypes) {
    int baseType = type.getBaseType();
    if(baseType == XQBASETYPE_STRING) {
      value = result.getAtomicValue();
    }
  }
  else if(XQITEMKIND_TEXT == type.getItemKind()) {
    value = result.getNode().getTextContent();
  }
  else if(XQITEMKIND_ATTRIBUTE == type.getItemKind()) {
    value = ((Attr)result.getNode()).getValue();
  }
  return value;
}

代码示例来源:origin: spring-projects/spring-integration-extensions

/**
 * Checks the data type of the string and converts to boolean if applicable.
 * The types have to be either boolean or string. For a string value,
 * the returned value is same as Boolean.valueOf(strValue)
 *
 * @param type
 * @param result
 * @return
 */
protected Boolean convertToBoolean(XQItemType type,XQResultSequence result) throws XQException {
  boolean skipBaseTypes = shouldSkipBaseType(type);
  Boolean value = null;
  if(!skipBaseTypes) {
    if(type.getBaseType() == XQBASETYPE_BOOLEAN) {
      value = Boolean.valueOf(result.getBoolean());
    }
    else if(type.getBaseType() == XQBASETYPE_STRING) {
      value = Boolean.valueOf(result.getAtomicValue());
    }
  }
  else if(XQITEMKIND_TEXT == type.getItemKind()) {
    String textContent = result.getNode().getTextContent();
    value = Boolean.valueOf(textContent);
  }
  else if(XQITEMKIND_ATTRIBUTE == type.getItemKind()) {
    String textContent = ((Attr)result.getNode()).getValue();
    value = Boolean.valueOf(textContent);
  }
  return value;
}

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

@Override
public void setContextItemStaticType(XQItemType contextItemType) throws XQException {
  
  if (contextItemType == null) {
    this.type = null;
  } else {
    QName typeName = null;
    if (XQUtils.isBaseTypeSupported(contextItemType.getItemKind())) {
      typeName = contextItemType.getTypeName();
    } else {
      // ???
    }
    QName nodeName = null;
    if (XQUtils.isNodeNameSupported(contextItemType.getItemKind())) {
      nodeName = contextItemType.getNodeName();
    }
    this.type = new BagriXQItemType(contextItemType.getBaseType(), contextItemType.getItemKind(),
        nodeName, typeName, contextItemType.isElementNillable(), contextItemType.getSchemaURI());
  }
}

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

public static BuiltInAtomicType getAtomicType(XQItemType type) throws XQException {
  int kind = type.getItemKind();
  if (XQUtils.isBaseTypeSupported(kind)) {
    switch (type.getBaseType()) {

代码示例来源:origin: spring-projects/spring-integration-extensions

else if(XQITEMKIND_TEXT == type.getItemKind()) {
  String textContent = result.getNode().getTextContent();
  value = convertStringToNumber(textContent);
else if(XQITEMKIND_ATTRIBUTE == type.getItemKind()) {
  String textContent = ((Attr)result.getNode()).getValue();
  value = convertStringToNumber(textContent);

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

public static Item convertXQItem(XQItem xqItem, Configuration config) throws XQException, XPathException {
  BuiltInAtomicType type = getAtomicType(xqItem.getItemType());
  if (type == null) {
    return convertToItem(xqItem.getObject(), config, xqItem.getItemType().getItemKind());
  }
  return convertToAtomicItem(xqItem.getObject(), config, type);
}

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

@Override
public XQItemType createDocumentElementType(XQItemType elementType)	throws XQException {
  
  checkState(ex_connection_closed);
  if (elementType == null) {
    throw new XQException("provided elementType is null");
  } 
  if (elementType.getItemKind() !=  XQITEMKIND_ELEMENT) {
    throw new XQException("provided elementType has wrong kind: " + elementType);
  }
  return new BagriXQItemType(elementType.getBaseType(), XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), 
      elementType.getTypeName(), false, null); 
}

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

@Override
public XQItem createItemFromDocument(String value, String baseURI, XQItemType type) throws XQException {
  checkState(ex_connection_closed);
  if (value == null) {
    throw new XQException("value is null");
  }
  
  // do not delete this line. it'll throw exception
  // in case when value contains wrong XML
  try {
    XMLUtils.textToDocument(value);
  } catch (IOException ex) {
    throw new XQException(ex.getMessage());
  }
  if (type == null) {
    return new BagriXQItem(xqProcessor, createDocumentElementType(createElementType(null, XQBASETYPE_UNTYPED)), 
        value); 
  } else {
    int kind = type.getItemKind(); 
    if (kind == XQITEMKIND_DOCUMENT || kind == XQITEMKIND_DOCUMENT_ELEMENT 
        || kind == XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) {
      return new BagriXQItem(xqProcessor, type, value);
    }
  }
  throw new XQException("wrong document type: " + type); 
}

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

@Override
public void write(ObjectDataOutput out, XQItemType type) throws IOException {
  try {
    int kind = type.getItemKind();
    out.writeInt(kind);
    if (isBaseTypeSupported(kind)) {
      out.writeInt(type.getBaseType());
      //out.writeObject(type.getTypeName());
      writeQName(out, type.getTypeName());
    }
    if (isNodeNameSupported(kind)) { // || isPINameSupported(kind)) {
      //out.writeObject(type.getNodeName()); // can be issues with wildcards
      writeQName(out, type.getNodeName());
    }
    if (type.getSchemaURI() == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      out.writeUTF(type.getSchemaURI().toString());
    }
    out.writeBoolean(type.isElementNillable());
  } catch (XQException ex) {
    throw new IOException(ex);
  }
}

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

if (this.getItemKind() != other.getItemKind()) {
  return false;

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

switch (type.getItemKind()) {
  case XQITEMKIND_ATOMIC: { 
    int bType = type.getBaseType();

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

logger.trace("write; got type: {}", type);
if (XQUtils.isBaseTypeSupported(type.getItemKind())) {
  int bType = type.getBaseType();
  if (XQUtils.isAtomicType(bType)) {
switch (type.getItemKind()) {
  case XQITEMKIND_DOCUMENT:
  case XQITEMKIND_DOCUMENT_ELEMENT:
    logger.info("write; wrong item kind: {}, writing as is", type.getItemKind());
    out.writeObject(item.getObject());

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com