Source Code Cross Referenced for RenameFieldData.java in  » UML » jrefactory » org » acm » seguin » refactor » field » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » jrefactory » org.acm.seguin.refactor.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Author:  Chris Seguin
003:         *
004:         *  This software has been developed under the copyleft
005:         *  rules of the GNU General Public License.  Please
006:         *  consult the GNU General Public License for more
007:         *  details about use and distribution of this software.
008:         */
009:        package org.acm.seguin.refactor.field;
010:
011:        import org.acm.seguin.refactor.ComplexTransform;
012:        import org.acm.seguin.summary.FieldSummary;
013:        import org.acm.seguin.summary.PackageSummary;
014:        import org.acm.seguin.summary.Summary;
015:        import org.acm.seguin.summary.TypeSummary;
016:        import org.acm.seguin.summary.query.Ancestor;
017:
018:        /**
019:         *  Object used to store the state of the rename field visitor
020:         *
021:         * @author    Chris Seguin
022:         * @since     2.4.0
023:         */
024:        class RenameFieldData {
025:            private String oldName;
026:            private String newName;
027:            private boolean this Required;
028:            private Summary current;
029:            private boolean mustInsertThis;
030:            private TypeSummary typeSummary;
031:            private boolean canBeFirst;
032:            private boolean canBeThis;
033:            private FieldSummary oldField;
034:            private ComplexTransform transform;
035:            private String fullName;
036:            private String importedName;
037:
038:            /**
039:             *  Constructor for the RenameFieldData object
040:             *
041:             * @param  oldField  Description of Parameter
042:             * @param  newName   the new field name
043:             * @since            2.4.0
044:             */
045:            public RenameFieldData(FieldSummary oldField, String newName) {
046:                this .oldName = oldField.getName();
047:                this .newName = newName;
048:                this .oldField = oldField;
049:                this Required = false;
050:                canBeFirst = false;
051:                canBeThis = false;
052:                mustInsertThis = false;
053:                current = null;
054:                typeSummary = (TypeSummary) oldField.getParent();
055:                initNames(oldField);
056:            }
057:
058:            /**
059:             *  Constructor for the RenameFieldData object
060:             *
061:             * @param  oldField   Description of Parameter
062:             * @param  newName    the new field name
063:             * @param  transform  Description of Parameter
064:             * @since             2.4.0
065:             */
066:            public RenameFieldData(FieldSummary oldField, String newName,
067:                    ComplexTransform transform) {
068:                this .newName = newName;
069:                this .oldField = oldField;
070:                this .transform = transform;
071:                oldName = oldField.getName();
072:                typeSummary = (TypeSummary) oldField.getParent();
073:            }
074:
075:            /**
076:             *  Sets the ThisRequired attribute of the RenameFieldData object
077:             *
078:             * @param  way  The new ThisRequired value
079:             * @since       2.4.0
080:             */
081:            public void setThisRequired(boolean way) {
082:                this Required = way;
083:            }
084:
085:            /**
086:             *  Sets the CurrentSummary attribute of the RenameFieldData object
087:             *
088:             * @param  value  The new CurrentSummary value
089:             * @since         2.4.0
090:             */
091:            public void setCurrentSummary(Summary value) {
092:                current = value;
093:                if (current instanceof  TypeSummary) {
094:                    check((TypeSummary) current);
095:                }
096:            }
097:
098:            /**
099:             *  Sets the MustInsertThis attribute of the RenameFieldData object
100:             *
101:             * @param  value  The new MustInsertThis value
102:             * @since         2.4.0
103:             */
104:            public void setMustInsertThis(boolean value) {
105:                mustInsertThis = value;
106:            }
107:
108:            /**
109:             *  Gets the OldName attribute of the RenameFieldData object
110:             *
111:             * @return    The OldName value
112:             * @since     2.4.0
113:             */
114:            public String getOldName() {
115:                return oldName;
116:            }
117:
118:            /**
119:             *  Gets the NewName attribute of the RenameFieldData object
120:             *
121:             * @return    The NewName value
122:             * @since     2.4.0
123:             */
124:            public String getNewName() {
125:                return newName;
126:            }
127:
128:            /**
129:             *  Gets the ThisRequired attribute of the RenameFieldData object
130:             *
131:             * @return    The ThisRequired value
132:             * @since     2.4.0
133:             */
134:            public boolean isThisRequired() {
135:                return this Required;
136:            }
137:
138:            /**
139:             *  Gets the CurrentSummary attribute of the RenameFieldData object
140:             *
141:             * @return    The CurrentSummary value
142:             * @since     2.4.0
143:             */
144:            public Summary getCurrentSummary() {
145:                return current;
146:            }
147:
148:            /**
149:             *  Gets the MustInsertThis attribute of the RenameFieldData object
150:             *
151:             * @return    The MustInsertThis value
152:             * @since     2.4.0
153:             */
154:            public boolean isMustInsertThis() {
155:                return mustInsertThis;
156:            }
157:
158:            /**
159:             *  Returns the type summary where the field is changing
160:             *
161:             * @return    The TypeSummary value
162:             * @since     2.4.0
163:             */
164:            public TypeSummary getTypeSummary() {
165:                return typeSummary;
166:            }
167:
168:            /**
169:             *  Gets the AllowedToChangeFirst attribute of the RenameFieldData object
170:             *
171:             * @return    The AllowedToChangeFirst value
172:             * @since     2.4.0
173:             */
174:            public boolean isAllowedToChangeFirst() {
175:                return canBeFirst;
176:            }
177:
178:            /**
179:             *  Gets the AllowedToChangeThis attribute of the RenameFieldData object
180:             *
181:             * @return    The AllowedToChangeThis value
182:             * @since     2.4.0
183:             */
184:            public boolean isAllowedToChangeThis() {
185:                return canBeThis;
186:            }
187:
188:            /**
189:             *  Gets the OldField attribute of the RenameFieldData object
190:             *
191:             * @return    The OldField value
192:             * @since     2.4.0
193:             */
194:            public FieldSummary getOldField() {
195:                return oldField;
196:            }
197:
198:            /**
199:             *  Gets the ComplexTransform attribute of the RenameFieldData object
200:             *
201:             * @return    The ComplexTransform value
202:             * @since     2.4.0
203:             */
204:            public ComplexTransform getComplexTransform() {
205:                return transform;
206:            }
207:
208:            /**
209:             *  Gets the FullName attribute of the RenameFieldData object
210:             *
211:             * @return    The FullName value
212:             * @since     2.4.0
213:             */
214:            public String getFullName() {
215:                return fullName;
216:            }
217:
218:            /**
219:             *  Gets the ImportedName attribute of the RenameFieldData object
220:             *
221:             * @return    The ImportedName value
222:             * @since     2.4.0
223:             */
224:            public String getImportedName() {
225:                return importedName;
226:            }
227:
228:            /**
229:             *  Converts to a String representation of the object.
230:             *
231:             * @return    A string representation of the object.
232:             * @since     2.4.0
233:             */
234:            public String toString() {
235:                StringBuffer sb = new StringBuffer();
236:                sb.append("  oldName=").append(oldName);
237:                sb.append("\n  newName=").append(newName);
238:                sb.append("\n  thisRequired=").append(this Required);
239:                sb.append("\n  current=").append(current);
240:                sb.append("\n  mustInsertThis=").append(mustInsertThis);
241:                sb.append("\n  typeSummary=").append(typeSummary);
242:                sb.append("\n  canBeFirst=").append(canBeFirst);
243:                sb.append("\n  canBeThis=").append(canBeThis);
244:                sb.append("\n  oldField=").append(oldField);
245:                sb.append("\n  transform=").append(transform);
246:                sb.append("\n  fullName=").append(fullName);
247:                sb.append("\n  importedName=").append(importedName)
248:                        .append("\n");
249:                return sb.toString();
250:            }
251:
252:            /**
253:             *  Returns true if the system can change the first name in an array
254:             *
255:             * @param  current  the type summary in question
256:             * @since           2.4.0
257:             */
258:            private void check(TypeSummary current) {
259:                if ((current == typeSummary)
260:                        || Ancestor.query(current, typeSummary)) {
261:                    canBeFirst = true;
262:                    canBeThis = true;
263:                    return;
264:                }
265:
266:                Summary cs = current;
267:                while (cs != null) {
268:                    if (cs == typeSummary) {
269:                        canBeThis = false;
270:                        canBeFirst = true;
271:                        return;
272:                    }
273:
274:                    cs = cs.getParent();
275:                }
276:
277:                canBeThis = false;
278:                canBeFirst = false;
279:            }
280:
281:            /**
282:             *  Initialize the names
283:             *
284:             * @param  field  the field summary
285:             * @since         2.4.0
286:             */
287:            private void initNames(FieldSummary field) {
288:                StringBuffer buffer = new StringBuffer(field.getName());
289:
290:                Summary current = field;
291:                while (current != null) {
292:                    if (current instanceof  TypeSummary) {
293:                        buffer.insert(0, ".");
294:                        buffer.insert(0, current.getName());
295:                    }
296:
297:                    if (current instanceof  PackageSummary) {
298:                        importedName = buffer.toString();
299:                        buffer.insert(0, ".");
300:                        buffer.insert(0, current.getName());
301:                        fullName = buffer.toString();
302:                        return;
303:                    }
304:
305:                    current = current.getParent();
306:                }
307:
308:                //  We should never get here
309:                importedName = buffer.toString();
310:                fullName = buffer.toString();
311:            }
312:
313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.