Revision: 17545
http://sourceforge.net/p/gate/code/17545
Author: markagreenwood
Date: 2014-03-05 18:38:46 +0000 (Wed, 05 Mar 2014)
Log Message:
-----------
some more generics updates, which include a bug fix that would have almost
certainly led to a ClassCastException if people had actually followed the API
Modified Paths:
--------------
gate/trunk/src/main/gate/AnnotationSet.java
gate/trunk/src/main/gate/Controller.java
gate/trunk/src/main/gate/CreoleRegister.java
gate/trunk/src/main/gate/DataStore.java
gate/trunk/src/main/gate/DataStoreRegister.java
gate/trunk/src/main/gate/creole/CreoleRegisterImpl.java
gate/trunk/src/main/gate/gui/NameBearerHandle.java
gate/trunk/src/main/gate/persist/SerialDataStore.java
Modified: gate/trunk/src/main/gate/AnnotationSet.java
===================================================================
--- gate/trunk/src/main/gate/AnnotationSet.java 2014-03-05 16:13:56 UTC (rev
17544)
+++ gate/trunk/src/main/gate/AnnotationSet.java 2014-03-05 18:38:46 UTC (rev
17545)
@@ -122,7 +122,7 @@
* annotations match these constraints, an empty set is
* returned. The returned set is immutable.
*/
- public AnnotationSet get(String type, Set featureNames);
+ public AnnotationSet get(String type, Set<? extends Object> featureNames);
/**
* Select annotations by type, features and offset. This method is a
Modified: gate/trunk/src/main/gate/Controller.java
===================================================================
--- gate/trunk/src/main/gate/Controller.java 2014-03-05 16:13:56 UTC (rev
17544)
+++ gate/trunk/src/main/gate/Controller.java 2014-03-05 18:38:46 UTC (rev
17545)
@@ -33,7 +33,7 @@
* controller. The actual type of collection returned depends on the
* controller type.
*/
- public Collection getPRs();
+ public Collection<ProcessingResource> getPRs();
/**
* Populates this controller from a collection of
@@ -45,7 +45,7 @@
* @throws UnsupportedOperationException if the <tt>setPRs</tt>
* method is not supported by this controller.
*/
- public void setPRs(Collection PRs);
+ public void setPRs(Collection<ProcessingResource> PRs);
/**
* <p>
Modified: gate/trunk/src/main/gate/CreoleRegister.java
===================================================================
--- gate/trunk/src/main/gate/CreoleRegister.java 2014-03-05 16:13:56 UTC
(rev 17544)
+++ gate/trunk/src/main/gate/CreoleRegister.java 2014-03-05 18:38:46 UTC
(rev 17545)
@@ -125,7 +125,7 @@
* <P>
* If Java allowed class methods in interfaces this would be static.
*/
- public File createCreoleDirectoryFile(File directoryFile, Set jarFileNames);
+ public File createCreoleDirectoryFile(File directoryFile, Set<String>
jarFileNames);
/** Get the list of types of LR in the register. */
public Set<String> getLrTypes();
Modified: gate/trunk/src/main/gate/DataStore.java
===================================================================
--- gate/trunk/src/main/gate/DataStore.java 2014-03-05 16:13:56 UTC (rev
17544)
+++ gate/trunk/src/main/gate/DataStore.java 2014-03-05 18:38:46 UTC (rev
17545)
@@ -103,21 +103,23 @@
throws PersistenceException,SecurityException;
/** Get a list of the types of LR that are present in the data store. */
- public List getLrTypes() throws PersistenceException;
+ public List<LanguageResource> getLrTypes() throws PersistenceException;
/** Get a list of the IDs of LRs of a particular type that are present. */
- public List getLrIds(String lrType) throws PersistenceException;
+ public List<String> getLrIds(String lrType) throws PersistenceException;
/** Get a list of the names of LRs of a particular type that are present. */
- public List getLrNames(String lrType) throws PersistenceException;
+ public List<String> getLrNames(String lrType) throws PersistenceException;
/** Get a list of LRs that satisfy some set or restrictions */
+ @SuppressWarnings("rawtypes") // we've never implemented the types are
unknown
public List findLrIds(List constraints) throws PersistenceException;
/**
* Get a list of LRs that satisfy some set or restrictions and are
* of a particular type
*/
+ @SuppressWarnings("rawtypes") // we've never implemented the types are
unknown
public List findLrIds(List constraints, String lrType) throws
PersistenceException;
/** Get the name of an LR from its ID. */
Modified: gate/trunk/src/main/gate/DataStoreRegister.java
===================================================================
--- gate/trunk/src/main/gate/DataStoreRegister.java 2014-03-05 16:13:56 UTC
(rev 17544)
+++ gate/trunk/src/main/gate/DataStoreRegister.java 2014-03-05 18:38:46 UTC
(rev 17545)
@@ -89,20 +89,20 @@
*/
@Override
public void clear() {
- Set datastores = new HashSet(this);
+ Set<DataStore> datastores = new HashSet<DataStore>(this);
super.clear();
- Iterator iter = datastores.iterator();
+ Iterator<DataStore> iter = datastores.iterator();
while (iter.hasNext()) {
- fireDatastoreClosed(new CreoleEvent((DataStore) iter.next(),
CreoleEvent.DATASTORE_CLOSED));
+ fireDatastoreClosed(new CreoleEvent(iter.next(),
CreoleEvent.DATASTORE_CLOSED));
} // while
} // clear()
/** Configuration data such as driver names. */
- private static Map configData = new HashMap();
+ private static Map<Object,Object> configData = new HashMap<Object,Object>();
/** Get the configuration data map. */
- public static Map getConfigData() {
+ public static Map<Object,Object> getConfigData() {
return configData;
}
@@ -111,24 +111,24 @@
* register. New key/value pairs are added to the existing set (this will
* overwrite existing pairs whose keys match new ones).
*/
- public static void addConfig(Map configData) {
+ public static void addConfig(Map<Object,Object> configData) {
DataStoreRegister.configData.putAll(configData);
} // addConfig
/** A hashmap from datastore to security data (current user and group) */
- private static Map securityData = new HashMap();
+ private static Map<DataStore, Map<Object,Object>> securityData = new
HashMap<DataStore, Map<Object,Object>>();
/**
* Returns the security data for this datastore
*/
- public static Map getSecurityData(DataStore ds) {
- return (Map) securityData.get(ds);
- } //
+ public static Map<Object,Object> getSecurityData(DataStore ds) {
+ return securityData.get(ds);
+ }
/**
* Adds security data for this datastore
*/
- public static void addSecurityData(DataStore ds, Map secData) {
+ public static void addSecurityData(DataStore ds, Map<Object,Object> secData)
{
DataStoreRegister.securityData.put(ds, secData);
}
@@ -147,7 +147,8 @@
*/
public synchronized void removeCreoleListener(CreoleListener l) {
if (creoleListeners != null && creoleListeners.contains(l)) {
- Vector v = (Vector) creoleListeners.clone();
+ @SuppressWarnings("unchecked")
+ Vector<CreoleListener> v = (Vector<CreoleListener>)
creoleListeners.clone();
v.removeElement(l);
creoleListeners = v;
}
@@ -160,7 +161,8 @@
* through {@link Gate#getCreoleRegister()}
*/
public synchronized void addCreoleListener(CreoleListener l) {
- Vector v = creoleListeners == null ? new Vector(2) : (Vector)
creoleListeners.clone();
+ @SuppressWarnings("unchecked")
+ Vector<CreoleListener> v = creoleListeners == null ? new
Vector<CreoleListener>(2) : (Vector<CreoleListener>)creoleListeners.clone();
if (!v.contains(l)) {
v.addElement(l);
creoleListeners = v;
@@ -175,10 +177,10 @@
*/
protected void fireDatastoreOpened(CreoleEvent e) {
if (creoleListeners != null) {
- Vector listeners = creoleListeners;
+ Vector<CreoleListener> listeners = creoleListeners;
int count = listeners.size();
for (int i = 0; i < count; i++) {
- ((CreoleListener) listeners.elementAt(i)).datastoreOpened(e);
+ listeners.elementAt(i).datastoreOpened(e);
} // for
} // if
} // fireDatastoreOpened(CreoleEvent e)
@@ -191,10 +193,10 @@
*/
protected void fireDatastoreCreated(CreoleEvent e) {
if (creoleListeners != null) {
- Vector listeners = creoleListeners;
+ Vector<CreoleListener> listeners = creoleListeners;
int count = listeners.size();
for (int i = 0; i < count; i++) {
- ((CreoleListener) listeners.elementAt(i)).datastoreCreated(e);
+ listeners.elementAt(i).datastoreCreated(e);
} // for
} // if
} // fireDatastoreCreated(CreoleEvent e)
@@ -207,15 +209,15 @@
*/
protected void fireDatastoreClosed(CreoleEvent e) {
if (creoleListeners != null) {
- Vector listeners = creoleListeners;
+ Vector<CreoleListener> listeners = creoleListeners;
int count = listeners.size();
for (int i = 0; i < count; i++) {
- ((CreoleListener) listeners.elementAt(i)).datastoreClosed(e);
+ listeners.elementAt(i).datastoreClosed(e);
} // for
} // if
} // fireDatastoreClosed(CreoleEvent e)
/** */
- private transient Vector creoleListeners;
+ private transient Vector<CreoleListener> creoleListeners;
} // class DataStoreRegister
Modified: gate/trunk/src/main/gate/creole/CreoleRegisterImpl.java
===================================================================
--- gate/trunk/src/main/gate/creole/CreoleRegisterImpl.java 2014-03-05
16:13:56 UTC (rev 17544)
+++ gate/trunk/src/main/gate/creole/CreoleRegisterImpl.java 2014-03-05
18:38:46 UTC (rev 17545)
@@ -409,7 +409,7 @@
* If Java allowed class methods in interfaces this would be static.
*/
@Override
- public File createCreoleDirectoryFile(File directoryFile, Set jarFileNames) {
+ public File createCreoleDirectoryFile(File directoryFile, Set<String>
jarFileNames) {
// //////////////////
// dump xml header and comment header and <CREOLE-DIRECTORY> into dirfile
// for each jar file pick out resource.xml
Modified: gate/trunk/src/main/gate/gui/NameBearerHandle.java
===================================================================
--- gate/trunk/src/main/gate/gui/NameBearerHandle.java 2014-03-05 16:13:56 UTC
(rev 17544)
+++ gate/trunk/src/main/gate/gui/NameBearerHandle.java 2014-03-05 18:38:46 UTC
(rev 17545)
@@ -546,7 +546,8 @@
public void actionPerformed(ActionEvent e) {
if(target instanceof Controller) {
// empty the controller of all its processing resources
- ((Controller)target).setPRs(Collections.emptyList());
+ List<ProcessingResource> empty = Collections.emptyList();
+ ((Controller)target).setPRs(empty);
if(target instanceof ConditionalController) {
((ConditionalController)target).setRunningStrategies(Collections
.emptyList());
@@ -1339,7 +1340,7 @@
+ " seconds");
}
else {
- FeatureMap securityData = (FeatureMap)DataStoreRegister
+ Map<Object,Object> securityData = DataStoreRegister
.getSecurityData(ds);
SecurityInfo si = null;
// check whether the datastore supports security data
Modified: gate/trunk/src/main/gate/persist/SerialDataStore.java
===================================================================
--- gate/trunk/src/main/gate/persist/SerialDataStore.java 2014-03-05
16:13:56 UTC (rev 17544)
+++ gate/trunk/src/main/gate/persist/SerialDataStore.java 2014-03-05
18:38:46 UTC (rev 17545)
@@ -522,7 +522,7 @@
/** Get a list of the IDs of LRs of a particular type that are present. */
@Override
- public List getLrIds(String lrType) throws PersistenceException {
+ public List<String> getLrIds(String lrType) throws PersistenceException {
// a File to represent the directory for this type
File resourceTypeDir = new File(storageDir, lrType);
if(! resourceTypeDir.exists())
@@ -533,7 +533,7 @@
/** Get a list of the names of LRs of a particular type that are present. */
@Override
- public List getLrNames(String lrType) throws PersistenceException {
+ public List<String> getLrNames(String lrType) throws PersistenceException {
// the list of files storing LRs of this type; an array for the names
List<String> lrFileNames = getLrIds(lrType);
List<String> lrNames = new ArrayList<String>();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs