commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1154432 - in /commons/proper/codec/trunk/src: java/org/apache/commons/codec/language/bm/ test/org/apache/commons/codec/language/bm/
Date Sat, 06 Aug 2011 02:33:39 GMT
Author: ggregory
Date: Sat Aug  6 02:33:39 2011
New Revision: 1154432

URL: http://svn.apache.org/viewvc?rev=1154432&view=rev
Log:
Better API names (IMO)

Modified:
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Languages.java
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java
    commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java?rev=1154432&r1=1154431&r2=1154432&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java (original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java Sat
Aug  6 02:33:39 2011
@@ -93,7 +93,7 @@ public class Lang {
 
     static {
         for (NameType s : NameType.values()) {
-            Langs.put(s, loadFromResource(LANGUAGE_RULES_RN, Languages.instance(s)));
+            Langs.put(s, loadFromResource(LANGUAGE_RULES_RN, Languages.getInstance(s)));
         }
     }
 

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Languages.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Languages.java?rev=1154432&r1=1154431&r2=1154432&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Languages.java
(original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Languages.java
Sat Aug  6 02:33:39 2011
@@ -135,15 +135,15 @@ public class Languages {
 
     static {
         for (NameType s : NameType.values()) {
-            LANGUAGES.put(s, instance(langResourceName(s)));
+            LANGUAGES.put(s, getInstance(langResourceName(s)));
         }
     }
 
-    public static Languages instance(NameType nameType) {
+    public static Languages getInstance(NameType nameType) {
         return LANGUAGES.get(nameType);
     }
 
-    public static Languages instance(String languagesResourceName) {
+    public static Languages getInstance(String languagesResourceName) {
         // read languages list
         Set<String> ls = new HashSet<String>();
         InputStream langIS = Languages.class.getClassLoader().getResourceAsStream(languagesResourceName);

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java?rev=1154432&r1=1154431&r2=1154432&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
(original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
Sat Aug  6 02:33:39 2011
@@ -264,7 +264,7 @@ public class PhoneticEngine {
      */
     public String encode(String input) {
         Languages.LanguageSet languageSet = this.lang.guessLanguages(input);
-        return phoneticUtf8(input, languageSet);
+        return encode(input, languageSet);
     }
 
     /**
@@ -311,10 +311,10 @@ public class PhoneticEngine {
      * @param languageSet
      * @return a phonetic representation of the input; a String containing '-'-separated
phonetic representations of the input
      */
-    public String phoneticUtf8(String input, final Languages.LanguageSet languageSet) {
-        final List<Rule> rules = Rule.instance(this.nameType, RuleType.RULES, languageSet);
-        final List<Rule> finalRules1 = Rule.instance(this.nameType, this.ruleType,
"common");
-        final List<Rule> finalRules2 = Rule.instance(this.nameType, this.ruleType,
languageSet);
+    public String encode(String input, final Languages.LanguageSet languageSet) {
+        final List<Rule> rules = Rule.getInstance(this.nameType, RuleType.RULES, languageSet);
+        final List<Rule> finalRules1 = Rule.getInstance(this.nameType, this.ruleType,
"common");
+        final List<Rule> finalRules2 = Rule.getInstance(this.nameType, this.ruleType,
languageSet);
         // System.err.println("Languages: " + languageSet);
         // System.err.println("Rules: " + rules);
 

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java?rev=1154432&r1=1154431&r2=1154432&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java (original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java Sat
Aug  6 02:33:39 2011
@@ -161,7 +161,7 @@ public class Rule {
             for (RuleType rt : RuleType.values()) {
                 Map<String, List<Rule>> rs = new HashMap<String, List<Rule>>();
 
-                Languages ls = Languages.instance(s);
+                Languages ls = Languages.getInstance(s);
                 for (String l : ls.getLanguages()) {
                     try {
                         rs.put(l, parseRules(createScanner(s, rt, l), createResourceName(s,
rt, l)));
@@ -217,8 +217,8 @@ public class Rule {
      *            the set of languages to consider
      * @return a list of Rules that apply
      */
-    public static List<Rule> instance(NameType nameType, RuleType rt, Languages.LanguageSet
langs) {
-        return langs.isSingleton() ? instance(nameType, rt, langs.getAny()) : instance(nameType,
rt, Languages.ANY);
+    public static List<Rule> getInstance(NameType nameType, RuleType rt, Languages.LanguageSet
langs) {
+        return langs.isSingleton() ? getInstance(nameType, rt, langs.getAny()) : getInstance(nameType,
rt, Languages.ANY);
     }
 
     /**
@@ -232,7 +232,7 @@ public class Rule {
      *            the language to consider
      * @return a list rules for a combination of name type, rule type and a single language.
      */
-    public static List<Rule> instance(NameType nameType, RuleType rt, String lang)
{
+    public static List<Rule> getInstance(NameType nameType, RuleType rt, String lang)
{
         List<Rule> rules = RULES.get(nameType).get(rt).get(lang);
 
         if (rules == null) {

Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java?rev=1154432&r1=1154431&r2=1154432&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
(original)
+++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
Sat Aug  6 02:33:39 2011
@@ -110,17 +110,17 @@ public class BeiderMorseEncoderTest exte
 
     @Test(expected = IllegalArgumentException.class)
     public void testInvalidLangIllegalArgumentException() {
-        Rule.instance(NameType.GENERIC, RuleType.APPROX, "noSuchLanguage");
+        Rule.getInstance(NameType.GENERIC, RuleType.APPROX, "noSuchLanguage");
     }
 
     @Test(expected = IllegalStateException.class)
     public void testInvalidLangIllegalStateException() {
-        Lang.loadFromResource("thisIsAMadeUpResourceName", Languages.instance(NameType.GENERIC));
+        Lang.loadFromResource("thisIsAMadeUpResourceName", Languages.getInstance(NameType.GENERIC));
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testInvalidLanguageIllegalArgumentException() {
-        Languages.instance("thereIsNoSuchLanguage");
+        Languages.getInstance("thereIsNoSuchLanguage");
     }
 
     @Test(timeout = 10000L)



Mime
View raw message