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: $Header:$
018: */package org.apache.beehive.netui.util.config.bean;
019:
020: /**
021: *
022: */
023: public final class MultipartHandler implements java.io.Serializable {
024:
025: public static final int INT_DISABLED = 0;
026: public static final int INT_MEMORY = 1;
027: public static final int INT_DISK = 2;
028:
029: /**
030: */
031: public static final MultipartHandler DISABLED = new MultipartHandler(
032: INT_DISABLED);
033:
034: /**
035: */
036: public static final MultipartHandler MEMORY = new MultipartHandler(
037: INT_MEMORY);
038:
039: /**
040: */
041: public static final MultipartHandler DISK = new MultipartHandler(
042: INT_DISK);
043:
044: private int _val;
045:
046: private MultipartHandler(int val) {
047: _val = val;
048: }
049:
050: /**
051: * Convert this multipart handler to a readable String.
052: * @return the readable multipart handler name
053: */
054: public String toString() {
055: switch (_val) {
056: case INT_DISABLED:
057: return "disabled";
058: case INT_MEMORY:
059: return "memory";
060: case INT_DISK:
061: return "disk";
062: }
063:
064: String message = "Encountered an unknown multipart handler with value \""
065: + _val + "\"";
066: assert false : message;
067: throw new IllegalStateException(message);
068: }
069:
070: /**
071: * Equals method.
072: * @param value value to check
073: * @return <code>true</code> if this multipart handler matches the <code>value</code>; <code>false</code> otherwise.
074: */
075: public boolean equals(Object value) {
076: if (value == this )
077: return true;
078: if (value == null || !(value instanceof MultipartHandler))
079: return false;
080:
081: return ((MultipartHandler) value)._val == _val;
082: }
083:
084: /**
085: * Hash code.
086: * @return the hash code
087: */
088: public int hashCode() {
089: return _val;
090: }
091:
092: /**
093: * The multipart handler's int value.
094: *
095: * @return the multipart handler's value
096: */
097: public int getValue() {
098: return _val;
099: }
100: }
|