@Test public void testSplitTagAndBasename() throws Exception { OwnLocalResources olr = new OwnLocalResources(); Pair<String,Path> pair = olr.splitTagAndBasename(new Path("hello/_native_centos7_liba.so")); assertEquals("centos7", pair.getFirst()); assertEquals("hello/liba.so", pair.getSecond().toString()); pair = olr.splitTagAndBasename(new Path("hello/_native_centos6_liba.so")); assertEquals("centos6", pair.getFirst()); assertEquals("hello/liba.so", pair.getSecond().toString()); pair = olr.splitTagAndBasename(new Path("a/b/c/d/_native_centos6_liba.so")); assertEquals("centos6", pair.getFirst()); assertEquals("a/b/c/d/liba.so", pair.getSecond().toString()); pair = olr.splitTagAndBasename(new Path("_native_centos6_liba.so")); assertEquals("centos6", pair.getFirst()); assertEquals("liba.so", pair.getSecond().toString()); pair = olr.splitTagAndBasename(new Path("_centos6_liba.so")); assertEquals(null, pair); pair = olr.splitTagAndBasename(new Path("_native_liba.so")); assertEquals(null, pair); pair = olr.splitTagAndBasename(new Path("_native_CENTOS7_liba.so")); assertEquals(null, pair); }
public Pair<String,Path> splitTagAndBasename(Path path){ String name = path.getName(); Path parent = path.getParent(); if(name.startsWith(LR_PREFIX) == false){ return null; } name = name.substring(LR_PREFIX.length()); int underscore = name.indexOf(LR_TAG_DELIM); if(underscore == -1){ return null; } String tag = name.substring(0, underscore); String basename = name.substring(underscore + 1); if(LR_ALL_TAGS.contains(tag) == false){ return null; } return new Pair<>(tag, new Path(parent, basename)); }
OwnLocalResources { public Pair<String,Path> splitTagAndBasename(Path path){ String name = path.getName(); Path parent = path.getParent(); if(name.startsWith(LR_PREFIX) == false){ return null; } name = name.substring(LR_PREFIX.length()); int underscore = name.indexOf(LR_TAG_DELIM); if(underscore == -1){ return null; } String tag = name.substring(0, underscore); String basename = name.substring(underscore + 1); if(LR_ALL_TAGS.contains(tag) == false){ return null; } return new Pair<>(tag, new Path(parent, basename)); } }
OwnLocalResources { public Pair<String,Path> splitTagAndBasename(Path path){ String name = path.getName(); Path parent = path.getParent(); if(name.startsWith(LR_PREFIX) == false){ return null; } name = name.substring(LR_PREFIX.length()); int underscore = name.indexOf(LR_TAG_DELIM); if(underscore == -1){ return null; } String tag = name.substring(0, underscore); String basename = name.substring(underscore + 1); if(LR_ALL_TAGS.contains(tag) == false){ return null; } return new Pair<>(tag, new Path(parent, basename)); } OwnLocalResources(String thisNodeTag);  OwnLocalResources(); }
OwnLocalResources { public Pair<String,Path> splitTagAndBasename(Path path){ String name = path.getName(); Path parent = path.getParent(); if(name.startsWith(LR_PREFIX) == false){ return null; } name = name.substring(LR_PREFIX.length()); int underscore = name.indexOf(LR_TAG_DELIM); if(underscore == -1){ return null; } String tag = name.substring(0, underscore); String basename = name.substring(underscore + 1); if(LR_ALL_TAGS.contains(tag) == false){ return null; } return new Pair<>(tag, new Path(parent, basename)); } OwnLocalResources(String thisNodeTag);  OwnLocalResources(); static Set<String> getLocalResourcesAllTags(); static String getThisLocalResourceTag(); Pair<String,Path> splitTagAndBasename(Path path); Map<Path,List<String>> filterLocalResources(Map<Path,List<String>> originLocalResources); }
OwnLocalResources { public Pair<String,Path> splitTagAndBasename(Path path){ String name = path.getName(); Path parent = path.getParent(); if(name.startsWith(LR_PREFIX) == false){ return null; } name = name.substring(LR_PREFIX.length()); int underscore = name.indexOf(LR_TAG_DELIM); if(underscore == -1){ return null; } String tag = name.substring(0, underscore); String basename = name.substring(underscore + 1); if(LR_ALL_TAGS.contains(tag) == false){ return null; } return new Pair<>(tag, new Path(parent, basename)); } OwnLocalResources(String thisNodeTag);  OwnLocalResources(); static Set<String> getLocalResourcesAllTags(); static String getThisLocalResourceTag(); Pair<String,Path> splitTagAndBasename(Path path); Map<Path,List<String>> filterLocalResources(Map<Path,List<String>> originLocalResources); static final String LR_PREFIX; static final String LR_TAG_CENTOS6; static final String LR_TAG_CENTOS7; static final String LR_TAG_MACOS10; static final String LR_TAG_DELIM; }