KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > aspect > impl > DefaultAspectDescription


1 /*
2  * Copyright 1999-2002,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 package org.apache.cocoon.portal.aspect.impl;
17
18 import org.apache.avalon.framework.configuration.Configuration;
19 import org.apache.avalon.framework.configuration.ConfigurationException;
20 import org.apache.cocoon.portal.aspect.AspectDescription;
21
22
23
24 /**
25  * A configured aspect
26  *
27  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
28  *
29  * @version CVS $Id: DefaultAspectDescription.java 30932 2004-07-29 17:35:38Z vgritsenko $
30  */

31 public class DefaultAspectDescription
32     implements AspectDescription {
33
34     protected String JavaDoc name;
35     
36     protected String JavaDoc className;
37     
38     protected String JavaDoc persistence;
39
40     protected boolean autoCreate;
41     
42     protected String JavaDoc defaultValue;
43     
44     /**
45      * Create a new description from a {@link Configuration} object.
46      * All values must be stored as attributes
47      */

48     public static AspectDescription newInstance(Configuration conf)
49     throws ConfigurationException {
50         DefaultAspectDescription adesc = new DefaultAspectDescription();
51         adesc.setClassName(conf.getAttribute("class"));
52         adesc.setName(conf.getAttribute("name"));
53         adesc.setPersistence(conf.getAttribute("store"));
54         adesc.setAutoCreate(conf.getAttributeAsBoolean("auto-create", false));
55         adesc.setDefaultValue(conf.getAttribute("value", null));
56         
57         return adesc;
58     }
59     
60     /**
61      * @return The class name
62      */

63     public String JavaDoc getClassName() {
64         return className;
65     }
66
67     /**
68      * @return The configred name
69      */

70     public String JavaDoc getName() {
71         return name;
72     }
73
74     /**
75      * @param string
76      */

77     public void setClassName(String JavaDoc string) {
78         className = string;
79     }
80
81     /**
82      * @param string
83      */

84     public void setName(String JavaDoc string) {
85         name = string;
86     }
87
88     /**
89      * @return The role of the store
90      */

91     public String JavaDoc getStoreName() {
92         return persistence;
93     }
94
95     /**
96      * @param string
97      */

98     public void setPersistence(String JavaDoc string) {
99         persistence = string;
100     }
101
102     /**
103      * If the data is not available, create it automatically (or not)
104      */

105     public boolean isAutoCreate() {
106         return autoCreate;
107     }
108
109     /**
110      * Set auto create
111      */

112     public void setAutoCreate(boolean b) {
113         autoCreate = b;
114     }
115
116     /**
117      * Default value
118      */

119     public String JavaDoc getDefaultValue() {
120         return this.defaultValue;
121     }
122
123     public void setDefaultValue(String JavaDoc value) {
124         this.defaultValue = value;
125     }
126     
127     public String JavaDoc toString() {
128         return ("AspectDescription name=" + this.name +
129                  ", class=" + this.className +
130                  ", persistence=" + this.persistence +
131                  ", autoCreate=" + this.autoCreate +
132                  ", defaultValue=" + this.defaultValue);
133     }
134 }
135
Popular Tags