StrongsMapSet.java |
1 /** 2 * Distribution License: 3 * JSword is free software; you can redistribute it and/or modify it under 4 * the terms of the GNU Lesser General Public License, version 2.1 or later 5 * as published by the Free Software Foundation. This program is distributed 6 * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 7 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 8 * See the GNU Lesser General Public License for more details. 9 * 10 * The License is available on the internet at: 11 * http://www.gnu.org/copyleft/lgpl.html 12 * or by writing to: 13 * Free Software Foundation, Inc. 14 * 59 Temple Place - Suite 330 15 * Boston, MA 02111-1307, USA 16 * 17 * © CrossWire Bible Society, 2007 - 2016 18 * 19 */ 20 package org.crosswire.jsword.book.study; 21 22 import java.util.HashMap; 23 import java.util.Locale; 24 import java.util.Map; 25 import java.util.Set; 26 import java.util.TreeSet; 27 28 /** 29 * A StrongsMapSet is keyed by a Strong's Number of the form Gd or Hd, where G 30 * and H stand for Greek and Hebrew respectively and d is the actual number, 31 * zero padded to 4 digits. The value for a MapEntry is a Set of Strings, which 32 * are the various ways a Strong's Number is marked up. 33 * 34 * @see gnu.lgpl.License The GNU Lesser General Public License for details. 35 * @author DM Smith 36 */ 37 public class StrongsMapSet { 38 /** 39 * Build an empty Strong's Map Set. 40 */ 41 public StrongsMapSet() { 42 map = new HashMap<String, Set<String>>(); 43 } 44 45 /** 46 * Add a String representing the content of an instance of a Strong's Number 47 * in a text. 48 * 49 * @param strongsNumber 50 * the Strong's Number 51 * @param representation 52 * a way the Strong's number is represented. 53 */ 54 public void add(String strongsNumber, String representation) { 55 Set<String> reps = map.get(strongsNumber); 56 if (reps == null) { 57 reps = new TreeSet<String>(); 58 map.put(strongsNumber, reps); 59 } 60 reps.add(representation.toLowerCase(Locale.ENGLISH)); 61 } 62 63 /** 64 * Get the set of all representations for a Strong's Number. 65 * 66 * @param strongsNumber 67 * @return the whole set 68 */ 69 public Set<String> get(String strongsNumber) { 70 return map.get(strongsNumber); 71 } 72 73 private Map<String, Set<String>> map; 74 } 75