001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.xml.multispaced;
023:
024: import org.jboss.xb.binding.MarshallingContext;
025: import org.jboss.xb.binding.ObjectModelProvider;
026:
027: /**
028: * @version <tt>$Revision: 57211 $</tt>
029: * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
030: */
031: public class XMBeanMetaDataProvider implements ObjectModelProvider {
032: public static final XMBeanMetaDataProvider INSTANCE = new XMBeanMetaDataProvider();
033:
034: private XMBeanMetaDataProvider() {
035: }
036:
037: public Object getRoot(Object o, MarshallingContext ctx,
038: String namespaceURI, String localName) {
039: return o;
040: }
041:
042: public Object getChildren(XMBeanMetaData xmbean,
043: String namespaceUri, String localName) {
044: Object children;
045: if ("mbean".equals(localName)) {
046: children = xmbean;
047: } else if ("constructor".equals(localName)) {
048: children = xmbean.getConstructors();
049: } else if ("attribute".equals(localName)) {
050: children = xmbean.getAttributes();
051: } else if ("operation".equals(localName)) {
052: children = xmbean.getOperations();
053: } else if ("notification".equals(localName)) {
054: children = xmbean.getNotifications();
055: } else if ("persistence".equals(localName)) {
056: children = xmbean.getPersistenceManager();
057: } else {
058: children = null;
059: }
060: return children;
061: }
062:
063: public Object getElementValue(XMBeanMetaData xmbean,
064: String namespaceUri, String localName) {
065: Object value;
066: if ("description".equals(localName)) {
067: value = xmbean.getDescription();
068: } else if ("class".equals(localName)) {
069: value = xmbean.getMbeanClass();
070: } else {
071: value = null;
072: }
073: return value;
074: }
075:
076: public Object getElementValue(
077: XMBeanConstructorMetaData constructor, String namespaceUri,
078: String localName) {
079: Object value;
080: if ("description".equals(localName)) {
081: value = constructor.getDescription();
082: } else if ("name".equals(localName)) {
083: value = constructor.getName();
084: } else {
085: value = null;
086: }
087: return value;
088: }
089:
090: public Object getAttributeValue(XMBeanAttributeMetaData attribute,
091: String namespaceUri, String localName) {
092: Object value;
093: if ("access".equals(localName)) {
094: value = attribute.getAccess();
095: } else if ("getMethod".equals(localName)) {
096: value = attribute.getGetMethod();
097: } else if ("setMethod".equals(localName)) {
098: value = attribute.getSetMethod();
099: } else {
100: value = null;
101: }
102: return value;
103: }
104:
105: public Object getElementValue(XMBeanAttributeMetaData attribute,
106: String namespaceUri, String localName) {
107: Object value;
108: if ("description".equals(localName)) {
109: value = attribute.getDescription();
110: } else if ("name".equals(localName)) {
111: value = attribute.getName();
112: } else if ("type".equals(localName)) {
113: value = attribute.getType();
114: } else {
115: value = null;
116: }
117: return value;
118: }
119:
120: public Object getElementValue(XMBeanOperationMetaData operation,
121: String namespaceUri, String localName) {
122: Object value;
123: if ("description".equals(localName)) {
124: value = operation.getDescription();
125: } else if ("name".equals(localName)) {
126: value = operation.getName();
127: } else if ("return-type".equals(localName)) {
128: value = operation.getReturnType();
129: } else {
130: value = null;
131: }
132: return value;
133: }
134:
135: public Object getElementValue(
136: XMBeanNotificationMetaData notification,
137: String namespaceUri, String localName) {
138: Object value;
139: if ("description".equals(localName)) {
140: value = notification.getDescription();
141: } else if ("name".equals(localName)) {
142: value = notification.getName();
143: } else if ("notification-type".equals(localName)) {
144: value = notification.getNotificationType();
145: } else {
146: value = null;
147: }
148: return value;
149: }
150: }
|