private static Permission[] flatten(Permission[] pa){
  List l=new ArrayList(pa.length);
  for (int i=0; i < pa.length; i++) {
    Permission p=pa[i];
    if (p instanceof GrantPermission) {
      l.addAll(Arrays.asList(((GrantPermission)p).grants));
    }
 else {
      l.add(p);
    }
  }
  return (Permission[])l.toArray(new Permission[l.size()]);
}

private static Permission [ ] flatten ( Permission [ ] pa ) { List l = new ArrayList ( pa . length ) ; for ( int i = 0 ; i < pa . length ; i ++ ) { Permission p = pa [ i ] ; if ( p instanceof GrantPermission ) { l . addAll ( Arrays . asList ( ( ( GrantPermission ) p ) . grants ) ) ; } else { l . add ( p ) ; } } return ( Permission [ ] ) l . toArray ( new Permission [ l . size ( ) ] ) ; }
returns an array containing all non - grantpermission permissions in the given permission array , including those contained in nested grantpermissions in the array .
