Revision: 17595
http://sourceforge.net/p/gate/code/17595
Author: markagreenwood
Date: 2014-03-08 13:05:32 +0000 (Sat, 08 Mar 2014)
Log Message:
-----------
the pre-lunch checkin of generics and serialVersionUID updates
Modified Paths:
--------------
gate/trunk/src/main/gate/creole/splitter/RegexSentenceSplitter.java
gate/trunk/src/main/gate/creole/splitter/SentenceSplitter.java
gate/trunk/src/main/gate/creole/tokeniser/DFSMState.java
gate/trunk/src/main/gate/creole/tokeniser/DefaultTokeniser.java
gate/trunk/src/main/gate/creole/tokeniser/FSMState.java
gate/trunk/src/main/gate/creole/tokeniser/InvalidRuleException.java
gate/trunk/src/main/gate/creole/tokeniser/SimpleTokeniser.java
gate/trunk/src/main/gate/creole/tokeniser/TokeniserException.java
gate/trunk/src/main/gate/creole/tokeniser/UnicodeType.java
gate/trunk/src/main/gate/email/EmailDocumentHandler.java
gate/trunk/src/main/gate/event/AnnotationEvent.java
gate/trunk/src/main/gate/event/AnnotationSetEvent.java
gate/trunk/src/main/gate/event/ControllerEvent.java
gate/trunk/src/main/gate/event/CorpusEvent.java
gate/trunk/src/main/gate/event/CreoleEvent.java
gate/trunk/src/main/gate/event/DatastoreEvent.java
gate/trunk/src/main/gate/event/DocumentEvent.java
gate/trunk/src/main/gate/event/GateEvent.java
gate/trunk/src/main/gate/event/ObjectModificationEvent.java
gate/trunk/src/main/gate/event/ProgressListenerAdaptor.java
gate/trunk/src/main/gate/fsm/FSM.java
gate/trunk/src/main/gate/fsm/FSMInstance.java
gate/trunk/src/main/gate/fsm/State.java
gate/trunk/src/main/gate/fsm/Transition.java
gate/trunk/src/main/gate/jape/PrioritisedRuleList.java
Modified: gate/trunk/src/main/gate/creole/splitter/RegexSentenceSplitter.java
===================================================================
--- gate/trunk/src/main/gate/creole/splitter/RegexSentenceSplitter.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/splitter/RegexSentenceSplitter.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -18,6 +18,8 @@
import java.util.*;
import java.util.regex.*;
+import org.apache.commons.io.IOUtils;
+
import gate.*;
import gate.creole.*;
import gate.creole.metadata.CreoleParameter;
@@ -101,22 +103,30 @@
protected Pattern nonSplitsPattern;
protected Pattern compilePattern(URL paternsListUrl, String encoding)
- throws UnsupportedEncodingException, IOException{
- BufferedReader reader = new
BomStrippingInputStreamReader(paternsListUrl.openStream(), encoding);
+ throws UnsupportedEncodingException, IOException {
+ BufferedReader reader = null;
StringBuffer patternString = new StringBuffer();
+
+ try {
+ reader =
+ new BomStrippingInputStreamReader(paternsListUrl.openStream(),
+ encoding);
+
+ String line = reader.readLine();
+ while(line != null) {
+ line = line.trim();
- String line = reader.readLine();
- while(line != null){
- line = line.trim();
-
- if(line.length() == 0 || line.startsWith("//")){
- //ignore empty lines and comments
- }else{
- if(patternString.length() > 0) patternString.append("|");
- patternString.append("(?:" + line + ")");
+ if(line.length() == 0 || line.startsWith("//")) {
+ // ignore empty lines and comments
+ } else {
+ if(patternString.length() > 0) patternString.append("|");
+ patternString.append("(?:" + line + ")");
+ }
+ // move to next line
+ line = reader.readLine();
}
- //move to next line
- line = reader.readLine();
+ } finally {
+ IOUtils.closeQuietly(reader);
}
return Pattern.compile(patternString.toString());
}
Modified: gate/trunk/src/main/gate/creole/splitter/SentenceSplitter.java
===================================================================
--- gate/trunk/src/main/gate/creole/splitter/SentenceSplitter.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/splitter/SentenceSplitter.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -46,6 +46,8 @@
@CreoleResource(name="ANNIE Sentence Splitter", comment="ANNIE sentence
splitter.", helpURL="http://gate.ac.uk/userguide/sec:annie:splitter",
icon="sentence-splitter")
public class SentenceSplitter extends AbstractLanguageAnalyser implements
Benchmarkable{
+ private static final long serialVersionUID = -5335682060379173111L;
+
public static final String
SPLIT_DOCUMENT_PARAMETER_NAME = "document";
@@ -314,9 +316,6 @@
this.benchmarkId = benchmarkId;
}
-
-
- private static final boolean DEBUG = false;
private String inputASName;
private String outputASName;
}//public class SentenceSplitter extends Nerc
Modified: gate/trunk/src/main/gate/creole/tokeniser/DFSMState.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/DFSMState.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/DFSMState.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -33,8 +33,7 @@
*/
class DFSMState implements java.io.Serializable { //extends FSMState{
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = 7584872407097617987L;
/** Constructs a new DFSMState object and adds it to the list of
deterministic
* states of the {@link DefaultTokeniser DefaultTokeniser} provided as
owner.
@@ -78,8 +77,7 @@
///String res = "";
//OT
StringBuffer res = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
- Set nextSet;
- Iterator nextSetIter;
+
DFSMState nextState;
for(int i = 0; i< transitionFunction.length; i++){
@@ -123,12 +121,11 @@
StringBuffer prefix = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
StringBuffer read = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
- LinkedList attributes = new LinkedList(),
- values = new LinkedList();
+ LinkedList<String> attributes = new LinkedList<String>(),
+ values = new LinkedList<String>();
StringTokenizer mainSt =
new StringTokenizer(rhs, ignorables + "\\\";=", true);
- int descIndex = 0;
//phase means:
//0 == looking for type;
//1 == looking for attribute;
@@ -212,8 +209,8 @@
tokenDesc = new String[attributes.size()][2];
for(int i = 0; i < attributes.size(); i++) {
- tokenDesc[i][0] = (String)attributes.get(i);
- tokenDesc[i][1] = (String)values.get(i);
+ tokenDesc[i][0] = attributes.get(i);
+ tokenDesc[i][1] = values.get(i);
}
// for(int i = 0; i < attributes.size(); i++){
Modified: gate/trunk/src/main/gate/creole/tokeniser/DefaultTokeniser.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/DefaultTokeniser.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/DefaultTokeniser.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -28,6 +28,8 @@
@CreoleResource(name = "ANNIE English Tokeniser", comment = "A customisable
English tokeniser.", helpURL =
"http://gate.ac.uk/userguide/sec:annie:tokeniser", icon = "tokeniser")
public class DefaultTokeniser extends AbstractLanguageAnalyser implements
Benchmarkable {
+ private static final long serialVersionUID = 3860943928124433852L;
+
public static final String
DEF_TOK_DOCUMENT_PARAMETER_NAME = "document";
Modified: gate/trunk/src/main/gate/creole/tokeniser/FSMState.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/FSMState.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/FSMState.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -22,8 +22,7 @@
*/
class FSMState implements java.io.Serializable {
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = -8044319707799787043L;
/** Creates a new FSMState belonging to a specified tokeniser
* @param owner the tokeniser that contains this new state
@@ -38,7 +37,7 @@
* As this state can belong to a non-deterministic automaton, the result
* will be a set.
*/
- Set nextSet(UnicodeType type) {
+ Set<FSMState> nextSet(UnicodeType type) {
if(null == type) return transitionFunction[SimpleTokeniser.maxTypeId];
else return transitionFunction[type.type];
} // nextSet(UnicodeType type)
@@ -48,7 +47,7 @@
* As this state can belong to a non-deterministic automaton, the result
* will be a set.
*/
- Set nextSet(int type) {
+ Set<FSMState> nextSet(int type) {
return transitionFunction[type];
} // nextSet(int type)
@@ -69,7 +68,7 @@
*/
void put(int index, FSMState state) {
if(null == transitionFunction[index])
- transitionFunction[index] = new HashSet();
+ transitionFunction[index] = new HashSet<FSMState>();
transitionFunction[index].add(state);
} // put(int index, FSMState state)
@@ -90,8 +89,8 @@
String getEdgesGML() {
/// String res = "";
StringBuffer res = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
- Set nextSet;
- Iterator nextSetIter;
+ Set<FSMState> nextSet;
+ Iterator<FSMState> nextSetIter;
FSMState nextState;
for(int i = 0; i <= SimpleTokeniser.maxTypeId; i++){
@@ -99,7 +98,7 @@
if(null != nextSet){
nextSetIter = nextSet.iterator();
while(nextSetIter.hasNext()){
- nextState = (FSMState)nextSetIter.next();
+ nextState = nextSetIter.next();
/* res += "edge [ source " + myIndex +
" target " + nextState.getIndex() +
" label \"";
@@ -127,7 +126,8 @@
* (the ids used internally by the tokeniser for the Unicode types) to sets
* of states.
*/
- Set[] transitionFunction = new Set[SimpleTokeniser.maxTypeId + 1];
+ @SuppressWarnings("unchecked")
+ Set<FSMState>[] transitionFunction = new Set[SimpleTokeniser.maxTypeId + 1];
/** The RHS string value from which the annotation associated to
* final states is constructed.
Modified: gate/trunk/src/main/gate/creole/tokeniser/InvalidRuleException.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/InvalidRuleException.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/InvalidRuleException.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -19,9 +19,9 @@
/** Fired when an invalid tokeniser rule is found
*/
public class InvalidRuleException extends TokeniserException {
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = 171132971054225662L;
+
public InvalidRuleException(String s) {
super(s);
}
Modified: gate/trunk/src/main/gate/creole/tokeniser/SimpleTokeniser.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/SimpleTokeniser.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/SimpleTokeniser.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -16,19 +16,42 @@
package gate.creole.tokeniser;
-import java.io.*;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.*;
-
-import gate.*;
-import gate.creole.*;
+import gate.AnnotationSet;
+import gate.Factory;
+import gate.FeatureMap;
+import gate.Gate;
+import gate.Resource;
+import gate.creole.AbstractLanguageAnalyser;
+import gate.creole.ExecutionException;
+import gate.creole.ExecutionInterruptedException;
+import gate.creole.ResourceInstantiationException;
import gate.creole.metadata.CreoleParameter;
import gate.creole.metadata.CreoleResource;
import gate.creole.metadata.Optional;
import gate.creole.metadata.RunTime;
-import gate.util.*;
+import gate.util.BomStrippingInputStreamReader;
+import gate.util.Err;
+import gate.util.GateRuntimeException;
+import gate.util.InvalidOffsetException;
+import gate.util.LuckyException;
+import java.io.BufferedReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.commons.io.IOUtils;
+
/** Implementation of a Unicode rule based tokeniser.
* The tokeniser gets its rules from a file an {@link java.io.InputStream
* InputStream} or a {@link java.io.Reader Reader} which should be sent to one
@@ -97,6 +120,9 @@
*/
@CreoleResource(name="GATE Unicode Tokeniser", comment="A customisable Unicode
tokeniser.", helpURL="http://gate.ac.uk/userguide/sec:annie:tokeniser",
icon="tokeniser")
public class SimpleTokeniser extends AbstractLanguageAnalyser{
+
+ private static final long serialVersionUID = 1411111968361716069L;
+
public static final String
SIMP_TOK_DOCUMENT_PARAMETER_NAME = "document";
@@ -109,10 +135,6 @@
public static final String
SIMP_TOK_ENCODING_PARAMETER_NAME = "encoding";
- /** Debug flag
- */
- private static final boolean DEBUG = false;
-
/**
* Creates a tokeniser
*/
@@ -127,17 +149,16 @@
*/
@Override
public Resource init() throws ResourceInstantiationException{
- Reader rulesReader;
+ BufferedReader bRulesReader = null;
try{
if(rulesURL != null){
- rulesReader = new BomStrippingInputStreamReader(rulesURL.openStream(),
encoding);
+ bRulesReader = new BufferedReader(new
BomStrippingInputStreamReader(rulesURL.openStream(), encoding));
}else{
//no init data, Scream!
throw new ResourceInstantiationException(
"No URL provided for the rules!");
}
initialState = new FSMState(this);
- BufferedReader bRulesReader = new BufferedReader(rulesReader);
String line = bRulesReader.readLine();
///String toParse = "";
StringBuffer toParse = new StringBuffer(Gate.STRINGBUFFER_SIZE);
@@ -163,6 +184,9 @@
}catch(TokeniserException te){
throw new ResourceInstantiationException(te);
}
+ finally {
+ IOUtils.closeQuietly(bRulesReader);
+ }
return this;
}
@@ -376,8 +400,8 @@
FSMState top;
FSMState currentState;
- Set nextStates;
- Iterator statesIter;
+ Set<FSMState> nextStates;
+ Iterator<FSMState> statesIter;
while(!list.isEmpty()) {
top = list.removeFirst();
@@ -387,7 +411,7 @@
statesIter = nextStates.iterator();
while(statesIter.hasNext()) {
- currentState = (FSMState)statesIter.next();
+ currentState = statesIter.next();
if(!lambdaClosure.contains(currentState)){
lambdaClosure.add(currentState);
list.addFirst(currentState);
@@ -406,8 +430,8 @@
//kalina:clear() faster than init() which is called with init()
newStates.clear();
- Set<Set> sdStates = new HashSet<Set>();
- LinkedList<Set> unmarkedDStates = new LinkedList<Set>();
+ Set<Set<FSMState>> sdStates = new HashSet<Set<FSMState>>();
+ LinkedList<Set<FSMState>> unmarkedDStates = new
LinkedList<Set<FSMState>>();
DFSMState dCurrentState = new DFSMState(this);
Set<FSMState> sdCurrentState = new HashSet<FSMState>();
@@ -510,9 +534,9 @@
StringBuffer nodes = new StringBuffer(Gate.STRINGBUFFER_SIZE),
edges = new StringBuffer(Gate.STRINGBUFFER_SIZE);
- Iterator fsmStatesIter = fsmStates.iterator();
+ Iterator<FSMState> fsmStatesIter = fsmStates.iterator();
while (fsmStatesIter.hasNext()){
- FSMState currentState = (FSMState)fsmStatesIter.next();
+ FSMState currentState = fsmStatesIter.next();
int stateIndex = currentState.getIndex();
/*nodes += "node[ id " + stateIndex +
" label \"" + stateIndex;
@@ -544,9 +568,9 @@
StringBuffer nodes = new StringBuffer(Gate.STRINGBUFFER_SIZE),
edges = new StringBuffer(Gate.STRINGBUFFER_SIZE);
- Iterator dfsmStatesIter = dfsmStates.iterator();
+ Iterator<DFSMState> dfsmStatesIter = dfsmStates.iterator();
while (dfsmStatesIter.hasNext()) {
- DFSMState currentState = (DFSMState)dfsmStatesIter.next();
+ DFSMState currentState = dfsmStatesIter.next();
int stateIndex = currentState.getIndex();
/* nodes += "node[ id " + stateIndex +
" label \"" + stateIndex;
@@ -767,7 +791,7 @@
/** A set containng all the states of the non deterministic machine
*/
- protected Set fsmStates = new HashSet();
+ protected Set<FSMState> fsmStates = new HashSet<FSMState>();
/** The initial state of the deterministic machine
*/
@@ -775,7 +799,7 @@
/** A set containng all the states of the deterministic machine
*/
- protected Set dfsmStates = new HashSet();
+ protected Set<DFSMState> dfsmStates = new HashSet<DFSMState>();
/** The separator from LHS to RH
*/
@@ -817,9 +841,9 @@
private String rulesResourceName;
private java.net.URL rulesURL;
private String encoding;
- private transient Vector progressListeners;
+
//kalina: added this as method to minimise too many init() calls
- protected transient Map<Set, DFSMState> newStates = new HashMap<Set,
DFSMState>();
+ protected transient Map<Set<FSMState>, DFSMState> newStates = new
HashMap<Set<FSMState>, DFSMState>();
/** The static initialiser will inspect the class {@link java.lang.Character}
Modified: gate/trunk/src/main/gate/creole/tokeniser/TokeniserException.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/TokeniserException.java
2014-03-08 12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/TokeniserException.java
2014-03-08 13:05:32 UTC (rev 17595)
@@ -20,9 +20,9 @@
/** The top level exception for all the exceptions fired by the tokeniser */
public class TokeniserException extends GateException {
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = 4372777620099537935L;
+
public TokeniserException(String text){ super(text); }
} // class TokeniserException
Modified: gate/trunk/src/main/gate/creole/tokeniser/UnicodeType.java
===================================================================
--- gate/trunk/src/main/gate/creole/tokeniser/UnicodeType.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/creole/tokeniser/UnicodeType.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -20,8 +20,6 @@
* the static member of java.lang.Character).
*/
class UnicodeType {
- /** Debug flag */
- private static final boolean DEBUG = false;
int type;
Modified: gate/trunk/src/main/gate/email/EmailDocumentHandler.java
===================================================================
--- gate/trunk/src/main/gate/email/EmailDocumentHandler.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/email/EmailDocumentHandler.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -41,9 +41,6 @@
*/
public class EmailDocumentHandler {
- /** Debug flag */
- private static final boolean DEBUG = false;
-
private String content = null;
private long documentSize = 0;
@@ -130,7 +127,6 @@
boolean insideAnEmail = false;
boolean insideHeader = false;
- boolean insideBody = false;
boolean emailReadBefore = false;
boolean fieldReadBefore = false;
@@ -562,7 +558,7 @@
* Initialises the collections with data used by method lineBeginsMessage()
*/
private void setUp(){
- day = new HashSet();
+ day = new HashSet<String>();
day.add("Mon");
day.add("Tue");
day.add("Wed");
@@ -571,7 +567,7 @@
day.add("Sat");
day.add("Sun");
- month = new HashSet();
+ month = new HashSet<String>();
month.add("Jan");
month.add("Feb");
month.add("Mar");
@@ -585,7 +581,7 @@
month.add("Nov");
month.add("Dec");
- zone = new HashSet();
+ zone = new HashSet<String>();
zone.add("UT");
zone.add("GMT");
zone.add("EST");
@@ -629,17 +625,13 @@
* about an event.
*/
protected void fireStatusChangedEvent(String text){
- Iterator listenersIter = myStatusListeners.iterator();
+ Iterator<StatusListener> listenersIter = myStatusListeners.iterator();
while(listenersIter.hasNext())
- ((StatusListener)listenersIter.next()).statusChanged(text);
+ listenersIter.next().statusChanged(text);
}
private static final int EMAILS_RATE = 16;
- // the content of the e-mail document, without any tag
- // for internal use
- private String tmpDocContent = null;
-
// a gate document
private gate.Document gateDocument = null;
@@ -653,7 +645,7 @@
private Map element2StringMap = null;
// listeners for status report
- protected List myStatusListeners = new LinkedList();
+ protected List<StatusListener> myStatusListeners = new
LinkedList<StatusListener>();
// this reports the the number of emails that have beed processed so far
private int emails = 0;
@@ -663,9 +655,9 @@
// in this member.
private String fieldName = null;
- private Collection day = null;
- private Collection month = null;
- private Collection zone = null;
+ private Collection<String> day = null;
+ private Collection<String> month = null;
+ private Collection<String> zone = null;
// TEST SECTION
Modified: gate/trunk/src/main/gate/event/AnnotationEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/AnnotationEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/AnnotationEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -21,6 +21,8 @@
*/
public class AnnotationEvent extends GateEvent{
+ private static final long serialVersionUID = -5794804058531941540L;
+
/**Event type used for situations when an annotation has been updated*/
public static final int ANNOTATION_UPDATED = 601;
Modified: gate/trunk/src/main/gate/event/AnnotationSetEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/AnnotationSetEvent.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/event/AnnotationSetEvent.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -21,6 +21,8 @@
*/
public class AnnotationSetEvent extends GateEvent{
+ private static final long serialVersionUID = 6618095991726447858L;
+
/**Event type used for situations when a new annotation has been added*/
public static final int ANNOTATION_ADDED = 201;
Modified: gate/trunk/src/main/gate/event/ControllerEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/ControllerEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/ControllerEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -22,6 +22,9 @@
* Events fired by controllers.
*/
public class ControllerEvent extends GateEvent{
+
+ private static final long serialVersionUID = 7881276383734235706L;
+
public ControllerEvent(Object source, int type, ProcessingResource pr){
super(source, type);
this.pr = pr;
Modified: gate/trunk/src/main/gate/event/CorpusEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/CorpusEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/CorpusEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -22,6 +22,8 @@
*/
public class CorpusEvent extends GateEvent {
+ private static final long serialVersionUID = -1499954680735513011L;
+
/**
* Event type that is fired when a new document is added to a corpus
*/
Modified: gate/trunk/src/main/gate/event/CreoleEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/CreoleEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/CreoleEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -22,6 +22,8 @@
*/
public class CreoleEvent extends GateEvent {
+ private static final long serialVersionUID = -6834347398037784548L;
+
/**
* Constructor
* @param res the {@link gate.Resource} that has been (un)loaded
Modified: gate/trunk/src/main/gate/event/DatastoreEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/DatastoreEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/DatastoreEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -22,6 +22,8 @@
*/
public class DatastoreEvent extends GateEvent {
+ private static final long serialVersionUID = 1807421127920552348L;
+
/**
* Constructor.
* @param source the datastore that originated the event.
Modified: gate/trunk/src/main/gate/event/DocumentEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/DocumentEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/DocumentEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -20,6 +20,8 @@
*/
public class DocumentEvent extends GateEvent {
+ private static final long serialVersionUID = 2315324967342557414L;
+
/**Event type used to mark the addition of an {@link gate.AnnotationSet}*/
public static final int ANNOTATION_SET_ADDED = 101;
Modified: gate/trunk/src/main/gate/event/GateEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/GateEvent.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/event/GateEvent.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -20,6 +20,8 @@
*/
public class GateEvent extends EventObject {
+ private static final long serialVersionUID = 7914516539094860389L;
+
public static final int FEATURES_UPDATED = 701;
/**
Modified: gate/trunk/src/main/gate/event/ObjectModificationEvent.java
===================================================================
--- gate/trunk/src/main/gate/event/ObjectModificationEvent.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/event/ObjectModificationEvent.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -18,6 +18,8 @@
public class ObjectModificationEvent extends GateEvent {
+ private static final long serialVersionUID = 317108345148607338L;
+
public static final int OBJECT_CREATED = 1000;
public static final int OBJECT_MODIFIED = 1001;
public static final int OBJECT_DELETED = 1002;
Modified: gate/trunk/src/main/gate/event/ProgressListenerAdaptor.java
===================================================================
--- gate/trunk/src/main/gate/event/ProgressListenerAdaptor.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/event/ProgressListenerAdaptor.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -20,9 +20,6 @@
*/
public class ProgressListenerAdaptor implements ProgressListener {
- /** Debug flag */
- private static final boolean DEBUG = false;
-
@Override
public void progressChanged(int i){}
Modified: gate/trunk/src/main/gate/fsm/FSM.java
===================================================================
--- gate/trunk/src/main/gate/fsm/FSM.java 2014-03-08 12:07:09 UTC (rev
17594)
+++ gate/trunk/src/main/gate/fsm/FSM.java 2014-03-08 13:05:32 UTC (rev
17595)
@@ -29,9 +29,11 @@
*/
public class FSM implements JapeConstants {
- private ArrayList<RuleTime> ruleTimes = new ArrayList<RuleTime>();
+ private static final long serialVersionUID = -7088856970776558801L;
- public ArrayList<RuleTime> getRuleTimes() {
+ private List<RuleTime> ruleTimes = new ArrayList<RuleTime>();
+
+ public List<RuleTime> getRuleTimes() {
return ruleTimes;
}
@@ -75,10 +77,10 @@
* Do the work involved in creating an FSM from a PrioritisedRuleList.
*/
protected void addRules(PrioritisedRuleList rules) {
- Iterator rulesEnum = rules.iterator();
+ Iterator<Rule> rulesEnum = rules.iterator();
while(rulesEnum.hasNext()){
- FSM ruleFSM = spawn((Rule) rulesEnum.next());
+ FSM ruleFSM = spawn(rulesEnum.next());
//added by Karter start -> JapeDebugger
ruleHash.putAll(ruleFSM.ruleHash);
@@ -343,6 +345,7 @@
private State generateStates(State startState, ComplexPatternElement cpe,
LinkedList<String> labels) {
//create a copy
+ @SuppressWarnings("unchecked")
LinkedList<String> newBindings = (LinkedList<String>)labels.clone();
String localLabel = cpe.getBindingName ();
@@ -425,8 +428,8 @@
public void eliminateVoidTransitions() {
dStates.clear(); //kalina: replaced from new HashSet()
- LinkedList<AbstractSet<State>> unmarkedDStates = new
LinkedList<AbstractSet<State>>();
- AbstractSet<State> currentDState = new HashSet<State>();
+ LinkedList<Set<State>> unmarkedDStates = new LinkedList<Set<State>>();
+ Set<State> currentDState = new HashSet<State>();
//kalina: prefer clear coz faster than init()
newStates.clear();
@@ -441,11 +444,11 @@
newStates.put(currentDState, initialState);
// find out if the new state is a final one
- Iterator innerStatesIter = currentDState.iterator();
+ Iterator<State> innerStatesIter = currentDState.iterator();
RightHandSide action = null;
while(innerStatesIter.hasNext()){
- State currentInnerState = (State)innerStatesIter.next();
+ State currentInnerState = innerStatesIter.next();
if(currentInnerState.isFinal()){
action = currentInnerState.getAction();
initialState.setAction(action);
@@ -457,18 +460,18 @@
while(!unmarkedDStates.isEmpty()) {
currentDState = unmarkedDStates.removeFirst();
- Iterator insideStatesIter = currentDState.iterator();
+ Iterator<State> insideStatesIter = currentDState.iterator();
while(insideStatesIter.hasNext()) {
- State innerState = (State)insideStatesIter.next();
- Iterator transIter = innerState.getTransitions().iterator();
+ State innerState = insideStatesIter.next();
+ Iterator<Transition> transIter =
innerState.getTransitions().iterator();
while(transIter.hasNext()) {
- Transition currentTrans = (Transition)transIter.next();
+ Transition currentTrans = transIter.next();
if(currentTrans.getConstraints() !=null) {
State target = currentTrans.getTarget();
- AbstractSet<State> newDState = new HashSet<State>();
+ Set<State> newDState = new HashSet<State>();
newDState.add(target);
newDState = lambdaClosure(newDState);
@@ -481,7 +484,7 @@
//find out if the new state is a final one
innerStatesIter = newDState.iterator();
while(innerStatesIter.hasNext()) {
- State currentInnerState = (State)innerStatesIter.next();
+ State currentInnerState = innerStatesIter.next();
if(currentInnerState.isFinal()) {
newState.setAction(
@@ -535,14 +538,14 @@
* @return a set containing all the states accessible from this state via
* transitions that bear no restrictions.
*/
- private AbstractSet<State> lambdaClosure(AbstractSet<State> s) {
+ private Set<State> lambdaClosure(Set<State> s) {
// the stack/queue used by the algorithm
LinkedList<State> list = new LinkedList<State>(s);
// the set to be returned
- AbstractSet<State> lambdaClosure = new HashSet<State>(s);
+ Set<State> lambdaClosure = new HashSet<State>(s);
State top;
- Iterator transIter;
+ Iterator<Transition> transIter;
Transition currentTransition;
State currentState;
while(!list.isEmpty()){
@@ -550,7 +553,7 @@
transIter = top.getTransitions().iterator();
while(transIter.hasNext()){
- currentTransition = (Transition)transIter.next();
+ currentTransition = transIter.next();
if(currentTransition.getConstraints() == null){
currentState = currentTransition.getTarget();
@@ -717,9 +720,9 @@
StringBuffer nodes = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE),
edges = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
- Iterator stateIter = allStates.iterator();
+ Iterator<State> stateIter = allStates.iterator();
while (stateIter.hasNext()){
- State currentState = (State)stateIter.next();
+ State currentState = stateIter.next();
int stateIndex = currentState.getIndex();
nodes.append("node[ id ");
nodes.append(stateIndex);
@@ -742,7 +745,7 @@
@Override
public String toString(){
String res = "Starting from:" + initialState.getIndex() + "\n";
- Iterator stateIter = allStates.iterator();
+ Iterator<State> stateIter = allStates.iterator();
while (stateIter.hasNext()){
res += "\n\n" + stateIter.next();
}
@@ -762,11 +765,11 @@
/**
* The set of states for this FSM
*/
- private transient Collection allStates = new HashSet();
+ private transient Collection<State> allStates = new HashSet<State>();
//kalina: added this member here to minimise HashMap allocation
- private transient Map<AbstractSet,State> newStates = new
HashMap<AbstractSet,State>();
- private transient Set<AbstractSet> dStates = new HashSet<AbstractSet>();
+ private transient Map<Set<State>,State> newStates = new
HashMap<Set<State>,State>();
+ private transient Set<Set<State>> dStates = new HashSet<Set<State>>();
//added by Karter start
Modified: gate/trunk/src/main/gate/fsm/FSMInstance.java
===================================================================
--- gate/trunk/src/main/gate/fsm/FSMInstance.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/fsm/FSMInstance.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -34,10 +34,9 @@
* note that a set of bindings is an object of type Map that maps names
* (java.lang.String) to bags of annotations (gate.AnnotationSet)
*/
-public class FSMInstance implements Comparable, Cloneable, Serializable {
+public class FSMInstance implements Comparable<FSMInstance>, Cloneable,
Serializable {
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = -2081096002552818621L;
/** Creates a new FSMInstance object.
* @param supportGraph the transition graph of the FSM
@@ -125,7 +124,7 @@
* process this FSM instance performed.
* @return a HashMap object
*/
- public HashMap<String, AnnotationSet> getBindings() { return bindings; }
+ public Map<String, AnnotationSet> getBindings() { return bindings; }
/** Returns the length of the parsed region in the document under scrutiny.
* More precisely this is the distnace between the Node in the annotation
@@ -171,7 +170,7 @@
//do a classic clone except for bindings which need to be cloned themselves
try {
FSMInstance clone = (FSMInstance)super.clone();
- clone.bindings = (HashMap)bindings.clone();
+ clone.bindings = new HashMap<String,AnnotationSet>(bindings);
return clone;
} catch (CloneNotSupportedException cnse) {
cnse.printStackTrace(Err.getPrintWriter());
@@ -201,20 +200,15 @@
* multiple match.
*/
@Override
- public int compareTo(Object obj) {
- if (obj instanceof FSMInstance) {
- if(obj == this) return 0;
- FSMInstance other = (FSMInstance)obj;
- if(length < other.getLength()) return -1;
+ public int compareTo(FSMInstance other) {
+ if(other == this) return 0;
+ if(length < other.getLength()) return -1;
else if(length > other.getLength()) return 1;
//equal length
else if(priority < other.priority) return -1;
else if(priority > other.priority) return 1;
//equal priority
else return other.fileIndex - fileIndex;
- } else throw new ClassCastException(
- "Attempt to compare a FSMInstance object to an object " +
- "of type " + obj.getClass()+"!");
}
/** Returns a textual representation of this FSM instance.
@@ -278,7 +272,7 @@
* bindings that took place during matching.
* needs to be HashMap instead of simply Map in order to cloneable
*/
- private HashMap<String, AnnotationSet> bindings;
+ private Map<String, AnnotationSet> bindings;
/** The size of the matched region in the Annotation Set*/
private long length = 0;
@@ -311,7 +305,7 @@
startNode, AGPosition,
bindings, doc);
else {
- res = (FSMInstance)myInstances.removeFirst();
+ res = myInstances.removeFirst();
res.supportGraph = supportGraph;
res.FSMPosition = FSMPosition;
res.startNode = startNode;
@@ -329,15 +323,15 @@
/** Release all the FSMInstances that are not currently in use */
public static void clearInstances() {
- myInstances = new LinkedList();
+ myInstances = new LinkedList<FSMInstance>();
}
/** The list of existing instances of type FSMInstance */
- private static LinkedList myInstances;
+ private static LinkedList<FSMInstance> myInstances;
/** The offset in the input List where the last matched annotation was*/
static{
- myInstances = new LinkedList();
+ myInstances = new LinkedList<FSMInstance>();
}
} // FSMInstance
Modified: gate/trunk/src/main/gate/fsm/State.java
===================================================================
--- gate/trunk/src/main/gate/fsm/State.java 2014-03-08 12:07:09 UTC (rev
17594)
+++ gate/trunk/src/main/gate/fsm/State.java 2014-03-08 13:05:32 UTC (rev
17595)
@@ -16,24 +16,23 @@
package gate.fsm;
-import java.util.ArrayList;
-import java.util.HashMap;
+import gate.jape.BasicPatternElement;
+import gate.jape.JapeConstants;
+import gate.jape.RightHandSide;
+import gate.util.SimpleArraySet;
+
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
-import gate.jape.*;
-import gate.util.SimpleArraySet;
-
/**
* This class implements a Finite State Machine state.
*
*/
public class State implements JapeConstants {
- /** Debug flag
- */
+ private static final long serialVersionUID = 1733852753275942428L;
- private static final boolean DEBUG = false;
-
public static final int UNKNOWN_INDEX = 1;
public static final int VISITED_INDEX = -2;
public static final int UNVISITED_INDEX = 2;
@@ -66,7 +65,7 @@
* Determines the appropriate rule by recursively searching this state's
outbound transitions until
* we reach a final state. Record this state in the ruleTimes and
ruleNameToIndexMap structures
*/
- public int getRuleForState(HashMap<String,Integer>
ruleNameToIndexMap,ArrayList<RuleTime>ruleTimes) {
+ public int getRuleForState(Map<String,Integer> ruleNameToIndexMap,
List<RuleTime>ruleTimes) {
if (this.getIndexInRuleList() != UNVISITED_INDEX) {
return this.getIndexInRuleList();
}
@@ -235,11 +234,11 @@
/// String res = "";
StringBuffer res = new StringBuffer(gate.Gate.STRINGBUFFER_SIZE);
- Iterator transIter = transitions.iterator();
+ Iterator<Transition> transIter = transitions.iterator();
BasicPatternElement bpe;
while(transIter.hasNext()) {
- Transition currentTrans = (Transition)transIter.next();
+ Transition currentTrans = transIter.next();
/* res += "edge [ source " + myIndex +
" target " + currentTrans.getTarget().getIndex() +
" label \"" + currentTrans.shortDesc() + ":";
@@ -281,7 +280,7 @@
///res += "\nTransitions:\n";
res.append("\nTransitions:\n");
- Iterator transIter = transitions.iterator();
+ Iterator<Transition> transIter = transitions.iterator();
while(transIter.hasNext()){
///res += transIter.next().toString();
res.append(transIter.next().toString());
Modified: gate/trunk/src/main/gate/fsm/Transition.java
===================================================================
--- gate/trunk/src/main/gate/fsm/Transition.java 2014-03-08 12:07:09 UTC
(rev 17594)
+++ gate/trunk/src/main/gate/fsm/Transition.java 2014-03-08 13:05:32 UTC
(rev 17595)
@@ -16,13 +16,14 @@
package gate.fsm;
-import java.io.Serializable;
-import java.util.LinkedList;
-
import gate.Annotation;
import gate.jape.BasicPatternElement;
import gate.jape.Constraint;
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* This class implements a Finite State Machine transition.
* A transition is owned by a gate.fsm.State object and contains set of
@@ -36,12 +37,12 @@
public class Transition implements Serializable {
*/
// >>> DAM, TransArray optimzation, now implements the Comparable interface
-public class Transition implements Serializable, Comparable {
+public class Transition implements Serializable, Comparable<Transition> {
+
+ private static final long serialVersionUID = 5970884178025357306L;
+
// >>> DAM, end
- /** Debug flag */
- private static final boolean DEBUG = false;
-
/**
* Default constructor. Creates a new transition with a new unique index.
* This constructor should be called by all other constructors.
@@ -57,7 +58,7 @@
* @param state the target state of this transition
*/
public Transition(BasicPatternElement constraints, State state) {
- this(constraints, state, new LinkedList());
+ this(constraints, state, new LinkedList<String>());
}
/**
@@ -66,7 +67,7 @@
* (aka annotations).
*/
public Transition(BasicPatternElement constraints, State state,
- LinkedList bindings) {
+ List<String> bindings) {
this();
this.constraints = constraints;
target = state;
@@ -174,7 +175,7 @@
/**
* Returns the list of bindings associated to this transition
*/
- public LinkedList getBindings(){ return bindings; }
+ public List<String> getBindings(){ return bindings; }
/**
* The constraints on this transition.
@@ -189,10 +190,8 @@
/**
* A list with all the labels associated to the annotations recognized by
* this transition.
- * We need to use the actual object and not the interface (java.util.List)
- * because we need this object to be cloneable
*/
- private LinkedList bindings;
+ private List<String> bindings;
/** The unique index of this transition. This value is not used by any of
* the algorithms. It is only provided as a convenient method of identifying
@@ -207,11 +206,10 @@
// >>> DAM, TransArray optimzation, now implements the Comparable interface
@Override
- public int compareTo(Object o)
+ public int compareTo(Transition t)
throws ClassCastException
{
- if (!(o instanceof Transition)) throw new
ClassCastException("gate.frm.Transition(compareTo)");
- return myIndex - ((Transition)o).myIndex;
+ return myIndex - t.myIndex;
}
// >>> DAM, end
} // Transition
Modified: gate/trunk/src/main/gate/jape/PrioritisedRuleList.java
===================================================================
--- gate/trunk/src/main/gate/jape/PrioritisedRuleList.java 2014-03-08
12:07:09 UTC (rev 17594)
+++ gate/trunk/src/main/gate/jape/PrioritisedRuleList.java 2014-03-08
13:05:32 UTC (rev 17595)
@@ -33,15 +33,14 @@
* insertion of elements at any point. The highest priority rule is the
* first in the list, which may be accessed by <CODE>front()</CODE>.
*/
-public class PrioritisedRuleList extends ArrayList implements
java.io.Serializable
+public class PrioritisedRuleList extends ArrayList<Rule> implements
java.io.Serializable
{
- /** Debug flag */
- private static final boolean DEBUG = false;
+ private static final long serialVersionUID = 1603854971047597460L;
/** Adds a rule in order. Used for non-matched rules. Implements the
* ordering based on priority/position.
*/
- public synchronized void add(Rule newRule) {
+ public synchronized boolean add(Rule newRule) {
/* for each rule,
* if it is higher priority, continue;
* else if it is same priority
@@ -50,10 +49,10 @@
* else (it is lower priority) break
* insert newRule before current position (which may be finish)
*/
- Iterator iterator = this.iterator();
+ Iterator<Rule> iterator = this.iterator();
int i = 0;
for( ; iterator.hasNext(); i++) {
- Rule rule = (Rule) iterator.next();
+ Rule rule = iterator.next();
int rulePriority = rule.getPriority();
int newRulePriority = newRule.getPriority();
int rulePosition = rule.getPosition();
@@ -74,6 +73,8 @@
this.add(i, newRule);
+
+ return true;
} // add(Rule)
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