325N/A/*
325N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.bind.v2.runtime.reflect;
325N/A
325N/Aimport com.sun.xml.internal.bind.api.AccessorException;
325N/Aimport com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
325N/A
325N/A/**
325N/A * {@link Lister} for primitive type arrays.
325N/A *
325N/A * <p>
325N/A * B y t e ArrayLister is used as the master to generate the rest of the
325N/A * lister classes. Do not modify the generated copies.
325N/A */
325N/Afinal class PrimitiveArrayListerLong<BeanT> extends Lister<BeanT,long[],Long,PrimitiveArrayListerLong.LongArrayPack> {
325N/A
325N/A private PrimitiveArrayListerLong() {
325N/A }
325N/A
325N/A /*package*/ static void register() {
325N/A Lister.primitiveArrayListers.put(Long.TYPE,new PrimitiveArrayListerLong());
325N/A }
325N/A
325N/A public ListIterator<Long> iterator(final long[] objects, XMLSerializer context) {
325N/A return new ListIterator<Long>() {
325N/A int idx=0;
325N/A public boolean hasNext() {
325N/A return idx<objects.length;
325N/A }
325N/A
325N/A public Long next() {
325N/A return objects[idx++];
325N/A }
325N/A };
325N/A }
325N/A
325N/A public LongArrayPack startPacking(BeanT current, Accessor<BeanT, long[]> acc) {
325N/A return new LongArrayPack();
325N/A }
325N/A
325N/A public void addToPack(LongArrayPack objects, Long o) {
325N/A objects.add(o);
325N/A }
325N/A
325N/A public void endPacking( LongArrayPack pack, BeanT bean, Accessor<BeanT,long[]> acc ) throws AccessorException {
325N/A acc.set(bean,pack.build());
325N/A }
325N/A
325N/A public void reset(BeanT o,Accessor<BeanT,long[]> acc) throws AccessorException {
325N/A acc.set(o,new long[0]);
325N/A }
325N/A
325N/A static final class LongArrayPack {
325N/A long[] buf = new long[16];
325N/A int size;
325N/A
325N/A void add(Long b) {
325N/A if(buf.length==size) {
325N/A // realloc
325N/A long[] nb = new long[buf.length*2];
325N/A System.arraycopy(buf,0,nb,0,buf.length);
325N/A buf = nb;
325N/A }
325N/A if(b!=null)
325N/A buf[size++] = b;
325N/A }
325N/A
325N/A long[] build() {
325N/A if(buf.length==size)
325N/A // if we are lucky enough
325N/A return buf;
325N/A
325N/A long[] r = new long[size];
325N/A System.arraycopy(buf,0,r,0,size);
325N/A return r;
325N/A }
325N/A }
325N/A}