001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.portal.aspect.impl;
018:
019: import org.apache.avalon.framework.configuration.Configuration;
020: import org.apache.avalon.framework.configuration.ConfigurationException;
021: import org.apache.cocoon.portal.aspect.AspectDescription;
022:
023: /**
024: * A configured aspect
025: *
026: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
027: *
028: * @version CVS $Id: DefaultAspectDescription.java 433543 2006-08-22 06:22:54Z crossley $
029: */
030: public class DefaultAspectDescription implements AspectDescription {
031:
032: protected String name;
033:
034: protected String className;
035:
036: protected String persistence;
037:
038: protected boolean autoCreate;
039:
040: protected String defaultValue;
041:
042: /**
043: * Create a new description from a {@link Configuration} object.
044: * All values must be stored as attributes
045: */
046: public static AspectDescription newInstance(Configuration conf)
047: throws ConfigurationException {
048: DefaultAspectDescription adesc = new DefaultAspectDescription();
049: adesc.setClassName(conf.getAttribute("class"));
050: adesc.setName(conf.getAttribute("name"));
051: adesc.setPersistence(conf.getAttribute("store"));
052: adesc.setAutoCreate(conf.getAttributeAsBoolean("auto-create",
053: false));
054: adesc.setDefaultValue(conf.getAttribute("value", null));
055:
056: return adesc;
057: }
058:
059: /**
060: * @return The class name
061: */
062: public String getClassName() {
063: return className;
064: }
065:
066: /**
067: * @return The configred name
068: */
069: public String getName() {
070: return name;
071: }
072:
073: /**
074: * @param string
075: */
076: public void setClassName(String string) {
077: className = string;
078: }
079:
080: /**
081: * @param string
082: */
083: public void setName(String string) {
084: name = string;
085: }
086:
087: /**
088: * @return The role of the store
089: */
090: public String getStoreName() {
091: return persistence;
092: }
093:
094: /**
095: * @param string
096: */
097: public void setPersistence(String string) {
098: persistence = string;
099: }
100:
101: /**
102: * If the data is not available, create it automatically (or not)
103: */
104: public boolean isAutoCreate() {
105: return autoCreate;
106: }
107:
108: /**
109: * Set auto create
110: */
111: public void setAutoCreate(boolean b) {
112: autoCreate = b;
113: }
114:
115: /**
116: * Default value
117: */
118: public String getDefaultValue() {
119: return this .defaultValue;
120: }
121:
122: public void setDefaultValue(String value) {
123: this .defaultValue = value;
124: }
125:
126: public String toString() {
127: return ("AspectDescription name=" + this .name + ", class="
128: + this .className + ", persistence=" + this .persistence
129: + ", autoCreate=" + this .autoCreate + ", defaultValue=" + this.defaultValue);
130: }
131: }
|