Package HTTP

Source Code of HTTP.ExecContext

/*
Copyright (c) 2003-2009 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package HTTP;

import java.text.MessageFormat;
import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Framework.CloneHelper;
import Framework.DynamicArray;
import Framework.GenericException;
import Framework.TextData;

/**
    *  ExecContext
    * <p>
    * <p>
    */
public class ExecContext

{
    public ExecContext() {
        this.init();
    }

    public ExecContext(HttpServletRequest prequest, HttpServletResponse presponse) {
        this.request = prequest;
        this.response = presponse;
    }

    public ExecContext(HTMLScanner pWebEntScanner, HttpServletRequest prequest, HttpServletResponse presponse) {
        this.WebEntScanner = pWebEntScanner;
        this.request = prequest;
        this.response = presponse;
    }

    // ---------------------------------------------------
    // Implementation of Clonable, DeepClonable interfaces
    // ---------------------------------------------------
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public Object clone(boolean pDeep) {
        if (pDeep)
            return CloneHelper.deepClone(this);
        else {
            try {
                return super.clone();
            }
            catch (CloneNotSupportedException e) {
                HTTPAccess.getWebEntLogger().error("Clone not supported for object of type " + this.getClass());
                return this;
            }
        }
    }
    // ----------
    // Attributes
    // ----------
    private HTTPAccess access;
    private TextData pageBuffer;
    //TODO private DynamicArray WebEntHandlerList;  // Array of WebEntHandlerInfo
    private DynamicArray<ResultSet> WebEntResultSets;  // Array of ResultSet
    private HTMLScanner WebEntScanner;
    private HttpServletRequest request;
    private HttpServletResponse response;
    private boolean WebEntDynamicData;

    // --------------------------------
    // Accessor methods for attributes.
    // --------------------------------
    public void setAccess(HTTPAccess pValue) {
        this.access = pValue;
    }

    public HTTPAccess getAccess() {
        return this.access;
    }

    public void setPageBuffer(TextData pValue) {
        this.pageBuffer = pValue;
    }

    public TextData getPageBuffer() {
        return this.pageBuffer;
    }

    public void setWebEntScanner(HTMLScanner pValue) {
        this.WebEntScanner = pValue;
    }

    public HTMLScanner getWebEntScanner() {
        return this.WebEntScanner;
    }

    public void setRequest(HttpServletRequest pValue) {
        this.request = pValue;
    }

    public HttpServletRequest getRequest() {
        return this.request;
    }

    public void setResponse(HttpServletResponse pValue) {
        this.response = pValue;
    }

    public HttpServletResponse getResponse() {
        return this.response;
    }

    public void setWebEntDynamicData(boolean pValue) {
        this.WebEntDynamicData = pValue;
    }

    public boolean getWebEntDynamicData() {
        return this.WebEntDynamicData;
    }

    /**
        *  getResultSet
        * <p>
        * <p>
        * @param ResultSetName Type: TextData
        * @return ResultSet
        */
    public ResultSet getResultSet(TextData ResultSetName)
    {
        //  return an existing result set, or create a new one,
        //  store it in the ResultSet list, and return its reference.
        //
        ResultSet result = this.WebEntFindResultSet(ResultSetName);

        if (result == null) {
            result = new ResultSet(new TextData( ResultSetName.getValue() ));
            this.WebEntAddResultSet(result);
        }
        return result;
    }

    /**
        *  init
        * <p>
        * <p>
        */
    private void init()
    {
        // super.init();
        this.WebEntResultSets = new DynamicArray<ResultSet>(ResultSet.class );
        this.pageBuffer = new TextData();
        //TODO this.WebEntHandlerList = new DynamicArray(WebEntHandlerInfo.class );
        this.WebEntDynamicData = false;
    }

    /**
        *  WebEntAddResultSet
        * <p>
        * <p>
        * @param rset Type: ResultSet
        */
    public void WebEntAddResultSet(ResultSet rset)
    {
        //  first see if one exists with the name

        if (this.WebEntFindResultSet(rset.getName()) != null) {
            Object[] qq_Args = { rset.getName() };
            GenericException e = new GenericException(MessageFormat.format( "A result set named {0} already exists.", qq_Args ) );
            e.setDetectingMethod("ExecContext::AddResultSet");
            throw e;
        }
        this.WebEntResultSets.add(rset);
    }

    /**
        *  WebEntClearHandlerList
        * <p>
        * <p>
        */
    public void WebEntClearHandlerList()
    {
/*        DynamicArray qq_localVector = this.WebEntHandlerList;
        for (Iterator qq_it = qq_localVector.iterator(); qq_it.hasNext();) {
            WebEntHandlerInfo row = (WebEntHandlerInfo)qq_it.next();
            row.decRef();
        }
*/    }

    /**
        *  WebEntFindHandler
        * <p>
        * <p>
        * @param HandlerName Type: TextData
        * @return WebEntHandlerInfo
        */
/*    TODO public WebEntHandlerInfo WebEntFindHandler(TextData HandlerName)
                throws Exception
    {
        WebEntHandlerInfo result = null;
        DynamicArray qq_localVector = this.WebEntHandlerList;
        for (Iterator qq_it = qq_localVector.iterator(); qq_it.hasNext();) {
            WebEntHandlerInfo row = (WebEntHandlerInfo)qq_it.next();

            if ((boolean)(row.getHandlerName().compare(HandlerName, true) == 0)) {
                result = row;
            }
        }

        if (result == null) {
            result = this.WebEntScanner.WebEntFindHandler(HandlerName);
            this.WebEntHandlerList.appendRow(result);
        }
        return result;
    }
*/
    /**
        *  WebEntFindResultSet
        * <p>
        * <p>
        * @param ResultSetname Type: TextData
        * @return ResultSet
        */
    public ResultSet WebEntFindResultSet(TextData ResultSetname)
    {
        //  iterate through existing result sets
        //  if one matches an existing, return it,
        //  else return nil;
        //
        ResultSet result = null;
        DynamicArray<ResultSet> qq_localVector = this.WebEntResultSets;
        for (Iterator<ResultSet> qq_it = qq_localVector.iterator(); qq_it.hasNext();) {
            ResultSet row = qq_it.next();

            if ((boolean)(ResultSetname.compare(row.getName(), true) == 0)) {
                result = row;
                break;
            }
        }
        return result;
    }

    /**
        *  WebEntRemoveResultSet
        * <p>
        * <p>
        * @param Name Type: TextData
        */
    public void WebEntRemoveResultSet(TextData Name)
    {
        ResultSet result = this.WebEntFindResultSet(Name);

        if (result != null) {
            this.WebEntResultSets.deleteRow(result);
        }
    }

// end class ExecContext
TOP

Related Classes of HTTP.ExecContext

TOP
Copyright © 2018 www.massapi.com. 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.