use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit by apache.
the class AbstractNodeType method getSubtypes.
//--------------------------------------------------------------------------
/**
* Returns the node types derived from this node type.
*
* @param directOnly if <code>true</code> only direct subtypes will be considered
*
* @return an <code>NodeTypeIterator</code>.
* @see NodeType#getSubtypes
* @see NodeType#getDeclaredSubtypes
*/
public NodeTypeIterator getSubtypes(boolean directOnly) {
NodeTypeIterator iter;
try {
iter = ntMgr.getAllNodeTypes();
} catch (RepositoryException e) {
// should never get here
log.error("failed to retrieve registered node types", e);
return NodeTypeIteratorAdapter.EMPTY;
}
ArrayList<NodeType> result = new ArrayList<NodeType>();
String thisName = getName();
while (iter.hasNext()) {
NodeType nt = iter.nextNodeType();
if (!nt.getName().equals(thisName)) {
if (directOnly) {
// direct subtypes only
for (String name : nt.getDeclaredSupertypeNames()) {
if (name.equals(thisName)) {
result.add(nt);
break;
}
}
} else {
// direct and indirect subtypes
if (nt.isNodeType(thisName)) {
result.add(nt);
}
}
}
}
return new NodeTypeIteratorAdapter(result);
}
Aggregations