1 17 package org.apache.ldap.server.db.jdbm; 18 19 20 import org.apache.ldap.server.db.Tuple; 21 import org.apache.ldap.server.db.TupleBrowser; 22 23 import javax.naming.NamingException ; 24 import java.io.IOException ; 25 26 27 33 public class JdbmTupleBrowser implements TupleBrowser 34 { 35 36 private jdbm.helper.TupleBrowser jdbmBrowser; 37 38 private jdbm.helper.Tuple jdbmTuple = new jdbm.helper.Tuple(); 39 40 41 46 public JdbmTupleBrowser( jdbm.helper.TupleBrowser jdbmBrowser ) 47 { 48 this.jdbmBrowser = jdbmBrowser; 49 } 50 51 52 55 public boolean getNext( Tuple tuple ) throws NamingException 56 { 57 boolean isSuccess = false; 58 59 synchronized ( jdbmTuple ) 60 { 61 try 62 { 63 isSuccess = jdbmBrowser.getNext( jdbmTuple ); 64 } 65 catch ( IOException ioe ) 66 { 67 NamingException ne = new NamingException ( 68 "Failed on call to jdbm TupleBrowser.getNext()" ); 69 ne.setRootCause( ioe ); 70 throw ne; 71 } 72 73 if ( isSuccess ) 74 { 75 tuple.setKey( jdbmTuple.getKey() ); 76 tuple.setValue( jdbmTuple.getValue() ); 77 } 78 } 79 80 return isSuccess; 81 } 82 83 84 87 public boolean getPrevious( Tuple tuple ) throws NamingException 88 { 89 boolean isSuccess = false; 90 91 synchronized ( jdbmTuple ) 92 { 93 try 94 { 95 isSuccess = jdbmBrowser.getPrevious( jdbmTuple ); 96 } 97 catch ( IOException ioe ) 98 { 99 NamingException ne = new NamingException ( 100 "Failed on call to jdbm TupleBrowser.getPrevious()" ); 101 ne.setRootCause( ioe ); 102 throw ne; 103 } 104 105 if ( isSuccess ) 106 { 107 tuple.setKey( jdbmTuple.getKey() ); 108 tuple.setValue( jdbmTuple.getValue() ); 109 } 110 } 111 112 return isSuccess; 113 } 114 } 115 | Popular Tags |