persistence.PersistentArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databeans Show documentation
Show all versions of databeans Show documentation
Fully object-oriented persistence for Java.
The newest version!
package persistence;
public final class PersistentArray extends PersistentObject implements Array {
public PersistentArray() {
}
@SuppressWarnings("unchecked")
public PersistentArray(final Store store, C component[]) {
this(store, (Class)component.getClass().getComponentType(), component.length);
copy(component, 0, this, 0, component.length);
}
public PersistentArray(final Store store, final Class componentType, final int length) {
super(store, new ArrayClass<>(store, componentType, length));
}
@SuppressWarnings("unchecked")
private ArrayClass arrayClass() {
return (ArrayClass)clazz;
}
public int length() {
return arrayClass().getLength();
}
public char typeCode() {
return arrayClass().getTypeCode();
}
public C get(int index) {
return get(arrayClass().getField(index));
}
public void set(int index, C value) {
set(arrayClass().getField(index),value);
}
public static void copy(Array extends C> src, int src_position, Array dst, int dst_position, int length) {
if(src_position=0;i--) dst.set(dst_position+i,src.get(src_position+i));
else for(int i=0;i void copy(C src[], int src_position, Array dst, int dst_position, int length) {
if(src_position=0;i--) dst.set(dst_position+i,src[src_position+i]);
else for(int i=0;i void copy(Array extends C> src, int src_position, C dst[], int dst_position, int length) {
if(src_position=0;i--) dst[dst_position+i]=src.get(src_position+i);
else for(int i=0;i