01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Victor A. Martynov
21: * @version $Revision: 1.1.2.3 $
22: */package org.apache.harmony.rmi.activation;
23:
24: /**
25: * Holds the ID of the node object and its state.
26: *
27: * @author Victor A. Martynov
28: * @version $Revision: 1.1.2.3 $
29: */
30: public class NodeInfo {
31:
32: private static final int REGISTERED_STATE = 0;
33: private static final int ACTIVE_STATE = 1;
34: private static final int INACTIVE_STATE = 2;
35:
36: private static final String[] STATES = { "(registered)", //$NON-NLS-1$
37: "(active)", //$NON-NLS-1$
38: "(inactive)" //$NON-NLS-1$
39: };
40:
41: /**
42: * Either ActivationGroupID or ActivationID.
43: */
44: private Object id;
45:
46: /**
47: * One of 3 possible states.
48: */
49: private int state;
50:
51: /**
52: * Creates NodeInfo object with given ID and <i>"registered"</i> state.
53: * @param id <code>ActivationGroupID</code> or <code>ActivationID</code>.
54: */
55: public NodeInfo(Object id) {
56: this .id = id;
57: this .state = REGISTERED_STATE;
58: }
59:
60: /**
61: * @return ID of this node.
62: */
63: public Object getID() {
64: return id;
65: }
66:
67: /**
68: * Sets the state of this node to <i>"active"</i>.
69: */
70: public void active() {
71: this .state = ACTIVE_STATE;
72: }
73:
74: /**
75: * Sets the state of this node to <i>"inactive"</i>.
76: */
77: public void inactive() {
78: this .state = INACTIVE_STATE;
79: }
80:
81: /**
82: * @return String representation of this node consisting of its ID and state.
83: */
84: public String toString() {
85: return id + ": " + STATES[state]; //$NON-NLS-1$
86: }
87: }
|