View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  
24  package com.gisgraphy.importer.dto;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  /**
30   * Represents a house number with an associated street in the Karlsruhe schema.
31   * 
32   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
33   */
34  public class AssociatedStreetHouseNumber {
35  
36  	private String relationID;
37  	private List<AssociatedStreetMember> associatedStreetMember = new ArrayList<AssociatedStreetMember>();
38  	List<AssociatedStreetMember> streets = null;
39  	List<AssociatedStreetMember> house =null;
40  	
41  	/**
42  	 * @return the associatedStreetMember
43  	 */
44  	public List<AssociatedStreetMember> getAssociatedStreetMember() {
45  		return associatedStreetMember;
46  	}
47  	/**
48  	 * @param associatedStreetMember the associatedStreetMember to set
49  	 */
50  	public void setAssociatedStreetMember(List<AssociatedStreetMember> associatedStreetMember) {
51  		this.associatedStreetMember = associatedStreetMember;
52  	}
53  	/**
54  	 * @return the relationID
55  	 */
56  	public String getRelationID() {
57  		return relationID;
58  	}
59  	/**
60  	 * @param relationID the relationID to set
61  	 */
62  	public void setRelationID(String relationID) {
63  		this.relationID = relationID;
64  	}
65  	
66  	public void addMember(AssociatedStreetMember member){
67  		associatedStreetMember.add(member);
68  	}
69  	
70  	public List<AssociatedStreetMember> getStreetMembers(){
71  		List<AssociatedStreetMember> streets = new ArrayList<AssociatedStreetMember>();
72  		for (AssociatedStreetMember member:associatedStreetMember){
73  			if (member.isStreet()){
74  				streets.add(member);
75  			}
76  		}
77  		return streets;
78  	}
79  	
80  	
81  	
82  	public List<AssociatedStreetMember> getHouseMembers(){
83  		List<AssociatedStreetMember> houses = new ArrayList<AssociatedStreetMember>();
84  		for (AssociatedStreetMember member:associatedStreetMember){
85  			if (member.isHouse()){
86  				houses.add(member);
87  			}
88  		}
89  		return houses;
90  	}
91  	@Override
92  	public String toString() {
93  		final int maxLen = 10;
94  		StringBuilder builder = new StringBuilder();
95  		builder.append("AssociatedStreetHouseNumber [");
96  		if (relationID != null)
97  			builder.append("relationID=").append(relationID).append(", ");
98  		if (associatedStreetMember != null)
99  			builder.append("associatedStreetMember=")
100 					.append(associatedStreetMember.subList(0,
101 							Math.min(associatedStreetMember.size(), maxLen)))
102 					.append(", ");
103 		if (streets != null)
104 			builder.append("streets=")
105 					.append(streets.subList(0, Math.min(streets.size(), maxLen)))
106 					.append(", ");
107 		if (house != null)
108 			builder.append("house=").append(
109 					house.subList(0, Math.min(house.size(), maxLen)));
110 		builder.append("]");
111 		return builder.toString();
112 	}
113 }