remove subversion $Id$ tags
[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 ‘Bombe’ Roden <bombe@freenetproject.org>
28  */
29 public class I18nContainer implements Iterable<Runnable> {
30
31         private static final I18nContainer singleton = new I18nContainer();
32         private final List<Runnable> i18nRunnables = Collections.synchronizedList(new ArrayList<Runnable>());
33         private final List<Runnable> i18nPostRunnables = Collections.synchronizedList(new ArrayList<Runnable>());
34
35         public static I18nContainer getInstance() {
36                 return singleton;
37         }
38
39         public void registerRunnable(Runnable i18nRunnable) {
40                 i18nRunnables.add(i18nRunnable);
41         }
42
43         public void registerPostRunnable(Runnable i18nPostRunnable) {
44                 i18nPostRunnables.add(i18nPostRunnable);
45         }
46
47         public Iterator<Runnable> iterator() {
48                 List<Runnable> allRunnables = new ArrayList<Runnable>();
49                 allRunnables.addAll(i18nRunnables);
50                 allRunnables.addAll(i18nPostRunnables);
51                 return allRunnables.iterator();
52         }
53
54 }