net.sf.saxon.om.Item.getStringValueCS()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(102)

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

Item.getStringValueCS介绍

[英]Get the string value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String. The method satisfies the rule that X.getStringValueCS().toString() returns a string that is equal to X.getStringValue().

Note that two CharSequence values of different types should not be compared using equals(), and for the same reason they should not be used as a key in a hash table.

If the calling code can handle any CharSequence, this method should be used. If the caller requires a string, the #getStringValue method is preferred.
[中]以CharSequence的形式获取项的字符串值。在某些情况下,这比返回字符串的方法版本更有效。该方法满足X.getStringValueCS().toString()返回等于X.getStringValue()的字符串的规则。
请注意,不应使用equals()比较不同类型的两个CharSequence值,出于同样的原因,不应将它们用作哈希表中的键。
如果调用代码可以处理任何CharSequence,则应使用此方法。如果调用方需要字符串,则首选#getStringValue方法。

代码示例

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

/**
 * Get the string value of this sequence. The string value of an item is the result of applying the string()
 * function. The string value of an empty sequence is the zero-length string.
 *
 * @return the string value of the sequence.
 */
public CharSequence getStringValueCS() {
  return item == null ? "" : item.getStringValueCS();
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Get the string value of this sequence. The string value of an item is the result of applying the string()
 * function. The string value of an empty sequence is the zero-length string.
 *
 * @return the string value of the sequence.
 */
public CharSequence getStringValueCS() {
  return item == null ? "" : item.getStringValueCS();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
* Evaluate the function in a string context
*/
public CharSequence evaluateAsString(XPathContext c) throws XPathException {
  return evaluateItem(c).getStringValueCS();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
* Expand the stylesheet elements subordinate to this one, returning the result
* as a string. The expansion must not generate any element or attribute nodes.
* @param context The dynamic context for the transformation
*/
public CharSequence expandChildren(XPathContext context) throws XPathException {
  Item item = select.evaluateItem(context);
  if (item==null) {
    return (noNodeIfEmpty ? null : "");
  } else {
    return item.getStringValueCS();
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

public Item map(Item item) throws XPathException {
    if (item instanceof AnyURIValue) {
      return new StringValue(item.getStringValueCS());
    } else {
      return item;
    }
  }
};

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException {
  CharSequence result;
  try {
    result = arg.getStringValueCS();
  } catch (UnsupportedOperationException err) {
    throw new XPathException(err.getMessage(), "FOTY0014");
  }
  return new StringValue(result);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

@Override
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException {
  CharSequence result;
  try {
    result = arg.getStringValueCS();
  } catch (UnsupportedOperationException err) {
    throw new XPathException(err.getMessage(), "FOTY0014");
  }
  return new StringValue(result);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException {
  final CharSequence s = arg.getStringValueCS();
  return StringValue.makeStringValue(iriToUri(s));
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException {
  final CharSequence s = arg.getStringValueCS();
  return StringValue.makeStringValue(escape(s, "-_.~"));
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
* Evaluate the function
*/
public Item evaluateItem(XPathContext c) throws XPathException {
  Item arg = argument[0].evaluateItem(c);
  if (arg==null) {
    return StringValue.EMPTY_STRING;
  } else {
    return StringValue.makeStringValue(arg.getStringValueCS());
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Append an arbitrary item (node or atomic value) to the output
 */
public void append(/*@Nullable*/ Item item, Location locationId, int copyNamespaces) throws XPathException {
  if (item instanceof NodeInfo) {
    decompose(item, locationId, copyNamespaces);
  } else {
    characters(item.getStringValueCS(), locationId, 0);
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public Fold getFold(XPathContext context, Sequence... additionalArguments) throws XPathException {
  CharSequence separator = "";
  if (additionalArguments.length > 0) {
    separator = additionalArguments[0].head().getStringValueCS();
  }
  return new StringJoinFold(separator);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

private static String showKind(Item item) {
  if (item instanceof NodeInfo && ((NodeInfo) item).getNodeKind() == Type.TEXT &&
    Whitespace.isWhite(item.getStringValueCS())) {
    return "whitespace text() node";
  } else {
    return Type.displayTypeName(item);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

private static String showKind(Item item) {
  if (item instanceof NodeInfo && ((NodeInfo) item).getNodeKind() == Type.TEXT &&
    Whitespace.isWhite(item.getStringValueCS())) {
    return "whitespace text() node";
  } else {
    return Type.displayTypeName(item);
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException {
  FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.C64);
  for (Sequence<?> arg : arguments) {
    Item item = arg.head();
    if (item != null) {
      fsb.append(item.getStringValueCS());
    }
  }
  return new StringValue(fsb);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException {
  final CharSequence s = arg.getStringValueCS();
  return StringValue.makeStringValue(
        HTMLURIEscaper.escapeURL(s, false, getRetainedStaticContext().getConfiguration()));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException {
  FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.C64);
  for (Sequence<?> arg : arguments) {
    Item item = arg.head();
    if (item != null) {
      fsb.append(item.getStringValueCS());
    }
  }
  return new StringValue(fsb);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public CharSequence evaluateAsString(XPathContext context) throws XPathException {
  FastStringBuffer buffer = new FastStringBuffer(256);
  for (Operand o: operands()) {
    Item it = o.getChildExpression().evaluateItem(context);
    if (it != null) {
      buffer.append(it.getStringValueCS());
    }
  }
  return buffer;
}

代码示例来源: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);
  StringValue val = new StringValue(item.getStringValueCS());
  return f.call(context, new Sequence[]{val}).materialize();
}

代码示例来源: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);
  StringValue val = new StringValue(item.getStringValueCS());
  return f.call(context, new Sequence[]{val}).materialize();
}

相关文章