Source Code Cross Referenced for ModelKeyMap.java in  » ERP-CRM-Financial » ofbiz » org » ofbiz » entity » model » 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 » ofbiz » org.ofbiz.entity.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.entity.model;
019:
020:        import java.util.List;
021:
022:        import org.w3c.dom.Document;
023:        import org.w3c.dom.Element;
024:
025:        import org.ofbiz.base.util.UtilMisc;
026:        import org.ofbiz.base.util.UtilXml;
027:
028:        /**
029:         * Generic Entity - KeyMap model class
030:         *
031:         */
032:        public class ModelKeyMap implements  java.io.Serializable {
033:
034:            /** name of the field in this entity */
035:            protected String fieldName = "";
036:
037:            /** name of the field in related entity */
038:            protected String relFieldName = "";
039:
040:            /** Default Constructor */
041:            public ModelKeyMap() {
042:            }
043:
044:            /** Data Constructor, if relFieldName is null defaults to fieldName */
045:            public ModelKeyMap(String fieldName, String relFieldName) {
046:                this .fieldName = fieldName;
047:                this .relFieldName = UtilXml.checkEmpty(relFieldName,
048:                        this .fieldName);
049:            }
050:
051:            /** XML Constructor */
052:            public ModelKeyMap(Element keyMapElement) {
053:                this .fieldName = UtilXml.checkEmpty(keyMapElement
054:                        .getAttribute("field-name"));
055:                // if no relFieldName is specified, use the fieldName; this is convenient for when they are named the same, which is often the case
056:                this .relFieldName = UtilXml.checkEmpty(keyMapElement
057:                        .getAttribute("rel-field-name"), this .fieldName);
058:            }
059:
060:            /** name of the field in this entity */
061:            public String getFieldName() {
062:                return this .fieldName;
063:            }
064:
065:            public void setFieldName(String fieldName) {
066:                this .fieldName = fieldName;
067:            }
068:
069:            /** name of the field in related entity */
070:            public String getRelFieldName() {
071:                return this .relFieldName;
072:            }
073:
074:            public void setRelFieldName(String relFieldName) {
075:                this .relFieldName = relFieldName;
076:            }
077:
078:            // ======= Some Convenience Oriented Factory Methods =======
079:            public static List makeKeyMapList(String fieldName1) {
080:                return UtilMisc.toList(new ModelKeyMap(fieldName1, null));
081:            }
082:
083:            public static List makeKeyMapList(String fieldName1,
084:                    String relFieldName1) {
085:                return UtilMisc.toList(new ModelKeyMap(fieldName1,
086:                        relFieldName1));
087:            }
088:
089:            public static List makeKeyMapList(String fieldName1,
090:                    String relFieldName1, String fieldName2,
091:                    String relFieldName2) {
092:                return UtilMisc.toList(new ModelKeyMap(fieldName1,
093:                        relFieldName1), new ModelKeyMap(fieldName2,
094:                        relFieldName2));
095:            }
096:
097:            public static List makeKeyMapList(String fieldName1,
098:                    String relFieldName1, String fieldName2,
099:                    String relFieldName2, String fieldName3,
100:                    String relFieldName3) {
101:                return UtilMisc.toList(new ModelKeyMap(fieldName1,
102:                        relFieldName1), new ModelKeyMap(fieldName2,
103:                        relFieldName2), new ModelKeyMap(fieldName3,
104:                        relFieldName3));
105:            }
106:
107:            public int hashCode() {
108:                return this .fieldName.hashCode() + this .relFieldName.hashCode();
109:            }
110:
111:            public boolean equals(Object other) {
112:                ModelKeyMap otherKeyMap = (ModelKeyMap) other;
113:
114:                if (!otherKeyMap.fieldName.equals(this .fieldName))
115:                    return false;
116:                if (!otherKeyMap.relFieldName.equals(this .relFieldName))
117:                    return false;
118:
119:                return true;
120:            }
121:
122:            public Element toXmlElement(Document document) {
123:                Element root = document.createElement("key-map");
124:                root.setAttribute("field-name", this .getFieldName());
125:                if (!this .getFieldName().equals(this .getRelFieldName())) {
126:                    root.setAttribute("rel-field-name", this.getRelFieldName());
127:                }
128:
129:                return root;
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.