Source Code Cross Referenced for TokenizerProperties.java in  » Parser » JTopas » de » susebox » jtopas » 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 » Parser » JTopas » de.susebox.jtopas 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * TokenizerProperties.java: store for tokenizer characteristics.
0003:         *
0004:         * Copyright (C) 2002 Heiko Blau
0005:         *
0006:         * This file belongs to the JTopas Library.
0007:         * JTopas is free software; you can redistribute it and/or modify it 
0008:         * under the terms of the GNU Lesser General Public License as published by the 
0009:         * Free Software Foundation; either version 2.1 of the License, or (at your 
0010:         * option) any later version.
0011:         *
0012:         * This software is distributed in the hope that it will be useful, but WITHOUT
0013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
0014:         * FITNESS FOR A PARTICULAR PURPOSE. 
0015:         * See the GNU Lesser General Public License for more details.
0016:         *
0017:         * You should have received a copy of the GNU Lesser General Public License along
0018:         * with JTopas. If not, write to the
0019:         *
0020:         *   Free Software Foundation, Inc.
0021:         *   59 Temple Place, Suite 330, 
0022:         *   Boston, MA 02111-1307 
0023:         *   USA
0024:         *
0025:         * or check the Internet: http://www.fsf.org
0026:         *
0027:         * Contact:
0028:         *   email: heiko@susebox.de 
0029:         */
0030:
0031:        package de.susebox.jtopas;
0032:
0033:        //-----------------------------------------------------------------------------
0034:        // Imports
0035:        //
0036:        import java.util.Iterator;
0037:
0038:        //-----------------------------------------------------------------------------
0039:        // Interface TokenizerProperties
0040:        //
0041:
0042:        /**<p>
0043:         * The interface <code>TokenizerProperties</code> declares constants and methods
0044:         * to maintain the characteristics of a {@link Tokenizer}, e. g. comments, keywords
0045:         * and special sequences. A <code>TokenizerProperties</code> implementation instance
0046:         * can be used by one or more {@link Tokenizer} instances.
0047:         *</p><p>
0048:         * A <code>TokenizerProperties</code> object that is used to parse Java or C code
0049:         * including line and column information, would be setup like this:
0050:         *<pre>
0051:         *    TokenizerProperties props = new StandardTokenizerProperties();
0052:         *
0053:         *    props.setParseFlags(Flags.F_COUNT_LINES);
0054:         *    props.addLineComment("//");
0055:         *    props.addBlockComment(TokenizerProperties.DEFAULT_BLOCK_COMMENT_START,
0056:         *                          TokenizerProperties.DEFAULT_BLOCK_COMMENT_END);
0057:         *    props.addString("\"", "\"", "\\");
0058:         *    props.addString("'", "'", "\\");
0059:         *    props.addSpecialSequence(">>");
0060:         *    props.addSpecialSequence("<<");
0061:         *    props.addSpecialSequence("++");
0062:         *    props.addSpecialSequence("--");
0063:         *    ...
0064:         *    props.addKeyword("class");
0065:         *    props.addKeyword("if");
0066:         *    props.addKeyword("then");
0067:         *    props.addKeyword("while");
0068:         *    props.addKeyword("do");
0069:         *    ...
0070:         *</pre>
0071:         *</p><p>
0072:         * Beside the dedicated method groups for comments, strings, keywords and
0073:         * special sequences (e.g. {@link #addKeyword}, {@link #removeKeyword} and 
0074:         * {@link #keywordExists}) there is a set of generic methods working with 
0075:         * {@link TokenizerProperty} objects:
0076:         *<ul><li>
0077:         *  {@link #addProperty}, 
0078:         *</li><li>
0079:         *  {@link #removeProperty} and 
0080:         *</li><li>
0081:         *  {@link #propertyExists}.
0082:         *</li></ul>
0083:         *</p><p>
0084:         * When adding a property through one of the <code>add...</code> calls without
0085:         * the <code>flags</code> parameter, the currently active flags of the 
0086:         * <code>TokenizerProperties</code> instance will be used for the property.
0087:         *</p><p>
0088:         * This interface is separated from the {@link Tokenizer} interface mainly to 
0089:         * distinguish between the more static information, the actual source of data
0090:         * and the tokenizing process. Especially in multithreaded environments where
0091:         * multible instances of "equal" tokenizers are run at the same time, it saves 
0092:         * both memory resources and setup effort to have one <code>TokenizerProperties</code>
0093:         * instance for all {@link Tokenizer} instances.
0094:         *</p><p>
0095:         * Beside its function as a store for lexical element descriptions, this interface
0096:         * also provides an event mechanism to notify all interested objects about changes
0097:         * (additions, modifications and removals) of such lexical element descriptions.
0098:         *</p><p>
0099:         * This interface partly replaces the older {@link de.susebox.java.util.Tokenizer}
0100:         * interface which is deprecated.
0101:         *</p>
0102:         *
0103:         * @see     Token
0104:         * @see     Tokenizer
0105:         * @see     TokenizerProperty
0106:         * @author  Heiko Blau
0107:         */
0108:        public interface TokenizerProperties {
0109:
0110:            //---------------------------------------------------------------------------
0111:            // default character classes
0112:            //
0113:
0114:            /** 
0115:             * Whitespaces are portions of the text, that contain one or more characters 
0116:             * that separate the significant parts of the text. Generally, a sequence of 
0117:             * whitespaces is equally represented by one single whitespace character. That 
0118:             * is the difference to separators.
0119:             *<br>
0120:             * The value of this constant contains the ASCII characters space, tab, carriage
0121:             * return and linefeed.
0122:             */
0123:            public static final String DEFAULT_WHITESPACES = " \t\r\n";
0124:
0125:            /** 
0126:             * Separators are otherwise not remarkable characters. An opening parenthesis 
0127:             * might be nessecary for a syntactically correct text, but without any special 
0128:             * meaning to the compiler, interpreter etc. after it has been detected.
0129:             *<br>
0130:             * The value of this constant includes all printable characters that are not
0131:             * alphanumeric and not whitespaces. Note, that adding one of the separator
0132:             * characters as a special sequence ({@link #addSpecialSequence}) takes 
0133:             * precedence.
0134:             */
0135:            public static final String DEFAULT_SEPARATORS = "\u0021\u0023-\u002f\u003a-\u0040\u005b-\u005e\u0060\u007b-\u007e";
0136:
0137:            /**
0138:             * Default starting sequence of a block comment (Java, C/C++).
0139:             */
0140:            public static final String DEFAULT_BLOCK_COMMENT_START = "/*";
0141:
0142:            /**
0143:             * Default end sequence of a block comment (Java, C/C++).
0144:             */
0145:            public static final String DEFAULT_BLOCK_COMMENT_END = "*/";
0146:
0147:            /**
0148:             * Default line comment seqence (Java, C++)
0149:             */
0150:            public static final String DEFAULT_LINE_COMMENT = "//";
0151:
0152:            /**
0153:             * The well-known string starting sequence " of C/C++, Java and other languages.
0154:             */
0155:            public static final String DEFAULT_STRING_START = "\"";
0156:
0157:            /**
0158:             * The well-known string ending sequence of C/C++, Java and other languages.
0159:             */
0160:            public static final String DEFAULT_STRING_END = DEFAULT_STRING_START;
0161:
0162:            /**
0163:             * The well-known escape sequence for strings in C/C++, Java and other languages.
0164:             */
0165:            public static final String DEFAULT_STRING_ESCAPE = "\\";
0166:
0167:            /**
0168:             * The well-known character starting sequence of C/C++, Java and other languages.
0169:             */
0170:            public static final String DEFAULT_CHAR_START = "'";
0171:
0172:            /**
0173:             * The well-known character ending sequence of C/C++, Java and other languages.
0174:             */
0175:            public static final String DEFAULT_CHAR_END = DEFAULT_CHAR_START;
0176:
0177:            /**
0178:             * The well-known escape sequence for character literals in C/C++, Java and other
0179:             * languages.
0180:             */
0181:            public static final String DEFAULT_CHAR_ESCAPE = DEFAULT_STRING_ESCAPE;
0182:
0183:            //---------------------------------------------------------------------------
0184:            // trivial property methods
0185:            //
0186:
0187:            /**
0188:             * Setting the control flags of the <code>TokenizerProperties</code>. Use a 
0189:             * combination of the {@link Flags} for the parameter.
0190:             *<br>
0191:             * This method sets the parse flags globally for all {@link Tokenizer} objects 
0192:             * sharing this <code>TokenizerProperties</code> instance. Some flags can be set 
0193:             * for single tokenizers separately.
0194:             *<br>
0195:             * When adding a property like a keyword without explicitely specifying flags,
0196:             * these properties are handled with the flags that were effective at the time
0197:             * of adding.
0198:             *<br>
0199:             * The method fires a {@link TokenizerPropertyEvent} of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
0200:             * each time it is called with different flag masks. The passed {@link TokenizerProperty}
0201:             * has the type {@link TokenizerProperty#PARSE_FLAG_MASK}.
0202:             *
0203:             * @param flags the parser control flags
0204:             */
0205:            public void setParseFlags(int flags);
0206:
0207:            /**
0208:             * Retrieving the parser control flags. A bitmask containing the {@link Flags}
0209:             * constants is returned. These flags are the ones set for all {@link Tokenizer}
0210:             * instances sharing this <code>TokenizerProperties</code> object and may be
0211:             * partially overridden in these tokenizers.
0212:             *
0213:             * @return the globally set parser control flags
0214:             * @see    #setParseFlags
0215:             */
0216:            public int getParseFlags();
0217:
0218:            /**
0219:             * Returns <code>true</code> if a given flag is set in the current parse flags.
0220:             * If the parameter contains more than one bit the method returns only 
0221:             * <code>true</code> if all bits are set.
0222:             *
0223:             * @param   flag  the flag to test
0224:             * @return  <code>true</code> if all bits in flag are set.
0225:             * @see     #setParseFlags
0226:             * @see     #getParseFlags
0227:             * @see     #isFlagSet(TokenizerProperty, int)
0228:             */
0229:            public boolean isFlagSet(int flag);
0230:
0231:            /**
0232:             * Checks if a given flag (see {@link Flags}) is set for the given {@link TokenizerProperty} 
0233:             * in the context of this <code>TokenizerProperties</code> instance.
0234:             *<br>
0235:             * The method uses the flag state of the <code>TokenizerProperty</code> object
0236:             * if it is contained in the flag mask of the property (see {@link TokenizerProperty#containsFlag}).
0237:             * Otherwise it falls back to the flag state set globally for this
0238:             * <code>TokenizerProperties</code> instance. 
0239:             *
0240:             * @param   prop  the {@link TokenizerProperty} concerned
0241:             * @param   flag  the flag to check (may contain more than one bit)
0242:             * @return  <code>true</code> if the flag is set either explicit in the property
0243:             *          or globally for this <code>TokenizerProperties</code> object, 
0244:             *          <code>false</code> otherwise
0245:             * @throws  NullPointerException if no property is given
0246:             */
0247:            public boolean isFlagSet(TokenizerProperty prop, int flag)
0248:                    throws NullPointerException;
0249:
0250:            //---------------------------------------------------------------------------
0251:            // whitespaces and single-character separators
0252:            //
0253:
0254:            /**
0255:             * Setting the whitespace character set of the tokenizer. Implementations should
0256:             * be able to operate on ranges like "a-z" when more than two whitespace characters 
0257:             * are neighbours in the UNICODE character set.
0258:             *<br>
0259:             * Whitespaces are sequences that have the same syntactical meaning as one
0260:             * single whitespace character would have. That means "     " (many spaces) is
0261:             * the same as " " (one space).
0262:             *<br>
0263:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0264:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} or 
0265:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} to all registered listeners
0266:             * (see {@link #addTokenizerPropertyListener}).
0267:             *<br>
0268:             * The method accepts an empty string to describe "no whitespaces".
0269:             *
0270:             * @param   whitespaces the whitespace set
0271:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0272:             *          ranges are specified (e.g. <code>"a-"</code>)
0273:             * @see     #getWhitespaces
0274:             * @see     #addWhitespaces
0275:             * @see     #removeWhitespaces
0276:             */
0277:            public void setWhitespaces(String whitespaces)
0278:                    throws IllegalArgumentException;
0279:
0280:            /**
0281:             * Adding new whitespaces to the existing set. This is a convenience method to
0282:             * complete the whitespace set without having to include the already known
0283:             * whitespaces (for instance the {@link #DEFAULT_WHITESPACES} set).
0284:             *<br>
0285:             * Whitespaces that are already known, are ignored (the new whitespaces are
0286:             * "merged" into the known set).
0287:             *<br>
0288:             * For more information see {@link #setWhitespaces}.
0289:             *
0290:             * @param   whitespaces   additional whitespaces for the whitespace set
0291:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0292:             *          ranges are specified (e.g. <code>"a-"</code>)
0293:             * @see     #getWhitespaces
0294:             * @see     #setWhitespaces
0295:             * @see     #removeWhitespaces
0296:             */
0297:            public void addWhitespaces(String whitespaces)
0298:                    throws IllegalArgumentException;
0299:
0300:            /**
0301:             * Removing whitespaces from the existing set. This is a convenience method to
0302:             * modify the whitespace set without having to reconstruct the probably major
0303:             * part of the whitespaces (for instance the {@link #DEFAULT_WHITESPACES} set).
0304:             * Especially, this method can be used to remove a known single whitespace 
0305:             * without bothering about the other whitespaces
0306:             *<br>
0307:             * Whitespaces that are not known, are ignored.
0308:             *<br>
0309:             * For more information see {@link #setWhitespaces}.
0310:             *
0311:             * @param   whitespaces   whitespaces to remove from the whitespace set
0312:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0313:             *          ranges are specified (e.g. <code>"a-"</code>)
0314:             * @see     #getWhitespaces
0315:             * @see     #setWhitespaces
0316:             * @see     #addWhitespaces
0317:             */
0318:            public void removeWhitespaces(String whitespaces)
0319:                    throws IllegalArgumentException;
0320:
0321:            /**
0322:             * Obtaining the whitespace character set. The set may contain ranges. The
0323:             * method may return an emtpy string, if no whitespaces are known.
0324:             *
0325:             * @see #setWhitespaces
0326:             * @return the currently active whitespace set
0327:             */
0328:            public String getWhitespaces();
0329:
0330:            /**
0331:             * Setting the separator set. This set may contain ranges. A range is a
0332:             * character (lower limit) followed by a '-' (minus) followed by a
0333:             * second character (upper limit). A range of "a-z" means: all characters in
0334:             * the UNICODE character set between and including 'a' and 'z'. The character
0335:             * '-' itself should be preceded by an escape character. Ranges should
0336:             * be used whenever possible since they speed up the parsing process.
0337:             *<br>
0338:             * Separators are characters that are significant for the syntax. A sequence
0339:             * of separators is <strong>NOT</strong> equal to one single separator. Thats 
0340:             * the difference to whitespaces.
0341:             *<br>
0342:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0343:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} or 
0344:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} to all registered listeners
0345:             * (see {@link #addTokenizerPropertyListener}).
0346:             *<br>
0347:             * The method accepts an empty string to describe "no separators".
0348:             *
0349:             * @param   separators   the set of separating characters
0350:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0351:             *          ranges are specified (e.g. <code>"[-"</code>)
0352:             * @see     #getSeparators
0353:             */
0354:            public void setSeparators(String separators)
0355:                    throws IllegalArgumentException;
0356:
0357:            /**
0358:             * Adding new separators to the existing set. This is a convenience method to
0359:             * complete the separator set without having to include the already known
0360:             * separators (for instance the {@link #DEFAULT_SEPARATORS} set).
0361:             *<br>
0362:             * Separators that are already known, are ignored (the new separators are
0363:             * "merged" into the known set).
0364:             *<br>
0365:             * For more information see {@link #setSeparators}.
0366:             *
0367:             * @param   separators   additional set of separating characters
0368:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0369:             *          ranges are specified (e.g. <code>"a-"</code>)
0370:             * @see     #getSeparators
0371:             * @see     #setSeparators
0372:             * @see     #removeSeparators
0373:             */
0374:            public void addSeparators(String separators)
0375:                    throws IllegalArgumentException;
0376:
0377:            /**
0378:             * Removing separators from the existing set. This is a convenience method to
0379:             * modify the separator set without having to reconstruct the probably major
0380:             * part of the separators (for instance the {@link #DEFAULT_SEPARATORS} set).
0381:             * Especially, this method can be used to remove a known single separator
0382:             * without bothering about the other separators.
0383:             *<br>
0384:             * Separators that are not known, are ignored.
0385:             *<br>
0386:             * For more information see {@link #setSeparators}.
0387:             *
0388:             * @param   separators   separating characters to remove from the separator set
0389:             * @throws  IllegalArgumentException when <code>null</code> is passed or incomplete
0390:             *          ranges are specified (e.g. <code>"a-"</code>)
0391:             * @see     #getSeparators
0392:             * @see     #setSeparators
0393:             * @see     #addSeparators
0394:             */
0395:            public void removeSeparators(String separators)
0396:                    throws IllegalArgumentException;
0397:
0398:            /**
0399:             * Obtaining the separator set of the <code>TokenizerProperties</code>. The set 
0400:             * may contain ranges or may be empty.
0401:             *
0402:             * @return the currently used set of separating characters
0403:             * @see #setSeparators
0404:             */
0405:            public String getSeparators();
0406:
0407:            //---------------------------------------------------------------------------
0408:            // string properties
0409:            //
0410:
0411:            /**
0412:             * Registering a string description. Strings are things like the primitive string 
0413:             * literals in C/C++, SQL varchar literals, but also the character literals 
0414:             * of C/C++ and Java.
0415:             *<br>
0416:             * If the given string starting sequence is already known to the parser,
0417:             * it will simply be re-registered. Using this method on a known string
0418:             * with an associated companion will remove that companion.
0419:             *<br>
0420:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0421:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0422:             * (see {@link #addTokenizerPropertyListener}) with the new string {@link TokenizerProperty}
0423:             * if the string is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
0424:             * if the string is re-registered.
0425:             *<br>
0426:             * Passing <code>null</code> or an empty string for the escape sequence means
0427:             * that no escapes are used in the described string element.
0428:             *
0429:             * @param   start     the starting sequence of a string
0430:             * @param   end       the finishing sequence of a string
0431:             * @param   escape    the escape sequence inside the string
0432:             * @throws  IllegalArgumentException when <code>null</code> or an empty string 
0433:             *          is passed for start or end
0434:             * @throws  UnsupportedOperationException if the method is not available for an
0435:             *          implementation of the <code>TokenizerProperties</code> interface
0436:             * @see     #addString(String, String, String, Object)
0437:             * @see     #addString(String, String, String, Object, int)
0438:             * @see     #removeString
0439:             */
0440:            public void addString(String start, String end, String escape)
0441:                    throws IllegalArgumentException,
0442:                    UnsupportedOperationException;
0443:
0444:            /**
0445:             * Registering a the sequences that are used for string-like text parts.
0446:             * This method supports also an information associated with the string,
0447:             * called the companion.
0448:             *<br>
0449:             * If the given string starting sequence is already known to the parser,
0450:             * it will simply be re-registered. Using this method on a known string
0451:             * with an associated companion will replace that companion against the given
0452:             * one.
0453:             *<br>
0454:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0455:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0456:             * (see {@link #addTokenizerPropertyListener}) with the new string {@link TokenizerProperty}
0457:             * if the string is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
0458:             * if the string is re-registered.
0459:             *<br>
0460:             * Passing <code>null</code> or an empty string for the escape sequence means
0461:             * that no escapes are used in the described string element.
0462:             *
0463:             * @param   start     the starting sequence of a string
0464:             * @param   end       the finishing sequence of a string
0465:             * @param   escape    the escape sequence inside the string
0466:             * @param   companion the associated information
0467:             * @throws  IllegalArgumentException when <code>null</code> or an empty string 
0468:             *          is passed for start or end
0469:             * @throws  UnsupportedOperationException if the method is not available for an
0470:             *          implementation of the <code>TokenizerProperties</code> interface
0471:             * @see     #addString(String, String, String)
0472:             * @see     #addString(String, String, String, Object, int)
0473:             * @see     #removeString
0474:             */
0475:            public void addString(String start, String end, String escape,
0476:                    Object companion) throws IllegalArgumentException;
0477:
0478:            /**
0479:             * Registering a the sequences that are used for string-like text parts.
0480:             * This method supports also an information associated with the string,
0481:             * called the companion.
0482:             *<br>
0483:             * If the given string starting sequence is already known to the parser,
0484:             * it will simply be re-registered. Using this method on a known string
0485:             * with an associated companion will replace that companion against the given
0486:             * one.
0487:             *<br>
0488:             * This version of <code>addString</code> supports a bitmask of the 
0489:             * {@link Flags} to modify the general tokenizer settings (see
0490:             * {@link #setParseFlags} for this special element.
0491:             *<br>
0492:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0493:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0494:             * (see {@link #addTokenizerPropertyListener}) with the new string {@link TokenizerProperty}
0495:             * if the string is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
0496:             * if the string is re-registered.
0497:             *<br>
0498:             * Passing <code>null</code> or an empty string for the escape sequence means
0499:             * that no escapes are used in the described string element.
0500:             *<br>
0501:             * A call to this method is equivalent to 
0502:             * <code>addString(start, end, escape, flags, flags)</code>.
0503:             *
0504:             * @param   start     the starting sequence of a string
0505:             * @param   end       the finishing sequence of a string
0506:             * @param   escape    the escape sequence inside the string
0507:             * @param   companion the associated information
0508:             * @param   flags     modification flags 
0509:             * @throws  IllegalArgumentException when <code>null</code> or an empty string 
0510:             *          is passed for start or end
0511:             * @throws  UnsupportedOperationException if the method is not available for an
0512:             *          implementation of the <code>TokenizerProperties</code> interface
0513:             * @see     #addString(String, String, String)
0514:             * @see     #addString(String, String, String, Object)
0515:             * @see     #addString(String, String, String, Object, int, int)
0516:             * @see     #removeString
0517:             */
0518:            public void addString(String start, String end, String escape,
0519:                    Object companion, int flags)
0520:                    throws IllegalArgumentException,
0521:                    UnsupportedOperationException;
0522:
0523:            /**
0524:             * Registering a string with a set of flags and an associated flag mask.
0525:             *<br>
0526:             * The method is an extension to {@link #addString(String, Object, int)} 
0527:             * having a bitmask for the flags that are explicitely specified for the block
0528:             * comment property. All other flag values (states) should be taken from the 
0529:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
0530:             *
0531:             * @param   start     the starting sequence of a string
0532:             * @param   end       the finishing sequence of a string
0533:             * @param   escape    the escape sequence inside the string
0534:             * @param   companion the associated information
0535:             * @param   flags     modification flags 
0536:             * @param   flagMask  flags that have valid values in the parameter <code>flags</code>
0537:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0538:             *          is passed for keyword
0539:             * @throws  UnsupportedOperationException if the method is not available for an
0540:             *          implementation of the <code>TokenizerProperties</code> interface
0541:             * @see     #addString(String, String, String)
0542:             * @see     #addString(String, String, String, Object)
0543:             * @see     #addString(String, String, String, Object, int)
0544:             * @see     #removeString
0545:             */
0546:            public void addString(String start, String end, String escape,
0547:                    Object companion, int flags, int flagMask)
0548:                    throws IllegalArgumentException,
0549:                    UnsupportedOperationException;
0550:
0551:            /**
0552:             * Removing a string description. The method does nothing if the string description
0553:             * identified by the given <code>start</code> sequence is not known to this
0554:             * <code>TokenizerProperties</code> instance. The method may throw an 
0555:             * {@link java.lang.IllegalArgumentException} if the given string start is
0556:             * <code>null</code> or empty.
0557:             *<br>
0558:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0559:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
0560:             * listeners (see {@link #addTokenizerPropertyListener}) if a string is actually 
0561:             * removed.
0562:             *
0563:             * @param   start   the starting sequence of a string
0564:             * @throws  IllegalArgumentException when <code>null</code> or an empty string 
0565:             *          is passed
0566:             */
0567:            public void removeString(String start)
0568:                    throws IllegalArgumentException;
0569:
0570:            /**
0571:             * Retrieving the information associated with a certain string. Only the 
0572:             * starting sequence is nessecary to identify the string. If the string is not 
0573:             * known to the parser, <code>null</code> will be returned.<br>
0574:             * If one needs to know if a string exists without a companion or if the string
0575:             * is unknown so far, use also the method {@link #stringExists}.
0576:             *
0577:             * @param   start   the starting sequence of a string
0578:             * @return  the associated information or <code>null</code>
0579:             * @throws  IllegalArgumentException when <code>null</code> or an emtpy string
0580:             *          is passed
0581:             */
0582:            public Object getStringCompanion(String start)
0583:                    throws IllegalArgumentException,
0584:                    UnsupportedOperationException;
0585:
0586:            /**
0587:             * Checks if the given starting sequence of the string is known to the parser.
0588:             * The method accepts both empty and <code>null</code> strings for <code>start</code>
0589:             * by returning <code>false</code>.
0590:             *<br>
0591:             * Note that there is no choice of parsing flags (different to the 
0592:             * {@link #addString(String, String, String, Object, int)} method), since it
0593:             * makes generally no sense to "overload" properties. A string might be introduced
0594:             * by the starting case-insensitive sequence <code>STR</code>, but there shouldn't
0595:             * be a case-sensitive start <code>str</code>.
0596:             *
0597:             * @param   start     the starting sequence of a string
0598:             * @return  <code>true</code> if the string is registered, 
0599:             *          <code>false</code> otherwise
0600:             */
0601:            public boolean stringExists(String start);
0602:
0603:            /**
0604:             * Get the full description of a string property starting with the given 
0605:             * prefix. The method returns <code>null</code> if the passed <code>start</code>
0606:             * parameter cannot be mapped to a known string description ({@link #stringExists}
0607:             * would return <code>false</code>). 
0608:             *
0609:             * @param start     the starting sequence of a string
0610:             * @return the full string description or <code>null</code>
0611:             * @throws IllegalArgumentException when <code>null</code> is passed
0612:             */
0613:            public TokenizerProperty getString(String start)
0614:                    throws IllegalArgumentException;
0615:
0616:            /**
0617:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
0618:             * objects. Each <code>TokenizerProperty</code> object contains the starting,
0619:             * finishing and escaping sequence of a string description and the companion if 
0620:             * it exists.
0621:             *
0622:             * @return enumeration of {@link TokenizerProperty} objects
0623:             */
0624:            public Iterator getStrings();
0625:
0626:            //---------------------------------------------------------------------------
0627:            // line and block comments
0628:            //
0629:
0630:            /**
0631:             * Registering a the starting sequence of a line comment. The line comment is
0632:             * a special type of whitespace. It starts with the given character sequence
0633:             * and contains all characters up to and including the next end-of-line
0634:             * character(s).<br>
0635:             * Although most languages have only one line comment sequence, it is possible
0636:             * to use more than one.<br>
0637:             * If the given line comment starting sequence is already known to the parser,
0638:             * it will simply be re-registered. Using this method on a known line comment
0639:             * with an associated companion will effectively remove the companion.
0640:             *
0641:             * @param   lineComment   the starting sequence of the line comment
0642:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0643:             *          is passed
0644:             * @throws  UnsupportedOperationException if the method is not available for an
0645:             *          implementation of the <code>TokenizerProperties</code> interface
0646:             * @see     #addLineComment(String, Object)
0647:             * @see     #addLineComment(String, Object, int)
0648:             * @see     #removeLineComment
0649:             */
0650:            public void addLineComment(String lineComment)
0651:                    throws IllegalArgumentException,
0652:                    UnsupportedOperationException;
0653:
0654:            /**
0655:             * Registering a the starting sequence of a line comment. The line comment is
0656:             * a special type of whitespace. It starts with the given character sequence
0657:             * and contains all characters up to and including the next end-of-line
0658:             * character(s).<br>
0659:             * Although most languages have only one line comment sequence, it is possible
0660:             * to use more than one.<br>
0661:             * This method supports also an information associated with the line comment,
0662:             * called the companion.<br>
0663:             * If the given line comment starting sequence is already known to the parser,
0664:             * it will simply be re-registered. Using this method on a known line comment
0665:             * with an associated companion will replace that companion against the given
0666:             * one.
0667:             *<br>
0668:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0669:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0670:             * (see {@link #addTokenizerPropertyListener}) with the new line comment
0671:             * {@link TokenizerProperty} if the line comment is a new one, or of type 
0672:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the line comment is 
0673:             * re-registered.
0674:             *
0675:             * @param   lineComment   the starting sequence of a line comment
0676:             * @param   companion     the associated information
0677:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0678:             *          is passed for lineComment
0679:             * @throws  UnsupportedOperationException if the method is not available for an
0680:             *          implementation of the <code>TokenizerProperties</code> interface
0681:             * @see     #addLineComment(String)
0682:             * @see     #addLineComment(String, Object, int)
0683:             * @see     #removeLineComment
0684:             */
0685:            public void addLineComment(String lineComment, Object companion)
0686:                    throws IllegalArgumentException,
0687:                    UnsupportedOperationException;
0688:
0689:            /**
0690:             * Registering a the starting sequence of a line comment. The line comment is
0691:             * a special type of whitespace. It starts with the given character sequence
0692:             * and contains all characters up to and including the next end-of-line
0693:             * character(s).
0694:             *<br>
0695:             * Although most languages have only one line comment sequence, it is possible
0696:             * to use more than one.
0697:             *<br>
0698:             * This method supports also an information associated with the line comment,
0699:             * called the companion.
0700:             *<br>
0701:             * If the given line comment starting sequence is already known to the parser,
0702:             * it will simply be re-registered. Using this method on a known line comment
0703:             * with an associated companion will replace that companion against the given
0704:             * one.
0705:             *<br>
0706:             * This version of <code>addLineComment</code> supports a bitmask of the 
0707:             * {@link Flags} to modify the general tokenizer settings (see
0708:             * {@link #setParseFlags}) for this special element.
0709:             *<br>
0710:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0711:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0712:             * (see {@link #addTokenizerPropertyListener}) with the new line comment
0713:             * {@link TokenizerProperty} if the line comment is a new one, or of type 
0714:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the line comment is 
0715:             * re-registered.
0716:             *<br>
0717:             * A call to this method is equivalent to 
0718:             * <code>addLineComment(lineComment, companion, flags, flags)</code>.
0719:             *
0720:             * @param   lineComment   the starting sequence of a line comment
0721:             * @param   companion     the associated information
0722:             * @param   flags         modification flags 
0723:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0724:             *          is passed for lineComment
0725:             * @throws  UnsupportedOperationException if the method is not available for an
0726:             *          implementation of the <code>TokenizerProperties</code> interface
0727:             * @see     #addLineComment(String)
0728:             * @see     #addLineComment(String, Object)
0729:             * @see     #addLineComment(String, Object, int, int)
0730:             * @see     #removeLineComment
0731:             */
0732:            public void addLineComment(String lineComment, Object companion,
0733:                    int flags) throws IllegalArgumentException,
0734:                    UnsupportedOperationException;
0735:
0736:            /**
0737:             * Registering a line comment with a set of flags and an associated flag mask.
0738:             *<br>
0739:             * The method is an extension to {@link #addLineComment(String, Object, int)} 
0740:             * having a bitmask for the flags that are explicitely specified for the block
0741:             * comment property. All other flag values (states) should be taken from the 
0742:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
0743:             *
0744:             * @param   lineComment   the starting sequence of a line comment
0745:             * @param   companion     the associated information
0746:             * @param   flags         modification flags 
0747:             * @param   flagMask      flags that have valid values in the parameter <code>flags</code>
0748:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0749:             *          is passed for keyword
0750:             * @throws  UnsupportedOperationException if the method is not available for an
0751:             *          implementation of the <code>TokenizerProperties</code> interface
0752:             * @see     #addLineComment(String)
0753:             * @see     #addLineComment(String, Object)
0754:             * @see     #addLineComment(String, Object, int)
0755:             * @see     #removeLineComment
0756:             */
0757:            public void addLineComment(String lineComment, Object companion,
0758:                    int flags, int flagMask) throws IllegalArgumentException,
0759:                    UnsupportedOperationException;
0760:
0761:            /**
0762:             * Removing a certain line comment. If the given comment is not known to this
0763:             * <code>TokenizerProperties</code> instance, the method does nothing.
0764:             *<br>
0765:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0766:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
0767:             * listeners if a line comment property is actually removed.
0768:             *
0769:             * @param   lineComment   the starting sequence of the line comment
0770:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0771:             *          is passed
0772:             * @see     #addLineComment(String)
0773:             * @see     #addLineComment(String, Object)
0774:             * @see     #addLineComment(String, Object, int)
0775:             */
0776:            public void removeLineComment(String lineComment)
0777:                    throws IllegalArgumentException;
0778:
0779:            /**
0780:             * Retrieving the associated object of a certain line comment. If the given
0781:             * starting sequence of a line comment is not known to the parser, then the
0782:             * method returns <code>null</code>.<br>
0783:             * To distinguish between an unknown line comment and companion-less line
0784:             * comment, use the method {@link #lineCommentExists}.
0785:             *
0786:             * @param   lineComment   the starting sequence of the line comment
0787:             * @return  the object    associated with the line comment
0788:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0789:             *          is passed for lineComment
0790:             * @see     #lineCommentExists
0791:             */
0792:            public Object getLineCommentCompanion(String lineComment)
0793:                    throws IllegalArgumentException;
0794:
0795:            /**
0796:             * Checks if the give line comment is known. The method accepts both empty and 
0797:             * <code>null</code> strings for <code>lineComment</code> by returning 
0798:             * <code>false</code>.
0799:             *
0800:             * @param   lineComment   the starting sequence of the line comment
0801:             * @return  <code>true</code> if the line comment is known, 
0802:             *          <code>false</code> otherwise
0803:             */
0804:            public boolean lineCommentExists(String lineComment);
0805:
0806:            /**
0807:             * Get the full description of a line comment property starting with the given 
0808:             * prefix. The method returns <code>null</code> if the passed <code>lineComment</code>
0809:             * parameter cannot be mapped to a known line comment description ({@link #lineCommentExists}
0810:             * would return <code>false</code>). 
0811:             *
0812:             * @param   lineComment   the starting sequence of the line comment
0813:             * @return  the full line comment description or <code>null</code>
0814:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0815:             *          is passed
0816:             * @see     #lineCommentExists
0817:             */
0818:            public TokenizerProperty getLineComment(String lineComment)
0819:                    throws IllegalArgumentException;
0820:
0821:            /**
0822:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
0823:             * objects. Each <code>TokenizerProperty</code> object contains one starting
0824:             * sequence of a line comment and its companion if it exists.
0825:             *
0826:             * @return enumeration of {@link TokenizerProperty} objects
0827:             */
0828:            public Iterator getLineComments();
0829:
0830:            /**
0831:             * Registering a block comment with the parser. This version takes only the starting
0832:             * and finishing sequence of the block comment.<br>
0833:             * If the given starting sequence is already known to the parser, the block 
0834:             * comment is simply re-registered. Using this method on a known block comment
0835:             * with an associated companion will remove that companion.
0836:             *<br>
0837:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0838:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0839:             * (see {@link #addTokenizerPropertyListener}) with the new block comment
0840:             * {@link TokenizerProperty} if the comment is a new one, or of type 
0841:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the comment is 
0842:             * re-registered.
0843:             *
0844:             * @param   start the starting sequence of the block comment
0845:             * @param   end   the finishing sequence of the block comment
0846:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0847:             *          is passed for start or end
0848:             * @throws  UnsupportedOperationException if the method is not available for an
0849:             *          implementation of the <code>TokenizerProperties</code> interface
0850:             * @see     #addBlockComment(String, String, Object)
0851:             * @see     #addBlockComment(String, String, Object, int)
0852:             * @see     #removeBlockComment
0853:             */
0854:            public void addBlockComment(String start, String end)
0855:                    throws IllegalArgumentException,
0856:                    UnsupportedOperationException;
0857:
0858:            /**
0859:             * Registering a block comment with the parser. Beside the obviously nessecary
0860:             * starting and finishing sequence of the block comment, it takes an object that
0861:             * is associated with the block comment, called the companion.<br>
0862:             * If the given starting sequence is already known to the parser, the block
0863:             * comment is simply re-registered. Using this method on a known block comment
0864:             * with an associated companion will replace that companion against the given
0865:             * one.
0866:             *<br>
0867:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0868:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0869:             * (see {@link #addTokenizerPropertyListener}) with the new block comment
0870:             * {@link TokenizerProperty} if the comment is a new one, or of type 
0871:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the comment is 
0872:             * re-registered.
0873:             *
0874:             * @param   start     the starting sequence of the block comment
0875:             * @param   end       the finishing sequence of the block comment
0876:             * @param   companion information object associated with this block comment
0877:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0878:             *          is passed for start or end
0879:             * @throws  UnsupportedOperationException if the method is not available for an
0880:             *          implementation of the <code>TokenizerProperties</code> interface
0881:             * @see     #addBlockComment(String, String)
0882:             * @see     #addBlockComment(String, String, Object, int)
0883:             * @see     #removeBlockComment
0884:             */
0885:            public void addBlockComment(String start, String end,
0886:                    Object companion) throws IllegalArgumentException,
0887:                    UnsupportedOperationException;
0888:
0889:            /**
0890:             * Registering a block comment. Beside the obviously nessecary
0891:             * starting and finishing sequence of the block comment, it takes an object that
0892:             * is associated with the block comment, called the companion.
0893:             *<br>
0894:             * If the given starting sequence is already known to the parser, the block
0895:             * comment is simply re-registered. Using this method on a known block comment
0896:             * with an associated companion will replace that companion against the given
0897:             * one.
0898:             *<br>
0899:             * This version of <code>addBlockComment</code> supports a bitmask of the 
0900:             * {@link Flags} to modify the general tokenizer settings (see
0901:             * {@link #setParseFlags}) for this special element.
0902:             *<br>
0903:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0904:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
0905:             * (see {@link #addTokenizerPropertyListener}) with the new block comment
0906:             * {@link TokenizerProperty} if the comment is a new one, or of type 
0907:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the comment is 
0908:             * re-registered.
0909:             *<br>
0910:             * A call to this method is equivalent to 
0911:             * <code>addBlockComment(start, end, companion, flags, flags)</code>.
0912:             *
0913:             * @param   start     the starting sequence of the block comment
0914:             * @param   end       the finishing sequence of the block comment
0915:             * @param   companion information object associated with this block comment
0916:             * @param   flags     modification flags 
0917:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0918:             *          is passed for start or end
0919:             * @throws  UnsupportedOperationException if the method is not available for an
0920:             *          implementation of the <code>TokenizerProperties</code> interface
0921:             * @see     #addBlockComment(String, String)
0922:             * @see     #addBlockComment(String, String, Object)
0923:             * @see     #addBlockComment(String, String, Object, int, int)
0924:             * @see     #removeBlockComment
0925:             */
0926:            public void addBlockComment(String start, String end,
0927:                    Object companion, int flags)
0928:                    throws IllegalArgumentException,
0929:                    UnsupportedOperationException;
0930:
0931:            /**
0932:             * Registering a block comment with a set of flags and an associated flag mask.
0933:             *<br>
0934:             * The method is an extension to {@link #addBlockComment(String, String, Object, int)} 
0935:             * having a bitmask for the flags that are explicitely specified for the block
0936:             * comment property. All other flag values (states) should be taken from the 
0937:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
0938:             *
0939:             * @param   start     the starting sequence of the block comment
0940:             * @param   end       the finishing sequence of the block comment
0941:             * @param   companion information object associated with this block comment
0942:             * @param   flags     modification flags 
0943:             * @param   flagMask  flags that have valid values in the parameter <code>flags</code>
0944:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0945:             *          is passed for keyword
0946:             * @throws  UnsupportedOperationException if the method is not available for an
0947:             *          implementation of the <code>TokenizerProperties</code> interface
0948:             * @see     #addBlockComment(String, String)
0949:             * @see     #addBlockComment(String, String, Object)
0950:             * @see     #addBlockComment(String, String, Object, int)
0951:             * @see     #removeBlockComment
0952:             */
0953:            public void addBlockComment(String start, String end,
0954:                    Object companion, int flags, int flagMask)
0955:                    throws IllegalArgumentException,
0956:                    UnsupportedOperationException;
0957:
0958:            /**
0959:             * Removing a certain block comment. Only the starting sequence is nessecary
0960:             * to identify the block comment.
0961:             *<br>
0962:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
0963:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
0964:             * listeners if a block comment property is actually removed.
0965:             *
0966:             * @param   start   the starting sequence of the block comment
0967:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0968:             *          is passed
0969:             */
0970:            public void removeBlockComment(String start)
0971:                    throws IllegalArgumentException;
0972:
0973:            /**
0974:             * Retrieving a certain block comment. Only the starting sequence is nessecary
0975:             * to identify the block comment. If the block comment is not known to the 
0976:             * parser, then <code>null</code> is returned.<br>
0977:             * To distinguish between an unknown line comment and companion-less line 
0978:             * comment, use the method {@link #lineCommentExists}.
0979:             *
0980:             * @param   start   the starting sequence of the block comment
0981:             * @return  the associated object of the block comment
0982:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
0983:             *          is passed
0984:             */
0985:            public Object getBlockCommentCompanion(String start)
0986:                    throws IllegalArgumentException;
0987:
0988:            /**
0989:             * Checks if the give block comment is known. Only the starting sequence is 
0990:             * nessecary to identify the block comment.
0991:             * The method accepts both empty and <code>null</code> strings for <code>start</code>
0992:             * by returning <code>false</code>.
0993:             *
0994:             * @param   start   the starting sequence of the block comment
0995:             * @return  <code>true</code> if the block comment is known, 
0996:             *          <code>false</code> otherwise
0997:             */
0998:            public boolean blockCommentExists(String start);
0999:
1000:            /**
1001:             * Get the full description of a block comment property starting with the given 
1002:             * prefix. The method returns <code>null</code> if the passed <code>start</code>
1003:             * parameter cannot be mapped to a known block comment description ({@link #blockCommentExists}
1004:             * would return <code>false</code>). 
1005:             *
1006:             * @param   start   the starting sequence of the block comment
1007:             * @return  the full block comment description or <code>null</code>
1008:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1009:             *          is passed
1010:             */
1011:            public TokenizerProperty getBlockComment(String start)
1012:                    throws IllegalArgumentException;
1013:
1014:            /**
1015:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
1016:             * objects. Each <code>TokenizerProperty</code> object contains the starting and
1017:             * finishing sequence of a block comment and the companion if it exists.
1018:             *
1019:             * @return enumeration of {@link TokenizerProperty} objects
1020:             */
1021:            public Iterator getBlockComments();
1022:
1023:            //---------------------------------------------------------------------------
1024:            // special sequences
1025:            //
1026:
1027:            /**
1028:             * Registering a special sequence of characters. Such sequences may be multicharacter
1029:             * operators like the shift operators in Java.
1030:             *<br>
1031:             * Unlike keywords, special sequences act also as separators between other tokens.
1032:             * If one special sequence is the prefix of other special sequences (in Java the
1033:             * shift operator <code>&gt;&gt;</code> is the prefix of the shift operator
1034:             * <code>&gt;&gt;&gt;</code>), always the longest possible match is returned.
1035:             * Testing on special sequences takes place after whitespaces and comments are ruled
1036:             * out, but before ordinary separators are tested.
1037:             *<br>
1038:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1039:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1040:             * (see {@link #addTokenizerPropertyListener}) with the new special sequence
1041:             * {@link TokenizerProperty} if the sequence is a new one, or of type 
1042:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the sequence is 
1043:             * re-registered.
1044:             *
1045:             * @param   specSeq   special sequence to register
1046:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1047:             *          is passed
1048:             * @throws  UnsupportedOperationException if the method is not available for an
1049:             *          implementation of the <code>TokenizerProperties</code> interface
1050:             * @see     #addSpecialSequence(String, Object)
1051:             * @see     #addSpecialSequence(String, Object, int)
1052:             * @see     #removeSpecialSequence
1053:             */
1054:            public void addSpecialSequence(String specSeq)
1055:                    throws IllegalArgumentException,
1056:                    UnsupportedOperationException;
1057:
1058:            /**
1059:             * Registering a special sequence of characters. Such sequences may be multicharacter
1060:             * operators like the shift operators in Java.
1061:             *<br>
1062:             * Unlike keywords, special sequences act also as separators between other tokens.
1063:             * If one special sequence is the prefix of other special sequences (in Java the
1064:             * shift operator <code>&gt;&gt;</code> is the prefix of the shift operator
1065:             * <code>&gt;&gt;&gt;</code>), always the longest possible match is returned.
1066:             * Testing on special sequences takes place after whitespaces and comments are ruled
1067:             * out, but before ordinary separators are tested.
1068:             * This form of <code>addSpecialSequence</code> also takes an object associated with
1069:             * the special sequence, called the companion.
1070:             *<br>
1071:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1072:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1073:             * (see {@link #addTokenizerPropertyListener}) with the new special sequence
1074:             * {@link TokenizerProperty} if the sequence is a new one, or of type 
1075:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the sequence is 
1076:             * re-registered.
1077:             *
1078:             * @param   specSeq     special sequence to register
1079:             * @param   companion   information object associated with this special sequence
1080:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1081:             *          is passed for specSeq
1082:             * @throws  UnsupportedOperationException if the method is not available for an
1083:             *          implementation of the <code>TokenizerProperties</code> interface
1084:             * @see     #addSpecialSequence(String)
1085:             * @see     #addSpecialSequence(String, Object, int)
1086:             * @see     #removeSpecialSequence
1087:             */
1088:            public void addSpecialSequence(String specSeq, Object companion)
1089:                    throws IllegalArgumentException,
1090:                    UnsupportedOperationException;
1091:
1092:            /**
1093:             * Registering a special sequence of characters. Such sequences may be multicharacter
1094:             * operators like the shift operators in Java.
1095:             *<br>
1096:             * Unlike keywords, special sequences act also as separators between other tokens.
1097:             * If one special sequence is the prefix of other special sequences (in Java the
1098:             * shift operator <code>&gt;&gt;</code> is the prefix of the shift operator
1099:             * <code>&gt;&gt;&gt;</code>), always the longest possible match is returned.
1100:             * Testing on special sequences takes place after whitespaces and comments are ruled
1101:             * out, but before ordinary separators are tested.
1102:             * This form of <code>addSpecialSequence</code> also takes an object associated with
1103:             * the special sequence, called the companion.
1104:             *<br>
1105:             * This version of <code>addSpecialSequence</code> supports a bitmask of the 
1106:             * {@link Flags} to modify the general tokenizer settings (see
1107:             * {@link #setParseFlags}) for this special element.
1108:             *<br>
1109:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1110:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1111:             * (see {@link #addTokenizerPropertyListener}) with the new special sequence
1112:             * {@link TokenizerProperty} if the sequence is a new one, or of type 
1113:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the sequence is 
1114:             * re-registered.
1115:             *<br>
1116:             * A call to this method is equivalent to <code>addSpecialSequence(keyword, companion, flags, flags)</code>.
1117:             *
1118:             * @param   specSeq     special sequence to register
1119:             * @param   companion   information object associated with this special sequence
1120:             * @param   flags       modification flags 
1121:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1122:             *          is passed for specSeq
1123:             * @throws  UnsupportedOperationException if the method is not available for an
1124:             *          implementation of the <code>TokenizerProperties</code> interface
1125:             * @see     #addSpecialSequence(String)
1126:             * @see     #addSpecialSequence(String, Object)
1127:             * @see     #addSpecialSequence(String, Object, int, int)
1128:             * @see     #removeSpecialSequence
1129:             */
1130:            public void addSpecialSequence(String specSeq, Object companion,
1131:                    int flags) throws IllegalArgumentException,
1132:                    UnsupportedOperationException;
1133:
1134:            /**
1135:             * Registering a special sequence with a set of flags and an associated flag mask.
1136:             *<br>
1137:             * The method is an extension to {@link #addSpecialSequence(String, Object, int)} having
1138:             * a bitmask for the flags that are explicitely specified for the special sequence 
1139:             * property. All other flag values (states) should be taken from the 
1140:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
1141:             *
1142:             * @param   specSeq     special sequence to register
1143:             * @param   companion   information object associated with this special sequence
1144:             * @param   flags       modification flags 
1145:             * @param   flagMask    flags that have valid values in the parameter <code>flags</code>
1146:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1147:             *          is passed for keyword
1148:             * @throws  UnsupportedOperationException if the method is not available for an
1149:             *          implementation of the <code>TokenizerProperties</code> interface
1150:             * @see     #addSpecialSequence(String)
1151:             * @see     #addSpecialSequence(String, Object)
1152:             * @see     #addSpecialSequence(String, Object, int)
1153:             * @see     #removeSpecialSequence
1154:             */
1155:            public void addSpecialSequence(String specSeq, Object companion,
1156:                    int flags, int flagMask) throws IllegalArgumentException,
1157:                    UnsupportedOperationException;
1158:
1159:            /**
1160:             * Removing a special sequence property from the store. If the special sequence
1161:             * is not known, the method does nothing.
1162:             *<br>
1163:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1164:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
1165:             * listeners if a special sequence property is actually removed.
1166:             *
1167:             * @param   specSeq   sequence to remove
1168:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1169:             *          is passed
1170:             * @see     #addSpecialSequence(String)
1171:             * @see     #addSpecialSequence(String, Object)
1172:             * @see     #addSpecialSequence(String, Object, int)
1173:             */
1174:            public void removeSpecialSequence(String specSeq)
1175:                    throws IllegalArgumentException;
1176:
1177:            /**
1178:             * Retrieving the companion of the given special sequence. If the special
1179:             * sequence doesn't exist the method returns <code>null</code>.
1180:             *
1181:             * @param   specSeq   sequence to remove
1182:             * @return  the object associated with the special sequence
1183:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1184:             *          is passed
1185:             */
1186:            public Object getSpecialSequenceCompanion(String specSeq)
1187:                    throws IllegalArgumentException;
1188:
1189:            /**
1190:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
1191:             * objects. Each <code>TokenizerProperty</code> object contains a special
1192:             * sequence and the companion if it exists.
1193:             *
1194:             * @return enumeration of {@link TokenizerProperty} objects
1195:             */
1196:            public Iterator getSpecialSequences();
1197:
1198:            /**
1199:             * Checks if the given special sequence is known to the <code>TokenizerProperties</code>.
1200:             * The method accepts both empty and <code>null</code> strings for <code>specSeq</code>
1201:             * by returning <code>false</code>.
1202:             *
1203:             * @param   specSeq   sequence to check
1204:             * @return  <code>true</code> if the block comment is known,
1205:             *          <code>false</code> otherwise
1206:             */
1207:            public boolean specialSequenceExists(String specSeq);
1208:
1209:            /**
1210:             * Get the full description of a special sequence property. The method returns 
1211:             * <code>null</code> if the passed <code>specSeq</code> image is unknown
1212:             * ({@link #specialSequenceExists} would return <code>false</code>). 
1213:             *
1214:             * @param   specSeq sequence to find
1215:             * @return  the full sequence description or <code>null</code>
1216:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1217:             *          is passed
1218:             */
1219:            public TokenizerProperty getSpecialSequence(String specSeq)
1220:                    throws IllegalArgumentException;
1221:
1222:            //---------------------------------------------------------------------------
1223:            // keyword properties
1224:            //
1225:
1226:            /**
1227:             * Registering a keyword. If the keyword is already known to the <code>TokenizerProperties</code>
1228:             * then it is simply re-registered. If the known keyword has an associated 
1229:             * companion it will be removed.
1230:             *<br>
1231:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1232:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1233:             * (see {@link #addTokenizerPropertyListener}) with the new keyword
1234:             * {@link TokenizerProperty} if the keyword is a new one, or of type 
1235:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the keyword is 
1236:             * re-registered.
1237:             *
1238:             * @param   keyword   keyword to register
1239:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1240:             *          is passed
1241:             * @throws  UnsupportedOperationException if the method is not available for an
1242:             *          implementation of the <code>TokenizerProperties</code> interface
1243:             * @see #addKeyword(String, Object)
1244:             * @see #addKeyword(String, Object, int)
1245:             * @see #removeKeyword
1246:             */
1247:            public void addKeyword(String keyword)
1248:                    throws IllegalArgumentException,
1249:                    UnsupportedOperationException;
1250:
1251:            /**
1252:             * Registering a keyword. If the keyword is already known to the <code>TokenizerProperties</code>
1253:             * then it is simply re-registered. If the known keyword has an associated
1254:             * companion it will be replaced against the given one.
1255:             *<br>
1256:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1257:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1258:             * (see {@link #addTokenizerPropertyListener}) with the new keyword
1259:             * {@link TokenizerProperty} if the keyword is a new one, or of type 
1260:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the keyword is 
1261:             * re-registered.
1262:             *
1263:             * @param   keyword   keyword to register
1264:             * @param   companion information object associated with this keyword
1265:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1266:             *          is passed for <code>keyword</code>
1267:             * @throws  UnsupportedOperationException if the method is not available for an
1268:             *          implementation of the <code>TokenizerProperties</code> interface
1269:             * @see #addKeyword(String)
1270:             * @see #addKeyword(String, Object, int)
1271:             * @see #removeKeyword
1272:             */
1273:            public void addKeyword(String keyword, Object companion)
1274:                    throws IllegalArgumentException,
1275:                    UnsupportedOperationException;
1276:
1277:            /**
1278:             * Registering a keyword. If the keyword is already known to the <code>TokenizerProperties</code>
1279:             * then it is simply re-registered. If the known keyword has an associated
1280:             * companion it will be replaced against the given one.
1281:             *<br>
1282:             * This version of <code>addKeyword</code> supports a bitmask of the 
1283:             * {@link Flags} to modify the general tokenizer settings (see
1284:             * {@link #setParseFlags}) for this special element.
1285:             *<br>
1286:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1287:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1288:             * (see {@link #addTokenizerPropertyListener}) with the new keyword
1289:             * {@link TokenizerProperty} if the keyword is a new one, or of type 
1290:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} if the keyword is 
1291:             * re-registered.
1292:             *<br>
1293:             * A call to this method is equivalent to <code>addKeyword(keyword, companion, flags, flags)</code>.
1294:             *
1295:             * @param   keyword     keyword to register
1296:             * @param   companion   information object associated with this keyword
1297:             * @param   flags       modification flags 
1298:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1299:             *          is passed for keyword
1300:             * @throws  UnsupportedOperationException if the method is not available for an
1301:             *          implementation of the <code>TokenizerProperties</code> interface
1302:             * @see #addKeyword(String)
1303:             * @see #addKeyword(String, Object)
1304:             * @see #removeKeyword
1305:             */
1306:            public void addKeyword(String keyword, Object companion, int flags)
1307:                    throws IllegalArgumentException,
1308:                    UnsupportedOperationException;
1309:
1310:            /**
1311:             * Registering a keyword with a set of flags and an associated flag mask..
1312:             *<br>
1313:             * The method is an extension to {@link #addKeyword(String, Object, int)} having
1314:             * a bitmask for the flags that are explicitely specified for the pattern 
1315:             * property. All other flag values (states) should be taken from the 
1316:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
1317:             *
1318:             * @param   keyword     keyword to register
1319:             * @param   companion   information object associated with this keyword
1320:             * @param   flags       modification flags 
1321:             * @param   flagMask    flags that have valid values in the parameter <code>flags</code>
1322:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1323:             *          is passed for keyword
1324:             * @throws  UnsupportedOperationException if the method is not available for an
1325:             *          implementation of the <code>TokenizerProperties</code> interface
1326:             * @see #addKeyword(String)
1327:             * @see #addKeyword(String, Object)
1328:             * @see #removeKeyword
1329:             */
1330:            public void addKeyword(String keyword, Object companion, int flags,
1331:                    int flagMask) throws IllegalArgumentException,
1332:                    UnsupportedOperationException;
1333:
1334:            /**
1335:             * Removing a keyword property from the store. If the keyword is not known
1336:             * then the method does nothing.
1337:             *<br>
1338:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1339:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
1340:             * listeners if a keyword property is actually removed.
1341:             *
1342:             * @param   keyword   keyword to remove
1343:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1344:             *          is passed
1345:             * @see #addKeyword(String)
1346:             * @see #addKeyword(String, Object)
1347:             * @see #addKeyword(String, Object, int)
1348:             */
1349:            public void removeKeyword(String keyword)
1350:                    throws IllegalArgumentException;
1351:
1352:            /**
1353:             * Retrieving the companion of the given special sequence. If the special
1354:             * sequence doesn't exist the method returns <code>null</code>.
1355:             *
1356:             * @param   keyword   keyword thats companion is sought
1357:             * @return  the object associated with the keyword
1358:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1359:             *          is passed
1360:             */
1361:            public Object getKeywordCompanion(String keyword)
1362:                    throws IllegalArgumentException;
1363:
1364:            /**
1365:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
1366:             * objects. Each <code>TokenizerProperty</code> object contains a keyword and 
1367:             * the companion if it exists.
1368:             *
1369:             * @return enumeration of {@link TokenizerProperty} objects
1370:             */
1371:            public Iterator getKeywords();
1372:
1373:            /**
1374:             * Checks if the given keyword is known to the <code>TokenizerProperties</code>.
1375:             * The method accepts both empty and <code>null</code> strings for <code>keyword</code>
1376:             * by returning <code>false</code>.
1377:             *
1378:             * @param keyword   keyword to search
1379:             * @return <code>true</code> if the keyword is known,
1380:             *        <code>false</code> otherwise
1381:             */
1382:            public boolean keywordExists(String keyword);
1383:
1384:            /**
1385:             * Get the full description of a keyword property. The method returns 
1386:             * <code>null</code> if the passed <code>keyword</code> image is unknown
1387:             * ({@link #keywordExists} would return <code>false</code>). 
1388:             *
1389:             * @param   keyword   keyword to search
1390:             * @return  the full sequence description or <code>null</code>
1391:             * @throws  IllegalArgumentException when <code>null</code> or an empty string
1392:             *          is passed
1393:             */
1394:            public TokenizerProperty getKeyword(String keyword)
1395:                    throws IllegalArgumentException;
1396:
1397:            //---------------------------------------------------------------------------
1398:            // pattern properties
1399:            //
1400:
1401:            /**
1402:             * Registering a pattern. Pattern can describe identifiers, numbers etc. They
1403:             * provide a way to deal with token that cannot be enumerated like keywords.
1404:             *<br>
1405:             * A pattern is usually a regular expression that is used by {@link java.util.regex.Pattern}. 
1406:             * But implementations of {@link de.susebox.jtopas.spi.PatternHandler} may use
1407:             * other pattern syntaxes, for example the simpler syntax used for file path 
1408:             * matching.  
1409:             *<br>
1410:             * Pattern are applied to input data in the order of their registration. The 
1411:             * first matching pattern stops the iteration.
1412:             *<br>
1413:             * Pattern matching is a rather complex operation that may have a significant
1414:             * impact on the speed of a {@link Tokenizer}. On the other hand, pattern may
1415:             * be used instead of string or comment descriptions (see {@link #addString} etc.)
1416:             * or if a pattern matching would be performed after the return of a token of
1417:             * type {@link Token#NORMAL}.
1418:             *<br>
1419:             * If the given pattern is already known to the parser, it will simply be 
1420:             * re-registered. Using this method on a known pattern with an associated companion 
1421:             * will remove that companion.
1422:             *<br>
1423:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1424:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1425:             * (see {@link #addTokenizerPropertyListener}) with the new pattern {@link TokenizerProperty}
1426:             * if the pattern is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
1427:             * if the pattern is re-registered.
1428:             *
1429:             * @param   pattern   the regular expression to be added
1430:             * @throws  IllegalArgumentException when <code>null</code> or an empty pattern
1431:             *          is passed
1432:             * @throws  UnsupportedOperationException if the method is not available for an
1433:             *          implementation of the <code>TokenizerProperties</code> interface
1434:             * @see     #removePattern
1435:             * @see     #addPattern(String, Object)
1436:             * @see     #addPattern(String, Object, int)
1437:             */
1438:            public void addPattern(String pattern)
1439:                    throws IllegalArgumentException,
1440:                    UnsupportedOperationException;
1441:
1442:            /**
1443:             * Registering a pattern with an associated object. See the description of the
1444:             * {@link #addPattern(String)} for details on pattern.
1445:             *<br>
1446:             * If the given pattern is already known to the parser, it will simply be 
1447:             * re-registered. The associated companion will be replaced against the new one.
1448:             *<br>
1449:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1450:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1451:             * (see {@link #addTokenizerPropertyListener}) with the new pattern {@link TokenizerProperty}
1452:             * if the pattern is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
1453:             * if the pattern is re-registered.
1454:             *
1455:             * @param   pattern     the regular expression to be added
1456:             * @param   companion   information object associated with this pattern
1457:             * @throws  IllegalArgumentException when <code>null</code> or an empty pattern
1458:             *          is passed
1459:             * @throws  UnsupportedOperationException if the method is not available for an
1460:             *          implementation of the <code>TokenizerProperties</code> interface
1461:             * @see     #removePattern
1462:             * @see     #addPattern(String)
1463:             * @see     #addPattern(String, Object, int)
1464:             */
1465:            public void addPattern(String pattern, Object companion)
1466:                    throws IllegalArgumentException,
1467:                    UnsupportedOperationException;
1468:
1469:            /**
1470:             * Registering a pattern with an associated object. See the description of the
1471:             * {@link #addPattern(String)} for details on pattern.
1472:             *<br>
1473:             * If the given pattern is already known to the parser, it will simply be 
1474:             * re-registered. The associated companion will be replaced against the new one.
1475:             *<br>
1476:             * This version of <code>addPattern</code> supports a bitmask of the 
1477:             * {@link Flags} to modify the general tokenizer settings (see
1478:             * {@link #setParseFlags}) for this special pattern. 
1479:             *<br>
1480:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1481:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} to all registered listeners
1482:             * (see {@link #addTokenizerPropertyListener}) with the new pattern {@link TokenizerProperty}
1483:             * if the pattern is a new one, or of type {@link TokenizerPropertyEvent#PROPERTY_MODIFIED}
1484:             * if the pattern is re-registered.
1485:             *<br>
1486:             * A call to this method is equivalent to <code>addPattern(pattern, companion, flags, flags)</code>.
1487:             *
1488:             * @param   pattern     the regular expression to be added
1489:             * @param   companion   information object associated with this keyword
1490:             * @param   flags       modification flags 
1491:             * @throws  IllegalArgumentException when <code>null</code> or an empty pattern
1492:             *          is passed
1493:             * @throws  UnsupportedOperationException if the method is not available for an
1494:             *          implementation of the <code>TokenizerProperties</code> interface
1495:             * @see     #removePattern
1496:             * @see     #addPattern(String)
1497:             * @see     #addPattern(String, Object)
1498:             */
1499:            public void addPattern(String pattern, Object companion, int flags)
1500:                    throws IllegalArgumentException,
1501:                    UnsupportedOperationException;
1502:
1503:            /**
1504:             * Registering a pattern with an associated object and explicitely given flags.
1505:             * See the description of the {@link #addPattern(String)} for details on pattern.
1506:             *<br>
1507:             * The method is an extension to {@link #addPattern(String, Object, int)} having
1508:             * a bitmask for the flags that are specified for the pattern property. 
1509:             * All other flag values (states) should be taken from the 
1510:             * <code>TokenizerProperty</code> instance or from the {@link Tokenizer}.
1511:             *
1512:             * @param   pattern     the regular expression to be added
1513:             * @param   companion   information object associated with this keyword
1514:             * @param   flags       values for modification flags 
1515:             * @param   flagMask    flags that have valid values in the parameter <code>flags</code>
1516:             * @throws  IllegalArgumentException when <code>null</code> or an empty pattern
1517:             *          is passed
1518:             * @throws  UnsupportedOperationException if the method is not available for an
1519:             *          implementation of the <code>TokenizerProperties</code> interface
1520:             * @see     #removePattern
1521:             * @see     #addPattern(String)
1522:             * @see     #addPattern(String, Object)
1523:             * @see     #addPattern(String, Object, int)
1524:             */
1525:            public void addPattern(String pattern, Object companion, int flags,
1526:                    int flagMask) throws IllegalArgumentException,
1527:                    UnsupportedOperationException;
1528:
1529:            /**
1530:             * Removing a pattern. The method does nothing if the given pattern is not known 
1531:             * to this <code>TokenizerProperties</code> instance. The method may throw an 
1532:             * {@link java.lang.IllegalArgumentException} if the given pattern is
1533:             * <code>null</code> or empty.
1534:             *<br>
1535:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1536:             * of type {@link TokenizerPropertyEvent#PROPERTY_REMOVED} to all registered 
1537:             * listeners (see {@link #addTokenizerPropertyListener}) if a pattern is actually 
1538:             * removed.
1539:             *
1540:             * @param   pattern     the regular expression to be removed
1541:             * @throws  IllegalArgumentException when <code>null</code> or an empty string 
1542:             *          is passed
1543:             */
1544:            public void removePattern(String pattern)
1545:                    throws IllegalArgumentException;
1546:
1547:            /**
1548:             * Retrieving the information associated with a given pattern. If the pattern 
1549:             * is not known to the parser, <code>null</code> will be returned.
1550:             *<br>
1551:             * If You need to know if a pattern is known to this <code>TokenizerProperties</code>
1552:             * instance with or without a companion, use the method {@link #patternExists}
1553:             * instead.
1554:             *
1555:             * @param   pattern     the regular expression to be removed
1556:             * @return  the associated information or <code>null</code>
1557:             * @throws  IllegalArgumentException when <code>null</code> or an emtpy pattern
1558:             *          is passed
1559:             */
1560:            public Object getPatternCompanion(String pattern)
1561:                    throws IllegalArgumentException;
1562:
1563:            /**
1564:             * Checks if the given pattern is known to the parser. The method accepts both 
1565:             * empty and <code>null</code> strings for <code>pattern</code> by returning 
1566:             * <code>false</code>.
1567:             *<br>
1568:             * Note that there is no choice of parsing flags (different to the 
1569:             * {@link #addString(String, String, String, Object, int)} method), since it
1570:             * makes generally no sense to "overload" properties.
1571:             *
1572:             * @param   pattern     the regular expression to be looked for
1573:             * @return  <code>true</code> if the pattern is registered, 
1574:             *          <code>false</code> otherwise
1575:             */
1576:            public boolean patternExists(String pattern);
1577:
1578:            /**
1579:             * Get the full description of a pattern property. The method returns <code>null</code> 
1580:             * if the passed <code>pattern</code> parameter cannot be mapped to a known 
1581:             * pattern description ({@link #patternExists} would return <code>false</code>). 
1582:             *
1583:             * @param   pattern   the regular expression to be looked for
1584:             * @return  the full pattern description or <code>null</code>
1585:             * @throws  IllegalArgumentException when <code>null</code> or an emtpy pattern 
1586:             *          is passed
1587:             */
1588:            public TokenizerProperty getPattern(String pattern)
1589:                    throws IllegalArgumentException;
1590:
1591:            /**
1592:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
1593:             * objects. Each <code>TokenizerProperty</code> object contains a pattern and 
1594:             * its companion if such an associated object exists.
1595:             *
1596:             * @return enumeration of {@link TokenizerProperty} objects
1597:             */
1598:            public Iterator getPatterns();
1599:
1600:            //---------------------------------------------------------------------------
1601:            // generic property methods
1602:            //
1603:
1604:            /**
1605:             * Registering a {@link TokenizerProperty}. This can be a keyword, comment etc.,
1606:             * even whitespaces, separators and property types not defined in {@link Token}.
1607:             *<br>
1608:             * If the property is already known to this <code>TokenizerProperties</code>
1609:             * instance then it is simply re-registered.
1610:             *<br>
1611:             * An implementation of this interface should fire a {@link TokenizerPropertyEvent}
1612:             * of type {@link TokenizerPropertyEvent#PROPERTY_ADDED} or 
1613:             * {@link TokenizerPropertyEvent#PROPERTY_MODIFIED} to all registered listeners
1614:             * (see {@link #addTokenizerPropertyListener}).
1615:             *<br>
1616:             * An implementation of this interface may or may not support adding of
1617:             * whitespaces and separators.
1618:             *
1619:             * @param   property   property to register
1620:             * @throws  IllegalArgumentException when <code>null</code>, an incomplete or 
1621:             *          otherwise unusable property is passed
1622:             * @throws  UnsupportedOperationException if the method is not available for an
1623:             *          implementation of the <code>TokenizerProperties</code> interface
1624:             */
1625:            public void addProperty(TokenizerProperty property)
1626:                    throws IllegalArgumentException,
1627:                    UnsupportedOperationException;
1628:
1629:            /**
1630:             * Deregistering a {@link TokenizerProperty} from the store. If the property is
1631:             * not known the method does nothing.
1632:             *
1633:             * @param   property    property to register
1634:             * @throws  IllegalArgumentException when <code>null</code>, an incomplete or 
1635:             *          otherwise unusable property is passed
1636:             */
1637:            public void removeProperty(TokenizerProperty property)
1638:                    throws IllegalArgumentException;
1639:
1640:            /**
1641:             * This method returns an {@link java.util.Iterator} of {@link TokenizerProperty}
1642:             * objects.
1643:             *
1644:             * @return enumeration of {@link TokenizerProperty} objects
1645:             */
1646:            public Iterator getProperties();
1647:
1648:            /**
1649:             * Checks if the given {@link TokenizerProperty} is known to this <code>TokenizerProperties</code>
1650:             * instance. The method compares the characteristics given in <code>property</code>
1651:             * against all known properties.
1652:             *<br>
1653:             * The method accepts <code>null</code> for <code>property</code> by returning 
1654:             * <code>false</code>.
1655:             *
1656:             * @param   property  the property to search
1657:             * @return <code>true</code> if the property is known,
1658:             *        <code>false</code> otherwise
1659:             */
1660:            public boolean propertyExists(TokenizerProperty property);
1661:
1662:            //---------------------------------------------------------------------------
1663:            // property change event handling
1664:            //
1665:
1666:            /**
1667:             * Registering a new {@link TokenizerPropertyListener}. An implementation of
1668:             * the <code>TokenizerProperties</code> interface should call the approbriate
1669:             * methods in the <code>TokenizerPropertyListener</code> interface for all
1670:             * registered listeners whenever a {@link TokenizerProperty} is added, removed
1671:             * or modified. 
1672:             *<br>
1673:             * Adding is done by one of the <code>add...</code> calls like {@link #addKeyword} 
1674:             * or {@link #addString}.
1675:             *<br>
1676:             * Modifications are re-registering of keywords, comments etc. regardless if 
1677:             * companions or parse flags actually changed. Also, {@link #setWhitespaces} 
1678:             * and {@link #setSeparators} are modifications.
1679:             *<br>
1680:             * Removals are performed by the <code>remove...</code> calls, for instance
1681:             * {@link #removeKeyword}.
1682:             *<br>
1683:             * Similar to the policy of event listener registration in the JDK, passing 
1684:             * <code>null</code> does nothing.
1685:             *
1686:             * @param listener  the new {@link TokenizerPropertyListener}
1687:             * @see #removeTokenizerPropertyListener
1688:             */
1689:            public void addTokenizerPropertyListener(
1690:                    TokenizerPropertyListener listener);
1691:
1692:            /**
1693:             * Removing a listener from the list of registered {@link TokenizerPropertyListener}
1694:             * instances. If the given listener is <code>null</code> or unknown, nothing
1695:             * is done.
1696:             *
1697:             * @param listener  the {@link TokenizerPropertyListener} to deregister
1698:             * @see #addTokenizerPropertyListener
1699:             */
1700:            public void removeTokenizerPropertyListener(
1701:                    TokenizerPropertyListener listener);
1702:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.