Source Code Cross Referenced for StructureAttributes.java in  » XML » jibx-1.1.5 » org » jibx » binding » 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 » XML » jibx 1.1.5 » org.jibx.binding.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        Copyright (c) 2004-2005, Dennis M. Sosnoski
003:        All rights reserved.
004:
005:        Redistribution and use in source and binary forms, with or without modification,
006:        are permitted provided that the following conditions are met:
007:
008:         * Redistributions of source code must retain the above copyright notice, this
009:           list of conditions and the following disclaimer.
010:         * Redistributions in binary form must reproduce the above copyright notice,
011:           this list of conditions and the following disclaimer in the documentation
012:           and/or other materials provided with the distribution.
013:         * Neither the name of JiBX nor the names of its contributors may be used
014:           to endorse or promote products derived from this software without specific
015:           prior written permission.
016:
017:        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018:        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019:        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021:        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         */
028:
029:        package org.jibx.binding.model;
030:
031:        import org.jibx.binding.util.StringArray;
032:
033:        /**
034:         * Model component for <b>structure</b> attribute group in binding definition.
035:         *
036:         * @author Dennis M. Sosnoski
037:         * @version 1.0
038:         */
039:        public class StructureAttributes extends AttributeBase {
040:            /** Enumeration of allowed attribute names */
041:            public static final StringArray s_allowedAttributes = new StringArray(
042:                    new String[] { "allow-repeats", "choice", "flexible",
043:                            "label", "ordered", "using" });
044:
045:            //
046:            // Instance data.
047:
048:            /** Flexible element handling flag. */
049:            private boolean m_isFlexible;
050:
051:            /** Flag for ordered child content. */
052:            private boolean m_isOrdered;
053:
054:            /** Flag for choice child content. */
055:            private boolean m_isChoice;
056:
057:            /** Flag for repeated child elements to be ignored. */
058:            private boolean m_isAllowRepeats;
059:
060:            /** Name for labeled child content defined elsewhere. */
061:            private String m_usingName;
062:
063:            /** Name for labeled child content potentially referenced elsewhere. */
064:            private String m_labelName;
065:
066:            /**
067:             * Constructor.
068:             */
069:            public StructureAttributes() {
070:                m_isOrdered = true;
071:            }
072:
073:            /**
074:             * Get flexible flag.
075:             * 
076:             * @return flexible flag
077:             */
078:            public boolean isFlexible() {
079:                return m_isFlexible;
080:            }
081:
082:            /**
083:             * Set flexible flag.
084:             * 
085:             * @param flexible
086:             */
087:            public void setFlexible(boolean flexible) {
088:                m_isFlexible = flexible;
089:            }
090:
091:            /**
092:             * Check if child components are ordered.
093:             *
094:             * @return <code>true</code> if ordered, <code>false</code> if not
095:             */
096:            public boolean isOrdered() {
097:                return m_isOrdered;
098:            }
099:
100:            /**
101:             * Set child components ordered flag.
102:             * 
103:             * @param ordered <code>true</code> if ordered, <code>false</code> if not
104:             */
105:            public void setOrdered(boolean ordered) {
106:                m_isOrdered = ordered;
107:            }
108:
109:            /**
110:             * Check if child components are a choice.
111:             *
112:             * @return <code>true</code> if choice, <code>false</code> if not
113:             */
114:            public boolean isChoice() {
115:                return m_isChoice;
116:            }
117:
118:            /**
119:             * Set child components choice flag.
120:             * 
121:             * @param ordered <code>true</code> if choice, <code>false</code> if not
122:             */
123:            public void setChoice(boolean choice) {
124:                m_isChoice = choice;
125:            }
126:
127:            /**
128:             * Check if repeated child elements are allowed.
129:             *
130:             * @return <code>true</code> if repeats allowed, <code>false</code> if not
131:             */
132:            public boolean isAllowRepeats() {
133:                return m_isAllowRepeats;
134:            }
135:
136:            /**
137:             * Set repeated child elements allowed flag.
138:             * 
139:             * @param ignore <code>true</code> if repeated child elements to be allowed,
140:             * <code>false</code> if not
141:             */
142:            public void setAllowRepeats(boolean ignore) {
143:                m_isAllowRepeats = ignore;
144:            }
145:
146:            /**
147:             * Get name for child component list definition.
148:             * 
149:             * @return text of name defining child components (<code>null</code> if
150:             * none)
151:             */
152:            public String getUsingName() {
153:                return m_usingName;
154:            }
155:
156:            /**
157:             * Set name for child component list definition.
158:             * 
159:             * @param name text of name defining child components (<code>null</code> if
160:             * none)
161:             */
162:            public void setUsingName(String name) {
163:                m_usingName = name;
164:            }
165:
166:            /**
167:             * Get label name for child component list.
168:             * 
169:             * @return label name text (<code>null</code> if none)
170:             */
171:            public String getLabelName() {
172:                return m_labelName;
173:            }
174:
175:            /**
176:             * Set label name for child component list.
177:             * 
178:             * @param name label text for name (<code>null</code> if none)
179:             */
180:            public void setLabelName(String name) {
181:                m_labelName = name;
182:            }
183:
184:            /* (non-Javadoc)
185:             * @see org.jibx.binding.model.AttributeBase#prevalidate(org.jibx.binding.model.ValidationContext)
186:             */
187:            public void prevalidate(ValidationContext vctx) {
188:                if (m_isOrdered) {
189:                    if (m_isChoice) {
190:                        vctx
191:                                .addError("choice='true' cannot be used with ordered children");
192:                    }
193:                    if (m_isFlexible) {
194:                        vctx
195:                                .addError("flexible='true' cannot be used with ordered children");
196:                    }
197:                    if (m_isAllowRepeats) {
198:                        vctx
199:                                .addError("allow-repeats='true' cannot be used with ordered children");
200:                    }
201:                }
202:                if (m_isChoice && m_isFlexible) {
203:                    vctx
204:                            .addError("choice='true' and flexible='true' cannot be used together");
205:                }
206:                if (m_isChoice && m_isAllowRepeats) {
207:                    vctx
208:                            .addError("choice='true' and allow-repeats='true' cannot be used together");
209:                }
210:                super .prevalidate(vctx);
211:            }
212:
213:            /* (non-Javadoc)
214:             * @see org.jibx.binding.model.AttributeBase#validate(org.jibx.binding.model.ValidationContext)
215:             */
216:            public void validate(ValidationContext vctx) {
217:                if (m_usingName != null) {
218:                    DefinitionContext dctx = vctx.getBindingRoot()
219:                            .getDefinitions();
220:                    if (dctx.getNamedStructure(m_usingName) == null) {
221:                        vctx.addError("Label \"" + m_usingName
222:                                + "\" is not defined");
223:                    } else {
224:                        vctx
225:                                .addWarning("The label/using approach is deprecated and "
226:                                        + "will not be supported in the future - consider using an "
227:                                        + "abstract mapping instead");
228:                    }
229:                }
230:                if (m_labelName != null) {
231:                    vctx
232:                            .addWarning("The label/using approach is deprecated and "
233:                                    + "will not be supported in the future - consider using an "
234:                                    + "abstract mapping instead");
235:                }
236:                super.validate(vctx);
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.