Source Code Cross Referenced for Keyword.java in  » Scripting » Nice » gnu » expr » 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 » Scripting » Nice » gnu.expr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package gnu.expr;
002:
003:        import gnu.mapping.*;
004:        import java.io.*;
005:        import gnu.lists.*;
006:
007:        public class Keyword extends CpsProcedure implements  Printable,
008:                Externalizable {
009:            // Does not include final ':'.
010:            private String name;
011:
012:            public Keyword() {
013:            }
014:
015:            private Keyword(String name) {
016:                this .name = name;
017:            }
018:
019:            private static java.util.Hashtable keywordTable = new java.util.Hashtable();
020:
021:            public int hashCode() {
022:                return name.hashCode();
023:            }
024:
025:            /**
026:             * Create or find a Keyword with a given name (without final ':').
027:             * @param name the print-name of the desired Keyword
028:             * @return a Keyword with the given name, newly created iff none such exist
029:             */
030:            static public Keyword make(String name) {
031:                Keyword keyword = (Keyword) keywordTable.get(name);
032:                if (keyword == null) {
033:                    keyword = new Keyword(name);
034:                    keywordTable.put(name, keyword);
035:                }
036:                return keyword;
037:            }
038:
039:            /*
040:            public FString toSchemeString()
041:            {
042:              return new FString(name);
043:            }
044:             */
045:
046:            public static boolean isKeyword(Object obj) {
047:                return obj instanceof  Keyword;
048:            }
049:
050:            public final String toString() {
051:                return name + ':';
052:            }
053:
054:            public void print(java.io.PrintWriter ps) {
055:                Symbol.print(name, ps);
056:                ps.print(':');
057:            }
058:
059:            /**
060:             * Search vals[0:offset-1] for a keyword.
061:             * Each key at vals[i] is followed by a value at vals[i+1].
062:             * (This is used to search for a keyword parameter in an argument list.)
063:             * @param vals the list to search in
064:             * @param offset the index in vals to start the search at
065:             * @param keyword the keyword to search for
066:             * @return vals[i+1] such that vals[i]==keyword (and (i-offset) is even
067:             * and non-negative);  if there is no such i, return Special.dfault.
068:             */
069:            public static Object searchForKeyword(Object[] vals, int offset,
070:                    Object keyword) {
071:                for (int i = offset; i < vals.length; i += 2) {
072:                    if (vals[i] == keyword)
073:                        return vals[i + 1];
074:                }
075:                return Special.dfault;
076:            }
077:
078:            /**
079:             * Search vals[0:offset-1] for a keyword.
080:             * Each key at vals[i] is followed by a value at keys[i+1].
081:             * (This is used to search for a keyword parameter in an argument list.)
082:             * @param vals the list to search in
083:             * @param offset the index in vals to start the search at
084:             * @param keyword the keyword to search for
085:             * @param dfault the value to return if there is no match
086:             * @return vals[i+1] such that vals[i]==keyword (and (i-offset) is even
087:             * and non-negative);  if there is no such i, return dfault.
088:             */
089:            public static Object searchForKeyword(Object[] vals, int offset,
090:                    Object keyword, Object dfault) {
091:                for (int i = offset; i < vals.length; i += 2) {
092:                    if (vals[i] == keyword)
093:                        return vals[i + 1];
094:                }
095:                return dfault;
096:            }
097:
098:            public final String getName() {
099:                return name;
100:            }
101:
102:            /**
103:             * @serialData Write the keyword name (without colons) using writeUTF.
104:             */
105:
106:            public void writeExternal(ObjectOutput out) throws IOException {
107:                out.writeUTF(name);
108:            }
109:
110:            public void readExternal(ObjectInput in) throws IOException,
111:                    ClassNotFoundException {
112:                name = in.readUTF();
113:            }
114:
115:            public Object readResolve() throws ObjectStreamException {
116:                return make(name);
117:            }
118:
119:            public void apply(CallContext ctx) {
120:                Consumer out = ctx.consumer;
121:                String tag = getName();
122:                int nargs = ctx.count;
123:                out.beginGroup(tag, this );
124:                for (int i = 0; i < nargs; i++) {
125:                    Object arg = ctx.getArgAsObject(i);
126:                    if (arg instanceof  Keyword && i + 1 < nargs) {
127:                        Keyword attr = (Keyword) arg;
128:                        arg = ctx.getArgAsObject(++i);
129:                        out.beginAttribute(attr.getName(), attr);
130:                        out.writeObject(arg);
131:                        out.endAttribute();
132:                    } else {
133:                        /*
134:                        if (arg instanceof Consumable)
135:                          ((Consumable) arg).consume(out);
136:                        else
137:                         */
138:                        out.writeObject(arg);
139:                    }
140:                }
141:                out.endGroup(tag);
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.