static private int getPathDepth ( INode inode ) throws IOException { // calculate the depth of this inode from root int depth = 1 ; INode node ; // node on the path to the root for ( node = inode ; node . parent != null ; node = node . parent ) { depth ++ ; } // parent should be root if ( node . isRoot ( ) ) { return depth ; } // invalid inode throw new IOException ( "Invalid inode: " + inode . getLocalName ( ) ) ; }
Get the depth of node inode from root