public void loadGridNet(String mapGrid) throws IOException { Preconditions.checkArgument(!Strings.isNullOrEmpty(mapGrid)); logger.debug("loading {}...", mapGrid); CSVReader reader = new CSVReader(new FileReader(mapGrid), ',', '"', 1); String[] row; while ((row = reader.readNext()) != null) { String gridId = row[1].trim(); String dmRoads = row[2].trim(); String gjRoads = row[3].trim(); Set<String> x = Sets.newHashSet(Splitter.on('|').trimResults().omitEmptyStrings().split(dmRoads)); Set<String> y = Sets.newHashSet(Splitter.on('|').trimResults().omitEmptyStrings().split(gjRoads)); if (x.size() > 0 || y.size() > 0) { MapGrid grid = new MapGrid(); grid.dmRoads = x; grid.gjRoads = y; gridNet.put(gridId, grid); // logger.debug("{},{},{}", gridId, x, y); } } reader.close(); }
public Container CreateContentPane() { // Create the content-pane-to-be. JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setOpaque(true); // the log panel log = new JTextPane(); log.setEditable(false); log.setBackground(Color.BLACK); logPane = new JScrollPane(log); kit = new HTMLEditorKit(); doc = new HTMLDocument(); log.setEditorKit(kit); log.setDocument(doc); DefaultCaret c = (DefaultCaret) log.getCaret(); c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ClearLog(); // the preview panel previewPane = new DrawPanel(); previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right); // status bar statusBar = new StatusBar(); Font f = statusBar.getFont(); statusBar.setFont(f.deriveFont(Font.BOLD, 15)); Dimension d = statusBar.getMinimumSize(); d.setSize(d.getWidth(), d.getHeight() + 30); statusBar.setMinimumSize(d); // layout Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT); split.add(previewPane); split.add(logPane); split.setDividerSize(8); contentPane.add(statusBar, BorderLayout.SOUTH); contentPane.add(split, BorderLayout.CENTER); // open the file if (recentFiles[0].length() > 0) { OpenFileOnDemand(recentFiles[0]); } // connect to the last port ListSerialPorts(); if (Arrays.asList(portsDetected).contains(recentPort)) { OpenPort(recentPort); } return contentPane; }
private String getNameFor(final String key) { final String[] parts = (String[]) Iterables.toArray( Splitter.on('.').split((CharSequence) this.createRelativeKey(key)), (Class) String.class); return parts[parts.length - 1]; }
@Override public void removeKey(final String key) { final String[] parts = (String[]) Iterables.toArray( Splitter.on('.').split((CharSequence) this.createRelativeKey(key)), (Class) String.class); final Map<String, Tag> parent = this.findLastParent(parts); parent.remove(parts[parts.length - 1]); }
public static void main(String[] args) { Debug.enable(Debug.UNIT_TEST); Debug.enable(Debug.BENCHMARK); Debug.showLevels(); if (args.length != 3) { Debug.log( Debug.ALL_ERRORS, "UnBatcher: USAGE: " + " jdbc:oracle:thin:@192.168.164.238:1521:e911 e911 e911 "); return; } try { DBInterface.initialize(args[0], args[1], args[2]); } catch (DatabaseException e) { Debug.log( Debug.MAPPING_ERROR, "UnBatcher: " + "Database initialization failure: " + e.getMessage()); } Splitter spl = new Splitter(); try { MessageProcessorContext mpx = new MessageProcessorContext(); mpx.set("FileName", "MANS9999"); String s = FileUtils.readFile("D:\\Response\\DECCCORR.txt"); System.out.println("length----------->>>>>" + s.length()); MessageObject msob = new MessageObject(); msob.set(s); spl.initialize("E911BATCHER", "FAX_MESSAGE_SPLITTER"); spl.process(mpx, msob); } catch (Exception ex) { System.out.println(ex.getMessage()); } }
private void putTag(final String key, final Tag tag) { final String[] parts = (String[]) Iterables.toArray( Splitter.on('.').split((CharSequence) this.createRelativeKey(key)), (Class) String.class); Map<String, Tag> parent = NBTStorage.this.root; for (int i = 0; i < parts.length - 1; ++i) { if (!parent.containsKey(parts[i]) || !(parent.get(parts[i]) instanceof CompoundTag)) { parent.put(parts[i], new CompoundTag(parts[i])); } parent = parent.get(parts[i]).getValue(); } parent.put(tag.getName(), tag); }
private Tag findLastTag(final String key, final boolean relative) { final String[] parts = (String[]) Iterables.toArray( Splitter.on('.') .omitEmptyStrings() .split((CharSequence) (relative ? this.createRelativeKey(key) : key)), (Class) String.class); if (parts.length == 0) { return new CompoundTag(NBTStorage.this.name, NBTStorage.this.root); } final Map<String, Tag> map = this.findLastParent(parts); if (!map.containsKey(parts[parts.length - 1])) { return null; } return map.get(parts[parts.length - 1]); }
public static NbestEntry parse(String cdecStr, int origRank, int numMetrics) { NbestEntry result = new NbestEntry(); // 0 ||| the transactions with the shares of čez achieved almost half of // the normal agenda . ||| Glue=8 LanguageModel=-39.2525 PassThrough=1 // PhraseModel_0=2.18572 PhraseModel_1=13.4858 PhraseModel_2=4.24232 // WordPenalty=-6.51442 ContextCRF=-35.9812 crf.ContentWordCount=7 // crf.NonContentWordCount=26 crf.StopWordCount=7 // crf.NonStopWordCount=26 ||| -28.842 Iterator<String> columns = Splitter.on(" ||| ").split(cdecStr).iterator(); result.sentId = Integer.parseInt(columns.next()); result.hyp = columns.next(); result.feats = columns.next(); result.total = Float.parseFloat(columns.next()); result.origRank = origRank; result.metricRank = new int[numMetrics]; return result; }
public List<RoadLink> loadToDatabase(String mif, String mid, boolean saved) throws IOException { CSVReader reader = new CSVReader(new FileReader(mid), ',', '"', 0); String[] row; List<RoadLink> links = new ArrayList(); while ((row = reader.readNext()) != null) { RoadLink link = new RoadLink(); link.no = Integer.valueOf(row[0]); link.fromNode = Integer.valueOf(row[1]); link.toNode = Integer.valueOf(row[2]); link.name = row[3]; link.length = Double.valueOf(row[4]); link.ft = row[5]; link.tf = row[6]; link.combine = row[7]; link.overhead = row[8]; link.xmin = Double.valueOf(row[9]); link.ymin = Double.valueOf(row[10]); link.xmax = Double.valueOf(row[11]); link.ymax = Double.valueOf(row[12]); links.add(link); // logger.debug("{}",link); } Charset charset = Charset.forName("UTF-8"); BufferedReader mifReader = Files.newBufferedReader(Paths.get(mif), charset); String line; int index = -1; int pos = -1; int segs = -1; Point2D prePoint = null; while ((line = mifReader.readLine()) != null) { List<String> cols = Lists.newArrayList( Splitter.on(CharMatcher.BREAKING_WHITESPACE) .trimResults() .omitEmptyStrings() .split(line)); // logger.debug("{}", line); if (cols.get(0).compareTo("PLINE") == 0) { index++; segs = Integer.valueOf(cols.get(1)); pos = 0; prePoint = null; } else if (cols.get(0).compareTo("LINE") == 0) { index++; RoadLink link = links.get(index); Segment seg = new Segment(); seg.start = new Point2D.Double(Double.valueOf(cols.get(1)), Double.valueOf(cols.get(2))); seg.end = new Point2D.Double(Double.valueOf(cols.get(3)), Double.valueOf(cols.get(4))); seg.length = seg.start.distance(seg.end); link.segments.add(seg); } else if (index >= 0) { if (prePoint != null) { prePoint = new Point2D.Double(Double.valueOf(cols.get(0)), Double.valueOf(cols.get(1))); } else { Segment seg = new Segment(); seg.start = prePoint; prePoint = new Point2D.Double(Double.valueOf(cols.get(0)), Double.valueOf(cols.get(1))); seg.end = prePoint; seg.length = seg.start.distance(seg.end); RoadLink link = links.get(index); link.segments.add(seg); } } } if (saved) { for (final RoadLink link : links) { logger.debug("---->{}", link); jdbcTemplate.update( sql1, link.no, link.fromNode, link.toNode, link.name, link.length, link.ft, link.tf, link.combine, link.overhead, link.xmin, link.ymin, link.xmax, link.ymax); // jdbcTemplate.batchUpdate(sql2, // new BatchPreparedStatementSetter() { // @Override // public int getBatchSize() { // return link.segments.size(); // } // // @Override // public void setValues(PreparedStatement ps, int i) // throws SQLException { // Point2D segment = link.segments.get(i); // ps.setInt(1, link.no); // ps.setInt(2, i); // ps.setDouble(3, segment.getX()); // ps.setDouble(4, segment.getY()); // } // }); } } // logger.debug("=>{},{}", links.size(), index); return links; }
public List<RoadLink> loadToDatabase(String mif, String mid) throws IOException { logger.debug("loading {}...", mid); CSVReader reader = new CSVReader(new FileReader(mid), ',', '"', 0); String[] row; List<RoadLink> links = new ArrayList(); while ((row = reader.readNext()) != null) { RoadLink link = new RoadLink(); link.no = Integer.valueOf(row[0]); link.fromNode = Integer.valueOf(row[1]); link.toNode = Integer.valueOf(row[2]); link.name = row[3]; link.length = Double.valueOf(row[4]); link.ft = row[5]; link.tf = row[6]; link.combine = row[7]; link.overhead = row[8]; link.xmin = Double.valueOf(row[9]); link.ymin = Double.valueOf(row[10]); link.xmax = Double.valueOf(row[11]); link.ymax = Double.valueOf(row[12]); links.add(link); roadNet.put(link.no, link); } for (final RoadLink link : links) { jdbcTemplate.update( sql1, link.no, link.fromNode, link.toNode, link.name, link.length, link.ft, link.tf, link.combine, link.overhead, link.xmin, link.ymin, link.xmax, link.ymax); } Charset charset = Charset.forName("UTF-8"); BufferedReader mifReader = Files.newBufferedReader(Paths.get(mif), charset); String line; int index = -1; int pos = -1; int segs = -1; Point2D prePoint = null; while ((line = mifReader.readLine()) != null) { List<String> cols = Lists.newArrayList( Splitter.on(CharMatcher.BREAKING_WHITESPACE) .trimResults() .omitEmptyStrings() .split(line)); // logger.debug("{}", line); if (cols.get(0).compareTo("PLINE") == 0) { index++; segs = Integer.valueOf(cols.get(1)); pos = 0; prePoint = null; } else if (cols.get(0).compareTo("LINE") == 0) { index++; RoadLink link = links.get(index); // link.segments.add(new Point2D.Double(Double.valueOf(cols.get(1)), // Double.valueOf(cols.get(2)))); // link.segments.add(new Point2D.Double(Double.valueOf(cols.get(3)), // Double.valueOf(cols.get(4)))); Segment seg = new Segment(); seg.start = new Point2D.Double(Double.valueOf(cols.get(1)), Double.valueOf(cols.get(2))); seg.end = new Point2D.Double(Double.valueOf(cols.get(3)), Double.valueOf(cols.get(4))); seg.length = seg.start.distance(seg.end); link.segments.add(seg); } else if (index >= 0) { if (prePoint == null) { prePoint = new Point2D.Double(Double.valueOf(cols.get(0)), Double.valueOf(cols.get(1))); } else { Segment seg = new Segment(); seg.start = prePoint; prePoint = new Point2D.Double(Double.valueOf(cols.get(0)), Double.valueOf(cols.get(1))); seg.end = prePoint; seg.length = seg.start.distance(seg.end); RoadLink link = links.get(index); link.segments.add(seg); } // RoadLink link = links.get(index); // link.segments.add(new Point2D.Double(Double.valueOf(cols.get(0)), // Double.valueOf(cols.get(1)))); } } return links; }