01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.proof;
12:
13: import java.io.File;
14: import java.text.DateFormat;
15: import java.util.Date;
16:
17: public class JavaModel {
18:
19: private String modelDir;
20: private String modelTag;
21: private String descr;
22:
23: public static final JavaModel NO_MODEL = new JavaModel();
24:
25: private JavaModel() {
26: descr = "no model";
27: }
28:
29: public JavaModel(String modelDir, String modelTag) {
30: this .modelDir = (new File(modelDir)).getAbsolutePath();
31: this .modelTag = modelTag;
32: this .descr = "model "
33: + (new File(modelDir)).getName()
34: + "@"
35: + DateFormat.getTimeInstance(DateFormat.MEDIUM).format(
36: new Date());
37: }
38:
39: public String getModelDir() {
40: return modelDir;
41: }
42:
43: public String getModelTag() {
44: return modelTag;
45: }
46:
47: public boolean isEmpty() {
48: return (this == NO_MODEL);
49: }
50:
51: public String getCVSModule() {
52: String s;
53: if (modelDir.charAt(0) == '/') {
54: s = modelDir.substring(1); // chop off leading "/"
55: } else if ((modelDir.charAt(1) == ':')
56: && (modelDir.charAt(2) == '\\')) {
57: s = modelDir.charAt(0) + "__" + modelDir.substring(3);
58: } else
59: s = modelDir;
60: return s;
61: }
62:
63: public String description() {
64: return descr;
65: }
66:
67: public boolean equals(Object o) {
68: if (!(o instanceof JavaModel)) {
69: return false;
70: } else if (getModelTag() == null) {
71: return ((JavaModel) o).getModelTag() == null;
72: } else {
73: return (getModelTag().equals(((JavaModel) o).getModelTag()));
74: }
75: }
76:
77: public int hashCode() {
78: if (getModelTag() == null)
79: return 42;
80: return getModelTag().hashCode();
81: }
82:
83: }
|