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


001:        // Copyright (c) 2004  Per M.A. Bothner.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.mapping;
005:
006:        /** A Location is an abstract cell/location/variable with a value. */
007:
008:        public abstract class Location {
009:            /* DEBUGGING
010:            static int counter;
011:            public int id=++counter;
012:             */
013:
014:            public Location() {
015:            }
016:
017:            public Symbol getKeySymbol() {
018:                return null;
019:            }
020:
021:            public Object getKeyProperty() {
022:                return null;
023:            }
024:
025:            public String toString() {
026:                StringBuffer sbuf = new StringBuffer();
027:                sbuf.append(getClass().getName());
028:                Symbol sym = getKeySymbol();
029:                sbuf.append('[');
030:                if (sym != null) {
031:                    sbuf.append(sym);
032:                    Object property = getKeyProperty();
033:                    // For a ThreadLocation the property defaults to "this".
034:                    // In that case we'd better not print the property ...
035:                    if (property != null && property != this ) {
036:                        sbuf.append('/');
037:                        sbuf.append(property);
038:                    }
039:                }
040:                /* DEBUGGING:
041:                sbuf.append(" #:");
042:                sbuf.append(id);
043:                 */
044:                sbuf.append("]");
045:                return sbuf.toString();
046:            }
047:
048:            /** Magic value used to indicate there is no property binding. */
049:            public static final String UNBOUND = new String("(unbound)");
050:
051:            public abstract Object get(Object defaultValue);
052:
053:            /** Get the current value of this location.
054:             * @exception UnboundLocationException the location does not have a value. */
055:            public final Object get() {
056:                Object unb = Location.UNBOUND;
057:                Object val = get(unb);
058:                if (val == unb)
059:                    throw new UnboundLocationException(this );
060:                return val;
061:            }
062:
063:            public abstract void set(Object value);
064:
065:            public void undefine() {
066:                set(UNBOUND);
067:            }
068:
069:            /** Set a value, but return cookie so old value can be restored.
070:             * This is intended for fluid-let where (in the case of multiple threads)
071:             * a simple save-restore isn't always the right thing. */
072:            public Object setWithSave(Object newValue, CallContext ctx) {
073:                ctx.pushFluid(this );
074:                Object old = get(UNBOUND);
075:                set(newValue);
076:                return old;
077:            }
078:
079:            /** Restore an old value.
080:             * @param oldValue the return value from a prior setWithSave. */
081:            public void setRestore(Object oldValue, CallContext ctx) {
082:                // if (oldValue == UNBOUND) ???;  // FIXME
083:                set(oldValue);
084:                ctx.popFluid();
085:            }
086:
087:            public boolean isBound() {
088:                Object unb = Location.UNBOUND;
089:                return get(unb) != unb;
090:            }
091:
092:            public boolean isConstant() {
093:                return false;
094:            }
095:
096:            public Location getBase() {
097:                return this ;
098:            }
099:
100:            public final Object getValue() {
101:                return get(null);
102:            }
103:
104:            public final Object setValue(Object newValue) {
105:                Object value = get(null);
106:                set(newValue);
107:                return value;
108:            }
109:
110:            /** True if directly entered in an Environment.  (Only if NamedLocation.) */
111:            public boolean entered() {
112:                return false;
113:            }
114:
115:            public void print(java.io.PrintWriter ps) {
116:                ps.print("#<location ");
117:                Symbol name = getKeySymbol();
118:                if (name != null)
119:                    ps.print(name);
120:                Object unb = Location.UNBOUND;
121:                Object value = get(unb);
122:                if (value != unb) {
123:                    ps.print(" -> ");
124:                    ps.print(value);
125:                } else
126:                    ps.print("(unbound)");
127:                ps.print('>');
128:            }
129:
130:            // The compiler emits calls to this method.
131:            public static Location make(Object init, String name) {
132:                ThreadLocation loc = new ThreadLocation(name);
133:                loc.setGlobal(init);
134:                return loc;
135:            }
136:
137:            // The compiler emits calls to this method.
138:            public static IndirectableLocation make(String name) {
139:                Symbol sym = Namespace.EmptyNamespace.getSymbol(name.intern());
140:                PlainLocation loc = new PlainLocation(sym, null);
141:                loc.base = null;
142:                loc.value = UNBOUND;
143:                return loc;
144:            }
145:
146:            public static IndirectableLocation make(Symbol name) {
147:                PlainLocation loc = new PlainLocation(name, null);
148:                loc.base = null;
149:                loc.value = UNBOUND;
150:                return loc;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.