POFilter extends net.sf.okapi.filters.po.POFilter { Set<String> getUsagesFromSkeleton(String skeleton) { Set<String> locations = new LinkedHashSet<>(); Pattern pattern = Pattern.compile(USAGE_LOCATION_PATTERN); Matcher matcher = pattern.matcher(skeleton); while (matcher.find()) { locations.add(matcher.group(USAGE_LOCATION_GROUP_NAME)); } return locations; }  @Override String getName(); @Override List<FilterConfiguration> getConfigurations(); @Override void open(RawDocument input); @Override boolean hasNext(); @Override Event next(); @Override EncoderManager getEncoderManager(); static final String FILTER_CONFIG_ID; }
@Test public void getUsagesFromSkeleton() { String skeleton = "#. Comments\n" + "#: core/logic/week_in_review_email_logic.py:49\n" + "#: core/logic/week_in_review_email_logic.py:72\n" + "msgid \"repin\"\n" + "msgid_plural \"repins\"\n" + "msgstr[0] \"repin-ru\"\n" + "msgstr[1] \"repins-ru-1\"\n" + "msgstr[2] \"repins-ru-2\"\n"; POFilter poFilter = new POFilter(); List<String> usages = new ArrayList<>(poFilter.getUsagesFromSkeleton(skeleton)); assertEquals("core/logic/week_in_review_email_logic.py:49", usages.get(0)); assertEquals("core/logic/week_in_review_email_logic.py:72", usages.get(1)); }
@Test public void getUsagesFromSkeletonNone() { String skeleton = "#. Comments\n" + "msgid \"repin\"\n" + "msgid_plural \"repins\"\n" + "msgstr[0] \"repin-ru\"\n" + "msgstr[1] \"repins-ru-1\"\n" + "msgstr[2] \"repins-ru-2\"\n"; POFilter poFilter = new POFilter(); List<String> usages = new ArrayList<>(poFilter.getUsagesFromSkeleton(skeleton)); assertEquals(0, usages.size()); }