com.sun.xml.bind.v2.runtime.reflect.PrimitiveArrayListerFloat Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.bind.v2.runtime.reflect;
import com.sun.xml.bind.api.AccessorException;
import com.sun.xml.bind.v2.runtime.XMLSerializer;
/**
* {@link Lister} for primitive type arrays.
*
* Auto-generated, do not edit.
*
*
* B y t e ArrayLister is used as the master to generate the rest of the
* lister classes. Do not modify the generated copies.
*
*/
final class PrimitiveArrayListerFloat extends Lister {
private PrimitiveArrayListerFloat() {
}
/*package*/ static void register() {
Lister.primitiveArrayListers.put(Float.TYPE,new PrimitiveArrayListerFloat());
}
public ListIterator iterator(final float[] objects, XMLSerializer context) {
return new ListIterator() {
int idx=0;
public boolean hasNext() {
return idx acc) {
return new FloatArrayPack();
}
public void addToPack(FloatArrayPack objects, Float o) {
objects.add(o);
}
public void endPacking( FloatArrayPack pack, BeanT bean, Accessor acc ) throws AccessorException {
acc.set(bean,pack.build());
}
public void reset(BeanT o,Accessor acc) throws AccessorException {
acc.set(o,new float[0]);
}
static final class FloatArrayPack {
float[] buf = new float[16];
int size;
void add(Float b) {
if(buf.length==size) {
// realloc
float[] nb = new float[buf.length*2];
System.arraycopy(buf,0,nb,0,buf.length);
buf = nb;
}
if(b!=null)
buf[size++] = b;
}
float[] build() {
if(buf.length==size)
// if we are lucky enough
return buf;
float[] r = new float[size];
System.arraycopy(buf,0,r,0,size);
return r;
}
}
}