Source Code Cross Referenced for SPropertyMap.java in  » Database-ORM » SimpleORM » simpleorm » properties » 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 » Database ORM » SimpleORM » simpleorm.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package simpleorm.properties;
002:
003:        import java.util.Hashtable;
004:        import java.util.Enumeration;
005:
006:        /*
007:         * Copyright (c) 2002 Southern Cross Software Limited (SCSQ).  All rights
008:         * reserved.  See COPYRIGHT.txt included in this distribution.
009:         */
010:
011:        /** A property map similar to java.util.Propeties except that the keys
012:         * are SProperty objects, and inheritance is supported.<p>
013:         *
014:         * Note that the map is SProperty --> Object directly.
015:         * SPropertyValues instances are not stored directly in this map, they
016:         * are picked appart into propety and value which are stored
017:         * separately.  ## Should they be?
018:         */
019:        public class SPropertyMap {
020:
021:            Hashtable hashMap = new Hashtable();
022:
023:            /** Gets the value of prop for this map.  May return a default value
024:                if none has been explicitly set.*/
025:            public Object getProperty(SProperty prop) {
026:                Object val = prop.theValue(this );
027:                if (val != null)
028:                    return val;
029:                if (hashMap.containsKey(prop))
030:                    return hashMap.get(prop);
031:                else
032:                    return prop.defaultValue(this );
033:            }
034:
035:            /** Convenient routine for getting boolean properties.  Default is
036:                always false. */
037:            public boolean getBoolean(SProperty prop) {
038:                Object val = getProperty(prop);
039:                if (val == null)
040:                    return false;
041:                return ((Boolean) val).booleanValue();
042:            }
043:
044:            /** (String)getProperty(..). */
045:            public String getString(SProperty prop) {
046:                return (String) getProperty(prop);
047:            }
048:
049:            /** Sets prop to value for this map after validating it.  May or may
050:                not already exist.  If value is null then removes the property,
051:                so a property cannot actually be set to null -- once removed it
052:                may start defaulting. */
053:            public void putProperty(SProperty prop, Object value) {
054:                //System.out.println("     -putting " + this + "." + prop + " := " + value);
055:                prop.validate(this , value);
056:                if (value == null) // Needs to be a special case!
057:                    hashMap.remove(prop);
058:                else
059:                    hashMap.put(prop, value);
060:            }
061:
062:            /** Sets prop to value for this map provided that it does not
063:                already have an <em>explicit</em> value in <em>this</em> map.
064:                Either way returns the value of the property now.
065:             */
066:            public Object putDefaultProperty(SProperty prop, Object value) {
067:                Object val = hashMap.get(prop);
068:                if (val == null) {
069:                    val = value;
070:                    putProperty(prop, value);
071:                }
072:                return val;
073:            }
074:
075:            /** Convenience method that sets this map to each property value pair. */
076:            public void setPropertyValues(SPropertyValue[] pvals) {
077:                for (int px = 0; px < pvals.length; px++) {
078:                    setPropertyValue(pvals[px]);
079:                }
080:            }
081:
082:            /** Convenience method that sets this mmap to this property value pair. */
083:            public void setPropertyValue(SPropertyValue pval) {
084:                putProperty(pval.property, pval.value);
085:            }
086:
087:            /** Removes the value in this Map only.  It may still be inheritable
088:                from other maps or have a default value.  This is quite
089:                different from setting the value to null. */
090:            public void remove(SProperty prop) {
091:                hashMap.remove(prop);
092:                ;
093:            }
094:
095:            /** ## Used to create foreign keys.  But should really be smarter and
096:                use inheritance.  But then multiple inheritiance issues need to
097:                be resolved.
098:            public SPropertyValue [] cloneMap() {
099:              SPropertyValue [] pvals = new SPropertyValue[hashMap.size()];
100:              int px=0;
101:              for (Enumeration keys = hashMap.keys(); 
102:                   keys.hasMoreElements(); px++) {
103:                SProperty prop = (SProperty)keys.nextElement();
104:                pvals[px]=new SPropertyValue(prop, hashMap.get(prop));
105:              }
106:              return pvals;
107:            }
108:             */
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.