KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > Plurals


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program 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
12   GNU 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 program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.ide;
20
21 import org.objectweb.jac.core.rtti.NamingConventions;
22 import org.objectweb.jac.util.Strings;
23 import java.util.Hashtable JavaDoc;
24 import java.util.Map JavaDoc;
25
26 public class Plurals {
27     // singular -> plural
28
Map JavaDoc plurals = new Hashtable JavaDoc();
29     // plural -> singular
30
Map JavaDoc singulars = new Hashtable JavaDoc();
31
32     public void addPlural(String JavaDoc singular, String JavaDoc plural) {
33         plurals.put(singular,plural);
34         singulars.put(plural,singular);
35     }
36     public void removePlural(String JavaDoc singular) {
37         singulars.remove(plurals.get(singular));
38         plurals.remove(singular);
39     }
40     public Map JavaDoc getPlurals() {
41         return plurals;
42     }
43     public String JavaDoc getPlural(String JavaDoc singular) {
44         String JavaDoc plural = (String JavaDoc)plurals.get(singular);
45         if (plural==null) {
46             plural = NamingConventions.getPlural(singular);
47         }
48         return plural;
49     }
50     public String JavaDoc getSingular(String JavaDoc plural) {
51         String JavaDoc singular = (String JavaDoc)singulars.get(plural);
52         if (singular==null) {
53             singular = NamingConventions.getSingular(plural);
54         }
55         return singular;
56     }
57 }
58
59
Popular Tags