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