001: //$Id: ActionState.java 220 2006-03-17 00:22:16Z jg_hamburg $
002: /********************************************************************************
003: * DDTUnit, a Datadriven Approach to Unit- and Moduletesting
004: * Copyright (c) 2004, Joerg and Kai Gellien
005: * All rights reserved.
006: *
007: * The Software is provided under the terms of the Common Public License 1.0
008: * as provided with the distribution of DDTUnit in the file cpl-v10.html.
009: * Redistribution and use in source and binary forms, with or without
010: * modification, are permitted provided that the following conditions
011: * are met:
012: *
013: * + Redistributions of source code must retain the above copyright
014: * notice, this list of conditions and the following disclaimer.
015: *
016: * + Redistributions in binary form must reproduce the above
017: * copyright notice, this list of conditions and the following
018: * disclaimer in the documentation and/or other materials provided
019: * with the distribution.
020: *
021: * + Neither the name of the authors or DDTUnit, nor the
022: * names of its contributors may be used to endorse or promote
023: * products derived from this software without specific prior
024: * written permission.
025: *
026: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
027: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
028: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
029: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
030: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
031: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
032: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
033: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
036: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037: ********************************************************************************/package junitx.ddtunit.data.processing;
038:
039: /**
040: * Class for defining special processing states useful for object instanciation
041: */
042: final class ActionState {
043: /**
044: * Object parsing type, identifying a standard object to parse
045: */
046: public final static ActionState OBJECT_CREATION = new ActionState(
047: 4, "Object Creation Processing");
048:
049: /**
050: * Assert parsing type, identifying a standard assertion to parse
051: */
052: public final static ActionState ASSERT_CREATION = new ActionState(
053: 5, "Assert Creation Processing");
054:
055: /**
056: * Exception parsing type, identifying a standard expected exception to
057: * parse
058: */
059: public final static ActionState EXCEPTION_CREATION = new ActionState(
060: 6, "Exception Creation Processing");
061:
062: /**
063: * XML Content parsing type, identifying xml content to parse
064: */
065: public final static ActionState CONTENT_CREATION = new ActionState(
066: 7, "Content Extraction Processing");
067:
068: /**
069: * Subelement parsing type, identifying a substructure object to parse, e.g.
070: * a field of a value object
071: */
072: public final static ActionState SUBELEMENT_CREATION = new ActionState(
073: 8, "Subelement Creation Processing");
074:
075: /**
076: * Collection parsing type, identifying a collection object to parse, e.g. a
077: * list of object values
078: */
079: public final static ActionState COLLECTION_CREATION = new ActionState(
080: 10, "Collection Creation Processing");
081:
082: /**
083: * Map parsing type, identifying a map object to parse, e.g. a list of
084: * object values
085: */
086: public final static ActionState MAP_CREATION = new ActionState(11,
087: "Map Creation Processing");
088:
089: /**
090: * Date parsing type, identifying a Date object to parse, e.g. a date time
091: * object
092: */
093: public final static ActionState DATE_CREATION = new ActionState(12,
094: "Date Creation Processing");
095:
096: public static final ActionState ATTRLIST_CREATION = new ActionState(
097: 13, "Internal Attribute Creation Processing");
098:
099: public static final ActionState ARRAY_CREATION = new ActionState(
100: 14, "Array Creation Processing");
101:
102: public static final ActionState BEAN_CREATION = new ActionState(15,
103: "Bean Creation Processing");
104:
105: public static final ActionState CALL_CREATION = new ActionState(16,
106: "Call Creation Processing");
107:
108: public static final ActionState CONSTANT_CREATION = new ActionState(
109: 17, "Constant Creation Process");
110:
111: private int id;
112:
113: private String name;
114:
115: private ActionState() {
116: // no special initialization
117: }
118:
119: private ActionState(int id, String name) {
120: if (id < 0 || name == null || name.compareTo("") == 0) {
121: throw new IllegalArgumentException(
122: "Wrong arguments: id >= 0, name not empty.");
123: }
124: this .id = id;
125: this .name = name;
126: }
127:
128: /**
129: * Overwrite toString() method.
130: *
131: * @return name of parse type
132: */
133: public String toString() {
134: return this .name;
135: }
136:
137: /**
138: * Returns <code>true</code> if this <code>ActionState</code> is the
139: * same as the o argument.
140: *
141: * @return <code>true</code> if this <code>ActionState</code> is the
142: * same as the o argument.
143: */
144: public boolean equals(Object obj) {
145: boolean check = false;
146: if (obj != null && obj.getClass() == getClass()) {
147: ActionState castedObj = (ActionState) obj;
148: check = ((this .id == castedObj.id) && (this .name == null ? castedObj.name == null
149: : this .name.equals(castedObj.name)));
150: }
151: return check;
152: }
153:
154: /**
155: * Override hashCode.
156: *
157: * @return the Objects hashcode.
158: */
159: public int hashCode() {
160: int hashCode = 1;
161: hashCode = 31 * hashCode + id;
162: hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode());
163: return hashCode;
164: }
165: }
|