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


001:        // PropertySet.java
002:        // $Id: PropertySet.java,v 1.16 2000/08/16 21:37:34 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.config;
007:
008:        import java.util.Hashtable;
009:
010:        import java.io.File;
011:
012:        import org.w3c.tools.resources.Attribute;
013:        import org.w3c.tools.resources.AttributeHolder;
014:        import org.w3c.tools.resources.AttributeRegistry;
015:        import org.w3c.tools.resources.BooleanAttribute;
016:        import org.w3c.tools.resources.ClassAttribute;
017:        import org.w3c.tools.resources.DoubleAttribute;
018:        import org.w3c.tools.resources.FileAttribute;
019:        import org.w3c.tools.resources.FrameArrayAttribute;
020:        import org.w3c.tools.resources.IllegalAttributeAccess;
021:        import org.w3c.tools.resources.IntegerAttribute;
022:        import org.w3c.tools.resources.LongAttribute;
023:        import org.w3c.tools.resources.Resource;
024:        import org.w3c.tools.resources.StringArrayAttribute;
025:        import org.w3c.tools.resources.StringAttribute;
026:
027:        import org.w3c.util.ObservableProperties;
028:
029:        import org.w3c.jigsaw.http.httpd;
030:
031:        public class PropertySet extends Resource {
032:            protected httpd server = null;
033:
034:            static {
035:                Class c = null;
036:                Attribute a = null;
037:
038:                try {
039:                    c = Class.forName("org.w3c.jigsaw.config.PropertySet");
040:                } catch (Exception ex) {
041:                    ex.printStackTrace();
042:                    System.exit(1);
043:                }
044:            }
045:
046:            /**
047:             * Get this property set title.
048:             * @return A String encoding the title of the property set.
049:             */
050:
051:            public String getTitle() {
052:                return getIdentifier() + " property set.";
053:            }
054:
055:            /**
056:             * Get this resource's help url.
057:             * @return An URL, encoded as a String, or <strong>null</strong> if not
058:             * available.
059:             */
060:
061:            public String getHelpURL() {
062:                String docurl = server.getDocumentationURL();
063:                if (docurl == null)
064:                    return null;
065:                return docurl + "/" + getClass().getName() + ".html";
066:            }
067:
068:            /**
069:             * Get the help URL for that resource's attribute.
070:             * @param topic The topic (can be an attribute name, or a property, etc).
071:             * @return A String encoded URL, or <strong>null</strong>.
072:             */
073:
074:            public String getHelpURL(String topic) {
075:                String docurl = server.getDocumentationURL();
076:                if (docurl == null)
077:                    return null;
078:                Class defines = AttributeRegistry.getAttributeClass(getClass(),
079:                        topic);
080:                if (defines != null)
081:                    return docurl + "/" + defines.getName() + ".html";
082:                return null;
083:            }
084:
085:            /**
086:             * Set value forwards the effectation to the properties.
087:             * @param idx The attribute (property in that case) being set.
088:             * @param value The new value for that property.
089:             */
090:
091:            public synchronized void setValue(int idx, Object value) {
092:                // Check access (we don't care about side effects)
093:                super .setValue(idx, value);
094:                if (idx > ATTR_LAST_MODIFIED) {
095:                    Attribute a = attributes[idx];
096:                    if (value == null) {
097:                        server.getProperties().remove(a.getName());
098:                    } else {
099:                        if (!server.getProperties().putValue(a.getName(),
100:                                a.stringify(value)))
101:                            throw new IllegalAttributeAccess(this ,
102:                                    getAttributes()[idx], value);
103:                    }
104:                }
105:            }
106:
107:            protected Object convertingGet(httpd s, Attribute a, Object def) {
108:                ObservableProperties p = s.getProperties();
109:                def = (def == null) ? a.getDefault() : def;
110:                if (a instanceof  FileAttribute) {
111:                    return p.getFile(a.getName(), (File) def);
112:                } else if (a instanceof  StringAttribute) {
113:                    return p.getString(a.getName(), (String) def);
114:                } else if (a instanceof  IntegerAttribute) {
115:                    int d = (def == null) ? -1 : ((Integer) def).intValue();
116:                    int i = p.getInteger(a.getName(), d);
117:                    return new Integer(i);
118:                } else if (a instanceof  LongAttribute) {
119:                    long d = (def == null) ? -1 : ((Long) def).longValue();
120:                    long l = p.getLong(a.getName(), d);
121:                    return new Long(l);
122:                } else if (a instanceof  BooleanAttribute) {
123:                    boolean b = p
124:                            .getBoolean(a.getName(), (def == Boolean.TRUE));
125:                    return b ? Boolean.TRUE : Boolean.FALSE;
126:                } else if (a instanceof  ClassAttribute) {
127:                    try {
128:                        String cn = p.getString(a.getName(), null);
129:                        if (cn == null)
130:                            return def;
131:                        return Class.forName(cn);
132:                    } catch (Exception ex) {
133:                        throw new RuntimeException("Invalid class name.");
134:                    }
135:                } else if (a instanceof  StringArrayAttribute) {
136:                    return p.getStringArray(a.getName(), null);
137:                } else if (a instanceof  DoubleAttribute) {
138:                    double d = ((def == null) ? Double.NaN : ((Double) def)
139:                            .doubleValue());
140:                    d = p.getDouble(a.getName(), d);
141:                    return (d == Double.NaN) ? def : new Double(d);
142:                } else if (a instanceof  FrameArrayAttribute) {
143:                    return null; // ugly hack FIXME
144:                } else {
145:                    throw new RuntimeException("// FIXME !!!");
146:                }
147:            }
148:
149:            public Object getValue(int idx, Object def) {
150:                // Check access (again we don't care about side effectes)
151:                if (idx <= ATTR_LAST_MODIFIED)
152:                    return super .getValue(idx, def);
153:                return convertingGet(server, attributes[idx], def);
154:            }
155:
156:            public Object unsafeGetValue(int idx, Object def) {
157:                // Check access (again we don't care about side effectes)
158:                if (idx <= ATTR_LAST_MODIFIED)
159:                    return super .unsafeGetValue(idx, def);
160:                return convertingGet(server, attributes[idx], def);
161:            }
162:
163:            public PropertySet(String name, httpd server) {
164:                super ();
165:                this .server = server;
166:                setValue(ATTR_IDENTIFIER, name);
167:            }
168:
169:            public void initialize(Object values[]) {
170:                super .initialize(values);
171:                attributes[ATTR_IDENTIFIER] = new StringAttribute("identifier",
172:                        null, 0);
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.