Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 19 20 package org.netbeans.modules.dbschema; 21 22 25 public final class DBIdentifier { 26 private String name; 27 transient private String fullName = null; 28 29 31 public DBIdentifier() { 32 } 33 34 37 private DBIdentifier(String name) { 38 this.name = name; 39 } 40 41 45 public static DBIdentifier create(String name) { 46 String shortName = name.intern(); 47 String longName = null; 48 int semicolonIndex = name.indexOf(';'); 49 DBIdentifier returnId = null; 50 51 if (semicolonIndex == -1) { 52 String testName = findShortName(name); 53 54 if (!testName.equals(name)) { 55 shortName = testName.intern(); 56 longName = name; 57 } else { 58 int index = name.lastIndexOf('/'); 59 if (index != -1) { 60 shortName = name.substring(index + 1).intern(); 61 longName = name; 62 } 63 } 64 } else { 65 String firstHalf = name.substring(0, semicolonIndex); 66 String secondHalf = name.substring(semicolonIndex + 1); 67 String testFirstName = findShortName(firstHalf); 68 String testSecondName = findShortName(secondHalf); 69 70 if (!testFirstName.equals(firstHalf) && !testSecondName.equals(secondHalf)) { 71 shortName = testFirstName + ';' + testSecondName; 72 longName = name; 73 } 74 } 75 76 returnId = new DBIdentifier(shortName); 77 78 if (longName != null) 79 returnId.setFullName(longName); 80 81 return returnId; 82 } 83 84 88 private static String findShortName(String name) { 89 int index = name.lastIndexOf('.'); 90 91 if (index != -1) 92 return name.substring(index + 1); 93 94 return name; 95 } 96 97 100 public String getName() { 101 return name; 102 } 103 104 107 public void setName (String name) { 108 this.name = name; 109 } 110 111 114 public String getFullName () { 115 return fullName; 116 } 117 118 121 public void setFullName (String fullName) { 122 this.fullName = fullName; 123 } 124 125 128 public String toString() { 129 return name; 130 } 131 132 136 public boolean compareTo(DBIdentifier id, boolean source) { 137 if (id.fullName != null && fullName != null) 138 if (id.fullName.equals(fullName)) 139 return true; 140 else 141 return false; 142 143 if (id.name.equals(name)) 144 return true; 145 146 return false; 147 } 148 } 149
| Popular Tags
|