gpt4 book ai didi

com.bagri.support.util.XQUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 00:23:05 27 4
gpt4 key购买 nike

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

XQUtils介绍

[英]set of XQJ static utilities
[中]XQJ静态实用程序集

代码示例

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

private Object getIndexedValue(Index idx, int pathId, Object value) {
  int baseType = getBaseTypeForTypeName(idx.getDataType());
  if (isStringTypeCompatible(baseType)) {
    value = value.toString();
    if (!idx.isCaseSensitive()) {
      value = ((String) value).toLowerCase();
    }
  } else {
    Path xPath = mdlMgr.getPath(pathId);
    if (xPath.getDataType() != baseType) {
      logger.info("getIndexedValue; index [{}] and path [{}] types are not compatible; Index: {}; path: {}; value: {}({})", 
          baseType, xPath.getDataType(), idx, pathId, value.getClass().getName(), value);
      try {
        // conversion from path type to index type
        value = getAtomicValue(baseType, value.toString());
      } catch (Exception ex) {
        // just log error and use old value
        logger.error("getIndexedValue.error: " + ex, ex);
      }
    }
  }
  return value;
}

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

@Override
public XQItemType createAttributeType(QName nodeName, int baseType)	throws XQException {
  
  return createAttributeType(nodeName, baseType, getTypeName(baseType), null);
}

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

@Override
public int getBaseType() throws XQException {
  
  if (XQUtils.isBaseTypeSupported(kind)) {
    return baseType;
  }
  throw new XQException("getBaseType is not supported for this item kind: " + kind);
}

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

/**
 * checks if the provided type name constant corresponds to any XQJ base types or not 
 * 
 * @param typeName one of XQJ type names 
 * @return true if the {@code typeName} corresponds to XQJ base type, false otherwise
 */
public static boolean isBaseType(String typeName) {
  return !isComplexType(typeName) && getBaseTypeForTypeName(typeName) > 0;
}

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

public static Object getAtomicValue(String typeName, String value) {
  int baseType = getBaseTypeForTypeName(typeName);
  return getAtomicValue(baseType, value);
}

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

/**
 * constructs XQJ item type for the {@code value} specified
 * 
 * @param factory the XQJ data factory to produce XQ item type
 * @param value the value to get item type from
 * @return XQ item type 
 * @throws XQException in case of construction error
 */
public static XQItemType getTypeForObject(XQDataFactory factory, Object value) throws XQException {
  
  if (value instanceof org.w3c.dom.Node) {
    return getTypeForNode(factory, (org.w3c.dom.Node) value);
  }
  
  int baseType = getBaseTypeForObject(value);
  return factory.createAtomicType(baseType, getTypeName(baseType), null);
}

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

newVals.add(adjustSearchValue(val, pathType));
if (isStringTypeCompatible(pathType)) {
  value = value.toString();
} else {				
    List newVals = new ArrayList(values.length);
    for (String val: values) {
      newVals.add(adjustSearchValue(val, pathType));
    value = getAtomicValue(pathType, value.toString());

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

@Override
public int hashCode() {
  
  int hashCode = this.getItemKind();
  if (this.getSchemaURI() != null) {
    hashCode = 31*hashCode + this.getSchemaURI().hashCode();
  }
  if (XQUtils.isBaseTypeSupported(kind)) {
    hashCode = 31*hashCode + baseType;
  }
  if (XQUtils.isNodeNameSupported(kind) && nodeName != null) {
    hashCode = 31*hashCode + nodeName.hashCode();
  }
  if (XQUtils.isBaseTypeSupported(kind)) {
    hashCode = 31*hashCode + typeName.hashCode();
  }
  try {
    if (XQUtils.isPINameSupported(kind) && this.getPIName () != null) { 
      hashCode = 31*hashCode + this.getPIName().hashCode();
    }
  } catch (XQException ex) {
    // can't be this, actually...
  }
  return hashCode;
}

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

/**
 * converts {@link QName} to the corresponding XQJ baseType. 
 * Return XQBASETYPE_STRING if the provided typeName's local name is not recognized.
 * Return XQBASETYPE_ANYTYPE if the provided typeName is not from standard xs: namespace.
 * 
 * @param typeName the QName type representation 
 * @return one of XQJ base type constants
 */
public static int getBaseTypeForTypeName(QName typeName) {
  if (xs_ns.equals(typeName.getNamespaceURI())) {
    return getBaseTypeForTypeName(typeName.getLocalPart());
  }
  return XQBASETYPE_ANYTYPE;
}

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

@Override
public void cancelExecution() throws XQException {
  try {
    getQueryManagement().cancelExecution();
  } catch (BagriException ex) {
    throw getXQException(ex);
  }
}

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

int baseType = 0;
QName typeName = null;
if (isBaseTypeSupported(kind)) {
  baseType = in.readInt();
if (isNodeNameSupported(kind)) { // || isPINameSupported(kind)) {
XQDataFactory xqFactory = getXQDataFactory();
if (baseType > 0) {
  if (isAtomicType(baseType)) {
    return xqFactory.createAtomicType(baseType, typeName, schemaURI); 
  } else {

代码示例来源: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

private List<Object> getSequenceValue(String type, List<String> values) {
  List<Object> list = new ArrayList<>();
  if (values.size() > 1) {
    for (String value: values) {
      list.add(getAtomicValue(type, value));
    }
  } else if (values.size() > 0){
    String[] vals = values.get(0).split(",");
    for (String value: vals) {
      list.add(getAtomicValue(type, value));
    }
  }
  return list;
}

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

private Object extractBodyValue(ContainerRequestContext context, Parameter pm, String content) { //throws IOException {
  logger.trace("extractBodyValue.enter; got param: {}; content: {}; mediaType: {}", pm, content, context.getMediaType());
  if (isBaseType(pm.getType())) {
    if (pm.getCardinality().isMultiple()) {
      List<String> values = new ArrayList<>(1);
      values.add(content);
      return getSequenceValue(pm.getType(), values);
    } else {
      return getAtomicValue(pm.getType(), content);
    }
  } else if (pm.getType().startsWith("map(")) {
    if (isSubtypeOf(context, "json")) {
      return mapFromJSON(content);
    }
    if (isSubtypeOf(context, "xml")) {
      return mapFromXML(content);
    }
  } else if (pm.getType().startsWith("document-node(")) {
    try {
      return textToDocument(content);
    } catch (IOException ex) {
      logger.error("", ex);
      return null;
    }
  } else if (pm.getType().startsWith("item(")) {
    return content; 
  }
  return content;
}

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

logger.trace("write; got type: {}", type);
if (XQUtils.isBaseTypeSupported(type.getItemKind())) {
  int bType = type.getBaseType();
  if (XQUtils.isAtomicType(bType)) {
    switch (bType) {
      case XQBASETYPE_BASE64BINARY:

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

} else if (item instanceof NodeInfo) {
  org.w3c.dom.Node node = NodeOverNodeInfo.wrap((NodeInfo)item);
  XQItemType xqt = XQUtils.getTypeForNode(xqFactory, node);
  return xqFactory.createItemFromNode(node, xqt);
} else if (item instanceof ObjectValue) {
    return (XQItemAccessor) value;
  } else {
    XQItemType xqt = XQUtils.getTypeForObject(xqFactory, value);
    return xqFactory.createItemFromObject(value, xqt);

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

@Override
public XQItem createItemFromObject(Object value, XQItemType type) throws XQException {
  checkState(ex_connection_closed);
  if (value == null) {
    throw new XQException("value is null");
  }
  if (type == null) {
    type = XQUtils.getTypeForObject(this, value); 
  } else {
    if (!XQUtils.isTypeValueCompatible(type.getBaseType(), value)) {
      throw new XQException("Value is not compatible");
    } 
  }
  return new BagriXQItem(xqProcessor, type, value);
}

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

@Override
public boolean apply(Entry<Long, QueryResult> resEntry) {
  long resultKey = resEntry.getKey();
  int queryKey = (int) (resultKey >> 32);
  if (queryKey == queryId) {
    Object param = resEntry.getValue().getParams().get(pex.getParamName());
    Object value = adjustSearchValue(param, pex.getCachedPath().getDataType());
    if (value != null) {
      return elts.apply(pex, value);
    }
  }
  return false;
}

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

@Override
public QName getNodeName() throws XQException {
  
  if (XQUtils.isNodeNameSupported(kind)) {
    
    if (nodeName != null && "*".equals(nodeName.getLocalPart())) { 
      return null;  // a wildcard..
    }
    return nodeName;
  }
  throw new XQException("getNodeName is not supported for this item kind: " + kind);
}

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

private void setCurrent() throws XQException {
  // TODO: construct XQItemType properly..?
  if (position > 0 && position <= sequence.size()) {
    Object current = sequence.get(position - 1); 
    if (current instanceof XQItem) {
      XQItem item = (XQItem) current;
      setCurrent(item.getItemType(), item.getObject());
    } else if (current instanceof XQSequence) {
      XQSequence sequence = (XQSequence) current;
      if (!sequence.isOnItem()) {
        sequence.first();
      }
      setCurrent(sequence.getItemType(), sequence);
    } else {
      setCurrent(XQUtils.getTypeForObject(xqFactory, current), current);
    }
  } else {
    setCurrent(null, null);
  }
}

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