public static Entity decode( ParsedXML node, Game game ) {
public static Entity decode( ParsedXML node, IGame game ) {
    public static Entity decode( ParsedXML node, Game game ) {        String attrStr = null;        int attrVal = 0;        Entity entity = null;        Coords coords = null;        Vector locations = new Vector();        ParsedXML pilotNode = null;        ParsedXML equipNode = null;        Enumeration children = null;        ParsedXML child = null;        String childName;        // Did we get a null node?        if ( null == node ) {            throw new IllegalArgumentException( "The entity is null." );        }        // Make sure that the node is for a Entity object.        if ( !node.getName().equals( "entity" ) ) {            throw new IllegalStateException( "Not passed a entity node." );        }        // TODO : perform version checking.        // Walk the entity node's children, finding bits for later parsing..        children = node.elements();        while ( children.hasMoreElements() ) {            child = (ParsedXML) children.nextElement();            childName = child.getName();            // Handle null child childNames.            if ( null == childName ) {                // No-op.            }            // Did we find the pilot node?            else if ( childName.equals( "pilot" ) ) {                // Save the entity's pilot for later decoding.                pilotNode = child;            } // End found-"entityEquipment"-node            // Did we find the entityData node?            else if ( childName.equals( "entityData" ) ) {                // Did we find the entity already?                if ( null != entity ) {                    throw new IllegalStateException                        ( "Found two entityData nodes for an Entity node." );                }                // Decode the entity data.                entity = EntityEncoder.decodeEntityData( child, game );            } // End found-"entityData"-node            // Did we find the entityEquipment node?            else if ( childName.equals( "entityEquipment" ) ) {                // Save the entity equipment for later decoding.                equipNode = child;            } // End found-"entityEquipment"-node            // Did we find the location node?            else if ( childName.equals( "location" ) ) {                // Save this location for later decoding.                locations.addElement( child );            } // End found-"location"-node        } // Look at the next child.        // Did we find the needed elements?        if ( null == entity ) {            throw new IllegalStateException                ( "Couldn't locate the entityData for an Entity node." );        }        else if ( null == pilotNode ) {            throw new IllegalStateException                ( "Couldn't locate the pilot for an Entity node." );        }        else if ( null == equipNode ) {            throw new IllegalStateException                ( "Couldn't locate the entityEquipment for an Entity node." );        }        else if ( locations.size() != entity.locations() ) {            StringBuffer msgBuf = new StringBuffer();            msgBuf.append( "Found " )                .append( locations.size() )                .append( " locations for an Entity node. " )                .append( "Was expecting to find " )                .append( entity.locations() )                .append( "." );            throw new IllegalStateException( msgBuf.toString() );        }        // Decode the entity node's chassis.        attrStr = node.getAttribute( "chassis" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the chassis from an Entity node." );        }        entity.setChassis( attrStr );        // Decode the entity node's model.        attrStr = node.getAttribute( "model" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the model from an Entity node." );        }        entity.setModel( attrStr );        // Decode the entity node's movement type.        attrStr = node.getAttribute( "typeVal" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the typeVal from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        entity.setMovementType( attrVal );        // Decode the entity node's year.        attrStr = node.getAttribute( "year" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the year from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        entity.setYear( attrVal );        // Decode the entity node's techBase.        attrStr = node.getAttribute( "techBase" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the techBase from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr.substring(0,1) );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr.substring(0,1) );        }        entity.setTechLevel( attrVal );        // Decode the entity node's mass.        attrStr = node.getAttribute( "mass" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the mass from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        entity.setWeight( attrVal );        // Decode the entity node's walkMp.        attrStr = node.getAttribute( "walkMp" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the walkMp from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        entity.setOriginalWalkMP( attrVal );        // Decode the entity node's jumpMp.        attrStr = node.getAttribute( "jumpMp" );        if ( null == attrStr ) {            throw new IllegalStateException                ( "Couldn't decode the jumpMp from an Entity node." );        }        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        entity.setOriginalJumpMP( attrVal );        // Try to pull the value from the string        try {            attrVal = Integer.parseInt( attrStr );        }        catch ( NumberFormatException exp ) {            throw new IllegalStateException                ( "Couldn't get an integer from " + attrStr );        }        // Decode the entity's pilot.        EntityEncoder.decodePilot( pilotNode, entity );        // Decode the entity's equipment.        EntityEncoder.decodeEntityEquipment( equipNode, entity );        // Decode the entity's locations.        children = locations.elements();        while ( children.hasMoreElements() ) {            child = (ParsedXML) children.nextElement();            EntityEncoder.decodeLocation( child, entity );        }        return entity;    }