Updated to worldwind release 20070817
[worldwind-tracker.git] / gov / nasa / worldwind / layers / placename / PlaceNameServiceSet.java
blobe977fce3c0b486d6dfdb2fde464f55eef9ce18a9
1 /*
2 Copyright (C) 2001, 2006 United States Government as represented by
3 the Administrator of the National Aeronautics and Space Administration.
4 All Rights Reserved.
5 */
6 package gov.nasa.worldwind.layers.placename;
8 import gov.nasa.worldwind.util.Logging;
10 import java.util.*;
12 /**
13 * @author Paul Collins
14 * @version $Id: PlaceNameServiceSet.java 2471 2007-07-31 21:50:57Z tgaskins $
16 public class PlaceNameServiceSet
18 private final List<PlaceNameService> serviceList = new LinkedList<PlaceNameService>();
20 public PlaceNameServiceSet()
24 /**
25 * @param placeNameService
26 * @param replace
27 * @return
28 * @throws IllegalArgumentException if <code>placeNameService</code> is null
30 public boolean addService(PlaceNameService placeNameService, boolean replace)
32 if (placeNameService == null)
34 String message = Logging.getMessage("nullValue.PlaceNameServiceIsNull");
35 Logging.logger().severe(message);
36 throw new IllegalArgumentException(message);
39 for (int i = 0; i < this.serviceList.size(); i++)
41 final PlaceNameService other = this.serviceList.get(i);
42 if (placeNameService.getService().equals(other.getService()) && placeNameService.getDataset().equals(
43 other.getDataset()))
45 if (replace)
47 this.serviceList.set(i, placeNameService);
48 return true;
50 else
52 return false;
57 this.serviceList.add(placeNameService);
58 return true;
61 public final PlaceNameServiceSet deepCopy()
63 PlaceNameServiceSet copy = new PlaceNameServiceSet();
65 // Creates a deep copy of this.serviceList in copy.serviceList.
66 for (int i = 0; i < this.serviceList.size(); i++)
68 copy.serviceList.add(i, this.serviceList.get(i).deepCopy());
71 return copy;
74 public final int getServiceCount()
76 return this.serviceList.size();
79 public final PlaceNameService getService(int index)
81 return this.serviceList.get(index);