summaryrefslogtreecommitdiff
path: root/sources/events/VSEvent.java
blob: eba60b1508af9264950aecb06ad990a847be66e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * VS is (c) 2008 by Paul C. Buetow
 * vs@dev.buetow.org
 */
package events;

import core.VSProcess;
import prefs.VSPrefs;

/**
 * The Class VSEvent.
 */
abstract public class VSEvent extends VSPrefs {
    /** The prefs. */
    protected VSPrefs prefs;

    /** The process. */
    protected VSProcess process;

    /** The event shortname. */
    private String eventShortname;

    /** The event classname. */
    private String eventClassname;

    /**
     * Inits the.
     *
     * @param process the process
     */
    public void init(VSProcess process) {
        this.process = process;
        this.prefs = process.getPrefs();

        onInit();
    }

    /**
     * Sets the classname.
     *
     * @param eventClassname the new classname
     */
    protected final void setClassname(String eventClassname) {
        if (eventClassname.startsWith("class "))
            eventClassname = eventClassname.substring(6);

        this.eventClassname = eventClassname;
    }

    /**
     * Gets the classname.
     *
     * @return the classname
     */
    public String getClassname() {
        return eventClassname;
    }

    /**
     * Gets the name.
     *
     * @return the name
     */
    public String getName() {
        return VSRegisteredEvents.getName(eventClassname);
    }

    /**
     * Sets the shortname.
     *
     * @param eventShortname the new shortname
     */
    public void setShortname(String eventShortname) {
        this.eventShortname = eventShortname;
    }

    /**
     * Gets the shortname.
     *
     * @return the shortname
     */
    public String getShortname() {
        if (eventShortname == null)
            return VSRegisteredEvents.getShortname(eventClassname);

        return eventShortname;
    }

    /**
     * Gets the process.
     *
     * @return the process
     */
    public VSProcess getProcess() {
        return process;
    }

    /**
     * Logg.
     *
     * @param message the message
     */
    public void logg(String message) {
        process.logg(/*toString() + "; " + */message);
    }

    /**
     * Equals.
     *
     * @param event the event
     *
     * @return true, if successful
     */
    public boolean equals(VSEvent event) {
        return super.getID() == event.getID();
    }

    /**
     * On init.
     */
    abstract protected void onInit();

    /**
     * On start.
     */
    abstract public void onStart();
}