PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-model/src/com/nimbits/client/model/value/ValueModel.java

http://nimbits-server.googlecode.com/
Java | 134 lines | 82 code | 35 blank | 17 comment | 1 complexity | dee79e5deea4a6fa2f3ae878f3a8b2a5 MD5 | raw file
  1/*
  2 * Copyright (c) 2010 Tonic Solutions LLC.
  3 *
  4 * http://www.nimbits.com
  5 *
  6 *
  7 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  8 *
  9 * http://www.gnu.org/licenses/gpl.html
 10 *
 11 * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 12 */
 13
 14package com.nimbits.client.model.value;
 15
 16
 17import java.util.Date;
 18
 19
 20public class ValueModel implements Value {
 21
 22    /**
 23     *
 24     */
 25    private static final long serialVersionUID = 1L;
 26    private long id;
 27    private double lat;
 28    private double lng;
 29    private double d;
 30    private Date timestamp;
 31    private long pointFK;
 32    private String note;
 33    private String data;
 34
 35
 36    public ValueModel() {
 37    }
 38
 39    @Override
 40    public void setAlertState(final AlertType alertState) {
 41        this.alertState = alertState;
 42    }
 43
 44    @Override
 45    public String getData() {
 46        return this.data;
 47    }
 48
 49
 50    private AlertType alertState;
 51
 52    public ValueModel(final Value v) {
 53        this.id = v.getId();
 54        this.lat = v.getLatitude();
 55        this.lng = v.getLongitude();
 56        this.d = v.getValue();
 57        this.timestamp = v.getTimestamp();
 58        this.pointFK = v.getPoint();
 59        this.note = v.getNote();
 60        this.data = v.getData();
 61        //  this.tag = v.getTag();
 62    }
 63
 64    public ValueModel(final double lat,
 65                      final double lng,
 66                      final double d,
 67                      final Date timestamp,
 68                      final long pointFK,
 69                      final String note,
 70                      final String data) {
 71        this.id = 0;
 72        this.lat = lat;
 73        this.lng = lng;
 74        this.d = d;
 75        this.timestamp = new Date(timestamp.getTime());
 76        this.pointFK = pointFK;
 77        this.note = note;
 78        this.data = data;
 79
 80    }
 81
 82
 83    //
 84    @Override
 85    public long getId() {
 86        return id;
 87    }
 88
 89
 90    @Override
 91    public String getNote() {
 92        return note == null ? "" : note;
 93
 94    }
 95
 96
 97    @Override
 98    public double getLatitude() {
 99        return lat;
100    }
101
102
103    @Override
104    public double getLongitude() {
105
106        return lng;
107    }
108
109
110    @Override
111    public long getPoint() {
112        return pointFK;
113    }
114
115
116    @Override
117    public double getValue() {
118        return this.d;
119
120    }
121
122
123    @Override
124    public Date getTimestamp() {
125        return new Date(this.timestamp.getTime());
126    }
127
128    @Override
129    public AlertType getAlertState() {
130        return this.alertState;
131    }
132
133
134}