Source Code Cross Referenced for RegistrationPropertyDescription.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » wsrp » registration » 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 » Portal » jboss portal 2.6.4 » org.jboss.portal.wsrp.registration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.wsrp.registration;
023:
024:        import org.jboss.portal.common.util.ParameterValidation;
025:        import org.jboss.portal.registration.PropertyDescription;
026:        import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
027:
028:        import javax.xml.namespace.QName;
029:        import java.net.URI;
030:        import java.net.URISyntaxException;
031:        import java.util.Arrays;
032:        import java.util.Locale;
033:
034:        /**
035:         * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
036:         * @version $Revision:5865 $
037:         * @since 2.6
038:         */
039:        public class RegistrationPropertyDescription implements 
040:                PropertyDescription {
041:            private Long key;
042:            private QName name;
043:            private QName type;
044:            private String schemaLocation;
045:            private LocalizedString description;
046:            private LocalizedString hint;
047:            private LocalizedString label;
048:            private String[] usages;
049:            private QName[] aliases;
050:
051:            private transient ProducerRegistrationRequirements parent;
052:
053:            public RegistrationPropertyDescription(QName name, QName type) {
054:                this .name = name;
055:                this .type = type;
056:            }
057:
058:            public RegistrationPropertyDescription(String name, QName type) {
059:                this (new QName(name), type);
060:            }
061:
062:            public RegistrationPropertyDescription() {
063:            }
064:
065:            public RegistrationPropertyDescription(
066:                    RegistrationPropertyDescription other) {
067:                ParameterValidation.throwIllegalArgExceptionIfNull(other,
068:                        "RegistrationPropertyDescription");
069:
070:                setName(new QName(other.name.toString()));
071:                setType(new QName(other.type.toString()));
072:
073:                if (other.aliases != null) {
074:                    aliases = new QName[other.aliases.length];
075:                    System.arraycopy(other.aliases, 0, aliases, 0,
076:                            other.aliases.length);
077:                }
078:
079:                if (other.description != null) {
080:                    setDescription(new LocalizedString(other.description));
081:                }
082:                if (other.hint != null) {
083:                    setHint(new LocalizedString(other.hint));
084:                }
085:                if (other.label != null) {
086:                    setLabel(new LocalizedString(other.label));
087:                }
088:                if (other.schemaLocation != null) {
089:                    setSchemaLocation(other.schemaLocation);
090:                }
091:
092:                if (other.usages != null) {
093:                    usages = new String[other.usages.length];
094:                    System.arraycopy(other.usages, 0, usages, 0,
095:                            other.usages.length);
096:                }
097:
098:                parent = other.parent;
099:            }
100:
101:            public boolean equals(Object o) {
102:                if (this  == o) {
103:                    return true;
104:                }
105:                if (o == null || getClass() != o.getClass()) {
106:                    return false;
107:                }
108:
109:                RegistrationPropertyDescription that = (RegistrationPropertyDescription) o;
110:
111:                if (key != null ? !key.equals(that.key) : that.key != null) {
112:                    return false;
113:                }
114:                if (!name.equals(that.name)) {
115:                    return false;
116:                }
117:                return type.equals(that.type);
118:
119:            }
120:
121:            public int hashCode() {
122:                int result;
123:                result = (key != null ? key.hashCode() : 0);
124:                result = 31 * result + name.hashCode();
125:                result = 31 * result + type.hashCode();
126:                return result;
127:            }
128:
129:            public String toString() {
130:                return "Registration Property Description named '" + name
131:                        + "', type=" + type + ", hint=" + hint + ", label="
132:                        + label;
133:            }
134:
135:            public Long getKey() {
136:                return key;
137:            }
138:
139:            public void setKey(Long key) {
140:                this .key = key;
141:            }
142:
143:            public QName getName() {
144:                return name;
145:            }
146:
147:            public void setName(QName name) {
148:                if (valueWillBeUpdated(this .name, name)) {
149:                    QName oldName = this .name;
150:                    this .name = name;
151:                    if (parent != null) {
152:                        parent.notifyRegistrationPropertyChangeListeners();
153:                        parent.propertyHasBeenRenamed(this , oldName);
154:                    }
155:                }
156:            }
157:
158:            public void setNameAsString(String name) {
159:                setName(new QName(name));
160:            }
161:
162:            public String getNameAsString() {
163:                return getName().getLocalPart();
164:            }
165:
166:            public QName getType() {
167:                return type;
168:            }
169:
170:            public void setType(QName type) {
171:                this .type = (QName) modifyIfNeeded(this .type, type);
172:            }
173:
174:            public String getSchemaLocation() {
175:                return schemaLocation;
176:            }
177:
178:            public URI getSchemaLocationAsURI() {
179:                try {
180:                    return new URI(schemaLocation);
181:                } catch (URISyntaxException e) {
182:                    // shouldn't happen
183:                    throw new IllegalArgumentException("Invalid URI: "
184:                            + schemaLocation + ". Cause: "
185:                            + e.getLocalizedMessage());
186:                }
187:            }
188:
189:            public void setSchemaLocation(String schemaLocation) {
190:                // 
191:                if (schemaLocation != null) {
192:                    // first check if schemaLocation is a valid URI
193:                    try {
194:                        new URI(schemaLocation);
195:                    } catch (URISyntaxException e) {
196:                        throw new IllegalArgumentException("Invalid URI: "
197:                                + schemaLocation + ". Cause: "
198:                                + e.getLocalizedMessage());
199:                    }
200:
201:                    this .schemaLocation = (String) modifyIfNeeded(
202:                            this .schemaLocation, schemaLocation);
203:                }
204:            }
205:
206:            public LocalizedString getDescription() {
207:                return description;
208:            }
209:
210:            public void setDescription(LocalizedString description) {
211:                this .description = (LocalizedString) modifyIfNeeded(
212:                        this .description, description);
213:            }
214:
215:            public void setDefaultDescription(String value) {
216:                setDescription(value == null ? null
217:                        : new LocalizedString(value));
218:            }
219:
220:            public LocalizedString getHint() {
221:                return hint;
222:            }
223:
224:            public void setHint(LocalizedString hint) {
225:                this .hint = (LocalizedString) modifyIfNeeded(this .hint, hint);
226:            }
227:
228:            public void setDefaultHint(String value) {
229:                setHint(value == null ? null : new LocalizedString(value));
230:            }
231:
232:            public LocalizedString getLabel() {
233:                return label;
234:            }
235:
236:            public void setLabel(LocalizedString label) {
237:                this .label = (LocalizedString) modifyIfNeeded(this .label, label);
238:            }
239:
240:            public void setDefaultLabel(String value) {
241:                setLabel(value == null ? null : new LocalizedString(value));
242:            }
243:
244:            public String[] getUsages() {
245:                return usages;
246:            }
247:
248:            public void setUsages(String[] usages) {
249:                if (!Arrays.equals(this .usages, usages)) {
250:                    if (usages != null) {
251:                        this .usages = new String[usages.length];
252:                        System.arraycopy(usages, 0, this .usages, 0,
253:                                usages.length);
254:                    } else {
255:                        this .usages = null;
256:                    }
257:                    notifyParentOfChangeIfNeeded();
258:                }
259:            }
260:
261:            public QName[] getAliases() {
262:                return aliases;
263:            }
264:
265:            public void setAliases(QName[] aliases) {
266:                if (!Arrays.equals(this .aliases, aliases)) {
267:                    if (aliases != null) {
268:                        this .aliases = new QName[aliases.length];
269:                        System.arraycopy(aliases, 0, this .aliases, 0,
270:                                aliases.length);
271:                    } else {
272:                        this .aliases = null;
273:                    }
274:                    notifyParentOfChangeIfNeeded();
275:                }
276:            }
277:
278:            public void setParent(ProducerRegistrationRequirements requirements) {
279:                this .parent = requirements;
280:            }
281:
282:            private void notifyParentOfChangeIfNeeded() {
283:                if (parent != null) {
284:                    parent.notifyRegistrationPropertyChangeListeners();
285:                }
286:            }
287:
288:            public Object modifyIfNeeded(Object oldValue, Object newValue) {
289:                if (valueWillBeUpdated(oldValue, newValue)) {
290:                    oldValue = newValue;
291:                    notifyParentOfChangeIfNeeded();
292:                }
293:
294:                return oldValue;
295:            }
296:
297:            private boolean valueWillBeUpdated(Object oldValue, Object newValue) {
298:                return (oldValue != null && !oldValue.equals(newValue))
299:                        || (oldValue == null && newValue != null);
300:            }
301:
302:            /**
303:             * Tries to heuristically determine the language for this RegistrationPropertyDescription
304:             *
305:             * @return
306:             */
307:            public Locale getLang() {
308:                Locale defaultLocale = Locale.getDefault();
309:                Locale locale;
310:
311:                locale = label != null ? label.getLocale() : defaultLocale;
312:                if (!defaultLocale.equals(locale)) {
313:                    return locale;
314:                }
315:
316:                locale = hint != null ? hint.getLocale() : defaultLocale;
317:                if (!defaultLocale.equals(locale)) {
318:                    return locale;
319:                }
320:
321:                locale = description != null ? description.getLocale()
322:                        : defaultLocale;
323:                if (!defaultLocale.equals(locale)) {
324:                    return locale;
325:                }
326:
327:                return defaultLocale;
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.