List of usage examples for org.dom4j DocumentFactory getInstance
public static synchronized DocumentFactory getInstance()
From source file:org.foxbpm.bpmn.converter.SequenceFlowXMLConverter.java
License:Apache License
public Element cretateXMLElement() { return DocumentFactory.getInstance().createElement( BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_SEQUENCEFLOW, BpmnXMLConstants.BPMN2_NAMESPACE); }
From source file:org.foxbpm.bpmn.converter.StartEventXMLConverter.java
License:Apache License
public Element cretateXMLElement() { return DocumentFactory.getInstance().createElement( BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_STARTEVENT, BpmnXMLConstants.BPMN2_NAMESPACE); }
From source file:org.foxbpm.bpmn.converter.SubProcessXMLConverter.java
License:Apache License
public Element cretateXMLElement() { return DocumentFactory.getInstance().createElement( BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_SUBPROCESS, BpmnXMLConstants.BPMN2_NAMESPACE); }
From source file:org.foxbpm.bpmn.converter.UserTaskXMLConverter.java
License:Apache License
public Element cretateXMLElement() { return DocumentFactory.getInstance().createElement( BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TASK_USER, BpmnXMLConstants.BPMN2_NAMESPACE); }
From source file:org.frogx.service.core.DefaultMUGRoom.java
License:Open Source License
public void broadcastTurn(Collection<Element> moves, MUGOccupant sender) throws ComponentException { Element rawMessage = DocumentFactory.getInstance().createDocument().addElement("message"); Element turn = rawMessage.addElement("turn", MUGService.mugNS + "#user"); if (moves != null) { for (Element move : moves) { move.setParent(null);/*from w w w . j a va 2 s .c om*/ turn.add(move); } } Message message = new Message(rawMessage, false); sendBroadcastPacket(message, sender); }
From source file:org.frogx.service.core.DefaultMUGRoom.java
License:Open Source License
public void sendTurn(Collection<Element> moves, MUGOccupant sender, MUGOccupant recipient) throws ComponentException { Element rawMessage = DocumentFactory.getInstance().createDocument().addElement("message"); Element turn = rawMessage.addElement("turn", MUGService.mugNS + "#user"); if (moves != null) { for (Element move : moves) { move.setParent(null);//from w w w .ja v a 2 s . c om turn.add(move); } } Message message = new Message(rawMessage, false); message.setFrom(sender.getRoomAddress()); recipient.send(message); }
From source file:org.frogx.service.core.DummyMatch.java
License:Open Source License
public Collection<Element> getConfigurationForm() { Collection<Element> result = new ArrayList<Element>(); Element element = DocumentFactory.getInstance().createElement("config", DummyMultiUserGame.namespace); result.add(element);/*from w w w .java 2s .c om*/ return result; }
From source file:org.frogx.service.core.DummyMatch.java
License:Open Source License
public Element getState() { return DocumentFactory.getInstance().createElement("state", DummyMultiUserGame.namespace); }
From source file:org.frogx.service.games.hearts.Match.java
License:Open Source License
public void processFirstTurn() throws InvalidTurnException, ComponentException { if (turnType.equalsIgnoreCase("firstturn")) { log.info("PFT\t Mi e' stata mandata una mossa firstturn, per lo scambio di carte."); log.info("PFT------------------------ MOSSA:" + moveID + " ------------------------"); int card1, card2, card3; int src = 0; card1 = Integer.valueOf(move.attributeValue("card1")); card2 = Integer.valueOf(move.attributeValue("card2")); card3 = Integer.valueOf(move.attributeValue("card3")); log.info("PFT\t - Le carte che voglio passare sono: " + card1 + " - " + card2 + " - " + card3); log.info("PFT\t - Mossa da cui ho estrapolato i dati: " + move.asXML()); if (role == Role.north) src = 0;// w w w. j a v a2 s . co m else if (role == Role.east) src = 1; else if (role == Role.south) src = 2; else if (role == Role.west) src = 3; log.info("PFT\t Il mio ruolo, messo nel messaggio broadcastato e' = " + role.toString()); log.info("PFT\t player: " + player.getNickname()); cardSwap[src][0] = card1; cardSwap[src][1] = card2; cardSwap[src][2] = card3; room.broadcastTurn(moves, player); this.moveID++; } if (this.firstTurn == 0) { if (((role == Role.west) && (botUsers == 0)) || ((role == Role.south) && (botUsers == 1)) || ((role == Role.east) && (botUsers == 2)) || ((role == Role.north) && (botUsers == 3))) { configureBotHands(); if (role == Role.north && botUsers == 3) { log.info("PFT\t ruolo attuale North, bot 3, estraggo le carte da scambiare ai bot"); swapCards(botE, cardSwap[1]); swapCards(botS, cardSwap[2]); swapCards(botW, cardSwap[3]); log.info("PFT\faccio il broadcast delle carte estratte"); for (int h = 1; h < 4; h++) { Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "firstturn"); botMove.addAttribute("card1", Integer.toString(cardSwap[h][0])); botMove.addAttribute("card2", Integer.toString(cardSwap[h][1])); botMove.addAttribute("card3", Integer.toString(cardSwap[h][2])); botMove.addAttribute("sender", (Role.valueOf((h + 1) * 10)).toString()); log.info("PFT\t Il bot " + (Role.valueOf((h + 1) * 10)).toString() + " invia a tutti la mossa: " + botMove.asXML()); botMoveToSend.add(botMove); room.broadcastTurn(botMoveToSend, player); } } if (role == Role.east && botUsers == 2) { log.info("PFT\t ruolo attuale East, bot 2, estraggo le carte da scambiare ai bot"); swapCards(botS, cardSwap[2]); swapCards(botW, cardSwap[3]); log.info("PFT\faccio il broadcast delle carte estratte"); for (int h = 2; h < 4; h++) { Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "firstturn"); botMove.addAttribute("card1", Integer.toString(cardSwap[h][0])); botMove.addAttribute("card2", Integer.toString(cardSwap[h][1])); botMove.addAttribute("card3", Integer.toString(cardSwap[h][2])); botMove.addAttribute("sender", (Role.valueOf((h + 1) * 10)).toString()); log.info("PFT\t Il bot " + (Role.valueOf((h + 1) * 10)).toString() + " invia a tutti la mossa: " + botMove.asXML()); botMoveToSend.add(botMove); room.broadcastTurn(botMoveToSend, player); } } if (role == Role.south && botUsers == 1) { log.info("PFT\t ruolo attuale South, bot 1, estraggo le carte da scambiare ai bot"); swapCards(botW, cardSwap[3]); log.info("PFT\faccio il broadcast delle carte estratte"); Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "firstturn"); botMove.addAttribute("card1", Integer.toString(cardSwap[3][0])); botMove.addAttribute("card2", Integer.toString(cardSwap[3][1])); botMove.addAttribute("card3", Integer.toString(cardSwap[3][2])); botMove.addAttribute("sender", Role.west.toString()); log.info("PFT\t Il bot " + Role.west.toString() + " invia a tutti la mossa: " + botMove.asXML()); botMoveToSend.add(botMove); room.broadcastTurn(botMoveToSend, player); } log.info("PFT\t Finisce la prima mano, e' ora di scambiare le carte nelle strutture dati"); this.firstTurn = 1; cardsController.passCards(cardSwap); log.info("PFT\t Carte Swappate"); //log.info("PFT:\t MOVEID = " + moveID); if (botUsers > 2) { log.info("PFT------------------------ MOSSA:" + moveID + " ------------------------"); botW.setHand(gameHands.get(3)); log.info("PFT\t Carte scambiate e mano del bot West configurata e sincronizzata"); log.info("PFT\tNext First Player: " + cardsController.nextFirstPlayer()); this.moveID++; } if (botUsers > 1) { log.info("PFT------------------------ MOSSA:" + moveID + " ------------------------"); botS.setHand(gameHands.get(2)); log.info("PFT\t Carte scambiate e mano del bot South configurata e sincronizzata"); log.info("PFT\tNext First Player: " + cardsController.nextFirstPlayer()); this.moveID++; } if (botUsers > 0) { log.info("PFT------------------------ MOSSA:" + moveID + " ------------------------"); botE.setHand(gameHands.get(1)); log.info("PFT\t Carte scambiate e mano del bot East configurata e sincronizzata"); log.info("PFT\tNext First Player: " + cardsController.nextFirstPlayer()); this.moveID++; } this.firstTurn = 1; } } this.role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PFT\tNext First Player: " + cardsController.nextFirstPlayer()); //log.info("PFT\t Mi calcolo quale sara' il prossimo turno (in base al 2 di fiori), ovvero: "+ role.toString()); this.firstPlayerTurn = (turn.getValue() / 10) - 1; this.turnCounter = 1; }
From source file:org.frogx.service.games.hearts.Match.java
License:Open Source License
public void processStandardTurn() throws InvalidTurnException, ComponentException { log.info("PST: \t STANDARD TURN!"); log.info("PST: \t Next Player: " + role.name()); if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("\t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); }//from w w w.ja va 2s.c o m if (turnCounter == 5) { log.info("\t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("\t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } if ((role == Role.north) || role == Role.east && botUsers < 3 || role == Role.south && botUsers < 2 || role == Role.west && botUsers < 1) { log.info("PST: \t GIOCA UN UMANO!"); if (moveID == 57) return; if (turnType.equalsIgnoreCase("standard")) { int playRoleID = ((role.getValue() % 40) + 10); log.info("\t Player ID: " + playRoleID); int card1 = Integer.valueOf(move.attributeValue("card1")); this.onTable[(role.getValue() / 10) - 1] = card1; //cardsController.checkHearts(card1); log.info("\t Turno normale, la carta giocata sul tavolo e': " + card1 + " --- " + cardsController.cardToString(card1)); log.info( "\t Se ci sono bot, faccio buttare le carte in tavola a tutti i bot giocanti che non hanno gia giocato."); log.info("BROADCAST!" + move.asXML() + player.toString()); room.broadcastTurn(moves, player); cardsController.cardPlayed(role.getValue(), gameHands.get((role.getValue() / 10) - 1), card1); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("\t Aggiorno nextRoleID che diventa -> " + playRoleID); moveID++; turnCounter++; log.info("PST: ------------------------ MOSSA:" + moveID + " ------------------------"); log.info("PST: ------------------------ TURNO:" + turnCounter + " ------------------------"); if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("PST: \t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); } if (turnCounter == 5) { log.info("PST: \t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } } } // ************ BOT ********** while ((role == Role.east && botUsers > 2) || (role == Role.south && botUsers > 1) || (role == Role.west && botUsers > 0)) { // GIOCA IL BOT log.info("PST: \t BOT TURN!"); if (moveID == 57) return; if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("PST: \t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); } if (turnCounter == 5) { log.info("PST: \t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } if (role == Role.east && botUsers > 2) { moveID++; turnCounter++; int botCard = botE.playCard(cardsController.getSeed(onTable[firstPlayerTurn])); cardsController.cardPlayed(role.getValue(), gameHands.get((role.getValue() / 10) - 1), botCard); this.onTable[((role.getValue()) / 10) - 1] = botCard; log.info("PST: \tBot card played " + cardsController.cardToString(botCard)); Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "standard"); botMove.addAttribute("card1", Integer.toString(botCard)); botMove.addAttribute("card2", ""); botMove.addAttribute("card3", ""); botMove.addAttribute("sender", role.toString()); botMoveToSend.add(botMove); log.info("PST:\t La mossa broadcastata e': " + "\n\t" + botMove.toString() + "\n"); room.broadcastTurn(botMoveToSend, player); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \tIl giocatore che deve giocare dopo di me e' " + role.getValue()); log.info("PST: ------------------------ MOSSA:" + moveID + " ------------------------"); log.info("PST: ------------------------ TURNO:" + turnCounter + " ------------------------"); if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("PST: \t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); } if (turnCounter == 5) { log.info("PST: \t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } } else if (role == Role.south && botUsers > 1) { moveID++; turnCounter++; int botCard = botS.playCard(cardsController.getSeed(onTable[firstPlayerTurn])); cardsController.cardPlayed(role.getValue(), gameHands.get((role.getValue() / 10) - 1), botCard); this.onTable[((role.getValue()) / 10) - 1] = botCard; log.info("PST: \tBot card played " + cardsController.cardToString(botCard)); Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "standard"); botMove.addAttribute("card1", Integer.toString(botCard)); botMove.addAttribute("card2", ""); botMove.addAttribute("card3", ""); botMove.addAttribute("sender", role.toString()); botMoveToSend.add(botMove); log.info("PST:\t La mossa broadcastata e': " + "\n\t" + botMove.toString() + "\n"); room.broadcastTurn(botMoveToSend, player); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \tIl giocatore che deve giocare dopo di me e' " + role.getValue()); log.info("PST: ------------------------ MOSSA:" + moveID + " ------------------------"); log.info("PST: ------------------------ TURNO:" + turnCounter + " ------------------------"); if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("PST: \t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); } if (turnCounter == 5) { log.info("PST: \t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } } else if (role == Role.west && botUsers > 0) { moveID++; turnCounter++; int botCard = botW.playCard(cardsController.getSeed(onTable[firstPlayerTurn])); cardsController.cardPlayed(role.getValue(), gameHands.get((role.getValue() / 10) - 1), botCard); this.onTable[((role.getValue()) / 10) - 1] = botCard; log.info("PST: \tBot card played " + cardsController.cardToString(botCard)); Element botMove = DocumentFactory.getInstance().createDocument().addElement("move", NAMESPACE); botMove.addAttribute("turntype", "standard"); botMove.addAttribute("card1", Integer.toString(botCard)); botMove.addAttribute("card2", ""); botMove.addAttribute("card3", ""); botMove.addAttribute("sender", role.toString()); botMoveToSend.add(botMove); log.info("PST:\t La mossa broadcastata e': " + "\n\t" + botMove.toString() + "\n"); room.broadcastTurn(botMoveToSend, player); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \tIl giocatore che deve giocare dopo di me e' " + role.getValue()); log.info("PST: ------------------------ MOSSA:" + moveID + " ------------------------"); log.info("PST: ------------------------ TURNO:" + turnCounter + " ------------------------"); if (turnCounter == 1) { firstPlayerTurn = (role.getValue() / 10) - 1; log.info("PST: \t Sono al primo turno della mano, configuro firsPlayerTurn = " + firstPlayerTurn); } if (turnCounter == 5) { log.info("PST: \t Controllo chi ha vinto la mano"); cardsController.handWinner(onTable, firstPlayerTurn); role = Role.valueOf(cardsController.nextFirstPlayer()); log.info("PST: \t Il giocatore che ha preso e deve lanciare e': " + turn.toString()); turnCounter = 1; resetTable(); } } } }