KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > mapping > MetaAttribute


1 //$Id: MetaAttribute.java,v 1.2 2004/09/17 05:21:03 maxcsaucdk Exp $
2
package org.hibernate.mapping;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.ArrayList JavaDoc;
6 import java.util.Collections JavaDoc;
7
8 /**
9  * A meta attribute is a named value or values.
10  * @author Gavin King
11  */

12 public class MetaAttribute implements Serializable JavaDoc {
13     private String JavaDoc name;
14     private java.util.List JavaDoc values = new ArrayList JavaDoc();
15
16     public MetaAttribute(String JavaDoc name) {
17         this.name = name;
18     }
19     
20     public String JavaDoc getName() {
21         return name;
22     }
23
24     public java.util.List JavaDoc getValues() {
25         return Collections.unmodifiableList(values);
26     }
27
28     public void addValue(String JavaDoc value) {
29         values.add(value);
30     }
31
32     public String JavaDoc getValue() {
33         if ( values.size()!=1 ) throw new IllegalStateException JavaDoc("no unique value");
34         return (String JavaDoc) values.get(0);
35     }
36
37     public boolean isMultiValued() {
38         return values.size()>1;
39     }
40
41     public String JavaDoc toString() {
42         return "[" + name + "=" + values + "]";
43     }
44 }
45
Popular Tags