1 package org.apache.commons.digester3.examples.xmlrules.addressbook;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 import java.io.PrintStream;
21
22 /**
23 * See Main.java.
24 */
25 public class Address
26 {
27
28 private String type;
29
30 private String street;
31
32 private String city;
33
34 private String state;
35
36 private String zip;
37
38 private String country;
39
40 @Override
41 public String toString()
42 {
43 StringBuilder sb = new StringBuilder();
44 sb.append( " address (type " + type + ")\n" );
45 sb.append( " " + street + "\n" );
46 sb.append( " " + city + " " + state + " " + zip + "\n" );
47 sb.append( " " + country + "\n" );
48 return sb.toString();
49 }
50
51 public void print( PrintStream out, int indentAmount )
52 {
53 StringBuilder indentStr = new StringBuilder( indentAmount );
54 for ( ; indentAmount > 0; --indentAmount )
55 {
56 indentStr.append( ' ' );
57 }
58
59 out.print( indentStr );
60 out.print( "address type: " );
61 out.println( type );
62
63 out.print( indentStr );
64 out.println( " " + street );
65
66 out.print( indentStr );
67 out.println( " " + city + " " + state + " " + zip );
68
69 out.print( indentStr );
70 out.println( " " + country );
71 }
72
73 /**
74 * Returns the value of street.
75 */
76 public String getStreet()
77 {
78 return street;
79 }
80
81 /**
82 * Sets the value of street.
83 *
84 * @param street The value to assign to street.
85 */
86 public void setStreet( String street )
87 {
88 this.street = street;
89 }
90
91 /**
92 * Returns the value of city.
93 */
94 public String getCity()
95 {
96 return city;
97 }
98
99 /**
100 * Sets the value of city.
101 *
102 * @param city The value to assign to city.
103 */
104 public void setCity( String city )
105 {
106 this.city = city;
107 }
108
109 /**
110 * Returns the value of state.
111 */
112 public String getState()
113 {
114 return state;
115 }
116
117 /**
118 * Sets the value of state.
119 *
120 * @param state The value to assign to state.
121 */
122 public void setState( String state )
123 {
124 this.state = state;
125 }
126
127 /**
128 * Returns the value of zip.
129 */
130 public String getZip()
131 {
132 return zip;
133 }
134
135 /**
136 * Sets the value of zip.
137 *
138 * @param zip The value to assign to zip.
139 */
140 public void setZip( String zip )
141 {
142 this.zip = zip;
143 }
144
145 /**
146 * Returns the value of country.
147 */
148 public String getCountry()
149 {
150 return country;
151 }
152
153 /**
154 * Sets the value of country.
155 *
156 * @param country The value to assign to country.
157 */
158 public void setCountry( String country )
159 {
160 this.country = country;
161 }
162
163 /**
164 * Returns the value of type.
165 */
166 public String getType()
167 {
168 return type;
169 }
170
171 /**
172 * Sets the value of type.
173 *
174 * @param type The value to assign to type.
175 */
176 public void setType( String type )
177 {
178 this.type = type;
179 }
180
181 }