@Test public void testLevel3() { final Mapping m = new Mapping("/content:3"); assertEquals("bar1", m.getResourceType("/content/foo/bar1", "nt:unstructured")); assertEquals("bar2", m.getResourceType("/content/foo/bar2/wii", "nt:unstructured")); assertEquals("bar3", m.getResourceType("/content/foo/bar3/wii2/xx", "nt:unstructured")); assertNull(m.getResourceType("/", "nt:unstructured")); assertNull(m.getResourceType("/content", "nt:unstructured")); assertNull(m.getResourceType("/content/foo", "nt:unstructured")); }
String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result; }
Mapping { String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result; } }
Mapping { String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result; } Mapping(String definition); }
Mapping { String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result; } Mapping(String definition); @Override String toString(); }
Mapping { String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result; } Mapping(String definition); @Override String toString(); static final String DEFAULT_NODE_TYPE; }