Package org.exist.xquery.value

Examples of org.exist.xquery.value.JavaObjectValue


        }

        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 parameters
        final String          name     = getArgument( 0 ).eval( contextSequence, contextItem ).getStringValue();
        final long            value    = new DateTimeValue( getArgument( 1 ).eval( contextSequence, contextItem ).getStringValue() ).getDate().getTime();

        //set response header
        if( response.getObject() instanceof ResponseWrapper ) {
            ( (ResponseWrapper)response.getObject() ).setDateHeader( name, value );
        } else {
            throw( new XPathException( this, "Type error: variable $response is not bound to a response object" ) );
        }

        return( Sequence.EMPTY_SEQUENCE );
View Full Code Here


        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();
        response.setHeader("Content-Type", contentType);

        if(filename != null) {
            response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
        }
View Full Code Here

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

        final JavaObjectValue value = (JavaObjectValue)var.getValue().itemAt( 0 );

        if( value.getObject() instanceof ResponseWrapper ) {

            try {
                ( (ResponseWrapper)value.getObject() ).sendRedirect( redirectURI );
            }
            catch( final IOException e ) {
                throw( new XPathException( this, "An IO exception occurred during redirect: " + e.getMessage(), e ) );
            }
        } else {
View Full Code Here

        }

        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 parameters
        final String          name     = getArgument( 0 ).eval( contextSequence, contextItem ).getStringValue();
        final String          value    = getArgument( 1 ).eval( contextSequence, contextItem ).getStringValue();

        //set response header
        if( response.getObject() instanceof ResponseWrapper ) {
            ( (ResponseWrapper)response.getObject() ).setHeader( name, value );
        } else {
            throw( new XPathException( this, "Type error: variable $response is not bound to a response object" ) );
        }

        return( Sequence.EMPTY_SEQUENCE );
View Full Code Here

        }

        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
        if( response.getObject() instanceof ResponseWrapper ) {
            ( (ResponseWrapper)response.getObject() ).setStatusCode( code );
        } else {
            throw( new XPathException( this, "Type error: variable $response is not bound to a response object" ) );
        }

        return( Sequence.EMPTY_SEQUENCE );
View Full Code Here

    }
   
    // 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];
      }
      if (values.length == 1) {
        return XPathUtil.javaObjectToXPath(values[0], null, false);
View Full Code Here

    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

   
    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 ) {
      try {
        final Object o = ( (SessionWrapper)session.getObject() ).getAttribute( attribName );
        if( o == null ) {
          return( Sequence.EMPTY_SEQUENCE );
        }
        return( XPathUtil.javaObjectToXPath( o, context ) );
      }
View Full Code Here

   
    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));
      }
      catch( final IllegalStateException ise ) {
        return new DateTimeValue(new Date(0));
      }
View Full Code Here

    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)
        {return Sequence.EMPTY_SEQUENCE;}
      return(new StringValue(id));
    }
    else
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.JavaObjectValue

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.