Source Code Cross Referenced for Keyword.java in  » Scripting » Kawa » 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 » Kawa » 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.text.Printable;
006:        import gnu.lists.Consumer;
007:
008:        public class Keyword extends Symbol implements  Printable,
009:                Externalizable {
010:            public static final Namespace keywordNamespace = new Namespace();
011:            static {
012:                keywordNamespace.setName("(keywords)");
013:            }
014:
015:            public Keyword() {
016:            }
017:
018:            private Keyword(String name) {
019:                super (keywordNamespace, name);
020:            }
021:
022:            /** Used for constructing literals (int gnu.expr.LitTable). */
023:            public Keyword(Namespace namespace, String name) {
024:                super (namespace, name);
025:            }
026:
027:            /** Get the corresponding non-keyword symbol.
028:             * Informally, the symbol corresponding to dropping the ':'.
029:             */
030:            public Symbol asSymbol() {
031:                return Namespace.EmptyNamespace.getSymbol(getName());
032:            }
033:
034:            /**
035:             * Create or find a Keyword with a given name (without final ':').
036:             * @param name the print-name of the desired Keyword
037:             * @return a Keyword with the given name, newly created iff none such exist
038:             */
039:            static public Keyword make(String name) {
040:                int hash = name.hashCode();
041:                Keyword keyword = (Keyword) keywordNamespace.lookup(name, hash,
042:                        false);
043:                if (keyword == null) {
044:                    keyword = new Keyword(name);
045:                    keywordNamespace.add(keyword, hash);
046:                }
047:                return keyword;
048:            }
049:
050:            /*
051:            public FString toSchemeString()
052:            {
053:              return new FString(name);
054:            }
055:             */
056:
057:            public static boolean isKeyword(Object obj) {
058:                return obj instanceof  Keyword;
059:            }
060:
061:            public final String toString() {
062:                return getName() + ':';
063:            }
064:
065:            public void print(Consumer out) {
066:                Symbols.print(getName(), out);
067:                out.write(':');
068:            }
069:
070:            /**
071:             * Search vals[0:offset-1] for a keyword.
072:             * Each key at vals[i] is followed by a value at keys[i+1].
073:             * (This is used to search for a keyword parameter in an argument list.)
074:             * @param vals the list to search in
075:             * @param offset the index in vals to start the search at
076:             * @param keyword the keyword to search for
077:             * @return vals[i+1] such that vals[i]==keyword (and (i-offset) is even
078:             * and non-negative);  if there is no such i, return Special.dfault.
079:             */
080:            public static Object searchForKeyword(Object[] vals, int offset,
081:                    Object keyword) {
082:                for (int i = offset; i < vals.length; i += 2) {
083:                    if (vals[i] == keyword)
084:                        return vals[i + 1];
085:                }
086:                return Special.dfault;
087:            }
088:
089:            /**
090:             * Search vals[0:offset-1] for a keyword.
091:             * Each key at vals[i] is followed by a value at keys[i+1].
092:             * (This is used to search for a keyword parameter in an argument list.)
093:             * @param vals the list to search in
094:             * @param offset the index in vals to start the search at
095:             * @param keyword the keyword to search for
096:             * @param dfault the value to return if there is no match
097:             * @return vals[i+1] such that vals[i]==keyword (and (i-offset) is even
098:             * and non-negative);  if there is no such i, return dfault.
099:             */
100:            public static Object searchForKeyword(Object[] vals, int offset,
101:                    Object keyword, Object dfault) {
102:                for (int i = offset; i < vals.length; i += 2) {
103:                    if (vals[i] == keyword)
104:                        return vals[i + 1];
105:                }
106:                return dfault;
107:            }
108:
109:            public void writeExternal(ObjectOutput out) throws IOException {
110:                out.writeObject(getName());
111:            }
112:
113:            public void readExternal(ObjectInput in) throws IOException,
114:                    ClassNotFoundException {
115:                name = (String) in.readObject();
116:            }
117:
118:            public Object readResolve() throws ObjectStreamException {
119:                return make(keywordNamespace, getName());
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.