Package megamek.common.loaders
Class MULParser
java.lang.Object
megamek.common.loaders.MULParser
Class for reading in and parsing MUL XML files. The MUL xsl is defined in the docs' directory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe names of attributes generally associated with Entity tagsstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe current (damage-lowered) Destroy Check of a Battlefield Support Asset.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDistinguishes alternate entity forms that can share the same chassis/model name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe names of the attributes recognized by this parser.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe unit-file UUID.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe names of the various elements recognized by this parser.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringSpecial values recognized by this parser.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionMULParser(File file, GameOptions options) This is the standard MULParser constructor for a file.MULParser(InputStream is, GameOptions options) This is provided for unit testing only, and should not be part of general parsing.MULParser(Element element, GameOptions options) This is the standard MULParser constructor for a single element. -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of all the allied Entity's parsed from the input, should be called afterparse.Returns a list of all the devastated Entity's parsed from the input, should be called afterparse.Returns a list of all the Entity's parsed from the input, should be called afterparse.getKills()Returns the kills hashtableReturns a list of all the Pilots parsed from the input, should be called afterparse.Returns a list of all the enemy retreated entities parsed from the input, should be called afterparse.Returns a list of all the salvaged Entity's parsed from the input, should be called afterparse.Returns a list of all the salvaged Entity's parsed from the input, should be called afterparse.Get the warning message from the last parse.booleanDetermine if unexpected XML entities were encountered during parsing.booleanboolean
-
Field Details
-
VERSION
- See Also:
-
ELE_RECORD
The names of the various elements recognized by this parser.- See Also:
-
ELE_SURVIVORS
- See Also:
-
ELE_ALLIES
- See Also:
-
ELE_SALVAGE
- See Also:
-
ELE_RETREATED
- See Also:
-
ELE_DEVASTATED
- See Also:
-
ELE_UNIT
- See Also:
-
ELE_ENTITY
- See Also:
-
ELE_PILOT
- See Also:
-
ELE_CREW
- See Also:
-
ELE_CREWMEMBER
- See Also:
-
ELE_KILLS
- See Also:
-
ELE_KILL
- See Also:
-
ELE_LOCATION
- See Also:
-
ELE_ARMOR
- See Also:
-
ELE_SLOT
- See Also:
-
ELE_MOTIVE
- See Also:
-
ELE_TURRET_LOCK
- See Also:
-
ELE_SI
- See Also:
-
ELE_HEAT
- See Also:
-
ELE_FUEL
- See Also:
-
ELE_KF
- See Also:
-
ELE_SAIL
- See Also:
-
ELE_AERO_CRIT
- See Also:
-
ELE_DROP_CRIT
- See Also:
-
ELE_TANK_CRIT
- See Also:
-
ELE_STABILIZER
- See Also:
-
ELE_BREACH
- See Also:
-
ELE_BLOWN_OFF
- See Also:
-
ELE_C3I
- See Also:
-
ELE_C3I_LINK
- See Also:
-
ELE_NC3
- See Also:
-
ELE_NC3LINK
- See Also:
-
ELE_ESCAPE_CRAFT
- See Also:
-
ELE_ESCAPE_CREW
- See Also:
-
ELE_ESCAPE_PASSENGERS
- See Also:
-
ELE_ORIG_PODS
- See Also:
-
ELE_ORIG_MEN
- See Also:
-
ELE_CONVEYANCE
- See Also:
-
ELE_TOWED_UNITS
- See Also:
-
ELE_TOWED_UNIT
- See Also:
-
ELE_GAME
- See Also:
-
ELE_FORCE
- See Also:
-
ELE_BAY
- See Also:
-
ELE_BAY_DOORS
- See Also:
-
ELE_BAY_DAMAGE
- See Also:
-
ELE_BOMBS
- See Also:
-
ELE_BOMB
- See Also:
-
ELE_BA_MEA
- See Also:
-
ELE_BA_APM
- See Also:
-
ELE_LOADED
- See Also:
-
ELE_SHIP
- See Also:
-
ELE_CONSTRUCTION_DATA
- See Also:
-
ATTR_CHASSIS
The names of attributes generally associated with Entity tags- See Also:
-
ATTR_MODEL
- See Also:
-
ATTR_CAMO_CATEGORY
- See Also:
-
ATTR_CAMO_FILENAME
- See Also:
-
ATTR_CAMO_ROTATION
- See Also:
-
ATTR_CAMO_SCALE
- See Also:
-
ATTR_CAMO_OVERLAY_STYLE
- See Also:
-
ATTR_CAMO_OVERLAY_DIRECTION
- See Also:
-
ATTR_CAMO_OVERLAY_COLOR
- See Also:
-
ATTR_NAME
The names of the attributes recognized by this parser. Not every attribute is valid for every element.- See Also:
-
ATTR_SIZE
- See Also:
-
ATTR_EXT_ID
- See Also:
-
ATTR_PICKUP_ID
- See Also:
-
ATTR_CLAN_PILOT
- See Also:
-
ATTR_NICK
- See Also:
-
ATTR_GENDER
- See Also:
-
ATTR_CAT_PORTRAIT
- See Also:
-
ATTR_FILE_PORTRAIT
- See Also:
-
ATTR_GUNNERY
- See Also:
-
ATTR_GUNNERY_L
- See Also:
-
ATTR_GUNNERY_M
- See Also:
-
ATTR_GUNNERY_B
- See Also:
-
ATTR_PILOTING
- See Also:
-
ATTR_ARTILLERY
- See Also:
-
ATTR_TOUGH
- See Also:
-
ATTR_FATIGUE
- See Also:
-
ATTR_INIT_B
- See Also:
-
ATTR_COMMAND_B
- See Also:
-
ATTR_HITS
- See Also:
-
ATTR_ADVANTAGES
- See Also:
-
ATTR_EDGE
- See Also:
-
ATTR_IMPLANTS
- See Also:
-
ATTR_EI_IMPLANTS
- See Also:
-
ATTR_EI_MODE
- See Also:
-
ATTR_PROSTHETIC_ENHANCEMENT_1
- See Also:
-
ATTR_PROSTHETIC_ENHANCEMENT_1_COUNT
- See Also:
-
ATTR_PROSTHETIC_ENHANCEMENT_2
- See Also:
-
ATTR_PROSTHETIC_ENHANCEMENT_2_COUNT
- See Also:
-
ATTR_QUIRKS
- See Also:
-
ATTR_TROOPER_MISS
- See Also:
-
ATTR_DRIVER
- See Also:
-
ATTR_COMMANDER
- See Also:
-
ATTR_OFFBOARD
- See Also:
-
ATTR_OFFBOARD_DISTANCE
- See Also:
-
ATTR_OFFBOARD_DIRECTION
- See Also:
-
ATTR_HIDDEN
- See Also:
-
ATTR_DEPLOYMENT
- See Also:
-
ATTR_DEPLOYMENT_ZONE
- See Also:
-
ATTR_DEPLOYMENT_ZONE_WIDTH
- See Also:
-
ATTR_DEPLOYMENT_ZONE_OFFSET
- See Also:
-
ATTR_DEPLOYMENT_ZONE_ANY_NWX
- See Also:
-
ATTR_DEPLOYMENT_ZONE_ANY_NWY
- See Also:
-
ATTR_DEPLOYMENT_ZONE_ANY_SEX
- See Also:
-
ATTR_DEPLOYMENT_ZONE_ANY_SEY
- See Also:
-
ATTR_NEVER_DEPLOYED
- See Also:
-
ATTR_UNIT_FILE_UUID
The unit-file UUID. Written for every unit that has one and used as the primary lookup on load (the chassis and model remain for backwards-compatibility and readability). It is essential for Battlefield Support Assets, which share a name with their base unit.- See Also:
-
ATTR_ENTITY_FORM
Distinguishes alternate entity forms that can share the same chassis/model name.- See Also:
-
ATTR_DESTROY_CHECK
The current (damage-lowered) Destroy Check of a Battlefield Support Asset.- See Also:
-
ATTR_VELOCITY
- See Also:
-
ATTR_ALTITUDE
- See Also:
-
ATTR_ELEVATION
- See Also:
-
ATTR_AUTO_EJECT
- See Also:
-
ATTR_COND_EJECT_AMMO
- See Also:
-
ATTR_COND_EJECT_ENGINE
- See Also:
-
ATTR_COND_EJECT_CT_DEST
- See Also:
-
ATTR_COND_EJECT_HEAD_SHOT
- See Also:
-
ATTR_DIC_DISABLED
- See Also:
-
ATTR_EJECTED
- See Also:
-
ATTR_INDEX
- See Also:
-
ATTR_IS_DESTROYED
- See Also:
-
ATTR_IS_REPAIRABLE
- See Also:
-
ATTR_ARMOR_HIT
- See Also:
-
ATTR_POINTS
- See Also:
-
ATTR_TYPE
- See Also:
-
ATTR_SHOTS
- See Also:
-
ATTR_CAPACITY
- See Also:
-
ATTR_IS_HIT
- See Also:
-
ATTR_MUNITION
- See Also:
-
ATTR_STANDARD
- See Also:
-
ATTR_INFERNO
- See Also:
-
ATTR_DIRECTION
- See Also:
-
ATTR_INTEGRITY
- See Also:
-
ATTR_SINK
- See Also:
-
ATTR_LEFT
- See Also:
-
ATTR_AVIONICS
- See Also:
-
ATTR_SENSORS
- See Also:
-
ATTR_ENGINE
- See Also:
-
ATTR_FCS
- See Also:
-
ATTR_CIC
- See Also:
-
ATTR_LEFT_THRUST
- See Also:
-
ATTR_RIGHT_THRUST
- See Also:
-
ATTR_LIFE_SUPPORT
- See Also:
-
ATTR_GEAR
- See Also:
-
ATTR_DOCKING_COLLAR
- See Also:
-
ATTR_KF_BOOM
- See Also:
-
ATTR_WEAPONS_BAY_INDEX
- See Also:
-
ATTR_DAMAGE
- See Also:
-
ATTR_PENALTY
- See Also:
-
ATTR_C3_MASTER_IS
- See Also:
-
ATTR_C3UUID
- See Also:
-
ATTR_LOAD
- See Also:
-
ATTR_INTERNAL
- See Also:
-
ATTR_BA_APM_MOUNT_NUM
- See Also:
-
ATTR_BA_APM_TYPE_NAME
- See Also:
-
ATTR_BA_MEA_MOUNT_LOC
- See Also:
-
ATTR_BA_MEA_TYPE_NAME
- See Also:
-
ATTR_KILLED
- See Also:
-
ATTR_KILLER
- See Also:
-
ATTR_DAMAGE_TAKEN
- See Also:
-
ATTR_ARMOR_NAME
- See Also:
-
ATTR_ARMOR_DIVISOR
- See Also:
-
ATTR_ARMOR_ENC
- See Also:
-
ATTR_DEST_ARMOR
- See Also:
-
ATTR_SPACESUIT
- See Also:
-
ATTR_SNEAK_CAMO
- See Also:
-
ATTR_SNEAK_IR
- See Also:
-
ATTR_SNEAK_ECM
- See Also:
-
ATTR_INF_SPEC
- See Also:
-
ATTR_DISPOSABLE_WEAPON
- See Also:
-
ATTR_DISPOSABLE_WEAPON_FIRED
- See Also:
-
ATTR_INF_SQUAD_NUM
- See Also:
-
ATTR_RFMG
- See Also:
-
ATTR_LINK
- See Also:
-
ATTR_ID
- See Also:
-
ATTR_NUMBER
- See Also:
-
ATTR_FORCE
- See Also:
-
ATTR_SLOT
- See Also:
-
ATTR_IS_REAR
- See Also:
-
ATTR_IS_TURRETED
- See Also:
-
ATTR_IS_MISSING
- See Also:
-
ATTR_GUNNERY_AERO
- See Also:
-
ATTR_GUNNERY_AERO_L
- See Also:
-
ATTR_GUNNERY_AERO_M
- See Also:
-
ATTR_GUNNERY_AERO_B
- See Also:
-
ATTR_PILOTING_AERO
- See Also:
-
ATTR_CREW_TYPE
- See Also:
-
ATTR_FILENAME
- See Also:
-
VALUE_DEAD
Special values recognized by this parser.- See Also:
-
VALUE_NA
- See Also:
-
VALUE_DESTROYED
- See Also:
-
VALUE_REAR
- See Also:
-
VALUE_INTERNAL
- See Also:
-
VALUE_EMPTY
- See Also:
-
VALUE_SYSTEM
- See Also:
-
VALUE_NONE
- See Also:
-
VALUE_HIT
- See Also:
-
VALUE_CONSOLE
- See Also:
-
VALUE_SQUADRON
- See Also:
-
VALUE_BATTLEFIELD_SUPPORT_ASSET
- See Also:
-
-
Constructor Details
-
MULParser
This is the standard MULParser constructor for a file. It initializes the values to parse with, then parses the file using the provided options. The options may be null in cases when the crew is not to be loaded as part of the MUL.- Parameters:
file- the file to parse, or null if there isn't anything to parseoptions- the game options to parse the MUL with, which may be null (only to be used when the crew is not to be loaded, as no saved optional Crew-based values are loaded).- Throws:
Exception- if there is an issue with parsing the file
-
MULParser
This is provided for unit testing only, and should not be part of general parsing.- Parameters:
is- the input stream to parse fromoptions- the game options to parse the MUL with, which may be null (only to be used when the crew is not to be loaded, as no saved optional Crew-based values are loaded).- Throws:
Exception
-
MULParser
This is the standard MULParser constructor for a single element. It initializes the values to parse with, then parses the element using the provided options. The options may be null in cases when the crew is not to be loaded as part of the MUL.- Parameters:
element- the element to parseoptions- the game options to parse the MUL with, which may be null (only to be used when the crew is not to be loaded, as no saved optional Crew-based values are loaded).
-
-
Method Details
-
hasWarningMessage
public boolean hasWarningMessage()Determine if unexpected XML entities were encountered during parsing.- Returns:
trueif a non-fatal warning occurred.
-
getWarningMessage
Get the warning message from the last parse.- Returns:
- The
Stringwarning message from the last parse. If there is no warning message, then annullvalue is returned.
-
getFileVersion
- Returns:
- the MegaMek version this MUL was saved in, or
nullif the file did not carry a parseable version
-
isNewerVersion
public boolean isNewerVersion()- Returns:
- true if the MUL was saved in a MegaMek version newer than the one currently running. Such a file is never
loaded, so
getEntities()and the other result accessors will be empty.
-
isOlderVersion
public boolean isOlderVersion()- Returns:
- true if the MUL was saved in an older MegaMek version than the one currently running, or does not carry a parseable version. The file is still parsed, but correct behavior is not guaranteed.
-
getEntities
Returns a list of all the Entity's parsed from the input, should be called afterparse. This is for entities that we want to be loaded into the chat lounge, so functional -
getSurvivors
Returns a list of all the salvaged Entity's parsed from the input, should be called afterparse. -
getAllies
Returns a list of all the allied Entity's parsed from the input, should be called afterparse. -
getSalvage
Returns a list of all the salvaged Entity's parsed from the input, should be called afterparse. -
getRetreated
Returns a list of all the enemy retreated entities parsed from the input, should be called afterparse. -
getDevastated
Returns a list of all the devastated Entity's parsed from the input, should be called afterparse. -
getPilots
Returns a list of all the Pilots parsed from the input, should be called afterparse. -
getKills
Returns the kills hashtable
-