本文整理汇总了Java中net.sf.freecol.common.io.FreeColXMLReader.nextTag方法的典型用法代码示例。如果您正苦于以下问题:Java FreeColXMLReader.nextTag方法的具体用法?Java FreeColXMLReader.nextTag怎么用?Java FreeColXMLReader.nextTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.io.FreeColXMLReader
的用法示例。
在下文中一共展示了FreeColXMLReader.nextTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readChild
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void readChild(FreeColXMLReader xr) throws XMLStreamException {
final String tag = xr.getLocalName();
switch (tag) {
case TEMPLATE_TAG:
xr.nextTag();
template = readChildOption(xr);
xr.closeTag(TEMPLATE_TAG);
break;
default:
try {
AbstractOption<T> op = readChildOption(xr);
if (op != null) addMember(op);
} catch (XMLStreamException xse) {
logger.log(Level.WARNING, "Invalid option at: " + tag, xse);
xr.closeTag(tag);
}
break;
}
}
示例2: getMission
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Returns a new Mission read from the input stream if possible,
* and null if not.
*
* @param game a {@code Game} value
* @param xr a {@code FreeColXMLReader} value
* @return a {@code Mission} value
* @exception XMLStreamException if an error occurs
*/
public static Mission getMission(Game game,
FreeColXMLReader xr) throws XMLStreamException {
String tag = xr.getLocalName();
Constructor<? extends Mission> c = missionMap.get(tag);
if (c == null) {
logger.warning("Unknown type of mission: '" + tag + "'.");
xr.nextTag();
return null;
} else {
try {
return c.newInstance(game, xr);
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to instatiate mission with tag: "
+ tag, e);
return null;
}
}
}
示例3: readFromXML
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
private static void readFromXML(FreeColXMLReader xr) throws XMLStreamException {
while (xr.moreTags()) {
String tag = xr.getLocalName();
if (null != tag) switch (tag) {
case VERSION_TAG:
xr.nextTag();
break;
case GENERATION_TAG:
xr.nextTag();
break;
case PLURALS_TAG:
while (xr.moreTags()) {
tag = xr.getLocalName();
if (PLURAL_RULES_TAG.equals(tag)) {
readChild(xr);
}
} break;
}
}
}
示例4: readAttributes
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void readAttributes(FreeColXMLReader xr) throws XMLStreamException {
super.readAttributes(xr);
final AIMain aiMain = getAIMain();
unit = xr.findFreeColGameObject(aiMain.getGame(), ID_ATTRIBUTE_TAG,
Unit.class, (Unit)null, true);
if (!unit.isInitialized()) {
xr.nextTag(); // Move off the opening <AIUnit> tag
throw new XMLStreamException("AIUnit for uninitialized Unit: "
+ unit.getId());
}
}
示例5: unserialize
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Unserialize from XML to a FreeColObject in this game.
*
* @param <T> The actual return type.
* @param xml The xml serialized version of an object.
* @param returnClass The expected object class.
* @return The unserialized object.
* @exception XMLStreamException if there are any problems reading from
* the stream.
*/
public <T extends FreeColObject> T unserialize(String xml,
Class<T> returnClass) throws XMLStreamException {
try {
FreeColXMLReader xr = new FreeColXMLReader(new StringReader(xml));
xr.nextTag();
T ret = newInstance(returnClass);
ret.readFromXML(xr);
return ret;
} catch (Exception ex) {
throw new XMLStreamException(ex);
}
}
示例6: readOption
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* General option reader routine.
*
* @param xr The {@code FreeColXMLReader} to read from.
* @return An option.
* @exception XMLStreamException on stream errors.
*/
protected AbstractOption readOption(FreeColXMLReader xr)
throws XMLStreamException {
final Specification spec = getSpecification();
final String tag = xr.getLocalName();
AbstractOption option = null;
if (ACTION_TAG.equals(tag)) {
// FIXME: load FreeColActions from client options?
// logger.finest("Skipping action " + xr.readId());
xr.nextTag();
} else if (AbstractUnitOption.TAG.equals(tag)) {
option = new AbstractUnitOption(spec);
} else if (AudioMixerOption.TAG.equals(tag)) {
option = new AudioMixerOption(spec);
} else if (BooleanOption.TAG.equals(tag)) {
option = new BooleanOption(spec);
} else if (FileOption.TAG.equals(tag)) {
option = new FileOption(spec);
} else if (IntegerOption.TAG.equals(tag)) {
option = new IntegerOption(spec);
} else if (LanguageOption.TAG.equals(tag)) {
option = new LanguageOption(spec);
} else if (ModListOption.TAG.equals(tag)) {
option = new ModListOption(spec);
} else if (ModOption.TAG.equals(tag)) {
option = new ModOption(spec);
} else if (OptionGroup.TAG.equals(tag)) {
option = new OptionGroup(spec);
} else if (PercentageOption.TAG.equals(tag)) {
option = new PercentageOption(spec);
} else if (RangeOption.TAG.equals(tag)) {
option = new RangeOption(spec);
} else if (SelectOption.TAG.equals(tag)) {
option = new SelectOption(spec);
} else if (StringOption.TAG.equals(tag)) {
option = new StringOption(spec);
} else if (UnitListOption.TAG.equals(tag)) {
option = new UnitListOption(spec);
} else if (UnitTypeOption.TAG.equals(tag)) {
option = new UnitTypeOption(spec);
} else if (TextOption.TAG.equals(tag)) {
option = new TextOption(spec);
} else {
logger.warning("Not an option type: " + tag);
xr.nextTag();
}
if (option != null) {
option.readFromXML(xr);
option.generateChoices();
}
return option;
}
示例7: load
import net.sf.freecol.common.io.FreeColXMLReader; //导入方法依赖的package包/类
/**
* Loads the options from the given reader.
*
* @param xr The {@code FreeColXMLReader} to read from.
* @return True if the options were loaded without error.
* @exception XMLStreamException if there is an error reading the stream.
*/
protected boolean load(FreeColXMLReader xr) throws XMLStreamException {
if (xr == null) return false;
xr.nextTag();
readFromXML(xr);
return true;
}