com.bagri.support.util.XQUtils.getAtomicValue()方法的使用及代码示例

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

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

XQUtils.getAtomicValue介绍

[英]converts String value to its Object representation. The resulting class constructed from the type provided.
[中]将字符串值转换为其对象表示形式。根据提供的类型构造的结果类。

代码示例

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

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

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

private void setNotFoundParam(Map<String, Object> params, String pType, Parameter pm) {
  // handle default values
  List<List<String>> atns = fn.getAnnotations().get(pType);
  if (atns != null) {
    String pName = pm.getName();
    String xpName = "{$" + pm.getName() + "}";
      for (List<String> values: atns) {
        if (values.size() > 2) {
          if (pName.equals(values.get(0)) || xpName.equals(values.get(1))) {
            params.put(pm.getName(), getAtomicValue(pm.getType(), values.get(2)));
            return;
          }
      }
    }
  }
  
  if (pm.getCardinality().isOptional()) {
    // pass empty value..
    params.put(pm.getName(), null);
  }
}

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

value = getAtomicValue(pathType, value.toString());

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

private void bindParams(Map<String, Parameter> params, XQDynamicContext xqe) throws XQException {
  for (Map.Entry<String, Parameter> e: params.entrySet()) {
    Parameter param = e.getValue();
    //if ("properties".equals(param.getType())) {
      // create and bind sequence with properties
    //	Properties props;
    //	try {
    //		props = propsFromString(param.getName());
    //	} catch (IOException ex) {
    //		logger.warn("bindParams.error; " + ex, ex);
    //		continue;
    //	}
      //XQItemType type = getConnection().createAtomicType(baseType, typeName, null);
      //XQSequence seq = getConnection().createSequence((java.util.Iterator) null);
      //xqe.bindSequence(new QName(e.getKey()), seq);
    //	XQSequenceType type = getConnection().createSequenceType(getConnection().createItemType(), XQSequenceType.OCC_ZERO_OR_MORE);
          //getConnection().createSequenceType(
          //		getConnection().createAtomicType(XQItemType.XQBASETYPE_STRING), XQSequenceType.OCC_ZERO_OR_MORE), XQSequenceType.OCC_ZERO_OR_MORE);
      //xqe.bindObject(new QName(e.getKey()), props, type);
    //} else {
      QName typeName = new QName(xs_ns, param.getType(), xs_prefix);
      int baseType = getBaseTypeForTypeName(typeName);
      XQItemType type = getConnection().createAtomicType(baseType, typeName, null);
      //xqe.bindAtomicValue(new QName(e.getKey()), param.getName(), type);
      xqe.bindObject(new QName(e.getKey()), getAtomicValue(baseType, param.getName()), type);
    //}
  }
}

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

List<String> vals = context.getUriInfo().getPathParameters().get(pm.getName());
if (vals != null) {
  params.put(pm.getName(), getAtomicValue(pm.getType(), vals.get(0)));
      Cookie val = context.getCookies().get(pm.getType());
      if (val != null) {
        params.put(pm.getName(), getAtomicValue(pm.getType(), val.getValue()));
        found = true;
            params.put(pm.getName(), getAtomicValue(pm.getType(), val));
            found = true;
        params.put(pm.getName(), getAtomicValue(pm.getType(), val));
        found = true;
          params.put(pm.getName(), getAtomicValue(pm.getType(), val));
          found = true;
          params.put(pm.getName(), getSequenceValue(pm.getType(), vals));
        } else {
          params.put(pm.getName(), getAtomicValue(pm.getType(), vals.get(0)));

相关文章