Back to project page Jello.
The source code is released under:
Apache License
If you think the Android project Jello listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.atteo.jello.store; //from w w w . j a v a2 s .c o m import java.util.Arrays; import com.google.inject.Inject; import com.google.inject.name.Named; public class HeaderPage extends Page { private short pageSize; private short blockSize; private int freeSpaceInfoPageId; private int klassManagerPageId; private int fileFormatVersion; private final byte[] magic; @Inject private HeaderPage(@Named("pageSize") final short pageSize, @Named("blockSize") final short blockSize, @Named("freeSpaceInfoPageId") final int freeSpaceInfoPageId, @Named("klassManagerPageId") final int klassManagerPageId, @Named("fileFormatVersion") final int fileFormatVersion, @Named("magic") final String magic) { super(); this.pageSize = pageSize; this.blockSize = blockSize; this.freeSpaceInfoPageId = freeSpaceInfoPageId; this.klassManagerPageId = klassManagerPageId; this.fileFormatVersion = fileFormatVersion; this.magic = magic.getBytes(); byteBuffer.put(magic.getBytes()); byteBuffer.putInt(fileFormatVersion); byteBuffer.putShort(pageSize); byteBuffer.putShort(blockSize); byteBuffer.putInt(freeSpaceInfoPageId); byteBuffer.putInt(klassManagerPageId); } public short getBlockSize() { return blockSize; } public int getFileFormatVersion() { return fileFormatVersion; } public int getFreeSpaceInfoPageId() { return freeSpaceInfoPageId; } public int getKlassManagerPageId() { return klassManagerPageId; } public short getPageSize() { return pageSize; } public boolean load() { final byte[] readMagic = new byte[magic.length]; byteBuffer.position(0); byteBuffer.get(readMagic); if (!Arrays.equals(readMagic, magic)) return false; fileFormatVersion = byteBuffer.getInt(); pageSize = byteBuffer.getShort(); blockSize = byteBuffer.getShort(); freeSpaceInfoPageId = byteBuffer.getInt(); klassManagerPageId = byteBuffer.getInt(); return true; } }