001: /**
002: * $Id: ServiceDescriptorImpl.java,v 1.5 2003/06/03 10:49:24 sy131129 Exp $
003: * Copyright 2002-2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.providers.simplewebservice.wsdl.impl;
014:
015: import java.util.Map;
016: import java.util.HashMap;
017: import java.util.Iterator;
018:
019: import com.sun.portal.providers.simplewebservice.wsdl.ServiceDescriptor;
020: import com.sun.portal.providers.simplewebservice.wsdl.PortDescriptor;
021:
022: /**
023: * This class represents a service, which groups related
024: * ports to provide some functionality.
025: *
026: */
027: public class ServiceDescriptorImpl implements ServiceDescriptor {
028:
029: private String name = null;
030: private String documentation = null;
031: private Map portDescriptors = new HashMap();
032:
033: /**
034: * Default Constructor.
035: *
036: * @param name the name of the ServiceDescriptor.
037: * @param documentation the documentation for this ServiceDescriptor.
038: * @param portDescriptors the PortDescriptors of the ServiceDescriptor.
039: */
040: public ServiceDescriptorImpl(String name, String documentation,
041: Map portDescriptors) {
042: this .name = name;
043: this .documentation = documentation;
044: this .portDescriptors = portDescriptors;
045: }
046:
047: /**
048: * Get the name of this ServiceDescriptor.
049: *
050: * @return the ServiceDescriptor name.
051: */
052: public String getName() {
053: return name;
054: }
055:
056: /**
057: * Get the documentation text for this ServiceDescriptor.
058: *
059: * @return the ServiceDescriptor documentation text.
060: */
061: public String getDocumentation() {
062: return documentation;
063: }
064:
065: /**
066: * Get the specified PortDescriptor.
067: *
068: * @param name the name of the desired PortDescriptor.
069: * @return the corresponding PortDescriptor, or null if there wasn't
070: * any matching PortDescriptor.
071: */
072: public PortDescriptor getPortDescriptor(String name) {
073: return (PortDescriptor) portDescriptors.get(name);
074: }
075:
076: /**
077: * Get all the PortDescriptor defined here.
078: *
079: * @return all the PortDescriptors.
080: */
081: public Map getPortDescriptors() {
082: return portDescriptors;
083: }
084:
085: /**
086: * Get the String representation of this ServiceDescriptor.
087: *
088: * @return the String representation of this ServiceDescriptor.
089: */
090: public String toString() {
091: StringBuffer strBuf = new StringBuffer();
092:
093: strBuf.append("\nServiceDescriptor: name=" + name);
094:
095: if (documentation != null) {
096: strBuf.append("\ndocumetation =" + documentation);
097: }
098:
099: if (portDescriptors != null) {
100: Iterator portIterator = portDescriptors.values().iterator();
101:
102: while (portIterator.hasNext()) {
103: strBuf.append("\n" + portIterator.next());
104: }
105: }
106:
107: return strBuf.toString();
108: }
109: }
|