001: /*
002: * Java HTML Tidy - JTidy
003: * HTML parser and pretty printer
004: *
005: * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
006: * Institute of Technology, Institut National de Recherche en
007: * Informatique et en Automatique, Keio University). All Rights
008: * Reserved.
009: *
010: * Contributing Author(s):
011: *
012: * Dave Raggett <dsr@w3.org>
013: * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
014: * Gary L Peskin <garyp@firstech.com> (Java development)
015: * Sami Lempinen <sami@lempinen.net> (release management)
016: * Fabrizio Giustina <fgiust at users.sourceforge.net>
017: *
018: * The contributing author(s) would like to thank all those who
019: * helped with testing, bug fixes, and patience. This wouldn't
020: * have been possible without all of you.
021: *
022: * COPYRIGHT NOTICE:
023: *
024: * This software and documentation is provided "as is," and
025: * the copyright holders and contributing author(s) make no
026: * representations or warranties, express or implied, including
027: * but not limited to, warranties of merchantability or fitness
028: * for any particular purpose or that the use of the software or
029: * documentation will not infringe any third party patents,
030: * copyrights, trademarks or other rights.
031: *
032: * The copyright holders and contributing author(s) will not be
033: * liable for any direct, indirect, special or consequential damages
034: * arising out of any use of the software or documentation, even if
035: * advised of the possibility of such damage.
036: *
037: * Permission is hereby granted to use, copy, modify, and distribute
038: * this source code, or portions hereof, documentation and executables,
039: * for any purpose, without fee, subject to the following restrictions:
040: *
041: * 1. The origin of this source code must not be misrepresented.
042: * 2. Altered versions must be plainly marked as such and must
043: * not be misrepresented as being the original source.
044: * 3. This Copyright notice may not be removed or altered from any
045: * source or altered source distribution.
046: *
047: * The copyright holders and contributing author(s) specifically
048: * permit, without fee, and encourage the use of this source code
049: * as a component for supporting the Hypertext Markup Language in
050: * commercial products. If you use this source code in a product,
051: * acknowledgment is not required but would be appreciated.
052: *
053: */
054: package org.w3c.tidy;
055:
056: /**
057: * Tag dictionary node. If the document uses just HTML 2.0 tags and attributes described it as HTML 2.0 Similarly for
058: * HTML 3.2 and the 3 flavors of HTML 4.0. If there are proprietary tags and attributes then describe it as HTML
059: * Proprietary. If it includes the xml-lang or xmlns attributes but is otherwise HTML 2.0, 3.2 or 4.0 then describe it
060: * as one of the flavors of Voyager (strict, loose or frameset).
061: * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
062: * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
063: * @author Fabrizio Giustina
064: * @version $Revision: 1.13 $ ($Author: fgiust $)
065: */
066: public class Dict {
067:
068: /**
069: * Content model: unknown.
070: */
071: public static final int CM_UNKNOWN = 0;
072:
073: /**
074: * Content model: empty.
075: */
076: public static final int CM_EMPTY = (1 << 0);
077:
078: /**
079: * Content model: html.
080: */
081: public static final int CM_HTML = (1 << 1);
082:
083: /**
084: * Content model: head.
085: */
086: public static final int CM_HEAD = (1 << 2);
087:
088: /**
089: * Content model: block.
090: */
091: public static final int CM_BLOCK = (1 << 3);
092:
093: /**
094: * Content model: inline.
095: */
096: public static final int CM_INLINE = (1 << 4);
097:
098: /**
099: * Content model: list.
100: */
101: public static final int CM_LIST = (1 << 5);
102:
103: /**
104: * Content model: definition list.
105: */
106: public static final int CM_DEFLIST = (1 << 6);
107:
108: /**
109: * Content model: table.
110: */
111: public static final int CM_TABLE = (1 << 7);
112:
113: /**
114: * Content model: rowgroup.
115: */
116: public static final int CM_ROWGRP = (1 << 8);
117:
118: /**
119: * Content model: row.
120: */
121: public static final int CM_ROW = (1 << 9);
122:
123: /**
124: * Content model: field.
125: */
126: public static final int CM_FIELD = (1 << 10);
127:
128: /**
129: * Content model: object.
130: */
131: public static final int CM_OBJECT = (1 << 11);
132:
133: /**
134: * Content model: param.
135: */
136: public static final int CM_PARAM = (1 << 12);
137:
138: /**
139: * Content model: frames.
140: */
141: public static final int CM_FRAMES = (1 << 13);
142:
143: /**
144: * Content model: heading.
145: */
146: public static final int CM_HEADING = (1 << 14);
147:
148: /**
149: * Content model: opt.
150: */
151: public static final int CM_OPT = (1 << 15);
152:
153: /**
154: * Content model: img.
155: */
156: public static final int CM_IMG = (1 << 16);
157:
158: /**
159: * Content model: mixed.
160: */
161: public static final int CM_MIXED = (1 << 17);
162:
163: /**
164: * Content model: no indent.
165: */
166: public static final int CM_NO_INDENT = (1 << 18);
167:
168: /**
169: * Content model: obsolete.
170: */
171: public static final int CM_OBSOLETE = (1 << 19);
172:
173: /**
174: * Content model: new.
175: */
176: public static final int CM_NEW = (1 << 20);
177:
178: /**
179: * Content model: omitst.
180: */
181: public static final int CM_OMITST = (1 << 21);
182:
183: /**
184: * Version: unknown.
185: */
186: public static final short VERS_UNKNOWN = 0;
187:
188: /**
189: * Version: html 2.0.
190: */
191: public static final short VERS_HTML20 = 1;
192:
193: /**
194: * Version: html 3.2.
195: */
196: public static final short VERS_HTML32 = 2;
197:
198: /**
199: * Version: html 4.0 strict.
200: */
201: public static final short VERS_HTML40_STRICT = 4;
202:
203: /**
204: * Version: html 4.0 transitional.
205: */
206: public static final short VERS_HTML40_LOOSE = 8;
207:
208: /**
209: * Version: html 4.0 frameset.
210: */
211: public static final short VERS_FRAMESET = 16;
212:
213: /**
214: * Version: xml.
215: */
216: public static final short VERS_XML = 32;
217:
218: /**
219: * Version: netscape.
220: */
221: public static final short VERS_NETSCAPE = 64;
222:
223: /**
224: * Version: microsoft.
225: */
226: public static final short VERS_MICROSOFT = 128;
227:
228: /**
229: * Version: sun.
230: */
231: public static final short VERS_SUN = 256;
232:
233: /**
234: * Version: malformed.
235: */
236: public static final short VERS_MALFORMED = 512;
237:
238: /**
239: * Version: xhtml 1.1.
240: */
241: public static final short VERS_XHTML11 = 1024;
242:
243: /**
244: * Version: xhtml basic.
245: */
246: public static final short VERS_BASIC = 2048;
247:
248: /**
249: * all tags and attributes are ok in proprietary version of HTML.
250: */
251: public static final short VERS_PROPRIETARY = (VERS_NETSCAPE
252: | VERS_MICROSOFT | VERS_SUN);
253:
254: /**
255: * tags/attrs in HTML4 but not in earlier version.
256: */
257: public static final short VERS_HTML40 = (VERS_HTML40_STRICT
258: | VERS_HTML40_LOOSE | VERS_FRAMESET);
259:
260: /**
261: * tags/attrs which are in all versions of HTML except strict.
262: */
263: public static final short VERS_LOOSE = (VERS_HTML32
264: | VERS_HTML40_LOOSE | VERS_FRAMESET);
265:
266: /**
267: * tags/attrs in HTML 4 loose and frameset.
268: */
269: public static final short VERS_IFRAME = (VERS_HTML40_LOOSE | VERS_FRAMESET);
270:
271: /**
272: * tags/attrs in all versions from HTML 3.2 onwards.
273: */
274: public static final short VERS_FROM32 = (VERS_HTML40_STRICT | VERS_LOOSE);
275:
276: /**
277: * versions with on... attributes.
278: */
279: public static final short VERS_EVENTS = (VERS_HTML40 | VERS_XHTML11);
280:
281: /**
282: * tags/attrs in any version.
283: */
284: public static final short VERS_ALL = (VERS_HTML20 | VERS_HTML32
285: | VERS_HTML40 | VERS_XHTML11 | VERS_BASIC);
286:
287: /**
288: * types of tags that the user can define: empty tag.
289: */
290: public static final short TAGTYPE_EMPTY = 1;
291:
292: /**
293: * types of tags that the user can define: inline tag.
294: */
295: public static final short TAGTYPE_INLINE = 2;
296:
297: /**
298: * types of tags that the user can define: block tag.
299: */
300: public static final short TAGTYPE_BLOCK = 4;
301:
302: /**
303: * types of tags that the user can define: pre tag.
304: */
305: public static final short TAGTYPE_PRE = 8;
306:
307: /**
308: * Tag name.
309: */
310: protected String name;
311:
312: /**
313: * Version in which this tag is defined.
314: */
315: protected short versions;
316:
317: /**
318: * model (CM_* constants).
319: */
320: protected int model;
321:
322: /**
323: * Parser for this tag.
324: */
325: private Parser parser;
326:
327: /**
328: * Validator for this tag.
329: */
330: private TagCheck chkattrs;
331:
332: /**
333: * Instantiates a new Tag definition.
334: * @param name tag name
335: * @param versions version in which this tag is defined
336: * @param model model (CM_* constants)
337: * @param parser parser for this tag
338: * @param chkattrs validator for this tag (can be null)
339: */
340: public Dict(String name, short versions, int model, Parser parser,
341: TagCheck chkattrs) {
342: this .name = name;
343: this .versions = versions;
344: this .model = model;
345: this .parser = parser;
346: this .chkattrs = chkattrs;
347: }
348:
349: /**
350: * Getter for <code>chkattrs</code>.
351: * @return Returns the chkattrs.
352: */
353: public TagCheck getChkattrs() {
354: return this .chkattrs;
355: }
356:
357: /**
358: * Getter for <code>model</code>.
359: * @return Returns the model.
360: */
361: public int getModel() {
362: return this .model;
363: }
364:
365: /**
366: * Getter for <code>name</code>.
367: * @return Returns the name.
368: */
369: public String getName() {
370: return this .name;
371: }
372:
373: /**
374: * Getter for <code>parser</code>.
375: * @return Returns the parser.
376: */
377: public Parser getParser() {
378: return this .parser;
379: }
380:
381: /**
382: * Setter for <code>chkattrs</code>.
383: * @param chkattrs The chkattrs to set.
384: */
385: public void setChkattrs(TagCheck chkattrs) {
386: this .chkattrs = chkattrs;
387: }
388:
389: /**
390: * Getter for <code>versions</code>.
391: * @return Returns the versions.
392: */
393: public short getVersions() {
394: return this .versions;
395: }
396:
397: /**
398: * Setter for <code>parser</code>.
399: * @param parser The parser to set.
400: */
401: public void setParser(Parser parser) {
402: this.parser = parser;
403: }
404: }
|