version 0.4.9.3:
[jSite.git] / src / de / todesbaum / jsite / i18n / I18nContainer.java
1 /*
2  * jSite-remote - I18nContainer.java Copyright © 2007 David Roden
3  * 
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  * 
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package de.todesbaum.jsite.i18n;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.List;
25
26 /**
27  * @author David Roden <droden@gmail.com>
28  * @version $Id$
29  */
30 public class I18nContainer implements Iterable<Runnable> {
31
32         private static final I18nContainer singleton = new I18nContainer();
33         private final List<Runnable> i18nRunnables = Collections.synchronizedList(new ArrayList<Runnable>());
34         private final List<Runnable> i18nPostRunnables = Collections.synchronizedList(new ArrayList<Runnable>());
35
36         public static I18nContainer getInstance() {
37                 return singleton;
38         }
39
40         public void registerRunnable(Runnable i18nRunnable) {
41                 i18nRunnables.add(i18nRunnable);
42         }
43
44         public void registerPostRunnable(Runnable i18nPostRunnable) {
45                 i18nPostRunnables.add(i18nPostRunnable);
46         }
47
48         public Iterator<Runnable> iterator() {
49                 List<Runnable> allRunnables = new ArrayList<Runnable>();
50                 allRunnables.addAll(i18nRunnables);
51                 allRunnables.addAll(i18nPostRunnables);
52                 return allRunnables.iterator();
53         }
54
55 }