|
From: <boo...@us...> - 2006-03-09 02:18:17
|
Revision: 150 Author: boomer70 Date: 2006-03-08 18:17:56 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=150&view=rev Log Message: ----------- Pluginized the rest of the Kit tags Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLstToken.java Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,91 @@ +/* + * KitClassLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitClass; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitClassLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + KitClass kitClass = null; + String className = colToken.nextToken(); + kitClass = new KitClass(className); + + Map tokenMap = TokenStore.inst().getTokenMap(KitClassLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitClassLstToken token = (KitClassLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitClass, value)) + { + Logging + .errorPrint("Error parsing Kit Ability tag " + + kitClass.getObjectName() + ':' + + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitClass, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Class info: \"" + colString + + "\""); + } + } + kit.addObject(kitClass); + } + +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitClassLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitClass; + +public interface KitClassLstToken extends LstToken +{ + public abstract boolean parse(KitClass kitClass, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,91 @@ +/* + * KitDeityLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitDeity; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitDeityLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + KitDeity kitDeity = null; + String deityName = colToken.nextToken(); + kitDeity = new KitDeity(deityName); + + Map tokenMap = TokenStore.inst().getTokenMap(KitDeityLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitDeityLstToken token = (KitDeityLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitDeity, value)) + { + Logging + .errorPrint("Error parsing Kit Ability tag " + + kitDeity.getObjectName() + ':' + + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitDeity, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Class info: \"" + colString + + "\""); + } + } + kit.addObject(kitDeity); + } + +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitDeityLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,9 @@ + +package pcgen.persistence.lst; + +import pcgen.core.kit.KitDeity; + +public interface KitDeityLstToken extends LstToken +{ + public abstract boolean parse(KitDeity kitDeity, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,96 @@ +/* + * KitFundsLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitFunds; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +/** + * Handles the parsing of a Kit line starting with FUNDS + * + * @author Aaron Divinsky <boo...@ya...> + * + */ +public class KitFundsLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + KitFunds kitFunds = new KitFunds(colToken.nextToken()); + + Map tokenMap = TokenStore.inst().getTokenMap(KitFundsLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitFundsLstToken token = (KitFundsLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitFunds, value)) + { + Logging + .errorPrint("Error parsing Kit Funds tag " + + kitFunds.getObjectName() + ':' + + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitFunds, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Funds info: \"" + colString + + "\""); + } + } + kit.addObject(kitFunds); + } + +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitFundsLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitFunds; + +public interface KitFundsLstToken extends LstToken +{ + public abstract boolean parse(KitFunds kitFunds, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,88 @@ +/* + * KitGearLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitGear; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitGearLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + KitGear kitGear = new KitGear(colToken.nextToken()); + + Map tokenMap = TokenStore.inst().getTokenMap(KitGearLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitGearLstToken token = (KitGearLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitGear, value)) + { + Logging.errorPrint("Error parsing Kit Funds tag " + + kitGear.getObjectName() + ':' + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitGear, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Gear info: \"" + colString + + "\""); + } + + } + kit.addObject(kitGear); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitGearLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitGear; + +public interface KitGearLstToken extends LstToken +{ + public abstract boolean parse(KitGear kitGear, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,111 @@ +/* + * KitLevelAbilityLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitLevelAbility; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitLevelAbilityLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + KitLevelAbility kitLA = new KitLevelAbility(); + + colString = colToken.nextToken(); + String classInfo = colString; + int levelInd = classInfo.indexOf("="); + if (levelInd < 0) + { + throw new PersistenceLayerException( + "Invalid level in KitLevelAbility info \"" + colString + + "\""); + } + kitLA.setClass(classInfo.substring(0, levelInd)); + try + { + kitLA.setLevel(Integer.parseInt(classInfo.substring(levelInd + 1))); + } + catch (NumberFormatException e) + { + throw new PersistenceLayerException( + "Invalid level in KitLevelAbility info \"" + colString + + "\""); + } + Map tokenMap = TokenStore.inst().getTokenMap( + KitLevelAbilityLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitLevelAbilityLstToken token = (KitLevelAbilityLstToken) tokenMap + .get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitLA, value)) + { + Logging.errorPrint("Error parsing Kit Level Ability tag " + + kitLA.getObjectName() + ':' + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitLA, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Level Ability info: \"" + + colString + "\""); + } + + } + kit.setDoLevelAbilities(false); + kit.addObject(kitLA); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLevelAbilityLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitLevelAbility; + +public interface KitLevelAbilityLstToken extends LstToken +{ + public abstract boolean parse(KitLevelAbility kitLA, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,88 @@ +/* + * KitProfLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitProf; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitProfLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + KitProf kitProf = new KitProf(colToken.nextToken()); + + Map tokenMap = TokenStore.inst().getTokenMap(KitProfLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitProfLstToken token = (KitProfLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitProf, value)) + { + Logging.errorPrint("Error parsing Kit Prof tag " + + kitProf.getObjectName() + ':' + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitProf, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Prof info: \"" + colString + + "\""); + } + + } + kit.addObject(kitProf); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitProfLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitProf; + +public interface KitProfLstToken extends LstToken +{ + public abstract boolean parse(KitProf kitProf, String value); +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,90 @@ +/* + * KitSkillLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitSkill; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitSkillLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + KitSkill kitSkill = new KitSkill(colToken.nextToken()); + + Map tokenMap = TokenStore.inst().getTokenMap(KitSkillLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitSkillLstToken token = (KitSkillLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitSkill, value)) + { + Logging + .errorPrint("Error parsing Kit Skill tag " + + kitSkill.getObjectName() + ':' + + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitSkill, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Skill info: \"" + colString + + "\""); + } + + } + kit.addObject(kitSkill); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSkillLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,9 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitSkill; + +public interface KitSkillLstToken extends LstToken +{ + public abstract boolean parse(KitSkill kitSkill, String value); +} + Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,125 @@ +/* + * KitSpellsLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.ArrayList; +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Globals; +import pcgen.core.Kit; +import pcgen.core.kit.KitSpells; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitSpellsLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + final KitSpells kitSpells = new KitSpells(); + colString = colToken.nextToken(); + final StringTokenizer aTok = new StringTokenizer(colString, "|"); + + String spellbook = Globals.getDefaultSpellBook(); + String castingClass = null; + while (aTok.hasMoreTokens()) + { + String field = aTok.nextToken(); + if (field.startsWith("SPELLBOOK=")) + { + spellbook = field.substring(10); + } + else if (field.startsWith("CLASS=")) + { + castingClass = field.substring(6); + } + else + { + String countStr = null; + if (field.indexOf("=") != -1) + { + countStr = field.substring(field.indexOf("=") + 1); + field = field.substring(0, field.indexOf("=")); + } + final StringTokenizer subTok = new StringTokenizer(field, "[]"); + final String spell = subTok.nextToken(); + ArrayList featList = new ArrayList(); + while (subTok.hasMoreTokens()) + { + featList.add(subTok.nextToken()); + } + kitSpells.addSpell(castingClass, spellbook, spell, featList, + countStr); + } + } + Map tokenMap = TokenStore.inst().getTokenMap(KitSpellsLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitSpellsLstToken token = (KitSpellsLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitSpells, value)) + { + Logging.errorPrint("Error parsing Kit Spells tag " + + kitSpells.getObjectName() + ':' + colString + + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitSpells, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Spells info: \"" + colString + + "\""); + } + + } + kit.addObject(kitSpells); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitSpellsLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,9 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitSpells; + +public interface KitSpellsLstToken extends LstToken +{ + public abstract boolean parse(KitSpells kitSpells, String value); +} + Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,89 @@ +/* + * KitStartpackLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitStartpackLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + kit.setName(colToken.nextToken()); + Map tokenMap = TokenStore.inst() + .getTokenMap(KitStartpackLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + if (PObjectLoader.parseTag(kit, colString)) + { + // Here if PObjectLoader has processed tag--nothing else to do + continue; + } + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitStartpackLstToken token = (KitStartpackLstToken) tokenMap + .get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kit, value)) + { + Logging.errorPrint("Error parsing Kit Startpack tag " + + kit.getName() + ':' + colString + "\""); + } + } + else + { + Logging.errorPrint("Unknown Kit Startpack info: \"" + colString + + "\""); + } + + } + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitStartpackLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,9 @@ +package pcgen.persistence.lst; + +import pcgen.core.Kit; + +public interface KitStartpackLstToken extends LstToken +{ + public abstract boolean parse(Kit kit, String value); +} + Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLoader.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,82 @@ +/* + * KitTableLoader.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 March 6, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ + +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitTableLoader +{ + public static void parseLine(Kit kit, String colString) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, + SystemLoader.TAB_DELIM); + + String tableName = colToken.nextToken(); + kit.addLookupTable(tableName); + + Map tokenMap = TokenStore.inst().getTokenMap(KitTableLstToken.class); + while (colToken.hasMoreTokens()) + { + colString = colToken.nextToken(); + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (StringIndexOutOfBoundsException e) + { + // TODO Handle Exception + } + KitTableLstToken token = (KitTableLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kit, tableName, value)) + { + Logging.errorPrint("Error parsing Kit Table tag " + + kit.getName() + ':' + colString + "\""); + } + } + else + { + Logging.errorPrint("Unknown Kit Table info: \"" + colString + + "\""); + } + } + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitTableLstToken.java 2006-03-09 02:17:56 UTC (rev 150) @@ -0,0 +1,9 @@ +package pcgen.persistence.lst; + +import pcgen.core.Kit; + +public interface KitTableLstToken extends LstToken +{ + public abstract boolean parse(Kit kit, final String tableName,String value); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |