• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AtomicValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.saxon.value.AtomicValue的典型用法代码示例。如果您正苦于以下问题:Java AtomicValue类的具体用法?Java AtomicValue怎么用?Java AtomicValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AtomicValue类属于net.sf.saxon.value包,在下文中一共展示了AtomicValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBooleanValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
/**
 * Gets a boolean value from the given index of the argument array. Atomic values are asked for their effective boolean
 * value; node values are assumed to be true. Empty sequences return false.
 * @param pArguments Function arguments.
 * @param pIndex Index of the array to inspect.
 * @return Boolean value of the argument.
 * @throws XPathException
 */
static boolean getBooleanValue(Sequence[] pArguments, int pIndex)
throws XPathException {
  if(pArguments.length > pIndex) {
    Item lItem = pArguments[pIndex].head();

    if(lItem == null) {
      return false;
    }

    if(lItem instanceof AtomicValue) {
      return ((AtomicValue) lItem).effectiveBooleanValue();
    }
    else {
      //Assume a node which exists and is therefore true
      return true;
    }
  }
  else {
    return false;
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:30,代码来源:FunctionUtils.java


示例2: convertResultObject

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
/**
 * Converts an object from an XPath result into a "cacheable" object which can be stored in an XPathVariableManager.
 * DOM/Node objects are cloned into unconnected elements, and collections are handled recursively.
 *
 * @param pVariableName Variable currently being converted for debug purposes.
 * @param pResultObject Object to convert.
 * @return Conversion result.
 */
private static Object convertResultObject(String pVariableName, Object pResultObject) {

  if(pResultObject instanceof String || pResultObject instanceof Number || pResultObject instanceof Boolean || pResultObject instanceof AtomicValue) {
    return pResultObject;
  }
  else if(pResultObject instanceof Collection) {
    return convertCollection(pVariableName, (Collection) pResultObject);
  }
  else if(pResultObject instanceof DOM) {
    return convertDOM(pVariableName, (DOM) pResultObject);
  }
  else if(pResultObject instanceof Node) {
    return convertDOM(pVariableName, new DOM((Node) pResultObject));
  }
  else {
    throw new ExInternal("Can't convert object of type " + pResultObject.getClass().getName() + " for variable $" + pVariableName);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:27,代码来源:ModuleXPathVariableManager.java


示例3: call

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {            
  try {        
    ResultSet rset = ((ObjectValue<ResultSet>) arguments[0].head()).getObject();
    if (!rset.next()) {
      return EmptySequence.getInstance();
    }        
    ArrayList<AtomicValue> values = new ArrayList<AtomicValue>();
    ResultSetMetaData metaData = rset.getMetaData();           
    int columnCount = metaData.getColumnCount();
    for (int i = 1; i <= columnCount; i++) {                    
      AtomicValue value = convertJavaObjectToAtomicValue(rset.getObject(i));
      values.add(value);
    }                
    return new OneOrMore<AtomicValue>(values.toArray(new AtomicValue[values.size()]));        
  } catch (Exception e) {
    throw new XPathException("Could not get row", e);
  }
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:21,代码来源:GetNextRow.java


示例4: getStringValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Nullable
public static String getStringValue(@Nullable Sequence seq) {
    if (seq == null) {
        return null;
    }

    if (seq instanceof AtomicValue) {
        return ((AtomicValue) seq).getStringValue();
    } else if (seq instanceof Item) {
        return ((Item) seq).getStringValue();
    } else {
        try {
            SequenceIterator seqIterator = seq.iterate();
            StrBuilder builder = new StrBuilder();
            Item seqItem;

            while ((seqItem = seqIterator.next()) != null) {
                Optional.ofNullable(getStringValue(seqItem)).ifPresent(builder::append);
            }

            return builder.build();
        } catch (XPathException e) {
            throw new SaxonApiUncheckedException(e);
        }
    }
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:27,代码来源:SdcctXdmUtils.java


示例5: convertToAtomicValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
public static AtomicValue convertToAtomicValue(Object value) throws TransformerException {
	if (value instanceof java.util.Date) { //special handling for time types
       	java.util.Date d = (java.util.Date)value;
       	DateTimeValue tdv = DateTimeValue.fromJavaDate(d);
       	if (value instanceof Date) {
       		value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes(), true);
       	} else if (value instanceof Time) {
       		value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes());
       	} else if (value instanceof Timestamp) {
       		Timestamp ts = (Timestamp)value;
       		value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000));
       	}
       	return (AtomicValue)value;
       }
	JPConverter converter = JPConverter.allocate(value.getClass(), null);
	return (AtomicValue)converter.convert(value, null);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:XMLSystemFunctions.java


示例6: getValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
public static Object getValue(Class<?> type,
		Item colItem, Configuration config, CommandContext context) throws XPathException,
		ValidationException, TransformationException {
	Object value = colItem;
	if (value instanceof AtomicValue) {
		value = getValue((AtomicValue)colItem, context);
	} else if (value instanceof Item) {
		Item i = (Item)value;
		if (XMLSystemFunctions.isNull(i)) {
			return null;
		}
		BuiltInAtomicType bat = typeMapping.get(type);
		if (bat != null) {
			AtomicValue av = new StringValue(i.getStringValueCS());
			ConversionResult cr = Converter.convert(av, bat, config.getConversionRules());
			value = cr.asAtomic();
			value = getValue((AtomicValue)value, context);
			if (value instanceof Item) {
				value = ((Item)value).getStringValue();
			}
		} else {
			value = i.getStringValue();
		}
	}
	return FunctionDescriptor.importValue(value, type);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:XMLTableNode.java


示例7: deepEquals

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public boolean deepEquals(Function other, XPathContext context, AtomicComparer comparer, int flags) throws XPathException {
	logger.trace("deepEquals.enter; other: {}; comparer: {}; flags: {}", other, comparer, flags);
       if (other instanceof MapItem && ((MapItem) other).size() == size()) {
           AtomicIterator keys = keys();
           AtomicValue key;
           while ((key = keys.next()) != null) {
               Sequence thisValue = get(key);
               Sequence otherValue = ((MapItem) other).get(key);
               if (otherValue == null) {
                   return false;
               }
               if (!DeepEqual.deepEqual(otherValue.iterate(), thisValue.iterate(), comparer, context, flags)) {
                   return false;
               }
           }
           return true;
       }
       return false;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:MapItemImpl.java


示例8: get

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public Sequence get(AtomicValue key) {
	logger.trace("get.enter; key: {}", key);
	String sKey = key.getStringValue();
	if (sKey.startsWith("@")) {
		sKey = sKey.substring(1);
	}
	Object value = source.get(sKey);
	if (value != null) {
		try {
			return SaxonUtils.objectToItem(value, config);
		} catch (XPathException ex) {
			logger.error("get.error; key: {}", key, ex); 
		}
	} else if ("map".equals(sKey)) {
		return this;
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:MapItemImpl.java


示例9: mapToString

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
private static String mapToString(HashTrieMap map) {
    StringBuilder result = new StringBuilder();
    result.append("(");
    List<AtomicValue> keyList = getKeys(map);
    for (int i = 0; i < keyList.size(); i++) {
        AtomicValue key = keyList.get(i);
        Sequence value = map.get(key);
        String[] sequenceValue = getSequenceValue(value);
        result.append(itemToString(key));
        result.append("->");
        result.append(sequenceValue[0]);
        if (i < keyList.size() - 1) {
            result.append(", ");
        }
    }
    result.append(")");
    return result.toString();
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:19,代码来源:SaxonItemConverter.java


示例10: convert

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
private Object convert(Object pObject) {

    //Mustache treats nulls and booleans specially so they shouldn't be wrapped
    if(pObject == null || pObject instanceof Boolean) {
      return pObject;
    }
    else if(pObject instanceof List) {
      throw new ExInternal("Cannot wrap a list for use in a mustache template");
    }
    else {

      String lObjectStringValue;
      if(pObject instanceof DOM) {
        lObjectStringValue = ((DOM) pObject).value(false);
      }
      else if(pObject instanceof Node){
        lObjectStringValue = new DOM((Node) pObject).value(false);
      }
      else if(pObject instanceof AtomicValue) {
        lObjectStringValue = ((AtomicValue) pObject).getStringValue();
      }
      else {
        lObjectStringValue = pObject.toString();
      }

      if(lObjectStringValue.trim().length() > 0) {
        return lObjectStringValue;
      }
      else {
        return null;
      }
    }
  }
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:34,代码来源:MustacheVariableConverter.java


示例11: asString

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
/**
* Gets this XPathResult object as a String. The following logic is used for different result types:
* <ul>
* <li>For NodeLists - return the non-recursive value of the first node in the list (i.e. text content for Elements,
* value for Attributes).
* If the list is empty, return an empty String.
* </li>
* <li>For Nodes - return the value of the node (as above)</li>
* <li>For Booleans - string "true" or string "false"</li>
* <li>For Numbers - the result of Number.toString()</li>
* <li>For Strings - the String</li>
* </ul>
* @return The result as a String.
*/
public String asString(){

  //If we have a list, use the first item as the result object
  Object lResultObject = getObjectOrFirstObjectInList(mResultObject, "");

  if(lResultObject instanceof String) {
    return (String) lResultObject;
  }
  else if(lResultObject instanceof DOM){
    return ((DOM) lResultObject).value(false);
  }
  else if(lResultObject instanceof Node){
    return new DOM((Node) lResultObject).value(false);
  }
  else if(lResultObject instanceof Boolean) {
    return ((Boolean) lResultObject) ? "true" : "false";
  }
  else if(lResultObject instanceof Number) {
    return ((Number) lResultObject).toString();
  }
  else if (lResultObject instanceof AtomicValue){
    return ((AtomicValue) lResultObject).getStringValue();
  }
  else {
    throw new ExInternal("Unable to convert XPATH result (type " + lResultObject.getClass().getName() + ") to String for XPath: " + mFoxPath.getOriginalPath());
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:42,代码来源:XPathResult.java


示例12: getBoolean

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public boolean getBoolean() throws HttpClientException {
  String str = myNode.getStringValue();
  AtomicValue val;
  try {
    val = BooleanValue.fromString(str).asAtomic();
  } catch (XPathException ex) {
    throw new HttpClientException("Error parse the attribute value as boolean", ex);
  }
  if (!(val instanceof BooleanValue)) {
    throw new HttpClientException("@" + getLocalName() + " is not a boolean");
  }
  BooleanValue b = (BooleanValue) val;
  return b.getBooleanValue();
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:16,代码来源:SaxonAttribute.java


示例13: call

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] args) throws XPathException {
	logger.trace("call.enter; got args: {}", args == null ? null : Arrays.toString(args));
       AtomicValue key = (AtomicValue) args[0].head();
       Sequence value = get(key);
       if (value == null) {
           return EmptySequence.getInstance();
       } else {
           return value;
       }
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:12,代码来源:MapItemImpl.java


示例14: addEntry

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public MapItem addEntry(AtomicValue key, Sequence value) {
	try {
		String sKey = key.getStringValue();
		Object sVal = SaxonUtils.itemToObject((Item) value);
		source.put(sKey, sVal);
	} catch (XPathException ex) {
		logger.error("addEntry.error; key: {}, value: {}", key, value, ex);
	}
	return this;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:12,代码来源:MapItemImpl.java


示例15: next

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public AtomicValue next() {
	logger.trace("MapKeyIterator.next.enter");
	String key = null;
	try {
		key = keys.next();
	} catch (NoSuchElementException ex) {
		// noop
	}
	if (key != null) {
		return new StringValue(key);
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:15,代码来源:MapItemImpl.java


示例16: makeCallExpression

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {

	return new ExtensionFunctionCall() {

		@Override
		public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
			
			String query = arguments[0].head().getStringValue();
			MapItem item = (MapItem) arguments[1].head();
			Map<String, Object> params = itemToMap(item);
			Properties props = null; 
			if (arguments.length > 2) {
				props = sequence2Properties(arguments[2]);
			}
			try {
				ResultCursor<String> uris = qm.getDocumentUris(query, params, props);
				ArrayList<AtomicValue> list = new ArrayList<>(); //uris.size());
				for (String uri: uris) {
					list.add(new StringValue(uri));
				}
				return new AtomicArray(list);
			} catch (BagriException ex) {
				throw new XPathException(ex);
			}
		}

	};
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:30,代码来源:QueryDocumentUris.java


示例17: makeCallExpression

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {

	return new ExtensionFunctionCall() {

		@Override
		public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
			
			String pattern = arguments[0].head().getStringValue();
			Properties props = null; 
			if (arguments.length > 1) {
				props = sequence2Properties(arguments[1]);
			} else {
				props = new Properties();
			}
			props.setProperty(pn_document_headers, String.valueOf(DocumentAccessor.HDR_URI));
			try (ResultCursor<DocumentAccessor> uris = xdm.getDocuments(pattern, props)) {
				List<AtomicValue> result = new ArrayList<>(); //uris.size());
				for (DocumentAccessor da: uris) {
					result.add(new StringValue(da.getUri()));
				}
				return new AtomicArray(result);
			} catch (Exception ex) {
				throw new XPathException(ex);
			}
		}
       };
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:29,代码来源:GetDocumentUris.java


示例18: getSequenceValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
public static String[] getSequenceValue(SequenceIterator iterator) {
    String type = "item()";
    try {
        List<String> sequenceItems = new ArrayList<>();
        Item next = iterator.next();
        if (next != null && next instanceof AtomicValue) {
            type = ((AtomicValue) next).getPrimitiveType().getPrimitiveItemType().toString();
        } else if (next != null && next instanceof HashTrieMap) {
            type = "map(*)";
        }

        while (next != null) {
            sequenceItems.add(itemToString(next));
            next = iterator.next();
        }

        StringBuilder sb = new StringBuilder();
        int numberOfSequenceItems = sequenceItems.size();
        if (numberOfSequenceItems > 1) {
            sb.append("(");
        }
        for (int i = 0; i < numberOfSequenceItems; i++) {
            sb.append(sequenceItems.get(i));
            if (i < numberOfSequenceItems - 1) {
                sb.append(", ");
            }
        }
        if (numberOfSequenceItems > 1) {
            sb.append(")");
            type = type + "*";
        }

        return new String[]{sb.toString(), type};
    } catch (XPathException e) {
        return null;
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:38,代码来源:SaxonItemConverter.java


示例19: getKeys

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
private static List<AtomicValue> getKeys(HashTrieMap map) {
    List<AtomicValue> keyList = new ArrayList<>();
    AtomicIterator keys = map.keys();
    AtomicValue key;
    while ((key = keys.next()) != null) {
        keyList.add(key);
    }
    return keyList;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:10,代码来源:SaxonItemConverter.java


示例20: getTypedValue

import net.sf.saxon.value.AtomicValue; //导入依赖的package包/类
/**
 * Get the typed value of the item
 */

public SequenceIterator getTypedValue() {
	return SingletonIterator.makeIterator((AtomicValue)atomize());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:8,代码来源:NodeWrapper.java



注:本文中的net.sf.saxon.value.AtomicValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IPlayerUsage类代码示例发布时间:2022-05-22
下一篇:
Java AbstractConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap