1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<!--NewPage--> 3<HTML> 4<HEAD> 5<!-- Generated by javadoc (build 1.6.0_03) on Mon Apr 12 16:25:48 EDT 2010 --> 6<TITLE> 7SecondaryKeyCreator (Oracle - Berkeley DB Java API) 8</TITLE> 9 10<META NAME="date" CONTENT="2010-04-12"> 11 12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style"> 13 14<SCRIPT type="text/javascript"> 15function windowTitle() 16{ 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="SecondaryKeyCreator (Oracle - Berkeley DB Java API)"; 19 } 20} 21</SCRIPT> 22<NOSCRIPT> 23</NOSCRIPT> 24 25</HEAD> 26 27<BODY BGCOLOR="white" onload="windowTitle();"> 28<HR> 29 30 31<!-- ========= START OF TOP NAVBAR ======= --> 32<A NAME="navbar_top"><!-- --></A> 33<A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35<TR> 36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37<A NAME="navbar_top_firstrow"><!-- --></A> 38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SecondaryKeyCreator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49</TABLE> 50</TD> 51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 53</TD> 54</TR> 55 56<TR> 57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> 59 <A HREF="../../../com/sleepycat/db/SecondaryMultiKeyCreator.html" title="interface in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> 60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../index.html?com/sleepycat/db/SecondaryKeyCreator.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="SecondaryKeyCreator.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69</SCRIPT> 70<NOSCRIPT> 71 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 72</NOSCRIPT> 73 74 75</FONT></TD> 76</TR> 77<TR> 78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 82</TR> 83</TABLE> 84<A NAME="skip-navbar_top"></A> 85<!-- ========= END OF TOP NAVBAR ========= --> 86 87<HR> 88<!-- ======== START OF CLASS DATA ======== --> 89<H2> 90<FONT SIZE="-1"> 91com.sleepycat.db</FONT> 92<BR> 93Interface SecondaryKeyCreator</H2> 94<DL> 95<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../com/sleepycat/bind/serial/SerialSerialKeyCreator.html" title="class in com.sleepycat.bind.serial">SerialSerialKeyCreator</A>, <A HREF="../../../com/sleepycat/bind/serial/TupleSerialKeyCreator.html" title="class in com.sleepycat.bind.serial">TupleSerialKeyCreator</A>, <A HREF="../../../com/sleepycat/bind/serial/TupleSerialMarshalledKeyCreator.html" title="class in com.sleepycat.bind.serial">TupleSerialMarshalledKeyCreator</A>, <A HREF="../../../com/sleepycat/bind/tuple/TupleTupleKeyCreator.html" title="class in com.sleepycat.bind.tuple">TupleTupleKeyCreator</A>, <A HREF="../../../com/sleepycat/bind/tuple/TupleTupleMarshalledKeyCreator.html" title="class in com.sleepycat.bind.tuple">TupleTupleMarshalledKeyCreator</A></DD> 96</DL> 97<HR> 98<DL> 99<DT><PRE>public interface <B>SecondaryKeyCreator</B></DL> 100</PRE> 101 102<P> 103The interface implemented for extracting single-valued secondary keys from 104primary records. 105<p> 106The key creator object is specified by calling 107<A HREF="../../../com/sleepycat/db/SecondaryConfig.html#setKeyCreator(com.sleepycat.db.SecondaryKeyCreator)"><CODE>SecondaryConfig.setKeyCreator</CODE></A>. 108The secondary database configuration is specified when calling 109<A HREF="../../../com/sleepycat/db/Environment.html#openSecondaryDatabase(com.sleepycat.db.Transaction, java.lang.String, java.lang.String, com.sleepycat.db.Database, com.sleepycat.db.SecondaryConfig)"><CODE>Environment.openSecondaryDatabase</CODE></A>. 110<p> 111For example: 112<pre> 113 class MyKeyCreator implements SecondaryKeyCreator { 114 public boolean createSecondaryKey(SecondaryDatabase secondary, 115 DatabaseEntry key, 116 DatabaseEntry data, 117 DatabaseEntry result) 118 throws DatabaseException { 119 // 120 // DO HERE: Extract the secondary key from the primary key and 121 // data, and set the secondary key into the result parameter. 122 // 123 return true; 124 } 125 } 126 ... 127 SecondaryConfig secConfig = new SecondaryConfig(); 128 secConfig.setKeyCreator(new MyKeyCreator()); 129 // Now pass secConfig to Environment.openSecondaryDatabase 130</pre> 131<P> 132 133<P> 134<HR> 135 136<P> 137 138<!-- ========== METHOD SUMMARY =========== --> 139 140<A NAME="method_summary"><!-- --></A> 141<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 142<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 143<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 144<B>Method Summary</B></FONT></TH> 145</TR> 146<TR BGCOLOR="white" CLASS="TableRowColor"> 147<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 148<CODE> boolean</CODE></FONT></TD> 149<TD><CODE><B><A HREF="../../../com/sleepycat/db/SecondaryKeyCreator.html#createSecondaryKey(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry)">createSecondaryKey</A></B>(<A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> secondary, 150 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, 151 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> data, 152 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> result)</CODE> 153 154<BR> 155 Creates a secondary key entry, given a primary key and data entry.</TD> 156</TR> 157</TABLE> 158 159<P> 160 161<!-- ============ METHOD DETAIL ========== --> 162 163<A NAME="method_detail"><!-- --></A> 164<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 165<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 166<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 167<B>Method Detail</B></FONT></TH> 168</TR> 169</TABLE> 170 171<A NAME="createSecondaryKey(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry)"><!-- --></A><H3> 172createSecondaryKey</H3> 173<PRE> 174boolean <B>createSecondaryKey</B>(<A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> secondary, 175 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, 176 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> data, 177 <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> result) 178 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 179<DL> 180<DD>Creates a secondary key entry, given a primary key and data entry. 181 <p> 182 A secondary key may be derived from the primary key, primary data, or a 183 combination of the primary key and data. For secondary keys that are 184 optional, the key creator method may return false and the key/data pair 185 will not be indexed. To ensure the integrity of a secondary database the 186 key creator method must always return the same result for a given set of 187 input parameters. 188 <p> 189<P> 190<DD><DL> 191<DT><B>Parameters:</B><DD><CODE>secondary</CODE> - the database to which the secondary key will be added. 192 This parameter is passed for informational purposes but is not commonly 193 used. 194 <p><DD><CODE>key</CODE> - the primary key entry. This parameter must not be modified 195 by this method. 196 <p><DD><CODE>data</CODE> - the primary data entry. This parameter must not be modified 197 by this method. 198 <p><DD><CODE>result</CODE> - the secondary key created by this method. 199 <p> 200<DT><B>Returns:</B><DD>true if a key was created, or false to indicate that the key is 201 not present. 202 <p> 203<DT><B>Throws:</B> 204<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if an error occurs attempting to create the 205 secondary key.</DL> 206</DD> 207</DL> 208<!-- ========= END OF CLASS DATA ========= --> 209<HR> 210 211 212<!-- ======= START OF BOTTOM NAVBAR ====== --> 213<A NAME="navbar_bottom"><!-- --></A> 214<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 215<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 216<TR> 217<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 218<A NAME="navbar_bottom_firstrow"><!-- --></A> 219<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 220 <TR ALIGN="center" VALIGN="top"> 221 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 222 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 223 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 224 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SecondaryKeyCreator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 225 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 226 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 227 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 228 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 229 </TR> 230</TABLE> 231</TD> 232<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 233<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 234</TD> 235</TR> 236 237<TR> 238<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 239 <A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> 240 <A HREF="../../../com/sleepycat/db/SecondaryMultiKeyCreator.html" title="interface in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> 241<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 242 <A HREF="../../../index.html?com/sleepycat/db/SecondaryKeyCreator.html" target="_top"><B>FRAMES</B></A> 243 <A HREF="SecondaryKeyCreator.html" target="_top"><B>NO FRAMES</B></A> 244 <SCRIPT type="text/javascript"> 245 <!-- 246 if(window==top) { 247 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 248 } 249 //--> 250</SCRIPT> 251<NOSCRIPT> 252 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 253</NOSCRIPT> 254 255 256</FONT></TD> 257</TR> 258<TR> 259<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 260 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 261<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 262DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 263</TR> 264</TABLE> 265<A NAME="skip-navbar_bottom"></A> 266<!-- ======== END OF BOTTOM NAVBAR ======= --> 267 268<HR> 269<font size=1>Copyright (c) 1996-2009 Oracle. All rights reserved.</font> 270</BODY> 271</HTML> 272