/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }
/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }
/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }