| 1 | /** |
| 2 | * Copyright (C) 2006 NetMind Consulting Bt. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 3 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | package hu.netmind.beankeeper.model; |
| 20 | |
| 21 | import hu.netmind.beankeeper.service.Service; |
| 22 | import java.util.Map; |
| 23 | import java.util.List; |
| 24 | |
| 25 | /** |
| 26 | * This class keeps track of different classes and objects. It's main |
| 27 | * purpose is to implement object reflection based logic, and provide |
| 28 | * type information. |
| 29 | * @author Brautigam Robert |
| 30 | * @version Revision: $Revision$ |
| 31 | */ |
| 32 | public interface ClassTracker extends Service |
| 33 | { |
| 34 | /** |
| 35 | * This enumeration represents the class type of a class. |
| 36 | */ |
| 37 | public enum ClassType |
| 38 | { |
| 39 | TYPE_NONE, // Extremal type |
| 40 | TYPE_PRIMITIVE, // It's Java primitive, String, Date or byte array |
| 41 | TYPE_HANDLED, // Handled by type handlers (Map, Set, etc.) |
| 42 | TYPE_OBJECT, // Plain class with attributes (user implementation) |
| 43 | TYPE_JAVA, // Class from the java JDK |
| 44 | TYPE_RESERVED, // Class from other reserved places |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Get the type id of given class. |
| 49 | */ |
| 50 | ClassType getType(Class clazz); |
| 51 | |
| 52 | /** |
| 53 | * Get class info for a class entry. |
| 54 | */ |
| 55 | ClassInfo getClassInfo(ClassEntry entry); |
| 56 | |
| 57 | /** |
| 58 | * Get class info for an object and it's class. |
| 59 | */ |
| 60 | ClassInfo getClassInfo(Class clazz, Object obj); |
| 61 | |
| 62 | /** |
| 63 | * Get class info from a string. |
| 64 | */ |
| 65 | ClassInfo getClassInfo(String className, String dynamicName); |
| 66 | |
| 67 | /** |
| 68 | * Get class information object of given class. Also, if class |
| 69 | * information does not exist, it will be created. |
| 70 | */ |
| 71 | ClassInfo getClassInfo(Class clazz, String dynamicName); |
| 72 | |
| 73 | /** |
| 74 | * Get all related classes to the given entry. Related class entries are |
| 75 | * all given class' super- and sub-classes which are all storable. |
| 76 | * Calling this method on non-storable entry will result in an undefined |
| 77 | * result. |
| 78 | */ |
| 79 | List<ClassEntry> getRelatedClassEntries(ClassEntry entry); |
| 80 | |
| 81 | /** |
| 82 | * Get all subclasses of given entry, including itself. |
| 83 | */ |
| 84 | List<ClassEntry> getSubClasses(ClassEntry entry); |
| 85 | |
| 86 | /** |
| 87 | * Get all storable roots for given entry. A storable root for a |
| 88 | * storable entry is itself. A non-storable entry (such as java.lang.Object) |
| 89 | * will have potentially a lot of storable roots: All classes in the |
| 90 | * class hierarchy which are storable, but have non-storable superclasses. |
| 91 | * So, storable roots are the first storable entry in a class hierarchy |
| 92 | * path (roots of the storable sub-forest). When a query is received |
| 93 | * for a non-stored class, the query will split into queries for all |
| 94 | * storable roots. |
| 95 | */ |
| 96 | List<ClassEntry> getStorableRootClassEntries(ClassEntry entry); |
| 97 | |
| 98 | /** |
| 99 | * Get a class entry for a class id. |
| 100 | */ |
| 101 | ClassEntry getClassEntry(Integer id); |
| 102 | |
| 103 | /** |
| 104 | * Get a Class instance for a class name postfix. The given parameter |
| 105 | * is treated as a postfix for a fully qualified class name. The postfix |
| 106 | * is considered matching, when it contains whole class of package |
| 107 | * qualifiers. For example: "book" matches "hu.netmind.beankeeper.Book" |
| 108 | * class, but does not match "hu.netmind.beankeeper.CookBook". Also |
| 109 | * "persistence.book" matches "hu.netmind.beankeeper.Book", but |
| 110 | * "tence.book" does not match to previous class.<br> |
| 111 | * If no classes are found null is returned. If more than one matching |
| 112 | * class is present, then one of them is returned (no guarantees which |
| 113 | * one is picked). |
| 114 | * @param postfix The class name postfix. |
| 115 | * @return The class info for which the postfix applies, or null. |
| 116 | */ |
| 117 | ClassEntry getMatchingClassEntry(String postfix); |
| 118 | |
| 119 | /** |
| 120 | * Get the next object id for an object of given entry. This id |
| 121 | * is guaranteed to be unique across all objects in the database. |
| 122 | */ |
| 123 | Long getNextId(ClassEntry entry); |
| 124 | } |
| 125 | |
| 126 | |