01: package net.sourceforge.squirrel_sql.plugins.hibernate.mapping;
02:
03: import net.sourceforge.squirrel_sql.fw.completion.CompletionInfo;
04: import net.sourceforge.squirrel_sql.fw.completion.util.CompletionParser;
05:
06: public class PropertyInfo extends CompletionInfo {
07: private HibernatePropertyInfo _hibernatePropertyInfo;
08: private MappedClassInfo _mappedClassInfo;
09: private String _mappedClassNameWithEndingDot;
10: private String _fullQualifiedName;
11: private String _simpleQualifiedName;
12: private String _simpleMappedClassNameWithEndingDot;
13:
14: public PropertyInfo(HibernatePropertyInfo hibernatePropertyInfo,
15: String mappedClassName) {
16: _hibernatePropertyInfo = hibernatePropertyInfo;
17: _fullQualifiedName = mappedClassName + "."
18: + hibernatePropertyInfo;
19: _simpleQualifiedName = MappingUtils
20: .getSimpleClassName(mappedClassName)
21: + "." + hibernatePropertyInfo;
22:
23: _mappedClassNameWithEndingDot = mappedClassName + ".";
24: _simpleMappedClassNameWithEndingDot = MappingUtils
25: .getSimpleClassName(mappedClassName)
26: + ".";
27:
28: }
29:
30: public String getCompareString() {
31: return _hibernatePropertyInfo.getPropertyName();
32: }
33:
34: public String toString() {
35: return _hibernatePropertyInfo.toString();
36: }
37:
38: public boolean matchesQualified(CompletionParser parser) {
39: String stringToParse = parser.getStringToParse();
40:
41: if ((_fullQualifiedName.startsWith(stringToParse) && stringToParse
42: .startsWith(_mappedClassNameWithEndingDot))
43: || (_simpleQualifiedName.startsWith(stringToParse) && stringToParse
44: .startsWith(_simpleMappedClassNameWithEndingDot))) {
45: return true;
46: }
47:
48: return false;
49: }
50:
51: public boolean matchesUnQualified(String attrCandidate) {
52: return _hibernatePropertyInfo.getPropertyName().startsWith(
53: attrCandidate);
54: }
55:
56: public String getClassName() {
57: return _hibernatePropertyInfo.getClassName();
58: }
59:
60: public HibernatePropertyInfo getHibernatePropertyInfo() {
61: return _hibernatePropertyInfo;
62: }
63:
64: public MappedClassInfo getMappedClassInfo() {
65: return _mappedClassInfo;
66: }
67:
68: public void setMappedClassInfo(MappedClassInfo mappedClassInfo) {
69: _mappedClassInfo = mappedClassInfo;
70: }
71: }
|