litesoft
@ 860
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.ui.support.nonpublic; import java.util.*; import org.litesoft.core.simpletypes.temporal.*; import org.litesoft.core.typeutils.*; public class CreditsData implements Comparable { private String mWho; private CalendarYMD mStartDate, mEndDate = null; public CreditsData( String pStartDateYYYY_MM_DD, String pWho, String pEndDateYYYY_MM_DD ) { mStartDate = CalendarYMD.fromYMD( pStartDateYYYY_MM_DD ); mWho = Strings.assertNotNullNotEmpty( "Who", pWho ); if ( pEndDateYYYY_MM_DD != null ) { mEndDate = CalendarYMD.fromYMD( pEndDateYYYY_MM_DD ); } } public CreditsData( String pStartDateYYYY_MM_DD, String pWho ) { this( pStartDateYYYY_MM_DD, pWho, null ); } public String getWho() { return mWho; } public CalendarYMD getStartDate() { return mStartDate; } public CalendarYMD getEndDate() { return (mEndDate != null) ? mEndDate : new CalendarYMD( new Date() ); } public boolean wasActiveDuring( int pYear, int pMonth, int pFromDay, int pThruDay ) { CalendarYMD fromDate = new CalendarYMD( pYear, pMonth, pFromDay ); CalendarYMD thruDate = new CalendarYMD( pYear, pMonth, pThruDay ); return !mStartDate.after( thruDate ) && !fromDate.after( getEndDate() ); } private Integer getActiveDuration() { int rv = getStartDate().daysTill( getEndDate() ); return new Integer( rv ); } public int compareTo( Object o ) { return compareTo( (CreditsData) o ); } public int compareTo( CreditsData them ) { // Note Reverse Order int rv = them.getActiveDuration().compareTo( this.getActiveDuration() ); return (rv != 0) ? rv : this.getWho().compareTo( them.getWho() ); } public boolean equals( CreditsData them ) { return (this == them) || ((them != null) && // this.mWho.equals( them.mWho ) && // this.mStartDate.equals( them.mStartDate ) && // Objects.areNonArraysEqual( this.mEndDate, them.mEndDate )); } public boolean equals( Object o ) { return (this == o) || ((o instanceof CreditsData) && equals( (CreditsData) o )); } public int hashCode() { int result = (mEndDate == null) ? 0 : mEndDate.hashCode(); result = 31 * result + mStartDate.hashCode(); result = 31 * result + mWho.hashCode(); return result; } public static class MonthYear { private int mY, mM; public MonthYear( int pY, int pM ) { mY = pY; mM = pM; } public MonthYear( CalendarYMD pCalendarYMD ) { mY = pCalendarYMD.getYear(); mM = pCalendarYMD.getMonth(); } public int getYear() { return mY; } public int getMonth() { return mM; } public MonthYear incMonth() { if ( 13 == ++mM ) { mM = 1; mY++; } return this; } public String toString() { return twoDigits( mM ) + "/" + twoDigits( mY ); } private String twoDigits( int i ) { String s = Integer.toString( i + 100 ); while ( s.length() > 2 ) { s = s.substring( 1 ); } return s; } public boolean isLessThan( CalendarYMD them ) { if ( this.mY == them.getYear() ) { return (this.mM < them.getMonth()); } return (this.mY < them.getYear()); } public boolean isLessThanOrEqual( CalendarYMD them ) { if ( this.mY == them.getYear() ) { return (this.mM <= them.getMonth()); } return (this.mY < them.getYear()); } } } |
Commits for litesoft/trunk/Java/core/jvm1.4/src/org/litesoft/ui/support/nonpublic/CreditsData.java
Revision | Author | Commited | Message |
---|---|---|---|
860 Diff | GeorgeS | Mon 05 Nov, 2012 01:39:02 +0000 | |
853 Diff | GeorgeS | Sun 04 Nov, 2012 15:18:21 +0000 | |
821 Diff | GeorgeS | Sun 19 Aug, 2012 00:08:41 +0000 | |
804 Diff | GeorgeS | Wed 15 Aug, 2012 12:48:51 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |