use of org.exist.xquery.value.StringValue in project exist by eXist-db.
the class FunEscapeURI method eval.
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
if (context.getProfiler().isEnabled()) {
context.getProfiler().start(this);
context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));
if (contextSequence != null) {
context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);
}
}
Sequence result;
if (args[0].isEmpty()) {
result = StringValue.EMPTY_STRING;
} else {
final String uri = args[0].getStringValue();
final boolean escapeReserved = args[1].effectiveBooleanValue();
return new StringValue(escape(uri, escapeReserved));
}
if (context.getProfiler().isEnabled()) {
context.getProfiler().end(this, "", result);
}
return result;
}
use of org.exist.xquery.value.StringValue in project exist by eXist-db.
the class TryCatchExpression method addJavaTrace.
// Local recursive function
private void addJavaTrace(final Throwable t, final Sequence result) throws XPathException {
final StackTraceElement[] elements = t.getStackTrace();
result.add(new StringValue("Caused by: " + t.toString()));
for (final StackTraceElement elt : elements) {
result.add(new StringValue("at " + elt.toString()));
}
final Throwable cause = t.getCause();
if (cause != null) {
addJavaTrace(cause, result);
}
}
use of org.exist.xquery.value.StringValue in project exist by eXist-db.
the class TryCatchExpression method addErrModule.
// err:module xs:string?
// The URI (or system ID) of the module containing the expression
// where the error occurred, or an empty sequence if the information
// is not available.
private void addErrModule(final Throwable t) throws XPathException {
final LocalVariable err_module = new LocalVariable(QN_MODULE);
err_module.setSequenceType(new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE));
final Sequence module;
if (t != null && t instanceof XPathException && ((XPathException) t).getSource() != null) {
module = new StringValue(((XPathException) t).getSource().pathOrShortIdentifier());
} else {
module = Sequence.EMPTY_SEQUENCE;
}
err_module.setValue(module);
context.declareVariableBinding(err_module);
}
use of org.exist.xquery.value.StringValue in project exist by eXist-db.
the class PermissionsFunctionModeConversionTest method modeToOctal_invalidMode.
@Test(expected = XPathException.class)
public void modeToOctal_invalidMode() throws XPathException {
final XQueryContext mckContext = EasyMock.createMock(XQueryContext.class);
final PermissionsFunction permissionsFunctions = new PermissionsFunction(mckContext, PermissionsFunction.FNS_MODE_TO_OCTAL);
Sequence[] args = { new StringValue("invalid") };
permissionsFunctions.eval(args, null);
}
use of org.exist.xquery.value.StringValue in project exist by eXist-db.
the class PermissionsFunctionModeConversionTest method octalToMode.
@Test
public void octalToMode() throws XPathException {
final XQueryContext mckContext = EasyMock.createMock(XQueryContext.class);
final PermissionsFunction permissionsFunctions = new PermissionsFunction(mckContext, PermissionsFunction.FNS_OCTAL_TO_MODE);
Sequence[] args = { new StringValue("0750") };
final Sequence result = permissionsFunctions.eval(args, null);
assertEquals(1, result.getItemCount());
assertEquals("rwxr-x---", result.itemAt(0).toString());
}
Aggregations