Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions prism/src/parser/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@

package parser;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;

import parser.type.Type;
import parser.type.TypeBool;
Expand All @@ -43,7 +40,7 @@
* Class to store a list of typed constant/variable values.
* (Basically, just a mapping from String to Object)
*/
public class Values //implements Comparable
public class Values implements Cloneable //implements Comparable
{
protected ArrayList<String> names;
protected ArrayList<Object> values;
Expand Down Expand Up @@ -405,26 +402,19 @@ public boolean equals(Object o)
// return 0;
// }

@SuppressWarnings("unchecked")
@Override
public Object clone()
public Values clone()
{
Values res;
int i, n;
String s;
Object o;

res = new Values();
n = getNumValues();
for (i = 0; i < n; i++) {
s = getName(i);
o = getValue(i);
if (o instanceof Integer) o = new Integer(((Integer)o).intValue());
else if (o instanceof Double) o = new Double(((Double)o).doubleValue());
else o = new Boolean(((Boolean)o).booleanValue());
res.addValue(s, o);
Values clone;
try {
clone = (Values) super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError("Object#clone is expected to work for Cloneable objects.", e);
}

return res;
clone.names = (ArrayList<String>) names.clone();
clone.values = (ArrayList<Object>) values.clone();
return clone;
}

@Override
Expand Down