Enumeration ammo = entity.getAmmo(); while ( ammo.hasMoreElements() ) {
for (Mounted mount : entity.getAmmo()) {
    private static String getLocString( Entity entity ) {        boolean isMech = entity instanceof Mech;        StringBuffer output = new StringBuffer();        // Walk through the locations for the entity,        // and only record damage and ammo.        for ( int loc = 0; loc < entity.locations(); loc++ ) {            // Add this location to the output string.            output.append( "<location index=\"" );            output.append( String.valueOf(loc) );            output.append( "\"> " );            // Record values of armor and internal structure,            // unless the section never has armor.            if ( entity.getOInternal(loc) != IArmorState.ARMOR_NA ) {                output.append( "<armor points=\"" );                output.append( String.valueOf(entity.getArmor(loc)) );                output.append( "\"/>" );                output.append( "<armor points=\"" );                output.append( String.valueOf(entity.getInternal(loc)) );                output.append( "\" type=\"Internal\"/>" );                if ( entity.hasRearArmor(loc) ) {                    output.append( "<armor points=\"" );                    output.append(String.valueOf(entity.getArmor(loc, true)));                    output.append( "\" type=\"Rear\"/>" );                }            }            // Walk through the slots in this location.            for ( int loop = 0; loop < entity.getNumberOfCriticals(loc);                  loop++ ) {                // Get this slot.                CriticalSlot slot = entity.getCritical( loc, loop );                // Did we get a slot?                if ( null == slot ) {                    // Nope.  Record missing actuators on Biped Mechs.                    if ( isMech && !entity.entityIsQuad() &&                         ( loc == Mech.LOC_RARM || loc == Mech.LOC_LARM ) &&                         ( loop == 2 || loop == 3 ) ) {                        output.append( "<slot index=\"" );                        output.append( String.valueOf(loop+1) );                        output.append( "\" type=\"Empty\"/>" );                    }                } else {                    // Yup.  If the equipment isn't a system, get it.                    Mounted mount = null;                    if ( CriticalSlot.TYPE_EQUIPMENT == slot.getType() ) {                        mount = entity.getEquipment( slot.getIndex() );                    }                    // Format the slot.                    output.append( formatSlot( slot, mount ) );                } // End have-slot            } // Check the next slot in this location            // Tanks don't have slots, and Protomechs only have            // system slots, so we have to handle their ammo specially.            if ( entity instanceof Tank ||                 entity instanceof Protomech ) {                Enumeration ammo = entity.getAmmo();                while ( ammo.hasMoreElements() ) {                    // Is this ammo in the current location?                    Mounted mount = (Mounted) ammo.nextElement();                    if ( mount.getLocation() == loc ) {                        output.append( "<slot index=\"N/A\" type=\"" );                        output.append( mount.getType().getInternalName() );                        output.append( "\" shots=\"" );                        output.append( String.valueOf(mount.getShotsLeft()) );                        output.append( "\"/>" );                    }                } // Check the next ammo.            } // End is-tank-or-proto            // Finish off the location            output.append( "</location>" );        } // Handle the next location        // Convert the output into a String and return it.        return output.toString();    } // End private static String getLocString( Entity )