/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. package com.nimbits.client.model.value;
  14. import java.util.Date;
  15. public class ValueModel implements Value {
  16. /**
  17. *
  18. */
  19. private static final long serialVersionUID = 1L;
  20. private long id;
  21. private double lat;
  22. private double lng;
  23. private double d;
  24. private Date timestamp;
  25. private long pointFK;
  26. private String note;
  27. private String data;
  28. public ValueModel() {
  29. }
  30. @Override
  31. public void setAlertState(final AlertType alertState) {
  32. this.alertState = alertState;
  33. }
  34. @Override
  35. public String getData() {
  36. return this.data;
  37. }
  38. private AlertType alertState;
  39. public ValueModel(final Value v) {
  40. this.id = v.getId();
  41. this.lat = v.getLatitude();
  42. this.lng = v.getLongitude();
  43. this.d = v.getValue();
  44. this.timestamp = v.getTimestamp();
  45. this.pointFK = v.getPoint();
  46. this.note = v.getNote();
  47. this.data = v.getData();
  48. // this.tag = v.getTag();
  49. }
  50. public ValueModel(final double lat,
  51. final double lng,
  52. final double d,
  53. final Date timestamp,
  54. final long pointFK,
  55. final String note,
  56. final String data) {
  57. this.id = 0;
  58. this.lat = lat;
  59. this.lng = lng;
  60. this.d = d;
  61. this.timestamp = new Date(timestamp.getTime());
  62. this.pointFK = pointFK;
  63. this.note = note;
  64. this.data = data;
  65. }
  66. //
  67. @Override
  68. public long getId() {
  69. return id;
  70. }
  71. @Override
  72. public String getNote() {
  73. return note == null ? "" : note;
  74. }
  75. @Override
  76. public double getLatitude() {
  77. return lat;
  78. }
  79. @Override
  80. public double getLongitude() {
  81. return lng;
  82. }
  83. @Override
  84. public long getPoint() {
  85. return pointFK;
  86. }
  87. @Override
  88. public double getValue() {
  89. return this.d;
  90. }
  91. @Override
  92. public Date getTimestamp() {
  93. return new Date(this.timestamp.getTime());
  94. }
  95. @Override
  96. public AlertType getAlertState() {
  97. return this.alertState;
  98. }
  99. }