ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1590312 [1/2] - in /ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup: ./ ae/ algorithms/ filter/ jdbc/ lucene/ phrasebuilder/ strtable/ vo/
Date Sat, 26 Apr 2014 22:04:50 GMT
Author: tmill
Date: Sat Apr 26 22:04:49 2014
New Revision: 1590312

URL: http://svn.apache.org/r1590312
Log:
CTAKES-197: Update Dictionary module to java 7 (and java 5 and 6 while I was at it).

Modified:
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/AbstractBaseDictionary.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/BaseDictionaryImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/DictionaryEngine.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/DictionaryLookupAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/FirstTokenPermLookupInitializerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupAnnotationToJCasAdapter.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilities.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilitiesRefactor.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/NamedEntityLookupConsumerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/OrangeBookFilterConsumerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedUmlsDictionaryLookupAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedConsumerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedLuceneConsumerImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/DirectPassThroughImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/FirstTokenPermutationImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/PermutationUtil.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/MetaDataPostLookupFilterImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/PostLookupFilterGroupImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/SetValuePostLookupFilterImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/TruncateCollectionFilterImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/jdbc/JdbcDictionaryImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDictionaryImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDocumentMetaDataHitImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/PhraseBuilder.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/VariantPhraseBuilderImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/FieldConstraintImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/StringTable.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/StringTableDictionaryImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/StringTableFactory.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/StringTableRow.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/strtable/StringTableRowMetaDataHitImpl.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/vo/LookupAnnotationToTokAdapter.java
    ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/vo/LookupHit.java

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/AbstractBaseDictionary.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/AbstractBaseDictionary.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/AbstractBaseDictionary.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/AbstractBaseDictionary.java Sat Apr 26 22:04:49 2014
@@ -28,7 +28,7 @@ import java.util.Set;
  */
 public abstract class AbstractBaseDictionary implements Dictionary {
 
-    private Set<String> _metaFieldNames = new HashSet<String>();
+    private Set<String> _metaFieldNames = new HashSet<>();
 
    /**
     * TODO - get rid of the using class iterators and use Collection foreach

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/BaseDictionaryImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/BaseDictionaryImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/BaseDictionaryImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/BaseDictionaryImpl.java Sat Apr 26 22:04:49 2014
@@ -33,7 +33,7 @@ import java.util.Set;
 @Deprecated
 public abstract class BaseDictionaryImpl implements Dictionary
 {
-    private Set<String> iv_metaFieldNames = new HashSet<String>();
+    private Set<String> iv_metaFieldNames = new HashSet<>();
 
     protected Iterator<String> getMetaFieldNames()
     {

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/DictionaryEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/DictionaryEngine.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/DictionaryEngine.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/DictionaryEngine.java Sat Apr 26 22:04:49 2014
@@ -42,15 +42,15 @@ public class DictionaryEngine {
    final private boolean _keepCase;
 
    // use Lists to store filters to maintain order
-   private List<PreLookupFilter> _preLookupFilterList = new ArrayList<PreLookupFilter>();
-   private List<PostLookupFilter> _postLookupFilterList = new ArrayList<PostLookupFilter>();
-   private List<CollectionFilter> _collectionFilterList = new ArrayList<CollectionFilter>();
+   private List<PreLookupFilter> _preLookupFilterList = new ArrayList<>();
+   private List<PostLookupFilter> _postLookupFilterList = new ArrayList<>();
+   private List<CollectionFilter> _collectionFilterList = new ArrayList<>();
 
    // cache objs
    // key = String text, value = Boolean
-   private Map<String, Boolean> _binaryLookupCacheMap = new HashMap<String, Boolean>();
+   private Map<String, Boolean> _binaryLookupCacheMap = new HashMap<>();
    // key = String text, value = Collection of MetaDataHits
-   private Map<String, Collection<MetaDataHit>> _metaLookupCacheMap = new HashMap<String, Collection<MetaDataHit>>();
+   private Map<String, Collection<MetaDataHit>> _metaLookupCacheMap = new HashMap<>();
 
 
    /**
@@ -138,7 +138,7 @@ public class DictionaryEngine {
       }
       // apply post-filtering
       if ( !_postLookupFilterList.isEmpty() ) {
-         final Set<MetaDataHit> mdhRemovalSet = new HashSet<MetaDataHit>();
+         final Set<MetaDataHit> mdhRemovalSet = new HashSet<>();
          for ( MetaDataHit metaDataHit : metaDataHitCol ) {
             // check the mdhRemoval set before iterating over the entire filter list (and filter .contains calls)
             if ( !mdhRemovalSet.contains( metaDataHit ) ) {

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/DictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/DictionaryLookupAnnotator.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/DictionaryLookupAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/DictionaryLookupAnnotator.java Sat Apr 26 22:04:49 2014
@@ -22,7 +22,6 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -33,6 +32,7 @@ import java.util.Set;
 import org.apache.ctakes.core.resource.FileResource;
 import org.apache.ctakes.dictionary.lookup.MetaDataHit;
 import org.apache.ctakes.dictionary.lookup.algorithms.LookupAlgorithm;
+import org.apache.ctakes.dictionary.lookup.vo.LookupAnnotation;
 import org.apache.ctakes.dictionary.lookup.vo.LookupHit;
 import org.apache.ctakes.dictionary.lookup.vo.LookupToken;
 import org.apache.ctakes.dictionary.lookup.vo.LookupTokenComparator;
@@ -57,14 +57,15 @@ public class DictionaryLookupAnnotator e
 
 	private UimaContext iv_context;
 
-	private Set iv_lookupSpecSet = new HashSet();
+	private Set<LookupSpec> iv_lookupSpecSet = new HashSet<>();
 
 	// used to prevent duplicate hits
 	// key = hit begin,end key (java.lang.String)
 	// val = Set of MetaDataHit objects
-	private Map iv_dupMap = new HashMap();
+	private Map<String,Set<MetaDataHit>> iv_dupMap = new HashMap<>();
 
-	public void initialize(UimaContext aContext)
+	@Override
+  public void initialize(UimaContext aContext)
 			throws ResourceInitializationException
 	{
 		super.initialize(aContext);
@@ -95,7 +96,8 @@ public class DictionaryLookupAnnotator e
 	/**
 	 * Entry point for processing.
 	 */
-	public void process(JCas jcas)
+	@Override
+  public void process(JCas jcas)
 			throws AnalysisEngineProcessException {
 		
 		iv_logger.info("process(JCas)");
@@ -103,19 +105,19 @@ public class DictionaryLookupAnnotator e
 		
 		try {
 
-			Iterator lsItr = iv_lookupSpecSet.iterator();
+			Iterator<LookupSpec> lsItr = iv_lookupSpecSet.iterator();
 			while (lsItr.hasNext()) {
 
-				LookupSpec ls = (LookupSpec) lsItr.next();
+				LookupSpec ls = lsItr.next();
 				LookupInitializer lInit = ls.getLookupInitializer();
 
-				Iterator windowItr = lInit.getLookupWindowIterator(jcas);
+				Iterator<Annotation> windowItr = lInit.getLookupWindowIterator(jcas);
 				while (windowItr.hasNext()) {
 
-					Annotation window = (Annotation) windowItr.next();
-					List lookupTokensInWindow = lInit.getSortedLookupTokens(jcas, window);
+					Annotation window = windowItr.next();
+					List<LookupToken> lookupTokensInWindow = lInit.getSortedLookupTokens(jcas, window);
 											
-					Map ctxMap = lInit.getContextMap(
+					Map<String, List<LookupAnnotation>> ctxMap = lInit.getContextMap(
 							jcas,
 							window.getBegin(),
 							window.getEnd());
@@ -133,19 +135,19 @@ public class DictionaryLookupAnnotator e
 	 * Executes the lookup algorithm on the lookup tokens. Hits are stored to
 	 * CAS.
 	 */
-	private void performLookup(JCas jcas, LookupSpec ls, List lookupTokenList,
-			Map ctxMap) throws Exception
+	private void performLookup(JCas jcas, LookupSpec ls, List<LookupToken> lookupTokenList,
+			Map<String, List<LookupAnnotation>> ctxMap) throws Exception
 	{
 		// sort the lookup tokens
 		Collections.sort(lookupTokenList, LookupTokenComparator.getInstance() );
 
 		// perform lookup
-		Collection lookupHitCol = null;
+		Collection<LookupHit> lookupHitCol = null;
 
-		LookupAlgorithm la = (LookupAlgorithm) ls.getLookupAlgorithm();
+		LookupAlgorithm la = ls.getLookupAlgorithm();
 		lookupHitCol = la.lookup(lookupTokenList, ctxMap);
 
-		Collection uniqueHitCol = filterHitDups(lookupHitCol);
+		Collection<LookupHit> uniqueHitCol = filterHitDups(lookupHitCol);
 
 		// consume hits
 		ls.getLookupConsumer().consumeHits(jcas, uniqueHitCol.iterator());
@@ -157,13 +159,13 @@ public class DictionaryLookupAnnotator e
 	 * @param lookupHitCol
 	 * @return
 	 */
-	private Collection filterHitDups(Collection lookupHitCol)
+	private Collection<LookupHit> filterHitDups(Collection<LookupHit> lookupHitCol)
 	{
-		List l = new ArrayList();
-		Iterator itr = lookupHitCol.iterator();
+		List<LookupHit> l = new ArrayList<>();
+		Iterator<LookupHit> itr = lookupHitCol.iterator();
 		while (itr.hasNext())
 		{
-			LookupHit lh = (LookupHit) itr.next();
+			LookupHit lh = itr.next();
 			if (!isDuplicate(lh))
 			{
 				l.add(lh);
@@ -184,13 +186,13 @@ public class DictionaryLookupAnnotator e
 
 		// iterate over MetaDataHits that have already been seen
 		String offsetKey = getOffsetKey(lh);
-		Set mdhDuplicateSet = (Set) iv_dupMap.get(offsetKey);
+		Set<MetaDataHit> mdhDuplicateSet = iv_dupMap.get(offsetKey);
 		if (mdhDuplicateSet != null)
 		{
-			Iterator itr = mdhDuplicateSet.iterator();
+			Iterator<MetaDataHit> itr = mdhDuplicateSet.iterator();
 			while (itr.hasNext())
 			{
-				MetaDataHit otherMdh = (MetaDataHit) itr.next();
+				MetaDataHit otherMdh = itr.next();
 				if (mdh.equals(otherMdh))
 				{
 					// current LookupHit is a duplicate
@@ -200,7 +202,7 @@ public class DictionaryLookupAnnotator e
 		}
 		else
 		{
-			mdhDuplicateSet = new HashSet();
+			mdhDuplicateSet = new HashSet<>();
 		}
 
 		// current LookupHit is new, add it to the duplicate set
@@ -219,14 +221,15 @@ public class DictionaryLookupAnnotator e
 	 * @return
 	 * @throws Exception
 	 */
-	private List constrainToWindow(Annotation window, Iterator lookupTokenItr)
+	@SuppressWarnings("unused")
+  private static List<LookupToken> constrainToWindow(Annotation window, Iterator<LookupToken> lookupTokenItr)
 			throws Exception
 	{
-		List ltObjectList = new ArrayList();
+		List<LookupToken> ltObjectList = new ArrayList<>();
 
 		while (lookupTokenItr.hasNext())
 		{
-			LookupToken lt = (LookupToken) lookupTokenItr.next();
+			LookupToken lt = lookupTokenItr.next();
 
 			// only consider if it's within the window
 			if ((lt.getStartOffset() >= window.getBegin())
@@ -238,7 +241,7 @@ public class DictionaryLookupAnnotator e
 		return ltObjectList;
 	}
 
-	private String getOffsetKey(LookupHit lh)
+	private static String getOffsetKey(LookupHit lh)
 	{
 		StringBuffer sb = new StringBuffer();
 		sb.append(lh.getStartOffset());

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/FirstTokenPermLookupInitializerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/FirstTokenPermLookupInitializerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/FirstTokenPermLookupInitializerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/FirstTokenPermLookupInitializerImpl.java Sat Apr 26 22:04:49 2014
@@ -65,9 +65,7 @@ public class FirstTokenPermLookupInitial
    final private Set<String> iv_exclusionTagSet;
 
    public FirstTokenPermLookupInitializerImpl( final UimaContext uimaContext,
-                                               final Properties props ) throws ClassNotFoundException,
-                                                                               IllegalAccessException,
-                                                                               NoSuchFieldException {
+                                               final Properties props ) {
       // TODO property validation could be done here
       iv_props = props;
 
@@ -86,7 +84,7 @@ public class FirstTokenPermLookupInitial
       // optional exclusion POS tags
       final String tagStr = iv_props.getProperty( EXC_TAGS_PRP_KEY );
       if ( tagStr != null ) {
-         iv_exclusionTagSet = new HashSet<String>();
+         iv_exclusionTagSet = new HashSet<>();
          final String[] tagArr = tagStr.split( "," );
          for ( String tag : tagArr ) {
             iv_exclusionTagSet.add( tag.toLowerCase() );
@@ -126,7 +124,7 @@ public class FirstTokenPermLookupInitial
     */
    @Override
    public Iterator<LookupToken> getLookupTokenIterator( final JCas jcas ) throws AnnotatorInitializationException {
-      final List<LookupToken> ltList = new ArrayList<LookupToken>();
+      final List<LookupToken> ltList = new ArrayList<>();
 
       final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
       final AnnotationIndex<Annotation> annotationIndex = indexes.getAnnotationIndex( BaseToken.type );
@@ -194,14 +192,14 @@ public class FirstTokenPermLookupInitial
       if ( iv_annotTypeArr == null ) {
          return Collections.emptyMap();
       }
-      final List<LookupAnnotation> list = new ArrayList<LookupAnnotation>();
+      final List<LookupAnnotation> list = new ArrayList<>();
       // algorithm depends on a window for permutations
       final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
       for ( int annotationType : iv_annotTypeArr ) {
          final Iterator<Annotation> itr = indexes.getAnnotationIndex( annotationType ).iterator();
          list.addAll( constrainToWindow( windowBegin, windowEnd, itr ) );
       }
-      final Map<String, List<LookupAnnotation>> m = new HashMap<String, List<LookupAnnotation>>( 1 );
+      final Map<String, List<LookupAnnotation>> m = new HashMap<>( 1 );
       m.put( FirstTokenPermutationImpl.CTX_KEY_WINDOW_ANNOTATIONS, list );
       return m;
    }
@@ -212,9 +210,9 @@ public class FirstTokenPermLookupInitial
     * @param annotItr -
     * @return list of lookup annotations
     */
-   private List<LookupAnnotation> constrainToWindow( final int begin, final int end,
+   private static List<LookupAnnotation> constrainToWindow( final int begin, final int end,
                                                      final Iterator<Annotation> annotItr ) {
-      final List<LookupAnnotation> list = new ArrayList<LookupAnnotation>();
+      final List<LookupAnnotation> list = new ArrayList<>();
       while ( annotItr.hasNext() ) {
          final Annotation annot = annotItr.next();
          // only consider if it's within the window
@@ -231,7 +229,7 @@ public class FirstTokenPermLookupInitial
    @Override
    public List<LookupToken> getSortedLookupTokens( final JCas jcas,
                                                    final Annotation covering ) throws AnnotatorInitializationException {
-      final List<LookupToken> ltList = new ArrayList<LookupToken>();
+      final List<LookupToken> ltList = new ArrayList<>();
       final List<BaseToken> inputList = org.uimafit.util.JCasUtil.selectCovered( jcas, BaseToken.class, covering );
       for ( BaseToken bta : inputList ) {
          final boolean isNonLookup = bta instanceof NewlineToken

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupAnnotationToJCasAdapter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupAnnotationToJCasAdapter.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupAnnotationToJCasAdapter.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupAnnotationToJCasAdapter.java Sat Apr 26 22:04:49 2014
@@ -18,25 +18,24 @@
  */
 package org.apache.ctakes.dictionary.lookup.ae;
 
-import org.apache.ctakes.dictionary.lookup.vo.LookupAnnotation;
-import org.apache.ctakes.dictionary.lookup.vo.LookupToken;
-import org.apache.uima.jcas.tcas.Annotation;
-
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.ctakes.dictionary.lookup.vo.LookupToken;
+import org.apache.uima.jcas.tcas.Annotation;
+
 
 /**
  * @author Mayo Clinic
  */
-public class LookupAnnotationToJCasAdapter implements LookupAnnotation, LookupToken {
+public class LookupAnnotationToJCasAdapter implements LookupToken {
 
    final private Map<String, String> _attributeMap;
    final private Annotation _jcasAnnotation;
 
    public LookupAnnotationToJCasAdapter( final Annotation jcasAnnotation ) {
       _jcasAnnotation = jcasAnnotation;
-      _attributeMap = new HashMap<String, String>();
+      _attributeMap = new HashMap<>();
    }
 
    /**

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilities.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilities.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilities.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilities.java Sat Apr 26 22:04:49 2014
@@ -60,33 +60,33 @@ import org.jdom.input.SAXBuilder;
 public class LookupParseUtilities
 {
 	//returns a set of LookupSpec objects
-	public static Set parseDescriptor(File descFile, UimaContext aContext, int maxListSize)
+	public static Set<LookupSpec> parseDescriptor(File descFile, UimaContext aContext, int maxListSize)
 			throws JDOMException, IOException, Exception
 	{
 		SAXBuilder saxBuilder = new SAXBuilder();
 		Document doc = saxBuilder.build(descFile);
 		maxSizeList = maxListSize;	//ohnlp-Bugs-3296301 fixes limit the search results to fixed 100 records.
-		Map dictMap = parseDictionaries(aContext, doc.getRootElement().getChild(
+		Map<String, DictionaryEngine> dictMap = parseDictionaries(aContext, doc.getRootElement().getChild(
 				"dictionaries"));
 		//ohnlp-Bugs-3296301
 		return parseLookupBindingXml(aContext, dictMap, doc.getRootElement().getChild("lookupBindings"));
 	}
 
-	public static Set parseDescriptor(File descFile, UimaContext aContext)
+	public static Set<LookupSpec> parseDescriptor(File descFile, UimaContext aContext)
 	throws JDOMException, IOException, Exception
 	{
 		SAXBuilder saxBuilder = new SAXBuilder();
 		Document doc = saxBuilder.build(descFile);
-		Map dictMap = parseDictionaries(aContext, doc.getRootElement().getChild(
+		Map<String, DictionaryEngine> dictMap = parseDictionaries(aContext, doc.getRootElement().getChild(
 		"dictionaries"));
 		//ohnlp-Bugs-3296301
 		return parseLookupBindingXml(aContext, dictMap, doc.getRootElement().getChild("lookupBindings"));
 	}
-	private static Map parseDictionaries(UimaContext aContext,
+	private static Map<String, DictionaryEngine> parseDictionaries(UimaContext aContext,
 			Element dictetteersEl) throws AnnotatorContextException, Exception
 	{
-		Map m = new HashMap();
-		Iterator dictItr = dictetteersEl.getChildren().iterator();
+		Map<String, DictionaryEngine> m = new HashMap<>();
+		Iterator<?> dictItr = dictetteersEl.getChildren().iterator();
 		while (dictItr.hasNext())
 		{
 			Element dictEl = (Element) dictItr.next();
@@ -162,19 +162,21 @@ public class LookupParseUtilities
             }
             
             File csvFile = ((FileResource) extResrc).getFile();
-            StringTable strTable = StringTableFactory.build(
-                    new FileReader(csvFile),
-                    fieldDelimiter,
-                    idxFieldNameArr,
-                    true);
-            dict = new StringTableDictionaryImpl(strTable, lookupFieldName);
+            try(FileReader fr = new FileReader(csvFile)){
+              StringTable strTable = StringTableFactory.build(
+                  fr,
+                  fieldDelimiter,
+                  idxFieldNameArr,
+                  true);
+              dict = new StringTableDictionaryImpl(strTable, lookupFieldName);
+            }
         }
 		else
 		{
 			throw new Exception("Unsupported impl type:" + implType);
 		}
 
-		Iterator metaFieldItr = rootDictEl.getChild("metaFields")
+		Iterator<?> metaFieldItr = rootDictEl.getChild("metaFields")
 				.getChildren()
 				.iterator();
 		while (metaFieldItr.hasNext())
@@ -200,13 +202,13 @@ public class LookupParseUtilities
 	 * Word(s) not to look up
 	 * TODO Consider adding common words as possible performance improvement
 	 */
-	private static void addExcludeList(DictionaryEngine ge, Iterator itr) {
+	private static void addExcludeList(DictionaryEngine ge, Iterator<?> itr) {
 
-		HashSet hs = new HashSet();
+		HashSet<String> hs = new HashSet<>();
 	    
 		while(itr.hasNext()) {
 			Element item = (Element) itr.next();
-			String s = (String)item.getAttributeValue("value");
+			String s = item.getAttributeValue("value");
 			System.out.println("Adding exclude value["+s+"]"); // TODO - use logger      
 			hs.add(s);
 	    }
@@ -216,33 +218,33 @@ public class LookupParseUtilities
 	}
 
 	
-	private static Set parseLookupBindingXml(UimaContext annotCtx,
-			Map dictMap, Element lookupBindingsEl) throws Exception {
+	private static Set<LookupSpec> parseLookupBindingXml(UimaContext annotCtx,
+			Map<String, DictionaryEngine> dictMap, Element lookupBindingsEl) throws Exception {
 
-		Set lsSet = new HashSet();
-		Iterator itr = lookupBindingsEl.getChildren().iterator();
+		Set<LookupSpec> lsSet = new HashSet<>();
+		Iterator<?> itr = lookupBindingsEl.getChildren().iterator();
 		while (itr.hasNext())
 		{
 			Element bindingEl = (Element) itr.next();
 
 			Element dictEl = bindingEl.getChild("dictionaryRef");
 			String dictID = dictEl.getAttributeValue("idRef");
-			DictionaryEngine dictEngine = (DictionaryEngine) dictMap.get(dictID);
+			DictionaryEngine dictEngine = dictMap.get(dictID);
 			if (dictEngine == null)
 			{
 				throw new Exception("Dictionary undefined: " + dictID);
 			}
 
-			Class[] constrArgs = { UimaContext.class, Properties.class };
-			Class[] constrArgsConsum = { UimaContext.class, Properties.class, int.class };//ohnlp-Bugs-3296301
-			Class[] constrArgsConsumB = { UimaContext.class, Properties.class };
+			Class<?>[] constrArgs = { UimaContext.class, Properties.class };
+			Class<?>[] constrArgsConsum = { UimaContext.class, Properties.class, int.class };//ohnlp-Bugs-3296301
+			Class<?>[] constrArgsConsumB = { UimaContext.class, Properties.class };
 
 			Element lookupInitEl = bindingEl.getChild("lookupInitializer");
 			String liClassName = lookupInitEl.getAttributeValue("className");
 			Element liPropertiesEl = lookupInitEl.getChild("properties");
 			Properties liProps = parsePropertiesXml(liPropertiesEl);
-			Class liClass = Class.forName(liClassName);
-			Constructor liConstr = liClass.getConstructor(constrArgs);
+			Class<?> liClass = Class.forName(liClassName);
+			Constructor<?> liConstr = liClass.getConstructor(constrArgs);
 			Object[] liArgs = { annotCtx, liProps };
 			LookupInitializer li = (LookupInitializer) liConstr.newInstance(liArgs);
 
@@ -250,9 +252,9 @@ public class LookupParseUtilities
 			String lcClassName = lookupConsumerEl.getAttributeValue("className");
 			Element lcPropertiesEl = lookupConsumerEl.getChild("properties");
 			Properties lcProps = parsePropertiesXml(lcPropertiesEl);
-			Class lcClass = Class.forName(lcClassName);
-			Constructor[] consts = lcClass.getConstructors();
-			Constructor lcConstr = null;
+			Class<?> lcClass = Class.forName(lcClassName);
+			Constructor<?>[] consts = lcClass.getConstructors();
+			Constructor<?> lcConstr = null;
 			Object[] lcArgs = null;
 			for(int i=0;i<consts.length;i++)
 			{
@@ -296,7 +298,7 @@ public class LookupParseUtilities
 	private static Properties parsePropertiesXml(Element propsEl)
 	{
 		Properties props = new Properties();
-		Iterator itr = propsEl.getChildren().iterator();
+		Iterator<?> itr = propsEl.getChildren().iterator();
 		while (itr.hasNext())
 		{
 			Element propEl = (Element) itr.next();

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilitiesRefactor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilitiesRefactor.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilitiesRefactor.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/LookupParseUtilitiesRefactor.java Sat Apr 26 22:04:49 2014
@@ -83,7 +83,7 @@ final public class LookupParseUtilitiesR
    private static Map<String,DictionaryEngine> parseDictionaries( final UimaContext aContext,
                                                                   final Element dictetteersEl )
          throws AnnotatorContextException, ResourceAccessException {
-      final Map<String,DictionaryEngine> m = new HashMap<String,DictionaryEngine>();
+      final Map<String,DictionaryEngine> m = new HashMap<>();
       final List<Element> dictatteerChildren = dictetteersEl.getChildren();
       for ( Element dictEl : dictatteerChildren ) {
          final String id = dictEl.getAttributeValue( "id" );
@@ -94,7 +94,7 @@ final public class LookupParseUtilitiesR
    }
 
    private static DictionaryEngine parseDictionaryXml( final UimaContext annotCtx, final Element rootDictEl )
-         throws AnnotatorContextException, ResourceAccessException {
+         throws ResourceAccessException {
       final String extResrcKey = rootDictEl.getAttributeValue( "externalResourceKey" );
       // UimaContext.getResourceObject(..) throws ResourceAccessException
       final Object extResrc = annotCtx.getResourceObject( extResrcKey );
@@ -182,7 +182,7 @@ final public class LookupParseUtilitiesR
     * TODO Consider adding common words as possible performance improvement
     */
    private static void addExcludeList( final DictionaryEngine dictionaryEngine, final List<Element> elementList ) {
-      final Set<String> excludeValues = new HashSet<String>( elementList.size() );
+      final Set<String> excludeValues = new HashSet<>( elementList.size() );
       for ( Element item : elementList ) {
          final String excludeValue = item.getAttributeValue( "value" );
          CLASS_LOGGER.info( "Adding exclude value[" + excludeValue + "]" );
@@ -197,11 +197,11 @@ final public class LookupParseUtilitiesR
                                                          final Map<String,DictionaryEngine> dictMap,
                                                          final Element lookupBindingsEl )
          throws AnnotatorContextException {
-      final Class[] constrArgs = {UimaContext.class, Properties.class};
-      final Class[] constrArgsConsum = {UimaContext.class, Properties.class, int.class};//ohnlp-Bugs-3296301
-      final Class[] constrArgsConsumB = {UimaContext.class, Properties.class};
+      final Class<?>[] constrArgs = {UimaContext.class, Properties.class};
+      final Class<?>[] constrArgsConsum = {UimaContext.class, Properties.class, int.class};//ohnlp-Bugs-3296301
+      final Class<?>[] constrArgsConsumB = {UimaContext.class, Properties.class};
 
-      final Set<LookupSpec> lsSet = new HashSet<LookupSpec>();
+      final Set<LookupSpec> lsSet = new HashSet<>();
       final List<Element> bindingChildren = lookupBindingsEl.getChildren();
       try {
          for ( Element bindingEl : bindingChildren ) {
@@ -216,8 +216,8 @@ final public class LookupParseUtilitiesR
             final String liClassName = lookupInitEl.getAttributeValue( "className" );
             final Element liPropertiesEl = lookupInitEl.getChild( "properties" );
             final Properties liProps = parsePropertiesXml( liPropertiesEl );
-            final Class liClass = Class.forName( liClassName );
-            final Constructor liConstr = liClass.getConstructor( constrArgs );
+            final Class<?> liClass = Class.forName( liClassName );
+            final Constructor<?> liConstr = liClass.getConstructor( constrArgs );
             final Object[] liArgs = {annotCtx, liProps};
             final LookupInitializer li = (LookupInitializer) liConstr.newInstance( liArgs );
 
@@ -225,11 +225,11 @@ final public class LookupParseUtilitiesR
             final String lcClassName = lookupConsumerEl.getAttributeValue( "className" );
             final Element lcPropertiesEl = lookupConsumerEl.getChild( "properties" );
             final Properties lcProps = parsePropertiesXml( lcPropertiesEl );
-            final Class lcClass = Class.forName( lcClassName );
-            final Constructor[] consts = lcClass.getConstructors();
-            Constructor lcConstr = null;
+            final Class<?> lcClass = Class.forName( lcClassName );
+            final Constructor<?>[] consts = lcClass.getConstructors();
+            Constructor<?> lcConstr = null;
             Object[] lcArgs = null;
-            for ( Constructor constConstr : consts ) {
+            for ( Constructor<?> constConstr : consts ) {
                lcConstr = constConstr;
                if ( Arrays.equals( constrArgsConsum, lcConstr.getParameterTypes() ) ) {
                   lcConstr = lcClass.getConstructor( constrArgsConsum );

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/NamedEntityLookupConsumerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/NamedEntityLookupConsumerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/NamedEntityLookupConsumerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/NamedEntityLookupConsumerImpl.java Sat Apr 26 22:04:49 2014
@@ -40,7 +40,7 @@ import java.util.*;
 /**
  * @author Mayo Clinic
  */
-public class NamedEntityLookupConsumerImpl extends BaseLookupConsumerImpl implements LookupConsumer {
+public class NamedEntityLookupConsumerImpl extends BaseLookupConsumerImpl {
 
    private static final String CODE_MF_PRP_KEY = "codeMetaField";
 
@@ -65,7 +65,7 @@ public class NamedEntityLookupConsumerIm
 
    private int countUniqueCodes( final Collection<LookupHit> hitsAtOffset ) {
       final String CODE_MF = _properties.getProperty( CODE_MF_PRP_KEY );
-      final Set<String> codes = new HashSet<String>();
+      final Set<String> codes = new HashSet<>();
       for ( LookupHit lookupHit : hitsAtOffset ) {
          final MetaDataHit mdh = lookupHit.getDictMetaDataHit();
          final String code = mdh.getMetaFieldValue( CODE_MF );
@@ -98,7 +98,7 @@ public class NamedEntityLookupConsumerIm
          // a corresponding JCas OntologyConcept object that will
          // be placed in a FSArray
          int ocArrIdx = 0;
-         final Set<String> codes = new HashSet<String>();
+         final Set<String> codes = new HashSet<>();
          for ( LookupHit lookupHit : entry.getValue() ) {
             final MetaDataHit mdh = lookupHit.getDictMetaDataHit();
             final String code = mdh.getMetaFieldValue( CODE_MF );

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/OrangeBookFilterConsumerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/OrangeBookFilterConsumerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/OrangeBookFilterConsumerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/OrangeBookFilterConsumerImpl.java Sat Apr 26 22:04:49 2014
@@ -43,7 +43,7 @@ import java.util.*;
  *
  * @author Mayo Clinic
  */
-public class OrangeBookFilterConsumerImpl extends BaseLookupConsumerImpl implements LookupConsumer {
+public class OrangeBookFilterConsumerImpl extends BaseLookupConsumerImpl {
    // LOG4J logger based on class name
    private final Logger iv_logger = Logger.getLogger( getClass().getName() );
 
@@ -92,7 +92,7 @@ public class OrangeBookFilterConsumerImp
          final String text = jcas.getDocumentText().substring( neBegin, neEnd ).trim().toLowerCase();
          final boolean isValid = isValid( "trade_name", text ) || isValid( "ingredient", text );
          if ( isValid ) {
-            final Set<String> validCodes = new HashSet<String>();
+            final Set<String> validCodes = new HashSet<>();
             for ( LookupHit lookupHit : entry.getValue() ) {
                final MetaDataHit mdh = lookupHit.getDictMetaDataHit();
                final String code = mdh.getMetaFieldValue( CODE_MF );

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java Sat Apr 26 22:04:49 2014
@@ -50,14 +50,15 @@ public class ThreadedDictionaryLookupAnn
    final private Logger _logger = Logger.getLogger(getClass().getName());
 
    // We need to start using types wrt generics
-   private Set _lookupSpecSet = new HashSet();
+   private Set<LookupSpec> _lookupSpecSet = new HashSet<>();
 
    // used to prevent duplicate hits
    // key = hit begin,end key (java.lang.String)
    // val = Set of MetaDataHit objects
-   private Map<LookupHitKey,Set<MetaDataHit>> _duplicateDataMap = new ConcurrentHashMap<LookupHitKey,Set<MetaDataHit>>();
+   private Map<LookupHitKey,Set<MetaDataHit>> _duplicateDataMap = new ConcurrentHashMap<>();
 
-   public void initialize( final UimaContext uimaContext ) throws ResourceInitializationException {
+   @Override
+  public void initialize( final UimaContext uimaContext ) throws ResourceInitializationException {
       super.initialize( uimaContext );
       configInit( uimaContext );
    }
@@ -66,7 +67,8 @@ public class ThreadedDictionaryLookupAnn
     * Close db connections in UmlsToSnomedDbConsumerImpl
     * @throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
     */
-   public void collectionProcessComplete() throws org.apache.uima.analysis_engine.AnalysisEngineProcessException {
+   @Override
+  public void collectionProcessComplete() throws org.apache.uima.analysis_engine.AnalysisEngineProcessException {
       for ( Object value : _lookupSpecSet ) {
          if ( value instanceof LookupSpec ) {
             final LookupSpec ls = (LookupSpec)value;
@@ -106,7 +108,8 @@ public class ThreadedDictionaryLookupAnn
    /**
     * Entry point for processing.
     */
-   public void process( final JCas jcas ) throws AnalysisEngineProcessException {
+   @Override
+  public void process( final JCas jcas ) throws AnalysisEngineProcessException {
       _logger.info( "process(JCas)" );
       _duplicateDataMap.clear();
       int specCount = 0;
@@ -119,7 +122,7 @@ public class ThreadedDictionaryLookupAnn
       final int threadCount = Math.min( specCount, procCount );
       final ExecutorService fixedThreadService = Executors.newFixedThreadPool( threadCount );
       final CompletionService<LookupDataStore> completionService
-            = new ExecutorCompletionService<LookupDataStore>( fixedThreadService );
+            = new ExecutorCompletionService<>( fixedThreadService );
       for ( Object value : _lookupSpecSet ) {
          if ( value instanceof LookupSpec ) {
             final LookupSpec ls = (LookupSpec)value;
@@ -154,7 +157,7 @@ public class ThreadedDictionaryLookupAnn
 
    private LookupDataStore getLookupData( final JCas jcas, final LookupSpec lookupSpec ) {
       final LookupInitializer lookupInitializer = lookupSpec.getLookupInitializer();
-      Iterator windowItr;
+      Iterator<Annotation> windowItr;
       try {
          windowItr = lookupInitializer.getLookupWindowIterator( jcas );
       } catch ( AnnotatorInitializationException aiE ) {
@@ -163,7 +166,7 @@ public class ThreadedDictionaryLookupAnn
       final LookupAlgorithm algorithm = lookupSpec.getLookupAlgorithm();
       final List<LookupHit> allHits = new ArrayList<LookupHit>();
       while (windowItr.hasNext()) {
-         final Annotation window = (Annotation) windowItr.next();
+         final Annotation window = windowItr.next();
          try {
             // ** Poor Form ** //
             // lookupInitializer.getLookupTokenIterator(jcas) depends on window, can't remove from loop
@@ -211,7 +214,7 @@ public class ThreadedDictionaryLookupAnn
     * @return             -
     */
    private Collection<LookupHit> filterHitDups(final Collection<LookupHit> lookupHitCol) {
-      final List<LookupHit> uniqueHits = new ArrayList<LookupHit>();
+      final List<LookupHit> uniqueHits = new ArrayList<>();
       for ( LookupHit lookupHit : lookupHitCol ) {
          if ( !isDuplicate( lookupHit ) ) {
             uniqueHits.add( lookupHit );
@@ -234,9 +237,8 @@ public class ThreadedDictionaryLookupAnn
       if (mdhDuplicateSet != null && mdhDuplicateSet.contains( metaDataHit ) ) {
          // current LookupHit is a duplicate
          return true;
-      } else {
-         mdhDuplicateSet = new HashSet<MetaDataHit>();
       }
+      mdhDuplicateSet = new HashSet<>();
       // current LookupHit is new, add it to the duplicate set for future checks
       mdhDuplicateSet.add(metaDataHit);
       _duplicateDataMap.put( lookupHitKey, mdhDuplicateSet );
@@ -244,28 +246,6 @@ public class ThreadedDictionaryLookupAnn
    }
 
    /**
-    * Gets a list of LookupToken objects within the specified window annotation.
-    *
-    * @param window -
-    * @param lookupTokenItr -
-    * @return -
-    */
-   static private List<LookupToken> constrainToWindow( final Annotation window, final Iterator lookupTokenItr ) {
-      final List<LookupToken> ltObjectList = new ArrayList<LookupToken>();
-      final int begin = window.getBegin();
-      final int end = window.getEnd();
-      while (lookupTokenItr.hasNext()) {
-         final LookupToken lookupToken = (LookupToken) lookupTokenItr.next();
-         // only consider if it's within the window
-         if ( lookupToken.getStartOffset() >= begin && lookupToken.getEndOffset() <= end ) {
-            ltObjectList.add(lookupToken);
-         }
-      }
-      return ltObjectList;
-   }
-
-
-   /**
     * Storage for a LookupSpec and all of its unique LookupHits
     */
    static private class LookupDataStore {
@@ -290,9 +270,11 @@ public class ThreadedDictionaryLookupAnn
          __end = lookupHit.getEndOffset();
          __hashCode = 1000 * __end + __start;
       }
+      @Override
       public int hashCode() {
          return __hashCode;
       }
+      @Override
       public boolean equals( final Object object ) {
          return object instanceof LookupHitKey
                && __start == ((LookupHitKey)object).__start

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedUmlsDictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedUmlsDictionaryLookupAnnotator.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedUmlsDictionaryLookupAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedUmlsDictionaryLookupAnnotator.java Sat Apr 26 22:04:49 2014
@@ -46,7 +46,8 @@ public class ThreadedUmlsDictionaryLooku
    final private Logger _logger = Logger.getLogger( getClass().getName() );
 
 
-   public void initialize( final UimaContext aContext ) throws ResourceInitializationException {
+   @Override
+  public void initialize( final UimaContext aContext ) throws ResourceInitializationException {
       super.initialize( aContext );
       final String umlsAddress = EnvironmentVariable.getEnv( UMLSADDR_PARAM, aContext );
       final String umlsVendor = EnvironmentVariable.getEnv( UMLSVENDOR_PARAM, aContext );
@@ -78,22 +79,23 @@ public class ThreadedUmlsDictionaryLooku
          final URL url = new URL( umlsaddr );
          final URLConnection connection = url.openConnection();
          connection.setDoOutput( true );
-         final OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() );
-         writer.write( data );
-         writer.flush();
-         boolean result = false;
-         final BufferedReader reader = new BufferedReader( new InputStreamReader( connection.getInputStream() ) );
-         String line;
-         while ( (line = reader.readLine()) != null ) {
-            final String trimline = line.trim();
-            if ( trimline.isEmpty() ) {
+         try(final OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() );
+             final BufferedReader reader = new BufferedReader( new InputStreamReader( connection.getInputStream() ) )){
+         
+           writer.write( data );
+           writer.flush();
+           boolean result = false;
+
+           String line;
+           while ( (line = reader.readLine()) != null ) {
+             final String trimline = line.trim();
+             if ( trimline.isEmpty() ) {
                break;
-            }
-            result = trimline.equalsIgnoreCase( "<Result>true</Result>" );
+             }
+             result = trimline.equalsIgnoreCase( "<Result>true</Result>" );
+           }
+           return result;
          }
-         writer.close();
-         reader.close();
-         return result;
       } catch ( IOException ioE ) {
          LOGGER.error( ioE.getMessage() );
          return false;

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java Sat Apr 26 22:04:49 2014
@@ -24,8 +24,6 @@ import java.io.OutputStreamWriter;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.apache.ctakes.utils.env.EnvironmentVariable;
 import org.apache.log4j.Logger;
@@ -55,7 +53,8 @@ public class UmlsDictionaryLookupAnnotat
 	private String UMLSUser;
 	private String UMLSPW;
 
-	public void initialize(UimaContext aContext)
+	@Override
+  public void initialize(UimaContext aContext)
 			throws ResourceInitializationException
 	{
 		super.initialize(aContext);
@@ -90,21 +89,20 @@ public class UmlsDictionaryLookupAnnotat
 		URL url = new URL(umlsaddr);
 		URLConnection conn = url.openConnection();
 		conn.setDoOutput(true);
-		OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
-		wr.write(data);
-		wr.flush();
-		boolean result = false;
-		BufferedReader rd = new BufferedReader(new InputStreamReader(
-				conn.getInputStream()));
-		String line;
-		while ((line = rd.readLine()) != null) {
-			if(line!=null && line.trim().length()>0)
-			{
-			 result = line.trim().equalsIgnoreCase("<Result>true</Result>");
-			}
+		try(OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
+		    BufferedReader rd = new BufferedReader(new InputStreamReader(
+		        conn.getInputStream()))){
+		  wr.write(data);
+		  wr.flush();
+		  boolean result = false;
+		  String line;
+		  while ((line = rd.readLine()) != null) {
+		    if(line.trim().length()>0)
+		    {
+		      result = line.trim().equalsIgnoreCase("<Result>true</Result>");
+		    }
+		  }
+		  return result;
 		}
-		wr.close();
-		rd.close();
-		return result;
 	}
 }
\ No newline at end of file

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedConsumerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedConsumerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedConsumerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedConsumerImpl.java Sat Apr 26 22:04:49 2014
@@ -47,7 +47,7 @@ import java.util.*;
  *
  * @author Mayo Clinic
  */
-public abstract class UmlsToSnomedConsumerImpl extends BaseLookupConsumerImpl implements LookupConsumer {
+public abstract class UmlsToSnomedConsumerImpl extends BaseLookupConsumerImpl {
 
    static private final String CUI_MF_PRP_KEY = "cuiMetaField";
    static private final String TUI_MF_PRP_KEY = "tuiMetaField";
@@ -60,12 +60,12 @@ public abstract class UmlsToSnomedConsum
    static private final String DISORDER_TUIS_PRP_KEY = "disorderTuis";
    static private final String FINDING_TUIS_PRP_KEY = "findingTuis";
 
-   private Set<String> _medicationSet = new HashSet<String>();
-   private Set<String> _antSiteTuiSet = new HashSet<String>();
-   private Set<String> _procedureTuiSet = new HashSet<String>();
-   private Set<String> _disorderTuiSet = new HashSet<String>();
-   private Set<String> _findingTuiSet = new HashSet<String>();
-   private Set<String> _validTuiSet = new HashSet<String>();
+   private Set<String> _medicationSet = new HashSet<>();
+   private Set<String> _antSiteTuiSet = new HashSet<>();
+   private Set<String> _procedureTuiSet = new HashSet<>();
+   private Set<String> _disorderTuiSet = new HashSet<>();
+   private Set<String> _findingTuiSet = new HashSet<>();
+   private Set<String> _validTuiSet = new HashSet<>();
 
    protected Properties props;
 
@@ -113,9 +113,9 @@ public abstract class UmlsToSnomedConsum
             final int neBegin = entry.getKey().__start;
             final int neEnd = entry.getKey().__end;
             // Use key "cui,tui" to avoid duplicates at this offset
-            final Set<String> cuiTuiSet = new HashSet<String>();
+            final Set<String> cuiTuiSet = new HashSet<>();
             // key = type of named entity, val = set of UmlsConcept objects
-            final Map<Integer,Set<UmlsConcept>> conceptMap = new HashMap<Integer,Set<UmlsConcept>>();
+            final Map<Integer,Set<UmlsConcept>> conceptMap = new HashMap<>();
             // Iterate over the LookupHit objects and group Snomed codes by NE type
             // For each NE type for which there is a hit, get all the Snomed codes
             // that map to the given CUI.
@@ -139,7 +139,7 @@ public abstract class UmlsToSnomedConsum
                   if ( conceptMap.containsKey( neType ) ) {
                      conceptSet = conceptMap.get( neType );
                   } else {
-                     conceptSet = new HashSet<UmlsConcept>();
+                     conceptSet = new HashSet<>();
                      conceptMap.put( neType, conceptSet );
                   }
                   final Collection<UmlsConcept> conceptCol = createConceptCol( jcas, cui, tui, snomedCodeSet );
@@ -217,7 +217,7 @@ public abstract class UmlsToSnomedConsum
    private Collection<UmlsConcept> createConceptCol( final JCas jcas, final String cui, final String tui,
                                         final Collection<String> snomedCodesCol ) {
       final String codingSchemeKey = props.getProperty( CODING_SCHEME_PRP_KEY );
-      final List<UmlsConcept> conceptList = new ArrayList<UmlsConcept>();
+      final List<UmlsConcept> conceptList = new ArrayList<>();
       for ( String snomedCode : snomedCodesCol ) {
          final UmlsConcept uc = new UmlsConcept( jcas );
          uc.setCode( snomedCode );
@@ -229,7 +229,7 @@ public abstract class UmlsToSnomedConsum
       return conceptList;
    }
 
-   private String getUniqueKey( final String cui, final String tui ) {
+   private static String getUniqueKey( final String cui, final String tui ) {
       final StringBuilder sb = new StringBuilder();
       sb.append( cui );
       sb.append( ':' );
@@ -243,12 +243,12 @@ public abstract class UmlsToSnomedConsum
     * @param delimitedString -
     * @return -
     */
-   private Set<String> loadList( final String delimitedString ) {
+   private static Set<String> loadList( final String delimitedString ) {
       if ( delimitedString == null || delimitedString.isEmpty() ) {
          return Collections.emptySet();
       }
       final String[] stringArray = delimitedString.split( "," );
-      final Set<String> stringSet = new HashSet<String>();
+      final Set<String> stringSet = new HashSet<>();
       for ( String text : stringArray ) {
          final String trimText = text.trim();
          if ( !trimText.isEmpty() ) {

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java Sat Apr 26 22:04:49 2014
@@ -37,7 +37,7 @@ import java.util.Set;
  *
  * @author Mayo Clinic
  */
-public class UmlsToSnomedDbConsumerImpl extends UmlsToSnomedConsumerImpl implements LookupConsumer {
+public class UmlsToSnomedDbConsumerImpl extends UmlsToSnomedConsumerImpl {
 
    static private final String DB_CONN_RESRC_KEY_PRP_KEY = "dbConnExtResrcKey";
    static private final String MAP_PREP_STMT_PRP_KEY = "mapPrepStmt";
@@ -83,14 +83,14 @@ public class UmlsToSnomedDbConsumerImpl 
     */
    @Override
    protected Set<String> getSnomedCodes( final String umlsCode ) throws SQLException {
-      final Set<String> codeSet = new HashSet<String>();
+      final Set<String> codeSet = new HashSet<>();
       _preparedStatement.setString( 1, umlsCode );
-      final ResultSet rs = _preparedStatement.executeQuery();
-      while ( rs.next() ) {
-         final String snomedCode = rs.getString( 1 ).trim();
-         codeSet.add( snomedCode );
+      try(final ResultSet rs = _preparedStatement.executeQuery()){
+        while ( rs.next() ) {
+          final String snomedCode = rs.getString( 1 ).trim();
+          codeSet.add( snomedCode );
+        }
       }
-      rs.close();
       return codeSet;
    }
 

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedLuceneConsumerImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedLuceneConsumerImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedLuceneConsumerImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedLuceneConsumerImpl.java Sat Apr 26 22:04:49 2014
@@ -45,8 +45,7 @@ import java.util.Set;
  *
  * @author Mayo Clinic
  */
-public class UmlsToSnomedLuceneConsumerImpl extends UmlsToSnomedConsumerImpl implements
-                                                                             LookupConsumer {
+public class UmlsToSnomedLuceneConsumerImpl extends UmlsToSnomedConsumerImpl {
 
    // LOG4J logger based on class name
    private Logger logger = Logger.getLogger( getClass().getName() );
@@ -117,8 +116,9 @@ public class UmlsToSnomedLuceneConsumerI
     * @return Set of Snomed codes that map to the given UMLS code (CUI).
     * @see getSnomedCodes in <code>UmlsToSnomedConsumerImpl</code> for example of using a database
     */
-   protected Set<String> getSnomedCodes( final String umlsCode ) throws DictionaryException {
-      final Set<String> codeSet = new HashSet<String>();
+   @Override
+  protected Set<String> getSnomedCodes( final String umlsCode ) throws DictionaryException {
+      final Set<String> codeSet = new HashSet<>();
       final String valueFieldName = props.getProperty( SNOMED_MAPPING_PRP_KEY );
       // Get the entries with field lookupFieldName having value umlsCode
       final Collection<MetaDataHit> mdhCollection = snomedLikeCodesIndex.getEntries( umlsCode );

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/DirectPassThroughImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/DirectPassThroughImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/DirectPassThroughImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/DirectPassThroughImpl.java Sat Apr 26 22:04:49 2014
@@ -61,12 +61,12 @@ public class DirectPassThroughImpl imple
     public Collection<LookupHit> lookup(final List<LookupToken> lookupTokenList,
                                         final Map<String,List<LookupAnnotation>> contextMap) throws Exception
     {
-        List<LookupHit> lhList = new ArrayList<LookupHit>();
+        List<LookupHit> lhList = new ArrayList<>();
         for (int tokenIdx = 0; tokenIdx < lookupTokenList.size(); tokenIdx++)
         {
             LookupToken lt = lookupTokenList.get(tokenIdx);
 
-            List<LookupToken> singleLtList = new ArrayList<LookupToken>();
+            List<LookupToken> singleLtList = new ArrayList<>();
             singleLtList.add(lt);
 
             String[] strArr = iv_phrBuilder.getPhrases(singleLtList);
@@ -89,7 +89,7 @@ public class DirectPassThroughImpl imple
 
     private Collection<MetaDataHit> getHits(String[] phrases) throws Exception
     {
-        Collection<MetaDataHit> mdhCol = new ArrayList<MetaDataHit>();
+        Collection<MetaDataHit> mdhCol = new ArrayList<>();
         for (int i = 0; i < phrases.length; i++)
         {
             Collection<MetaDataHit> curMdhCol = iv_dictEngine.metaLookup(phrases[i]);

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/FirstTokenPermutationImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/FirstTokenPermutationImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/FirstTokenPermutationImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/FirstTokenPermutationImpl.java Sat Apr 26 22:04:49 2014
@@ -88,7 +88,7 @@ public class FirstTokenPermutationImpl i
       iv_textMetaFieldNames = textMetaFieldNames;
 
       iv_maxPermutationLevel = maxPermutationLevel;
-      iv_permCacheMap = new HashMap<Integer, List<List<Integer>>>( maxPermutationLevel );
+      iv_permCacheMap = new HashMap<>( maxPermutationLevel );
       for ( int i = 0; i <= maxPermutationLevel; i++ ) {
          final List<List<Integer>> permList = PermutationUtil.getPermutationList( i );
          iv_permCacheMap.put( i, permList );
@@ -115,7 +115,7 @@ public class FirstTokenPermutationImpl i
       // map of all the token end indices as keys and the tokens with those indices as values
       final Map<Integer, List<LookupToken>> ltEndOffsetMap = getMultipleEndOffsetMap( lookupTokenList );
 
-      final List<LookupHit> lookupHits = new ArrayList<LookupHit>();
+      final List<LookupHit> lookupHits = new ArrayList<>();
       for ( int currentIndex = 0; currentIndex < lookupTokenList.size(); currentIndex++ ) {
          final LookupToken lookupToken = lookupTokenList.get( currentIndex );
          final String useForLookupString = lookupToken.getStringAttribute( LT_KEY_USE_FOR_LOOKUP );
@@ -162,7 +162,7 @@ public class FirstTokenPermutationImpl i
    }
 
    private Map<String,Set<MetaDataHit>> getNamedMetaDataHits( final Collection<MetaDataHit> firstTokenHits ) {
-      final Map<String,Set<MetaDataHit>> namedMetaDataHits = new HashMap<String,Set<MetaDataHit>>();
+      final Map<String,Set<MetaDataHit>> namedMetaDataHits = new HashMap<>();
       for ( MetaDataHit firstTokenHit : firstTokenHits ) {
          for ( String name : iv_textMetaFieldNames ) {
             String text = firstTokenHit.getMetaFieldValue( name );
@@ -170,7 +170,7 @@ public class FirstTokenPermutationImpl i
                text = text.toLowerCase();
                Set<MetaDataHit> mdhSet = namedMetaDataHits.get( text );
                if ( mdhSet == null ) {
-                  mdhSet = new HashSet<MetaDataHit>();
+                  mdhSet = new HashSet<>();
                }
                mdhSet.add( firstTokenHit );
                namedMetaDataHits.put( text, mdhSet );
@@ -193,7 +193,7 @@ public class FirstTokenPermutationImpl i
       }
       final Map<String,Set<MetaDataHit>> namedMetaDataHits = getNamedMetaDataHits( firstTokenHits );
 
-      final List<LookupHit> lookupHits = new ArrayList<LookupHit>();
+      final List<LookupHit> lookupHits = new ArrayList<>();
       final LookupToken firstWordLookupToken = wLookupTokenList.get( firstTokenIndex );
       final int firstWordStartOffset = firstWordLookupToken.getStartOffset();
       final int firstWordEndOffset = firstWordLookupToken.getEndOffset();
@@ -232,7 +232,7 @@ public class FirstTokenPermutationImpl i
             }
          }
          // convert permutation idx back into LookupTokens
-         final List<LookupToken> tempLookupTokens = new ArrayList<LookupToken>();
+         final List<LookupToken> tempLookupTokens = new ArrayList<>();
          for ( Integer idx : permutations ) {
             if ( idx <= firstTokenIndex ) {
                idx--;
@@ -322,7 +322,7 @@ public class FirstTokenPermutationImpl i
     * @param traverseRight -
     * @return list of lookup tokens in window, never null
     */
-   private List<LookupToken> getLookupTokenList( final int offset,
+   private static List<LookupToken> getLookupTokenList( final int offset,
                                                  final Map<Integer, List<LookupToken>> ltOffsetMap,
                                                  final boolean traverseRight ) {
       // first attempt the original offset, which will be the case most of the time
@@ -364,8 +364,8 @@ public class FirstTokenPermutationImpl i
                                                         final Map<LookupToken, Integer> ltListIndexMap,
                                                         final Map<Integer, List<LookupAnnotation>> wStartOffsetMap,
                                                         final Map<Integer, List<LookupAnnotation>> wEndOffsetMap ) {
-      final Set<LookupAnnotation> startCandidateSet = new HashSet<LookupAnnotation>();
-      final Set<LookupAnnotation> endCandidateSet = new HashSet<LookupAnnotation>();
+      final Set<LookupAnnotation> startCandidateSet = new HashSet<>();
+      final Set<LookupAnnotation> endCandidateSet = new HashSet<>();
 
       for ( Map.Entry<Integer, List<LookupAnnotation>> entry : wStartOffsetMap.entrySet() ) {
          final Integer startOffset = entry.getKey();
@@ -436,7 +436,7 @@ public class FirstTokenPermutationImpl i
     * @return -
     */
    static private Map<LookupToken, Integer> getListIndexMap( final List<LookupToken> list ) {
-      final Map<LookupToken, Integer> m = new HashMap<LookupToken, Integer>( list.size() );
+      final Map<LookupToken, Integer> m = new HashMap<>( list.size() );
       for ( int i = 0; i < list.size(); i++ ) {
          m.put( list.get( i ), i );
       }
@@ -465,12 +465,12 @@ public class FirstTokenPermutationImpl i
     * @return map of integers and lookup annotation lists
     */
    static private <T extends LookupAnnotation> Map<Integer, List<T>> getMultipleStartOffsetMap( final List<T> lookupAnnotList ) {
-      final Map<Integer, List<T>> m = new HashMap<Integer, List<T>>();
+      final Map<Integer, List<T>> m = new HashMap<>();
       for ( T lookupAnnotation : lookupAnnotList ) {
          final Integer key = lookupAnnotation.getStartOffset();
          List<T> list = m.get( key );
          if ( list == null ) {
-            list = new ArrayList<T>();
+            list = new ArrayList<>();
          }
          list.add( lookupAnnotation );
          m.put( key, list );
@@ -485,7 +485,7 @@ public class FirstTokenPermutationImpl i
     * @return map of integers and lookup annotations
     */
    static private <T extends LookupAnnotation> Map<Integer, T> getSingleEndOffsetMap( final List<T> lookupAnnotList ) {
-      final Map<Integer, T> m = new HashMap<Integer, T>();
+      final Map<Integer, T> m = new HashMap<>();
       for ( T lookupAnnotation : lookupAnnotList ) {
          final Integer key = lookupAnnotation.getEndOffset();
          m.put( key, lookupAnnotation );
@@ -500,12 +500,12 @@ public class FirstTokenPermutationImpl i
     * @return map of integers and lookup annotation lists
     */
    static private <T extends LookupAnnotation> Map<Integer, List<T>> getMultipleEndOffsetMap( final List<T> lookupAnnotList ) {
-      final Map<Integer, List<T>> m = new HashMap<Integer, List<T>>();
+      final Map<Integer, List<T>> m = new HashMap<>();
       for ( T lookupAnnotation : lookupAnnotList ) {
          final Integer key = lookupAnnotation.getEndOffset();
          List<T> list = m.get( key );
          if ( list == null ) {
-            list = new ArrayList<T>();
+            list = new ArrayList<>();
          }
          list.add( lookupAnnotation );
          m.put( key, list );
@@ -524,7 +524,7 @@ public class FirstTokenPermutationImpl i
    private Collection<MetaDataHit> getFirstTokenHits( final LookupToken firstLookupToken ) throws Exception {
       final List<LookupToken> singleTokenList = Arrays.asList( firstLookupToken );
       final String[] phrases = iv_phrBuilder.getPhrases( singleTokenList );
-      final List<MetaDataHit> metaDataHits = new ArrayList<MetaDataHit>();
+      final List<MetaDataHit> metaDataHits = new ArrayList<>();
       for ( String phrase : phrases ) {
          final Collection<MetaDataHit> phraseMetaDataHits = iv_firstTokenDictEngine.metaLookup( phrase );
          if ( !phraseMetaDataHits.isEmpty() ) {

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/PermutationUtil.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/PermutationUtil.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/PermutationUtil.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/algorithms/PermutationUtil.java Sat Apr 26 22:04:49 2014
@@ -30,15 +30,15 @@ public class PermutationUtil {
     * @param maxLevel -
     */
    public static List<List<Integer>> getPermutationList( final int maxLevel ) {
-      final List<List<Integer>> permList = new ArrayList<List<Integer>>();
+      final List<List<Integer>> permList = new ArrayList<>();
       for ( int levelIdx = maxLevel; levelIdx >= 0; levelIdx-- ) {
          // contains ALL index values
-         final List<Integer> baseNumList = new ArrayList<Integer>();
+         final List<Integer> baseNumList = new ArrayList<>();
          for ( int j = 1; j <= levelIdx; j++ ) {
             baseNumList.add( j );
          }
 
-         final Collection<List<Integer>> numListCol = new ArrayList<List<Integer>>();
+         final Collection<List<Integer>> numListCol = new ArrayList<>();
          if ( levelIdx != maxLevel ) {
             numListCol.addAll( getNumLists( maxLevel, baseNumList ) );
          } else {
@@ -60,7 +60,7 @@ public class PermutationUtil {
    }
 
    private static Collection<List<Integer>> getNumLists( final int maxLevel, final List<Integer> baseNumList ) {
-      final Collection<List<Integer>> numListCol = new ArrayList<List<Integer>>();
+      final Collection<List<Integer>> numListCol = new ArrayList<>();
       buildPermutations( maxLevel, baseNumList, numListCol, new ArrayList<Integer>(), 0 );
       filterNonIncreasingLists( numListCol );
       return numListCol;
@@ -73,7 +73,7 @@ public class PermutationUtil {
     * @param numListCol -
     */
    private static void filterNonIncreasingLists( final Collection<List<Integer>> numListCol ) {
-      final Set<List<Integer>> removalSet = new HashSet<List<Integer>>();
+      final Set<List<Integer>> removalSet = new HashSet<>();
       for ( List<Integer> numList : numListCol ) {
          Integer largestNum = null;
          for ( Integer num : numList ) {
@@ -109,13 +109,13 @@ public class PermutationUtil {
       if ( residualCount > baseNumList.size() ) {
          return;
       } else if ( residualCount == baseNumList.size() ) {
-         numListCol.add( new ArrayList<Integer>( residualList ) );
+         numListCol.add( new ArrayList<>( residualList ) );
          return;
       } else {
          final int num = baseNumList.get( residualCount );
          residualCount++;
          for ( int i = num; i <= maxLevel; i++ ) {
-            List<Integer> tempList = new ArrayList<Integer>( residualList );
+            List<Integer> tempList = new ArrayList<>( residualList );
             if ( !tempList.contains( i ) ) {
                tempList.add( i );
                buildPermutations( maxLevel, baseNumList, numListCol, tempList, residualCount );
@@ -132,7 +132,7 @@ public class PermutationUtil {
     * @return      -
     */
    public static Collection<List<Integer>> getLinearPermutations( final List<Integer> numList ) {
-      final Collection<List<Integer>> permutations = new ArrayList<List<Integer>>();
+      final Collection<List<Integer>> permutations = new ArrayList<>();
       getLinearPermutations( permutations, new ArrayList<Integer>(), numList );
       return permutations;
    }
@@ -147,7 +147,7 @@ public class PermutationUtil {
    private static void getLinearPermutations( final Collection<List<Integer>> permutations,
                                               final List<Integer> plusList, final List<Integer> numList ) {
       for ( Integer num : numList ) {
-         final List<Integer> subList = new ArrayList<Integer>( numList );
+         final List<Integer> subList = new ArrayList<>( numList );
 //         subList.addAll( numList );
          subList.remove( num );
 
@@ -156,7 +156,7 @@ public class PermutationUtil {
          if ( !subList.isEmpty() ) {
             getLinearPermutations( permutations, plusList, subList );
          } else {
-            final List<Integer> permutation = new ArrayList<Integer>( plusList );
+            final List<Integer> permutation = new ArrayList<>( plusList );
 //            for ( Integer n : plusList ) {
 //               permutation.add( n );
 //            }

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/MetaDataPostLookupFilterImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/MetaDataPostLookupFilterImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/MetaDataPostLookupFilterImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/MetaDataPostLookupFilterImpl.java Sat Apr 26 22:04:49 2014
@@ -53,10 +53,7 @@ public class MetaDataPostLookupFilterImp
             {
                 return isContained;
             }
-            else
-            {
-                return !isContained;
-            }
+            return !isContained;
         }
         catch (DictionaryException ge)
         {

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/PostLookupFilterGroupImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/PostLookupFilterGroupImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/PostLookupFilterGroupImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/PostLookupFilterGroupImpl.java Sat Apr 26 22:04:49 2014
@@ -79,9 +79,6 @@ public class PostLookupFilterGroupImpl i
         {
             return isContained;
         }
-        else
-        {
-            return !isContained;
-        }    
+        return !isContained;    
     }
 }
\ No newline at end of file

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/SetValuePostLookupFilterImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/SetValuePostLookupFilterImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/SetValuePostLookupFilterImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/SetValuePostLookupFilterImpl.java Sat Apr 26 22:04:49 2014
@@ -75,10 +75,7 @@ public class SetValuePostLookupFilterImp
         {
             return isContained;
         }
-        else
-        {
-            return !isContained;
-        }
+        return !isContained;
     }
 
     /**

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/TruncateCollectionFilterImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/TruncateCollectionFilterImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/TruncateCollectionFilterImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/filter/TruncateCollectionFilterImpl.java Sat Apr 26 22:04:49 2014
@@ -35,7 +35,7 @@ import java.util.List;
 public class TruncateCollectionFilterImpl implements CollectionFilter
 {
     private int iv_mdhCount;
-    private Comparator iv_mdhComparator;
+    private Comparator<MetaDataHit> iv_mdhComparator;
 
     /**
      * Constructor
@@ -45,7 +45,7 @@ public class TruncateCollectionFilterImp
      * @param mdhCount
      *            Number of objects (N) to retain.
      */
-    public TruncateCollectionFilterImpl(Comparator mdhComparator, int mdhCount)
+    public TruncateCollectionFilterImpl(Comparator<MetaDataHit> mdhComparator, int mdhCount)
     {
         iv_mdhComparator = mdhComparator;
         iv_mdhCount = mdhCount;
@@ -61,7 +61,7 @@ public class TruncateCollectionFilterImp
             return metaDataHitCol;
         }
         
-        final List<MetaDataHit> mdhList = new ArrayList<MetaDataHit>(metaDataHitCol);
+        final List<MetaDataHit> mdhList = new ArrayList<>(metaDataHitCol);
 
         // sort the hits
         Collections.sort(mdhList, iv_mdhComparator);

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/jdbc/JdbcDictionaryImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/jdbc/JdbcDictionaryImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/jdbc/JdbcDictionaryImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/jdbc/JdbcDictionaryImpl.java Sat Apr 26 22:04:49 2014
@@ -18,20 +18,27 @@
  */
 package org.apache.ctakes.dictionary.lookup.jdbc;
 
-import org.apache.ctakes.dictionary.lookup.*;
-import org.apache.ctakes.dictionary.lookup.Dictionary;
-
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ctakes.dictionary.lookup.AbstractBaseDictionary;
+import org.apache.ctakes.dictionary.lookup.DictionaryException;
+import org.apache.ctakes.dictionary.lookup.GenericMetaDataHitImpl;
+import org.apache.ctakes.dictionary.lookup.MetaDataHit;
 
 
 /**
  * @author Mayo Clinic
  */
-public class JdbcDictionaryImpl extends AbstractBaseDictionary implements Dictionary {
+public class JdbcDictionaryImpl extends AbstractBaseDictionary {
    final private Connection iv_dbConn;
    final private String iv_tableName;
    final private String iv_lookupFieldName;
@@ -72,9 +79,9 @@ public class JdbcDictionaryImpl extends 
 
          // translate meta data field names into columns
          // to be returned in the result set
-         final Iterator metaFieldNameItr = getMetaFieldNames();
+         final Iterator<String> metaFieldNameItr = getMetaFieldNames();
          while ( metaFieldNameItr.hasNext() ) {
-            String mdFieldName = (String) metaFieldNameItr.next();
+            String mdFieldName = metaFieldNameItr.next();
             sb.append( mdFieldName );
             sb.append( ',' );
          }
@@ -118,16 +125,16 @@ public class JdbcDictionaryImpl extends 
     */
    @Override
    public Collection<MetaDataHit> getEntries( final String text ) throws DictionaryException {
-      final Set<MetaDataHit> metaDataHitSet = new HashSet<MetaDataHit>();
+      final Set<MetaDataHit> metaDataHitSet = new HashSet<>();
       try {
          final PreparedStatement prepStmt = initMetaDataPrepStmt( text );
          final ResultSet rs = prepStmt.executeQuery();
 
          while ( rs.next() ) {
-            final Map<String, String> nameValMap = new HashMap<String, String>();
-            final Iterator metaFieldNameItr = getMetaFieldNames();
+            final Map<String, String> nameValMap = new HashMap<>();
+            final Iterator<String> metaFieldNameItr = getMetaFieldNames();
             while ( metaFieldNameItr.hasNext() ) {
-               final String metaFieldName = (String) metaFieldNameItr.next();
+               final String metaFieldName = metaFieldNameItr.next();
                final String metaFieldValue = rs.getString( metaFieldName );
                nameValMap.put( metaFieldName, metaFieldValue );
             }

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDictionaryImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDictionaryImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDictionaryImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDictionaryImpl.java Sat Apr 26 22:04:49 2014
@@ -42,7 +42,7 @@ import java.util.Set;
 /**
  * @author Mayo Clinic
  */
-public class LuceneDictionaryImpl extends AbstractBaseDictionary implements Dictionary {
+public class LuceneDictionaryImpl extends AbstractBaseDictionary {
    final private IndexSearcher iv_searcher;
    final private String iv_lookupFieldName;
    //ohnlp-Bugs-3296301 limits the search results to fixed 100 records.
@@ -75,7 +75,7 @@ public class LuceneDictionaryImpl extend
     */
    @Override
    public Collection<MetaDataHit> getEntries( final String text ) throws DictionaryException {
-      final Set<MetaDataHit> metaDataHitSet = new HashSet<MetaDataHit>();
+      final Set<MetaDataHit> metaDataHitSet = new HashSet<>();
 
       try {
          Query q = null;

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDocumentMetaDataHitImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDocumentMetaDataHitImpl.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDocumentMetaDataHitImpl.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/lucene/LuceneDocumentMetaDataHitImpl.java Sat Apr 26 22:04:49 2014
@@ -18,21 +18,25 @@
  */
 package org.apache.ctakes.dictionary.lookup.lucene;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.concurrent.Immutable;
+
 import org.apache.ctakes.dictionary.lookup.AbstractBaseMetaDataHit;
-import org.apache.ctakes.dictionary.lookup.MetaDataHit;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexableField;
 
-import javax.annotation.concurrent.Immutable;
-import java.util.*;
-
 
 /**
  * @author Mayo Clinic
  */
 @Immutable
-public final class LuceneDocumentMetaDataHitImpl extends AbstractBaseMetaDataHit implements MetaDataHit {
+public final class LuceneDocumentMetaDataHitImpl extends AbstractBaseMetaDataHit {
    final private Document _luceneDoc;
    final private Set<String> _nameSet;
    final private Collection<String> _valueList;
@@ -40,8 +44,8 @@ public final class LuceneDocumentMetaDat
    public LuceneDocumentMetaDataHitImpl( final Document luceneDoc ) {
       _luceneDoc = luceneDoc;
       final List<IndexableField> fieldEnumList = _luceneDoc.getFields();
-      final Set<String> nameSet = new HashSet<String>( fieldEnumList.size() );
-      final List<String> valueList = new ArrayList<String>( fieldEnumList.size() );
+      final Set<String> nameSet = new HashSet<>( fieldEnumList.size() );
+      final List<String> valueList = new ArrayList<>( fieldEnumList.size() );
       for ( IndexableField field : fieldEnumList ) {
          nameSet.add( field.name() );
          valueList.add( field.stringValue() );

Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/PhraseBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/PhraseBuilder.java?rev=1590312&r1=1590311&r2=1590312&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/PhraseBuilder.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/phrasebuilder/PhraseBuilder.java Sat Apr 26 22:04:49 2014
@@ -20,6 +20,8 @@ package org.apache.ctakes.dictionary.loo
 
 import java.util.List;
 
+import org.apache.ctakes.dictionary.lookup.vo.LookupToken;
+
 /**
  * Interface for building phrases from LookupToken objects.
  * 
@@ -33,5 +35,5 @@ public interface PhraseBuilder
      * @param lookupTokenList List of LookupTokens.
      * @return One or more String phrases.
      */
-    public String[] getPhrases(List lookupTokenList);
+    public String[] getPhrases(List<LookupToken> lookupTokenList);
 }



Mime
View raw message