01: package net.matuschek.html;
02:
03: /*********************************************
04: Copyright (c) 2001 by Daniel Matuschek
05: *********************************************/
06:
07: import java.net.URLEncoder;
08:
09: /**
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 getFieldname() {
19: return fieldname;
20: }
21:
22: public void setFieldname(String fieldname) {
23: this .fieldname = fieldname;
24: }
25:
26: public String getValue() {
27: return value;
28: }
29:
30: public void setValue(String value) {
31: this .value = value;
32: }
33:
34: /**
35: * convert to a String represantation
36: * @return a fieldname=value string
37: */
38: public String toString() {
39: return fieldname + "=" + value;
40: }
41:
42: /**
43: * convert to an URL encoded string (like toString,
44: * but uses URLEncoder for encoding fieldname and value
45: * @return a fieldname=value string
46: */
47: @SuppressWarnings("deprecation")
48: public String toEncodedString() {
49: return URLEncoder.encode(fieldname) + "="
50: + URLEncoder.encode(value);
51: }
52:
53: private String fieldname;
54:
55: private String value;
56: }
|