Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced field declaration of Vector with List

Change-Id: I91e1b89c5c60abe97e3733265af8f6fd456cf97a
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
commit d796b4a4e7798cd3db55f2327f9b33c7a4942736 1 parent f97b493
John May authored August 02, 2012 egonw committed August 02, 2012
13  src/main/org/openscience/cdk/iupac/parser/AttachedGroup.java
@@ -24,8 +24,9 @@
24 24
 
25 25
 package org.openscience.cdk.iupac.parser;
26 26
 
  27
+import java.util.ArrayList;
27 28
 import java.util.Iterator;
28  
-import java.util.Vector;
  29
+import java.util.List;
29 30
 
30 31
 /**
31 32
  * Holds data on a specific functional group or substituent.
@@ -38,7 +39,7 @@
38 39
     /** The name of the group */
39 40
     private String name = "";
40 41
     /** The collection of locations the group is attached to */
41  
-    private Vector locations = new Vector();
  42
+    private List<Token> locations = new ArrayList<Token>();
42 43
     /** The length of the substituent chain */
43 44
     private int length = 0;
44 45
     
@@ -47,14 +48,14 @@ public AttachedGroup() {
47 48
     }
48 49
     
49 50
     /** Creates a new instance of AttachedGroup with a Sting denoting the functional group */
50  
-    public AttachedGroup (Vector locations, String name)
  51
+    public AttachedGroup (List<Token> locations, String name)
51 52
     {
52 53
         setLocations (locations);
53 54
         setName (name);
54 55
     }
55 56
     
56 57
     /** Creates a new instance of AttachedGroup with an int denoting the length of the substituent chain */
57  
-    public AttachedGroup (Vector locations, int length)
  58
+    public AttachedGroup (List<Token> locations, int length)
58 59
     {
59 60
         setLocations (locations);
60 61
         setLength (length);
@@ -80,7 +81,7 @@ public void setName(java.lang.String name) {
80 81
      * @return Value of property locations.
81 82
      *
82 83
      */
83  
-    public java.util.Vector getLocations() {
  84
+    public List<Token> getLocations() {
84 85
         return locations;
85 86
     }
86 87
     
@@ -88,7 +89,7 @@ public void setName(java.lang.String name) {
88 89
      * @param locations New value of property locations.
89 90
      *
90 91
      */
91  
-    public void setLocations(java.util.Vector locations) {
  92
+    public void setLocations(List<Token> locations) {
92 93
         this.locations = locations;
93 94
     }
94 95
     
20  src/main/org/openscience/cdk/iupac/parser/MoleculeBuilder.java
@@ -25,7 +25,7 @@
25 25
 package org.openscience.cdk.iupac.parser;
26 26
 
27 27
 import java.util.Iterator;
28  
-import java.util.Vector;
  28
+import java.util.List;
29 29
 
30 30
 import org.openscience.cdk.Atom;
31 31
 import org.openscience.cdk.AtomContainer;
@@ -65,7 +65,7 @@
65 65
     /**
66 66
      * Builds the main chain which may act as a foundation for futher working groups.
67 67
      *
68  
-     * @param mainChain The parsed prefix which depicts the chain's length.
  68
+ * @param mainChain The parsed prefix which depicts the chain's length.
69 69
      * @param isMainCyclic A flag to show if the molecule is a ring. 0 means not a ring, 1 means is a ring.
70 70
      * @return A Molecule containing the requested chain.
71 71
      */
@@ -102,12 +102,12 @@ private IAtomContainer buildChain(int length, boolean isMainCyclic)
102 102
      * @param attachedGroups A vector of AttachedGroup's representing functional groups.
103 103
      * @see #addFunGroup
104 104
      */
105  
-    private void buildFunGroups(Vector attachedGroups)
  105
+    private void buildFunGroups(List<AttachedGroup> attachedGroups)
106 106
     {
107  
-        Iterator groupsIterator = attachedGroups.iterator();
  107
+        Iterator<AttachedGroup> groupsIterator = attachedGroups.iterator();
108 108
         while (groupsIterator.hasNext())
109 109
         {
110  
-            AttachedGroup attachedGroup = (AttachedGroup) groupsIterator.next();
  110
+            AttachedGroup attachedGroup = groupsIterator.next();
111 111
             
112 112
             Iterator locationsIterator = attachedGroup.getLocations().iterator();
113 113
             while (locationsIterator.hasNext())
@@ -483,12 +483,12 @@ private void addAtom(String newAtomType, IAtom otherConnectingAtom, Order bondOr
483 483
      *
484 484
      * @param attachedSubstituents A vector of AttachedGroup's representing substituents.
485 485
      */
486  
-    private void addHeads(Vector attachedSubstituents)
  486
+    private void addHeads(List<AttachedGroup> attachedSubstituents)
487 487
     {
488  
-        Iterator substituentsIterator = attachedSubstituents.iterator();
  488
+        Iterator<AttachedGroup> substituentsIterator = attachedSubstituents.iterator();
489 489
         while (substituentsIterator.hasNext())
490 490
         {
491  
-            AttachedGroup attachedSubstituent = (AttachedGroup) substituentsIterator.next();
  491
+            AttachedGroup attachedSubstituent = substituentsIterator.next();
492 492
             
493 493
             Iterator locationsIterator = attachedSubstituent.getLocations().iterator();
494 494
             while (locationsIterator.hasNext())
@@ -528,8 +528,8 @@ private void addHeads(Vector attachedSubstituents)
528 528
      * @param isMainCyclic An indiacation of if the main chain is cyclic.
529 529
      * @return The molecule as built from the parsed tokens.
530 530
      */
531  
-    protected IAtomContainer buildMolecule(int mainChain, Vector attachedSubstituents
532  
-    , Vector attachedGroups, boolean isMainCyclic, String name) throws
  531
+    protected IAtomContainer buildMolecule(int mainChain, List<AttachedGroup> attachedSubstituents
  532
+    , List<AttachedGroup> attachedGroups, boolean isMainCyclic, String name) throws
533 533
     ParseException, CDKException
534 534
     {
535 535
         //Set up the molecle's name
22  src/main/org/openscience/cdk/iupac/parser/NomParser.jj
@@ -46,17 +46,17 @@ public class NomParser {
46 46
     private static boolean isMainCyclic;
47 47
 
48 48
     /** The tempory vector of locations the current group/substiuant is attached to */
49  
-    private static Vector tempLocation;
  49
+    private static List<Token> tempLocation;
50 50
 
51 51
     /** The vector of attached functional groups, with an instance of AttachedGroup for each
52 52
      * functional group.
53 53
      */
54  
-    private static Vector attachedGroups;
  54
+    private static List<AttachedGroup> attachedGroups;
55 55
 
56 56
     /** The vector of attached substituent, with an instance of AttachedGroup for each
57 57
      * substituent.
58 58
      */
59  
-    private static Vector attachedSubstituents;
  59
+    private static List<AttachedGroup> attachedSubstituents;
60 60
 
61 61
     /**
62 62
      * Used in the build up of ancient greek style prfixes
@@ -74,9 +74,9 @@ public class NomParser {
74 74
     public static IAtomContainer generate (String stringToParse) throws ParseException, CDKException
75 75
     {
76 76
         isMainCyclic = false;
77  
-        tempLocation = new Vector();
78  
-        attachedSubstituents = new Vector();
79  
-        attachedGroups = new Vector();
  77
+        tempLocation = new ArrayList<Token>();
  78
+        attachedSubstituents = new ArrayList<AttachedGroup>();
  79
+        attachedGroups = new ArrayList<AttachedGroup>();
80 80
         currentNumber = 0;
81 81
 
82 82
         StringReader stringReader = new StringReader (stringToParse.toLowerCase() + "\n");
@@ -103,17 +103,17 @@ public class NomParser {
103 103
      * @throws ParseException A taylored instance of ParseException so nomen can display
104 104
      * the error to the user.
105 105
      */
106  
-    private static void checkConnections (Iterator vectorIterator) throws ParseException
  106
+    private static void checkConnections (Iterator<AttachedGroup> vectorIterator) throws ParseException
107 107
     {
108 108
         while (vectorIterator.hasNext())
109 109
         {
110  
-            AttachedGroup ag = (AttachedGroup) vectorIterator.next();
111  
-            Vector locations = ag.getLocations();
  110
+            AttachedGroup ag = vectorIterator.next();
  111
+            List<Token> locations = ag.getLocations();
112 112
 
113  
-            Iterator locationsIterator = locations.iterator();
  113
+            Iterator<Token> locationsIterator = locations.iterator();
114 114
             while (locationsIterator.hasNext())
115 115
             {
116  
-                Token tok = (Token) locationsIterator.next();
  116
+                Token tok =  locationsIterator.next();
117 117
 
118 118
                 try
119 119
                 {
12  src/main/org/openscience/cdk/renderer/GraphRendererModel.java
@@ -26,6 +26,8 @@
26 26
 package org.openscience.cdk.renderer;
27 27
 
28 28
 import java.awt.Color;
  29
+import java.util.ArrayList;
  30
+import java.util.List;
29 31
 
30 32
 import org.openscience.cdk.math.IFunction;
31 33
 
@@ -48,8 +50,8 @@
48 50
   private String xtitle = "X title"; // Title of the x axis
49 51
   private String ytitle = "Y title"; // Title of the y axis
50 52
 
51  
-  private java.util.Vector functions = new java.util.Vector();
52  
-  private java.util.Vector colors = new java.util.Vector();
  53
+  private List<IFunction> functions = new ArrayList<IFunction>();
  54
+  private List<Color>     colors    = new ArrayList<Color>();
53 55
 
54 56
   /** Paints the function normal */
55 57
   public final static int NORMAL = 0;
@@ -207,7 +209,7 @@ public void addFunction(IFunction function, Color color)
207 209
       colors.add(color);
208 210
     }
209 211
     else
210  
-      colors.setElementAt(color, functions.indexOf(function));
  212
+      colors.set(functions.indexOf(function), color);
211 213
   }
212 214
 
213 215
   /**
@@ -223,7 +225,7 @@ public int getFunctionsSize()
223 225
    */
224 226
   public IFunction getFunction(int index)
225 227
   {
226  
-    return (IFunction) functions.elementAt(index);
  228
+    return functions.get(index);
227 229
   }
228 230
 
229 231
   /**
@@ -231,6 +233,6 @@ public IFunction getFunction(int index)
231 233
    */
232 234
   public Color getFunctionColor(int index)
233 235
   {
234  
-    return (Color) colors.elementAt(index);
  236
+    return colors.get(index);
235 237
   }
236 238
 }

0 notes on commit d796b4a

Please sign in to comment.
Something went wrong with that request. Please try again.