net.sf.magicproject.xml
Class XmlTbs

java.lang.Object
  extended by net.sf.magicproject.xml.XmlTbs

public final class XmlTbs
extends java.lang.Object

This is the main class used to convert a turn based system described in a XML form to a binary form for further interpretation.

Since:
0.80, 0.82 static-modifiers supported in TBS rules
Author:
Fabrice Daugan

Field Summary
static ReferencePager cardPager
          The card reference pager.
static int currentActionIndex
          Nb written action in the current 'writeActionlist' method.
static boolean currentInEffect
          Is the last action has benn written in effects part of ability?
static java.util.Map<java.lang.String,XmlParser.Node> referencedAbilities
          Available ability references of this Card.
static java.util.Map<java.lang.String,java.util.List<XmlParser.Node>> referencedActions
          Available actions references of this Card.
static java.util.Set<java.lang.String> referencedNonMacroActions
          Available actions references that do not accept macro.
static java.util.Map<java.lang.String,XmlParser.Node> referencedTest
          Available test references of this Card.
 
Method Summary
static XmlParser.Node getReferencedAbility(java.lang.String abilityName)
          Returns the referenced ability.
static java.util.List<XmlParser.Node> getReferencedActions(java.lang.String actionName)
          Returns the referenced action(s).
static XmlParser.Node getReferencedAttachment(java.lang.String attachmentName)
          Returns the referenced attachment declared within the rules definition.
static XmlParser.Node getReferencedTest(java.lang.String testName)
          Returns the referenced test.
static XmlToMDB getTbsComponent(java.lang.String component)
          Returns a suitable XmlToMDB implementation for the given tbs component name.
static boolean isNotMacro(java.lang.String referenceName)
          Indicates if the specified referenced action accept macro or not.
static void updateMdb(java.lang.String mdbName, java.io.OutputStream out)
          Reads from the tbs directory the existing XML files, parse them, add them to the mdb file in the right order
static int writeActionList(XmlParser.Node node, java.io.OutputStream out0)
          Writes a list of actions described in the given XML node to the given OutputStream (which must be a FileOutputStream) prefixing the stream with an integer containing the number of written actions and returns this number of written actions.
static int writeActionListNoNb(XmlParser.Node node, java.io.OutputStream out)
          Writes a list of actions described in the given XML node into the given OutputStream as a sequence and returns the number of written actions.
static void writeCard(java.lang.String currentDir, java.io.OutputStream out, java.lang.String cardFile)
          Writes the card identified by the given card XML description file name in the given directory to the given OutputStream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

referencedAbilities

public static java.util.Map<java.lang.String,XmlParser.Node> referencedAbilities
Available ability references of this Card.


referencedTest

public static java.util.Map<java.lang.String,XmlParser.Node> referencedTest
Available test references of this Card.


referencedActions

public static java.util.Map<java.lang.String,java.util.List<XmlParser.Node>> referencedActions
Available actions references of this Card.


referencedNonMacroActions

public static java.util.Set<java.lang.String> referencedNonMacroActions
Available actions references that do not accept macro.


currentActionIndex

public static int currentActionIndex
Nb written action in the current 'writeActionlist' method.


currentInEffect

public static boolean currentInEffect
Is the last action has benn written in effects part of ability?


cardPager

public static ReferencePager cardPager
The card reference pager.

Method Detail

writeActionList

public static int writeActionList(XmlParser.Node node,
                                  java.io.OutputStream out0)
                           throws java.io.IOException
Writes a list of actions described in the given XML node to the given OutputStream (which must be a FileOutputStream) prefixing the stream with an integer containing the number of written actions and returns this number of written actions.

Parameters:
node - the node containing list of actions
out0 - the OutputStream to write the given actions to
Returns:
the amount of written action.
Throws:
java.io.IOException - if an I/O error occurs if an illegal access error occurs if a security error occurs if an illegal argument is given

writeActionListNoNb

public static int writeActionListNoNb(XmlParser.Node node,
                                      java.io.OutputStream out)
                               throws java.io.IOException
Writes a list of actions described in the given XML node into the given OutputStream as a sequence and returns the number of written actions.

Parameters:
node - the node containing list of actions
out - the OutputStream to write the actions to
Returns:
the amount of written action.
Throws:
java.io.IOException - if an I/O error occurs if an illegal access error occurs if a security error occurs if an illegal argument is given

writeCard

public static void writeCard(java.lang.String currentDir,
                             java.io.OutputStream out,
                             java.lang.String cardFile)
Writes the card identified by the given card XML description file name in the given directory to the given OutputStream.

Parameters:
currentDir - the directory path to find the card XML description file name
out - the OutputStream to write the identified card to
cardFile - the card XML description file name

updateMdb

public static void updateMdb(java.lang.String mdbName,
                             java.io.OutputStream out)
                      throws java.io.IOException
Reads from the tbs directory the existing XML files, parse them, add them to the mdb file in the right order

Parameters:
mdbName - the mdb name used to find the directory containing the XML files.
out - the outputStream where the cards would written in.
Throws:
java.io.IOException

getTbsComponent

public static XmlToMDB getTbsComponent(java.lang.String component)
Returns a suitable XmlToMDB implementation for the given tbs component name.

Parameters:
component - the name of the tbs component
Returns:
a suitable XmlToMDB implementation for the given tbs component name

getReferencedAbility

public static XmlParser.Node getReferencedAbility(java.lang.String abilityName)
Returns the referenced ability. First search into the declared abilities within the current card, then within the declared ability within the rules definition.

Parameters:
abilityName - the ability name
Returns:
the ability referenced by the given ability name as a node

getReferencedAttachment

public static XmlParser.Node getReferencedAttachment(java.lang.String attachmentName)
Returns the referenced attachment declared within the rules definition.

Parameters:
attachmentName - the attachment name
Returns:
the attachment referenced by the given attachment name as a xml node

getReferencedActions

public static java.util.List<XmlParser.Node> getReferencedActions(java.lang.String actionName)
Returns the referenced action(s). First search into the declared action(s) within the current card, then within the declared action(s) within the rules definition.

Parameters:
actionName - the action name
Returns:
the action(s) referenced by the given action name as a list

isNotMacro

public static boolean isNotMacro(java.lang.String referenceName)
Indicates if the specified referenced action accept macro or not.

Parameters:
referenceName - the referenced action name
Returns:
true if the specified referenced action accept macro, false either

getReferencedTest

public static XmlParser.Node getReferencedTest(java.lang.String testName)
Returns the referenced test. First search into the declared test within the current card, then within the declared test within the rules definition.

Parameters:
testName - the test name
Returns:
the test referenced by the given test name as a node


Copyright © 2003-2007 Magic-Project. All Rights Reserved.