Java Doc for KeyField.java in  » JMX » je » com » sleepycat » persist » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.persist.model 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sleepycat.persist.model.KeyField

KeyField
public @interface KeyField(Code)
Indicates the sorting position of a key field in a composite key class when the Comparable interface is not implemented. The KeyField integer value specifies the sort order of this field within the set of fields in the composite key.

If the field type of a PrimaryKey or SecondaryKey is a composite key class containing more than one key field, then a KeyField annotation must be present on each non-transient instance field of the composite key class. The KeyField value must be a number between one and the number of non-transient instance fields declared in the composite key class.

Note that a composite key class is a flat container for one or more simple type fields. All non-transient instance fields in the composite key class are key fields, and the composite key class may not have superclasses containing non-transient instance fields.

For example:

 class Animal {
 Classification classification;
 ...
 }
 class Classification {
 ...
 }

This causes entities to be sorted first by kingdom , then by phylum within kingdom , and so on.

The fields in a composite key class may not be null.

Custom Sort Order

To override the default sort order, a composite key class may implement the Comparable interface. This allows overriding the sort order and is therefore useful even when there is only one key field in the composite key class. For example, the following class sorts Strings using a Canadian collator:

 import java.text.Collator;
 import java.util.Locale;
 class Animal {
 ...
 CollatedString canadianName;
 ...
 }
  {
 static Collator collator = Collator.getInstance(Locale.CANADA);
 String value;
 CollatedString(String value) { this.value = value; }
 private CollatedString() {}
 public int compareTo(CollatedString o) {
 return collator.compare(value, o.value);
 }
 }

Several important rules should be considered when implementing a custom comparison method. Failure to follow these rules may result in the primary or secondary index becoming unusable; in other words, the store will not be able to function.

  1. The comparison method must always return the same result, given the same inputs. The behavior of the comparison method must not change over time.

  2. A corollary to the first rule is that the behavior of the comparison method must not be dependent on state which may change over time. For example, if the above collation method used the default Java locale, and the default locale is changed, then the sort order will change.

  3. The comparison method must not assume that it is called after the store has been opened. With Berkeley DB Java Edition, the comparison method is called during database recovery, which occurs in the Environment constructor.

  4. The comparison method must not assume that it will only be called with keys that are currently present in the database. The comparison method will occasionally be called with deleted keys or with keys for records that were not part of a committed transaction.

author:
   Mark Hayes


Field Summary
 intvalue
    



Field Detail
value
int value(Code)





www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.