Revision: 17582
http://sourceforge.net/p/gate/code/17582
Author: markagreenwood
Date: 2014-03-07 19:39:39 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
more generics stuff, including a definate bug fix that could have led to a
ClassCastException at runtime
Modified Paths:
--------------
gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
Modified:
gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
===================================================================
--- gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
2014-03-07 19:39:04 UTC (rev 17581)
+++ gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
2014-03-07 19:39:39 UTC (rev 17582)
@@ -373,9 +373,15 @@
* Sets the current document to the memeber PRs
*/
protected void setDocToPrs(Document doc){
- Iterator prIter = getPRs().iterator();
+ Iterator<ProcessingResource> prIter = getPRs().iterator();
while(prIter.hasNext()){
- ((LanguageAnalyser)prIter.next()).setDocument(doc);
+ ProcessingResource pr = prIter.next();
+
+ // This is a bug fix, found by playing with the generics, as the
+ // old version cast everything to be a LanguageAnalyser even
+ // though not every ProcessingResource is one
+ if (pr instanceof LanguageAnalyser)
+ ((LanguageAnalyser)pr).setDocument(doc);
}
}
@@ -393,25 +399,25 @@
* or of the read accessor for a parameter.
*/
@Override
- public List getOffendingPocessingResources()
+ public List<ProcessingResource> getOffendingPocessingResources()
throws ResourceInstantiationException{
//take all the contained PRs
- ArrayList badPRs = new ArrayList(getPRs());
+ List<ProcessingResource> badPRs = new
ArrayList<ProcessingResource>(getPRs());
//remove the ones that no parameters problems
- Iterator prIter = getPRs().iterator();
+ Iterator<ProcessingResource> prIter = getPRs().iterator();
while(prIter.hasNext()){
- ProcessingResource pr = (ProcessingResource)prIter.next();
+ ProcessingResource pr = prIter.next();
ResourceData rData = Gate.getCreoleRegister().
get(pr.getClass().getName());
//this is a list of lists
- List parameters = rData.getParameterList().getRuntimeParameters();
+ List<List<Parameter>> parameters =
rData.getParameterList().getRuntimeParameters();
//remove corpus and document
- List newParameters = new ArrayList();
- Iterator pDisjIter = parameters.iterator();
+ List<List<Parameter>> newParameters = new ArrayList<List<Parameter>>();
+ Iterator<List<Parameter>> pDisjIter = parameters.iterator();
while(pDisjIter.hasNext()){
- List aDisjunction = (List)pDisjIter.next();
- List newDisjunction = new ArrayList(aDisjunction);
- Iterator internalParIter = newDisjunction.iterator();
+ List<Parameter> aDisjunction = pDisjIter.next();
+ List<Parameter> newDisjunction = new
ArrayList<Parameter>(aDisjunction);
+ Iterator<Parameter> internalParIter = newDisjunction.iterator();
while(internalParIter.hasNext()){
Parameter parameter = (Parameter)internalParIter.next();
if(parameter.getName().equals("corpus") ||
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