KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > matuschek > html > FormField


1 package net.matuschek.html;
2
3 /*********************************************
4     Copyright (c) 2001 by Daniel Matuschek
5 *********************************************/

6
7 import java.net.URLEncoder JavaDoc;
8
9 /**
10  * This class represents a form field. It is defined by a name
11  * and a value.
12  *
13  * @author Daniel Matuschek <daniel@matuschek.net>
14  * @version $Id: FormField.java,v 1.2 2001/04/17 15:29:27 matuschd Exp $
15  */

16 public class FormField {
17
18   public String JavaDoc getFieldname() {
19     return fieldname;
20   }
21   
22   public void setFieldname(String JavaDoc fieldname) {
23     this.fieldname = fieldname;
24   }
25   
26   public String JavaDoc getValue() {
27     return value;
28   }
29   
30   public void setValue(String JavaDoc value) {
31     this.value = value;
32   }
33
34   /**
35    * convert to a String represantation
36    * @return a fieldname=value string
37    */

38   public String JavaDoc toString() {
39     return fieldname+"="+value;
40   }
41
42
43   /**
44    * convert to an URL encoded string (like toString,
45    * but uses URLEncoder for encoding fieldname and value
46    * @return a fieldname=value string
47    */

48   @SuppressWarnings JavaDoc("deprecation")
49   public String JavaDoc toEncodedString() {
50     return
51       URLEncoder.encode(fieldname)+
52       "="+
53       URLEncoder.encode(value);
54   }
55   
56   private String JavaDoc fieldname;
57   
58   private String JavaDoc value;
59 }
60
Popular Tags