Author: mgentry
Date: Tue Oct 21 08:31:32 2008
New Revision: 706659
URL: http://svn.apache.org/viewvc?rev=706659&view=rev
Log:
Added Java generic type information, removed redundant casts after adding
generic types, and made final inner classes static.
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCache.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCache.java
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCache.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCache.java?rev=706659&r1=706658&r2=706659&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCache.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCache.java
Tue Oct 21 08:31:32 2008
@@ -48,7 +48,7 @@
this.map = new LRUMap(maxSize);
}
- public List get(QueryMetadata metadata) {
+ public List<?> get(QueryMetadata metadata) {
String key = metadata.getCacheKey();
if (key == null) {
return null;
@@ -68,8 +68,8 @@
* a result there is a potential of multiple threads to be updating cache
in parallel -
* this wouldn't lead to corruption of the cache, but can be suboptimal.
*/
- public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
- List result = get(metadata);
+ public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory)
{
+ List<?> result = get(metadata);
if (result == null) {
Object newObject = factory.createObject();
@@ -85,14 +85,14 @@
}
}
- result = (List) newObject;
+ result = (List<?>) newObject;
put(metadata, result);
}
return result;
}
- public void put(QueryMetadata metadata, List results) {
+ public void put(QueryMetadata metadata, List<?> results) {
String key = metadata.getCacheKey();
if (key != null) {
@@ -144,8 +144,7 @@
return map.size();
}
- final class CacheEntry implements Serializable {
-
+ final static class CacheEntry implements Serializable {
List<?> list;
String[] cacheGroups;
}
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java?rev=706659&r1=706658&r2=706659&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
Tue Oct 21 08:31:32 2008
@@ -75,15 +75,15 @@
delegate.clear();
}
- public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
+ public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory)
{
return delegate.get(qualifiedMetadata(metadata), factory);
}
- public List get(QueryMetadata metadata) {
+ public List<?> get(QueryMetadata metadata) {
return delegate.get(qualifiedMetadata(metadata));
}
- public void put(QueryMetadata metadata, List results) {
+ public void put(QueryMetadata metadata, List<?> results) {
delegate.put(qualifiedMetadata(metadata), results);
}
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCache.java?rev=706659&r1=706658&r2=706659&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
Tue Oct 21 08:31:32 2008
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -89,7 +88,7 @@
protected GeneralCacheAdministrator osCache;
RefreshSpecification defaultRefreshSpecification;
- Map refreshSpecifications;
+ Map<String, RefreshSpecification> refreshSpecifications;
Properties properties;
public OSQueryCache() {
@@ -105,7 +104,7 @@
* Returns a collection of group names that have been configured
explicitly via
* properties.
*/
- public Collection getGroupNames() {
+ public Collection<?> getGroupNames() {
return refreshSpecifications != null
?
Collections.unmodifiableCollection(refreshSpecifications.keySet())
: Collections.EMPTY_SET;
@@ -116,7 +115,7 @@
RefreshSpecification spec = null;
if (refreshSpecifications != null) {
- spec = (RefreshSpecification) refreshSpecifications.get(groupName);
+ spec = refreshSpecifications.get(groupName);
}
if (spec == null) {
@@ -131,7 +130,7 @@
RefreshSpecification spec = null;
if (refreshSpecifications != null) {
- spec = (RefreshSpecification) refreshSpecifications.get(groupName);
+ spec = refreshSpecifications.get(groupName);
}
if (spec == null) {
@@ -222,11 +221,10 @@
private RefreshSpecification nonNullSpec(String name) {
if (refreshSpecifications == null) {
- refreshSpecifications = new HashMap();
+ refreshSpecifications = new HashMap<String,
RefreshSpecification>();
}
- RefreshSpecification spec = (RefreshSpecification)
refreshSpecifications
- .get(name);
+ RefreshSpecification spec = refreshSpecifications.get(name);
if (spec == null) {
spec = new RefreshSpecification();
spec.cronExpression = defaultRefreshSpecification.cronExpression;
@@ -237,7 +235,7 @@
return spec;
}
- public List get(QueryMetadata metadata) {
+ public List<?> get(QueryMetadata metadata) {
String key = metadata.getCacheKey();
if (key == null) {
return null;
@@ -246,7 +244,7 @@
RefreshSpecification refresh = getRefreshSpecification(metadata);
try {
- return (List) osCache.getFromCache(
+ return (List<?>) osCache.getFromCache(
key,
refresh.refreshPeriod,
refresh.cronExpression);
@@ -263,7 +261,7 @@
* will block on the entry update or not is controlled by "cache.blocking"
* configuration property and is "false" by default.
*/
- public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
+ public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory)
{
String key = metadata.getCacheKey();
if (key == null) {
return null;
@@ -272,7 +270,7 @@
RefreshSpecification refresh = getRefreshSpecification(metadata);
try {
- return (List) osCache.getFromCache(
+ return (List<?>) osCache.getFromCache(
key,
refresh.refreshPeriod,
refresh.cronExpression);
@@ -294,7 +292,7 @@
}
}
- List list = (List) result;
+ List<?> list = (List<?>) result;
put(metadata, list);
updated = true;
@@ -320,14 +318,14 @@
if (refreshSpecifications != null) {
String[] groups = metadata.getCacheGroups();
if (groups != null && groups.length > 0) {
- refresh = (RefreshSpecification)
refreshSpecifications.get(groups[0]);
+ refresh = refreshSpecifications.get(groups[0]);
}
}
return refresh != null ? refresh : defaultRefreshSpecification;
}
- public void put(QueryMetadata metadata, List results) {
+ public void put(QueryMetadata metadata, List<?> results) {
String key = metadata.getCacheKey();
if (key != null) {
osCache.putInCache(key, results, metadata.getCacheGroups());
@@ -382,8 +380,7 @@
}
}
- final class OSCacheAdministrator extends GeneralCacheAdministrator {
-
+ final static class OSCacheAdministrator extends GeneralCacheAdministrator {
OSCacheAdministrator() {
}
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCache.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCache.java?rev=706659&r1=706658&r2=706659&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCache.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCache.java
Tue Oct 21 08:31:32 2008
@@ -34,7 +34,7 @@
* Returns a cached query result for the given QueryMetadata or null if
the result is
* not cached or is expired.
*/
- List get(QueryMetadata metadata);
+ List<?> get(QueryMetadata metadata);
/**
* Returns a cached query result for the given QueryMetadata. If the
result is not
@@ -45,9 +45,9 @@
* from running the same query when a missing entry is requested by
multiple threads
* simultaneously.
*/
- List get(QueryMetadata metadata, QueryCacheEntryFactory factory);
+ List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory);
- void put(QueryMetadata metadata, List results);
+ void put(QueryMetadata metadata, List<?> results);
/**
* Removes a single entry from cache.