001package org.apache.commons.digester3.examples.api.addressbook; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020/** 021 * See Main.java. 022 */ 023public class Address 024{ 025 026 private String type; 027 028 private String street; 029 030 private String city; 031 032 private String state; 033 034 private String zip; 035 036 private String country; 037 038 @Override 039 public String toString() 040 { 041 StringBuilder sb = new StringBuilder(); 042 sb.append( " address (type " + type + ")\n" ); 043 sb.append( " " + street + "\n" ); 044 sb.append( " " + city + " " + state + " " + zip + "\n" ); 045 sb.append( " " + country + "\n" ); 046 return sb.toString(); 047 } 048 049 public void print( java.io.PrintStream out, int indentAmount ) 050 { 051 StringBuilder indentStr = new StringBuilder( indentAmount ); 052 for ( ; indentAmount > 0; --indentAmount ) 053 { 054 indentStr.append( ' ' ); 055 } 056 057 out.print( indentStr ); 058 out.print( "address type: " ); 059 out.println( type ); 060 061 out.print( indentStr ); 062 out.println( " " + street ); 063 064 out.print( indentStr ); 065 out.println( " " + city + " " + state + " " + zip ); 066 067 out.print( indentStr ); 068 out.println( " " + country ); 069 } 070 071 /** 072 * Returns the value of street. 073 */ 074 public String getStreet() 075 { 076 return street; 077 } 078 079 /** 080 * Sets the value of street. 081 * 082 * @param street The value to assign to street. 083 */ 084 public void setStreet( String street ) 085 { 086 this.street = street; 087 } 088 089 /** 090 * Returns the value of city. 091 */ 092 public String getCity() 093 { 094 return city; 095 } 096 097 /** 098 * Sets the value of city. 099 * 100 * @param city The value to assign to city. 101 */ 102 public void setCity( String city ) 103 { 104 this.city = city; 105 } 106 107 /** 108 * Returns the value of state. 109 */ 110 public String getState() 111 { 112 return state; 113 } 114 115 /** 116 * Sets the value of state. 117 * 118 * @param state The value to assign to state. 119 */ 120 public void setState( String state ) 121 { 122 this.state = state; 123 } 124 125 /** 126 * Returns the value of zip. 127 */ 128 public String getZip() 129 { 130 return zip; 131 } 132 133 /** 134 * Sets the value of zip. 135 * 136 * @param zip The value to assign to zip. 137 */ 138 public void setZip( String zip ) 139 { 140 this.zip = zip; 141 } 142 143 /** 144 * Returns the value of country. 145 */ 146 public String getCountry() 147 { 148 return country; 149 } 150 151 /** 152 * Sets the value of country. 153 * 154 * @param country The value to assign to country. 155 */ 156 public void setCountry( String country ) 157 { 158 this.country = country; 159 } 160 161 /** 162 * Returns the value of type. 163 */ 164 public String getType() 165 { 166 return type; 167 } 168 169 /** 170 * Sets the value of type. 171 * 172 * @param type The value to assign to type. 173 */ 174 public void setType( String type ) 175 { 176 this.type = type; 177 } 178 179}