private void parseEntity(Element entityNode,Vector<Entity> list){
  Entity entity=null;
  String chassis=entityNode.getAttribute(CHASSIS);
  String model=entityNode.getAttribute(MODEL);
  entity=getEntity(chassis,model);
  if (entity == null) {
    warning.append("Failed to load entity!");
    return;
  }
  parseEntityAttributes(entity,entityNode);
  NodeList nl=entityNode.getChildNodes();
  for (int i=0; i < nl.getLength(); i++) {
    Node currNode=nl.item(i);
    if (currNode.getParentNode() != entityNode) {
      continue;
    }
    int nodeType=currNode.getNodeType();
    if (nodeType == Node.ELEMENT_NODE) {
      Element currEle=(Element)currNode;
      String nodeName=currNode.getNodeName();
      if (nodeName.equalsIgnoreCase(PILOT)) {
        parsePilot(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(LOCATION)) {
        parseLocation(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(MOVEMENT)) {
        parseMovement(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(TURRETLOCK)) {
        parseTurretLock(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(TURRET2LOCK)) {
        parseTurret2Lock(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(SI)) {
        parseSI(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(HEAT)) {
        parseHeat(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(FUEL)) {
        parseFuel(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(KF)) {
        parseKF(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(SAIL)) {
        parseSail(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(AEROCRIT)) {
        parseAeroCrit(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(TANKCRIT)) {
        parseTankCrit(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(BOMBS)) {
        parseBombs(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(C3I)) {
        parseC3I(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(BA_MEA)) {
        parseBAMEA(currEle,entity);
      }
 else       if (nodeName.equalsIgnoreCase(BA_APM)) {
        parseBAAPM(currEle,entity);
      }
    }
 else {
      continue;
    }
  }
  list.add(entity);
}

private void parseEntity ( Element entityNode , Vector < Entity > list ) { Entity entity = null ; String chassis = entityNode . getAttribute ( CHASSIS ) ; String model = entityNode . getAttribute ( MODEL ) ; entity = getEntity ( chassis , model ) ; if ( entity == null ) { warning . append ( "Failed to load entity!" ) ; return ; } parseEntityAttributes ( entity , entityNode ) ; NodeList nl = entityNode . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node currNode = nl . item ( i ) ; if ( currNode . getParentNode ( ) != entityNode ) { continue ; } int nodeType = currNode . getNodeType ( ) ; if ( nodeType == Node . ELEMENT_NODE ) { Element currEle = ( Element ) currNode ; String nodeName = currNode . getNodeName ( ) ; if ( nodeName . equalsIgnoreCase ( PILOT ) ) { parsePilot ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( LOCATION ) ) { parseLocation ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( MOVEMENT ) ) { parseMovement ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( TURRETLOCK ) ) { parseTurretLock ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( TURRET2LOCK ) ) { parseTurret2Lock ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( SI ) ) { parseSI ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( HEAT ) ) { parseHeat ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( FUEL ) ) { parseFuel ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( KF ) ) { parseKF ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( SAIL ) ) { parseSail ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( AEROCRIT ) ) { parseAeroCrit ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( TANKCRIT ) ) { parseTankCrit ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( BOMBS ) ) { parseBombs ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( C3I ) ) { parseC3I ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( BA_MEA ) ) { parseBAMEA ( currEle , entity ) ; } else if ( nodeName . equalsIgnoreCase ( BA_APM ) ) { parseBAAPM ( currEle , entity ) ; } } else { continue ; } } list . add ( entity ) ; }
parse an entity tag . entity tags will have a number of attributes such as model , chassis , type , etc . they should also have a child pilot tag and they may also contain some number of location tags .
