Source Code Cross Referenced for SpecialTokenData.java in  » UML » jrefactory » org » acm » seguin » pretty » 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.pretty 
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.pretty;
010:
011:        import net.sourceforge.jrefactory.parser.Token;
012:        import net.sourceforge.jrefactory.parser.JavaParserConstants;
013:        import org.acm.seguin.util.MissingSettingsException;
014:        import org.acm.seguin.util.FileSettings;
015:
016:        /**
017:         *  Store the data that understands how to output comments and newlines
018:         *
019:         *@author     Chris Seguin
020:         *@author     Mike Atkinson
021:         *@created    April 30, 1999
022:         */
023:        public class SpecialTokenData {
024:            //  Instance Variables
025:            private PrintData data;
026:            private Token special;
027:            private JavaDocable jdi;
028:            private boolean lastReturnExpected;
029:            private boolean acceptNewlines;
030:            private boolean setAcceptingNewlines;
031:            private boolean reformatComments;
032:
033:            /**
034:             *  Creates a special token data object
035:             *
036:             *@param  token      the special token
037:             *@param  printData  the print data
038:             */
039:            public SpecialTokenData(JavaDocable jdi, Token token,
040:                    PrintData printData) {
041:                this (jdi, token, printData, true);
042:            }
043:
044:            /**
045:             *  Creates a special token data object
046:             *
047:             *@param  token      the special token
048:             *@param  printData  the print data
049:             */
050:            public SpecialTokenData(Token token, PrintData printData) {
051:                this (null, token, printData, true);
052:            }
053:
054:            /**
055:             *  Creates a special token data object
056:             *
057:             *@param  token      the special token
058:             *@param  printData  the print data
059:             *@param  accept     whether newlines should be accepted
060:             */
061:            public SpecialTokenData(Token token, PrintData printData,
062:                    boolean accept) {
063:                this (null, token, printData, accept);
064:            }
065:
066:            /**
067:             *  Creates a special token data object
068:             *
069:             *@param  token      the special token
070:             *@param  printData  the print data
071:             *@param  accept     whether newlines should be accepted
072:             */
073:            public SpecialTokenData(JavaDocable jdi, Token token,
074:                    PrintData printData, boolean accept) {
075:                this .jdi = jdi;
076:                data = printData;
077:                special = beginning(token);
078:                lastReturnExpected = true;
079:                acceptNewlines = accept;
080:                setAcceptingNewlines = false;
081:
082:                //  Check if comments should be reformatted
083:                reformatComments = printData.isReformatComments();
084:            }
085:
086:            /**
087:             *  Set that the last return was (or not) expected
088:             *
089:             *@param  way  the way it was expected
090:             */
091:            public void setReturnExpected(boolean way) {
092:                if (!setAcceptingNewlines) {
093:                    lastReturnExpected = way;
094:                    setAcceptingNewlines = true;
095:                }
096:            }
097:
098:            /**
099:             *  Returns true when it is the last
100:             *
101:             *@return    true if we are at the last
102:             */
103:            public boolean isLast() {
104:                return ((special == null) || (special.next == null) || (""
105:                        .equals(special.next)));
106:            }
107:
108:            /**
109:             *  Returns true when it is the last JavaDoc comment.
110:             *
111:             *@return    true if we are the last
112:             *@since     JRefactory 2.7.00
113:             */
114:            public boolean isLastJavadocComment() {
115:                boolean last = true;
116:                Token s = special.next;
117:                while (s != null) {
118:                    if (s.image != null && s.image.startsWith("/**")) {
119:                        last = false;
120:                    }
121:                    s = s.next;
122:                }
123:                return last;
124:            }
125:
126:            /**
127:             *  If the first special Token is a C_STYLE_COMMENT, then pretend it
128:             *  is a SINGLE_LINE_COMMENT.
129:             *
130:             *  Fixes bug 761890 (at least partly).
131:             *
132:             *@since     JRefactory 2.7.03
133:             */
134:            public void convertFirstCStyleCommentToSingleLine() {
135:                if (special != null
136:                        && special.kind == JavaParserConstants.MULTI_LINE_COMMENT
137:                        && special.image.indexOf('\n') < 0) {
138:                    //System.out.println("  - converting");
139:                    special.kind = JavaParserConstants.SINGLE_LINE_COMMENT;
140:                }
141:            }
142:
143:            /**
144:             *  Returns true when it is the first
145:             *
146:             *@return    true if we are at the first
147:             */
148:            public boolean isFirst() {
149:                return ((special == null) || (special.specialToken == null));
150:            }
151:
152:            /**
153:             *  Return the print data
154:             *
155:             *@return    the print data object
156:             */
157:            public PrintData getPrintData() {
158:                return data;
159:            }
160:
161:            /**
162:             *  Return the special token
163:             *
164:             *@return    the special token
165:             */
166:            public Token getSpecialToken() {
167:                return special;
168:            }
169:
170:            public JavaDocable getJDI() {
171:                return jdi;
172:            }
173:
174:            /**
175:             *  Get the token type
176:             *
177:             *@return    the token type
178:             */
179:            public int getTokenType() {
180:                if (special == null) {
181:                    return -1;
182:                }
183:                return special.kind;
184:            }
185:
186:            /**
187:             *  Get the token image
188:             *
189:             *@return    the token image
190:             */
191:            public String getTokenImage() {
192:                if (special == null) {
193:                    return "";
194:                }
195:
196:                return special.image;
197:            }
198:
199:            /**
200:             *  Return true if the last return was expected
201:             *
202:             *@return    true if last was expected
203:             */
204:            public boolean isReturnExpected() {
205:                return lastReturnExpected;
206:            }
207:
208:            /**
209:             *  Return true if new lines should be accepted
210:             *
211:             *@return    true if newlines should be accepted
212:             */
213:            public boolean isAcceptingReturns() {
214:                return acceptNewlines;
215:            }
216:
217:            /**
218:             *  Returns true if comments are being reformatted
219:             *
220:             *@return    true if comments should be reformatted
221:             */
222:            public boolean isReformattingComments() {
223:                return reformatComments;
224:            }
225:
226:            /**
227:             *  Got to the beginning
228:             *
229:             *@param  tok  Description of Parameter
230:             *@return      Description of the Returned Value
231:             */
232:            public Token beginning(Token tok) {
233:                if (tok == null) {
234:                    return null;
235:                }
236:
237:                //  Find the first token
238:                Token current = tok;
239:                Token previous = tok.specialToken;
240:                while (previous != null) {
241:                    current = previous;
242:                    previous = current.specialToken;
243:                }
244:
245:                //  Return the first
246:                return current;
247:            }
248:
249:            /**
250:             *  Get the next token
251:             */
252:            public void next() {
253:                if (special != null) {
254:                    special = special.next;
255:                }
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.