Source Code Cross Referenced for SyntaxElement.java in  » Swing-Library » abeille-forms-designer » org » netbeans » editor » ext » html » 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 » Swing Library » abeille forms designer » org.netbeans.editor.ext.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *                 Sun Public License Notice
003:         * 
004:         * The contents of this file are subject to the Sun Public License
005:         * Version 1.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://www.sun.com/
008:         * 
009:         * The Original Code is NetBeans. The Initial Developer of the Original
010:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
011:         * Microsystems, Inc. All Rights Reserved.
012:         */
013:
014:        package org.netbeans.editor.ext.html;
015:
016:        import java.util.Collection;
017:        import java.util.ConcurrentModificationException;
018:        import java.util.Iterator;
019:
020:        import javax.swing.text.BadLocationException;
021:
022:        /**
023:         * SyntaxElement is class internal to HTML Completion engine, it is used during
024:         * the analysis of the HTML code.
025:         * 
026:         * It is an element of the dynamically created chain of other SyntaxElements.
027:         * The access to it is done through the HTMLSyntaxSupport, which also takes care
028:         * of dynamically extending it when needed.
029:         * 
030:         * @author Petr Nejedly
031:         * @version 1.0
032:         */
033:        class SyntaxElement {
034:
035:            public static final int TYPE_COMMENT = 0;
036:            public static final int TYPE_DECLARATION = 1;
037:            public static final int TYPE_ERROR = 2;
038:            public static final int TYPE_TEXT = 3;
039:            public static final int TYPE_TAG = 4;
040:            public static final int TYPE_ENDTAG = 5;
041:
042:            private HTMLSyntaxSupport support;
043:            private SyntaxElement previous;
044:            private SyntaxElement next;
045:
046:            int offset;
047:            int length;
048:            int type;
049:
050:            /** Creates new SyntaxElement */
051:            public SyntaxElement(HTMLSyntaxSupport support, int from, int to,
052:                    int type) {
053:                this .support = support;
054:                this .offset = from;
055:                this .length = to - from;
056:                this .type = type;
057:            }
058:
059:            public int getElementOffset() {
060:                return offset;
061:            }
062:
063:            public int getElementLength() {
064:                return length;
065:            }
066:
067:            public int getType() {
068:                return type;
069:            }
070:
071:            public String getText() {
072:                try {
073:                    return support.getDocument().getText(offset, length);
074:                } catch (BadLocationException exc) {
075:                    // this could happen only when in inconsistent state
076:                    throw new ConcurrentModificationException(
077:                            "SyntaxElement in inconsistent state"); // NOI18N
078:                }
079:            }
080:
081:            public SyntaxElement getPrevious() throws BadLocationException {
082:                if (previous == null) {
083:                    previous = support.getPreviousElement(offset);
084:                    if (previous != null)
085:                        previous.next = this ;
086:                }
087:                return previous;
088:            }
089:
090:            public SyntaxElement getNext() throws BadLocationException {
091:                if (next == null) {
092:                    next = support.getNextElement(offset + length);
093:                    if (next != null)
094:                        next.previous = this ;
095:                }
096:                return next;
097:            }
098:
099:            public String toString() {
100:                return "Element(" + type + ")[" + offset + ","
101:                        + (offset + length - 1) + "]"; // NOI18N
102:            }
103:
104:            /**
105:             * Declaration models SGML declaration with emphasis on <!DOCTYPE
106:             * declaration, as other declarations are not allowed inside HTML. It
107:             * represents unknown/broken declaration or either public or system DOCTYPE
108:             * declaration.
109:             */
110:            static class Declaration extends SyntaxElement {
111:                private String root;
112:                private String publicID;
113:                private String file;
114:
115:                /**
116:                 * Creates a model of SGML declaration with some properties of DOCTYPE
117:                 * declaration.
118:                 * 
119:                 * @param doctypeRootElement
120:                 *            the name of the root element for a DOCTYPE. Can be null to
121:                 *            express that the declaration is not DOCTYPE declaration or
122:                 *            is broken.
123:                 * @param doctypePI
124:                 *            public identifier for this DOCTYPE, if available. null for
125:                 *            system doctype or other/broken declaration.
126:                 * @param doctypeFile
127:                 *            system identifier for this DOCTYPE, if available. null
128:                 *            otherwise.
129:                 */
130:                public Declaration(HTMLSyntaxSupport support, int from, int to,
131:                        String doctypeRootElement, String doctypePI,
132:                        String doctypeFile) {
133:                    super (support, from, to, TYPE_DECLARATION);
134:                    root = doctypeRootElement;
135:                    publicID = doctypePI;
136:                    file = doctypeFile;
137:                }
138:
139:                /**
140:                 * @return the name of the root element for a DOCTYPE declaration or
141:                 *         null if the declatarion is not DOCTYPE or is broken.
142:                 */
143:                public String getRootElement() {
144:                    return root;
145:                }
146:
147:                /**
148:                 * @return a public identifier of the PUBLIC DOCTYPE declaration or null
149:                 *         for SYSTEM DOCTYPE and broken or other declaration.
150:                 */
151:                public String getPublicIdentifier() {
152:                    return publicID;
153:                }
154:
155:                /**
156:                 * @return a system identifier of both PUBLIC and SYSTEM DOCTYPE
157:                 *         declaration or null for PUBLIC declaration with system
158:                 *         identifier not specified and broken or other declaration.
159:                 */
160:                public String getDoctypeFile() {
161:                    return file;
162:                }
163:
164:            }
165:
166:            static class Named extends SyntaxElement {
167:                String name;
168:
169:                public Named(HTMLSyntaxSupport support, int from, int to,
170:                        int type, String name) {
171:                    super (support, from, to, type);
172:                    this .name = name;
173:                }
174:
175:                public String getName() {
176:                    return name;
177:                }
178:
179:                public String toString() {
180:                    return super .toString() + " - \"" + name + '"'; // NOI18N
181:                }
182:            }
183:
184:            static class Tag extends SyntaxElement.Named {
185:                Collection attribs;
186:
187:                public Tag(HTMLSyntaxSupport support, int from, int to,
188:                        String name, Collection attribs) {
189:                    super (support, from, to, TYPE_TAG, name);
190:                    this .attribs = attribs;
191:                }
192:
193:                public Collection getAttributes() {
194:                    return attribs;
195:                }
196:
197:                public String toString() {
198:                    StringBuffer ret = new StringBuffer(super .toString());
199:                    ret.append(" - {"); // NOI18N
200:
201:                    for (Iterator i = attribs.iterator(); i.hasNext();) {
202:                        ret.append(i.next());
203:                        ret.append(", "); // NOI18N
204:                    }
205:
206:                    ret.append("}"); // NOI18N
207:                    return ret.toString();
208:                }
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.