Package org.exist.xquery

Examples of org.exist.xquery.Variable


        }

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

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

        if( ( var == null ) || ( var.getValue() == null ) ) {
            throw( new XPathException( this, "Response not set" ) );
        }

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

        //get parameter
        final int             code     = ( (IntegerValue)getArgument( 0 ).eval( contextSequence, contextItem ).convertTo( Type.INTEGER ) ).getInt();

        //set response status code
View Full Code Here


    if( getSignature().getArgumentCount() == 3 ) {
      failOnError = args[2].effectiveBooleanValue();
    }
   
    // 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) {
      if( failOnError ) {
        throw new XPathException(this, "Variable $request is not bound to an Java object.");
      } else {
        return args[1];
      }
    }
   
    // get parameters
    final String param = args[0].getStringValue();
   
    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if (value.getObject() instanceof RequestWrapper) {
      final String[] values = ((RequestWrapper)value.getObject()).getParameterValues(param);
      if (values == null || values.length == 0) {
        return args[1];
      }
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 IntegerValue(((RequestWrapper) value.getObject()).getServerPort());
    } else
      {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
  }
View Full Code Here

    BooleanValue exists = BooleanValue.TRUE;
   
    final SessionModule myModule = (SessionModule)context.getModule( SessionModule.NAMESPACE_URI );
   
    // session object is read from global variable $session
    final Variable var = myModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( var == null || var.getValue() == null ) {
      exists = BooleanValue.FALSE;
    }
     
    return( exists );
  }
View Full Code Here

  {
   
    final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
   
    // session object is read from global variable $session
    final Variable var = myModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( var == null || var.getValue() == null ) {
      // throw( new XPathException( this, "Session not set" ) );
      return( Sequence.EMPTY_SEQUENCE );
    }
   
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( this, "Variable $session is not bound to a Java object." ) );
    }

    final JavaObjectValue session = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    // get attribute name parameter
    final String attribName = getArgument( 0 ).eval( contextSequence, contextItem ).getStringValue();
   
    if( session.getObject() instanceof SessionWrapper ) {
View Full Code Here

    }       
   
    final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
   
    // session object is read from global variable $session
    final Variable var = myModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( var == null || var.getValue() == null ) {
      // throw( new XPathException( this, "Session not set" ) );
      return( XPathUtil.javaObjectToXPath( Integer.valueOf(-1), context ) );
    }
   
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( this, "Variable $session is not bound to a Java object." ) );
    }

    final JavaObjectValue session = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    if( session.getObject() instanceof SessionWrapper ) {
      try {
        final long creationTime = ( (SessionWrapper)session.getObject() ).getCreationTime();
        return new DateTimeValue(new Date(creationTime));
View Full Code Here

  public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException
  {
    final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
   
    /* session object is read from global variable $session */
    final Variable var = myModule.resolveVariable(SessionModule.SESSION_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "Session not set");}
    if(var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $session is not bound to an Java object.");}
    final JavaObjectValue session = (JavaObjectValue) var.getValue().itemAt(0);
   
    if(session.getObject() instanceof SessionWrapper)
    {
      final String id = ((SessionWrapper)session.getObject()).getId();
      if (id == null)
View Full Code Here

    }       
   
    final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
   
    // session object is read from global variable $session
    final Variable var = myModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( var == null || var.getValue() == null ) {
      // throw( new XPathException( this, "Session not set" ) );
      return( XPathUtil.javaObjectToXPath( Integer.valueOf(-1), context ) );
    }
   
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( this, "Variable $session is not bound to a Java object." ) );
    }

    final JavaObjectValue session = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    if( session.getObject() instanceof SessionWrapper ) {
      try {
        final long lastAccessedTime = ( (SessionWrapper)session.getObject() ).getLastAccessedTime();
        return new DateTimeValue(new Date(lastAccessedTime));
View Full Code Here

  {
   
    final RequestModule myModule = (RequestModule)context.getModule(RequestModule.NAMESPACE_URI);
   
    // request object is read from global variable $session
    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 RequestWrapper request = (RequestWrapper)value.getObject();
   
View Full Code Here

    throws XPathException {
   
    final ResponseModule myModule = (ResponseModule)context.getModule(ResponseModule.NAMESPACE_URI);
     
    // request object is read from global variable $response
    final Variable var = myModule.resolveVariable(ResponseModule.RESPONSE_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 $response is not bound to an Java object.");
    }
   
    // get parameters
    final String url = args[0].getStringValue();
   
    final JavaObjectValue value = (JavaObjectValue)
      var.getValue().itemAt(0);
    if(value.getObject() instanceof ResponseWrapper) {
      return new AnyURIValue(((ResponseWrapper)value.getObject()).encodeURL(url));
    } else {
      throw new XPathException(this, "Variable $response is not bound to a Response 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.