📄 blobpageimpl.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id: BLOBPageImpl.java,v 1.3 2002/12/29 11:15:55 per_nyfelt Exp $
package org.ozoneDB.blob;
import org.ozoneDB.OzoneObject;
/**
* One page of an ozone BLOB.
*
*
* @author <a href="http://www.softwarebuero.de/">SMB</a>
* @version $Revision: 1.3 $Date: 2002/12/29 11:15:55 $
*/
public class BLOBPageImpl extends OzoneObject implements BLOBPage {
byte[] data;
int space;
int size;
public BLOBPageImpl() {
}
public void init( int _space ) {
space = _space;
data = new byte[space];
size = 0;
}
public int size() {
return size;
}
/** */
public void write( byte[] b, int off ) {
if (off == 0 && b.length == space) {
data = b;
size = space;
} else {
int len = b.length;
// calculate the real length: 0 <= len <= (space-off)
len = Math.max( Math.min( space - off, len ), 0 );
System.arraycopy( b, 0, data, off, len );
size = off + len;
}
}
/** */
public byte[] read( int off, int len ) {
// calculate the real length: 0 <= len <= (size-off)
len = Math.max( Math.min( size - off, len ), 0 );
byte[] result = new byte[len];
System.arraycopy( data, off, result, 0, len );
//////////////////////////////////////////////////////
//System.out.println ("return an array with length "+result.length);
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -