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

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