/* (non-Javadoc)
   * @see pcgen.persistence.lst.GameModeLstToken#parse(pcgen.core.GameMode, java.lang.String, java.net.URI)
   */
  @Override
  public boolean parse(GameMode gameMode, String value, URI source) {
    final StringTokenizer aTok = new StringTokenizer(value, "|", false);

    if (aTok.countTokens() < 2) {
      Logging.log(
          Logging.LST_ERROR,
          getTokenName() + " expecting '|', format is: " + "EquipType|IconPath was: " + value);
      return false;
    }

    if (aTok.countTokens() > 3) {
      Logging.log(
          Logging.LST_ERROR,
          getTokenName()
              + " too many '|', format is: "
              + "EquipType|IconPath|Priority was: "
              + value);
      return false;
    }

    final String equipType = aTok.nextToken();
    final String iconPath = aTok.nextToken();
    int priority = 10;
    if (aTok.hasMoreElements()) {
      String priorityToken = aTok.nextToken();
      try {
        priority = Integer.parseInt(priorityToken);
      } catch (NumberFormatException ex) {
        Logging.log(
            Logging.LST_ERROR,
            getTokenName()
                + " expected an integer priority .  Found: "
                + priorityToken
                + " in "
                + value);
        return false;
      }
    }

    gameMode.setEquipTypeIcon(equipType.intern(), iconPath.intern(), priority);
    return true;
  }