public static Text[] toTextArray(Document doc,Object o) throws PageException {
  if (o instanceof Node[]) {
    Node[] nodes=(Node[])o;
    if (_isAllOfSameType(nodes,Node.TEXT_NODE))     return (Text[])nodes;
    Text[] textes=new Text[nodes.length];
    for (int i=0; i < nodes.length; i++) {
      textes[i]=toText(doc,nodes[i]);
    }
    return textes;
  }
 else   if (o instanceof Collection) {
    Collection coll=(Collection)o;
    Iterator<Object> it=coll.valueIterator();
    List<Text> textes=new ArrayList<Text>();
    while (it.hasNext()) {
      textes.add(toText(doc,it.next()));
    }
    return textes.toArray(new Text[textes.size()]);
  }
  Node[] nodes=_toNodeArray(doc,o);
  if (nodes != null)   return toTextArray(doc,nodes);
  try {
    return new Text[]{toText(doc,o)};
  }
 catch (  ExpressionException e) {
    throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Text Array");
  }
}

public static Text [ ] toTextArray ( Document doc , Object o ) throws PageException { if ( o instanceof Node [ ] ) { Node [ ] nodes = ( Node [ ] ) o ; if ( _isAllOfSameType ( nodes , Node . TEXT_NODE ) ) return ( Text [ ] ) nodes ; Text [ ] textes = new Text [ nodes . length ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { textes [ i ] = toText ( doc , nodes [ i ] ) ; } return textes ; } else if ( o instanceof Collection ) { Collection coll = ( Collection ) o ; Iterator < Object > it = coll . valueIterator ( ) ; List < Text > textes = new ArrayList < Text > ( ) ; while ( it . hasNext ( ) ) { textes . add ( toText ( doc , it . next ( ) ) ) ; } return textes . toArray ( new Text [ textes . size ( ) ] ) ; } Node [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return toTextArray ( doc , nodes ) ; try { return new Text [ ] { toText ( doc , o ) } ; } catch ( ExpressionException e ) { throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Text Array" ) ; } }
casts a value to a xml text array
