List of usage examples for com.google.gson GsonBuilder GsonBuilder
public GsonBuilder()
From source file:JestMain.java
public static String generateEsUpdateScriptFromMap(Map<String, String> updatesMap) { JsonObject jsonObj = new JsonObject(); StringBuffer scriptBuffer = new StringBuffer(); JsonObject jsonObject_1 = new JsonObject(); for (Map.Entry<String, String> entrySet : updatesMap.entrySet()) { String key = entrySet.getKey(); String value = entrySet.getValue(); scriptBuffer.append("ctx._source.").append(key).append("=" + key + ";"); jsonObject_1.addProperty(key, value); }//from ww w.ja v a2 s .c om jsonObj.addProperty("script", scriptBuffer.toString()); jsonObj.add("params", jsonObject_1); return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(jsonObj); }
From source file:LanguageServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Define action String action = request.getParameter("action"); //Define data String data = request.getParameter("data"); //Create locale object Locale locale = null;//from w w w . j a v a2 s .com //Create resource bundle object ResourceBundle resourceBundle = null; //Create key - value pair collection for response Map<String, String> map = new HashMap<String, String>(); //Here i use Gson library for working with Json Gson gson = new GsonBuilder().create(); //Based on action i can switch to different options. //I print predefined text to output just for debugging try { if (action.equals("changeLang")) { if (data.equals("en")) { locale = new Locale("en", "EN"); resourceBundle = ResourceBundle.getBundle("i18n.Bundle", locale); System.out.println(resourceBundle.getString("NAME")); System.out.println(resourceBundle.getString("LAST_NAME")); System.out.println(resourceBundle.getString("LANGUAGE")); } else if (data.equals("ru")) { locale = new Locale("ru", "RU"); resourceBundle = ResourceBundle.getBundle("i18n.Bundle", locale); System.out.println(resourceBundle.getString("NAME")); System.out.println(resourceBundle.getString("LAST_NAME")); System.out.println(resourceBundle.getString("LANGUAGE")); } else if (data.equals("de")) { locale = new Locale("de", "DE"); resourceBundle = ResourceBundle.getBundle("i18n.Bundle", locale); System.out.println(resourceBundle.getString("NAME")); System.out.println(resourceBundle.getString("LAST_NAME")); System.out.println(resourceBundle.getString("LANGUAGE")); } } //Put data to collection.Keys are equals to index.html label's id values. map.put("name", resourceBundle.getString("NAME")); map.put("lastname", resourceBundle.getString("LAST_NAME")); map.put("language", resourceBundle.getString("LANGUAGE")); //Send response to browser. response.getWriter().write(gson.toJson(map)); } catch (Exception e) { e.printStackTrace(); } }
From source file:RunnerRepository.java
License:Apache License
public static void generateJSon() { JsonObject root = new JsonObject(); JsonObject array = new JsonObject(); array.addProperty("Embedded", "embedded"); array.addProperty("DEFAULT", "Embedded"); JsonObject array2 = new JsonObject(); array2.addProperty("NimbusLookAndFeel", "javax.swing.plaf.nimbus.NimbusLookAndFeel"); array2.addProperty("MetalLookAndFeel", "javax.swing.plaf.metal.MetalLookAndFeel"); array2.addProperty("MotifLookAndFeel", "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); array2.addProperty("WindowsLookAndFeel", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); array2.addProperty("JGoodiesWindowsLookAndFeel", "com.jgoodies.looks.windows.WindowsLookAndFeel"); array2.addProperty("Plastic3DLookAndFeel", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); array2.addProperty("PlasticXPLookAndFeel", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); array2.addProperty("DEFAULT", "MetalLookAndFeel"); root.add("plugins", new JsonArray()); root.add("editors", array); root.add("looks", array2); root.add("layout", new JsonObject()); try {/*from w ww .j a va 2 s.co m*/ FileWriter writer = new FileWriter(TWISTERINI); Gson gson = new GsonBuilder().setPrettyPrinting().create(); writer.write(gson.toJson(root)); writer.close(); } catch (Exception e) { System.out.println("Could not write default JSon to twister.conf"); e.printStackTrace(); } System.out.println("twister.conf successfully created"); }
From source file:RunnerRepository.java
License:Apache License
public static void writeJSon() { try {//from w ww .j av a2s . c o m Writer writer = new OutputStreamWriter(new FileOutputStream(TWISTERINI)); Gson gson = new GsonBuilder().setPrettyPrinting().create(); gson.toJson(inifile, writer); writer.close(); } catch (Exception e) { System.out.println("Could not write to local config file"); e.printStackTrace(); } }
From source file:ListAction.java
@Override public void execute(HttpServletRequest request, PrintWriter out, File folder) { try {/*from w w w.j av a 2 s . co m*/ String type = request.getParameter("type"); JsonArray list = new JsonArray(); switch (type) { case "movie": File[] movies = Service.listAllMovies(folder); for (int i = 0; i < movies.length; i++) { JsonObject m = new JsonObject(); m.addProperty("title", movies[i].getName()); list.add(m); } break; case "series": File[] series = Service.listAllSeries(folder); for (int i = 0; i < series.length; i++) { JsonObject m = new JsonObject(); m.addProperty("title", series[i].getName()); list.add(m); } break; case "episode": String series_title = request.getParameter("series"); folder = new File(folder.getAbsolutePath() + "\\Series\\" + series_title); List<File> episodes = Service.listAllEpisodes(folder); for (File f : episodes) { JsonObject episode = new JsonObject(); String title = f.getName().split(" - ")[0]; episode.addProperty("title", series_title + " - " + title); list.add(episode); } break; } JsonObject container = new JsonObject(); container.add("list", list); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(container); out.println(json); } catch (Exception e) { throw e; } }
From source file:KerfNetJavaAPI.java
Object synchronousRemoteExecute(Socket socket, String query, Object... args) throws Exception { Object[] bundle = { query, args }; Gson gson = new GsonBuilder().create(); String json_send = gson.toJson(bundle); long n = json_send.length(); sendJsonBundle(socket, json_send); String json_recv = recvJson(socket); Object response = gson.fromJson(json_recv, Object.class); return response; }/*from w w w. j a v a2s.c om*/
From source file:markov.java
License:Apache License
/** * @param args/*from w w w .j av a 2 s . c o m*/ */ public static void main(String[] args) { // hack: eclipse don't support IO redirection worth a shit // try { // System.setIn(new FileInputStream("./json")); // } catch (FileNotFoundException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } boolean graphMode = false; boolean jsonMode = false; boolean jsonRecoverMode = false; boolean endNode = false; int count = -1; long n = 0; long sumOfSqr = 0; long sum = 0; for (String s : args) { if (!s.matches("^-[vegjJh]*(c[0-9]*)?$")) { System.out.println("invalid argument"); return; } if (s.matches("^-.*h.*")) { System.out.println(HELP); return; } if (s.matches("^-.*v.*")) { verbose = true; log("verbose mode"); } if (s.matches("^-.*g.*")) { graphMode = true; log("graph mode"); } if (s.matches("^-.*j.*")) { jsonMode = true; log("json mode"); } if (s.matches("^-.*J.*")) { jsonRecoverMode = true; log("json recover mode"); } if (s.matches("^-.*e.*")) { endNode = true; log("include end node"); } if (s.matches("^-.*c[0-9]*$")) { log("counted output mode"); count = Integer.parseInt(s.replaceAll("^-.*c", "")); } boolean error = (graphMode == true && jsonMode == true); if (!error) { error = (count > -1) && (graphMode == true || jsonMode == true); } if (error) { System.err.println("[error] switches j, g and, c are mutualy exclusive."); return; } } StateTransitionDiagram<Character> std; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { if (!jsonRecoverMode) { Trainer<Character> trainer = new Trainer<Character>(); String s = br.readLine(); while (s != null) { trainer.train(string2List(s)); n++; sumOfSqr += s.length() * s.length(); sum += s.length(); s = br.readLine(); } if (n == 0) { System.err .println("Invalid corpus: At least one sample is required, two to make it interesting"); return; } std = trainer.getTransitionDiagram(); } else { std = new StateTransitionDiagram<Character>(); GsonStub gstub = new Gson().fromJson(br, GsonStub.class); n = gstub.meta.n; sum = gstub.meta.sum; sumOfSqr = gstub.meta.sumOfSqr; for (Entry<String, StateStub> entry : gstub.states.entrySet()) { State<Character> state; if (entry.getKey().equals("null")) { state = std.getGuard(); } else { state = std.getState(Character.valueOf(entry.getKey().charAt(0))); } for (Entry<String, Integer> transitions : entry.getValue().transitions.entrySet()) { State<Character> tranny; if (transitions.getKey().equals("null")) { tranny = std.getGuard(); } else { tranny = std.getState(Character.valueOf(transitions.getKey().charAt(0))); } state.addTransition(tranny.getValue(), transitions.getValue()); } } } if (graphMode) { if (endNode) { System.out.println(std.toString()); } else { System.out.println(std.removeEndGuards().toString()); } return; } if (jsonMode) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); String partialJson; if (endNode) { partialJson = gson.toJson(std); } else { partialJson = gson.toJson(std.removeEndGuards()); } GsonStub gstub = new Gson().fromJson(partialJson, GsonStub.class); gstub.meta = new Meta(); gstub.meta.n = n; gstub.meta.sum = sum; gstub.meta.sumOfSqr = sumOfSqr; System.out.println(gson.toJson(gstub)); return; } Generator<Character> generator; if (endNode) { generator = new EndTagGenerator<Character>(std); } else { double sd = ((double) sumOfSqr - (double) (sum * sum) / (double) n) / (double) (n - 1); double mean = (double) sum / (double) n; log(String.format("mean: %.4f sd: %.4f", mean, sd)); NormalDistributionImpl dist = new NormalDistributionImpl(mean, sd); generator = new NormalizedGenerator<Character>(std.removeEndGuards(), dist); } if (count >= 0) { for (int c = 0; c < count; c++) { output(generator); } } else { while (true) { output(generator); } } } catch (IOException e) { e.printStackTrace(); } }
From source file:PacketSnifferPlugin.java
License:Apache License
public void initializeMainPanel() { try {/* www. ja v a 2s . c om*/ bstart = new JButton("Start"); breset = new JButton("Reset"); JPanel panel1 = new JPanel(); panel1.setLayout(null); panel1.setMaximumSize(new Dimension(1150, 700)); panel1.setMinimumSize(new Dimension(1150, 700)); panel1.setPreferredSize(new Dimension(1150, 700)); InputStream in = getClass().getResourceAsStream("Sniff0.png"); Image im = ImageIO.read(in); button0 = new ImageIcon(im); in = getClass().getResourceAsStream("Sniff1.png"); im = ImageIO.read(in); final ImageIcon button1 = new ImageIcon(im); in = getClass().getResourceAsStream("Stop1.png"); im = ImageIO.read(in); final ImageIcon button2 = new ImageIcon(im); in = getClass().getResourceAsStream("Stop0.png"); im = ImageIO.read(in); button3 = new ImageIcon(im); in = getClass().getResourceAsStream("Reset1.png"); im = ImageIO.read(in); final ImageIcon button5 = new ImageIcon(im); in = getClass().getResourceAsStream("Save.png"); im = ImageIO.read(in); ImageIcon save = new ImageIcon(im); breset.setBounds(515, 635, 120, 30); panel1.add(breset); breset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { String resp = client .execute("runPlugin", new Object[] { variables.get("user"), getName(), "command=reset" }) .toString(); ((DefaultTableModel) jTable1.getModel()).setNumRows(0); index = "0"; } catch (Exception e) { e.printStackTrace(); } } }); bstart = new JButton("Start"); bstart.setBounds(385, 635, 120, 30); panel1.add(bstart); bstart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (start == 1) { bstart.setText("Start"); start = 0; try { String resp = client .execute("runPlugin", new Object[] { variables.get("user"), getName(), "command=pause" }) .toString(); System.out.println("resp: " + resp); } catch (Exception ex) { ex.printStackTrace(); } } else { bstart.setText("Stop"); start = 1; try { String resp = client .execute("runPlugin", new Object[] { variables.get("user"), getName(), "command=resume" }) .toString(); System.out.println("resp: " + resp); } catch (Exception ex) { ex.printStackTrace(); } } } }); jTable1 = new JTable(); jTable1.getTableHeader().setReorderingAllowed(false); jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent arg0) { if (!arg0.getValueIsAdjusting()) { if (jTable1.getSelectedRow() == -1) { content.setText(""); return; } String pac = null; try { String id = jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString(); System.out.println("requested id: " + id); pac = client.execute("runPlugin", new Object[] { variables.get("user"), getName(), "command=querypkt&data=" + id }).toString(); JsonElement el = new JsonParser().parse(pac); JsonObject jobject = el.getAsJsonObject(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(jobject); json = json.replaceAll("\"", ""); json = json.replaceAll("\\\\n", "\n"); content.setText(json); } catch (Exception e) { System.out.println("Server response: " + pac.toString()); e.printStackTrace(); } } } }); JScrollPane pane = new JScrollPane(jTable1); pane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); pane.setBounds(25, 70, 1100, 300); jTable1.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Protocol", "SRC IP", "SRC Mac", "SRC Port", "DST IP", "DST Mac", "DST Port", "" }) { private static final long serialVersionUID = 1L; public boolean isCellEditable(int row, int col) { return false; } }); TableRowSorter sorter = new TableRowSorter(jTable1.getModel()); jTable1.setRowSorter(sorter); TableColumn c = jTable1.getColumnModel().getColumn(7); c.setMinWidth(0); c.setMaxWidth(0); c.setWidth(0); c.setPreferredWidth(0); panel1.add(pane); content = new JTextArea(); content.setEditable(false); JScrollPane sc = new JScrollPane(content); sc.setBounds(25, 380, 1100, 250); panel1.add(sc); JPanel top = new JPanel(); top.setBounds(25, 0, 1100, 35); panel1.add(top); JPanel top2 = new JPanel(); top2.setBounds(25, 35, 1100, 30); panel1.add(top2); JLabel filter = new JLabel("View Filter:"); panel1.add(top); top.add(filter); final JTextField search = new JTextField(); search.setMinimumSize(new Dimension(130, 20)); search.setPreferredSize(new Dimension(130, 20)); search.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.VK_ENTER) { filter(search.getText()); } } }); top.add(search); JButton apply = new JButton("Apply"); apply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { filter(search.getText()); } }); top.add(apply); JButton clear = new JButton("Clear"); clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { search.setText(""); filter(""); } }); top.add(clear); filter = new JLabel("Start Options:"); top.add(filter); final JTextField search2 = new JTextField(); search2.setMinimumSize(new Dimension(130, 20)); search2.setPreferredSize(new Dimension(130, 20)); search2.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.VK_ENTER) { setRemoteFilter(search2.getText()); } } }); try { HashMap<String, String> filters = (HashMap<String, String>) client.execute("runPlugin", new Object[] { variables.get("user"), getName(), "command=getfilters" }); Iterator<Entry<String, String>> iter = filters.entrySet().iterator(); StringBuilder sb = new StringBuilder(); Entry<String, String> en; while (iter.hasNext()) { en = iter.next(); sb.append(en.getKey()); sb.append(" "); sb.append(en.getValue()); sb.append(" "); } System.out.println("Filter:" + sb.toString()); search2.setText(sb.toString()); } catch (Exception e) { e.printStackTrace(); } top.add(search2); JButton apply2 = new JButton("Apply"); apply2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setRemoteFilter(search2.getText()); } }); top.add(apply2); JButton clear2 = new JButton("Clear"); clear2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { search2.setText(""); setRemoteFilter(""); } }); top.add(clear2); pro = new JCheckBox("Protocol"); pro.setSelected(true); pro.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (pro.isSelected()) { jTable1.addColumn(columns[0]); jTable1.moveColumn(jTable1.getColumnCount() - 1, 0); } else { int index = findColumn("Protocol"); columns[0] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[0]); } } }); top2.add(pro); srcip = new JCheckBox("SRC IP"); srcip.setSelected(true); srcip.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (srcip.isSelected()) { int index = findColumn("Protocol"); if (index == -1) { jTable1.addColumn(columns[1]); jTable1.moveColumn(jTable1.getColumnCount() - 1, 0); } else { jTable1.addColumn(columns[1]); jTable1.moveColumn(jTable1.getColumnCount() - 1, 1); } } else { int index = findColumn("SRC IP"); columns[1] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[1]); } } }); top2.add(srcip); srcmac = new JCheckBox("SRC Mac"); srcmac.setSelected(true); srcmac.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (srcmac.isSelected()) { jTable1.addColumn(columns[2]); int index = findColumn("SRC IP"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1); } else if (findColumn("Protocol") != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, 1); } else { jTable1.moveColumn(jTable1.getColumnCount() - 1, 0); } } else { int index = findColumn("SRC Mac"); columns[2] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[2]); } } }); top2.add(srcmac); srcport = new JCheckBox("SRC Port"); srcport.setSelected(true); srcport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (srcport.isSelected()) { jTable1.addColumn(columns[3]); int index = findColumn("SRC Mac"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1); } else { index = findColumn("SRC IP"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1); } else if (findColumn("Protocol") != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, 1); } else { jTable1.moveColumn(jTable1.getColumnCount() - 1, 0); } } } else { int index = findColumn("SRC Port"); columns[3] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[3]); } } }); top2.add(srcport); dstip = new JCheckBox("DST IP"); dstip.setSelected(true); dstip.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (dstip.isSelected()) { jTable1.addColumn(columns[4]); int index = findColumn("DST Mac"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index); } else { index = findColumn("DST Port"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index); } } } else { int index = findColumn("DST IP"); columns[4] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[4]); } } }); top2.add(dstip); dstmac = new JCheckBox("DST Mac"); dstmac.setSelected(true); dstmac.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (dstmac.isSelected()) { jTable1.addColumn(columns[5]); int index = findColumn("DST Port"); if (index != -1) { jTable1.moveColumn(jTable1.getColumnCount() - 1, index); } } else { int index = findColumn("DST Mac"); columns[5] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[5]); } } }); top2.add(dstmac); dstport = new JCheckBox("DST Port"); dstport.setSelected(true); dstport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (dstport.isSelected()) { jTable1.addColumn(columns[6]); } else { int index = findColumn("DST Port"); columns[6] = jTable1.getColumnModel().getColumn(index); jTable1.removeColumn(columns[6]); } } }); top2.add(dstport); JButton bsave = new JButton(save); bsave.setToolTipText("Save as libpcap"); bsave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { saveFile(); } }); bsave.setBounds(645, 635, 120, 30); panel1.add(bsave); p.add(new JScrollPane(panel1)); } catch (IOException e) { e.printStackTrace(); } }
From source file:AAMAirline.service.PdfServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RuntimeTypeAdapterFactory<Jsonable> rta = RuntimeTypeAdapterFactory.of(Jsonable.class, "_class") .registerSubtype(Ciudad.class, "Ciudad").registerSubtype(Tiquete.class, "Tiquete") .registerSubtype(Ruta.class, "Ruta").registerSubtype(Avion.class, "Avion") .registerSubtype(Usuario.class, "Usuario").registerSubtype(Asiento.class, "Asiento") .registerSubtype(Vuelo.class, "Vuelo"); response.setContentType("aplication/pdf"); response.setHeader("Content-Disposition", "inline;filename=\"report.pdf\""); PdfDocument pdf = new PdfDocument(new PdfWriter(response.getOutputStream())); Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).setDateFormat("dd/MM/yyyy").create(); String json;// ww w . j av a 2 s. c o m try (Document document = new Document(pdf)) { Paragraph p; p = new Paragraph("TIQUETE DE VUELO"); p.setTextAlignment(TextAlignment.CENTER); p.setBold(); p.setBackgroundColor(Color.PINK); document.add(p); String h = "Vuelo %s, %s - %s, %s %s %s"; String codigo_tiquete = request.getParameter("tiquete"); Tiquete ticket = AAMAirlineModel.consultaTiquete(codigo_tiquete); ArrayList<String> asientosIda = AAMAirlineModel.getAsientosPDF(ticket.getCodigo_Tiquete(), ticket.getVueloida().getAvion().getCodigo_Avion()); ArrayList asientosVuelta; String asientos = ""; String horaVuelta = ""; Float precio = (ticket.getVueloida().getPrecio()) * (asientosIda.size()); if (ticket.getVueloVuelta() != null) { asientosVuelta = AAMAirlineModel.getAsientosPDF(ticket.getCodigo_Tiquete(), ticket.getVueloVuelta().getAvion().getCodigo_Avion()); horaVuelta = " / salida vuelo Vuelta " + ticket.getVueloVuelta().getHora_salida() + " horas "; asientos = asientos + "Vuelta \n"; for (int i = 0; i < asientosVuelta.size(); i++) { asientos = asientos + asientosVuelta.get(i) + "\n"; } precio += (ticket.getVueloVuelta().getPrecio() * asientosVuelta.size()); } String horaida = ticket.getVueloida().getHora_salida(); String algo = " horas "; h = String.format(h, ticket.getVueloida().getCodigo_Vuelo(), ticket.getVueloida().getRuta().getCiudadO().getNombre(), ticket.getVueloida().getRuta().getCiudadD().getNombre(), ticket.getVueloida().getDia_salida(), " salida vuelo ida :" + horaida + algo, horaVuelta); p = new Paragraph(h); p.setTextAlignment(TextAlignment.LEFT); p.setBold(); document.add(p); for (int i = 0; i < asientosIda.size(); i++) { asientos = asientos + "Ida: \n"; asientos = asientos + asientosIda.get(i) + "\n"; } p = new Paragraph("------------- Asientos ------------- \n" + asientos); document.add(p); p = new Paragraph("COSTO TOTAL: $ " + precio); p.setTextAlignment(TextAlignment.RIGHT); p.setBold(); p.setBackgroundColor(Color.PINK); document.add(p); } catch (SQLException ex) { Logger.getLogger(PdfServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:abfab3d.shapejs.JSONParsing.java
License:LGPL
public static Gson getJSONParser() { return new GsonBuilder().serializeSpecialFloatingPointValues().create(); }