本文整理汇总了Java中org.h2.mvstore.DataUtils.newIllegalArgumentException方法的典型用法代码示例。如果您正苦于以下问题:Java DataUtils.newIllegalArgumentException方法的具体用法?Java DataUtils.newIllegalArgumentException怎么用?Java DataUtils.newIllegalArgumentException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.mvstore.DataUtils
的用法示例。
在下文中一共展示了DataUtils.newIllegalArgumentException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
/**
* Add an entry to the cache. The entry may or may not exist in the
* cache yet. This method will usually mark unknown entries as cold and
* known entries as hot.
*
* @param key the key (may not be null)
* @param hash the hash
* @param value the value (may not be null)
* @param memory the memory used for the given entry
* @return the old value, or null if there was no resident entry
*/
synchronized V put(long key, int hash, V value, int memory) {
if (value == null) {
throw DataUtils.newIllegalArgumentException(
"The value may not be null");
}
V old;
Entry<V> e = find(key, hash);
if (e == null) {
old = null;
} else {
old = e.value;
remove(key, hash);
}
if (memory > maxMemory) {
// the new entry is too big to fit
return old;
}
e = new Entry<V>();
e.key = key;
e.value = value;
e.memory = memory;
int index = hash & mask;
e.mapNext = entries[index];
entries[index] = e;
usedMemory += memory;
if (usedMemory > maxMemory) {
// old entries needs to be removed
evict();
// if the cache is full, the new entry is
// cold if possible
if (stackSize > 0) {
// the new cold entry is at the top of the queue
addToQueue(queue, e);
}
}
mapSize++;
// added entries are always added to the stack
addToStack(e);
return old;
}
示例2: serialize
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
/**
* Serialize the object to a byte array.
*
* @param obj the object to serialize
* @return the byte array
*/
public static byte[] serialize(Object obj) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(out);
os.writeObject(obj);
return out.toByteArray();
} catch (Throwable e) {
throw DataUtils.newIllegalArgumentException(
"Could not serialize {0}", obj, e);
}
}
示例3: deserialize
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
/**
* De-serialize the byte array to an object.
*
* @param data the byte array
* @return the object
*/
public static Object deserialize(byte[] data) {
try {
ByteArrayInputStream in = new ByteArrayInputStream(data);
ObjectInputStream is = new ObjectInputStream(in);
return is.readObject();
} catch (Throwable e) {
throw DataUtils.newIllegalArgumentException(
"Could not deserialize {0}", Arrays.toString(data), e);
}
}
示例4: addMap
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
/**
* Add the given shard.
*
* @param map the map
* @param min the lowest key, or null if no limit
* @param max the highest key, or null if no limit
*/
public void addMap(Map<K, V> map, K min, K max) {
if (min != null && max != null && keyType.compare(min, max) > 0) {
DataUtils.newIllegalArgumentException("Invalid range: {0} .. {1}", min, max);
}
int len = shards.length + 1;
Shard<K, V>[] newShards = Arrays.copyOf(shards, len);
Shard<K, V> newShard = new Shard<K, V>();
newShard.map = map;
newShard.minIncluding = min;
newShard.maxExcluding = max;
newShards[len - 1] = newShard;
shards = newShards;
}
示例5: FreeSpaceList
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
public FreeSpaceList(int firstFreeBlock, int blockSize) {
this.firstFreeBlock = firstFreeBlock;
if (Integer.bitCount(blockSize) != 1) {
throw DataUtils.newIllegalArgumentException("Block size is not a power of 2");
}
this.blockSize = blockSize;
clear();
}
示例6: FreeSpaceTree
import org.h2.mvstore.DataUtils; //导入方法依赖的package包/类
public FreeSpaceTree(int firstFreeBlock, int blockSize) {
this.firstFreeBlock = firstFreeBlock;
if (Integer.bitCount(blockSize) != 1) {
throw DataUtils.newIllegalArgumentException("Block size is not a power of 2");
}
this.blockSize = blockSize;
clear();
}