KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > condition > solo > RuleUserHandle


1 /**
2  * $Id: RuleUserHandle.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.condition.solo;
30
31 /**
32  * Luggage that carries around a shareable condition's caller's information.
33  *
34  * @since JWare/AntX 0.2
35  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
36  * @version 0.5
37  * @.safety multiple
38  * @.group impl,infra
39  * @see BuildRule
40  * @.pattern JWare.Luggage
41  **/

42
43 final class RuleUserHandle
44 {
45     /**
46      * Initializes new empty handle (done by factory).
47      **/

48     RuleUserHandle()
49     {
50     }
51
52     /**
53      * Sets the current thread's frontmost rule user.
54      * @param c new frontmost caller (can be <i>null</i>)
55      * @return the previous rule user (can be <i>null</i>)
56      **/

57     ShareableConditionUser setCaller(ShareableConditionUser c)
58     {
59         ShareableConditionUser old = m_ruleUser;
60         m_ruleUser = c;
61         return old;
62     }
63
64
65     /**
66      * Returns the current thread's frontmost caller.
67      * Can return <i>null</i>.
68      **/

69     ShareableConditionUser getCaller()
70     {
71         return m_ruleUser;
72     }
73
74
75     /* Seekrit member. */
76     private ShareableConditionUser m_ruleUser;
77
78
79     // ---------------------------------------------------------------------------------------
80
/**
81      * Factory of thread-specific RuleUserHandles.
82      * @since JWare/AntX 0.2
83      * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
84      * @version 0.5
85      **/

86     static final class Factory extends InheritableThreadLocal JavaDoc
87     {
88         /**
89          * Returns a new RuleUserHandle.
90          **/

91         protected Object JavaDoc initialValue()
92         {
93             return new RuleUserHandle();
94         }
95
96         /**
97          * Returns a new RuleUserHandle with reference to its parent's
98          * rule caller.
99          **/

100         protected Object JavaDoc childValue(Object JavaDoc parentValue)
101         {
102             RuleUserHandle parentsJunk = (RuleUserHandle)parentValue;
103             RuleUserHandle copy = new RuleUserHandle();
104             if (parentsJunk!=null) {
105                 copy.setCaller(parentsJunk.getCaller());
106             }
107             return copy;
108         }
109
110         /**
111          * Creates a new factory (only allowed from package's BuildRule).
112          **/

113         Factory()
114         {
115         }
116     }
117 }
118
119 /* end-of-RuleUserHandle.java */
120
Popular Tags