Source Code Cross Referenced for PropertySig.java in  » Scripting » jacl » tcl » lang » 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 » jacl » tcl.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * PropertySig.java --
003:         *
004:         *	This class implements the internal representation of a Java
005:         *	property signature.
006:         *
007:         * Copyright (c) 1997 Sun Microsystems, Inc.
008:         *
009:         * See the file "license.terms" for information on usage and
010:         * redistribution of this file, and for a DISCLAIMER OF ALL
011:         * WARRANTIES.
012:         *
013:         * RCS: @(#) $Id: PropertySig.java,v 1.4 2000/10/29 06:00:42 mdejong Exp $
014:         *
015:         */
016:
017:        package tcl.lang;
018:
019:        import tcl.lang.reflect.*;
020:        import java.lang.reflect.*;
021:        import java.beans.*;
022:
023:        /**
024:         * This class implements the internal representation of a Java Property
025:         * signature.
026:         */
027:
028:        class PropertySig implements  InternalRep {
029:
030:            // The class that the property signature is used against. It is the
031:            // class of the java object specified in the java::prop command.
032:            // targetCls is used to test the validity of a cached PropertySig
033:            // internal rep.
034:
035:            Class targetCls;
036:
037:            // Property descriptor of the property.
038:
039:            PropertyDescriptor desc;
040:
041:            // The PkgInvoker used to access the property. 
042:
043:            PkgInvoker pkgInvoker;
044:
045:            /*
046:             *----------------------------------------------------------------------
047:             *
048:             * PropertySig --
049:             *
050:             *	Creates a new PropertySig instance.
051:             *
052:             * Side effects:
053:             *	Member fields are initialized.
054:             *
055:             *----------------------------------------------------------------------
056:             */
057:
058:            PropertySig(Class c, // Initial value for targetCls.
059:                    PkgInvoker i, // Initial value for pkgInvoker.
060:                    PropertyDescriptor d) // Initial value for desc.
061:            {
062:                targetCls = c;
063:                pkgInvoker = i;
064:                desc = d;
065:            }
066:
067:            /*
068:             *----------------------------------------------------------------------
069:             *
070:             * duplicate --
071:             *
072:             *	Make a copy of an object's internal representation.
073:             *
074:             * Results:
075:             *	Returns a newly allocated instance of the appropriate type.
076:             *
077:             * Side effects:
078:             *	None.
079:             *
080:             *----------------------------------------------------------------------
081:             */
082:
083:            public InternalRep duplicate() {
084:                return new PropertySig(targetCls, pkgInvoker, desc);
085:            }
086:
087:            /**
088:             * Implement this no-op for the InternalRep interface.
089:             */
090:
091:            public void dispose() {
092:            }
093:
094:            /*
095:             *----------------------------------------------------------------------
096:             *
097:             * get --
098:             *
099:             *	Returns the FieldSig internal rep given by the field signature.
100:             *
101:             * Results:
102:             *	The FieldSig given by the signature.
103:             *
104:             * Side effects:
105:             *	When successful, the internalRep of the signature object is
106:             *	converted to FieldSig.
107:             *
108:             *----------------------------------------------------------------------
109:             */
110:
111:            static PropertySig get(Interp interp, // Current interpreter
112:                    Class targetCls, // The target class of the property signature.
113:                    TclObject signature) // The TclObject that holds a prop. signature.
114:                    throws TclException // Standard Tcl exception.
115:            {
116:                InternalRep rep = signature.getInternalRep();
117:
118:                if ((rep instanceof  PropertySig)
119:                        && (targetCls == ((PropertySig) rep).targetCls)) {
120:                    // The cached internal rep is a valid property signature for
121:                    // the given targetCls. Return it.
122:
123:                    return (PropertySig) rep;
124:                }
125:
126:                String propName = signature.toString();
127:                PropertyDescriptor desc = null;
128:
129:                search_prop: {
130:                    BeanInfo beanInfo;
131:
132:                    try {
133:                        beanInfo = Introspector.getBeanInfo(targetCls);
134:                    } catch (IntrospectionException e) {
135:                        break search_prop;
136:                    }
137:
138:                    PropertyDescriptor descriptors[] = beanInfo
139:                            .getPropertyDescriptors();
140:
141:                    if (descriptors == null) {
142:                        break search_prop;
143:                    }
144:
145:                    // Search for a property that has the same name as propName.
146:
147:                    for (int i = 0; i < descriptors.length; i++) {
148:                        // FIXME : null tests are just for debugging
149:                        if (descriptors[i] == null) {
150:                            throw new NullPointerException("descriptor is null");
151:                        }
152:                        if (descriptors[i].getName() == null) {
153:                            throw new NullPointerException(
154:                                    "descriptor.getName() is null");
155:                        }
156:                        if (propName == null) {
157:                            throw new NullPointerException("propName is null");
158:                        }
159:
160:                        if (descriptors[i].getName().equals(propName)) {
161:                            if (descriptors[i] instanceof  IndexedPropertyDescriptor) {
162:                                throw new TclException(interp,
163:                                        "can't access indexed property \""
164:                                                + propName
165:                                                + "\": not implemented");
166:                            }
167:                            desc = descriptors[i];
168:                            break;
169:                        }
170:                    }
171:                }
172:
173:                if (desc == null) {
174:                    throw new TclException(interp, "unknown property \""
175:                            + propName + "\"");
176:                }
177:
178:                PropertySig sig = new PropertySig(targetCls, PkgInvoker
179:                        .getPkgInvoker(targetCls), desc);
180:
181:                signature.setInternalRep(sig);
182:
183:                return sig;
184:            }
185:
186:        } // end PropertySig
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.