FileDocCategorySizeDatePackage
TriStateBool.javaAPI DocGlassfish v2 API3673Fri May 04 22:32:08 BST 2007com.sun.enterprise.util

TriStateBool

public class TriStateBool extends Object
This class is a Java Enum for a bool value that also has an "undefined" state.

Fields Summary
public static final TriStateBool
TRUE
public static final TriStateBool
FALSE
public static final TriStateBool
UNDEFINED
Constructors Summary
private TriStateBool()

	
Methods Summary
public static voidmain(java.lang.String[] args)

	

	//////////////////////////////////////////////////////////////////////////
	
	    
	
		System.out.println("TruE: " + translate("TruE"));
		System.out.println("FALse: " + translate("FALse"));
		System.out.println("TruEX: " + translate("TruEX"));
	
public java.lang.StringtoString()

		if(this == TRUE)
			return "TRUE";
		else if(this == FALSE)
			return "FALSE";
		if(this == UNDEFINED)
			return "UNDEFINED";
		else
			return "IMPOSSIBLE VALUE!!";
	
public static final com.sun.enterprise.util.TriStateBooltranslate(java.lang.String s)
Convert a String into one of the three possible TriStateBool instances. It does a case-insensitive string comparison:

"true" --> TRUE "false" --> FALSE anything-else --> UNDEFINED

param
s String representation of the TriStateBool
return
One of the 3 possible values

		if(StringUtils.ok(s))
		{
			s = s.toLowerCase();

			if(s.equals("true"))
				return TRUE;
			if(s.equals("false"))
				return FALSE;
		}
		return UNDEFINED;