Translate Java module directly by B4Android
I completeli agree whit Ashchopra
As B4Android basically converts all B4Android code to java, there should be a way that you could use the java functions/methods/classses in B4Android,
(eventual with a externe module). I find it a little "stupid" to make a library of every module written in Java
because most of them wil be used once.
What i mean is that the included code is a class written in java. I want simply make a [class]module in B4Android of it. so i have completely rewritte it in B4Android. and after that B4Android retranslate it to java :icon_clap: If i had something in B4Android to translate this code directly into a B4Android classe i saved a lot of my time.
Attention the code is only a demo what i mean and is not compleed
@ShortName("PersianCalender")
public class PersianDate extends AbstractDate {
private static final String[] monthName = { "", "فروردین",
"اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان",
"آذر", "دی", "بهمن", "اسفند" };
public String[] getMonthsList() {
return monthName;
}
private int year;
private int month;
private int day;
public PersianDate(int year, int month, int day) {
setYear(year);
// Initialize day, so that we get no exceptions when setting month
this.day = 1;
setMonth(month);
setDayOfMonth(day);
}
public int getDayOfMonth() {
return day;
}
public int getMonth() {
return month;
}
public String getMonthName() {
return monthName[month];
}
public int getWeekOfYear() {
throw new RuntimeException("not implemented yet!");
}
public int getYear() {
return year;
}
public void rollDay(int amount, boolean up) {
throw new RuntimeException("not implemented yet!");
}
public void rollMonth(int amount, boolean up) {
throw new RuntimeException("not implemented yet!");
}
public void rollYear(int amount, boolean up) {
throw new RuntimeException("not implemented yet!");
}
public void setDayOfMonth(int day) {
if (day < 1)
throw new DayOutOfRangeException("day " + day + " is out of range!");
if (month <= 6 && day > 31)
throw new DayOutOfRangeException("day " + day + " is out of range!");
if (month > 6 && month <= 12 && day > 30)
throw new DayOutOfRangeException("day " + day + " is out of range!");
if (month == 12 && day > 29 && (!isLeapYear()))
throw new DayOutOfRangeException("day " + day + " is out of range!");
this.day = day;
}
public void setMonth(int month) {
if (month < 1 || month > 12)
throw new MonthOutOfRangeException("month " + month
+ " is out of range!");
// Set the day again, so that exceptions are thrown if the
// day is out of range
setDayOfMonth(day);
this.month = month;
}
public void setYear(int year) {
if (year == 0)
throw new YearOutOfRangeException("Year 0 is invalid!");
this.year = year;
}
public String getEvent() {
throw new RuntimeException("not implemented yet!");
}
public int getDayOfWeek() {
throw new RuntimeException("not implemented yet!");
}
public int getDayOfYear() {
throw new RuntimeException("not implemented yet!");
}
public int getWeekOfMonth() {
throw new RuntimeException("not implemented yet!");
}
public boolean isLeapYear() {
int mod = getYear() % 33;
if (mod == 1 || mod == 5 || mod == 9 || mod == 13 || mod == 17
|| mod == 22 || mod == 26 || mod == 30)
return true;
return false;
}
public boolean equals(PersianDate persianDate) {
if (this.getDayOfMonth() == persianDate.getDayOfMonth()
&& this.getMonth() == persianDate.getMonth()
&& this.getYear() == persianDate.getYear())
return true;
return false;
}
}