Source Code Cross Referenced for RelativeChildObjectRange.java in  » Content-Management-System » harmonise » org » openharmonise » rm » resources » metadata » properties » ranges » 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.resources.metadata.properties.ranges 
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.resources.metadata.properties.ranges;
020:
021:        import java.util.*;
022:
023:        import org.openharmonise.rm.*;
024:        import org.openharmonise.rm.metadata.ChildObjectPropertyInstance;
025:        import org.openharmonise.rm.publishing.State;
026:        import org.openharmonise.rm.resources.*;
027:        import org.w3c.dom.Element;
028:
029:        /**
030:         * Class which represents a <code>Property</code> range which is
031:         * restricted to <code>AbstractChildObject</code> values defined by
032:         * a relative path.
033:         * 
034:         * @author Michael Bell
035:         * @version $Revision: 1.2 $
036:         *
037:         */
038:        public class RelativeChildObjectRange extends AbstractRange implements 
039:                ChildObjectRange {
040:
041:            /**
042:             * Relative child object range tag name.
043:             */
044:            public final static String TAG_RELATIVECHILDOBJECT_RANGE = "RelativeChildObjectRange";
045:
046:            /**
047:             * Constructs a new <code>RelativeChildObjectRange</code>.
048:             */
049:            public RelativeChildObjectRange() {
050:                super (RelativeChildObjectRange.class.getName());
051:            }
052:
053:            /**
054:             * Constructs a <code>RelativeChildObjectRange</code> with the specified
055:             * non class type restrictions.
056:             * 
057:             * @param sDetails the relative path which will be used to determine
058:             * members of this range
059:             */
060:            public RelativeChildObjectRange(String sDetails) {
061:                super (RelativeChildObjectRange.class.getName(), sDetails);
062:            }
063:
064:            /**
065:             * Constructs a <code>RelativeChildObjectRange</code> with the specified
066:             * class and path restrictions.
067:             * 
068:             * @param objName the class name to associated with this range
069:             * @param sDetails the relative path which will be used to determine
070:             * members of this range
071:             */
072:            protected RelativeChildObjectRange(String objName, String sDetails) {
073:                super (objName, sDetails);
074:            }
075:
076:            /* (non-Javadoc)
077:             * @see org.openharmonise.rm.resources.metadata.properties.ranges.Range#isValid(java.lang.Object)
078:             */
079:            public boolean isValid(Object obj) {
080:                boolean bIsValid = false;
081:
082:                return bIsValid;
083:            }
084:
085:            /**
086:             * Returns the list of <code>AbstractChildObject</code> members of this range
087:             * determined by the relative path restriction.
088:             * 
089:             * @param child the <code>AbstractChildObject</code> from which to base
090:             * the relative path restrictions
091:             * @return the list of <code>AbstractChildObject</code> members of this range
092:             * @throws DataAccessException if any errors occur
093:             */
094:            public List getAvailableValues(AbstractChildObject child)
095:                    throws DataAccessException {
096:                List avails = new ArrayList();
097:
098:                AbstractParentObject parent = child.getRealParent();
099:
100:                StringTokenizer tokeniser = new StringTokenizer(m_sDetails, "/");
101:
102:                while (tokeniser.hasMoreTokens() && parent != null) {
103:                    String sToken = tokeniser.nextToken();
104:
105:                    if (sToken != null && sToken.length() > 0) {
106:                        parent = getParentFromPath(parent, sToken);
107:                    }
108:                }
109:
110:                if (parent != null) {
111:                    addAllChildObjectsToList(avails, parent);
112:                }
113:
114:                return avails;
115:            }
116:
117:            /**
118:             * Returns the relative path restriction for this <code>Range</code>.
119:             * 
120:             * @return the relative path restriction for this <code>Range</code>
121:             */
122:            public String getPathRestriction() {
123:                return m_sDetails;
124:            }
125:
126:            /**
127:             * Sets the relative path restriction for this <code>Range</code>.
128:             * 
129:             * @param sPath the relative path restriction for this <code>Range</code>
130:             */
131:            public void setPathRestriction(String sPath) {
132:                setDetails(sPath);
133:
134:            }
135:
136:            /**
137:             * Returns the <code>AbstractParentObject</code> related to the given
138:             * <code>AbstractParentObject</code> by the specified relative path
139:             * segment.
140:             * 
141:             * @param parent the parent object from which to resolve the relative path
142:             * @param sPathSegment the relative path segment. May be '.','..' or a 
143:             * child member's name
144:             * 
145:             * @return the related <code>AbstractParentObject</code>
146:             * @throws DataAccessException if an error occurs accessing the relative
147:             * object
148:             */
149:            private AbstractParentObject getParentFromPath(
150:                    AbstractParentObject parent, String sPathSegment)
151:                    throws DataAccessException {
152:                AbstractParentObject result = null;
153:
154:                if (sPathSegment != null && sPathSegment.length() > 0) {
155:
156:                    if (sPathSegment.equals(".")) {
157:                        result = parent;
158:                    } else if (sPathSegment.equals("..")) {
159:                        result = parent.getRealParent();
160:                    } else {
161:                        AbstractChildObject child = parent
162:                                .getChildByName(sPathSegment);
163:
164:                        if (child instanceof  AbstractParentObject) {
165:                            result = (AbstractParentObject) child;
166:                        }
167:                    }
168:                }
169:
170:                return result;
171:            }
172:
173:            /**
174:             * Adds all the non <code>AbstractParentObject</code> <code>AbstractChildObject</code>s
175:             * of the given <code>AbstractParentObject</code> to the given <code>List</code>.
176:             * 
177:             * @param result the list to add <code>AbstractChildObject</code>s to
178:             * @param parent the <code>AbstractParentObject</code> from which the child
179:             * member will be taken
180:             * 
181:             * @throws DataAccessException if an error occurs accessing child members
182:             * from the <code>AbstractParentObject</code>
183:             */
184:            private void addAllChildObjectsToList(List result,
185:                    AbstractParentObject parent) throws DataAccessException {
186:                Iterator iter = parent.getChildren().iterator();
187:
188:                while (iter.hasNext()) {
189:                    AbstractChildObject child = (AbstractChildObject) iter
190:                            .next();
191:
192:                    if ((child instanceof  AbstractParentObject) == false) {
193:                        result.add(child);
194:                    }
195:
196:                    if (child instanceof  AbstractParentObject) {
197:                        addAllChildObjectsToList(result,
198:                                (AbstractParentObject) child);
199:                    }
200:                }
201:            }
202:
203:            /* (non-Javadoc)
204:             * @see org.openharmonise.rm.resources.metadata.properties.ranges.ChildObjectRange#getChildObjectValueClassName(org.openharmonise.rm.resources.AbstractChildObject)
205:             */
206:            public String getChildObjectValueClassName(AbstractChildObject child) {
207:                return child.getClass().getName();
208:            }
209:
210:            /* (non-Javadoc)
211:             * @see org.openharmonise.rm.resources.metadata.properties.ranges.Range#getPropertyInstanceClass()
212:             */
213:            public Class getPropertyInstanceClass()
214:                    throws ClassNotFoundException {
215:                return ChildObjectPropertyInstance.class;
216:            }
217:
218:            /* (non-Javadoc)
219:             * @see org.openharmonise.rm.publishing.Publishable#getTagName()
220:             */
221:            public String getTagName() {
222:                return TAG_RELATIVECHILDOBJECT_RANGE;
223:            }
224:
225:            /* (non-Javadoc)
226:             * @see org.openharmonise.rm.publishing.Publishable#populate(org.w3c.dom.Element, org.openharmonise.rm.publishing.State)
227:             */
228:            public void populate(Element xmlElement, State state)
229:                    throws PopulateException {
230:                String sTagname = xmlElement.getTagName();
231:
232:                if (sTagname.equals(TAG_PATH_RESTRICTION)) {
233:                    String sPath = xmlElement.getFirstChild().getNodeValue();
234:                    setPathRestriction(sPath);
235:                } else {
236:                    super .populate(xmlElement, state);
237:                }
238:
239:            }
240:
241:            /* (non-Javadoc)
242:             * @see org.openharmonise.rm.resources.metadata.properties.ranges.ChildObjectRange#getChildObjectValueClassName(java.lang.Class)
243:             */
244:            public String getChildObjectValueClassName(Class clss) {
245:                return clss.getName();
246:            }
247:
248:        }
w___w_w_.j_av___a2s__.__c___o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.