All Downloads are FREE. Search and download functionalities are using the official Maven repository.

persistence.ArrayClass Maven / Gradle / Ivy

The newest version!
package persistence;

import java.util.Iterator;
import java.util.NoSuchElementException;

public final class ArrayClass extends PersistentClass {
	transient int header;

	public ArrayClass() {
	}

	ArrayClass(final Store store, Class componentType, int length) {
		this(store, new Field("element",componentType).typeCode, length);
	}

	ArrayClass(final Store store, char typeCode, int length) {
		super(store, PersistentArray.class);
		setTypeCode(typeCode);
		setLength(length);
	}

	void setup() {
		super.setup();
		header=size;
		size+=new Field("element",getTypeCode()).size*getLength();
	}

	Field getField(int index) {
		if(map==null) setup();
		int length=getLength();
		if(index fieldIterator() {
		if(map==null) setup();
		return new Iterator() {
			int length=getLength();
			int index=0;

			public boolean hasNext() {
				return index=length) throw new NoSuchElementException();
				return getField(index++);
			}

			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}

	public int getLength() {
		return get("length");
	}

	public void setLength(int n) {
		set("length",n);
	}

	public char getTypeCode() {
		return get("typeCode");
	}

	public void setTypeCode(char c) {
		set("typeCode",c);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy