/interpreter/tags/at2dist030708/src/edu/vub/at/objects/ATBoolean.java

http://ambienttalk.googlecode.com/ · Java · 131 lines · 12 code · 11 blank · 108 comment · 0 complexity · cf64fe6cc40948539e7db22327ce4198 MD5 · raw file

  1. /**
  2. * AmbientTalk/2 Project
  3. * ATBoolean.java created on Jul 26, 2006 at 9:53:31 PM
  4. * (c) Programming Technology Lab, 2006 - 2007
  5. * Authors: Tom Van Cutsem & Stijn Mostinckx
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use,
  11. * copy, modify, merge, publish, distribute, sublicense, and/or
  12. * sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following
  14. * conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. package edu.vub.at.objects;
  29. import edu.vub.at.exceptions.InterpreterException;
  30. /**
  31. * The ATBoolean represents the public interface of a boolean object.
  32. *
  33. * @author smostinc
  34. * @author tvcutsem
  35. */
  36. public interface ATBoolean extends ATObject {
  37. /**
  38. * Returns an ATObject representing the result of evaluating the code to execute
  39. * if the boolean condition is true. Returns nil if the boolean expression is false.
  40. * <p>
  41. * Usage:
  42. * <code>booleanCondition.ifTrue: { code }</code>
  43. *
  44. * @param consequent a closure containing the code to execute if the boolean is true.
  45. * @return the result of evaluating the closure or nil.
  46. * @throws InterpreterException if raised in the evaluation of the closure.
  47. */
  48. public ATObject base_ifTrue_(ATClosure consequent) throws InterpreterException;
  49. /**
  50. * Returns an {@link ATObject} representing the result of evaluating the code to execute
  51. * if the boolean condition is false. Returns nil if the boolean expression is true.
  52. * <p>
  53. * Usage:
  54. * <code>booleanCondition.ifFalse: { code } </code>
  55. *
  56. * @param alternative a closure containing the code to execute if the boolean is false.
  57. * @return the result of evaluating the closure or nil.
  58. * @throws InterpreterException if raised in the evaluation of the closure.
  59. */
  60. public ATObject base_ifFalse_(ATClosure alternative) throws InterpreterException;
  61. /**
  62. * Returns an {@link ATObject} representing the result of evaluating either the code to execute
  63. * if the boolean condition is false or the one to execute if the boolean condition is true.
  64. * <p>
  65. * Usage:
  66. * <code>booleanCondition.ifTrue: { consequent } ifFalse: { alternative } </code>
  67. *
  68. * @param consequent a closure containing the code to execute if the boolean is true.
  69. * @param alternative a closure containing the code to execute if the boolean is false.
  70. * @return the result of the consequent or alternative closure.
  71. * @throws InterpreterException if raised in the evaluation of the consequent or alternative closure.
  72. */
  73. public ATObject base_ifTrue_ifFalse_(ATClosure consequent, ATClosure alternative) throws InterpreterException;
  74. /**
  75. * Returns false if the receiver is false or the result of the evaluation of the other
  76. * boolean expression passed as argument if the receiver is true.
  77. * <p>
  78. * Usage: <code>boolean.and: { other }</code>
  79. *
  80. * @param other a closure whose evaluation returns a boolean.
  81. * @return false or the result of evaluating the other boolean.
  82. * @throws InterpreterException if raised in the evaluation of the other boolean.
  83. */
  84. public ATBoolean base_and_(ATClosure other) throws InterpreterException;
  85. /**
  86. * Auxiliary function:
  87. * <code>
  88. * def boolean.and: b1 and: b2 {
  89. * (boolean.and: b1).and: b2
  90. * }
  91. * </code>
  92. */
  93. public ATBoolean base_and_and_(ATClosure b1, ATClosure b2) throws InterpreterException;
  94. /**
  95. * Returns true if the receiver is true or the result of the evaluation of the other
  96. * boolean expression passed as argument if the receiver is false.
  97. * <p>
  98. * Usage: <code>boolean.or: { other }</code>
  99. *
  100. * @param other a closure whose evaluation returns a boolean.
  101. * @return true or the result of evaluating the other boolean.
  102. * @throws InterpreterException if raised in the evaluation of the other boolean.
  103. */
  104. public ATBoolean base_or_(ATClosure other) throws InterpreterException;
  105. /**
  106. * Auxiliary function:
  107. * <code>
  108. * def boolean.or: b1 or: b2 {
  109. * (boolean.or: b1).or: b2
  110. * }
  111. * </code>
  112. */
  113. public ATBoolean base_or_or_(ATClosure b1, ATClosure b2) throws InterpreterException;
  114. /**
  115. * Returns true if the receiver is false or false if the receiver is true.
  116. *
  117. * @return a boolean resulting of the negation of the receiver.
  118. */
  119. public ATBoolean base_not() throws InterpreterException;
  120. }