List of usage examples for org.dom4j DocumentFactory getInstance
public static synchronized DocumentFactory getInstance()
From source file:fr.gouv.culture.vitam.writer.XmlWriter.java
License:Open Source License
/** * @param file/* w ww .j av a 2 s.c o m*/ * @param rootname */ public XmlWriter(File file, String rootname) { this.file = file; this.rootname = rootname; DocumentFactory factory = DocumentFactory.getInstance(); document = factory.createDocument(StaticValues.CURRENT_OUTPUT_ENCODING); Element root = factory.createElement(rootname); document.setRootElement(root); }
From source file:fr.gouv.culture.vitam.writer.XmlWriter.java
License:Open Source License
public void write() throws IOException { FileOutputStream out = new FileOutputStream(file); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(StaticValues.CURRENT_OUTPUT_ENCODING); XMLWriter writer = new XMLWriter(out, format); writer.write(document);// w w w. jav a 2 s . c o m writer.close(); out.close(); document.clearContent(); document = null; DocumentFactory factory = DocumentFactory.getInstance(); document = factory.createDocument(StaticValues.CURRENT_OUTPUT_ENCODING); Element root = factory.createElement(rootname); document.setRootElement(root); StaticValues.freeMemory(); }
From source file:fr.gouv.culture.vitam.writer.XmlWriter.java
License:Open Source License
public static void loadDbTableDataFromFile(DbSchema schema, DbTable table, Element etable) throws WaarpDatabaseSqlException, IOException { int read = 0; VitamReader reader = schema.identifier.getReader(); Element erows = DocumentFactory.getInstance().createElement("rows"); switch (table.type) { case CSVTYPE: { String[] values = null;/*from w ww .ja v a 2s . c om*/ // first row to ignore if (reader.readOneLine() != null) { int warning = 0; while ((values = reader.readOneLine()) != null) { read++; if (values.length != table.nbFields()) { logger.warn("Attention: nombre de champs insuffisant en ligne: " + (read + 1)); warning++; } addOneTableRow(table, values, read, 0, erows); } if (warning > 0) { logger.warn("Enregistrements lus: " + read + " Mal forms (CSV): " + warning); } } } break; case MULTIPLETYPE: { String[] values = null; while ((values = reader.readOneLine(table.rank)) != null) { read++; addOneTableRow(table, values, read, 1, erows); } } break; case UNIQUETYPE: { String[] values = null; while ((values = reader.readOneLine()) != null) { read++; addOneTableRow(table, values, read, 0, erows); } } break; } etable.add(erows); System.out.println("Enregistrements lues: " + read); }
From source file:gjset.client.ConcreteClientGUIController.java
License:Open Source License
/** * Construct a controller for the indicated player connected to the indicated model. * * @param client The client for communicating with the server. * @param localPlayer the Player object that represents the local player. *///ww w .ja v a 2 s . co m public ConcreteClientGUIController(ClientCommunicator client, PlayerData localPlayer) { documentFactory = DocumentFactory.getInstance(); model = new ClientGUIModel(); model.setLocalPlayer(localPlayer); gameStartTriggers = new Vector<Runnable>(); this.client = client; client.addMessageHandler(this); }
From source file:gjset.client.GameInitiator.java
License:Open Source License
/** * Create the game initiator. This will cause the client to connect to the server. Once the * connection is complete, the initiator will verify communication parameters, register a player, * and start the game.// w ww . j a va2 s .c o m * * @param client * @param username * @param gameInitiationHandler */ public GameInitiator(ClientCommunicator client, String username, GameInitiationHandler gameInitiationHandler) { this.client = client; this.username = username; this.gameInitiationHandler = gameInitiationHandler; readyToStart = false; controller = null; documentFactory = DocumentFactory.getInstance(); // Add ourselves as a message handler. client.addMessageHandler(this); }
From source file:gjset.data.PlayerData.java
License:Open Source License
/** * Return a representation of the player. * * @return//from ww w.j av a 2 s . c om */ public Element getXMLRepresentation() { DocumentFactory documentFactory = DocumentFactory.getInstance(); Element playerElement = documentFactory.createElement("player"); playerElement.addAttribute("id", "" + id); Element pointsElement = documentFactory.createElement("points"); pointsElement.setText("" + points); playerElement.add(pointsElement); Element penaltyElement = documentFactory.createElement("penalty"); penaltyElement.setText("" + penalty); playerElement.add(penaltyElement); Element nameElement = documentFactory.createElement("name"); nameElement.setText(name); playerElement.add(nameElement); Element wantsToDrawElement = documentFactory.createElement("wanttodraw"); wantsToDrawElement.setText("" + wantsToDraw); playerElement.add(wantsToDrawElement); return playerElement; }
From source file:gjset.server.game.GameController.java
License:Open Source License
public GameController() { model = new GameModel(); model.addObserver(this); documentFactory = DocumentFactory.getInstance(); }
From source file:gjset.server.game.GameModel.java
License:Open Source License
public GameModel() { // There is no active game at this time. gameState = GameConstants.GAME_STATE_NOT_STARTED; // Create the deck. deck = new Deck(); //Create the card table. cardTable = new CardTable(); // Create the player array. players = new PlayerData[GameConstants.MAX_PLAYERS]; // Set the default set caller id setCallerId = 0;/*from w w w . ja va 2s . c o m*/ // Create a set timer to abort an incoming set. setTimer = new CountdownTimer(SET_TIME, new Runnable() { public void run() { handleSetTimeout(); } }); // Create a display timer to resume gameplay after the results of a set are displayed. displayTimer = new CountdownTimer(DISPLAY_TIME, new Runnable() { public void run() { resumeGame(); } }); // Get a DocumentFactory for use in creating XML representations of the game model. documentFactory = DocumentFactory.getInstance(); }
From source file:gjset.server.PlayerClientHandler.java
License:Open Source License
public PlayerClientHandler(Socket socket, GameServer server, ServerConsole console) { this.socket = socket; this.server = server; this.console = console; console.message("Creating client handler"); documentFactory = DocumentFactory.getInstance(); //Get our I/O streams. try {//ww w.j a v a 2 s.co m createIOStreams(); } catch (IOException e) { console.errorMessage("Could not obtain I/O streams for client socket."); e.printStackTrace(); } }
From source file:gjset.server.ServerGameController.java
License:Open Source License
/** * Create a ServerGameController/*from w ww. j a v a 2s . c o m*/ * * This constructor instantiates and initializes all of the game model data. * @param gamePort * */ public ServerGameController(GameServer server) { this.server = server; server.addMessageHandler(this); model = new GameModel(); model.addObserver(this); documentFactory = DocumentFactory.getInstance(); createMessageQueue(); }