KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > strategy > TuneBean


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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
18 package org.apache.commons.betwixt.strategy;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24
25 /**
26  * @author <a HREF='http://jakarta.apache.org/'>Jakarta Commons Team</a>
27  * @version $Revision: 1.2.2.1 $
28  */

29 public class TuneBean {
30
31     private ArrayList JavaDoc composers = new ArrayList JavaDoc();
32     private String JavaDoc name;
33     private String JavaDoc artist;
34     private int recorded;
35     
36     public TuneBean() {}
37     public TuneBean(String JavaDoc name, String JavaDoc artist, int recorded) {
38         setName(name);
39         setArtist(artist);
40         setRecorded(recorded);
41     }
42  
43     public String JavaDoc getArtist() {
44         return artist;
45     }
46
47     public Iterator JavaDoc getComposers() {
48         return composers.iterator();
49     }
50
51     public String JavaDoc getName() {
52         return name;
53     }
54
55     public int getRecorded() {
56         return recorded;
57     }
58
59     public void setArtist(String JavaDoc string) {
60         artist = string;
61     }
62
63     public void addComposer(ComposerBean composer) {
64         composers.add(composer);
65     }
66     
67     public void setName(String JavaDoc string) {
68         name = string;
69     }
70
71     public void setRecorded(int i) {
72         recorded = i;
73     }
74
75     public boolean sameComposers(Collection JavaDoc otherComposers) {
76                 // doesn't check cardinality but should be ok
77
if (otherComposers.size() != composers.size()) {
78             return false;
79         }
80         for (Iterator JavaDoc it=composers.iterator();it.hasNext();) {
81             Object JavaDoc object = it.next();
82             if (!otherComposers.contains(object)) {
83                 return false;
84             }
85         }
86         return true;
87     }
88 }
89
Popular Tags