001: /*
002: * ====================================================================
003: * JAFFA - Java Application Framework For All
004: *
005: * Copyright (C) 2002 JAFFA Development Group
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * Redistribution and use of this software and associated documentation ("Software"),
022: * with or without modification, are permitted provided that the following conditions are met:
023: * 1. Redistributions of source code must retain copyright statements and notices.
024: * Redistributions must also contain a copy of this document.
025: * 2. Redistributions in binary form must reproduce the above copyright notice,
026: * this list of conditions and the following disclaimer in the documentation
027: * and/or other materials provided with the distribution.
028: * 3. The name "JAFFA" must not be used to endorse or promote products derived from
029: * this Software without prior written permission. For written permission,
030: * please contact mail to: jaffagroup@yahoo.com.
031: * 4. Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
032: * appear in their names without prior written permission.
033: * 5. Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
034: *
035: * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: */
049:
050: package org.jaffa.rules.metadata;
051:
052: import java.util.*;
053:
054: /** An instance of this class represents a field defined in the Rules config file. */
055: public class FieldMetaData {
056:
057: private String m_name;
058: private boolean m_overridesDefault;
059: private String m_extendsClass;
060: private String m_extendsField;
061: private List m_rules;
062:
063: /** Creates an instance. */
064: public FieldMetaData() {
065: m_rules = new LinkedList();
066: }
067:
068: /** Getter for the property name.
069: * @return Value of property name.
070: */
071: public String getName() {
072: return m_name;
073: }
074:
075: /** Setter for property name.
076: * @param name New value of property name.
077: */
078: public void setName(String name) {
079: m_name = name;
080: }
081:
082: /** Getter for the property overridesDefault.
083: * @return Value of property overridesDefault.
084: */
085: public boolean getOverridesDefault() {
086: return m_overridesDefault;
087: }
088:
089: /** Setter for property overridesDefault.
090: * @param overridesDefault New value of property overridesDefault.
091: */
092: public void setOverridesDefault(boolean overridesDefault) {
093: m_overridesDefault = overridesDefault;
094: }
095:
096: /** Getter for the property extendsClass.
097: * @return Value of property extendsClass.
098: */
099: public String getExtendsClass() {
100: return m_extendsClass;
101: }
102:
103: /** Setter for property extendsClass.
104: * @param extendsClass New value of property extendsClass.
105: */
106: public void setExtendsClass(String extendsClass) {
107: m_extendsClass = extendsClass;
108: }
109:
110: /** Getter for the property extendsField.
111: * @return Value of property extendsField.
112: */
113: public String getExtendsField() {
114: return m_extendsField;
115: }
116:
117: /** Setter for property extendsField.
118: * @param extendsField New value of property extendsField.
119: */
120: public void setExtendsField(String extendsField) {
121: m_extendsField = extendsField;
122: }
123:
124: /** Clears the rules for the field.
125: */
126: public void clearRules() {
127: m_rules.clear();
128: }
129:
130: /** Add a rule to the field.
131: * @param rule The rule to be added.
132: */
133: public void addRule(RuleMetaData rule) {
134: m_rules.add(rule);
135: }
136:
137: /** Getter for the property rules.
138: * @return Value of property rules.
139: */
140: public RuleMetaData[] getRules() {
141: return (RuleMetaData[]) m_rules.toArray(new RuleMetaData[0]);
142: }
143:
144: /** Setter for property rules.
145: * @param rules New value of property rules.
146: */
147: public void setRules(RuleMetaData[] rules) {
148: clearRules();
149: if (rules != null) {
150: for (int i = 0; i < rules.length; i++)
151: addRule(rules[i]);
152: }
153: }
154:
155: /** Returns diagnostic information.
156: * @return a String containing diagnostic information.
157: */
158: public String toString() {
159: StringBuffer buf = new StringBuffer("<FieldMetaData>");
160: buf.append("<name>");
161: if (m_name != null)
162: buf.append(m_name);
163: buf.append("</name>");
164: buf.append("<overridesDefault>");
165: buf.append(m_overridesDefault);
166: buf.append("</overridesDefault>");
167: buf.append("<extendsClass>");
168: if (m_extendsClass != null)
169: buf.append(m_extendsClass);
170: buf.append("</extendsClass>");
171: buf.append("<extendsField>");
172: if (m_extendsField != null)
173: buf.append(m_extendsField);
174: buf.append("</extendsField>");
175: for (Iterator i = m_rules.iterator(); i.hasNext();)
176: buf.append(i.next());
177: buf.append("</FieldMetaData>");
178: return buf.toString();
179: }
180: }
|