Search in sources :

Example 71 with StringValue

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;
}
Also used : Sequence(org.exist.xquery.value.Sequence) StringValue(org.exist.xquery.value.StringValue)

Example 72 with StringValue

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);
    }
}
Also used : StringValue(org.exist.xquery.value.StringValue)

Example 73 with StringValue

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);
}
Also used : StringValue(org.exist.xquery.value.StringValue)

Example 74 with StringValue

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);
}
Also used : XQueryContext(org.exist.xquery.XQueryContext) Sequence(org.exist.xquery.value.Sequence) StringValue(org.exist.xquery.value.StringValue) Test(org.junit.Test)

Example 75 with StringValue

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());
}
Also used : XQueryContext(org.exist.xquery.XQueryContext) Sequence(org.exist.xquery.value.Sequence) StringValue(org.exist.xquery.value.StringValue) Test(org.junit.Test)

Aggregations

StringValue (org.exist.xquery.value.StringValue)96 Sequence (org.exist.xquery.value.Sequence)49 XPathException (org.exist.xquery.XPathException)40 ValueSequence (org.exist.xquery.value.ValueSequence)27 IOException (java.io.IOException)11 PermissionDeniedException (org.exist.security.PermissionDeniedException)10 Item (org.exist.xquery.value.Item)10 XQueryContext (org.exist.xquery.XQueryContext)8 Txn (org.exist.storage.txn.Txn)7 AnyURIValue (org.exist.xquery.value.AnyURIValue)7 QName (org.exist.dom.QName)6 LockException (org.exist.util.LockException)6 NodeValue (org.exist.xquery.value.NodeValue)6 Path (java.nio.file.Path)5 EXistException (org.exist.EXistException)5 TriggerException (org.exist.collections.triggers.TriggerException)5 DocumentImpl (org.exist.dom.persistent.DocumentImpl)5 StoredNode (org.exist.dom.persistent.StoredNode)5 NotificationService (org.exist.storage.NotificationService)5 MimeType (org.exist.util.MimeType)5