]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/util/Lockable.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / util / Lockable.java
1 /*\r
2  ******************************************************************************\r
3  * Copyright (C) 2005-2008, International Business Machines Corporation and   *\r
4  * others. All Rights Reserved.                                               *\r
5  ******************************************************************************\r
6 */\r
7 package com.ibm.icu.dev.test.util;\r
8 \r
9 /**\r
10  * Provides a flexible mechanism for controlling access, without requiring that a class be immutable.\r
11  * Once locked, an object can never be unlocked, so it is thread-safe from that point onward.\r
12  * The implementation of both methods must be synchronized.\r
13  * Once the object has been locked, it must guarantee that no changes can be made to it.\r
14  * Any attempt to alter it must raise an UnsupportedOperationException exception.\r
15  * This means that when the object returns internal objects,\r
16  * or if anyone has references to those internal objects, that those internal objects must either be immutable,\r
17  * or must also raise exceptions if any attempt to modify them is made. Of course, the object can return clones\r
18  * of internal objects, since those are safe. * @author davis\r
19  */\r
20 public interface Lockable extends Cloneable {\r
21     /**\r
22      * Determines whether the object has been locked or not.\r
23      */\r
24     public boolean isLocked();\r
25     /**\r
26      * Locks the object.\r
27      * @return the object itself.\r
28      */\r
29     public Object lock();\r
30     /**\r
31      * Provides for the clone operation. Any clone is initially unlocked.\r
32      */\r
33     public Object clone();\r
34 }