001    /*
002      Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
003    
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser General Public
015      License along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017      USA */
018    
019    package org.objectweb.jac.ide;
020    
021    import org.objectweb.jac.core.rtti.NamingConventions;
022    import org.objectweb.jac.util.Strings;
023    import java.util.Hashtable;
024    import java.util.Map;
025    
026    public class Plurals {
027        // singular -> plural
028        Map plurals = new Hashtable();
029        // plural -> singular
030        Map singulars = new Hashtable();
031    
032        public void addPlural(String singular, String plural) {
033            plurals.put(singular,plural);
034            singulars.put(plural,singular);
035        }
036        public void removePlural(String singular) {
037            singulars.remove(plurals.get(singular));
038            plurals.remove(singular);
039        }
040        public Map getPlurals() {
041            return plurals;
042        }
043        public String getPlural(String singular) {
044            String plural = (String)plurals.get(singular);
045            if (plural==null) {
046                plural = NamingConventions.getPlural(singular);
047            }
048            return plural;
049        }
050        public String getSingular(String plural) {
051            String singular = (String)singulars.get(plural);
052            if (singular==null) {
053                singular = NamingConventions.getSingular(plural);
054            }
055            return singular;
056        }
057    }
058