本文整理汇总了Java中net.sf.saxon.value.StringValue类的典型用法代码示例。如果您正苦于以下问题:Java StringValue类的具体用法?Java StringValue怎么用?Java StringValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringValue类属于net.sf.saxon.value包,在下文中一共展示了StringValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
private static final long serialVersionUID = 1L;
@Override
public Sequence call(XPathContext xPathContext, Sequence[] arguments) throws XPathException {
// 1st argument (mandatory, index 0)
StringValue arg1 = (StringValue) arguments[0].iterate().next();
String arg1Str = arg1.getStringValue();
// 2nd argument (optional, index 1)
String arg2Str = "";
if (arguments.length > 1) {
StringValue arg2 = (StringValue) arguments[1].iterate().next();
arg2Str = arg2.getStringValue();
}
// Functionality goes here
String resultStr = arg1Str + arg2Str;
Item result = new StringValue(resultStr);
return SequenceTool.toLazySequence(SingletonIterator.makeIterator(result));
}
};
}
示例2: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
private static final long serialVersionUID = 1L;
@Override
public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
// get value of first arg passed to the function
Item arg1 = sequences[0].head();
String arg1Val = arg1.getStringValue();
// return a altered version of the first arg
return new StringValue("arg1[" + arg1Val + "]");
}
};
}
示例3: getStringValueOrNull
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
static String getStringValueOrNull(Sequence[] pArguments, int pIndex, String pFunctionName, boolean pStrict)
throws XPathException {
String lResult = null;
if(pArguments.length > pIndex) {
Item lItem = pArguments[pIndex].head();
if(!(lItem instanceof StringValue) && pStrict) {
throw new ExInternal("Argument " + (pIndex+1) + " to " + pFunctionName + " function must be a string.");
}
if(lItem != null) {
lResult = lItem.getStringValue();
}
}
return lResult;
}
示例4: getPath
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
public static Sequence getPath(KeyDefInterface keyDef) {
if (keyDef != null) {
List<String> path = keyDef.getNamespaceList();
List<Item> list = new LinkedList<>();
if (path != null) {
for (String element : path) {
list.add(new StringValue(element));
}
}
list.add(new StringValue(keyDef.getKey()));
//logger.info("result: " + keyDef.getNamespace() + " " + keyDef.getKey());
return new SequenceExtent(list);
} else {
//logger.info("result: ()");
return EmptySequence.getInstance();
}
}
示例5: call
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final Item contextItem = context.getContextItem();
if (!(contextItem instanceof NodeInfo)) {
throw new XPathException("Context item '" + contextItem.getClass() + "'needs to be an instance of NodeInfo.");
}
final String xPath = arguments[0].head().getStringValue();
final SaxonNodeWrapper contextNode = new SaxonNodeWrapper((NodeInfo)contextItem, otResolver.getXPathCache());
final String resolvedXPath = EmbeddedXPathResolver.resolve(xPath, contextNode);
return new StringValue(resolvedXPath);
}
示例6: call
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final SaxonNodeWrapper keyRefNode = new SaxonNodeWrapper((NodeInfo)arguments[0].head(), otResolver.getXPathCache());
final KeyRef keyRef = KeyRef.fromNode(keyRefNode);
final Item keyDefItem = arguments[1].head();
if ((keyRef == null) || (keyDefItem == null)) {
return EmptySequence.getInstance();
} else {
final KeyDefInterface keyDef = DitaSemiaOtResolver.getKeyDefFromItem(arguments[1].head());
final DisplaySuffix displaySuffix = keyRef.getDisplaySuffix(keyDef, false);
final List<Item> list = new LinkedList<>();
list.add(new StringValue(displaySuffix.keySuffix));
list.add(new StringValue(displaySuffix.nameSuffix));
return new SequenceExtent(list);
}
}
示例7: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
String text = "";
try {
text = ((StringValue) arguments[0].next()).getStringValue();
// Split street name and number + addition, return number + addition
// Find first number, and return everything including and after that
// position.
// TODO: Problem some street names have numbers in them...
int i;
for (i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (Character.isDigit(c)) {
break;
}
}
if (i == text.length()) {
return Value.asIterator(EmptySequence.getInstance());
}
text = text.substring(i, text.length()).trim();
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
return Value.asIterator(StringValue.makeStringValue(text));
}
};
}
示例8: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
// grijpt nummer uit string en plakt eventuele toevoeging eraan vast
String streetName = "";
try {
streetName = ((StringValue) arguments[0].next()).getStringValue();
streetName = sanitizeStreetName(streetName);
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
if (streetName.length() == 0) {
return Value.asIterator(EmptySequence.getInstance());
}
return Value.asIterator(StringValue.makeStringValue(streetName));
}
};
}
示例9: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
String type = "";
try {
type = ((StringValue) arguments[0].next()).getStringValue();
// Rewrite TAM export types
if (TYPES.containsKey(type)) {
String newType = TYPES.get(type);
return Value.asIterator(StringValue.makeStringValue(newType));
} else {
return Value.asIterator(EmptySequence.getInstance());
}
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
}
};
}
示例10: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
String postalCode = "";
String number = "";
String addition = "";
try {
postalCode = ((StringValue) arguments[0].next()).getStringValue();
number = ((StringValue) arguments[1].next()).getStringValue();
if (arguments.length == 3) {
addition = ((StringValue) arguments[2].next()).getStringValue();
}
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
if (postalCode.length() > 0 && number.length() > 0) {
//addition may be empty sequence
String address = postalCode + number + addition;
address = address
.replaceAll("\\s+","")
.replaceAll("\\/+", "-")
.replaceAll("\\\\+", "-");
return Value.asIterator(StringValue.makeStringValue(address));
} else {
return Value.asIterator(EmptySequence.getInstance());
}
}
};
}
示例11: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
boolean result = false;
try {
String str = ((StringValue) arguments[0].next()).getStringValue();
// TODO: are values > 1 also true?
result = (str.equals("1") || str.toLowerCase().equals("true")) ? true : false;
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
return Value.asIterator(StringValue.makeStringValue(Boolean.toString(result)));
}
};
}
示例12: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
String text = "";
try {
text = ((StringValue) arguments[0].next()).getStringValue();
if (text.length() == 1) {
text = text.toUpperCase();
} else {
text = text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
}
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
return Value.asIterator(StringValue.makeStringValue(text));
}
};
}
示例13: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
String point = "";
try {
String lat = ((StringValue) arguments[0].next()).getStringValue();
String lon = ((StringValue) arguments[1].next()).getStringValue();
// WKT POINT specification: first lon, then lat.
//if ( fn:empty($lat) or fn:empty($long) ) then () else concat( 'POINT(', $long, ' ', $lat, ')' )
point = "POINT(" + lon + " " + lat + ")";
} catch (NullPointerException e) {
}
if (point.length() > 0) {
return Value.asIterator(StringValue.makeStringValue(point));
} else {
return Value.asIterator(EmptySequence.getInstance());
}
}
};
}
示例14: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
float number = 0;
try {
number = ((FloatValue) arguments[0].next()).getFloatValue();
} catch (NullPointerException e) {}
if (number == 0) {
return Value.asIterator(EmptySequence.getInstance());
} else {
return Value.asIterator(StringValue.makeStringValue(Float.toString(number)));
}
}
};
}
示例15: makeCallExpression
import net.sf.saxon.value.StringValue; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public SequenceIterator call(SequenceIterator[] arguments,
XPathContext context) throws XPathException {
// concat twee strings (naam en nummer). Alleen naam mag, alleen nummer niet.
String streetName = "";
String streetNumber = "";
try {
streetName = ((StringValue) arguments[0].next()).getStringValue();
if (arguments.length > 1) {
streetNumber = arguments[1].next().getStringValue();
}
} catch (Exception e) {
return Value.asIterator(EmptySequence.getInstance());
}
String streetAddress = streetName;
if (streetNumber.length() > 0) {
streetAddress += " " + streetNumber;
}
return Value.asIterator(StringValue.makeStringValue(streetAddress));
}
};
}