Update of /var/cvs/src/org/mmbase/cache
In directory james.mmbase.org:/tmp/cvs-serv25982/src/org/mmbase/cache

Modified Files:
        ConstraintsMatchingStrategy.java CacheManager.java Cache.java 
        NodeListCache.java 
Log Message:
Cleaned the code a little
Added some generic stuff for function and datatypes


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/cache


Index: ConstraintsMatchingStrategy.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/cache/ConstraintsMatchingStrategy.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- ConstraintsMatchingStrategy.java    7 Apr 2007 17:12:53 -0000       1.35
+++ ConstraintsMatchingStrategy.java    3 Feb 2008 17:33:56 -0000       1.36
@@ -43,7 +43,7 @@
  *
  * @author Ernst Bunders
  * @since MMBase-1.8
- * @version $Id: ConstraintsMatchingStrategy.java,v 1.35 2007/04/07 17:12:53 
nklasens Exp $
+ * @version $Id: ConstraintsMatchingStrategy.java,v 1.36 2008/02/03 17:33:56 
nklasens Exp $
  *
  */
 public class ConstraintsMatchingStrategy extends ReleaseStrategy {
@@ -423,7 +423,7 @@
 
         protected abstract int getOperator();
 
-        protected boolean valueMatches(final Class fieldType, Object 
constraintValue, Object valueToCompare, final boolean isCaseSensitive) {
+        protected boolean valueMatches(final Class<Object> fieldType, Object 
constraintValue, Object valueToCompare, final boolean isCaseSensitive) {
             if (log.isDebugEnabled()) {
                 log.debug("**method: valueMatches() fieldtype: " + fieldType);
             }
@@ -589,12 +589,12 @@
             return stringToCompare.matches(sb.toString());
         }
 
-        protected Class getFieldTypeClass(StepField stepField) {
+        protected Class<Object> getFieldTypeClass(StepField stepField) {
             MMBase mmbase = MMBase.getMMBase();
             // why it this checked anyway?
             CoreField field = 
mmbase.getBuilder(stepField.getStep().getTableName()).getField(stepField.getFieldName());
-            DataType fieldType = field.getDataType();
-            Class fieldTypeClass = fieldType.getTypeAsClass();
+            DataType<Object> fieldType = field.getDataType();
+            Class<Object> fieldTypeClass = fieldType.getTypeAsClass();
             if( fieldTypeClass.equals(Boolean.class) ||
                 fieldTypeClass.equals(Date.class) ||
                 fieldTypeClass.equals(Integer.class) ||
@@ -618,7 +618,7 @@
 
 
     private static class BasicFieldValueConstraintMatcher extends 
FieldCompareConstraintMatcher {
-        private final Class fieldTypeClass;
+        private final Class<Object> fieldTypeClass;
         protected final StepField stepField;
         protected final BasicFieldValueConstraint wrappedFieldValueConstraint;
 
@@ -703,7 +703,7 @@
      * @since MMBase-1.8.1
      */
     private static class BasicFieldValueInConstraintMatcher extends 
FieldCompareConstraintMatcher {
-        private final Class fieldTypeClass;
+        private final Class<Object> fieldTypeClass;
         protected final StepField stepField;
         protected final BasicFieldValueInConstraint 
wrappedFieldValueInConstraint;
 


Index: CacheManager.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/cache/CacheManager.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- CacheManager.java   6 Dec 2007 08:17:08 -0000       1.20
+++ CacheManager.java   3 Feb 2008 17:33:56 -0000       1.21
@@ -24,7 +24,7 @@
  * Cache manager manages the static methods of [EMAIL PROTECTED] Cache}. If 
you prefer you can call them on this in stead.
  *
  * @since MMBase-1.8
- * @version $Id: CacheManager.java,v 1.20 2007/12/06 08:17:08 michiel Exp $
+ * @version $Id: CacheManager.java,v 1.21 2008/02/03 17:33:56 nklasens Exp $
  */
 public class CacheManager {
 
@@ -89,7 +89,7 @@
      * @param cache A cache.
      * @return The previous cache of the same type (stored under the same name)
      */
-    public static Cache putCache(Cache cache) {
+    public static <K,V> Cache<K,V> putCache(Cache<K,V> cache) {
         Cache old = caches.put(cache.getName(), cache);
         configure(configReader, cache.getName());
         return old;


Index: Cache.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/cache/Cache.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- Cache.java  1 Aug 2007 06:48:20 -0000       1.48
+++ Cache.java  3 Feb 2008 17:33:56 -0000       1.49
@@ -20,7 +20,7 @@
  * A base class for all Caches. Extend this class for other caches.
  *
  * @author Michiel Meeuwissen
- * @version $Id: Cache.java,v 1.48 2007/08/01 06:48:20 michiel Exp $
+ * @version $Id: Cache.java,v 1.49 2008/02/03 17:33:56 nklasens Exp $
  */
 abstract public class Cache<K, V> implements SizeMeasurable, Map<K, V> {
 
@@ -59,7 +59,7 @@
 
     void setImplementation(String clazz, Map<String,String> configValues) {
         try {
-            Class clas = Class.forName(clazz);
+            Class<?> clas = Class.forName(clazz);
             if (implementation == null || (! 
clas.equals(implementation.getClass()))) {
                 implementation = (CacheImplementationInterface<K,V>) 
clas.newInstance();
                 implementation.config(configValues);
@@ -271,9 +271,9 @@
             size += ((SizeMeasurable) implementation).getByteSize(sizeof);
         } else {
             // sizeof.sizeof(implementation) does not work because 
this.equals(implementation)
-            Iterator i = implementation.entrySet().iterator();
+            Iterator<Map.Entry<K, V>> i = implementation.entrySet().iterator();
             while(i.hasNext()) {
-                Map.Entry entry = (Map.Entry) i.next();
+                Map.Entry<K, V> entry = i.next();
                 size += sizeof.sizeof(entry.getKey());
                 size += sizeof.sizeof(entry.getValue());
             }
@@ -290,9 +290,9 @@
     public int getCheapByteSize() {
         int size = 0;
         SizeOf sizeof = new SizeOf();
-        Iterator i = implementation.entrySet().iterator();
+        Iterator<Map.Entry<K, V>> i = implementation.entrySet().iterator();
         while(i.hasNext()) {
-            Map.Entry entry = (Map.Entry) i.next();
+            Map.Entry<K, V> entry = i.next();
             size += sizeof.sizeof(entry.getKey());
             size += sizeof.sizeof(entry.getValue());
             sizeof.clear();
@@ -397,7 +397,7 @@
      * @see CacheManager#putCache(Cache)
      */
 
-    public Cache putCache() {
+    public Cache<K,V> putCache() {
         return CacheManager.putCache(this);
     }
 


Index: NodeListCache.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/cache/NodeListCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- NodeListCache.java  19 Jul 2007 15:36:51 -0000      1.7
+++ NodeListCache.java  3 Feb 2008 17:33:56 -0000       1.8
@@ -9,8 +9,6 @@
 */
 package org.mmbase.cache;
 
-import org.mmbase.core.event.RelationEvent;
-
 /**
  * Query result cache used for getNodes from MMObjectBuilder. So it contains 
only simple nodes (no
  * clusternodes).
@@ -19,7 +17,7 @@
  * fields of one of the steps (the 'node step').
  *
  * @author Michiel Meeuwissen
- * @version $Id: NodeListCache.java,v 1.7 2007/07/19 15:36:51 michiel Exp $
+ * @version $Id: NodeListCache.java,v 1.8 2008/02/03 17:33:56 nklasens Exp $
  * @see   org.mmbase.module.core.MMObjectBuilder#getNodes
  * @since MMBase-1.7
  */
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to