Source Code Cross Referenced for HtmlAttribute.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » designer » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.designer.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.visualweb.designer.html;
043:
044:        import org.w3c.dom.Element;
045:
046:        /**
047:         * HTML attributes. Most of these are probably unused now so we should
048:         * get rid of them.
049:         *
050:         * @author Tor Norbye
051:         */
052:        public final class HtmlAttribute {
053:            public static final String FOR = "for"; // NOI18N
054:            public static final String FRAME = "frame"; // NOI18N
055:            public static final String RULES = "rules"; // NOI18N
056:            public static final String SIZE = "size"; // NOI18N
057:            public static final String COLOR = "color"; // NOI18N
058:            public static final String CLEAR = "clear"; // NOI18N
059:            public static final String BACKGROUND = "background"; // NOI18N
060:            public static final String BGCOLOR = "bgcolor"; // NOI18N
061:            public static final String TEXT = "text"; // NOI18N
062:            public static final String LINK = "link"; // NOI18N
063:            //public static final String VLINK = "vlink"; // NOI18N
064:            //public static final String ALINK = "alink"; // NOI18N
065:            public static final String WIDTH = "width"; // NOI18N
066:            public static final String HEIGHT = "height"; // NOI18N
067:            public static final String ALIGN = "align"; // NOI18N
068:            public static final String NAME = "name"; // NOI18N
069:            public static final String HREF = "href"; // NOI18N
070:            public static final String REL = "rel"; // NOI18N
071:            public static final String REV = "rev"; // NOI18N
072:            public static final String TITLE = "title"; // NOI18N
073:            public static final String TARGET = "target"; // NOI18N
074:            public static final String SHAPE = "shape"; // NOI18N
075:            public static final String COORDS = "coords"; // NOI18N
076:            public static final String ISMAP = "ismap"; // NOI18N
077:            public static final String NOHREF = "nohref"; // NOI18N
078:            public static final String ALT = "alt"; // NOI18N
079:            public static final String ID = "id"; // NOI18N
080:            public static final String SRC = "src"; // NOI18N
081:            public static final String HSPACE = "hspace"; // NOI18N
082:            public static final String VSPACE = "vspace"; // NOI18N
083:            public static final String USEMAP = "usemap"; // NOI18N
084:            public static final String LOWSRC = "lowsrc"; // NOI18N
085:            public static final String CODEBASE = "codebase"; // NOI18N
086:            public static final String CODE = "code"; // NOI18N
087:            public static final String ARCHIVE = "archive"; // NOI18N
088:            public static final String VALUE = "value"; // NOI18N
089:            public static final String VALUETYPE = "valuetype"; // NOI18N
090:            public static final String TYPE = "type"; // NOI18N
091:            public static final String CLASS = "class"; // NOI18N
092:            public static final String STYLE = "style"; // NOI18N
093:            public static final String LANG = "lang"; // NOI18N
094:            public static final String FACE = "face"; // NOI18N
095:            public static final String DIR = "dir"; // NOI18N
096:            public static final String DECLARE = "declare"; // NOI18N
097:            public static final String CLASSID = "classid"; // NOI18N
098:            public static final String DATA = "data"; // NOI18N
099:            public static final String CODETYPE = "codetype"; // NOI18N
100:            public static final String ONLOAD = "onload"; // NOI18N
101:            public static final String STANDBY = "standby"; // NOI18N
102:            public static final String BORDER = "border"; // NOI18N
103:            public static final String SHAPES = "shapes"; // NOI18N
104:            public static final String NOSHADE = "noshade"; // NOI18N
105:            public static final String COMPACT = "compact"; // NOI18N
106:            public static final String START = "start"; // NOI18N
107:            public static final String ACTION = "action"; // NOI18N
108:            public static final String METHOD = "method"; // NOI18N
109:            public static final String ENCTYPE = "enctype"; // NOI18N
110:            public static final String CHECKED = "checked"; // NOI18N
111:            public static final String MAXLENGTH = "maxlength"; // NOI18N
112:            public static final String MULTIPLE = "multiple"; // NOI18N
113:            public static final String SELECTED = "selected"; // NOI18N
114:            public static final String ROWS = "rows"; // NOI18N
115:            public static final String COLS = "cols"; // NOI18N
116:            //public static final String DUMMY = "dummy"; // NOI18N
117:            public static final String CELLSPACING = "cellspacing"; // NOI18N
118:            public static final String CELLPADDING = "cellpadding"; // NOI18N
119:            public static final String VALIGN = "valign"; // NOI18N
120:            public static final String HALIGN = "halign"; // NOI18N
121:            public static final String NOWRAP = "nowrap"; // NOI18N
122:            public static final String ROWSPAN = "rowspan"; // NOI18N
123:            public static final String COLSPAN = "colspan"; // NOI18N
124:            public static final String SPAN = "span"; // NOI18N
125:            public static final String PROMPT = "prompt"; // NOI18N
126:            public static final String HTTPEQUIV = "http-equiv"; // NOI18N
127:            public static final String CONTENT = "content"; // NOI18N
128:            public static final String LANGUAGE = "language"; // NOI18N
129:            public static final String VERSION = "version"; // NOI18N
130:            //public static final String N = "n"; // NOI18N
131:            public static final String FRAMEBORDER = "frameborder"; // NOI18N
132:            public static final String MARGINWIDTH = "marginwidth"; // NOI18N
133:            public static final String MARGINHEIGHT = "marginheight"; // NOI18N
134:            public static final String SCROLLING = "scrolling"; // NOI18N
135:            public static final String NORESIZE = "noresize"; // NOI18N
136:            public static final String ENDTAG = "endtag"; // NOI18N
137:            public static final String COMMENT = "comment"; // NOI18N
138:            public static final String MEDIA = "media"; // NOI18N
139:
140:            // Integer IDS
141:            public static final int ALIGN_ID = 0;
142:            public static final int VALIGN_ID = ALIGN_ID + 1;
143:            public static final int BGCOLOR_ID = VALIGN_ID + 1;
144:            public static final int BACKGROUND_ID = BGCOLOR_ID + 1;
145:            public static final int TEXT_ID = BACKGROUND_ID + 1;
146:            public static final int WIDTH_ID = TEXT_ID + 1;
147:            public static final int HEIGHT_ID = WIDTH_ID + 1;
148:            public static final int NOWRAP_ID = HEIGHT_ID + 1;
149:            public static final int BORDER_ID = NOWRAP_ID + 1;
150:            public static final int COLOR_ID = BORDER_ID + 1;
151:            public static final int SIZE_ID = COLOR_ID + 1;
152:            public static final int FACE_ID = SIZE_ID + 1;
153:            public static final int TYPE_ID = FACE_ID + 1;
154:            public static final int LINK_ID = TYPE_ID + 1;
155:            public static final int CLEAR_ID = LINK_ID + 1;
156:
157:            /**
158:             * Fetches an integer attribute value.  HtmlAttribute values
159:             * are stored as a string, and this is a convenience method
160:             * to convert to an actual integer.
161:             *
162:             * @param attr the set of attributes to use to try to fetch a value
163:             * @param key the key to use to fetch the value
164:             * @param def the default value to use if the attribute isn't
165:             *  defined or there is an error converting to an integer
166:             * @todo Make this do the right thing for "20px" - right now it
167:             *  returns 0 instead of 20 ! Ditto for percentages...
168:             */
169:            public static int getIntegerAttributeValue(Element el, String key,
170:                    int def) {
171:                int value = def;
172:                String istr = el.getAttribute(key);
173:                if (istr != null && istr.length() > 0) {
174:                    try {
175:                        //value = Integer.parseInt(istr);
176:                        value = parseInt(istr);
177:                    } catch (NumberFormatException e) {
178:                        value = def;
179:                    }
180:                }
181:                return value;
182:            }
183:
184:            public static final byte VALUE_ABSOLUTE = 1;
185:            public static final byte VALUE_PERCENTAGE = 2;
186:            public static final byte VALUE_RELATIVE = 4;
187:
188:            /** Return the number type of the given String, if it represents
189:             * a number, percentage or relative length */
190:            public static byte getNumberType(String s) {
191:                // I start from the beginning rather than the end before I
192:                // want to use the first relevant character after the number;
193:                // the String could point to more stuff afterwards
194:                for (int i = 0, n = s.length(); i < n; i++) {
195:                    if (s.charAt(i) == '%') {
196:                        return VALUE_PERCENTAGE;
197:                    } else if (s.charAt(i) == '*') {
198:                        return VALUE_RELATIVE;
199:                    }
200:                }
201:                return VALUE_ABSOLUTE;
202:            }
203:
204:            /**
205:             * Very similar to Integer.parseInt (based on it), but more liberal
206:             * about what it allows.  Specifically, it allows the string to have
207:             * a suffix that's not a number; this is ignored. For example
208:             * "100px" will return "100". Integer.parseInt would throw an
209:             * exception. This specific case is useful, since for example a
210:             * buggy <table>tag might set border="1px" - confusing attributes
211:             * with CSS style attributes - and this would with Integer.parseInt
212:             * evaluate to 0, whereas both Mozilla and Safari will use a border
213:             * of 1. Unlike Integer.parseInt, we only support base 10.
214:             * @todo Move into Util
215:             */
216:            public static int parseInt(String s) {
217:                int radix = 10;
218:                if (s == null) {
219:                    return 0;
220:                }
221:
222:                int result = 0;
223:                boolean negative = false;
224:                int i = 0, max = s.length();
225:                int limit;
226:                int multmin;
227:                int digit;
228:
229:                if (max > 0) {
230:                    // Skip initial spaces
231:                    while (Character.isWhitespace(s.charAt(i))) {
232:                        i++;
233:                    }
234:                    if (i == max) {
235:                        return 0;
236:                    }
237:
238:                    if (s.charAt(i) == '-') {
239:                        negative = true;
240:                        limit = Integer.MIN_VALUE;
241:                        i++;
242:                    } else {
243:                        limit = -Integer.MAX_VALUE;
244:                    }
245:                    multmin = limit / radix;
246:                    if (i < max) {
247:                        digit = Character.digit(s.charAt(i++), radix);
248:                        if (digit < 0) {
249:                            //throw NumberFormatException.forInputString(s);
250:                            return negative ? result : -result;
251:                        } else {
252:                            result = -digit;
253:                        }
254:                    }
255:                    while (i < max) {
256:                        // Accumulating negatively avoids surprises near MAX_VALUE
257:                        digit = Character.digit(s.charAt(i++), radix);
258:                        if (digit < 0) {
259:                            //throw NumberFormatException.forInputString(s);
260:                            return negative ? result : -result;
261:                        }
262:                        if (result < multmin) {
263:                            //throw NumberFormatException.forInputString(s);
264:                            return negative ? result : -result;
265:                        }
266:                        result *= radix;
267:                        if (result < limit + digit) {
268:                            //throw NumberFormatException.forInputString(s);
269:                            return negative ? result : -result;
270:                        }
271:                        result -= digit;
272:                    }
273:                } else {
274:                    //throw NumberFormatException.forInputString(s);
275:                    //return negative ? result : -result;
276:                    return 0;
277:                }
278:                done: if (negative) {
279:                    if (i > 1) {
280:                        return result;
281:                    } else { /* Only got "-" */
282:                        //throw NumberFormatException.forInputString(s);
283:                        return 0;
284:                    }
285:                } else {
286:                    return -result;
287:                }
288:            }
289:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.