|
From: <nu...@us...> - 2006-03-22 02:17:00
|
Revision: 369 Author: nuance Date: 2006-03-21 18:16:46 -0800 (Tue, 21 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=369&view=rev Log Message: ----------- Add missing header info to AbilityFromTemplateChoiceManagerTest. Add another little utility method for a piece of code I've duplicated far too many times already. Test new method. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/AbilityInfo.java Trunk/pcgen/code/src/java/pcgen/core/EquipmentUtilities.java Trunk/pcgen/code/src/test/pcgen/core/chooser/AbilityFromTemplateChoiceManagerTest.java Modified: Trunk/pcgen/code/src/java/pcgen/core/AbilityInfo.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AbilityInfo.java 2006-03-22 02:14:21 UTC (rev 368) +++ Trunk/pcgen/code/src/java/pcgen/core/AbilityInfo.java 2006-03-22 02:16:46 UTC (rev 369) @@ -83,7 +83,10 @@ if (realThing == null) { realThing = AbilityUtilities.retrieveAbilityKeyed(this.category, this.keyName); - // Globals.getAbilityKeyed(this.category, this.keyName); + + if ((realThing != null) && (!realThing.getKeyName().equals(this.keyName))) { + + } } return realThing; Modified: Trunk/pcgen/code/src/java/pcgen/core/EquipmentUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/EquipmentUtilities.java 2006-03-22 02:14:21 UTC (rev 368) +++ Trunk/pcgen/code/src/java/pcgen/core/EquipmentUtilities.java 2006-03-22 02:16:46 UTC (rev 369) @@ -326,7 +326,7 @@ * * @param aName * - * @return the name with choices stripped + * @return the name with sub-choices stripped from it */ public static String removeChoicesFromName(String aName) { @@ -334,4 +334,37 @@ return (anInt >= 0) ? aName.substring(0, anInt).trim() : aName; } + + + /** + * Takes a string of the form "foo (bar, baz)", populates the array + * with ["bar", "baz"] and returns foo. All strings returned by this + * function have had leading.trailing whitespace removed. + * + * @param name + * @param specifics + * + * @return the name with sub-choices stripped from it + */ + public static String getUndecoratedName(final String name, ArrayList specifics) { + + String altName = removeChoicesFromName(name); + + specifics.clear(); + int start = name.indexOf('(') + 1; + int end = name.lastIndexOf(')'); + + if (start >= 0 && end > start) { + + // we want what is inside the outermost parenthesis. + String subName = name.substring(start, end); + + for (Iterator specIt = Arrays.asList(subName.split("\\s*,\\s*")).iterator(); specIt.hasNext(); ) { + specifics.add(((String) specIt.next()).trim()); + } + } + + return altName; + } + } Modified: Trunk/pcgen/code/src/test/pcgen/core/chooser/AbilityFromTemplateChoiceManagerTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/chooser/AbilityFromTemplateChoiceManagerTest.java 2006-03-22 02:14:21 UTC (rev 368) +++ Trunk/pcgen/code/src/test/pcgen/core/chooser/AbilityFromTemplateChoiceManagerTest.java 2006-03-22 02:16:46 UTC (rev 369) @@ -1,11 +1,31 @@ /** - * + * AbilityFromTemplateChoiceManagerTest.java + * Copyright 2006 (C) Andrew Wilson <nu...@so...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on 17 March 2005 + * + * $Author: nuance $ + * $Date: 2006-03-22 00:25:03 +0000 (Wed, 22 Mar 2006) $ + * $Revision: 362 $ */ package pcgen.core.chooser; import java.lang.reflect.Field; import java.util.HashMap; -import java.util.List; import java.util.Set; import pcgen.AbstractCharacterTestCase; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |