Source Code Cross Referenced for PropertyImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » impl » metabossmodel » datadictionarymodel » 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 » UML » MetaBoss » com.metaboss.sdlctools.models.impl.metabossmodel.datadictionarymodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.models.impl.metabossmodel.datadictionarymodel;
016:
017:        import java.util.ArrayList;
018:        import java.util.Collection;
019:        import java.util.Collections;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import org.netbeans.mdr.storagemodel.StorableObject;
024:
025:        import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementImpl;
026:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
027:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Property;
028:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.PropertyDescriptor;
029:
030:        public abstract class PropertyImpl extends ModelElementImpl implements 
031:                Property {
032:            // Required constructor
033:            protected PropertyImpl(StorableObject storable) {
034:                super (storable);
035:            }
036:
037:            // Helper. Returns array of all subproperties (not only immedate ones)
038:            public Collection getCombinedProperties() {
039:                ArrayList lCombinedProperties = new ArrayList();
040:                Collection lSubProperties = getSubProperties();
041:                if (!lSubProperties.isEmpty()) {
042:                    Iterator lSubPropertiesIterator = lSubProperties.iterator();
043:                    while (lSubPropertiesIterator.hasNext()) {
044:                        Property lSubProperty = (Property) lSubPropertiesIterator
045:                                .next();
046:                        lCombinedProperties.add(lSubProperty);
047:                        lCombinedProperties.addAll(lSubProperty
048:                                .getCombinedProperties());
049:                    }
050:                }
051:                return Collections.unmodifiableCollection(lCombinedProperties);
052:            }
053:
054:            /** @return property key in format name(optional index[i]).name(optional index[i]).......
055:             * This key is unique and good for use in property files */
056:            public String getKey() {
057:                StringBuffer lKeyBuffer = new StringBuffer();
058:                Property lParentProperty = getParentProperty();
059:                if (lParentProperty != null) {
060:                    // We are child property - call to get parent's key
061:                    lKeyBuffer.append(lParentProperty.getKey());
062:                    lKeyBuffer.append(".");
063:                }
064:                lKeyBuffer.append(getName());
065:                // Calculate and append index if necessary
066:                PropertyDescriptor lPropertyDescriptor = getDescriptor();
067:                if (lPropertyDescriptor != null
068:                        && lPropertyDescriptor.isArray()) {
069:                    lKeyBuffer.append("[");
070:                    lKeyBuffer.append(getArrayIndex());
071:                    lKeyBuffer.append("]");
072:                }
073:                return lKeyBuffer.toString();
074:            }
075:
076:            public Integer getArrayIndex() {
077:                Property lParentProperty = getParentProperty();
078:                DataType lParentDataType = getDataType();
079:                List lParentsPropertiesList = null;
080:                if (lParentProperty != null) {
081:                    lParentsPropertiesList = lParentProperty.getSubProperties();
082:                } else if (lParentDataType != null) {
083:                    lParentsPropertiesList = lParentDataType
084:                            .getTypetemplateProperties();
085:                } else
086:                    throw new RuntimeException(
087:                            "Unexpected situation. Property must be owned by DataType or another Property.");
088:                // Calculate the number of instances of the property which is governed by the same descriptor
089:                // and which occurs prior to this instance
090:                int lNumberOfInstancesPrior = 0;
091:                PropertyDescriptor lPropertyDescriptor = getDescriptor();
092:                if (lPropertyDescriptor != null
093:                        && lPropertyDescriptor.isArray()) {
094:                    for (Iterator lParentPropertiesIterator = lParentsPropertiesList
095:                            .iterator(); lParentPropertiesIterator.hasNext();) {
096:                        Property lOtherProperty = (Property) lParentPropertiesIterator
097:                                .next();
098:                        if (lOtherProperty.equals(this ))
099:                            break; // Hit ourselves - time to get out
100:                        if (lOtherProperty.getDescriptor().equals(
101:                                lPropertyDescriptor))
102:                            lNumberOfInstancesPrior++; // Hit our sibling - increase the counter
103:                    }
104:                    lNumberOfInstancesPrior++; // Array index starts with one. Non array properties have index zero
105:                }
106:                return new Integer(lNumberOfInstancesPrior);
107:            }
108:
109:            /**
110:             * @param pPropertyKey 
111:             * @return Property with specified name or throws exception if none found
112:             */
113:            public Property getPropertyByKey(String pPropertyKey) {
114:                Property lFoundProperty = findPropertyByKey(pPropertyKey);
115:                // Throw exception if nothing found
116:                if (lFoundProperty == null)
117:                    throw new IllegalArgumentException(
118:                            "Unable to locate Property with key '"
119:                                    + pPropertyKey
120:                                    + "' in Property. PropertyRef: " + getRef()
121:                                    + ". PropertyKey: " + getKey());
122:                return lFoundProperty;
123:            }
124:
125:            /** Retrieves the property with the specified key or returns null if none found 
126:             * @param pPropertyKey 
127:             * @return Property with specified name or null if none found
128:             */
129:            public Property findPropertyByKey(String pPropertyKey) {
130:                // Disassemble the property key to its components
131:                String lThisKey = null;
132:                String lSubKey = null;
133:                String lThisName = null;
134:                int lThisArayIndex = 0;
135:                {
136:                    int lFirstDotIndex = pPropertyKey.indexOf('.');
137:                    if (lFirstDotIndex > 0) {
138:                        lThisKey = pPropertyKey.substring(0, lFirstDotIndex);
139:                        lSubKey = pPropertyKey.substring(lFirstDotIndex + 1);
140:                    } else {
141:                        lThisKey = pPropertyKey;
142:                        lSubKey = null;
143:                    }
144:                    if (lThisKey.endsWith("]")) {
145:                        int lOpenBracketPos = lThisKey.indexOf('[');
146:                        int lCloseBracketPos = lThisKey.length() - 1;
147:                        lThisName = lThisKey.substring(0, lOpenBracketPos);
148:                        lThisArayIndex = Integer.parseInt(lThisKey.substring(
149:                                lOpenBracketPos + 1, lCloseBracketPos));
150:                    } else {
151:                        lThisName = lThisKey;
152:                        lThisArayIndex = 0;
153:                    }
154:                }
155:                // Now iterate through properties loking for a match
156:                Collection lProperties = getSubProperties();
157:                for (Iterator lPropertiesIterator = lProperties.iterator(); lPropertiesIterator
158:                        .hasNext();) {
159:                    Property lProperty = (Property) lPropertiesIterator.next();
160:                    if (lProperty.getName().equals(lThisName) == false)
161:                        continue; // Name mismatch
162:                    if ((lThisArayIndex > 0)
163:                            && (lProperty.getArrayIndex() == null || lProperty
164:                                    .getArrayIndex().intValue() != lThisArayIndex))
165:                        continue; // position mismatch
166:                    // Looks like it is ours
167:                    if (lSubKey != null)
168:                        return lProperty.findPropertyByKey(lSubKey); // Look for the subkey
169:                    return lProperty; // Found match	
170:                }
171:                return null; // Could not match
172:            }
173:
174:            // Returns all properties described by given descriptor	
175:            public Collection getPropertiesByDescriptor(
176:                    PropertyDescriptor pDescriptor) {
177:                List lProperties = new ArrayList();
178:                for (Iterator lPropertiesIterator = getCombinedProperties()
179:                        .iterator(); lPropertiesIterator.hasNext();) {
180:                    Property lProperty = (Property) lPropertiesIterator.next();
181:                    if (lProperty.getDescriptor().equals(pDescriptor))
182:                        lProperties.add(lProperty);
183:                }
184:                return Collections.unmodifiableCollection(lProperties);
185:            }
186:        }
w___w__w_._j___av___a_2__s_.___c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.