src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 283                     acc.set(bean,collection);
 284             }
 285             collection.clear();
 286             return collection;
 287         }
 288 
 289         public void addToPack(T collection, Object o) {
 290             collection.add(o);
 291         }
 292 
 293         public void endPacking( T collection, BeanT bean, Accessor<BeanT,T> acc ) throws AccessorException {
 294             // this needs to be done in the endPacking, because
 295             // sometimes the accessor uses an adapter, and the adapter needs to see
 296             // the whole thing.
 297 
 298             // but always doing so causes a problem when this collection property
 299             // is getter-only
 300 
 301             // invoke set when possible (see Issue 488)
 302             try {

 303                 acc.set(bean,collection);

 304             } catch (AccessorException ae) {
 305                 if(acc.isAdapted()) throw ae;
 306             }
 307         }
 308 
 309         public void reset(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException {
 310             T collection = acc.get(bean);
 311             if(collection == null) {
 312                 return;
 313             }
 314             collection.clear();
 315         }
 316     }
 317 
 318     /**
 319      * {@link Lister} for IDREFS.
 320      */
 321     private static final class IDREFS<BeanT,PropT> extends Lister<BeanT,PropT,String,IDREFS<BeanT,PropT>.Pack> {
 322         private final Lister<BeanT,PropT,Object,Object> core;
 323         /**


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 283                     acc.set(bean,collection);
 284             }
 285             collection.clear();
 286             return collection;
 287         }
 288 
 289         public void addToPack(T collection, Object o) {
 290             collection.add(o);
 291         }
 292 
 293         public void endPacking( T collection, BeanT bean, Accessor<BeanT,T> acc ) throws AccessorException {
 294             // this needs to be done in the endPacking, because
 295             // sometimes the accessor uses an adapter, and the adapter needs to see
 296             // the whole thing.
 297 
 298             // but always doing so causes a problem when this collection property
 299             // is getter-only
 300 
 301             // invoke set when possible (see Issue 488)
 302             try {
 303                 if (acc.isAdapted()) {
 304                     acc.set(bean,collection);
 305                 }
 306             } catch (AccessorException ae) {
 307                 if(acc.isAdapted()) throw ae;
 308             }
 309         }
 310 
 311         public void reset(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException {
 312             T collection = acc.get(bean);
 313             if(collection == null) {
 314                 return;
 315             }
 316             collection.clear();
 317         }
 318     }
 319 
 320     /**
 321      * {@link Lister} for IDREFS.
 322      */
 323     private static final class IDREFS<BeanT,PropT> extends Lister<BeanT,PropT,String,IDREFS<BeanT,PropT>.Pack> {
 324         private final Lister<BeanT,PropT,Object,Object> core;
 325         /**