~ubuntu-branches/ubuntu/precise/triplea/precise

« back to all changes in this revision

Viewing changes to src/games/strategy/engine/data/DelegateList.java

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2011-11-11 21:40:11 UTC
  • Revision ID: package-import@ubuntu.com-20111111214011-sehf2rwat36o2xqf
Tags: upstream-1.3.2.2
ImportĀ upstreamĀ versionĀ 1.3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This program is free software; you can redistribute it and/or modify
 
3
 * it under the terms of the GNU General Public License as published by
 
4
 * the Free Software Foundation; either version 2 of the License, or
 
5
 * (at your option) any later version.
 
6
 * This program is distributed in the hope that it will be useful,
 
7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
8
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
9
 * GNU General Public License for more details.
 
10
 * You should have received a copy of the GNU General Public License
 
11
 * along with this program; if not, write to the Free Software
 
12
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
13
 */
 
14
 
 
15
/*
 
16
 * DelegateList.java
 
17
 *
 
18
 * Created on October 17, 2001, 9:21 PM
 
19
 */
 
20
 
 
21
package games.strategy.engine.data;
 
22
 
 
23
import games.strategy.engine.delegate.*;
 
24
 
 
25
import java.util.*;
 
26
import java.io.*;
 
27
 
 
28
/**
 
29
 *
 
30
 * @author  Sean Bridges
 
31
 *
 
32
 *
 
33
 */
 
34
public class DelegateList extends GameDataComponent implements Iterable<IDelegate>
 
35
{
 
36
        private Map<String, IDelegate> m_delegates = new HashMap<String, IDelegate>();
 
37
 
 
38
    public DelegateList(GameData data)
 
39
        {
 
40
                super(data);
 
41
    }
 
42
 
 
43
        public void addDelegate(IDelegate del)
 
44
        {
 
45
                m_delegates.put(del.getName(), del);
 
46
        }
 
47
 
 
48
        public int size()
 
49
        {
 
50
                return m_delegates.size();
 
51
        }
 
52
 
 
53
        public Iterator<IDelegate> iterator()
 
54
        {
 
55
                return m_delegates.values().iterator();
 
56
        }
 
57
 
 
58
        public IDelegate getDelegate(String name)
 
59
        {
 
60
                return m_delegates.get(name);
 
61
        }
 
62
 
 
63
        private void writeObject(ObjectOutputStream out)
 
64
        {
 
65
            //dont write since delegates should be handled seperatly.
 
66
        }
 
67
 
 
68
        private void readObject(ObjectInputStream in)
 
69
        {
 
70
                m_delegates = new HashMap<String, IDelegate>();
 
71
        }
 
72
}