private static Node [ ] _toNodeArray ( Document doc , Object o ) { if ( o instanceof Node ) return new Node [ ] { ( Node ) o } ; // Node[] if ( o instanceof Node [ ] ) return ( ( Node [ ] ) o ) ; // NamedNodeMap else if ( o instanceof NamedNodeMap ) { NamedNodeMap map = ( NamedNodeMap ) o ; int len = map . getLength ( ) ; Node [ ] nodes = new Node [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { nodes [ i ] = map . item ( i ) ; } return nodes ; } // XMLAttributes else if ( o instanceof XMLAttributes ) { return _toNodeArray ( doc , ( ( XMLAttributes ) o ) . toNamedNodeMap ( ) ) ; } // NodeList else if ( o instanceof NodeList ) { NodeList list = ( NodeList ) o ; int len = list . getLength ( ) ; Node [ ] nodes = new Node [ len ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { nodes [ i ] = list . item ( i ) ; } return nodes ; } return null ; }
casts a value to a XML named Node Map