Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/cerberus/component/descriptor/MessageSignature.java


1   /*
2    * MessageSignature.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.cerberus.component.descriptor;
11  
12  import java.util.HashMap;
13  import java.util.Collection;
14  import java.util.Iterator;
15  
16  /**
17   * <p>Represents the set of properties comprising the signature of a
18   * {@link com.aendvari.hermes.broker.Message}.</p>
19   *
20   * <p>Message signatures are used to explicitly describe a component's interface
21   * to other components.</p>
22   *
23   * @author  Trevor Milne
24   *
25   */
26  
27  public class MessageSignature
28  {
29    /** The properties of the signature. */
30    protected HashMap properties;
31  
32  
33    /* Constructors. */
34  
35  
36    /**
37     * Constructs a <code>MessageSignature</code> instance.
38     *
39     */
40  
41    public MessageSignature()
42    {
43      super();
44  
45      properties = new HashMap();
46    }
47  
48    /**
49     * Constructs a <code>MessageSignature</code> instance as a copy of the one supplied.
50     *
51     * @param    signature          The <code>MessageSignature</code> to copy.
52     *
53     */
54  
55    public MessageSignature(MessageSignature signature)
56    {
57      super();
58  
59      properties = new HashMap();
60  
61      // copy properties
62      Iterator propertyIterator = signature.getProperties().iterator();
63  
64      while (propertyIterator.hasNext())
65      {
66        SignatureProperty copyProperty = (SignatureProperty)propertyIterator.next();
67        SignatureProperty newProperty = new SignatureProperty(copyProperty);
68  
69        addProperty(newProperty);
70      }
71    }
72  
73  
74    /* Accessors. */
75  
76  
77    /* Properties. */
78  
79    /**
80     * Adds a property to this signature.
81     *
82     * @param    property          A property of this signature.
83     *
84     */
85  
86    public void addProperty(SignatureProperty property)
87    {
88      properties.put(property.getName(), property);
89    }
90  
91    /**
92     * Returns the specified property.
93     *
94     * @param    name            The name of the property.
95     *
96     * @return                  The property having the supplied name.
97     *
98     */
99  
100   public SignatureProperty getProperty(String name)
101   {
102     return (SignatureProperty)properties.get(name);
103   }
104 
105   /**
106    * Returns the properties of this signature.
107    *
108    * @return                  A <code>Collection</code> of {@link SignatureProperty SignatureProperties}.
109    *
110    */
111 
112   public Collection getProperties()
113   {
114     return properties.values();
115   }
116 }
117