Source Code Cross Referenced for Utils.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » text » html » parser » 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 » Apache Harmony Java SE » javax package » javax.swing.text.html.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Evgeniya G. Maenkova
019:         * @version $Revision$
020:         */package javax.swing.text.html.parser;
021:
022:        import java.io.BufferedOutputStream;
023:        import java.io.ByteArrayInputStream;
024:        import java.io.ByteArrayOutputStream;
025:        import java.io.DataInputStream;
026:        import java.io.FileInputStream;
027:        import java.io.IOException;
028:        import java.io.InputStreamReader;
029:        import java.io.ObjectInputStream;
030:        import java.io.ObjectOutputStream;
031:        import java.io.Reader;
032:        import java.lang.reflect.Field;
033:        import java.util.BitSet;
034:        import java.util.Vector;
035:
036:        import javax.swing.SwingTestCase;
037:        import javax.swing.text.BadLocationException;
038:        import javax.swing.text.ChangedCharSetException;
039:        import javax.swing.text.MutableAttributeSet;
040:        import javax.swing.text.SimpleAttributeSet;
041:        import javax.swing.text.html.HTML;
042:        import javax.swing.text.html.HTMLEditorKit;
043:        import javax.swing.text.html.HTML.Tag;
044:
045:        import junit.framework.TestCase;
046:
047:        public class Utils {
048:            static Field[] dtdConstantsFields;
049:            static String[] dtdConstantsNames;
050:
051:            public static String[] getDTDConstantsNames() {
052:                if (dtdConstantsFields == null) {
053:                    dtdConstantsFields = DTDConstants.class.getDeclaredFields();
054:                }
055:                if (dtdConstantsNames == null) {
056:                    dtdConstantsNames = new String[dtdConstantsFields.length];
057:                    for (int i = 0; i < dtdConstantsFields.length; i++) {
058:                        dtdConstantsNames[i] = dtdConstantsFields[i].getName();
059:                    }
060:                }
061:                return dtdConstantsNames;
062:            }
063:
064:            public static String attrToString(final AttributeList attl) {
065:                if (attl == null) {
066:                    return null;
067:                }
068:                ;
069:                String result = attl + "[" + attl.value + "]:";
070:                if (attl.values == null) {
071:                    return result;
072:                }
073:                for (int i = 0; i < attl.values.size(); i++) {
074:                    result += attl.values.get(i) + ",";
075:                }
076:                if (attl.next == null) {
077:                    return result;
078:                }
079:                return result + "!" + attrToString(attl.next);
080:            }
081:
082:            public static void printElement(final Element e, final String descr) {
083:                String offset = "   ";
084:                System.out.println(offset + descr);
085:                System.out.println(offset + "name: " + e.getName());
086:                System.out.println(offset + "type: " + e.getType());
087:                System.out.println(offset + "oStart: " + e.omitStart());
088:                System.out.println(offset + "oEnd: " + e.omitEnd());
089:                System.out.println(offset + "content: " + e.content);
090:                System.out.println(offset + "exclusions: " + e.exclusions);
091:                System.out.println(offset + "inclusions: " + e.inclusions);
092:                //System.out.println(offset + "atts: " + e.atts.paramString());
093:                System.out.println(offset + "data: " + e.data);
094:                System.out.println(offset + "index: " + e.index);
095:            }
096:
097:            public static void printEntity(final Entity e, final String descr) {
098:                String offset = "   ";
099:                System.out.println(offset + descr);
100:                System.out.println(offset + "name: " + e.getName());
101:                System.out.println(offset + "type: " + (int) e.type + " "
102:                        + e.getType());
103:                System.out.println(offset + "data: " + String.valueOf(e.data));
104:                System.out.println(offset + "isParameter: " + e.isParameter());
105:                System.out.println(offset + "isGeneral: " + e.isGeneral());
106:            }
107:
108:            public static void printContentModel(
109:                    final ContentModel contentModel, final Object content,
110:                    final int type, final ContentModel next,
111:                    final boolean isEmpty, final Element first,
112:                    final Object objUnderTest, final boolean canBeFirst) {
113:                System.out.println(content + " " + contentModel.content);
114:                System.out.println(content.hashCode() + " "
115:                        + contentModel.content.hashCode());
116:                System.out
117:                        .println((char) type + " " + (char) contentModel.type);
118:                System.out.println(next + " " + contentModel.next);
119:                System.out.println(isEmpty + " " + contentModel.empty());
120:                System.out.println(canBeFirst + " "
121:                        + contentModel.first(objUnderTest));
122:                System.out.println(first + " " + contentModel.first());
123:            }
124:
125:            public static void checkElement(final Element elem,
126:                    final AttributeList atts, final ContentModel model,
127:                    final Object data, final BitSet inclusions,
128:                    final BitSet exclusions, final int index,
129:                    final String name, final boolean oEnd,
130:                    final boolean oStart, final int type) {
131:                checkElement(elem, atts, model, data, inclusions, exclusions,
132:                        index, name, oEnd, oStart, type, true);
133:            }
134:
135:            public static Object doSerialization(final Object data) {
136:                try {
137:                    ByteArrayOutputStream outByte = new ByteArrayOutputStream();
138:                    BufferedOutputStream buffOut = new BufferedOutputStream(
139:                            outByte);
140:                    ObjectOutputStream output = new ObjectOutputStream(buffOut);
141:                    output.writeObject(data);
142:                    output.flush();
143:                    buffOut.flush();
144:                    ByteArrayInputStream inptByte = new ByteArrayInputStream(
145:                            outByte.toByteArray());
146:                    ObjectInputStream input = new ObjectInputStream(inptByte);
147:                    return input.readObject();
148:                } catch (Exception e) {
149:                    e.printStackTrace();
150:                    TestCase.assertFalse("unexpected Exception", true);
151:                }
152:
153:                return null;
154:            }
155:
156:            public static void checkElement(final Element elem,
157:                    final AttributeList atts, final ContentModel model,
158:                    final Object data, final BitSet inclusions,
159:                    final BitSet exclusions, final int index,
160:                    final String name, final boolean oEnd,
161:                    final boolean oStart, final int type, boolean isStrongCheck) {
162:                if (isStrongCheck) {
163:                    TestCase.assertEquals(atts, elem.atts);
164:                    TestCase.assertEquals(model, elem.content);
165:                    TestCase.assertEquals(atts, elem.getAttributes());
166:                    TestCase.assertEquals(model, elem.getContent());
167:                }
168:
169:                TestCase.assertEquals(data, elem.data);
170:                TestCase.assertEquals(inclusions, elem.inclusions);
171:                TestCase.assertEquals(exclusions, elem.exclusions);
172:                TestCase.assertEquals(index, elem.index);
173:                TestCase.assertEquals(name, elem.name);
174:                TestCase.assertEquals(oEnd, elem.oEnd);
175:                TestCase.assertEquals(oStart, elem.oStart);
176:                TestCase.assertEquals(type, elem.type);
177:                TestCase.assertEquals(index, elem.getIndex());
178:                TestCase.assertEquals(name, elem.getName());
179:                TestCase.assertEquals(oEnd, elem.omitEnd());
180:                TestCase.assertEquals(oStart, elem.omitStart());
181:                TestCase.assertEquals(type, elem.getType());
182:            }
183:
184:            public static void checkDTDDefaultElement(final Element elem,
185:                    final String name, final int index) {
186:
187:                TestCase.assertNull(elem.atts);
188:                TestCase.assertNull(elem.content);
189:                TestCase.assertNull(elem.data);
190:                TestCase.assertNull(elem.inclusions);
191:                TestCase.assertNull(elem.exclusions);
192:                TestCase.assertEquals(index, elem.index);
193:                TestCase.assertEquals(name, elem.name);
194:                TestCase.assertFalse(elem.oEnd);
195:                TestCase.assertFalse(elem.oStart);
196:                TestCase.assertEquals(19, elem.type);
197:            }
198:
199:            public static void checkAttributeList(final AttributeList attl,
200:                    final int modifier, final int type, final String name,
201:                    final AttributeList next, final Vector values,
202:                    final String value, final boolean isStrongCheck) {
203:                TestCase.assertEquals(modifier, attl.getModifier());
204:                TestCase.assertEquals(name, attl.getName());
205:                TestCase.assertEquals(type, attl.getType());
206:                TestCase.assertEquals(value, attl.getValue());
207:                TestCase.assertEquals(values, attl.values);
208:                if (isStrongCheck || next == null) {
209:                    TestCase.assertEquals(next, attl.getNext());
210:                } else {
211:                    AttributeList attrList = attl.getNext();
212:                    TestCase
213:                            .assertEquals(next.modifier, attrList.getModifier());
214:                    TestCase.assertEquals(next.name, attrList.getName());
215:                    TestCase.assertEquals(next.type, attrList.getType());
216:                    TestCase.assertEquals(next.value, attrList.getValue());
217:                    TestCase.assertEquals(next.values, attrList.values);
218:                }
219:            }
220:
221:            public static void checkContentModel(
222:                    final ContentModel contentModel, final Object content,
223:                    final int type, final ContentModel next) {
224:                TestCase.assertEquals("content", content, contentModel.content);
225:                TestCase.assertEquals("type", type, contentModel.type);
226:                TestCase.assertEquals("next", next, contentModel.next);
227:            }
228:
229:            public static void initElement(final Element elem,
230:                    final AttributeList atts, final ContentModel model,
231:                    final Object data, final BitSet inclusions,
232:                    final BitSet exclusions, final int index,
233:                    final String name, final boolean oEnd,
234:                    final boolean oStart, final int type) {
235:                elem.atts = atts;
236:                elem.content = model;
237:                elem.data = data;
238:                elem.inclusions = inclusions;
239:                elem.exclusions = exclusions;
240:                elem.index = index;
241:                elem.name = name;
242:                elem.oEnd = oEnd;
243:                elem.oStart = oStart;
244:                elem.type = type;
245:            }
246:
247:            public static void checkEntity(final Entity entity,
248:                    final String name, final int type, final String data,
249:                    final boolean isGeneral, final boolean isParameter) {
250:                TestCase.assertEquals(name, entity.name);
251:                //TestCase.assertEquals(type, entity.type);
252:                TestCase.assertEquals(data, String.valueOf(entity.data));
253:                TestCase.assertEquals(name, entity.getName());
254:                TestCase.assertEquals(type, entity.getType()); //TODO 65536
255:                TestCase.assertEquals(data, entity.getString());
256:                TestCase.assertEquals(isGeneral, entity.isGeneral());
257:                TestCase.assertEquals(isParameter, entity.isParameter());
258:            }
259:
260:            public static void checkEntity(final Entity entity,
261:                    final String name, final int type, final char data,
262:                    final boolean isGeneral, final boolean isParameter) {
263:                TestCase.assertEquals(name, entity.name);
264:                TestCase.assertEquals(1, entity.data.length);
265:                TestCase.assertEquals(data, entity.data[0]);
266:                TestCase.assertEquals(name, entity.getName());
267:                TestCase.assertEquals(type, entity.getType()); //TODO 65536
268:                TestCase.assertEquals(isGeneral, entity.isGeneral());
269:                TestCase.assertEquals(isParameter, entity.isParameter());
270:            }
271:
272:            public static Reader getReader(final String testName) {
273:                Reader result = null;
274:                try {
275:                    FileInputStream fis = new FileInputStream(System
276:                            .getProperty("TEST_SRC_DIR")
277:                            + "javax/swing/text/html/parser/"
278:                            + testName
279:                            + ".html");
280:                    result = new InputStreamReader(fis);
281:                } catch (IOException e) {
282:                    e.printStackTrace();
283:                }
284:                return result;
285:            }
286:
287:            static DTD dtd;
288:
289:            public static DTD getDefaultDTDInstance() {
290:                DTD dtd = new DTD("test") {
291:                    public Element getElement(final int index) {
292:                        return super .getElement(index);
293:                    }
294:
295:                    public Element getElement(final String name) {
296:                        Element result = super .getElement(name);
297:                        return result;
298:                    }
299:                };
300:
301:                return dtd;
302:            }
303:
304:            public static DTD getFilledDTD() {
305:                //        if (SwingTestCase.isHarmony())  {
306:                //            DTD dtd = new DTD("test");
307:                //            DTDUtilities.initDTD(dtd);
308:                //            return dtd;
309:                //        }
310:
311:                DTD dtd = getDefaultDTDInstance();
312:                fillDTD(dtd);
313:                return dtd;
314:            }
315:
316:            public static void fillDTD(final DTD dtd) {
317:                String name = SwingTestCase.isHarmony() ? "transitional401.bdtd"
318:                        : "html32.bdtd";
319:                try {
320:                    dtd.read(new DataInputStream(dtd.getClass()
321:                            .getResourceAsStream(name)));
322:                } catch (IOException e) {
323:                    e.printStackTrace();
324:                    TestCase.assertFalse("Unexpected IOException", true);
325:                }
326:            }
327:
328:            public static DTD getDefaultDTD() {
329:                if (dtd == null) {
330:                    dtd = getDefaultDTDInstance();
331:                }
332:                return dtd;
333:            }
334:
335:            public static void printDebugInfo(final String msg,
336:                    final boolean condition) {
337:                if (condition) {
338:                    System.out.println(msg);
339:                }
340:            }
341:
342:            //TODO add checking position for atts && pos &&
343:            public static class ParserCallback extends
344:                    HTMLEditorKit.ParserCallback {
345:                public final boolean debugOut = true;
346:
347:                public Utils.ExtDocumentParser parserForCheck;
348:
349:                public boolean checkArguments = false;
350:
351:                public void checkArguments(final int pos, final HTML.Tag tag) {
352:                    if (checkArguments) {
353:                        TestCase.assertEquals(parserForCheck.pos_d, pos);
354:                        TestCase.assertEquals(parserForCheck.tag_d, tag);
355:                    }
356:                }
357:
358:                public void checkArguments(final int pos) {
359:                    if (checkArguments) {
360:                        TestCase.assertEquals(parserForCheck.pos_d, pos);
361:                    }
362:                }
363:
364:                public void checkArguments(final HTML.Tag tag) {
365:                    if (checkArguments) {
366:                        TestCase.assertEquals(parserForCheck.tag_d, tag);
367:                    }
368:                }
369:
370:                public void setParser(final Utils.ExtDocumentParser parser) {
371:                    parserForCheck = parser;
372:                }
373:
374:                public void printDebugInfo(final String msg) {
375:                    Utils.printDebugInfo("Utils.ParserCallback:" + msg,
376:                            debugOut);
377:                }
378:
379:                public void flush() throws BadLocationException {
380:                    printDebugInfo("flush");
381:                    super .flush();
382:                }
383:
384:                public void handleComment(final char[] data, final int pos) {
385:                    printDebugInfo("handleComment(data=" + String.valueOf(data)
386:                            + ", " + "pos= " + pos + ")");
387:                    super .handleComment(data, pos);
388:                }
389:
390:                public void handleEndOfLineString(final String eol) {
391:                    printDebugInfo("handleEndOfLineString(eol=" + eol + ")");
392:                    super .handleEndOfLineString(eol);
393:                }
394:
395:                public void handleEndTag(final Tag tag, final int pos) {
396:                    printDebugInfo("handleEndTag(tag=" + tag + ", " + "pos="
397:                            + pos + ")");
398:                    super .handleEndTag(tag, pos);
399:                }
400:
401:                public void handleError(final String msg, final int pos) {
402:                    printDebugInfo("handleError(msg=" + msg + ", " + "pos="
403:                            + pos + ")");
404:                    super .handleError(msg, pos);
405:                }
406:
407:                public void handleSimpleTag(final Tag tag,
408:                        final MutableAttributeSet atts, final int pos) {
409:                    printDebugInfo("handleSimpleTag(tag=" + tag + ", "
410:                            + "atts=" + atts + ", " + "pos=" + pos + ")");
411:                    super .handleSimpleTag(tag, atts, pos);
412:                }
413:
414:                public void handleStartTag(final Tag tag,
415:                        final MutableAttributeSet atts, final int pos) {
416:                    checkArguments(tag);
417:                    printDebugInfo("handleStartTag(tag=" + tag + ", " + "atts="
418:                            + atts + ", " + "pos=" + pos + ")");
419:                    super .handleStartTag(tag, atts, pos);
420:                }
421:
422:                public void handleText(final char[] text, final int pos) {
423:                    printDebugInfo("handleText(data=" + String.valueOf(text)
424:                            + ", " + "pos= " + pos + ")");
425:                    super .handleText(text, pos);
426:                }
427:            }
428:
429:            public static class ExtParser extends Parser {
430:                public boolean debugOut = true;
431:
432:                public void printDebugInfo(final String msg) {
433:                    Utils.printDebugInfo("Utils.ExtParser:" + msg, debugOut);
434:                }
435:
436:                public ExtParser(final DTD dtd) {
437:                    super (dtd);
438:                }
439:
440:                protected void endTag(final boolean omitted) {
441:                    printDebugInfo("endTag()");
442:                    super .endTag(omitted);
443:                }
444:
445:                protected void error(final String msg) {
446:                    printDebugInfo("2.error: " + msg);
447:                    super .error(msg);
448:                }
449:
450:                protected void error(final String msg1, final String msg2) {
451:                    printDebugInfo("3.error: " + msg1 + " " + msg2);
452:                    super .error(msg1, msg2);
453:                }
454:
455:                protected void error(final String msg1, final String msg2,
456:                        final String msg3) {
457:                    printDebugInfo("4.error: " + msg1 + " " + msg2 + " " + msg3);
458:                    super .error(msg1, msg2, msg3);
459:                }
460:
461:                protected void error(final String msg1, final String msg2,
462:                        final String msg3, final String msg4) {
463:                    printDebugInfo("5.error: " + msg1 + " " + msg2 + " " + msg3
464:                            + " " + msg4);
465:                    super .error(msg1, msg2, msg3, msg4);
466:                }
467:
468:                protected void flushAttributes() {
469:                    printDebugInfo("6.flushAttributes");
470:                    super .flushAttributes();
471:                }
472:
473:                protected SimpleAttributeSet getAttributes() {
474:                    printDebugInfo("7.getAttributes");
475:                    return super .getAttributes();
476:                }
477:
478:                protected int getCurrentLine() {
479:                    printDebugInfo("8.getCurrentLine");
480:                    return super .getCurrentLine();
481:                }
482:
483:                protected int getCurrentPos() {
484:                    printDebugInfo("9.getCurrentLine");
485:                    return super .getCurrentPos();
486:                }
487:
488:                protected void handleComment(final char[] text) {
489:                    super .handleComment(text);
490:                    printDebugInfo("10.handleComment: " + new String(text));
491:
492:                }
493:
494:                protected void handleEmptyTag(final TagElement elem)
495:                        throws ChangedCharSetException {
496:                    printDebugInfo("11.handleEmptyTag");
497:                    super .handleEmptyTag(elem);
498:                }
499:
500:                protected void handleEndTag(final TagElement elem) {
501:                    printDebugInfo("12.handleEndTag");
502:                    super .handleEndTag(elem);
503:                }
504:
505:                protected void handleEOFInComment() {
506:                    printDebugInfo("13.handleEOFInComment");
507:                    super .handleEOFInComment();
508:                }
509:
510:                protected void handleError(final int pos, final String msg) {
511:                    printDebugInfo("14.handleError: " + pos + " " + msg);
512:                    super .handleError(pos, msg);
513:                }
514:
515:                protected void handleStartTag(final TagElement elem) {
516:                    printDebugInfo("15.handleStartTag " + elem.getElement());
517:                    AttributeList attList = elem.getElement().getAttributes();
518:                    if (attList != null) {
519:                        printDebugInfo("..." + attList.getName() + " "
520:                                + attList.getValue());
521:                    }
522:                    super .handleStartTag(elem);
523:                }
524:
525:                protected void handleText(final char[] text) {
526:                    printDebugInfo("16.handleText: " + new String(text));
527:                    super .handleText(text);
528:                }
529:
530:                protected void handleTitle(final char[] text) {
531:                    printDebugInfo("17.handleTitle: " + new String(text));
532:                    super .handleTitle(text);
533:                }
534:
535:                protected TagElement makeTag(final Element elem) {
536:                    printDebugInfo("18.makeTag(1)" + elem);
537:                    //printElement(elem, "");
538:                    return super .makeTag(elem);
539:                }
540:
541:                protected TagElement makeTag(final Element elem,
542:                        final boolean functional) {
543:                    printDebugInfo("19.makeTag(2)" + functional + " " + elem);
544:                    //printElement(elem, "");
545:                    return super .makeTag(elem, functional);
546:                }
547:
548:                protected void markFirstTime(final Element elem) {
549:                    printDebugInfo("20.markFirstTime");
550:                    super .markFirstTime(elem);
551:                }
552:
553:                protected boolean parseMarkupDeclarations(final StringBuffer buf)
554:                        throws IOException {
555:                    printDebugInfo("21.parseMarkupDeclarations");
556:                    return super .parseMarkupDeclarations(buf);
557:                }
558:
559:                protected void startTag(final TagElement elem)
560:                        throws ChangedCharSetException {
561:                    printDebugInfo("22.startTag " + elem.getHTMLTag());
562:                    /*System.out.println("__________________________ _");
563:                    Utils.printElement(elem.getElement()," ");
564:                    System.out.println("____________________________"); */
565:                    super .startTag(elem);
566:                }
567:            }
568:
569:            public static class ExtDTD extends DTD {
570:                public boolean debugOut = true;
571:
572:                ExtDTD(final String name) {
573:                    super (name);
574:                }
575:
576:                public void printDebugInfo(final String msg) {
577:                    Utils.printDebugInfo("Utils:ExtDTD:" + msg, debugOut);
578:
579:                }
580:
581:                protected AttributeList defAttributeList(final String arg0,
582:                        final int arg1, final int arg2, final String arg3,
583:                        final String arg4, final AttributeList arg5) {
584:                    AttributeList result = super .defAttributeList(arg0, arg1,
585:                            arg2, arg3, arg4, arg5);
586:                    printDebugInfo("defAttributeList=" + result);
587:                    return result;
588:                }
589:
590:                protected ContentModel defContentModel(final int arg0,
591:                        final Object arg1, final ContentModel arg2) {
592:                    ContentModel result = super .defContentModel(arg0, arg1,
593:                            arg2);
594:                    printDebugInfo("defContentModel=" + result);
595:                    return result;
596:                }
597:
598:                protected Element defElement(final String name, final int type,
599:                        final boolean o1, final boolean o2,
600:                        final ContentModel model, final String[] excl,
601:                        final String[] incl, final AttributeList atts) {
602:                    Element e = super .defElement(name, type, o1, o2, model,
603:                            excl, incl, atts);
604:                    printDebugInfo("defElement(str)=" + e);
605:                    Utils.printElement(e, "(defElement)");
606:                    return e;
607:                }
608:
609:                public Entity defEntity(final String arg0, final int arg1,
610:                        final int arg2) {
611:                    Entity result = super .defEntity(arg0, arg1, arg2);
612:                    printDebugInfo("defEntity=" + result);
613:                    return result;
614:                }
615:
616:                protected Entity defEntity(final String arg0, final int arg1,
617:                        final String arg2) {
618:                    Entity result = super .defEntity(arg0, arg1, arg2);
619:                    printDebugInfo("defEntity=" + result);
620:                    return result;
621:                }
622:
623:                public void defineAttributes(final String arg0,
624:                        final AttributeList arg1) {
625:                    printDebugInfo("defineAttributes");
626:                    super .defineAttributes(arg0, arg1);
627:                }
628:
629:                public Element defineElement(final String name, final int type,
630:                        final boolean o1, final boolean o2,
631:                        final ContentModel model, final BitSet excl,
632:                        final BitSet incl, final AttributeList atts) {
633:
634:                    Element e = super .defineElement(name, type, o1, o2, model,
635:                            excl, incl, atts);
636:                    printDebugInfo("defineElement=" + e);
637:                    //Utils.printElement(e, "(defineElement)");
638:                    return e;
639:                }
640:
641:                public Entity defineEntity(final String arg0, final int arg1,
642:                        final char[] arg2) {
643:                    Entity result = super .defineEntity(arg0, arg1, arg2);
644:                    printDebugInfo("defineEntity=" + result);
645:                    return result;
646:                }
647:
648:                public Element getElement(final int arg0) {
649:                    Element result = super .getElement(arg0);
650:                    printDebugInfo("getElement(int)=" + result);
651:                    return result;
652:                }
653:
654:                public Element getElement(final String arg0) {
655:                    Element result = super .getElement(arg0);
656:                    printDebugInfo("getElement(str)=" + result);
657:                    return result;
658:                }
659:
660:                public Entity getEntity(final int arg0) {
661:                    Entity result = super .getEntity(arg0);
662:                    printDebugInfo("getEntity(int)=" + result);
663:                    return result;
664:                }
665:
666:                public Entity getEntity(final String arg0) {
667:                    Entity result = super .getEntity(arg0);
668:                    printDebugInfo("getEntity(str)=" + result);
669:                    return result;
670:                }
671:
672:                public String getName() {
673:                    printDebugInfo("getName " + super .getName());
674:                    return super .getName();
675:                }
676:
677:                public void read(final DataInputStream arg0) throws IOException {
678:                    printDebugInfo("read");
679:                    super .read(arg0);
680:                }
681:
682:                public String toString() {
683:                    printDebugInfo("toString");
684:                    return super .toString();
685:                }
686:            }
687:
688:            public static class ExtDocumentParser extends DocumentParser {
689:                public boolean debugOut = true;
690:
691:                public int pos_d;
692:
693:                public HTML.Tag tag_d;
694:
695:                public ExtDocumentParser(final DTD dtd) {
696:                    super (dtd);
697:                }
698:
699:                public void printDebugInfo(final String msg) {
700:                    Utils.printDebugInfo("Utils.ExtDocumentParser:" + msg,
701:                            debugOut);
702:                }
703:
704:                protected void handleComment(final char[] text) {
705:                    printDebugInfo("handleComment(text=" + String.valueOf(text)
706:                            + ")");
707:                    super .handleComment(text);
708:                }
709:
710:                protected void handleEmptyTag(final TagElement tagElement)
711:                        throws ChangedCharSetException {
712:                    printDebugInfo("handleEmptyTag(tag=" + tagElement + ")");
713:                    super .handleEmptyTag(tagElement);
714:                }
715:
716:                protected void handleEndTag(final TagElement tagElement) {
717:                    printDebugInfo("handleEndTag(tag=" + tagElement + ")");
718:                    super .handleEndTag(tagElement);
719:                }
720:
721:                protected void handleError(final int pos, final String msg) {
722:                    printDebugInfo("handleError(pos=" + pos + ", msg=" + ")");
723:                    super .handleError(pos, msg);
724:                }
725:
726:                protected void handleStartTag(final TagElement tagElement) {
727:                    printDebugInfo("handleStartTag(" + tagElement + ")");
728:                    pos_d = getCurrentPos();
729:                    tag_d = tagElement.getHTMLTag();
730:                    super .handleStartTag(tagElement);
731:                }
732:
733:                protected void handleText(final char[] text) {
734:                    printDebugInfo("handleText(text=" + String.valueOf(text)
735:                            + ")");
736:                    super .handleText(text);
737:                }
738:
739:                public void parse(final Reader reader,
740:                        final HTMLEditorKit.ParserCallback cb,
741:                        final boolean ichs) throws IOException {
742:                    printDebugInfo("parse(reader=" + reader + ", cb=" + cb
743:                            + ", " + "ichs=" + ichs);
744:                    super.parse(reader, cb, ichs);
745:                }
746:            }
747:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.