80037dabb130a065649d3f8cdbf63c3baab7702c
[mir.git] / source / mir / storage / store / StoreUtil.java
1 package mir.storage.store;
2
3 /**
4  * Title:
5  * Description:
6  * Copyright:    Copyright (c) 2002
7  * Company:
8  * @author
9  * @version 1.0
10  */
11
12 public final class StoreUtil {
13
14         private final static Class    storableObjectInterface=StorableObject.class;
15
16   // avoid construction
17   private StoreUtil() { }
18
19
20   public static final String getPropNameFor(Class aClass) {
21     if ( aClass!=null ) {
22       String className=aClass.toString();
23       return className.substring(className.lastIndexOf(".")+1);
24     }
25     return null;
26   }
27
28   public static final String getEntityListUniqueIdentifierFor( String table,
29     String where, String order, int offset, int limit)
30   {
31     StringBuffer sb = new StringBuffer(table);
32     sb.append("@");
33     if ( where!=null ) sb.append(where);
34     sb.append("@");
35     if ( order!=null ) sb.append(order);
36     sb.append("@").append(offset);
37     sb.append("@").append(limit);
38     return sb.toString();
39   }
40
41         /**
42          *  Method:       implementsStorableObject
43          *  Description:  internall helper method to find out if a class implements
44          *                interface StorableObject.
45          *
46          *  @return       true if yes, otherwise no.
47          */
48         public final static boolean implementsStorableObject(Class aClass) {
49                 if (aClass!=null) {
50                         Class[] interfaces = aClass.getInterfaces();
51                         if (interfaces.length>0) {
52                                 for (int i=0;i<interfaces.length;i++) {
53                                         if (interfaces[i]==storableObjectInterface) return true;
54                                 }
55                         }
56                 }
57                 return false;
58         }
59
60
61
62 }