Source Code Cross Referenced for Variable.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » bsh » 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 » Swing Library » jEdit » org.gjt.sp.jedit.bsh 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gjt.sp.jedit.bsh;
002:
003:        public class Variable implements  java.io.Serializable {
004:            static final int DECLARATION = 0, ASSIGNMENT = 1;
005:            /** A null type means an untyped variable */
006:            String name;
007:            Class type = null;
008:            String typeDescriptor;
009:            Object value;
010:            Modifiers modifiers;
011:            LHS lhs;
012:
013:            Variable(String name, Class type, LHS lhs) {
014:                this .name = name;
015:                this .lhs = lhs;
016:                this .type = type;
017:            }
018:
019:            Variable(String name, Object value, Modifiers modifiers)
020:                    throws UtilEvalError {
021:                this (name, (Class) null/*type*/, value, modifiers);
022:            }
023:
024:            /**
025:            	This constructor is used in class generation.
026:             */
027:            Variable(String name, String typeDescriptor, Object value,
028:                    Modifiers modifiers) throws UtilEvalError {
029:                this (name, (Class) null/*type*/, value, modifiers);
030:                this .typeDescriptor = typeDescriptor;
031:            }
032:
033:            /**
034:            	@param value may be null if this 
035:             */
036:            Variable(String name, Class type, Object value, Modifiers modifiers)
037:                    throws UtilEvalError {
038:
039:                this .name = name;
040:                this .type = type;
041:                this .modifiers = modifiers;
042:                setValue(value, DECLARATION);
043:            }
044:
045:            /**
046:            	Set the value of the typed variable.
047:            	@param value should be an object or wrapped bsh Primitive type.
048:            	if value is null the appropriate default value will be set for the
049:            	type: e.g. false for boolean, zero for integer types.
050:             */
051:            public void setValue(Object value, int context)
052:                    throws UtilEvalError {
053:
054:                // check this.value
055:                if (hasModifier("final") && this .value != null)
056:                    throw new UtilEvalError("Final variable, can't re-assign.");
057:
058:                if (value == null)
059:                    value = Primitive.getDefaultValue(type);
060:
061:                if (lhs != null) {
062:                    lhs.assign(value, false/*strictjava*/);
063:                    return;
064:                }
065:
066:                // TODO: should add isJavaCastable() test for strictJava
067:                // (as opposed to isJavaAssignable())
068:                if (type != null)
069:                    value = Types.castObject(value, type,
070:                            context == DECLARATION ? Types.CAST
071:                                    : Types.ASSIGNMENT);
072:
073:                this .value = value;
074:            }
075:
076:            /*
077:            	Note: UtilEvalError here comes from lhs.getValue().
078:            	A Variable can represent an LHS for the case of an imported class or
079:            	object field.
080:             */
081:            Object getValue() throws UtilEvalError {
082:                if (lhs != null)
083:                    return lhs.getValue();
084:
085:                return value;
086:            }
087:
088:            /** A type of null means loosely typed variable */
089:            public Class getType() {
090:                return type;
091:            }
092:
093:            public String getTypeDescriptor() {
094:                return typeDescriptor;
095:            }
096:
097:            public Modifiers getModifiers() {
098:                return modifiers;
099:            }
100:
101:            public String getName() {
102:                return name;
103:            }
104:
105:            public boolean hasModifier(String name) {
106:                return modifiers != null && modifiers.hasModifier(name);
107:            }
108:
109:            public String toString() {
110:                return "Variable: " + super .toString() + " " + name + ", type:"
111:                        + type + ", value:" + value + ", lhs = " + lhs;
112:            }
113:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.