01: package org.apache.ojb.broker.metadata;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
19: import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
20:
21: import java.io.Serializable;
22:
23: /**
24: * Is the base class for all other attribute descriptors.
25: * It holds basic the mapping information for a specific attribute.
26: *
27: * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
28: * @version $Id: AttributeDescriptorBase.java,v 1.17.2.1 2005/12/21 22:26:10 tomdz Exp $
29: */
30: public class AttributeDescriptorBase extends DescriptorBase implements
31: Serializable {
32: private static final long serialVersionUID = -818671542770428043L;
33:
34: protected PersistentField m_PersistentField = null;
35: protected ClassDescriptor m_ClassDescriptor = null;
36:
37: /**
38: * Constructor declaration
39: */
40: public AttributeDescriptorBase(ClassDescriptor descriptor) {
41: this .m_ClassDescriptor = descriptor;
42: }
43:
44: /**
45: * @throws MetadataException if an error occours when setting the PersistenteField
46: */
47: public void setPersistentField(Class c, String fieldname) {
48: m_PersistentField = PersistentFieldFactory
49: .createPersistentField(c, fieldname);
50: }
51:
52: public void setPersistentField(PersistentField pf) {
53: m_PersistentField = pf;
54: }
55:
56: /**
57: *
58: */
59: public PersistentField getPersistentField() {
60: return m_PersistentField;
61: }
62:
63: /**
64: * @return the name of the Attribute
65: */
66: public String getAttributeName() {
67: return getPersistentField().getName();
68: }
69:
70: /**
71: * Gets the classDescriptor.
72: * @return Returns a ClassDescriptor
73: */
74: public ClassDescriptor getClassDescriptor() {
75: return m_ClassDescriptor;
76: }
77:
78: /**
79: * Sets the classDescriptor.
80: * @param classDescriptor The classDescriptor to set
81: */
82: public void setClassDescriptor(ClassDescriptor classDescriptor) {
83: m_ClassDescriptor = classDescriptor;
84: }
85:
86: public String toString() {
87: StringBuffer buf = new StringBuffer();
88: buf.append(m_PersistentField);
89: buf.append(", field_belongs_to "
90: + m_ClassDescriptor.getClassNameOfObject());
91: buf.append(", " + super.toString());
92: return buf.toString();
93: }
94: }
|