本文整理了Java中net.sf.saxon.om.Item.atomize()
方法的一些代码示例,展示了Item.atomize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.atomize()
方法的具体详情如下:
包路径:net.sf.saxon.om.Item
类名称:Item
方法名:atomize
[英]Atomize the item.
[中]使物品雾化。
代码示例来源:origin: net.sf.saxon/Saxon-HE
public AtomicValue next() throws XPathException {
Item nextSource = base.next();
if (nextSource == null) {
return null;
} else {
return (AtomicValue) nextSource.atomize();
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
protected List<ItemToBeSorted> getItemsToBeSorted(Sequence<?> input) throws XPathException {
final List<ItemToBeSorted> inputList = new ArrayList<>();
int i = 0;
SequenceIterator<?> iterator = input.iterate();
Item item;
while ((item = iterator.next()) != null) {
ItemToBeSorted member = new ItemToBeSorted();
member.value = item;
member.originalPosition = i++;
member.sortKey = item.atomize();
inputList.add(member);
}
return inputList;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
protected List<ItemToBeSorted> getItemsToBeSorted(Sequence<?> input) throws XPathException {
final List<ItemToBeSorted> inputList = new ArrayList<>();
int i = 0;
SequenceIterator<?> iterator = input.iterate();
Item item;
while ((item = iterator.next()) != null) {
ItemToBeSorted member = new ItemToBeSorted();
member.value = item;
member.originalPosition = i++;
member.sortKey = item.atomize();
inputList.add(member);
}
return inputList;
}
代码示例来源:origin: dsukhoroslov/bagri
public static List<Object> itemToList(ArrayItem ai) throws XPathException {
List<Object> result = new ArrayList<>(ai.arrayLength());
for (Sequence sq: ai) {
result.add(itemToObject(sq.head().atomize().head()));
}
return result;
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public AtomicSequence atomize() throws XPathException {
List<AtomicValue> list = new ArrayList<>(source.size());
for (Object o: source) {
Item item = objectToItem(o, config);
SequenceIterator iter = item.iterate();
while ((item = iter.next()) != null) {
AtomicSequence atoms = item.atomize();
for (AtomicValue atom: atoms) {
list.add(atom);
}
}
}
return new AtomicArray(list);
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Evaluate as an Item. This should only be called if the Atomizer has cardinality zero-or-one,
* which will only be the case if the underlying expression has cardinality zero-or-one.
*/
public AtomicValue evaluateItem(XPathContext context) throws XPathException {
Item i = getBaseExpression().evaluateItem(context);
if (i == null) {
return null;
} else {
return i.atomize().head();
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Evaluate as an Item. This should only be called if the Atomizer has cardinality zero-or-one,
* which will only be the case if the underlying expression has cardinality zero-or-one.
*/
public AtomicValue evaluateItem(XPathContext context) throws XPathException {
Item i = getBaseExpression().evaluateItem(context);
if (i == null) {
return null;
} else {
return i.atomize().head();
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Atomize the item.
*
* @return the result of atomization
* @throws XPathException if atomization is not allowed for this kind of item
*/
public AtomicSequence atomize() throws XPathException {
List<AtomicValue> list = new ArrayList<>(arrayLength());
for (GroundedValue<?> seq : members()) {
seq.iterate().forEachOrFail(item -> {
AtomicSequence atoms = item.atomize();
for (AtomicValue atom : atoms) {
list.add(atom);
}
});
}
return new AtomicArray(list);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
public AtomicValue next() throws XPathException {
Item nextSource = base.next();
/*@Nullable*/
if (nextSource == null) {
return null;
} else {
if (nextSource instanceof NodeInfo) {
return (AtomicValue) nextSource.atomize();
} else if (nextSource instanceof AtomicValue) {
return (AtomicValue) nextSource;
} else if (nextSource instanceof ObjectValue) {
return ((ObjectValue)nextSource).atomize();
} else {
assert !(nextSource instanceof ArrayItem);
throw new XPathException("The typed value of a function item is not defined", "FOTY0013");
}
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Evaluate the expression. (Used for run-time evaluation only)
*
* @param context the dynamic evaluation context
* @param arguments the values of the arguments, supplied as Sequences
* @return the result of the evaluation, in the form of a Sequence
* @throws net.sf.saxon.trans.XPathException
* if a dynamic error occurs during the evaluation of the expression
*/
public Sequence<? extends AtomicValue> call(XPathContext context, Sequence[] arguments) throws XPathException {
Sequence<?> arg = arguments[0];
if (arg instanceof Item) {
return ((Item)arg).atomize();
} else {
SequenceIterator<? extends AtomicValue> a = Atomizer.getAtomizingIterator(arg.iterate(), false);
return SequenceTool.toLazySequence(a);
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Atomize the item.
*
* @return the result of atomization
* @throws XPathException if atomization is not allowed for this kind of item
*/
public AtomicSequence atomize() throws XPathException {
List<AtomicValue> list = new ArrayList<>(arrayLength());
for (GroundedValue<?> seq : members()) {
seq.iterate().forEachOrFail(item -> {
AtomicSequence atoms = item.atomize();
for (AtomicValue atom : atoms) {
list.add(atom);
}
});
}
return new AtomicArray(list);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Evaluate the expression. (Used for run-time evaluation only)
*
* @param context the dynamic evaluation context
* @param arguments the values of the arguments, supplied as Sequences
* @return the result of the evaluation, in the form of a Sequence
* @throws net.sf.saxon.trans.XPathException
* if a dynamic error occurs during the evaluation of the expression
*/
public Sequence<? extends AtomicValue> call(XPathContext context, Sequence[] arguments) throws XPathException {
Sequence<?> arg = arguments[0];
if (arg instanceof Item) {
return ((Item)arg).atomize();
} else {
SequenceIterator<? extends AtomicValue> a = Atomizer.getAtomizingIterator(arg.iterate(), false);
return SequenceTool.toLazySequence(a);
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
public AtomicValue next() throws XPathException {
while (true) {
if (currentValue != null) {
if (currentValuePosition < currentValueSize) {
return currentValue.itemAt(currentValuePosition++);
} else {
currentValue = null;
}
}
Item nextSource = base.next();
if (nextSource != null) {
AtomicSequence v = nextSource.atomize();
if (v instanceof AtomicValue) {
return (AtomicValue) v;
} else {
currentValue = v;
currentValuePosition = 0;
currentValueSize = currentValue.getLength();
// now go round the loop to get the first item from the atomized value
}
} else {
currentValue = null;
return null;
}
}
}
代码示例来源:origin: dsukhoroslov/bagri
public static Map<String, Object> itemToMap(MapItem mi) throws XPathException {
AtomicValue key;
AtomicIterator itr = mi.keys();
Map<String, Object> result = new HashMap<>(mi.size());
while ((key = itr.next()) != null) {
Sequence value = mi.get(key);
result.put(key.getStringValue(), itemToObject(value.head().atomize().head()));
}
return result;
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
if (nextSource != null) {
try {
AtomicSequence v = nextSource.atomize();
if (v instanceof AtomicValue) {
return (AtomicValue) v;
代码示例来源:origin: net.sf.saxon/Saxon-HE
@Override
public GroundedValue evaluate(Item item, XPathContext context) throws XPathException {
SystemFunction f = SystemFunction.makeFunction(getDetails().name.getLocalPart(), getRetainedStaticContext(), 1);
AtomicSequence val = item.atomize();
switch (val.getLength()) {
case 0:
return DoubleValue.NaN;
case 1:
return f.call(context, new Sequence[]{val.head()}).materialize();
default:
XPathException err = new XPathException(
"When number() is called with no arguments, the atomized value of the context node must " +
"not be a sequence of several atomic values", "XPTY0004");
err.setIsTypeError(true);
throw err;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
@Override
public GroundedValue evaluate(Item item, XPathContext context) throws XPathException {
SystemFunction f = SystemFunction.makeFunction(getDetails().name.getLocalPart(), getRetainedStaticContext(), 1);
AtomicSequence val = item.atomize();
switch (val.getLength()) {
case 0:
return DoubleValue.NaN;
case 1:
return f.call(context, new Sequence[]{val.head()}).materialize();
default:
XPathException err = new XPathException(
"When number() is called with no arguments, the atomized value of the context node must " +
"not be a sequence of several atomic values", "XPTY0004");
err.setIsTypeError(true);
throw err;
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
} else if (count == 1) {
Item first = base.next();
return first.atomize().iterate();
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Evaluate as an Item. This should only be called if a singleton or empty sequence is required;
* it throws a type error if the underlying sequence is multi-valued.
*/
public AtomicValue evaluateItem(XPathContext context) throws XPathException {
int found = 0;
AtomicValue result = null;
SequenceIterator iter = getBaseExpression().iterate(context);
Item item;
while ((item = iter.next()) != null) {
AtomicSequence seq = item.atomize();
found += seq.getLength();
if (found > 1) {
typeError(
"A sequence of more than one item is not allowed as the " +
role.getMessage() + CardinalityChecker.depictSequenceStart(getBaseExpression().iterate(context), 3),
role.getErrorCode(), context);
}
if (found == 1) {
result = seq.head();
}
}
if (found == 0 && !allowEmpty) {
typeError("An empty sequence is not allowed as the " +
role.getMessage(), role.getErrorCode(), null);
}
return result;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Evaluate as an Item. This should only be called if a singleton or empty sequence is required;
* it throws a type error if the underlying sequence is multi-valued.
*/
public AtomicValue evaluateItem(XPathContext context) throws XPathException {
int found = 0;
AtomicValue result = null;
SequenceIterator iter = getBaseExpression().iterate(context);
Item item;
while ((item = iter.next()) != null) {
AtomicSequence seq = item.atomize();
found += seq.getLength();
if (found > 1) {
typeError(
"A sequence of more than one item is not allowed as the " +
role.getMessage() + CardinalityChecker.depictSequenceStart(getBaseExpression().iterate(context), 3),
role.getErrorCode(), context);
}
if (found == 1) {
result = seq.head();
}
}
if (found == 0 && !allowEmpty) {
typeError("An empty sequence is not allowed as the " +
role.getMessage(), role.getErrorCode(), null);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!