@Test void testConvertNumberToOntologyTermStyle() { assertEquals("kg\\/m\\^\\[2\\]", unitResolverImpl.convertNumberToOntologyTermStyle("kg/m^2")); assertEquals("kg\\/m\\^\\[2\\]", unitResolverImpl.convertNumberToOntologyTermStyle("kg/m^²")); assertEquals("kg\\/m\\^\\[2\\]", unitResolverImpl.convertNumberToOntologyTermStyle("kg/m²")); }
String convertNumberToOntologyTermStyle(String term) { term = UnitHelper.superscriptToNumber(term.replaceAll("\\^", StringUtils.EMPTY)); Pattern pattern = Pattern.compile("\\w+(\\d+)"); Matcher matcher = pattern.matcher(term); if (matcher.find()) { String group = matcher.group(1); String modifiedPart = group.trim(); modifiedPart = "^[" + modifiedPart + "]"; term = term.replaceAll(group, modifiedPart); } return QueryParser.escape(term); }
UnitResolverImpl implements UnitResolver { String convertNumberToOntologyTermStyle(String term) { term = UnitHelper.superscriptToNumber(term.replaceAll("\\^", StringUtils.EMPTY)); Pattern pattern = Pattern.compile("\\w+(\\d+)"); Matcher matcher = pattern.matcher(term); if (matcher.find()) { String group = matcher.group(1); String modifiedPart = group.trim(); modifiedPart = "^[" + modifiedPart + "]"; term = term.replaceAll(group, modifiedPart); } return QueryParser.escape(term); } }
UnitResolverImpl implements UnitResolver { String convertNumberToOntologyTermStyle(String term) { term = UnitHelper.superscriptToNumber(term.replaceAll("\\^", StringUtils.EMPTY)); Pattern pattern = Pattern.compile("\\w+(\\d+)"); Matcher matcher = pattern.matcher(term); if (matcher.find()) { String group = matcher.group(1); String modifiedPart = group.trim(); modifiedPart = "^[" + modifiedPart + "]"; term = term.replaceAll(group, modifiedPart); } return QueryParser.escape(term); } UnitResolverImpl(OntologyService ontologyService); }
UnitResolverImpl implements UnitResolver { String convertNumberToOntologyTermStyle(String term) { term = UnitHelper.superscriptToNumber(term.replaceAll("\\^", StringUtils.EMPTY)); Pattern pattern = Pattern.compile("\\w+(\\d+)"); Matcher matcher = pattern.matcher(term); if (matcher.find()) { String group = matcher.group(1); String modifiedPart = group.trim(); modifiedPart = "^[" + modifiedPart + "]"; term = term.replaceAll(group, modifiedPart); } return QueryParser.escape(term); } UnitResolverImpl(OntologyService ontologyService); @Override Unit<? extends Quantity> resolveUnit(Attribute attr); }
UnitResolverImpl implements UnitResolver { String convertNumberToOntologyTermStyle(String term) { term = UnitHelper.superscriptToNumber(term.replaceAll("\\^", StringUtils.EMPTY)); Pattern pattern = Pattern.compile("\\w+(\\d+)"); Matcher matcher = pattern.matcher(term); if (matcher.find()) { String group = matcher.group(1); String modifiedPart = group.trim(); modifiedPart = "^[" + modifiedPart + "]"; term = term.replaceAll(group, modifiedPart); } return QueryParser.escape(term); } UnitResolverImpl(OntologyService ontologyService); @Override Unit<? extends Quantity> resolveUnit(Attribute attr);  }