@Test public void testParam() throws Exception { assertTrue(parseParam("[PRIDE,PRIDE:0000114,iTRAQ reagent 114,]") instanceof CVParam); assertTrue(parseParam("[, ,tolerance,0.5]") instanceof UserParam); assertTrue(parseParam("[, ,,0.5]") == null); assertTrue(parseParam("null") == null); }
public static Param parseParam(String target) { target = parseString(target); if (target == null) { return null; } String regexp = "\\[([^,]+)?,([^,]+)?,([^,]+),([^,]*)\\]"; Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (matcher.find()) { String cvLabel = matcher.group(1); String accession = matcher.group(2); String name = matcher.group(3); String value = matcher.group(4); if (isEmpty(name)) { return null; } if (isEmpty(cvLabel) && isEmpty(accession)) { return new UserParam(name, value); } else { return new CVParam(cvLabel, accession, name, value); } } else { return null; } }
MZTabUtils { public static Param parseParam(String target) { target = parseString(target); if (target == null) { return null; } String regexp = "\\[([^,]+)?,([^,]+)?,([^,]+),([^,]*)\\]"; Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (matcher.find()) { String cvLabel = matcher.group(1); String accession = matcher.group(2); String name = matcher.group(3); String value = matcher.group(4); if (isEmpty(name)) { return null; } if (isEmpty(cvLabel) && isEmpty(accession)) { return new UserParam(name, value); } else { return new CVParam(cvLabel, accession, name, value); } } else { return null; } } }
MZTabUtils { public static Param parseParam(String target) { target = parseString(target); if (target == null) { return null; } String regexp = "\\[([^,]+)?,([^,]+)?,([^,]+),([^,]*)\\]"; Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (matcher.find()) { String cvLabel = matcher.group(1); String accession = matcher.group(2); String name = matcher.group(3); String value = matcher.group(4); if (isEmpty(name)) { return null; } if (isEmpty(cvLabel) && isEmpty(accession)) { return new UserParam(name, value); } else { return new CVParam(cvLabel, accession, name, value); } } else { return null; } }  }
MZTabUtils { public static Param parseParam(String target) { target = parseString(target); if (target == null) { return null; } String regexp = "\\[([^,]+)?,([^,]+)?,([^,]+),([^,]*)\\]"; Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (matcher.find()) { String cvLabel = matcher.group(1); String accession = matcher.group(2); String name = matcher.group(3); String value = matcher.group(4); if (isEmpty(name)) { return null; } if (isEmpty(cvLabel) && isEmpty(accession)) { return new UserParam(name, value); } else { return new CVParam(cvLabel, accession, name, value); } } else { return null; } }  static boolean isEmpty(String s); static String parseString(String target); static String printDouble(Double value); static Param parseParam(String target); static SplitList<String> parseStringList(char splitChar, String target); static SplitList<Param> parseParamList(String target); static SplitList<String> parseGOTermList(String target); static Integer parseInteger(String target); static Double parseDouble(String target); static SplitList<Double> parseDoubleList(String target); static String parseUnitId(String target); static URL parseURL(String target); static URI parseURI(String target); static SplitList<PublicationItem> parsePublicationItems(String target); static SplitList<SpecRef> parseSpecRefList(Unit unit, String target); static Modification parseModification(Section section, String target); static SplitList<Modification> parseModificationList(Section section, String target); }
MZTabUtils { public static Param parseParam(String target) { target = parseString(target); if (target == null) { return null; } String regexp = "\\[([^,]+)?,([^,]+)?,([^,]+),([^,]*)\\]"; Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (matcher.find()) { String cvLabel = matcher.group(1); String accession = matcher.group(2); String name = matcher.group(3); String value = matcher.group(4); if (isEmpty(name)) { return null; } if (isEmpty(cvLabel) && isEmpty(accession)) { return new UserParam(name, value); } else { return new CVParam(cvLabel, accession, name, value); } } else { return null; } }  static boolean isEmpty(String s); static String parseString(String target); static String printDouble(Double value); static Param parseParam(String target); static SplitList<String> parseStringList(char splitChar, String target); static SplitList<Param> parseParamList(String target); static SplitList<String> parseGOTermList(String target); static Integer parseInteger(String target); static Double parseDouble(String target); static SplitList<Double> parseDoubleList(String target); static String parseUnitId(String target); static URL parseURL(String target); static URI parseURI(String target); static SplitList<PublicationItem> parsePublicationItems(String target); static SplitList<SpecRef> parseSpecRefList(Unit unit, String target); static Modification parseModification(Section section, String target); static SplitList<Modification> parseModificationList(Section section, String target);  }