本文整理汇总了Java中net.sf.freecol.common.io.FreeColXMLReader.readFreeColObject方法的典型用法代码示例。如果您正苦于以下问题:Java FreeColXMLReader.readFreeColObject方法的具体用法?Java FreeColXMLReader.readFreeColObject怎么用?Java FreeColXMLReader.readFreeColObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.io.FreeColXMLReader
的用法示例。
在下文中一共展示了FreeColXMLReader.readFreeColObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LootCargoMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code LootCargoMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public LootCargoMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, WINNER_TAG, LOSER_TAG);
List<Goods> goods = new ArrayList<>();
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (Goods.TAG.equals(tag)) {
if (goods == null) {
Goods g = xr.readFreeColObject(game, Goods.class);
if (g != null) goods.add(g);
} else {
expected(TAG, tag);
}
} else {
expected(Goods.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
appendChildren(goods);
}
示例2: ErrorMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code ErrorMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public ErrorMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, MESSAGE_TAG);
StringTemplate template = null;
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (StringTemplate.TAG.equals(tag)) {
if (template == null) {
template = xr.readFreeColObject(game, StringTemplate.class);
} else {
expected(TAG, tag);
}
} else {
expected(StringTemplate.TAG, tag);
}
}
xr.expectTag(TAG);
appendChild(template);
}
示例3: MonarchActionMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code MonarchActionMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public MonarchActionMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, ACTION_TAG, MONARCH_TAG, TAX_TAG, RESULT_TAG);
StringTemplate template = null;
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (StringTemplate.TAG.equals(tag)) {
if (template == null) {
template = xr.readFreeColObject(game, StringTemplate.class);
} else {
expected(TAG, tag);
}
} else {
expected(StringTemplate.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
appendChild(template);
}
示例4: DeliverGiftMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code DeliverGiftMessage} from stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there a problem reading the stream.
*/
public DeliverGiftMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, UNIT_TAG, SETTLEMENT_TAG);
Goods goods = null;
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (Goods.TAG.equals(tag)) {
if (goods == null) {
goods = xr.readFreeColObject(game, Goods.class);
} else {
expected(TAG, tag);
}
} else {
expected(Goods.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
appendChild(goods);
}
示例5: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
final Game game = getGame();
final String tag = xr.getLocalName();
if (Region.TAG.equals(tag)) {
addRegion(xr.readFreeColObject(game, Region.class));
} else if (Tile.TAG.equals(tag)) {
Tile t = xr.readFreeColObject(game, Tile.class);
setTile(t);
} else {
super.readChild(xr);
}
}
示例6: AnimateAttackMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code AnimateAttackMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public AnimateAttackMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, ATTACKER_TAG, ATTACKER_TILE_TAG,
DEFENDER_TAG, DEFENDER_TILE_TAG, SUCCESS_TAG);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
List<Unit> units = new ArrayList<>();
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (Unit.TAG.equals(tag)) {
Unit u = xr.readFreeColObject(game, Unit.class);
if (u != null) units.add(u);
} else {
expected(Unit.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChildren(units);
}
示例7: AddPlayerMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code AddPlayerMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public AddPlayerMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG);
this.destination = null;
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
List<Player> players = new ArrayList<>();
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (Player.TAG.equals(tag)) {
Player p = xr.readFreeColObject(game, Player.class);
if (p != null) players.add(p);
} else {
expected(Player.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChildren(players);
}
示例8: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
final Specification spec = getSpecification();
final Game game = getGame();
final String tag = xr.getLocalName();
// @compat 0.11.0
if (OLD_EQUIPMENT_TAG.equals(tag)) {
xr.swallowTag(OLD_EQUIPMENT_TAG);
// end @compat 0.11.0
} else if (TileImprovement.TAG.equals(tag)
// @compat 0.11.3
|| OLD_TILE_IMPROVEMENT_TAG.equals(tag)
// end @compat 0.11.3
) {
workImprovement = xr.readFreeColObject(game, TileImprovement.class);
} else {
super.readChild(xr);
}
}
示例9: UpdateMapGeneratorOptionsMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code UpdateMapGeneratorOptionsMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public UpdateMapGeneratorOptionsMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
this(null);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
OptionGroup optionGroup = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (OptionGroup.TAG.equals(tag)) {
if (optionGroup == null) {
optionGroup = xr.readFreeColObject(game, OptionGroup.class);
} else {
expected(TAG, tag);
}
} else {
expected(OptionGroup.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(optionGroup);
}
示例10: SetGoodsLevelsMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code SetGoodsLevelsMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public SetGoodsLevelsMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, COLONY_TAG);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
ExportData data = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (ExportData.TAG.equals(tag)) {
if (data == null) {
data = xr.readFreeColObject(game, ExportData.class);
} else {
expected(TAG, tag);
}
} else {
expected(ExportData.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(data);
}
示例11: DiplomacyMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code DiplomacyMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
*/
public DiplomacyMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, OUR_ID_TAG, OTHER_ID_TAG);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
DiplomaticTrade agreement = null;
Unit extraUnit = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (DiplomaticTrade.TAG.equals(tag)) {
if (agreement == null) {
agreement = xr.readFreeColObject(game, DiplomaticTrade.class);
} else {
expected(TAG, tag);
}
} else if (Unit.TAG.equals(tag)) {
if (extraUnit == null) {
extraUnit = xr.readFreeColObject(game, Unit.class);
} else {
expected(TAG, tag);
}
} else {
expected((agreement == null) ? DiplomaticTrade.TAG : Unit.TAG,
tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(agreement);
appendChild(extraUnit);
}
示例12: UpdateTradeRouteMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code UpdateTradeRouteMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public UpdateTradeRouteMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
this(null);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
TradeRoute tradeRoute = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (TradeRoute.TAG.equals(tag)) {
if (tradeRoute == null) {
tradeRoute = xr.readFreeColObject(game, TradeRoute.class);
} else {
expected(TAG, tag);
}
} else {
expected(TradeRoute.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(tradeRoute);
}
示例13: NativeTradeMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code NativeTradeMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public NativeTradeMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, ACTION_TAG);
NativeTrade nt = null;
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (NativeTrade.TAG.equals(tag)) {
if (nt == null) {
nt = xr.readFreeColObject(game, NativeTrade.class);
} else {
expected(TAG, tag);
}
} else {
expected(NativeTrade.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(nt);
}
示例14: AnimateMoveMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code AnimateMoveMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public AnimateMoveMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
super(TAG, xr, NEW_TILE_TAG, OLD_TILE_TAG, UNIT_TAG);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
Unit unit = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (Unit.TAG.equals(tag)) {
if (unit == null) {
unit = xr.readFreeColObject(game, Unit.class);
} else {
expected(TAG, tag);
}
} else {
expected(Unit.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(unit);
}
示例15: UpdateGameOptionsMessage
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Create a new {@code UpdateGameOptionsMessage} from a stream.
*
* @param game The {@code Game} this message belongs to.
* @param xr The {@code FreeColXMLReader} to read from.
* @exception XMLStreamException if there is a problem reading the stream.
*/
public UpdateGameOptionsMessage(Game game, FreeColXMLReader xr)
throws XMLStreamException {
this(null);
FreeColXMLReader.ReadScope rs
= xr.replaceScope(FreeColXMLReader.ReadScope.NOINTERN);
OptionGroup optionGroup = null;
try {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (OptionGroup.TAG.equals(tag)) {
if (optionGroup == null) {
optionGroup = xr.readFreeColObject(game, OptionGroup.class);
} else {
expected(TAG, tag);
}
} else {
expected(OptionGroup.TAG, tag);
}
xr.expectTag(tag);
}
xr.expectTag(TAG);
} finally {
xr.replaceScope(rs);
}
appendChild(optionGroup);
}