001 /* 002 * Zmanim Java API 003 * Copyright (C) 2007 Eliyahu Hershfeld 004 * 005 * This program is free software; you can redistribute it and/or modify it under the terms of the 006 * GNU General Public License as published by the Free Software Foundation; either version 2 of the 007 * License, or (at your option) any later version. 008 * 009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 010 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * General Public License for more details. 012 * 013 * You should have received a copy of the GNU General Public License along with this program; if 014 * not, write to the Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 015 * 02111-1307, USA or connect to: http://www.fsf.org/copyleft/gpl.html 016 */ 017 package net.sourceforge.zmanim.util; 018 019 import java.util.Comparator; 020 import java.util.Date; 021 022 /** 023 * Wrapper class for an astronomical time, mostly used to sort astronomical times. 024 * 025 * @author © Eliyahu Hershfeld 2007 026 * @version 0.1 027 */ 028 public class Zman { 029 private String zmanLabel; 030 private Date zman; 031 private long duration; 032 private Date zmanDescription; 033 034 public Zman(Date date, String label) { 035 zmanLabel = label; 036 zman = date; 037 } 038 039 public Zman(long duration, String label) { 040 zmanLabel = label; 041 this.duration = duration; 042 } 043 044 public Date getZman() { 045 return zman; 046 } 047 048 public void setZman(Date date) { 049 zman = date; 050 } 051 052 public long getDuration() { 053 return duration; 054 } 055 056 public void setDuration(long duration) { 057 this.duration = duration; 058 } 059 060 public String getZmanLabel() { 061 return zmanLabel; 062 } 063 064 public void setZmanLabel(String label) { 065 zmanLabel = label; 066 } 067 068 /** 069 * TODO implement duration support for solar hours 070 */ 071 public static final Comparator DATE_ORDER = new Comparator() { 072 public int compare(Object o1, Object o2) { 073 Zman z1 = (Zman) o1; 074 Zman z2 = (Zman) o2; 075 return z1.getZman().compareTo(z2.getZman()); 076 } 077 }; 078 079 public static final Comparator NAME_ORDER = new Comparator() { 080 public int compare(Object o1, Object o2) { 081 Zman z1 = (Zman) o1; 082 Zman z2 = (Zman) o2; 083 return z1.getZmanLabel().compareTo(z2.getZmanLabel()); 084 } 085 }; 086 087 /** 088 * @return the zmanDescription 089 */ 090 public Date getZmanDescription() { 091 return zmanDescription; 092 } 093 094 /** 095 * @param zmanDescription the zmanDescription to set 096 */ 097 public void setZmanDescription(Date zmanDescription) { 098 this.zmanDescription = zmanDescription; 099 } 100 }