public TreeBean() { String[] components = {"< a4j:ajaxListener >", "< a4j:keepAlive >", "< a4j:actionparam >"}; String[][] attributes = { {"type"}, {"ajaxOnly", "beanName"}, {"actionListener", "assignTo", "binding", "converter", "id", "name", "noEscape", "value"} }; if (data == null) { data = new TreeNodeImpl<String>(); for (int i = 0; i < components.length; i++) { TreeNode<String> child = new TreeNodeImpl<String>(); child.setData(components[i]); data.addChild(components[i], child); for (int j = 0; j < attributes[i].length; j++) { TreeNode<String> grandChild = new TreeNodeImpl<String>(); grandChild.setData(attributes[i][j]); child.addChild(attributes[i][j], grandChild); } } } }
public void begin(String namespace, String name, Attributes attributes) throws Exception { super.begin(namespace, name, attributes); level++; XmlNodeData xmlNodeData = new XmlNodeData(); xmlNodeData.setName(name); xmlNodeData.setNamespace(namespace); String id = null; if (attributes != null) { int length = attributes.getLength(); for (int i = 0; i < length; i++) { xmlNodeData.setAttribute(attributes.getQName(i), attributes.getValue(i)); } id = attributes.getValue("id"); } if (exclusionSets.size() == level) { exclusionSets.add(null); } if (id == null || id.length() == 0) { int currentId = 0; if (idsList.size() <= level) { for (int i = idsList.size(); i <= level; i++) { idsList.add(null); } } else { Integer integer = (Integer) idsList.get(level); currentId = integer.intValue() + 1; } Set exclusions = (Set) exclusionSets.get(level); while (exclusions != null && exclusions.contains(Integer.toString(currentId))) { currentId++; } idsList.set(level, new Integer(currentId)); id = Integer.toString(currentId); } else { Set exclusions = (Set) exclusionSets.get(level); if (exclusions == null) { exclusions = new HashSet(); exclusionSets.set(level, exclusions); } exclusions.add(id); } TreeNode node = new TreeNodeImpl(); node.setData(xmlNodeData); this.treeNode.addChild(id, node); this.treeNodesList.add(this.treeNode); this.treeNode = node; }
public static TreeNode standardTraverseTree( OWLNamedClass cl, List stack, TreeNode node, boolean applyfilter) { Collection<RDFIndividual> instances = cl.getInstances(false); // adding a new category - isn't backed by any data, not even name?? TreeNode childClass = new TreeNodeImpl(); String instanceCountText = instances.size() > 0 ? " (" + instances.size() + ")" : ""; childClass.setData(new DummyOntologyProperty(cl.getLocalName() + instanceCountText)); // addChild(key, nodeImpl node.addChild(cl.getURI(), childClass); if (instances.size() > 0) { for (Iterator<RDFIndividual> jt = instances.iterator(); jt.hasNext(); ) { try { RDFIndividual individual = (RDFIndividual) jt.next(); // OWLIndividual individual = (OWLIndividual) jt.next(); TreeNode child = new TreeNodeImpl(); OntologyProperty ontologyProperty = new OntologyPropertyImpl(individual); boolean bMatchesFilter = true; if (applyfilter) { boolean b1 = ontologyProperty.getName().toLowerCase().contains(filterTreeString.toLowerCase()); boolean b2 = ontologyProperty .getHumanReadableName() .toLowerCase() .contains(filterTreeString.toLowerCase()); bMatchesFilter = b1 || b2; } if (bMatchesFilter) { child.setData(ontologyProperty); childClass.addChild(ontologyProperty.getURI(), child); } } catch (ClassCastException e) { log.debug("Shouldn't happen any more: Filtering out RDFIndividual"); } } } if (!stack.contains(cl)) { for (java.util.Iterator<OWLNamedClass> it = cl.getSubclasses(false).iterator(); it.hasNext(); ) { OWLNamedClass subClass = (OWLNamedClass) it.next(); stack.add(cl); standardTraverseTree(subClass, stack, childClass, applyfilter); stack.remove(cl); } } // remove nodes that don't apply the given filter if (applyfilter) { Iterator it = childClass.getChildren(); if (it.hasNext()) { // ok node still has other leaf elements - keep it } else { node.removeChild(cl.getURI()); } } return node; }
public void setSelTreeNode(TreeNode node) { this.selNode = new TreeNodeImpl(); selNode.setData(node.getData()); }