KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > DatabaseUtil


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: DatabaseUtil.java,v 1.33 2006/10/30 21:14:12 bostic Exp $
7  */

8
9 package com.sleepycat.je;
10
11 /**
12  * Utils for use in the db package.
13  */

14 class DatabaseUtil {
15
16     /**
17      * Throw an exception if the parameter is null.
18      */

19     static void checkForNullParam(Object JavaDoc param, String JavaDoc name) {
20         if (param == null) {
21             throw new NullPointerException JavaDoc(name + " cannot be null");
22         }
23     }
24
25     /**
26      * Throw an exception if the dbt is null or the data field is not set.
27      */

28     static void checkForNullDbt(DatabaseEntry dbt,
29                 String JavaDoc name,
30                 boolean checkData) {
31         if (dbt == null) {
32             throw new NullPointerException JavaDoc
33         ("DatabaseEntry " + name + " cannot be null");
34         }
35
36         if (checkData) {
37             if (dbt.getData() == null) {
38                 throw new NullPointerException JavaDoc
39             ("Data field for DatabaseEntry " +
40              name + " cannot be null");
41             }
42         }
43     }
44
45     /**
46      * Throw an exception if the key dbt has the partial flag set. This method
47      * should be called for all put() operations.
48      */

49     static void checkForPartialKey(DatabaseEntry dbt) {
50         if (dbt.getPartial()) {
51             throw new IllegalArgumentException JavaDoc
52         ("A partial key DatabaseEntry is not allowed");
53         }
54     }
55 }
56
Popular Tags