Source Code Cross Referenced for TokenAssembly.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » rules » parse » tokens » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.rules.parse.tokens 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ofbiz.rules.parse.tokens;
002:
003:        import org.ofbiz.rules.parse.*;
004:
005:        /**
006:         * <p><b>Title:</b> Token Assembly
007:         * <p><b>Description:</b> None
008:         * <p>Copyright (c) 1999 Steven J. Metsker.
009:         * <p>Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
010:         *
011:         * <p>Permission is hereby granted, free of charge, to any person obtaining a
012:         *  copy of this software and associated documentation files (the "Software"),
013:         *  to deal in the Software without restriction, including without limitation
014:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
015:         *  and/or sell copies of the Software, and to permit persons to whom the
016:         *  Software is furnished to do so, subject to the following conditions:
017:         *
018:         * <p>The above copyright notice and this permission notice shall be included
019:         *  in all copies or substantial portions of the Software.
020:         *
021:         * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
022:         *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
023:         *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
024:         *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
025:         *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
026:         *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
027:         *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
028:         *
029:         * <br>
030:         * A TokenAssembly is an Assembly whose elements are Tokens.
031:         * Tokens are, roughly, the chunks of text that a <code>
032:         * Tokenizer</code> returns.
033:         *
034:         * @author Steven J. Metsker
035:         * @version 1.0
036:         */
037:        public class TokenAssembly extends Assembly {
038:
039:            /**
040:             * the "string" of tokens this assembly will consume
041:             */
042:            protected TokenString tokenString;
043:
044:            /**
045:             * Constructs a TokenAssembly on a TokenString constructed
046:             * from the given String.
047:             *
048:             * @param   string   the string to consume
049:             *
050:             * @return   a TokenAssembly that will consume a tokenized
051:             *           version of the supplied String
052:             */
053:            public TokenAssembly(String s) {
054:                this (new TokenString(s));
055:            }
056:
057:            /**
058:             * Constructs a TokenAssembly on a TokenString constructed
059:             * from the given Tokenizer.
060:             *
061:             * @param   Tokenizer   the tokenizer to consume tokens
062:             *                      from
063:             *
064:             * @return   a TokenAssembly that will consume a tokenized
065:             *           version of the supplied Tokenizer
066:             */
067:            public TokenAssembly(Tokenizer t) {
068:                this (new TokenString(t));
069:            }
070:
071:            /**
072:             * Constructs a TokenAssembly from the given TokenString.
073:             *
074:             * @param   tokenString   the tokenString to consume
075:             *
076:             * @return   a TokenAssembly that will consume the supplied
077:             *           TokenString
078:             */
079:            public TokenAssembly(TokenString tokenString) {
080:                this .tokenString = tokenString;
081:            }
082:
083:            /**
084:             * Returns a textual representation of the amount of this
085:             * tokenAssembly that has been consumed.
086:             *
087:             * @param   delimiter   the mark to show between consumed
088:             *                      elements
089:             *
090:             * @return   a textual description of the amount of this
091:             *           assembly that has been consumed
092:             */
093:            public String consumed(String delimiter) {
094:                StringBuffer buf = new StringBuffer();
095:
096:                for (int i = 0; i < elementsConsumed(); i++) {
097:                    if (i > 0) {
098:                        buf.append(delimiter);
099:                    }
100:                    buf.append(tokenString.tokenAt(i));
101:                }
102:                return buf.toString();
103:            }
104:
105:            /**
106:             * Returns the default string to show between elements
107:             * consumed or remaining.
108:             *
109:             * @return   the default string to show between elements
110:             *           consumed or remaining
111:             */
112:            public String defaultDelimiter() {
113:                return "/";
114:            }
115:
116:            /**
117:             * Returns the number of elements in this assembly.
118:             *
119:             * @return   the number of elements in this assembly
120:             */
121:            public int length() {
122:                return tokenString.length();
123:            }
124:
125:            /**
126:             * Returns the next token.
127:             *
128:             * @return   the next token from the associated token string.
129:             *
130:             * @exception  ArrayIndexOutOfBoundsException  if there are no
131:             *             more tokens in this tokenizer's string.
132:             */
133:            public Object nextElement() {
134:                return tokenString.tokenAt(index++);
135:            }
136:
137:            /**
138:             * Shows the next object in the assembly, without removing it
139:             *
140:             * @return   the next object
141:             *
142:             */
143:            public Object peek() {
144:                if (index < length()) {
145:                    return tokenString.tokenAt(index);
146:                } else {
147:                    return null;
148:                }
149:            }
150:
151:            /**
152:             * Returns a textual representation of the amount of this
153:             * tokenAssembly that remains to be consumed.
154:             *
155:             * @param   delimiter   the mark to show between consumed
156:             *                      elements
157:             *
158:             * @return   a textual description of the amount of this
159:             *           assembly that remains to be consumed
160:             */
161:            public String remainder(String delimiter) {
162:                StringBuffer buf = new StringBuffer();
163:
164:                for (int i = elementsConsumed(); i < tokenString.length(); i++) {
165:
166:                    if (i > elementsConsumed()) {
167:                        buf.append(delimiter);
168:                    }
169:                    buf.append(tokenString.tokenAt(i));
170:                }
171:                return buf.toString();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.