static Object coerceToJava ( XObject xo ) throws TransformerException { if ( xo instanceof XBoolean ) { return xo . bool ( ) ; } else if ( xo instanceof XNumber ) { return xo . num ( ) ; } else if ( xo instanceof XString ) { return xo . str ( ) ; } else if ( xo instanceof XNodeSet ) { NodeList nodes = xo . nodelist ( ) ; // if there is only one node in the nodeset return it rather than the list if ( nodes . getLength ( ) == 1 ) { return nodes . item ( 0 ) ; } else { return nodes ; } } else { // unexpected result type throw new AssertionError ( ) ; } }
Return the Java value corresponding to an XPath result .