View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.manager;
18  
19  import java.io.Serializable;
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.List;
23  
24  /***
25   * @author srt
26   * @version $Id: Queue.java,v 1.3 2005/08/21 22:39:22 srt Exp $
27   */
28  public class Queue implements Serializable
29  {
30      /***
31       * Serial version identifier
32       */
33      private static final long serialVersionUID = -6597536667933738312L;
34      private String name;
35      private Integer max;
36      private List entries;
37  
38      public Queue(String name)
39      {
40          this.name = name;
41          this.entries = Collections.synchronizedList(new ArrayList());
42      }
43  
44      public String getName()
45      {
46          return name;
47      }
48  
49      public Integer getMax()
50      {
51          return max;
52      }
53  
54      public void setMax(Integer max)
55      {
56          this.max = max;
57      }
58  
59      public List getEntries()
60      {
61          return entries;
62      }
63  
64      public void addEntry(Channel entry)
65      {
66          entries.add(entry);
67      }
68  
69      public void removeEntry(Channel entry)
70      {
71          entries.remove(entry);
72      }
73  
74      public String toString()
75      {
76          StringBuffer sb;
77  
78          sb = new StringBuffer(getClass().getName() + ": ");
79  
80          sb.append("name='" + getName() + "'; ");
81          sb.append("max='" + getMax() + "'; ");
82          sb.append("entries='" + getEntries() + "'; ");
83          sb.append("systemHashcode=" + System.identityHashCode(this));
84  
85          return sb.toString();
86      }
87  }