001: package com.meterware.httpunit;
002:
003: /********************************************************************************************************************
004: * $Id: ParameterHolder.java,v 1.9 2004/09/22 03:15:22 russgold Exp $
005: *
006: * Copyright (c) 2002, Russell Gold
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
009: * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
010: * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
011: * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
012: *
013: * The above copyright notice and this permission notice shall be included in all copies or substantial portions
014: * of the Software.
015: *
016: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
017: * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
019: * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
020: * DEALINGS IN THE SOFTWARE.
021: *
022: *******************************************************************************************************************/
023: import java.io.IOException;
024: import java.io.File;
025:
026: /**
027: * This abstract class is extended by classes which hold parameters for web requests. Note that it is an abstract class
028: * rather than an interface in order to keep its methods package-local.
029: *
030: * @author <a href="mailto:russgold@acm.org">Russell Gold</a>
031: **/
032: abstract class ParameterHolder {
033:
034: /**
035: * Specifies the position at which an image button (if any) was clicked. This default implementation does nothing.
036: **/
037: void selectImageButtonPosition(SubmitButton imageButton, int x,
038: int y) {
039: }
040:
041: /**
042: * Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\
043: * These parameters always go on the URL, no matter what encoding method is used.
044: **/
045: abstract void recordPredefinedParameters(
046: ParameterProcessor processor) throws IOException;
047:
048: /**
049: * Iterates through the parameters in this holder, recording them in the supplied parameter processor.
050: **/
051: abstract void recordParameters(ParameterProcessor processor)
052: throws IOException;
053:
054: /**
055: * Returns an array of all parameter names in this collection.
056: **/
057: abstract String[] getParameterNames();
058:
059: /**
060: * Returns the multiple default values of the named parameter.
061: **/
062: abstract String[] getParameterValues(String name);
063:
064: /**
065: * Removes a parameter name from this collection.
066: **/
067: abstract void removeParameter(String name);
068:
069: /**
070: * Sets the value of a parameter in a web request.
071: **/
072: abstract void setParameter(String name, String value);
073:
074: /**
075: * Sets the multiple values of a parameter in a web request.
076: **/
077: abstract void setParameter(String name, String[] values);
078:
079: /**
080: * Sets the multiple values of a file upload parameter in a web request.
081: **/
082: abstract void setParameter(String name, UploadFileSpec[] files);
083:
084: /**
085: * Returns true if the specified name is that of a file parameter. The default implementation returns false.
086: */
087: boolean isFileParameter(String name) {
088: return false;
089: }
090:
091: /**
092: * Returns the character set encoding for the request.
093: **/
094: String getCharacterSet() {
095: return HttpUnitUtils.DEFAULT_CHARACTER_SET;
096: }
097:
098: abstract boolean isSubmitAsMime();
099:
100: abstract void setSubmitAsMime(boolean mimeEncoded);
101: }
|