001 package railo.runtime.interpreter.ref.literal; 002 003 import railo.runtime.exp.PageException; 004 import railo.runtime.interpreter.ref.Ref; 005 import railo.runtime.interpreter.ref.RefSupport; 006 import railo.runtime.interpreter.ref.util.RefUtil; 007 import railo.runtime.op.Caster; 008 009 /** 010 * constructor of the class 011 */ 012 public final class LBoolean extends RefSupport implements Literal { 013 014 /** 015 * Field <code>TRUE</code> 016 */ 017 public static final Ref TRUE = new LBoolean(Boolean.TRUE); 018 /** 019 * Field <code>FALSE</code> 020 */ 021 public static final Ref FALSE = new LBoolean(Boolean.FALSE); 022 023 private Boolean literal; 024 025 /** 026 * constructor with Boolean 027 * @param literal 028 */ 029 public LBoolean(Boolean literal) { 030 this.literal=literal; 031 } 032 033 /** 034 * constructor with boolean 035 * @param b 036 */ 037 public LBoolean(boolean b) { 038 this.literal=b?Boolean.TRUE:Boolean.FALSE; 039 } 040 041 /** 042 * constructor with boolean 043 * @param str 044 * @throws PageException 045 */ 046 public LBoolean(String str) throws PageException { 047 this.literal=Caster.toBoolean(str); 048 } 049 050 051 /** 052 * @see railo.runtime.interpreter.ref.Ref#getValue() 053 */ 054 public Object getValue() { 055 return literal; 056 } 057 058 /** 059 * @see railo.runtime.interpreter.ref.Ref#getTypeName() 060 */ 061 public String getTypeName() { 062 return "literal"; 063 } 064 065 /** 066 * @see railo.runtime.interpreter.ref.literal.Literal#getString() 067 */ 068 public String getString() { 069 return Caster.toString(literal.booleanValue()); 070 } 071 072 /** 073 * @see java.lang.Object#toString() 074 */ 075 public String toString() { 076 return getString(); 077 } 078 079 /** 080 * @see railo.runtime.interpreter.ref.Ref#eeq(railo.runtime.interpreter.ref.Ref) 081 */ 082 public boolean eeq(Ref other) throws PageException { 083 if(other instanceof LNumber){ 084 return literal.booleanValue()==((LBoolean)other).literal.booleanValue(); 085 } 086 return RefUtil.eeq(this,other); 087 } 088 089 }