Revision: 17601
http://sourceforge.net/p/gate/code/17601
Author: markagreenwood
Date: 2014-03-08 18:56:22 +0000 (Sat, 08 Mar 2014)
Log Message:
-----------
and a few more, although it's now time to go peel potatoes for dinner; roast
chicken, roast potatoes, and creamy roast parsnips with butternut squash
Modified Paths:
--------------
gate/trunk/src/main/gate/util/ant/packager/GazetteerLists.java
gate/trunk/src/main/gate/util/profile/Profiler.java
Modified: gate/trunk/src/main/gate/util/ant/packager/GazetteerLists.java
===================================================================
--- gate/trunk/src/main/gate/util/ant/packager/GazetteerLists.java
2014-03-08 18:47:11 UTC (rev 17600)
+++ gate/trunk/src/main/gate/util/ant/packager/GazetteerLists.java
2014-03-08 18:56:22 UTC (rev 17601)
@@ -11,6 +11,7 @@
import java.util.Iterator;
import java.util.Set;
+import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;
@@ -56,6 +57,7 @@
* ResourceCollection interface: returns an iterator over the list
* files.
*/
+ @SuppressWarnings("rawtypes")
@Override
public Iterator iterator() {
load();
@@ -100,36 +102,34 @@
Set<String> lists = new HashSet<String>();
+ BufferedReader in = null;
+
try {
- FileInputStream fis = new FileInputStream(definition);
- try {
- BufferedReader in = null;
- if(encoding == null) {
- in = new BomStrippingInputStreamReader(fis);
- }
- else {
- in = new BomStrippingInputStreamReader(fis, encoding);
- }
+ if(encoding == null) {
+ in = new BomStrippingInputStreamReader(new
FileInputStream(definition));
+ }
+ else {
+ in = new BomStrippingInputStreamReader(new
FileInputStream(definition), encoding);
+ }
- String line;
- while((line = in.readLine()) != null) {
- int indexOfColon = line.indexOf(':');
- // Ignore lines that don't include a colon.
- if(indexOfColon > 0) {
- String listFile = line.substring(0, indexOfColon);
- lists.add(listFile);
- log("Found list file " + listFile, Project.MSG_VERBOSE);
- }
+ String line;
+ while((line = in.readLine()) != null) {
+ int indexOfColon = line.indexOf(':');
+ // Ignore lines that don't include a colon.
+ if(indexOfColon > 0) {
+ String listFile = line.substring(0, indexOfColon);
+ lists.add(listFile);
+ log("Found list file " + listFile, Project.MSG_VERBOSE);
}
}
- finally {
- fis.close();
- }
}
catch(IOException ioe) {
throw new BuildException("Error reading gazetteer definition file "
+ definition, ioe);
}
+ finally {
+ IOUtils.closeQuietly(in);
+ }
listNames = lists.toArray(new String[lists.size()]);
}
Modified: gate/trunk/src/main/gate/util/profile/Profiler.java
===================================================================
--- gate/trunk/src/main/gate/util/profile/Profiler.java 2014-03-08 18:47:11 UTC
(rev 17600)
+++ gate/trunk/src/main/gate/util/profile/Profiler.java 2014-03-08 18:56:22 UTC
(rev 17601)
@@ -43,8 +43,9 @@
*/
//import java.io.PrintStream;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.apache.log4j.Logger;
@@ -59,14 +60,14 @@
private boolean m_doPrintToStdOut = true;
// keeps the sum of the time spend on a category of tasks
- // the catoegries are identified via strings which are used as
+ // the categories are identified via strings which are used as
// keys in the table. The values in the table are Long objects, millisec.
- private Hashtable m_categorySums;
+ private Map<String,Long> m_categorySums;
// keeps the time spend on the last task of a category
- // the catoegries are identified via strings which are used as
+ // the categories are identified via strings which are used as
// keys in the table. The values in the table are Long objects, millisec.
- private Hashtable m_categoryLasts;
+ private Map<String,Long> m_categoryLasts;
private Runtime m_rt;
@@ -170,8 +171,8 @@
m_lastCheckTime=0;
m_lastDuration=0;
- m_categorySums = new Hashtable();
- m_categoryLasts = new Hashtable();
+ m_categorySums = new HashMap<String,Long>();
+ m_categoryLasts = new HashMap<String,Long>();
if ( m_doPrintToStdOut ) {
log.debug(buf.toString());
}
@@ -237,11 +238,11 @@
private void checkCategories(String categs[]) {
int size = categs.length;
String categ;
- long last, sum;
+ long sum;
Long l;
for (int i=0; i<size; i++) {
categ = categs[i].toUpperCase();
- l = (Long)m_categorySums.get(categ);
+ l = m_categorySums.get(categ);
sum = (l==null) ? 0 : l.longValue();
sum += m_lastDuration;
m_categorySums.put(categ, new Long(sum));
@@ -286,7 +287,7 @@
* Returns 0 if the category was not found
*/
public long getCategoryTimeSum(String category) {
- Long sum = (Long)m_categorySums.get(category.toUpperCase());
+ Long sum = m_categorySums.get(category.toUpperCase());
return (sum == null) ? 0 : sum.longValue();
} // getCategoryTimeSum
@@ -294,7 +295,7 @@
* Returns 0 if the category was not found
*/
public long getCategoryTimeLast(String category) {
- Long sum = (Long)m_categoryLasts.get(category.toUpperCase());
+ Long sum = m_categoryLasts.get(category.toUpperCase());
return (sum == null) ? 0 : sum.longValue();
} // getCategoryTimeSum
@@ -303,10 +304,10 @@
*/
public void showCategoryTimes() {
log.debug("Time spent by categories:");
- Enumeration categNames = m_categorySums.keys();
+ Iterator<String> categNames = m_categorySums.keySet().iterator();
String categ;
- while (categNames.hasMoreElements()) {
- categ = (String)categNames.nextElement();
+ while (categNames.hasNext()) {
+ categ = categNames.next();
showCategoryTime(categ);
} // while
} // showCategoryTimes
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