Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / commands / AbstractCommand.java @ 24496

History | View | Annotate | Download (3.46 KB)

1

    
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

    
43
package org.gvsig.fmap.dal.feature.impl.commands;
44

    
45
import java.util.GregorianCalendar;
46

    
47
import org.gvsig.fmap.dal.exceptions.DataException;
48
import org.gvsig.fmap.dal.feature.Command;
49

    
50

    
51
/**
52
 * DOCUMENT ME!
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public abstract class AbstractCommand implements Command {
57
    private String description;
58
    private int year;
59
    private int month;
60
    private int day;
61
    private int hour;
62
    private int minute;
63
    private int second;
64

    
65
    public AbstractCommand(String description) {
66
        this.description = description;
67
        initDate();
68
    }
69

    
70
    public AbstractCommand() {
71
        initDate();
72
    }
73

    
74
    /**
75
     * DOCUMENT ME!
76
     */
77
    private void initDate() {
78
        GregorianCalendar calendario = new GregorianCalendar();
79
        year = calendario.get(GregorianCalendar.YEAR);
80
        month = calendario.get(GregorianCalendar.MONTH);
81
        day = calendario.get(GregorianCalendar.DAY_OF_MONTH);
82
        hour = calendario.get(GregorianCalendar.HOUR_OF_DAY);
83
        minute = calendario.get(GregorianCalendar.MINUTE);
84
        second = calendario.get(GregorianCalendar.SECOND);
85
    }
86

    
87
    /**
88
     * DOCUMENT ME!
89
     *
90
     * @param description DOCUMENT ME!
91
     */
92
    public void setDescription(String description) {
93
        this.description = description;
94
    }
95

    
96
    /**
97
     * DOCUMENT ME!
98
     *
99
     * @return DOCUMENT ME!
100
     */
101
    public String getDescription() {
102
        return this.description;
103
    }
104

    
105
    /**
106
     * DOCUMENT ME!
107
     *
108
     * @return DOCUMENT ME!
109
     */
110
    public String getDate() {
111
        return day + "/" + month + "/" + year;
112
    }
113

    
114
    /**
115
     * DOCUMENT ME!
116
     *
117
     * @return DOCUMENT ME!
118
     */
119
    public String getTime() {
120
        return hour + ":" + minute + ":" + second;
121
    }
122

    
123
    /**
124
     * DOCUMENT ME!
125
     *
126
     * @return DOCUMENT ME!
127
     */
128
    public String toString() {
129
        return this.getType() + " " + this.getDescription() + " " +
130
        this.getDate() + " " + this.getTime();
131
    }
132

    
133
        public abstract void execute();
134

    
135
        public abstract String getType();
136

    
137
        public abstract void redo() throws DataException;
138

    
139
        public abstract void undo() throws DataException;
140
}