private boolean matchesUnit(Unit unit, String text, boolean isRegex) { return matches(unit.getProperty(), text, isRegex) || matchesConcept(unit, text, isRegex); }
private void searchUnits(List<Concept> concepts, List<? extends Unit> units, String text, boolean isRegex) { for (Unit unit : units) { if (matchesUnit(unit, text, isRegex)) concepts.add(unit); } }
public List<Concept> doSearch(UcumModel model, ConceptKind kind, String text, boolean isRegex) { List<Concept> concepts = new ArrayList<Concept>(); if (kind == null || kind == ConceptKind.PREFIX) searchPrefixes(concepts, model.getPrefixes(), text, isRegex); if (kind == null || kind == ConceptKind.BASEUNIT) searchUnits(concepts, model.getBaseUnits(), text, isRegex); if (kind == null || kind == ConceptKind.UNIT) searchUnits(concepts, model.getDefinedUnits(), text, isRegex); return concepts; }
private boolean matchesConcept(Concept concept, String text, boolean isRegex) { for (String name : concept.getNames()) { if (matches(name, text, isRegex)) return true; } if (matches(concept.getCode(), text, isRegex)) return true; if (matches(concept.getCodeUC(), text, isRegex)) return true; if (matches(concept.getPrintSymbol(), text, isRegex)) return true; return false; }
private void searchPrefixes(List<Concept> concepts, List<? extends Prefix> prefixes, String text, boolean isRegex) { for (Concept concept : prefixes) { if (matchesConcept(concept, text, isRegex)) concepts.add(concept); } }
public List<Concept> doSearch(UcumModel model, ConceptKind kind, String text, boolean isRegex) { List<Concept> concepts = new ArrayList<Concept>(); if (kind == null || kind == ConceptKind.PREFIX) searchPrefixes(concepts, model.getPrefixes(), text, isRegex); if (kind == null || kind == ConceptKind.BASEUNIT) searchUnits(concepts, model.getBaseUnits(), text, isRegex); if (kind == null || kind == ConceptKind.UNIT) searchUnits(concepts, model.getDefinedUnits(), text, isRegex); return concepts; }
private boolean matchesConcept(Concept concept, String text, boolean isRegex) { for (String name : concept.getNames()) { if (matches(name, text, isRegex)) return true; } if (matches(concept.getCode(), text, isRegex)) return true; if (matches(concept.getCodeUC(), text, isRegex)) return true; if (matches(concept.getPrintSymbol(), text, isRegex)) return true; return false; }
private void searchPrefixes(List<Concept> concepts, List<? extends Prefix> prefixes, String text, boolean isRegex) { for (Concept concept : prefixes) { if (matchesConcept(concept, text, isRegex)) concepts.add(concept); } }
private boolean matchesUnit(Unit unit, String text, boolean isRegex) { return matches(unit.getProperty(), text, isRegex) || matchesConcept(unit, text, isRegex); }
private void searchUnits(List<Concept> concepts, List<? extends Unit> units, String text, boolean isRegex) { for (Unit unit : units) { if (matchesUnit(unit, text, isRegex)) concepts.add(unit); } }