Source Code Cross Referenced for ResourceDescription.java in  » Web-Server » Jigsaw » org » w3c » tools » resources » serialization » 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 » Web Server » Jigsaw » org.w3c.tools.resources.serialization 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ResourceDescription.java
002:        // $Id: ResourceDescription.java,v 1.3 2000/08/16 21:37:54 ylafon Exp $
003:        // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:        package org.w3c.tools.resources.serialization;
006:
007:        import java.util.Vector;
008:
009:        import org.w3c.tools.resources.Attribute;
010:        import org.w3c.tools.resources.Resource;
011:        import org.w3c.tools.resources.ResourceFrame;
012:
013:        /**
014:         * @version $Revision: 1.3 $
015:         * @author  Benoît Mahé (bmahe@w3.org)
016:         */
017:        public class ResourceDescription {
018:
019:            String classname = null;
020:            String classes[] = null;
021:            String interfaces[] = null;
022:            String identifier = null;
023:            AttributeDescription attributes[] = null;
024:            String children[] = null;
025:
026:            /**
027:             * Get a clone of this resource description but with only the
028:             * given list of attribute descriptions.
029:             * @param attrs the new attribute descriptions
030:             * @return a ResourceDescription;
031:             */
032:            public ResourceDescription getClone(AttributeDescription attrs[]) {
033:                ResourceDescription descr = new ResourceDescription(classname);
034:                descr.identifier = identifier;
035:                descr.children = children;
036:                descr.attributes = attrs;
037:                descr.classes = classes;
038:                descr.interfaces = interfaces;
039:                return descr;
040:            }
041:
042:            /**
043:             * Get this resource class hierarchy.
044:             * @return a String array
045:             */
046:            public String[] getClassHierarchy() {
047:                return classes;
048:            }
049:
050:            /**
051:             * Get this resource interfaces
052:             * @return a String array
053:             */
054:            public String[] getInterfaces() {
055:                return interfaces;
056:            }
057:
058:            public String[] getClassesAndInterfaces() {
059:                String all[] = new String[interfaces.length + classes.length];
060:                System.arraycopy(classes, 0, all, 0, classes.length);
061:                System.arraycopy(interfaces, 0, all, classes.length,
062:                        interfaces.length);
063:                return all;
064:            }
065:
066:            /**
067:             * Get the resource Class name.
068:             * @return a String
069:             */
070:            public String getClassName() {
071:                return classname;
072:            }
073:
074:            /**
075:             * Get the resource identifier.
076:             * @return a String instance
077:             */
078:            public String getIdentifier() {
079:                if ((identifier == null) && (attributes != null)) {
080:                    for (int i = 0; i < attributes.length; i++) {
081:                        if (attributes[i].getName().equals("identifier"))
082:                            identifier = (String) attributes[i].getValue();
083:                    }
084:                }
085:                return identifier;
086:            }
087:
088:            /**
089:             * get the children identifiers
090:             * @return a String array
091:             */
092:            public String[] getChildren() {
093:                return children;
094:            }
095:
096:            /**
097:             * Set the children names.
098:             * @param a String array
099:             */
100:            public void setChildren(String children[]) {
101:                this .children = children;
102:            }
103:
104:            /**
105:             * Get the attributes description.
106:             * @return an AttributeDescription array
107:             * @see AttributeDescription
108:             */
109:            public AttributeDescription[] getAttributeDescriptions() {
110:                return attributes;
111:            }
112:
113:            /**
114:             * Get the description of the frames associated to this resource.
115:             * @return a ResourceDescription array.
116:             */
117:            public ResourceDescription[] getFrameDescriptions() {
118:                for (int i = 0; i < attributes.length; i++) {
119:                    Object value = attributes[i].getValue();
120:                    if (value instanceof  ResourceDescription[])
121:                        return (ResourceDescription[]) value;
122:                }
123:                return new ResourceDescription[0];
124:            }
125:
126:            /**
127:             * Constructor.
128:             * @param resource the resource to describe.
129:             */
130:            public ResourceDescription(Resource resource) {
131:                this .classname = resource.getClass().getName();
132:                //build class hierarchy
133:                Vector vclasses = new Vector(8);
134:                Vector vinterfaces = new Vector(8);
135:                Class ints[] = resource.getClass().getInterfaces();
136:                if (ints != null)
137:                    for (int i = 0; i < ints.length; i++)
138:                        vinterfaces.addElement(ints[i]);
139:                for (Class c = resource.getClass().getSuperclass(); c != null; c = c
140:                        .getSuperclass()) {
141:                    vclasses.addElement(c.getName());
142:                    ints = c.getInterfaces();
143:                    if (ints != null)
144:                        for (int i = 0; i < ints.length; i++)
145:                            vinterfaces.addElement(ints[i]);
146:                }
147:                this .classes = new String[vclasses.size()];
148:                vclasses.copyInto(this .classes);
149:                this .interfaces = new String[vinterfaces.size()];
150:                vinterfaces.copyInto(this .interfaces);
151:                //build attributes description
152:                Attribute attrs[] = resource.getAttributes();
153:                Vector vattrs = new Vector(10);
154:                for (int j = 0; j < attrs.length; j++) {
155:                    Object value = resource.getValue(j, null);
156:                    if (value instanceof  ResourceFrame[]) {
157:                        ResourceFrame frames[] = (ResourceFrame[]) value;
158:                        int len = frames.length;
159:                        ResourceDescription descr[] = new ResourceDescription[len];
160:                        for (int i = 0; i < len; i++)
161:                            descr[i] = new ResourceDescription(frames[i]);
162:                        vattrs.addElement(new AttributeDescription(attrs[j],
163:                                descr));
164:                    } else {
165:                        vattrs.addElement(new AttributeDescription(attrs[j],
166:                                value));
167:                    }
168:                }
169:                this .attributes = new AttributeDescription[vattrs.size()];
170:                vattrs.copyInto(attributes);
171:            }
172:
173:            /**
174:             * Set the attributes description of the resource
175:             * @param a Vector of AttributeDescription instances
176:             */
177:            public void setAttributeDescriptions(Vector attrs) {
178:                attributes = new AttributeDescription[attrs.size()];
179:                attrs.copyInto(attributes);
180:            }
181:
182:            /**
183:             * Set the resource class hierarchy.
184:             * @param a String array
185:             */
186:            public void setClassHierarchy(String classes[]) {
187:                this .classes = classes;
188:            }
189:
190:            /**
191:             * Set the resource class hierarchy.
192:             * @param a String array
193:             */
194:            public void setInterfaces(String interfaces[]) {
195:                this .interfaces = interfaces;
196:            }
197:
198:            /**
199:             * Set the resource class hierarchy.
200:             * @param a Vector of String instances
201:             */
202:            public void setClassHierarchy(Vector vclasses) {
203:                this .classes = new String[vclasses.size()];
204:                vclasses.copyInto(this .classes);
205:            }
206:
207:            /**
208:             * Set the resource class hierarchy.
209:             * @param a Vector of String instances
210:             */
211:            public void setInterfaces(Vector vinterfaces) {
212:                this .interfaces = new String[vinterfaces.size()];
213:                vinterfaces.copyInto(this .interfaces);
214:            }
215:
216:            /**
217:             * Constructor.
218:             * @param classname the resource class name
219:             */
220:            public ResourceDescription(String classname) {
221:                this .classname = classname;
222:                this .interfaces = new String[0];
223:                this .classes = new String[0];
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.