1
2
3
4 package net.sourceforge.pmd.util.database;
5
6 import java.util.logging.Logger;
7
8
9
10
11
12
13 public class SourceObject {
14
15 private static final String CLASS_NAME = SourceObject.class.getName();
16 private static final Logger LOG = Logger.getLogger(CLASS_NAME);
17
18
19
20
21
22
23 String schema;
24
25
26
27
28
29
30 String name;
31
32
33
34
35
36
37 String type;
38
39
40
41
42
43
44 String revision;
45
46 SourceObject(String schema, String type, String name, String revision) {
47 this.schema = schema;
48 this.type = type;
49 this.name = name;
50 this.revision = revision;
51 }
52
53 @Override
54 public String toString()
55 {
56 return String.format("schema=\"%s\",type=\"%s\",name=\"%s\",revision=\"%s\""
57 , this.getSchema(), this.getType(), this.getName(), this.getRevision());
58 }
59
60
61
62
63 public String getSchema() {
64 return schema;
65 }
66
67
68
69
70 public void setSchema(String schema) {
71 this.schema = schema;
72 }
73
74
75
76
77 public String getName() {
78 return name;
79 }
80
81
82
83
84 public void setName(String name) {
85 this.name = name;
86 }
87
88
89
90
91 public String getType() {
92 return type;
93 }
94
95
96
97
98 public void setType(String type) {
99 this.type = type;
100 }
101
102
103
104
105 public String getRevision() {
106 return revision;
107 }
108
109
110
111
112 public void setRevision(String revision) {
113 this.revision = revision;
114 }
115
116
117
118
119
120
121 public String getSuffixFromType()
122 {
123 LOG.entering(CLASS_NAME, "getSuffixFromType", this);
124 if (null == type || type.isEmpty()) {
125 return "";
126 } else if (type.toUpperCase().indexOf("JAVA") >= 0) {
127 return ".java";
128 } else if (type.toUpperCase().indexOf("TRIGGER") >= 0) {
129 return ".trg";
130 } else if (type.toUpperCase().indexOf("FUNCTION") >= 0) {
131 return ".fnc";
132 } else if (type.toUpperCase().indexOf("PROCEDURE") >= 0) {
133 return ".prc";
134 } else if (type.toUpperCase().indexOf("PACKAGE_BODY") >= 0) {
135 return ".pkb";
136 } else if (type.toUpperCase().indexOf("PACKAGE") >= 0) {
137 return ".pks";
138 } else if (type.toUpperCase().indexOf("TYPE_BODY") >= 0) {
139 return ".tpb";
140 } else if (type.toUpperCase().indexOf("TYPE") >= 0) {
141 return ".tps";
142 } else {
143 return "";
144 }
145 }
146
147
148
149
150
151
152 public String getPseudoFileName() {
153 String falseFilePath = String.format("/Database/%s/%s/%s%s", getSchema(), getType(), getName(),
154 getSuffixFromType());
155 return falseFilePath;
156 }
157 }