If the match succeeds then more information can be obtained via the start, end, and group methods.
339340341342343344345346347348349
if (line == null) return null; if (line.startsWith("#")) continue; if (line.trim().length() == 0) continue; //System.out.printf("line %s%n", line); matcher = vinfo.p.matcher(line); if (matcher.matches()) break; System.out.printf("FAIL %s%n", line); } recno++; return new StationData(vinfo.sm, matcher);
260261262263264265266267268269270
return new String(cc, 0, count); } boolean match(String header, Message m) { Matcher matcher = pattern.matcher(header); if (!matcher.matches()) return false; if (first == null) { first = m; } else if (m.hashCode() != first.hashCode()) { System.out.println(" DDS doesnt match pqact= " + pats);
316317318319320321322323324325326
return count; } */ String norm(String s) { Matcher matcher = pattern.matcher(s); if (!matcher.matches()) return s; return matcher.group(1); } Map<Integer, List<String>> problems = new TreeMap<Integer, List<String>>();
497498499500501502503504505506507
private static final Pattern wmoPattern = Pattern.compile(".*([IJ]..... ....) .*"); static String extractWMO(String header) { Matcher matcher = wmoPattern.matcher( header); if (!matcher.matches()) { //out.format("***header failed= %s\n", header); return null; } return matcher.group(1); }
882883884885886887888889890891892
RandomAccessFile raf = new RandomAccessFile(filein, "r"); MessageScanner scan = new MessageScanner(raf); while (scan.hasNext()) { Message m = scan.next(); Matcher matcher = p.matcher(m.getHeader()); if (matcher.matches()) { scan.writeCurrentMessage(wbc); System.out.println(" found match "+m.getHeader()); } } raf.close();
439440441442443444445446447448449
while (true) { line = timeSeriesRaf.readLine(); if (line == null) return null; // only on EOF if (line.trim().length() == 0) continue; matcher = seriesVinfo.p.matcher(line); if (matcher.matches()) break; System.out.printf("FAIL TimeSeriesIter <%s>%n", line); } countRead++; return new TimeSeriesData(matcher);
512513514515516517518519520521522
@Override public StructureData next() throws IOException { if (!hasNext()) return null; Matcher matcher = profileVinfo.p.matcher(lines.get(countRead)); StructureData sd; if (matcher.matches()) sd = new StructureDataRegexp(profileVinfo.sm, matcher); else throw new IllegalStateException("line = "+lines.get(countRead)+ "pattern = "+profileVinfo.p ); countRead++; return sd;
302303304305306307308309310311312
public static final String getServerLocation(String repositoryLocation) { // Try to parse the server URL from the repository URL Pattern urlPattern = Pattern.compile("(.*)/" + Protocol.REPOSITORIES + "/[^/]*/?"); Matcher matcher = urlPattern.matcher(repositoryLocation); if (matcher.matches() && matcher.groupCount() == 1) { return matcher.group(1); } else { return null; }
499500501502503504505506507508509
line = raf.readLine(); if (line == null) break; if (line.startsWith("#")) continue; if (line.trim().length() == 0) continue; Matcher matcher = p.matcher(line); return matcher.matches(); } return false; } @Override
800801802803804805806807808809810
long stnPos = stnInfo.rafile.getFilePointer(); String line = stnInfo.rafile.readLine(); if (line == null) break; Matcher matcher = stnInfo.p.matcher(line); if (!matcher.matches()) { System.out.printf("FAIL %s%n", line); continue; } String svalue = matcher.group(f.fldno); Long id = Long.parseLong(svalue.trim());