1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package convwatch; 25 26 public class TriState 27 { 28 public static final TriState TRUE = new TriState(1); 29 public static final TriState FALSE = new TriState(0); 30 public static final TriState UNSET = new TriState(-1); 31 32 int m_nValue; 33 34 /** 35 Allocates a <code>TriState</code> object representing the 36 <code>value</code> argument. 37 38 @param value the value of the <code>TriState</code>. 39 */ TriState(int value)40 public TriState(int value) 41 { 42 m_nValue = value; 43 } 44 45 /** 46 Returns the value of this TriState object as an int 47 * @return the primitive <code>int</code> value of this object. 48 */ intValue()49 public int intValue() 50 { 51 return m_nValue; 52 } 53 /** 54 Returns <code>true</code> if and only if the argument is not 55 <code>null</code> and is a <code>TriState</code> object that 56 contains the same <code>int</code> value as this object. 57 58 @param obj the object to compare with. 59 @return <code>true</code> if the objects are the same; 60 <code>false</code> otherwise. 61 */ 62 equals(Object obj)63 public boolean equals(Object obj) 64 { 65 if ((obj != null) && 66 (obj instanceof TriState)) 67 { 68 return m_nValue == ((TriState)obj).intValue(); 69 } 70 return false; 71 } 72 } 73