本文整理汇总了Java中net.sf.saxon.value.EmptySequence.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java EmptySequence.getInstance方法的具体用法?Java EmptySequence.getInstance怎么用?Java EmptySequence.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.value.EmptySequence
的用法示例。
在下文中一共展示了EmptySequence.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPath
import net.sf.saxon.value.EmptySequence; //导入方法依赖的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();
}
}
示例2: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
File file = getFile(((StringValue) arguments[0].head()).getStringValue());
boolean recursive = false;
if (arguments.length > 1) {
recursive = ((BooleanValue) arguments[1].head()).getBooleanValue();
}
if (!file.exists()) {
throw new FileException(String.format("Path \"%s\" does not exist",
file.getAbsolutePath()), FileException.ERROR_PATH_NOT_EXIST);
}
if (file.isDirectory() && !recursive && file.list().length > 0) {
throw new FileException(String.format("Path \"%s\" points to a non-empty directory",
file.getAbsolutePath()), FileException.ERROR_PATH_IS_DIRECTORY);
}
FileUtils.forceDelete(file);
return EmptySequence.getInstance();
} catch (FileException fe) {
throw fe;
} catch (Exception e) {
throw new FileException("Other file error", e, FileException.ERROR_IO);
}
}
示例3: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的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);
}
}
示例4: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
String source = ((StringValue) arguments[0].head()).getStringValue();
String target = ((StringValue) arguments[1].head()).getStringValue();
try {
File sourceDir = new File(source);
if (!sourceDir.isDirectory()) {
throw new IOException("Source directory \"" + sourceDir.getAbsolutePath() + "\" not found");
}
File targetFile = new File(target);
if (targetFile.isDirectory()) {
throw new IOException("Output file \"" + targetFile.getAbsolutePath() + "\" already exists as directory");
} else if (targetFile.isFile() && FileUtils.deleteQuietly(targetFile)) {
throw new IOException("Could not delete existing output file \"" + targetFile.getAbsolutePath() + "\"");
} else if (!targetFile.getParentFile().isDirectory() && !targetFile.getParentFile().mkdirs()) {
throw new IOException("Could not create output directory \"" + targetFile.getParentFile().getAbsolutePath() + "\"");
}
ZipUtils.zipDirectory(sourceDir, targetFile);
return EmptySequence.getInstance();
} catch (IOException ioe) {
throw new XPathException("Error zipping \"" + source + "\" to \"" + target + "\"", ioe);
}
}
示例5: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的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);
}
}
示例6: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String path = ((StringValue) arguments[0].head()).getStringValue();
File file;
if ((file = XSLWebUtils.getSafeTempFile(path)) == null) {
throw new XPathException("Could not register temporary file. Path is not a valid temporary path.");
}
HttpServletRequest request = getRequest(context);
List<File> tempFiles = (List<File>) request.getAttribute(Definitions.ATTRNAME_TEMPFILES);
if (tempFiles == null) {
tempFiles = new ArrayList<File>();
request.setAttribute(Definitions.ATTRNAME_TEMPFILES, tempFiles);
}
tempFiles.add(file);
return EmptySequence.getInstance();
} catch (Exception e) {
throw new XPathException("Could not register temporary file", e);
}
}
示例7: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
AutoCloseable closeable = (AutoCloseable) ((ObjectValue) arguments[0].head()).getObject();
closeable.close();
return EmptySequence.getInstance();
} catch (Exception e) {
throw new XPathException("Error closing object", e);
}
}
示例8: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
NodeInfo cookieElem = unwrapNodeInfo((NodeInfo) arguments[0].head());
String comment = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "comment", context);
String domain = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "domain", context);
String maxAge = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "max-age", context);
String name = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "name", context);
String path = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "path", context);
String isSecure = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "is-secure", context);
String value = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "value", context);
String version = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "version", context);
Cookie cookie = new Cookie(name, value);
if (comment != null) cookie.setComment(comment);
if (domain != null) cookie.setDomain(domain);
if (maxAge != null) cookie.setMaxAge(Integer.parseInt(maxAge));
if (path != null) cookie.setPath(path);
if (isSecure != null) cookie.setSecure(Boolean.parseBoolean(isSecure));
if (version != null) cookie.setVersion(Integer.parseInt(version));
getResponse(context).addCookie(cookie);
return EmptySequence.getInstance();
}
示例9: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final String titleString = arguments[TITLE].head().getStringValue();
final String iconString = arguments[ICON].head().getStringValue();
String textString = "";
SequenceIterator iterator = arguments[TEXT].iterate();
Item item = iterator.next();
while (item != null) {
textString += item.getStringValue();
item = iterator.next();
}
JOptionPane.showMessageDialog(
(Frame)PluginWorkspaceProvider.getPluginWorkspace().getParentFrame(),
textString,
titleString,
getMessageType(iconString));
return EmptySequence.getInstance();
}
示例10: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String json = ((StringValue) arguments[0].head()).getStringValue();
if (StringUtils.isBlank(json)) {
return EmptySequence.getInstance();
}
XMLInputFactory factory = new JsonXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(json));
StAXSource source = new StAXSource(reader);
Configuration config = context.getConfiguration();
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.getParseOptions().getParserFeatures().remove("http://apache.org/xml/features/xinclude");
TinyBuilder builder = new TinyBuilder(pipe);
SerializerFactory sf = config.getSerializerFactory();
Receiver receiver = sf.getReceiver(builder, pipe, new Properties());
NamespaceReducer reducer = new NamespaceReducer(receiver);
ParseOptions options = pipe.getParseOptions();
options.setContinueAfterValidationErrors(true);
Sender.send(source, reducer, options);
return builder.getCurrentRoot();
} catch (Exception e) {
throw new XPathException("Error parsing JSON string", e);
}
}
示例11: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
logger.info("call");
try{
final URL url = getURL(context, arguments[URL].head().getStringValue());
logger.info("url: " + url.toExternalForm());
final String viewString = arguments[VIEW].head().getStringValue();
logger.info("view: " + viewString);
if (viewString.equals("author")) {
workspace.open(url, EditorPageConstants.PAGE_AUTHOR);
} else if (viewString.equals("text")) {
workspace.open(url, EditorPageConstants.PAGE_TEXT);
} else {
throw new XPathException("The given view ('" + viewString + "') is invalid. It must be either 'author' or 'text'.");
}
} catch (Exception e) {
logger.error(e, e);
}
return EmptySequence.getInstance();
}
示例12: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
File file = getFile(((StringValue) arguments[0].head()).getStringValue());
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
throw new FileException(String.format("Parent directory \"%s\" does not exist",
parentFile.getAbsolutePath()), FileException.ERROR_PATH_NOT_DIRECTORY);
}
if (file.isDirectory()) {
throw new FileException(String.format("Path \"%s\" points to a directory",
file.getAbsolutePath()), FileException.ERROR_PATH_IS_DIRECTORY);
}
FileUtils.writeByteArrayToFile(file, ((Base64BinaryValue) arguments[1].head()).getBinaryValue(), append);
return EmptySequence.getInstance();
} catch (FileException fe) {
throw fe;
} catch (Exception e) {
throw new FileException("Other file error", e, FileException.ERROR_IO);
}
}
示例13: makeCallExpression
import net.sf.saxon.value.EmptySequence; //导入方法依赖的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]);
}
try {
xdm.removeDocuments(pattern, props);
} catch (BagriException ex) {
throw new XPathException(ex);
}
return EmptySequence.getInstance();
}
};
}
示例14: makeCallExpression
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
DocumentAccessor result = null;
try {
String uri = arguments[0].head().getStringValue();
Properties props = null;
if (arguments.length > 1) {
props = sequence2Properties(arguments[1]);
}
result = xdm.getDocument(uri, props);
} catch (BagriException ex) {
throw new XPathException(ex);
}
if (result == null) {
return EmptySequence.getInstance();
}
return new StringValue((String) result.getContent());
}
};
}
示例15: call
import net.sf.saxon.value.EmptySequence; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String key = ((StringValue) arguments[0].head()).getStringValue();
Cache cache = Context.getInstance().getCacheManager().getCache(Definitions.CACHENAME_RESPONSECACHINGFILTER);
cache.remove(key);
return EmptySequence.getInstance();
} catch (Exception e) {
throw new XPathException("Could not remove element from cache", e);
}
}