1. /*
  2. * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpParams.java,v 1.6 2004/05/13 04:01:22 mbecke Exp $
  3. * $Revision: 1.6 $
  4. * $Date: 2004/05/13 04:01:22 $
  5. *
  6. * ====================================================================
  7. *
  8. * Copyright 1999-2004 The Apache Software Foundation
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * ====================================================================
  22. *
  23. * This software consists of voluntary contributions made by many
  24. * individuals on behalf of the Apache Software Foundation. For more
  25. * information on the Apache Software Foundation, please see
  26. * <http://www.apache.org/>.
  27. *
  28. */
  29. package org.apache.commons.httpclient.params;
  30. /**
  31. * This interface represents a collection of HTTP protocol parameters. Protocol parameters
  32. * may be linked together to form a hierarchy. If a particular parameter value has not been
  33. * explicitly defined in the collection itself, its value will be drawn from the parent
  34. * collection of parameters.
  35. *
  36. * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
  37. *
  38. * @version $Revision: 1.6 $
  39. *
  40. * @since 3.0
  41. */
  42. public interface HttpParams {
  43. /**
  44. * Returns the parent collection that this collection will defer to
  45. * for a default value if a particular parameter is not explicitly
  46. * set in the collection itself
  47. *
  48. * @return the parent collection to defer to, if a particular parameter
  49. * is not explictly set in the collection itself.
  50. *
  51. * @see #setDefaults(HttpParams)
  52. */
  53. public HttpParams getDefaults();
  54. /**
  55. * Assigns the parent collection that this collection will defer to
  56. * for a default value if a particular parameter is not explicitly
  57. * set in the collection itself
  58. *
  59. * @param params the parent collection to defer to, if a particular
  60. * parameter is not explictly set in the collection itself.
  61. *
  62. * @see #getDefaults()
  63. */
  64. public void setDefaults(final HttpParams params);
  65. /**
  66. * Returns a parameter value with the given name. If the parameter is
  67. * not explicitly defined in this collection, its value will be drawn
  68. * from a higer level collection at which this parameter is defined.
  69. * If the parameter is not explicitly set anywhere up the hierarchy,
  70. * <tt>null</tt> value is returned.
  71. *
  72. * @param name the parent name.
  73. *
  74. * @return an object that represents the value of the parameter.
  75. *
  76. * @see #setParameter(String, Object)
  77. */
  78. public Object getParameter(final String name);
  79. /**
  80. * Assigns the value to the parameter with the given name
  81. *
  82. * @param name parameter name
  83. * @param value parameter value
  84. */
  85. public void setParameter(final String name, final Object value);
  86. /**
  87. * Returns a {@link Long} parameter value with the given name.
  88. * If the parameter is not explicitly defined in this collection, its
  89. * value will be drawn from a higer level collection at which this parameter
  90. * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  91. * the default value is returned.
  92. *
  93. * @param name the parent name.
  94. * @param defaultValue the default value.
  95. *
  96. * @return a {@link Long} that represents the value of the parameter.
  97. *
  98. * @see #setLongParameter(String, long)
  99. */
  100. public long getLongParameter(final String name, long defaultValue);
  101. /**
  102. * Assigns a {@link Long} to the parameter with the given name
  103. *
  104. * @param name parameter name
  105. * @param value parameter value
  106. */
  107. public void setLongParameter(final String name, long value);
  108. /**
  109. * Returns an {@link Integer} parameter value with the given name.
  110. * If the parameter is not explicitly defined in this collection, its
  111. * value will be drawn from a higer level collection at which this parameter
  112. * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  113. * the default value is returned.
  114. *
  115. * @param name the parent name.
  116. * @param defaultValue the default value.
  117. *
  118. * @return a {@link Integer} that represents the value of the parameter.
  119. *
  120. * @see #setIntParameter(String, int)
  121. */
  122. public int getIntParameter(final String name, int defaultValue);
  123. /**
  124. * Assigns an {@link Integer} to the parameter with the given name
  125. *
  126. * @param name parameter name
  127. * @param value parameter value
  128. */
  129. public void setIntParameter(final String name, int value);
  130. /**
  131. * Returns a {@link Double} parameter value with the given name.
  132. * If the parameter is not explicitly defined in this collection, its
  133. * value will be drawn from a higer level collection at which this parameter
  134. * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  135. * the default value is returned.
  136. *
  137. * @param name the parent name.
  138. * @param defaultValue the default value.
  139. *
  140. * @return a {@link Double} that represents the value of the parameter.
  141. *
  142. * @see #setDoubleParameter(String, double)
  143. */
  144. public double getDoubleParameter(final String name, double defaultValue);
  145. /**
  146. * Assigns a {@link Double} to the parameter with the given name
  147. *
  148. * @param name parameter name
  149. * @param value parameter value
  150. */
  151. public void setDoubleParameter(final String name, double value);
  152. /**
  153. * Returns a {@link Boolean} parameter value with the given name.
  154. * If the parameter is not explicitly defined in this collection, its
  155. * value will be drawn from a higer level collection at which this parameter
  156. * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  157. * the default value is returned.
  158. *
  159. * @param name the parent name.
  160. * @param defaultValue the default value.
  161. *
  162. * @return a {@link Boolean} that represents the value of the parameter.
  163. *
  164. * @see #setBooleanParameter(String, boolean)
  165. */
  166. public boolean getBooleanParameter(final String name, boolean defaultValue);
  167. /**
  168. * Assigns a {@link Boolean} to the parameter with the given name
  169. *
  170. * @param name parameter name
  171. * @param value parameter value
  172. */
  173. public void setBooleanParameter(final String name, boolean value);
  174. /**
  175. * Returns <tt>true</tt> if the parameter is set at any level, <tt>false</tt> otherwise.
  176. *
  177. * @param name parameter name
  178. *
  179. * @return <tt>true</tt> if the parameter is set at any level, <tt>false</tt>
  180. * otherwise.
  181. */
  182. public boolean isParameterSet(final String name);
  183. /**
  184. * Returns <tt>true</tt> if the parameter is set locally, <tt>false</tt> otherwise.
  185. *
  186. * @param name parameter name
  187. *
  188. * @return <tt>true</tt> if the parameter is set locally, <tt>false</tt>
  189. * otherwise.
  190. */
  191. public boolean isParameterSetLocally(final String name);
  192. /**
  193. * Returns <tt>true</tt> if the parameter is set and is <tt>true</tt>, <tt>false</tt>
  194. * otherwise.
  195. *
  196. * @param name parameter name
  197. *
  198. * @return <tt>true</tt> if the parameter is set and is <tt>true</tt>, <tt>false</tt>
  199. * otherwise.
  200. */
  201. public boolean isParameterTrue(final String name);
  202. /**
  203. * Returns <tt>true</tt> if the parameter is either not set or is <tt>false</tt>,
  204. * <tt>false</tt> otherwise.
  205. *
  206. * @param name parameter name
  207. *
  208. * @return <tt>true</tt> if the parameter is either not set or is <tt>false</tt>,
  209. * <tt>false</tt> otherwise.
  210. */
  211. public boolean isParameterFalse(final String name);
  212. }