|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SynchronizedStatement.java | 25% | 47.1% | 57.1% | 43.8% |
|
||||||||||||||
| 1 | /* | |
| 2 | * DynamicJava - Copyright (C) 1999-2001 | |
| 3 | * | |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 | * copy of this software and associated documentation files | |
| 6 | * (the "Software"), to deal in the Software without restriction, including | |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, | |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 | * persons to whom the Software is furnished to do so, subject to the | |
| 10 | * following conditions: | |
| 11 | * The above copyright notice and this permission notice shall be included | |
| 12 | * in all copies or substantial portions of the Software. | |
| 13 | * | |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 17 | * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 20 | * DEALINGS IN THE SOFTWARE. | |
| 21 | * | |
| 22 | * Except as contained in this notice, the name of Dyade shall not be | |
| 23 | * used in advertising or otherwise to promote the sale, use or other | |
| 24 | * dealings in this Software without prior written authorization from | |
| 25 | * Dyade. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | package koala.dynamicjava.tree; | |
| 30 | ||
| 31 | import koala.dynamicjava.tree.visitor.*; | |
| 32 | ||
| 33 | /** | |
| 34 | * This class represents the synchronized statement nodes of the syntax tree | |
| 35 | * | |
| 36 | * @author Stephane Hillion | |
| 37 | * @version 1.0 - 1999/05/26 | |
| 38 | */ | |
| 39 | ||
| 40 | public class SynchronizedStatement extends Statement { | |
| 41 | /** | |
| 42 | * The lock object | |
| 43 | */ | |
| 44 | private Expression lock; | |
| 45 | ||
| 46 | /** | |
| 47 | * The body of this statement | |
| 48 | */ | |
| 49 | private Node body; | |
| 50 | ||
| 51 | /** | |
| 52 | * Creates a new while statement | |
| 53 | * @param lock the lock object | |
| 54 | * @param body the body | |
| 55 | * @exception IllegalArgumentException if lock is null or body is null | |
| 56 | */ | |
| 57 | 2 | public SynchronizedStatement(Expression lock, Node body, |
| 58 | SourceInfo si) { | |
| 59 | 2 | super(si); |
| 60 | ||
| 61 | 0 | if (lock == null) throw new IllegalArgumentException("lock == null"); |
| 62 | 0 | if (body == null) throw new IllegalArgumentException("body == null"); |
| 63 | ||
| 64 | 2 | this.lock = lock; |
| 65 | 2 | this.body = body; |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Gets the lock object | |
| 70 | */ | |
| 71 | 2 | public Expression getLock() { |
| 72 | 2 | return lock; |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Sets the condition to evaluate | |
| 77 | * @exception IllegalArgumentException if e is null | |
| 78 | */ | |
| 79 | 0 | public void setLock(Expression e) { |
| 80 | 0 | if (e == null) throw new IllegalArgumentException("e == null"); |
| 81 | 0 | lock = e; |
| 82 | } | |
| 83 | ||
| 84 | /** | |
| 85 | * Returns the body of this statement | |
| 86 | */ | |
| 87 | 2 | public Node getBody() { |
| 88 | 2 | return body; |
| 89 | } | |
| 90 | ||
| 91 | /** | |
| 92 | * Sets the body of this statement | |
| 93 | * @exception IllegalArgumentException if node is null | |
| 94 | */ | |
| 95 | 0 | public void setBody(Node node) { |
| 96 | 0 | if (node == null) throw new IllegalArgumentException("node == null"); |
| 97 | 0 | body = node; |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Allows a visitor to traverse the tree | |
| 102 | * @param visitor the visitor to accept | |
| 103 | */ | |
| 104 | 0 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 105 | 0 | return visitor.visit(this); |
| 106 | } | |
| 107 | /** | |
| 108 | * Implementation of toString for use in unit testing | |
| 109 | */ | |
| 110 | 2 | public String toString() { |
| 111 | 2 | return "("+getClass().getName()+": "+getLock()+" "+getBody()+")"; |
| 112 | } | |
| 113 | } |
|
||||||||||