1/**
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.util;
18
19import android.os.Message;
20
21/**
22 * {@hide}
23 *
24 * The class for implementing states in a StateMachine
25 */
26public class State implements IState {
27
28    /**
29     * Constructor
30     */
31    protected State() {
32    }
33
34    /* (non-Javadoc)
35     * @see com.android.internal.util.IState#enter()
36     */
37    @Override
38    public void enter() {
39    }
40
41    /* (non-Javadoc)
42     * @see com.android.internal.util.IState#exit()
43     */
44    @Override
45    public void exit() {
46    }
47
48    /* (non-Javadoc)
49     * @see com.android.internal.util.IState#processMessage(android.os.Message)
50     */
51    @Override
52    public boolean processMessage(Message msg) {
53        return false;
54    }
55
56    /**
57     * Name of State for debugging purposes.
58     *
59     * This default implementation returns the class name, returning
60     * the instance name would better in cases where a State class
61     * is used for multiple states. But normally there is one class per
62     * state and the class name is sufficient and easy to get. You may
63     * want to provide a setName or some other mechanism for setting
64     * another name if the class name is not appropriate.
65     *
66     * @see com.android.internal.util.IState#processMessage(android.os.Message)
67     */
68    @Override
69    public String getName() {
70        String name = getClass().getName();
71        int lastDollar = name.lastIndexOf('$');
72        return name.substring(lastDollar + 1);
73    }
74}
75