Ejemplo n.º 1
0
    @Override
    public void marshal(
        Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
      ResultsXML results = (ResultsXML) source;

      for (IAdminResponse response : results.getResponses()) {
        if (response.getClass().equals(TileXML.class)) {
          Tile tile = ((TileXML) response).getTile();
          if (tile.isNull()) {
            throw new RuntimeException("Should not enter into this case");
          } else {
            writer.startNode(Constants.TAG_TILE);
            writer.addAttribute(Constants.ATTRIBUTE_TILE_C0, tile.getColor0().name());
            writer.addAttribute(Constants.ATTRIBUTE_TILE_C1, tile.getColor1().name());
          }
          writer.endNode();
        } else if (response.getClass().equals(FalseXML.class)) {
          writer.startNode(Constants.TAG_FALSE);
          writer.endNode();
        } else if (response.getClass().equals(RerackXML.class)) {
          writer.startNode(Constants.TAG_RERACK);
          context.convertAnother(response);
          writer.endNode();
        }
      }

      if (results.isBad()) {
        writer.startNode(Constants.TAG_BAD);
        writer.addAttribute(Constants.TAG_REASON, results.getBad());
        writer.endNode();
      }
    }
Ejemplo n.º 2
0
 @Override
 public void marshal(
     Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
   TileXML tileXML = (TileXML) source;
   Tile tile = tileXML.getTile();
   if (!tile.isNull()) {
     writer.addAttribute(Constants.ATTRIBUTE_TILE_C0, tile.getColor0().name());
     writer.addAttribute(Constants.ATTRIBUTE_TILE_C1, tile.getColor1().name());
   } else new RuntimeException("Can't Marshal a null tile");
 }