net.sf.magicproject.xml
Class XmlTools

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

public final class XmlTools
extends java.lang.Object

Author:
Fabrice Daugan

Field Summary
static java.util.Map<java.lang.String,java.lang.Integer> aliasMap
          The definied user alias
static boolean defaultOnMeTag
          This field must be set by activated ability, triggered, and counters to known the default value for the 'on' attribute
static boolean testCanBePreempted
          This field must be set by actions needing some pre-check test such as target action.
static java.util.Map<java.lang.String,java.lang.Integer> zones
          The available zones.
 
Method Summary
static void clean()
          Clean tables.
static int getAliasValue(java.lang.String alias)
          Return the corresponding code to the card color name
static int getColor(java.lang.String colorName)
          Return the corresponding code to the card color name
static XmlParser.Node getExternalizableNode(XmlParser.Node node, java.lang.String nodeName)
          Return the named node from the given node.
static int getIdCard(java.lang.String idCard)
          Return the corresponding code to the card type name
static int getIdCards(java.lang.String list)
          Return the corresponding code to the list of card type name
static int getInt(java.lang.String alias)
          Return the corresponding code to the specified alias.
static IdMessageBox getMessageType(java.lang.String attribute)
           
static int getModifierLayer(java.lang.String attribute)
           
static int getOperation(java.lang.String operation)
          Return the operation code
static Optimization getOptimization(java.lang.String attribute)
           
static java.lang.Integer getPosition(java.lang.String positionAlias)
          Return the corresponding code to the specified position name.
static Priority getPriority(java.lang.String resolution)
          Return the resolution code
static int getTargetMode(java.lang.String modeAlias)
          Return the corresponding code to the specified target mode.
static int getValue(java.lang.String alias)
          Return the corresponding codeto the specified string register index.
static int getZone(java.lang.String zoneAlias)
          Return the corresponding code to the specified zone name.
static void initHashMaps()
          Fill the referenced HashMaps
static void tryWriteExpression(XmlParser.Node node, java.lang.String attribute, java.io.OutputStream out)
          If there is neither attribute neither node with the given name, '-1' is witten instead of throwing an exception.
static void writeAttrOptions(XmlParser.Node node, java.lang.String tagAttr, java.io.OutputStream out)
           
static void writeAttrOptions(XmlParser.Node node, java.lang.String tagAttr, java.io.OutputStream out, java.lang.String nameSpace)
           
static void writeAttrOptionsDefault(XmlParser.Node node, java.lang.String tagAttr, java.io.OutputStream out, java.lang.String defaultValue)
           
static void writeComplexValue(java.io.OutputStream out, XmlParser.Node expr)
           
static void writeConstant(java.io.OutputStream out, int value)
          Write to the specified output stream the 16bits integer value.
static void writeList(java.io.OutputStream out, XmlParser.Node node, java.lang.String tagAttr)
          Write to the specified output stream the values defined as linear list ' ' separated values, or 'value' elements.
static void writeSimpleValue(java.io.OutputStream out, java.lang.String value)
          Write to the specified output stream the 16bits integer value.
static void writeTestOn(java.io.OutputStream out, java.lang.String xsdName)
          Write the TestOn instance corresponding to the given XSD attribute name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zones

public static java.util.Map<java.lang.String,java.lang.Integer> zones
The available zones.

See Also:
net.sf.magicproject.xml.tbs.Tbs#buildMdb(Node, OutputStream)

aliasMap

public static java.util.Map<java.lang.String,java.lang.Integer> aliasMap
The definied user alias


defaultOnMeTag

public static boolean defaultOnMeTag
This field must be set by activated ability, triggered, and counters to known the default value for the 'on' attribute


testCanBePreempted

public static boolean testCanBePreempted
This field must be set by actions needing some pre-check test such as target action. When is true, the last build test does not refer to a ability's runtime register such as 'stack' register.

Method Detail

tryWriteExpression

public static void tryWriteExpression(XmlParser.Node node,
                                      java.lang.String attribute,
                                      java.io.OutputStream out)
                               throws java.io.IOException
If there is neither attribute neither node with the given name, '-1' is witten instead of throwing an exception.

Parameters:
node - the parent node.
attribute - the attribute/node name to write.
out - the outputstream.
Throws:
java.io.IOException - error while writting.

initHashMaps

public static void initHashMaps()
Fill the referenced HashMaps


clean

public static void clean()
Clean tables.


writeTestOn

public static void writeTestOn(java.io.OutputStream out,
                               java.lang.String xsdName)
                        throws java.io.IOException
Write the TestOn instance corresponding to the given XSD attribute name.

Parameters:
out - the stream ths enum would be written.
xsdName - the Xsd name of this TestOn.
Throws:
java.io.IOException - error while writting.

getModifierLayer

public static int getModifierLayer(java.lang.String attribute)
Parameters:
attribute - the layer name.
Returns:
the layer id.

getOptimization

public static Optimization getOptimization(java.lang.String attribute)
Parameters:
attribute - the optimization name.
Returns:
the optimization id.

getOperation

public static int getOperation(java.lang.String operation)
Return the operation code

Parameters:
operation - the alias
Returns:
the operation code
See Also:
ModifyRegister

getPriority

public static Priority getPriority(java.lang.String resolution)
Return the resolution code

Parameters:
resolution - the alias
Returns:
the resolution code

getTargetMode

public static int getTargetMode(java.lang.String modeAlias)
Return the corresponding code to the specified target mode.

Parameters:
modeAlias - the alias of mode
Returns:
the corresponding code to the specified target mode.
See Also:
IdTargets.MODE_NAMES

getPosition

public static java.lang.Integer getPosition(java.lang.String positionAlias)
Return the corresponding code to the specified position name.

Parameters:
positionAlias - the alias of place
Returns:
the corresponding code to the specified position name.
See Also:
IdPositions.POSITION_NAMES

getZone

public static int getZone(java.lang.String zoneAlias)
Return the corresponding code to the specified zone name.

Parameters:
zoneAlias - the alias of place
Returns:
the corresponding code to the specified zone name.
See Also:
IdZones.ZONE_NAMES

getValue

public static int getValue(java.lang.String alias)
Return the corresponding codeto the specified string register index.

Parameters:
alias - the alias of value in it's string form
Returns:
the corresponding code to the specified string register index.

getInt

public static int getInt(java.lang.String alias)
Return the corresponding code to the specified alias.

Parameters:
alias - the alias of value in it's string form
Returns:
the corresponding code to the specified alias.

getAliasValue

public static int getAliasValue(java.lang.String alias)
Return the corresponding code to the card color name

Parameters:
alias - the alias name.
Returns:
the alias value

getColor

public static int getColor(java.lang.String colorName)
Return the corresponding code to the card color name

Parameters:
colorName - the color alias
Returns:
the corresponding code to the card color name

getIdCard

public static int getIdCard(java.lang.String idCard)
Return the corresponding code to the card type name

Parameters:
idCard - the card type name
Returns:
the corresponding code to the card type name

getIdCards

public static int getIdCards(java.lang.String list)
Return the corresponding code to the list of card type name

Parameters:
list - is the list of card type name
Returns:
the corresponding code to the list of card type name.

writeList

public static void writeList(java.io.OutputStream out,
                             XmlParser.Node node,
                             java.lang.String tagAttr)
                      throws java.io.IOException
Write to the specified output stream the values defined as linear list ' ' separated values, or 'value' elements.

Parameters:
out - outputstream where the card structure will be saved
node - the XML test container structure
tagAttr -
Throws:
java.io.IOException - error while writting.

writeSimpleValue

public static void writeSimpleValue(java.io.OutputStream out,
                                    java.lang.String value)
                             throws java.io.IOException
Write to the specified output stream the 16bits integer value.

Parameters:
out - outputstream where the card structure will be saved
value - the simple value to write.
Throws:
java.io.IOException - error while writting.

writeConstant

public static void writeConstant(java.io.OutputStream out,
                                 int value)
                          throws java.io.IOException
Write to the specified output stream the 16bits integer value.

Parameters:
out - outputstream where the card structure will be saved
value - the simple value to write.
Throws:
java.io.IOException - error while writting.

writeComplexValue

public static void writeComplexValue(java.io.OutputStream out,
                                     XmlParser.Node expr)
                              throws java.io.IOException
Parameters:
out - outputstream where the card structure will be saved
expr - complex expression node to write
Throws:
java.io.IOException - error while writting.

writeAttrOptions

public static void writeAttrOptions(XmlParser.Node node,
                                    java.lang.String tagAttr,
                                    java.io.OutputStream out)
                             throws java.io.IOException
Parameters:
node - the XML test container structure
tagAttr -
out - outputstream where the card structure will be saved
Throws:
java.io.IOException - error while writting.

writeAttrOptionsDefault

public static void writeAttrOptionsDefault(XmlParser.Node node,
                                           java.lang.String tagAttr,
                                           java.io.OutputStream out,
                                           java.lang.String defaultValue)
                                    throws java.io.IOException
Parameters:
node - the XML test container structure
tagAttr -
out - outputstream where the card structure will be saved
defaultValue - the default value to use if neither attribute, neither element has been found.
Throws:
java.io.IOException - error while writting.

writeAttrOptions

public static void writeAttrOptions(XmlParser.Node node,
                                    java.lang.String tagAttr,
                                    java.io.OutputStream out,
                                    java.lang.String nameSpace)
                             throws java.io.IOException
Parameters:
node -
tagAttr -
out -
nameSpace -
Throws:
java.io.IOException - error while writting.

getMessageType

public static IdMessageBox getMessageType(java.lang.String attribute)
Parameters:
attribute - the message name.
Returns:
the message id.

getExternalizableNode

public static XmlParser.Node getExternalizableNode(XmlParser.Node node,
                                                   java.lang.String nodeName)
Return the named node from the given node. This node may be definied in an externalized xml file.

Parameters:
node - the parent node.
nodeName - the node name.
Returns:
the named node from the given node.


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