|
From: <th...@us...> - 2008-12-31 05:16:03
|
Revision: 8746
http://pcgen.svn.sourceforge.net/pcgen/?rev=8746&view=rev
Author: thpr
Date: 2008-12-31 05:15:59 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
replace PRE support in Vision
Modified Paths:
--------------
Trunk/pcgen/code/src/java/plugin/lsttokens/VisionLst.java
Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/VisionLst.java
===================================================================
--- Trunk/pcgen/code/src/java/plugin/lsttokens/VisionLst.java 2008-12-31 04:51:55 UTC (rev 8745)
+++ Trunk/pcgen/code/src/java/plugin/lsttokens/VisionLst.java 2008-12-31 05:15:59 UTC (rev 8746)
@@ -67,13 +67,24 @@
public boolean parse(LoadContext context, CDOMObject obj, String value)
{
+ if (isEmpty(value) || hasIllegalSeparator('|', value))
+ {
+ return false;
+ }
StringTokenizer aTok = new StringTokenizer(value, Constants.PIPE);
+ String visionString = aTok.nextToken();
+ if (visionString.startsWith("PRE") || visionString.startsWith("!PRE"))
+ {
+ Logging.log(Logging.LST_ERROR,
+ "Cannot have only PRExxx subtoken in " + getTokenName()
+ + ": " + value);
+ return false;
+ }
- List<Vision> list = new ArrayList<Vision>();
- while (aTok.hasMoreTokens())
+ ArrayList<AssociatedPrereqObject> edgeList = new ArrayList<AssociatedPrereqObject>();
+
+ while (true)
{
- String visionString = aTok.nextToken();
-
if (".CLEAR".equals(visionString))
{
context.getListContext().removeAllFromList(getTokenName(), obj,
@@ -99,18 +110,28 @@
return false;
}
}
+ else if (visionString.startsWith("PRE")
+ || visionString.startsWith("!PRE"))
+ {
+ break;
+ }
else
{
if (visionString.startsWith(".SET."))
{
- // TODO Need a deprecation warning here
+ Logging.deprecationPrint(".SET. in " + getTokenName()
+ + " has been deprecated, please use .CLEAR,x");
context.getListContext().removeAllFromList(getTokenName(),
obj, Vision.VISIONLIST);
visionString = visionString.substring(5);
}
try
{
- list.add(Vision.getVision(visionString));
+ Vision vision = Vision.getVision(visionString);
+ AssociatedPrereqObject edge = context.getListContext()
+ .addToList(getTokenName(), obj, Vision.VISIONLIST,
+ new CDOMDirectSingleRef<Vision>(vision));
+ edgeList.add(edge);
}
catch (IllegalArgumentException e)
{
@@ -120,11 +141,31 @@
return false;
}
}
+ if (!aTok.hasMoreTokens())
+ {
+ return true;
+ }
+ visionString = aTok.nextToken();
}
- for (Vision vis : list)
+ while (true)
{
- context.getListContext().addToList(getTokenName(), obj,
- Vision.VISIONLIST, new CDOMDirectSingleRef<Vision>(vis));
+ Prerequisite prereq = getPrerequisite(visionString);
+ if (prereq == null)
+ {
+ Logging.log(Logging.LST_ERROR,
+ " (Did you put vision after the " + "PRExxx tags in "
+ + getTokenName() + ":?)");
+ return false;
+ }
+ for (AssociatedPrereqObject edge : edgeList)
+ {
+ edge.addPrerequisite(prereq);
+ }
+ if (!aTok.hasMoreTokens())
+ {
+ break;
+ }
+ visionString = aTok.nextToken();
}
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|