// else if(Node.class.isAssignableFrom(javaClass))
else if(javaClass == Node.class)
{
DTMIterator iter = ((XRTreeFrag) xobj).asNodeIterator();
int rootHandle = iter.nextNode();
DTM dtm = iter.getDTM(rootHandle);
return dtm.getNode(dtm.getFirstChild(rootHandle));
}
else if(javaClass == java.lang.String.class)
{
return xobj.str();
}
else if(javaClass == Boolean.TYPE)
{
return xobj.bool() ? Boolean.TRUE : Boolean.FALSE;
}
else if(javaClass.isPrimitive())
{
return convertDoubleToNumber(xobj.num(), javaClass);
}
else
{
DTMIterator iter = ((XRTreeFrag) xobj).asNodeIterator();
int rootHandle = iter.nextNode();
DTM dtm = iter.getDTM(rootHandle);
Node child = dtm.getNode(dtm.getFirstChild(rootHandle));
if(javaClass.isAssignableFrom(child.getClass()))
return child;
else
return null;
}
}
// break; Unreachable
case XObject.CLASS_NODESET:
{
// GLP: I don't see the reason for the isAssignableFrom call
// instead of an == test as is used everywhere else.
// Besides, if the javaClass is a subclass of NodeIterator
// the condition will be true and we'll create a NodeIterator
// which may not match the javaClass, causing a RuntimeException.
// if((NodeIterator.class.isAssignableFrom(javaClass)) ||
if ( (javaClass == NodeIterator.class) ||
(javaClass == java.lang.Object.class) )
{
return xobj.nodeset();
}
// Same comment as above
// else if(NodeList.class.isAssignableFrom(javaClass))
else if(javaClass == NodeList.class)
{
return xobj.nodelist();
}
// Same comment as above
// else if(Node.class.isAssignableFrom(javaClass))
else if(javaClass == Node.class)
{
// Xalan ensures that iter() always returns an
// iterator positioned at the beginning.
DTMIterator ni = xobj.iter();
int handle = ni.nextNode();
if (handle != DTM.NULL)
return ni.getDTM(handle).getNode(handle); // may be null.
else
return null;
}
else if(javaClass == java.lang.String.class)
{
return xobj.str();
}
else if(javaClass == Boolean.TYPE)
{
return xobj.bool() ? Boolean.TRUE : Boolean.FALSE;
}
else if(javaClass.isPrimitive())
{
return convertDoubleToNumber(xobj.num(), javaClass);
}
else
{
DTMIterator iter = xobj.iter();
int childHandle = iter.nextNode();
DTM dtm = iter.getDTM(childHandle);
Node child = dtm.getNode(childHandle);
if(javaClass.isAssignableFrom(child.getClass()))
return child;
else
return null;
}