Revize 27ba3ec6
Přidáno uživatelem Daniel Stuš před více než 5 roky(ů)
src/data/Bitmap.java | ||
---|---|---|
7 | 7 |
import java.time.temporal.WeekFields; |
8 | 8 |
import java.util.Arrays; |
9 | 9 |
import java.util.Locale; |
10 |
import java.util.Objects; |
|
10 | 11 |
|
11 | 12 |
/** |
12 | 13 |
* |
... | ... | |
16 | 17 |
* @version 1.0 |
17 | 18 |
* |
18 | 19 |
*/ |
19 |
public class Bitmap { |
|
20 |
public class Bitmap implements Comparable<Bitmap>{
|
|
20 | 21 |
|
21 | 22 |
//-------------- Atributy --------------/ |
22 | 23 |
|
... | ... | |
456 | 457 |
switch (hardCode) { |
457 | 458 |
case 'X': if(day.getDayOfWeek() != DayOfWeek.SATURDAY && day.getDayOfWeek() != DayOfWeek.SUNDAY && !isBankHoliday(day)) return true ; break; |
458 | 459 |
case '+': if (day.getDayOfWeek() != DayOfWeek.SATURDAY) return true; break; |
459 |
case '1': if (day.getDayOfWeek() == DayOfWeek.MONDAY) return true; break; |
|
460 |
case '1': if (day.getDayOfWeek() == DayOfWeek.MONDAY) return true; break;
|
|
460 | 461 |
case '2': if (day.getDayOfWeek() == DayOfWeek.TUESDAY) return true; break; |
461 | 462 |
case '3': if (day.getDayOfWeek() == DayOfWeek.WEDNESDAY) return true; break; |
462 | 463 |
case '4': if (day.getDayOfWeek() == DayOfWeek.THURSDAY) return true; break; |
... | ... | |
590 | 591 |
* @param year Rok pro vypocet velikonocnich svatku |
591 | 592 |
*/ |
592 | 593 |
public void getEasterHolidays(int year) { |
593 |
int Y = year; |
|
594 |
int a = Y % 19; |
|
595 |
int b = Y / 100; |
|
596 |
int c = Y % 100; |
|
594 |
int a = year % 19; |
|
595 |
int b = year / 100; |
|
596 |
int c = year % 100; |
|
597 | 597 |
int d = b / 4; |
598 | 598 |
int e = b % 4; |
599 | 599 |
int f = (b + 8) / 25; |
... | ... | |
870 | 870 |
} |
871 | 871 |
|
872 | 872 |
|
873 |
/** |
|
874 |
* Porovnava bitmapy podle jejich atributu pro serazeni podle hodnot |
|
875 |
* @param o bitmapa k porovnani se stavajici |
|
876 |
* @return 0 - kdyz jsou bitmapy stejne |
|
877 |
* 1 - kdyz je bitmapa "vetsi" |
|
878 |
* -1 - kdyz je bitmapa "mensi" |
|
879 |
*/ |
|
880 |
@Override |
|
881 |
public int compareTo(Bitmap o) { |
|
882 |
|
|
883 |
if (this.lineNumber.equals(o.lineNumber)) { |
|
884 |
if(this.lineVersion.equals(o.lineVersion)) { |
|
885 |
if (this.timeCode.equals(o.timeCode)) { |
|
886 |
if (this.hardCodes.equals(o.hardCodes)) { |
|
887 |
if(Arrays.equals(this.bitmap, o.bitmap)) return 0; |
|
888 |
else return -1; |
|
889 |
} |
|
890 |
else if (this.hardCodes.equals("") && !o.hardCodes.equals("")) |
|
891 |
return -Integer.parseInt(o.hardCodes); |
|
892 |
else if (!this.hardCodes.equals("") && !o.hardCodes.equals("")) |
|
893 |
return Integer.parseInt(this.hardCodes); |
|
894 |
else return Integer.parseInt(this.hardCodes) - Integer.parseInt(o.hardCodes); |
|
895 |
} |
|
896 |
else if (this.timeCode.equals("") && !o.timeCode.equals("")) |
|
897 |
return -Integer.parseInt(o.timeCode); |
|
898 |
else if (!this.timeCode.equals("") && o.timeCode.equals("")) |
|
899 |
return Integer.parseInt(this.timeCode); |
|
900 |
else return Integer.parseInt(this.timeCode) - Integer.parseInt(o.timeCode); |
|
901 |
} |
|
902 |
else return Integer.parseInt(this.lineVersion) - Integer.parseInt(o.lineVersion); |
|
903 |
} |
|
904 |
else return Integer.parseInt(this.lineNumber) - Integer.parseInt(o.lineNumber); |
|
905 |
} |
|
906 |
|
|
907 |
/** |
|
908 |
* Porovna objekt s bitmapou a rozhodne zda se jedna o stejnou ci ne |
|
909 |
* @param obj objekt k porovnani s bitmapou |
|
910 |
* @return true - kdyz je cela bitmapa stejna |
|
911 |
* false - v opacnem pripade |
|
912 |
*/ |
|
913 |
@Override |
|
914 |
public boolean equals(Object obj) { |
|
915 |
if (this == obj) return true; |
|
916 |
if (obj == null) return false; |
|
917 |
if(getClass() != obj.getClass()) return false; |
|
918 |
Bitmap o = (Bitmap) obj; |
|
919 |
return Objects.equals(lineNumber, o.lineNumber) && Objects.equals(lineVersion, o.lineVersion) && |
|
920 |
Objects.equals(timeCode, o.timeCode) && Objects.equals(hardCodes, o.hardCodes) && |
|
921 |
Objects.equals(bitmap, o.bitmap); |
|
922 |
} |
|
923 |
|
|
924 |
|
|
873 | 925 |
} |
926 |
|
|
927 |
|
Také k dispozici: Unified diff
Oprava implementace podle potřeb zadavatele, doplnění funkcionality pseudo linek + odstranění redundantních tříd a souborů (Re #7570)