Source Code Cross Referenced for Propriedades.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » igor » 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 » ERP CRM Financial » Personal Finance Manager » br.com.igor.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 04/02/2005
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2004  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.igor.config;
024:
025:        import java.lang.reflect.InvocationHandler;
026:        import java.lang.reflect.Method;
027:        import java.lang.reflect.Proxy;
028:        import java.sql.SQLException;
029:        import java.util.Date;
030:        import java.util.HashMap;
031:        import java.util.Map;
032:
033:        import br.com.igor.db.AbstractPersistentObject;
034:        import br.com.igor.db.Coluna;
035:        import br.com.igor.db.Table;
036:        import br.com.igor.plugin.core.DynamicClassLoader;
037:
038:        /**
039:         *
040:         * @author Igor Regis da Silva Simoes
041:         * @since 04/02/2005 11:03:53
042:         */
043:        @Table(name="Propriedades")
044:        public class Propriedades extends AbstractPersistentObject implements 
045:                InvocationHandler {
046:            /**
047:             * Categoria das propriedades. Ex.:Segurança, Conexão a Internet, etc...
048:             */
049:            @Coluna(nome="Categoria",isPk=false,writeMethodName="setCategoria",readMethodName="getCategoria")
050:            private String categoria = null;
051:
052:            /**
053:             * Map com as propriedades desta categoria.
054:             */
055:            @Coluna(nome="Propriedades",isPk=false,writeMethodName="setPropriedades",readMethodName="getPropriedades")
056:            private Map<String, Object> propriedades = new HashMap<String, Object>();
057:
058:            /**
059:             *	Campo ID do objeto
060:             */
061:            @Coluna(nome="Id",isPk=true,writeMethodName="setId",readMethodName="getId")
062:            private Integer id = null;
063:
064:            /**
065:             * Não queremos que ninguem instancie esta classse diretamente
066:             * @param categoria Nome da categoria desta propriedade
067:             */
068:            private Propriedades(String categoria) {
069:                this .categoria = categoria;
070:            }
071:
072:            /**
073:             * Aqui sim nos instanciamos esta classe
074:             * @param impl Interface que o proxy deverá implementar
075:             * @return Retorna uma nova instancia de um proxy listener de eventos
076:             */
077:            public static Object loadPropiedades(Class impl) {
078:                Propriedades proxy = new Propriedades(impl.getName());
079:                return Proxy.newProxyInstance(DynamicClassLoader
080:                        .getClassLoader(), new Class[] { impl }, proxy);
081:            }
082:
083:            /**
084:             * 
085:             * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
086:             */
087:            public Object invoke(Object proxy, Method method, Object[] args)
088:                    throws Throwable {
089:                if (method.getName().equals("getPersistentObject")) {
090:                    return this ;
091:                } else if (method.getName().startsWith("set")) {
092:                    getPropriedades().put(
093:                            method.getName().substring(3,
094:                                    method.getName().length()), args[0]);
095:                } else if (method.getName().startsWith("get")) {
096:                    Object retorno = getPropriedades().get(
097:                            method.getName().substring(3,
098:                                    method.getName().length()));
099:                    if (retorno == null
100:                            && (method.getReturnType().isAssignableFrom(
101:                                    Boolean.class) || method.getReturnType()
102:                                    .isAssignableFrom(boolean.class)))
103:
104:                        return Boolean.valueOf(false);
105:                    else if (retorno == null
106:                            && (method.getReturnType().isAssignableFrom(
107:                                    Number.class)
108:                                    || method.getReturnType().isAssignableFrom(
109:                                            int.class)
110:                                    || method.getReturnType().isAssignableFrom(
111:                                            long.class)
112:                                    || method.getReturnType().isAssignableFrom(
113:                                            double.class)
114:                                    || method.getReturnType().isAssignableFrom(
115:                                            float.class) || method
116:                                    .getReturnType().isAssignableFrom(
117:                                            byte.class)))
118:                        return Integer.valueOf("0");
119:                    else if (method.getReturnType()
120:                            .isAssignableFrom(Date.class)
121:                            && retorno == null)
122:                        return new Date();
123:                    else if (method.getReturnType().isAssignableFrom(
124:                            String.class)
125:                            && retorno == null)
126:                        return "";
127:                    return retorno;
128:                } else if (method.getName().equals("toString")) {
129:                    return toString();
130:                }
131:                return null;
132:            }
133:
134:            /**
135:             * @see br.com.igor.db.PersistentObject#validate()
136:             */
137:            public void validate() throws SQLException {
138:                // Por enquato sem validação
139:            }
140:
141:            /**
142:             * @see br.com.igor.db.PersistentObject#getAsString(int)
143:             */
144:            public String getAsString(int format) {
145:                return toString();
146:            }
147:
148:            /**
149:             * Representação em forma de String
150:             * @see br.com.igor.db.AbstractPersistentObject#toString()
151:             */
152:            @Override
153:            public String toString() {
154:                return "Categoria=" + getCategoria() + " - Propriedades="
155:                        + getPropriedades();
156:            }
157:
158:            /**
159:             * Getter for property id.
160:             * @return Value of property id.
161:             */
162:            public Integer getId() {
163:                return id;
164:            }
165:
166:            /**
167:             * Setter for property id.
168:             * @param id New value of property id.
169:             */
170:            public void setId(Integer id) {
171:                this .id = id;
172:            }
173:
174:            /**
175:             * Retorna a categaria destas propriedades 
176:             * @return String categaria
177:             */
178:            public String getCategoria() {
179:                return categoria;
180:            }
181:
182:            /**
183:             * Indica uma categaria para estas propriedades
184:             * @param categoria String nova categaria
185:             */
186:            public void setCategoria(String categoria) {
187:                this .categoria = categoria;
188:            }
189:
190:            /**
191:             * Um Map com todas propriedades para esta categoria  
192:             * @return Map contendo as prodiedades
193:             */
194:            public Map<String, Object> getPropriedades() {
195:                return propriedades;
196:            }
197:
198:            /**
199:             * Seta uma nova lista de propriedades para esta categoria de propriedades
200:             * @param propriedades Map
201:             */
202:            public void setPropriedades(Map<String, Object> propriedades) {
203:                this.propriedades = propriedades;
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.