当前位置: 首页>>代码示例>>Java>>正文


Java AtomicValue类代码示例

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


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


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