Source Code Cross Referenced for MultipleKey.java in  » Web-Framework » makumba » org » makumba » commons » 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 Framework » makumba » org.makumba.commons 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        ///////////////////////////////
002:        //  Makumba, Makumba tag library
003:        //  Copyright (C) 2000-2003  http://www.makumba.org
004:        //
005:        //  This library is free software; you can redistribute it and/or
006:        //  modify it under the terms of the GNU Lesser General Public
007:        //  License as published by the Free Software Foundation; either
008:        //  version 2.1 of the License, or (at your option) any later version.
009:        //
010:        //  This library is distributed in the hope that it will be useful,
011:        //  but WITHOUT ANY WARRANTY; without even the implied warranty of
012:        //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:        //  Lesser General Public License for more details.
014:        //
015:        //  You should have received a copy of the GNU Lesser General Public
016:        //  License along with this library; if not, write to the Free Software
017:        //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:        //
019:        //  -------------
020:        //  $Id: MultipleKey.java 1903 2007-10-24 09:05:37Z manuel_gay $
021:        //  $Name$
022:        /////////////////////////////////////
023:
024:        package org.makumba.commons;
025:
026:        import java.io.Serializable;
027:        import java.util.Dictionary;
028:        import java.util.Vector;
029:
030:        /**
031:         * Holds the values for a group of fields. Every element of a MultipleKey holds an Object. In case of a null value being
032:         * passed to one of the constructors, the element is replaced by a placeholder.
033:         * 
034:         * @author Cristian Bogdan
035:         * @version $Id: MultipleKey.java 1903 2007-10-24 09:05:37Z manuel_gay $
036:         */
037:        public class MultipleKey extends Vector implements  Serializable {
038:
039:            private static final long serialVersionUID = 1L;
040:
041:            /**
042:             * Dummy object holding the place for a null element
043:             */
044:            static private final Object theNull = new Object() {
045:                public String toString() {
046:                    return "null key member";
047:                }
048:            };
049:
050:            public MultipleKey(int size) {
051:                super (size);
052:            }
053:
054:            public MultipleKey(Vector v) {
055:                this (v, v.size());
056:            }
057:
058:            public MultipleKey(Vector v, int size) {
059:                super (size);
060:                for (; elementCount < v.size(); elementCount++)
061:                    elementData[elementCount] = checkNull(v
062:                            .elementAt(elementCount));
063:            }
064:
065:            /**
066:             * Extends the Vector v and adds the object
067:             * @param v An instance of Vector 
068:             * @param o An object to be added
069:             */
070:            public MultipleKey(Vector v, Object o) {
071:                this (v, v.size() + 1);
072:                setAt(o, v.size());
073:            }
074:
075:            public MultipleKey(Object o[]) {
076:                this (o, o.length);
077:            }
078:
079:            public MultipleKey(Object o[], int size) {
080:                super (size);
081:                for (; elementCount < o.length; elementCount++)
082:                    elementData[elementCount] = checkNull(o[elementCount]);
083:            }
084:
085:            /**
086:             * Keeps together the values associated with the give keys
087:             * 
088:             * @param keys
089:             *            A vector of keys
090:             * @param data
091:             *            The dictionary containing the values of the keys
092:             */
093:            public MultipleKey(Vector keys, Dictionary data) {
094:                this (keys, data, keys.size());
095:            }
096:
097:            /**
098:             * Keeps together the values associated with the given keys
099:             * 
100:             * @param keys
101:             *            A vector of keys
102:             * @param data
103:             *            The dictionary containing the values of the keys
104:             * @param size
105:             *            The size of the MultipleKey object to be constructed
106:             */
107:            public MultipleKey(Vector keys, Dictionary data, int size) {
108:                super (size);
109:                for (; elementCount < keys.size(); elementCount++)
110:                    elementData[elementCount] = checkNull(data.get(keys
111:                            .elementAt(elementCount)));
112:            }
113:
114:            /**
115:             * Keeps together the values associated with the given keys
116:             * 
117:             * @param indexes
118:             *            A vector of keys
119:             * @param data
120:             *            The object array containing the values of the keys
121:             */
122:            public MultipleKey(Vector indexes, Object[] data) {
123:                this (indexes, data, indexes.size());
124:            }
125:
126:            /**
127:             * Keep together the values associated with the given keys
128:             * 
129:             * @param indexes
130:             *            A vector of keys
131:             * @param data
132:             *            The object array containing the values of the keys
133:             * @param size
134:             *            The size of the MultipleKey object to be constructed
135:             */
136:            public MultipleKey(Vector indexes, Object[] data, int size) {
137:                super (size);
138:                for (; elementCount < indexes.size(); elementCount++)
139:                    elementData[elementCount] = checkNull(data[((Integer) indexes
140:                            .elementAt(elementCount)).intValue()]);
141:            }
142:
143:            public void setAt(Object o, int n) {
144:                if (elementCount <= n)
145:                    elementCount = n + 1;
146:                elementData[n] = checkNull(o);
147:            }
148:
149:            protected Object checkNull(Object o) {
150:                return o == null ? theNull : o;
151:            }
152:
153:            /**
154:             * Compares the elements of two MultipleKey objects
155:             * 
156:             * @param o
157:             *            The object to be compared with
158:             */
159:            public boolean equals(Object o) {
160:                for (int i = 0; i < elementCount; i++)
161:                    if (!((MultipleKey) o).elementAt(i).equals(elementData[i]))
162:                        return false;
163:                return true;
164:            }
165:
166:            /**
167:             * Computes a hash code of the MultipleKey by adding the individual hashcodes of each element
168:             * 
169:             * @return The hashcode of the MultipleKey
170:             */
171:            public int hashCode() {
172:                int ret = 0;
173:                for (int i = 0; i < elementCount; i++)
174:                    ret += elementData[i].hashCode();
175:                return ret;
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.