コード例 #1
0
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    this.colony = xr.getAttribute(getGame(), COLONY_TAG, Colony.class, (Colony) null);

    this.demanded = xr.getAttribute(DEMANDED_TAG, false);
  }
コード例 #2
0
ファイル: ProductionType.java プロジェクト: vardars/FreeCol
  /** {@inheritDoc} */
  @Override
  public void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    // ProductionType does not need an id.
    // No need for: super.readAttributes(in);
    // FIXME: as soon as we allow the user to select a production type,
    // we will need an id

    unattended = xr.getAttribute(UNATTENDED_TAG, false);

    productionLevel = xr.getAttribute(PRODUCTION_LEVEL_TAG, (String) null);
    // @compat 0.11.3
    if (productionLevel == null) {
      productionLevel = xr.getAttribute(OLD_PRODUCTION_LEVEL_TAG, (String) null);
    }
    // end @compat 0.11.3
  }
コード例 #3
0
ファイル: Wish.java プロジェクト: vardars/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    final AIMain aiMain = getAIMain();

    destination = xr.getLocationAttribute(aiMain.getGame(), DESTINATION_TAG, false);

    // Delegate transportable one level down
  }
コード例 #4
0
ファイル: SettlementType.java プロジェクト: Thue/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    // Clear containers.
    if (xr.shouldClearContainers()) {
      plunder = null;
      gifts = null;
    }

    super.readChildren(xr);
  }
コード例 #5
0
ファイル: IndianSettlement.java プロジェクト: vardars/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    final Specification spec = getSpecification();

    lastTribute = xr.getAttribute(LAST_TRIBUTE_TAG, 0);

    convertProgress = xr.getAttribute(CONVERT_PROGRESS_TAG, 0);

    learnableSkill = xr.getType(spec, LEARNABLE_SKILL_TAG, UnitType.class, (UnitType) null);

    mostHated =
        xr.findFreeColGameObject(getGame(), MOST_HATED_TAG, Player.class, (Player) null, false);

    for (int i = 0; i < wantedGoods.length; i++) {
      wantedGoods[i] = xr.getType(spec, WANTED_GOODS_TAG + i, GoodsType.class, (GoodsType) null);
    }
  }
コード例 #6
0
ファイル: SettlementType.java プロジェクト: Thue/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (GIFTS_TAG.equals(tag)) {
      addGift(new RandomRange(xr));

    } else if (PLUNDER_TAG.equals(tag)) {
      addPlunder(new RandomRange(xr));

    } else {
      super.readChild(xr);
    }
  }
コード例 #7
0
ファイル: Limit.java プロジェクト: Thue/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (LEFT_HAND_SIDE_TAG.equals(tag)) {
      leftHandSide = new Operand(xr);

    } else if (RIGHT_HAND_SIDE_TAG.equals(tag)) {
      rightHandSide = new Operand(xr);

    } else {
      super.readChild(xr);
    }
  }
コード例 #8
0
ファイル: ProductionType.java プロジェクト: vardars/FreeCol
  /** {@inheritDoc} */
  @Override
  public void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final Specification spec = getSpecification();
    final String tag = xr.getLocalName();

    if (INPUT_TAG.equals(tag)) {
      GoodsType type = xr.getType(spec, GOODS_TYPE_TAG, GoodsType.class, (GoodsType) null);
      addInput(type, xr.getAttribute(VALUE_TAG, -1));
      xr.closeTag(INPUT_TAG);

    } else if (OUTPUT_TAG.equals(tag)) {
      GoodsType type = xr.getType(spec, GOODS_TYPE_TAG, GoodsType.class, (GoodsType) null);
      addOutput(type, xr.getAttribute(VALUE_TAG, -1));
      xr.closeTag(OUTPUT_TAG);

    } else {
      super.readChild(xr);
    }
  }
コード例 #9
0
ファイル: SettlementType.java プロジェクト: Thue/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    capital = xr.getAttribute(CAPITAL_TAG, capital);

    minimumSize = xr.getAttribute(MINIMUM_SIZE_TAG, minimumSize);

    maximumSize = xr.getAttribute(MAXIMUM_SIZE_TAG, maximumSize);

    visibleRadius = xr.getAttribute(VISIBLE_RADIUS_TAG, visibleRadius);

    claimableRadius = xr.getAttribute(CLAIMABLE_RADIUS_TAG, claimableRadius);

    extraClaimableRadius = xr.getAttribute(EXTRA_CLAIMABLE_RADIUS_TAG, extraClaimableRadius);

    wanderingRadius = xr.getAttribute(WANDERING_RADIUS_TAG, wanderingRadius);

    minimumGrowth = xr.getAttribute(MINIMUM_GROWTH_TAG, minimumGrowth);

    maximumGrowth = xr.getAttribute(MAXIMUM_GROWTH_TAG, maximumGrowth);

    tradeBonus = xr.getAttribute(TRADE_BONUS_TAG, tradeBonus);

    convertThreshold = xr.getAttribute(CONVERT_THRESHOLD_TAG, convertThreshold);
  }
コード例 #10
0
ファイル: Limit.java プロジェクト: Thue/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    operator = xr.getAttribute(OPERATOR_TAG, Operator.class, (Operator) null);
  }
コード例 #11
0
ファイル: FreeColAction.java プロジェクト: Thue/FreeCol
 /**
  * Initialize this object from an XML-representation of this object.
  *
  * @param xr The <code>FreeColXMLReader</code> to read from.
  * @throws XMLStreamException if a problem was encountered during parsing.
  */
 public void readFromXML(FreeColXMLReader xr) throws XMLStreamException {
   // id is hard-wired
   String acc = xr.getAttribute(ACCELERATOR_TAG, "");
   putValue(ACCELERATOR_KEY, ("".equals(acc)) ? null : KeyStroke.getKeyStroke(acc));
   xr.closeTag(getXMLElementTagName());
 }
コード例 #12
0
  /** {@inheritDoc} */
  @Override
  protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
    super.readAttributes(xr);

    target = xr.getLocationAttribute(getGame(), TARGET_TAG, false);
  }
コード例 #13
0
ファイル: IndianSettlement.java プロジェクト: vardars/FreeCol
  /** {@inheritDoc} */
  @Override
  protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final Game game = getGame();
    final String tag = xr.getLocalName();

    if (ALARM_TAG.equals(tag)) {
      Player player = xr.findFreeColGameObject(game, PLAYER_TAG, Player.class, (Player) null, true);
      // @compat 0.10.5
      if (getName() != null) {
        // Alarm used to imply contact, but only set contacted if
        // we also have a valid name for the settlement.
        setContacted(player);
      }
      // end @compat
      alarm.put(player, new Tension(xr.getAttribute(VALUE_TAG, 0)));
      xr.closeTag(ALARM_TAG);

    } else if (CONTACT_LEVEL_TAG.equals(tag)) {
      ContactLevel cl = xr.getAttribute(LEVEL_TAG, ContactLevel.class, ContactLevel.UNCONTACTED);
      Player player = xr.findFreeColGameObject(game, PLAYER_TAG, Player.class, (Player) null, true);
      contactLevels.put(player, cl);
      xr.closeTag(CONTACT_LEVEL_TAG);

      // @compat 0.10.5
    } else if (IS_VISITED_TAG.equals(tag)) {
      Player player = xr.findFreeColGameObject(game, PLAYER_TAG, Player.class, (Player) null, true);
      setScouted(player);
      xr.closeTag(IS_VISITED_TAG);
      // end @compat

    } else if (MISSIONARY_TAG.equals(tag)) {
      xr.nextTag();
      missionary = xr.readFreeColGameObject(game, Unit.class);
      missionary.setLocationNoUpdate(this);
      xr.closeTag(MISSIONARY_TAG);

      // @compat 0.10.1
    } else if (OLD_UNITS_TAG.equals(tag)) {
      while (xr.nextTag() != XMLStreamConstants.END_ELEMENT) {
        super.readChild(xr);
      }
      // end @compat

    } else if (OWNED_UNITS_TAG.equals(tag)) {
      Unit unit = xr.makeFreeColGameObject(game, ID_ATTRIBUTE_TAG, Unit.class, true);
      addOwnedUnit(unit);
      xr.closeTag(OWNED_UNITS_TAG);

    } else {
      super.readChild(xr);
    }
  }