KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > tree > TreeUtils


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

8
9 package com.sleepycat.je.tree;
10
11 /**
12  * Miscellaneous Tree utilities.
13  */

14 public class TreeUtils {
15     
16     static private final String JavaDoc SPACES =
17     " " +
18     " " +
19     " " +
20     " ";
21
22     /**
23      * For tree dumper.
24      */

25     public static String JavaDoc indent(int nSpaces) {
26     return SPACES.substring(0, nSpaces);
27     }
28
29     public static String JavaDoc dumpByteArray(byte[] b) {
30         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
31         if (b != null) {
32         if (Key.DUMP_BINARY) {
33         for (int i = 0; i < b.length; i++) {
34             //sb.append(Integer.toHexString(b[i] & 0xFF));
35
sb.append(b[i] & 0xFF);
36             sb.append(" ");
37         }
38         } else {
39         sb.append(new String JavaDoc(b));
40         }
41         } else {
42             sb.append("null");
43         }
44         return sb.toString();
45     }
46 }
47
Popular Tags