KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > map > EmbeddableAttribute


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19 package org.apache.cayenne.map;
20
21 import java.io.Serializable JavaDoc;
22
23 import org.apache.cayenne.util.Util;
24 import org.apache.cayenne.util.XMLEncoder;
25 import org.apache.cayenne.util.XMLSerializable;
26
27 /**
28  * A persistent attribute of an embeddable object.
29  *
30  * @since 3.0
31  * @author Andrus Adamchik
32  */

33 public class EmbeddableAttribute implements XMLSerializable, Serializable JavaDoc {
34
35     protected String JavaDoc name;
36     protected String JavaDoc type;
37     protected String JavaDoc dbAttributeName;
38
39     protected Embeddable embeddable;
40
41     public EmbeddableAttribute() {
42
43     }
44
45     public EmbeddableAttribute(String JavaDoc name) {
46         this.name = name;
47     }
48
49     public void encodeAsXML(XMLEncoder encoder) {
50         encoder.print("<embeddable-attribute name=\"" + getName() + '\"');
51
52         if (getType() != null) {
53             encoder.print(" type=\"");
54             encoder.print(getType());
55             encoder.print('\"');
56         }
57
58         // If this obj attribute is mapped to db attribute
59
if (dbAttributeName != null) {
60             encoder.print(" db-attribute-name=\"");
61             encoder.print(Util.encodeXmlAttribute(dbAttributeName));
62             encoder.print('\"');
63         }
64
65         encoder.println("/>");
66     }
67
68     public String JavaDoc getDbAttributeName() {
69         return dbAttributeName;
70     }
71
72     public void setDbAttributeName(String JavaDoc dbAttributeName) {
73         this.dbAttributeName = dbAttributeName;
74     }
75
76     public String JavaDoc getName() {
77         return name;
78     }
79
80     public void setName(String JavaDoc name) {
81         this.name = name;
82     }
83
84     public String JavaDoc getType() {
85         return type;
86     }
87
88     public void setType(String JavaDoc type) {
89         this.type = type;
90     }
91
92     public Embeddable getEmbeddable() {
93         return embeddable;
94     }
95
96     public void setEmbeddable(Embeddable embeddable) {
97         this.embeddable = embeddable;
98     }
99 }
100
Popular Tags