protected void removeChild(DestinationMapNode node) { childNodes.remove(node.getPath()); pruneIfEmpty(); } }
/** * Factory method to create a child node */ protected DestinationMapNode createChildNode() { return new DestinationMapNode(this); }
public void add(String[] paths, int idx, Object value) { if (idx >= paths.length) { values.add(value); } else { getChildOrCreate(paths[idx]).add(paths, idx + 1, value); } }
public void remove(String[] paths, int idx, Object value) { if (idx >= paths.length) { values.remove(value); pruneIfEmpty(); } else { getChildOrCreate(paths[idx]).remove(paths, ++idx, value); } }
protected void printNodes(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); String label = path; if (prefix.equals("topic")) { label = "Topics"; } else if (prefix.equals("queue")) { label = "Queues"; } writer.print("[ label = \""); writer.print(label); writer.println("\" ];"); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); printNodes(writer, child, prefix + ID_SEPARATOR + path); } }
protected String getPath(DestinationMapNode node) { String path = node.getPath(); if (path.equals("*")) { return "root"; } return path; } }
public void set(String[] paths, int idx, Object value) { if (idx >= paths.length) { values.clear(); values.add(value); } else { getChildOrCreate(paths[idx]).set(paths, idx + 1, value); } }
/** * Matches any entries in the map containing wildcards */ public void appendMatchingWildcards(Set answer, String[] paths, int idx) { if (idx - 1 > pathLength) { return; } DestinationMapNode wildCardNode = getChild(ANY_CHILD); if (wildCardNode != null) { wildCardNode.appendMatchingValues(answer, paths, idx + 1); } wildCardNode = getChild(ANY_DESCENDENT); if (wildCardNode != null) { answer.addAll(wildCardNode.getDesendentValues()); } }
public int getTopicRootChildCount() { return topicRootNode.getChildCount(); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void appendMatchingValues(Set answer, String[] paths, int idx) { appendMatchingValues(answer, paths, idx, true); }
/** * Returns a list of all the values from this node down the tree */ @SuppressWarnings({ "rawtypes", "unchecked" }) public Set getDesendentValues() { Set answer = new HashSet(); appendDescendantValues(answer); return answer; }
public void unsynchronizedPut(ActiveMQDestination key, Object value) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; put(childDestination, value); } return; } String[] paths = key.getDestinationPaths(); getRootNode(key).add(paths, 0, value); }
/** * Returns the child node for the given named path, lazily creating one if * it does not yet exist */ public DestinationMapNode getChildOrCreate(String path) { DestinationMapNode answer = (DestinationMapNode)childNodes.get(path); if (answer == null) { answer = createChildNode(); answer.path = path; childNodes.put(path, answer); } return answer; }
/** * Matches any entries in the map containing wildcards */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void appendMatchingWildcards(Set answer, String[] paths, int idx) { if (idx - 1 > pathLength) { return; } DestinationNode wildCardNode = getChild(ANY_CHILD); if (wildCardNode != null) { wildCardNode.appendMatchingValues(answer, paths, idx + 1); } wildCardNode = getChild(ANY_DESCENDENT); if (wildCardNode != null) { // for a wildcard Node match, add all values of the descendant node answer.addAll(wildCardNode.getValues()); // and all descendants for paths like ">.>" answer.addAll(wildCardNode.getDesendentValues()); } }
public void remove(String[] paths, int idx, Object value) { if (idx >= paths.length) { values.remove(value); pruneIfEmpty(); } else { getChildOrCreate(paths[idx]).remove(paths, ++idx, value); } }
protected void printNodeLinks(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(" -> "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(ID_SEPARATOR); writer.print(getPath(child)); writer.println(";"); printNodeLinks(writer, child, prefix + ID_SEPARATOR + path); } }
protected String getPath(DestinationMapNode node) { String path = node.getPath(); if (path.equals("*")) { return "root"; } return path; }
public void set(String[] paths, int idx, Object value) { if (idx >= paths.length) { values.clear(); values.add(value); } else { getChildOrCreate(paths[idx]).set(paths, idx + 1, value); } }
public int getQueueRootChildCount() { return queueRootNode.getChildCount(); }
@SuppressWarnings({"rawtypes", "unchecked"}) protected Set findWildcardMatches(ActiveMQDestination key, boolean deep) { String[] paths = key.getDestinationPaths(); Set answer = new HashSet(); getRootNode(key).appendMatchingValues(answer, paths, 0, deep); return answer; }