Source Code Cross Referenced for PropertyAccessor.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » model2 » 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 » ERP CRM Financial » jmoney » net.sf.jmoney.model2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *  JMoney - A Personal Finance Manager
004:         *  Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
005:         *
006:         *
007:         *  This program is free software; you can redistribute it and/or modify
008:         *  it under the terms of the GNU General Public License as published by
009:         *  the Free Software Foundation; either version 2 of the License, or
010:         *  (at your option) any later version.
011:         *
012:         *  This program is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         *  GNU General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU General Public License
018:         *  along with this program; if not, write to the Free Software
019:         *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020:         *
021:         */
022:
023:        package net.sf.jmoney.model2;
024:
025:        /**
026:         * This class contains information about a property.  The property may be in the base
027:         * bookkeeping class or in an extension bookkeeping class.
028:         *
029:         * This object contains the metadata.
030:         *
031:         * Some properties may be allowed to take null values and
032:         * some may not.  The determination is made by the JMoney framework
033:         * by looking at the type returned by the getter method.
034:         * <P>
035:         * The following properties may take null values:
036:         * <UL>
037:         * <LI>All properties that reference extendable objects</LI>
038:         * <LI>All properties of type String, Date or other such simple class</LI>
039:         * <LI>All properties where the type is one of the classes representing intrinsic types,
040:         * 			such as Integer, Long</LI>
041:         * </UL>
042:         * The following properties may not take null values:
043:         * <UL>
044:         * <LI>All properties where the type is an intrinsic type, such as int, long</LI>
045:         * </UL>
046:         * 
047:         * @author  Nigel Westbury
048:         */
049:        public abstract class PropertyAccessor {
050:
051:            protected PropertySet propertySet;
052:
053:            protected String localName;
054:
055:            protected String displayName;
056:
057:            /**
058:             * Index into the list of parameters passed to the constructor.
059:             * Zero indicates that this property is passed as the first
060:             * parameter to the constructor.
061:             * 
062:             */
063:            protected int indexIntoConstructorParameters = -1;
064:
065:            public PropertyAccessor(PropertySet propertySet, String localName,
066:                    String displayName) {
067:                this .propertySet = propertySet;
068:                this .localName = localName;
069:                this .displayName = displayName;
070:            }
071:
072:            /**
073:             * Create a property accessor for a list property.
074:             * 
075:             * @param set
076:             * @param name
077:             * @param listItemClass
078:             * @param displayName
079:             * @param propertyDependency
080:             */
081:            public PropertyAccessor(PropertySet propertySet, String localName,
082:                    String displayName,
083:                    Class<? extends ExtendableObject> listItemClass) {
084:                this .propertySet = propertySet;
085:                this .localName = localName;
086:                this .displayName = displayName;
087:            }
088:
089:            /**
090:             * Returns the property set which contains this property.
091:             */
092:            // TODO: Check all the uses of this.  Some of the uses require
093:            // that for extension property sets, the property set being
094:            // extended should be returned.  This saves the caller from having
095:            // to test the property set.
096:            public PropertySet getPropertySet() {
097:                return propertySet;
098:            }
099:
100:            /**
101:             * Returns the extendable property set which contains this property.
102:             * 
103:             * If the property is in an extendable property set then this
104:             * method returns the same value as <code>getPropertySet()</code>.
105:             * If the property is in an extension property set then
106:             * the property set being extended is returned.
107:             */
108:            // TODO: Consider removing this method.  It is not used.
109:            /*	
110:             public PropertySet getExtendablePropertySet() {
111:             if (propertySet.isExtension()) {
112:             return propertySet.getExtendablePropertySet();
113:             } else {
114:             return propertySet;
115:             }
116:             }
117:             */
118:            /**
119:             * Returns the PropertySet for the values of this property.
120:             * This property must contain a value or values that are
121:             * extendable objects. 
122:             */
123:            /* not used.   
124:             public PropertySet getValuePropertySet() {
125:             for (Iterator iter = PropertySet.getPropertySetIterator(); iter.hasNext(); ) {
126:             PropertySet propertySet = (PropertySet)iter.next();
127:             if (!propertySet.isExtension()) {
128:             if (propertySet.getImplementationClass() == propertyClass) {
129:             return propertySet;
130:             }
131:             }
132:             }
133:            
134:             throw new RuntimeException("No property set found for extendable class object" + propertyClass.getName() + ".");
135:             }
136:             */
137:            /**
138:             * Return a name for this property.
139:             *
140:             * This name is used by the framework for persisting information about the property
141:             * in configuration files etc.  For example, if the user sorts a column based on a
142:             * property then that information can be stored in a configuration file so that the
143:             * data is sorted on the column the next time the user loads the view.
144:             */
145:            public String getName() {
146:                // We must uniquify the name, so prepend the property set id.
147:                // TODO: this does not uniquify the name because a property may
148:                // exist with the same name as both, say, an account property
149:                // and an entry property.  We should probably add the base
150:                // class name here too.
151:                return propertySet.toString() + "." + localName;
152:            }
153:
154:            /**
155:             * The local name of the property is just the last part of the name, after
156:             * the last dot. This will be unique within an extension but may not be
157:             * unique across all plugins or even across extensions to different types of
158:             * bookkeeping objects (entries, categories, transactions, or commodities)
159:             * within a plug-in.
160:             */
161:            public String getLocalName() {
162:                return localName;
163:            }
164:
165:            /**
166:             * A short description that is suitable as a column header when this
167:             * property is displayed in a table.
168:             */
169:            public String getDisplayName() {
170:                return displayName;
171:            }
172:
173:            /**
174:             * Indicates if the property is a list of intrinsic values or objects.
175:             */
176:            public abstract boolean isList();
177:
178:            /**
179:             * Indicates if the property is a single intrinsic value or object
180:             * (not a list of values)
181:             */
182:            public boolean isScalar() {
183:                return !isList();
184:            }
185:
186:            /**
187:             * @return the index into the constructor parameters, where
188:             * 		an index of zero indicates that the property is the
189:             * 		first parameter to the constructor.  An index of -1
190:             * 		indicates that the property is not passed to the
191:             * 		constructor (the property value is redundant and the
192:             * 		object can be fully re-constructed from the other
193:             * 		properties).
194:             */
195:            public int getIndexIntoConstructorParameters() {
196:                return indexIntoConstructorParameters;
197:            }
198:
199:            /**
200:             * 
201:             * @param indexIntoConstructorParameters
202:             */
203:            // TODO: This method should be accessible only from within the package. 
204:            public void setIndexIntoConstructorParameters(
205:                    int indexIntoConstructorParameters) {
206:                this.indexIntoConstructorParameters = indexIntoConstructorParameters;
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.