Context-detection API for Android developed as a university project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JourneyStep.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2009-2010 Chris Smith
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package uk.co.md87.android.common.model;
  23. import android.net.Uri;
  24. /**
  25. * A journey step is a single activity which occurred one or more times in a
  26. * {@link Journey}. The activity may be repeated any number of times in a row.
  27. *
  28. * @author chris
  29. */
  30. public class JourneyStep {
  31. public static final String _ID = "_id";
  32. public static final String ACTIVITY = "activity";
  33. public static final String REPETITIONS = "repetitions";
  34. public static final String JOURNEY = "journey";
  35. public static final String NEXT = "next";
  36. public static final Uri CONTENT_URI = Uri.parse("content://uk.co.md87"
  37. + ".android.contextanalyser.journeyscontentprovider/steps");
  38. public static final String CONTENT_TYPE = "vnd.contextanalyser.journeystep";
  39. private final long id;
  40. private final String activity;
  41. private final int repetitions;
  42. private final long journey;
  43. private final long next;
  44. public JourneyStep(final String activity, final int repetitions) {
  45. this(-1, activity, repetitions, -1, -1);
  46. }
  47. public JourneyStep(final long id, final String activity,
  48. final int repetitions, final long journey, final long next) {
  49. this.id = id;
  50. this.activity = activity;
  51. this.repetitions = repetitions;
  52. this.journey = journey;
  53. this.next = next;
  54. }
  55. public String getActivity() {
  56. return activity;
  57. }
  58. public long getId() {
  59. return id;
  60. }
  61. public long getJourney() {
  62. return journey;
  63. }
  64. public long getNext() {
  65. return next;
  66. }
  67. public int getRepetitions() {
  68. return repetitions;
  69. }
  70. /** {@inheritDoc} */
  71. @Override
  72. public boolean equals(final Object obj) {
  73. if (obj == null || getClass() != obj.getClass()) {
  74. return false;
  75. }
  76. final JourneyStep other = (JourneyStep) obj;
  77. return this.activity.equals(other.getActivity())
  78. && this.repetitions == other.getRepetitions();
  79. }
  80. /** {@inheritDoc} */
  81. @Override
  82. public int hashCode() {
  83. int hash = 7;
  84. hash = 37 * hash + this.activity.hashCode();
  85. hash = 37 * hash + this.repetitions;
  86. return hash;
  87. }
  88. @Override
  89. public String toString() {
  90. return "JourneyStep{" + activity + " * " + repetitions + '}';
  91. }
  92. }