001package org.apache.commons.digester3.examples.xmlrules.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 020import java.io.PrintStream; 021 022/** 023 * See Main.java. 024 */ 025public class Address 026{ 027 028 private String type; 029 030 private String street; 031 032 private String city; 033 034 private String state; 035 036 private String zip; 037 038 private String country; 039 040 @Override 041 public String toString() 042 { 043 StringBuilder sb = new StringBuilder(); 044 sb.append( " address (type " + type + ")\n" ); 045 sb.append( " " + street + "\n" ); 046 sb.append( " " + city + " " + state + " " + zip + "\n" ); 047 sb.append( " " + country + "\n" ); 048 return sb.toString(); 049 } 050 051 public void print( PrintStream out, int indentAmount ) 052 { 053 StringBuilder indentStr = new StringBuilder( indentAmount ); 054 for ( ; indentAmount > 0; --indentAmount ) 055 { 056 indentStr.append( ' ' ); 057 } 058 059 out.print( indentStr ); 060 out.print( "address type: " ); 061 out.println( type ); 062 063 out.print( indentStr ); 064 out.println( " " + street ); 065 066 out.print( indentStr ); 067 out.println( " " + city + " " + state + " " + zip ); 068 069 out.print( indentStr ); 070 out.println( " " + country ); 071 } 072 073 /** 074 * Returns the value of street. 075 */ 076 public String getStreet() 077 { 078 return street; 079 } 080 081 /** 082 * Sets the value of street. 083 * 084 * @param street The value to assign to street. 085 */ 086 public void setStreet( String street ) 087 { 088 this.street = street; 089 } 090 091 /** 092 * Returns the value of city. 093 */ 094 public String getCity() 095 { 096 return city; 097 } 098 099 /** 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}