Package org.exist.xquery

Examples of org.exist.xquery.Variable


        // directly stream the backup contents to the HTTP response
        final ResponseModule myModule = (ResponseModule)context.getModule( ResponseModule.NAMESPACE_URI );

        // response object is read from global variable $response
        final Variable       respVar  = myModule.resolveVariable( ResponseModule.RESPONSE_VAR );

        if( respVar == null ) {
            throw( new XPathException( this, "No response object found in the current XQuery context." ) );
        }

        if( respVar.getValue().getItemType() != Type.JAVA_OBJECT ) {
            throw( new XPathException( this, "Variable $response is not bound to an Java object." ) );
        }
        final JavaObjectValue respValue = (JavaObjectValue)respVar.getValue().itemAt( 0 );

        if( !"org.exist.http.servlets.HttpResponseWrapper".equals( respValue.getObject().getClass().getName() ) ) {
            throw( new XPathException( this, signature.toString() + " can only be used within the EXistServlet or XQueryServlet" ) );
        }
        final ResponseWrapper response = (ResponseWrapper)respValue.getObject();
View Full Code Here


                                switch (_child.getNodeType()) {
                                case Node.ELEMENT_NODE:
                                    nodeName = ((ElementImpl) _child).getLocalName();
                                    if (nodeName.equals("param")) {
                                        el = ((ElementImpl) _child);
                                        Variable var = new VariableImpl(QName.parse(context, el.getAttribute("name")));

                                        String type = el.getAttribute("as");
                                        if ("xs:date".equals(type)) {
                                            var.setStaticType(Type.DATE);

                                            Sequence res = xquery.execute(el.getAttribute("select"), null, AccessContext.TEST);
                                            Assert.assertEquals(1, res.getItemCount());
                                            var.setValue(res);
                                        } else if ("xs:dateTime".equals(type)) {
                                            var.setStaticType(Type.DATE_TIME);

                                            Sequence res = xquery.execute(el.getAttribute("select"), null, AccessContext.TEST);
                                            Assert.assertEquals(1, res.getItemCount());
                                            var.setValue(res);
                                        } else if ("xs:string".equals(type)) {
                                            var.setStaticType(Type.STRING);

                                            Sequence res = xquery.execute(el.getAttribute("select"), null, AccessContext.TEST);
                                            Assert.assertEquals(1, res.getItemCount());
                                            var.setValue(res);
                                        } else {
                                            Assert.fail("unknown type '" + type + "'");
                                        }
                                        context.declareGlobalVariable(var);
                                    }
View Full Code Here


    @Override
    public Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException {
       
        final Variable var;
        if(isCalledAs("base-uri")) {
             var = context.resolveVariable(ResourceFunctionExecutorImpl.XQ_VAR_BASE_URI);
        } else {
            var = context.resolveVariable(ResourceFunctionExecutorImpl.XQ_VAR_URI);
        }

        if(var == null) {
            throw new XPathException(new EXQueryErrorCode(RestXqErrorCodes.RQDY0101), getLine(), getColumn());
        } else {
            return var.getValue();
        }
    }
View Full Code Here

    Map<QName, org.exist.xquery.Variable> params = getXSLParams();
   
    if (params.containsKey(param.getName()))
      compileError(XSLExceptions.ERR_XTSE0580);
   
     Variable variable = context.declareVariable(param.getName(), param);
     params.put(param.getName(), variable);
  }
View Full Code Here

      }
    }
 
  public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
    if (name != null && select == null) {
      Variable var = getXSLContext().resolveVariable(name);
     
      Sequence result = var.getValue();
     
      if (as != null)
        return result.convertTo(Type.getType(as));
     
      return result;
View Full Code Here

   
    final RequestModule myModule =
      (RequestModule) context.getModule(RequestModule.NAMESPACE_URI);

    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "No request object found in the current XQuery context.");}
    if (var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $request is not bound to an Java object.");}
    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if (value.getObject() instanceof RequestWrapper) {
      final ValueSequence result = new ValueSequence();
      for (final Enumeration<String> e =
        ((RequestWrapper) value.getObject()).getParameterNames();
        e.hasMoreElements();
View Full Code Here

    throws XPathException {
   
    final RequestModule myModule = (RequestModule)context.getModule(RequestModule.NAMESPACE_URI);
   
    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "No request object found in the current XQuery context.");}
    if (var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $request is not bound to an Java object.");}

    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if (value.getObject() instanceof RequestWrapper) {
      return new StringValue(((RequestWrapper) value.getObject()).getScheme());
    } else
      {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
  }
View Full Code Here

    throws XPathException {
   
    final RequestModule myModule = (RequestModule)context.getModule(RequestModule.NAMESPACE_URI);
   
    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "No request object found in the current XQuery context.");}
    if (var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $request is not bound to an Java object.");}

    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if (value.getObject() instanceof RequestWrapper) {
      return new StringValue(((RequestWrapper) value.getObject()).getMethod());
    } else
      {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
  }
View Full Code Here

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException
  {
    final RequestModule myModule = (RequestModule) context.getModule(RequestModule.NAMESPACE_URI);

    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if (var == null || var.getValue() == null || var.getValue().getItemType() != Type.JAVA_OBJECT) {
      return Sequence.EMPTY_SEQUENCE;
    }

    // get the cookieName to match
    final String cookieName = args[0].getStringValue();

    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if (value.getObject() instanceof RequestWrapper)
    {
      final Cookie[] cookies = ((RequestWrapper)value.getObject()).getCookies();
      if(cookies != null)
      {
View Full Code Here

    throws XPathException {
   
    final RequestModule myModule = (RequestModule)context.getModule(RequestModule.NAMESPACE_URI);
   
    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "No request object found in the current XQuery context.");}
    if (var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $request is not bound to an Java object.");}

    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
   
    if (value.getObject() instanceof RequestWrapper) {
      return new StringValue(((RequestWrapper) value.getObject()).getRemoteHost());
    } else
      {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
View Full Code Here

TOP

Related Classes of org.exist.xquery.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.