Source Code Cross Referenced for PropertyInstanceFactory.java in  » Content-Management-System » harmonise » org » openharmonise » rm » metadata » 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 » Content Management System » harmonise » org.openharmonise.rm.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.rm.metadata;
020:
021:        import org.openharmonise.commons.dsi.AbstractDataStoreInterface;
022:        import org.openharmonise.commons.xml.XMLUtils;
023:        import org.openharmonise.rm.*;
024:        import org.openharmonise.rm.factory.*;
025:        import org.openharmonise.rm.resources.AbstractObject;
026:        import org.openharmonise.rm.resources.metadata.properties.Property;
027:        import org.openharmonise.rm.resources.metadata.properties.ranges.Range;
028:        import org.w3c.dom.Element;
029:
030:        /**
031:         * A factory class providing <code>static</code> methods for returning
032:         * property instances.
033:         * 
034:         * @author Michael Bell
035:         * @version $Revision: 1.6 $
036:         *  
037:         */
038:        public class PropertyInstanceFactory {
039:
040:            /**
041:             * Constructs a <code>PropertyInstanceFactory</code>
042:             * 
043:             * Note: this a <code>private</code> method so will never be called
044:             */
045:            private PropertyInstanceFactory() {
046:                super ();
047:            }
048:
049:            /**
050:             * Returns the appropriate property instance for the given property insatnce
051:             * XML element.
052:             * 
053:             * @param dsi the data store interface
054:             * @param el the property instance XML element
055:             * @param prof the <code>Profile</code> that the returned property 
056:             * instance will be associated with
057:             * @return the appropriate property instance for the given 
058:             * XML element
059:             * @throws DataAccessException if there is an error getting the 
060:             * <code>Range</code> details from the associated <code>Property</code>
061:             * @throws HarmoniseFactoryException if there is an error getting the 
062:             * assocaited <code>Property</code> from the cache
063:             * @throws ProfileException if there is an error adding the property 
064:             * instance to the profile
065:             */
066:            public static AbstractPropertyInstance getPropertyInstance(
067:                    AbstractDataStoreInterface dsi, Element el, Profile prof)
068:                    throws DataAccessException, HarmoniseFactoryException,
069:                    ProfileException {
070:                AbstractPropertyInstance propInst = getPropertyInstance(dsi, el);
071:                if (prof != null) {
072:                    AbstractPropertyInstance tmpPropInst = prof
073:                            .getPropertyInstance(propInst.getProperty());
074:
075:                    if (tmpPropInst != null) {
076:                        try {
077:                            tmpPropInst.populate(el, null);
078:                        } catch (PopulateException e) {
079:                            throw new DataAccessException(e);
080:                        }
081:                        propInst = tmpPropInst;
082:                    } else {
083:                        prof.addPropertyInstance(propInst);
084:                    }
085:
086:                }
087:
088:                return propInst;
089:            }
090:
091:            /**
092:             * Returns the appropriate property instance for the given property instance
093:             * XML element.
094:             * 
095:             * @param dsi the data store interface
096:             * @param el the property instance XML element
097:             * @return the appropriate property instance for the given XML element
098:             * @throws DataAccessException if there is an error getting the <code>Range</code> details
099:             * from the associated <code>Property</code>
100:             * @throws HarmoniseFactoryException if there is an error getting the assocaited
101:             * <code>Property</code> from the cache
102:             */
103:            public static AbstractPropertyInstance getPropertyInstance(
104:                    AbstractDataStoreInterface dsi, Element el)
105:                    throws DataAccessException, HarmoniseFactoryException {
106:                Element propertyElm = XMLUtils.getFirstNamedChild(el,
107:                        Property.TAG_PROPERTY);
108:                // get the property tag
109:                String sPropertyId = el.getAttribute(AbstractObject.ATTRIB_ID);
110:
111:                Property prop = null;
112:
113:                prop = (Property) HarmoniseObjectFactory
114:                        .instantiatePublishableObject(dsi, propertyElm, null);
115:
116:                if (prop == null) {
117:                    throw new HarmoniseFactoryException(
118:                            "Could not find property requested");
119:                }
120:
121:                return getPropertyInstance(dsi, prop);
122:            }
123:
124:            /**
125:             * Returns an appropriate concrete implementation of
126:             * <code>AbstractPropertyInstance</code> for the specified
127:             * <code>Property</code>.
128:             * 
129:             * @param dsi the data store interface
130:             * @param prop the <code>Property</code> for which a property 
131:             * instance is needed
132:             * @return an appropriate concrete implementation of
133:             * <code>AbstractPropertyInstance</code> for the specified
134:             * <code>Property</code>
135:             * @throws DataAccessException if there is an error getting 
136:             * the <code>Range</code> details from the associated <code>Property</code>
137:             */
138:            public static AbstractPropertyInstance getPropertyInstance(
139:                    AbstractDataStoreInterface dsi, Property prop)
140:                    throws DataAccessException {
141:                AbstractPropertyInstance propInst = null;
142:
143:                Range range = prop.getRange();
144:
145:                try {
146:                    if (range != null) {
147:                        propInst = (AbstractPropertyInstance) range
148:                                .getPropertyInstanceClass().newInstance();
149:                        propInst.setDataStoreInterface(dsi);
150:                        propInst.setProperty(prop);
151:                    } else {
152:                        throw new DataAccessException(
153:                                "Unable to get Property instance with no range");
154:                    }
155:                } catch (PopulateException e) {
156:                    throw new DataAccessException(e.getLocalizedMessage(), e);
157:                } catch (InstantiationException e) {
158:                    throw new DataAccessException(e.getLocalizedMessage(), e);
159:                } catch (IllegalAccessException e) {
160:                    throw new DataAccessException(e.getLocalizedMessage(), e);
161:                } catch (ClassNotFoundException e) {
162:                    throw new DataAccessException(e.getLocalizedMessage(), e);
163:                }
164:
165:                return propInst;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.