当前位置: 首页>>代码示例>>Java>>正文


Java WriteScope类代码示例

本文整理汇总了Java中net.sf.freecol.common.io.FreeColXMLWriter.WriteScope的典型用法代码示例。如果您正苦于以下问题:Java WriteScope类的具体用法?Java WriteScope怎么用?Java WriteScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WriteScope类属于net.sf.freecol.common.io.FreeColXMLWriter包,在下文中一共展示了WriteScope类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpTile

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * Debug action to dump a tile to stderr.
 *
 * Called from tile popup menu.
 * Not concerned with i18n for stderr output.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param tile The {@code Tile} to dump.
 */
public static void dumpTile(final FreeColClient freeColClient,
                            final Tile tile) {
    final FreeColServer server = freeColClient.getFreeColServer();
    final Game game = freeColClient.getGame();
    final Game sGame = server.getGame();
    final Player player = freeColClient.getMyPlayer();

    System.err.println("\nClient (" + game.getClientUserName()
        + "/" + player.getId() + "):");
    tile.save(System.err, WriteScope.toClient(player), true);
    System.err.println("\n\nServer:");
    Tile sTile = sGame.getFreeColGameObject(tile.getId(), Tile.class);
    sTile.save(System.err, WriteScope.toServer(), true);
    System.err.println("\n\nSave:");
    sTile.save(System.err, WriteScope.toSave(), true);
    System.err.println('\n');
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:27,代码来源:DebugUtils.java

示例2: writeChildren

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void writeChildren(FreeColXMLWriter xw) throws XMLStreamException {
    Tile spyTile = getSpyTile();
    if (spyTile != null) {
        FreeColXMLWriter.WriteScope ws = xw.getWriteScope();
        if (xw.getClientPlayer() != null) { // Override scope to client
            ws = xw.replaceScope(FreeColXMLWriter.WriteScope.toServer());
        }
        try {
            spyTile.toXML(xw);
        } finally {
            xw.replaceScope(ws);
        }
    }            
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:19,代码来源:SpySettlementMessage.java

示例3: save

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * Writes the object to the given output stream
 *
 * @param out The {@code OutputStream} to write to.
 * @param scope The {@code WriteScope} to use.
 * @param pretty Attempt to indent the output nicely.
 * @return True if the save proceeded without error.
 */
public boolean save(OutputStream out, WriteScope scope, boolean pretty) {
    boolean ret = false;
    if (scope == null) scope = FreeColXMLWriter.WriteScope.toSave();
    try (
        FreeColXMLWriter xw = new FreeColXMLWriter(out, scope, pretty);
    ) {
        xw.writeStartDocument("UTF-8", "1.0");

        this.toXML(xw);

        xw.writeEndDocument();

        ret = true;
    } catch (XMLStreamException xse) {
        logger.log(Level.WARNING, "Exception writing object.", xse);

    } catch (IOException ioe) {
        logger.log(Level.WARNING, "Error creating FreeColXMLWriter.", ioe);
    }
    return ret;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:30,代码来源:FreeColObject.java

示例4: serialize

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * Serialize this FreeColObject to a string, possibly partially.
 *
 * @param scope The write scope to use.
 * @param fields A list of field names, which if non-null indicates this
 *     should be a partial write.
 * @return The serialized object, or null if the stream could not be
 *     created.
 * @exception XMLStreamException if there are any problems writing
 *     to the stream.
 */
public String serialize(WriteScope scope, List<String> fields)
    throws XMLStreamException {
    StringWriter sw = new StringWriter();
    try (
        FreeColXMLWriter xw = new FreeColXMLWriter(sw, scope);
    ) {
        if (fields == null) {
            this.toXML(xw);
        } else {
            this.toXMLPartial(xw, fields);
        }
    } catch (IOException ioe) {
        logger.log(Level.WARNING, "Error creating FreeColXMLWriter,", ioe);
        return null;
    }

    return sw.toString();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:30,代码来源:FreeColObject.java

示例5: toXML

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void toXML(FreeColXMLWriter xw) throws XMLStreamException {
    FreeColXMLWriter.WriteScope ws = null;
    if (this.destination != null) {
        ws = xw.replaceScope(FreeColXMLWriter.WriteScope
            .toClient(this.destination));
    }
    super.toXML(xw);
    if (this.destination != null) xw.replaceScope(ws);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:UpdateMessage.java

示例6: dumpObject

import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; //导入依赖的package包/类
/**
 * Debugging tool, dump object XML to System.err.
 */
public void dumpObject() {
    save(System.err, WriteScope.toSave(), false);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:7,代码来源:FreeColObject.java


注:本文中的net.sf.freecol.common.io.FreeColXMLWriter.WriteScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。