Source Code Cross Referenced for MappedPreference.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » migration » model20 » impl » preferences » 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 » Portal » jboss portal 2.6.4 » org.jboss.portal.migration.model20.impl.preferences 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software 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 GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.migration.model20.impl.preferences;
023:
024:        import org.jboss.portal.migration.model20.model.Preference;
025:        import org.jboss.portal.migration.model20.other.StringValues;
026:        import org.jboss.portal.migration.model20.other.Value;
027:
028:        /**
029:         * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
030:         * @version $Revision: 8784 $
031:         * @hibernate.class table="test_pref"
032:         */
033:        public class MappedPreference implements  Preference {
034:
035:            private static final String[] EMPTY_STRING_ARRAY = new String[0];
036:            private static final Value EMPTY_VALUE = new StringValues(
037:                    EMPTY_STRING_ARRAY);
038:
039:            /*
040:             // The id
041:             private Integer id;
042:
043:             // The name
044:             private String name;
045:
046:             // The db value
047:             private int type;
048:             private String[] strings;
049:             */
050:
051:            // The id
052:            public Integer id;
053:
054:            // The name
055:            public String name;
056:
057:            // The db value
058:            public int type;
059:            public String[] strings;
060:
061:            // The value which is actually equals to type+strings
062:            private Value value;
063:
064:            // This flag is used because the value is made up of strings and type
065:            // and it is not possible to update the value when strings or type
066:            // is updated, so when strings of type is modified with set dirty
067:            private boolean dirty;
068:
069:            public MappedPreference() {
070:                this .id = null;
071:                this .name = null;
072:                this .type = 0;
073:                this .strings = EMPTY_STRING_ARRAY;
074:                this .value = EMPTY_VALUE;
075:                this .dirty = false;
076:            }
077:
078:            public MappedPreference(String name) {
079:                this .id = null;
080:                this .name = name;
081:                this .type = 0;
082:                this .strings = EMPTY_STRING_ARRAY;
083:                this .value = EMPTY_VALUE;
084:            }
085:
086:            /** @hibernate.id column="jbp_id" generator-class="native" */
087:            protected Integer getID() {
088:                return id;
089:            }
090:
091:            /** Called by hibernate. */
092:            protected void setID(Integer id) {
093:                this .id = id;
094:            }
095:
096:            /** @hibernate.property column="jbp_name" not-null="true" update="false" */
097:            public String getName() {
098:                return name;
099:            }
100:
101:            /** Called by hibernate. */
102:            protected void setName(String name) {
103:                this .name = name;
104:            }
105:
106:            /** @hibernate.property column="jbp_type" */
107:            public int getType() {
108:                return type;
109:            }
110:
111:            /** Called by hibernate. */
112:            protected void setType(int type) {
113:                this .type = type;
114:                this .dirty = true;
115:            }
116:
117:            /**
118:             * @hibernate.array table="test_prop_value" cascade="all"
119:             * @hibernate.collection-key column="jbp_prop_id"
120:             * @hibernate.collection-index column="jbp_idx"
121:             * @hibernate.collection-element column="jbp_value" type="string"
122:             */
123:            public String[] getStrings() {
124:                return strings;
125:            }
126:
127:            public void setValue(Value value) {
128:                TypedStringArray tsa = ValueManager
129:                        .createTypedStringArray(value);
130:                this .value = value;
131:                this .type = tsa.getType();
132:                this .strings = tsa.getStrings();
133:            }
134:
135:            /** Called by hibernate. */
136:            private void setStrings(String[] strings) {
137:                this .strings = strings;
138:                this .dirty = true;
139:            }
140:
141:            public Value getValue() {
142:                if (dirty) {
143:                    value = ValueManager.createValue(new TypedStringArray(type,
144:                            strings));
145:                    dirty = false;
146:                }
147:                return value;
148:            }
149:
150:            /** By default it's never read only. Subclasses may provide custom behaviour here. */
151:            public boolean isReadOnly() {
152:                return false;
153:            }
154:
155:            /** Provide a default impl. */
156:            public String toString() {
157:                StringBuffer buffer = new StringBuffer("[");
158:                buffer.append(id).append(",").append(name).append(",");
159:                if (strings == null) {
160:                    buffer.append("null,");
161:                } else {
162:                    buffer.append("(");
163:                    for (int i = 0; i < strings.length; i++) {
164:                        String s = strings[i];
165:                        buffer.append(i > 0 ? "," : "").append(s);
166:                    }
167:                    buffer.append("),");
168:                }
169:                buffer.append(value).append("]");
170:                return buffer.toString();
171:            }
172:        }
w__w_w___.___j___a__v___a__2s__._c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.