repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/AccountingChronology.java | AccountingChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<AccountingDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<AccountingDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<AccountingDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<AccountingDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"AccountingDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"AccountingDate",
">",
")",
"... | Obtains a Accounting local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Accounting local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Accounting",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L426-L430 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/AccountingChronology.java | AccountingChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<AccountingDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<AccountingDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<AccountingDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<AccountingDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"AccountingDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"AccountingDate",
">",
")",
"... | Obtains a Accounting zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Accounting zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Accounting",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/AccountingChronology.java#L439-L443 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/CopticChronology.java | CopticChronology.date | @Override
public CopticDate date(int prolepticYear, int month, int dayOfMonth) {
return CopticDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public CopticDate date(int prolepticYear, int month, int dayOfMonth) {
return CopticDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"CopticDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"CopticDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Coptic calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Coptic local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Coptic",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L167-L170 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/CopticChronology.java | CopticChronology.dateYearDay | @Override
public CopticDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public CopticDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"CopticDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Coptic calendar system from the
era, year-of-era and day-of-year fields.
@param era the Coptic era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Coptic local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code CopticEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Coptic",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L183-L186 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/CopticChronology.java | CopticChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<CopticDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<CopticDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<CopticDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<CopticDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"CopticDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"CopticDate",
">",
")",
"super",
... | Obtains a Coptic local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Coptic local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Coptic",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L286-L290 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/CopticChronology.java | CopticChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<CopticDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<CopticDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<CopticDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<CopticDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"CopticDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"CopticDate",
">",
")",
"super",
... | Obtains a Coptic zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Coptic zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Coptic",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/CopticChronology.java#L299-L303 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/YearQuarter.java | YearQuarter.with | private YearQuarter with(int newYear, Quarter newQuarter) {
if (year == newYear && quarter == newQuarter) {
return this;
}
return new YearQuarter(newYear, newQuarter);
} | java | private YearQuarter with(int newYear, Quarter newQuarter) {
if (year == newYear && quarter == newQuarter) {
return this;
}
return new YearQuarter(newYear, newQuarter);
} | [
"private",
"YearQuarter",
"with",
"(",
"int",
"newYear",
",",
"Quarter",
"newQuarter",
")",
"{",
"if",
"(",
"year",
"==",
"newYear",
"&&",
"quarter",
"==",
"newQuarter",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"YearQuarter",
"(",
"newYear",
... | Returns a copy of this year-quarter with the new year and quarter, checking
to see if a new object is in fact required.
@param newYear the year to represent, validated from MIN_YEAR to MAX_YEAR
@param newQuarter the quarter-of-year to represent, validated not null
@return the year-quarter, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"year",
"-",
"quarter",
"with",
"the",
"new",
"year",
"and",
"quarter",
"checking",
"to",
"see",
"if",
"a",
"new",
"object",
"is",
"in",
"fact",
"required",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearQuarter.java#L308-L313 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java | BritishCutoverChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<BritishCutoverDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<BritishCutoverDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<BritishCutoverDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<BritishCutoverDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"BritishCutoverDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"BritishCutoverDate",
">",
... | Obtains a British Cutover local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the British Cutover local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"British",
"Cutover",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java#L370-L374 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java | BritishCutoverChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<BritishCutoverDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<BritishCutoverDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<BritishCutoverDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<BritishCutoverDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"BritishCutoverDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"BritishCutoverDate",
">",
... | Obtains a British Cutover zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the British Cutover zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"British",
"Cutover",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/BritishCutoverChronology.java#L383-L387 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/YearWeek.java | YearWeek.weekRange | private static int weekRange(int weekBasedYear) {
LocalDate date = LocalDate.of(weekBasedYear, 1, 1);
// 53 weeks if year starts on Thursday, or Wed in a leap year
if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) {
return 53;
}
return 52;
} | java | private static int weekRange(int weekBasedYear) {
LocalDate date = LocalDate.of(weekBasedYear, 1, 1);
// 53 weeks if year starts on Thursday, or Wed in a leap year
if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) {
return 53;
}
return 52;
} | [
"private",
"static",
"int",
"weekRange",
"(",
"int",
"weekBasedYear",
")",
"{",
"LocalDate",
"date",
"=",
"LocalDate",
".",
"of",
"(",
"weekBasedYear",
",",
"1",
",",
"1",
")",
";",
"// 53 weeks if year starts on Thursday, or Wed in a leap year",
"if",
"(",
"date"... | from IsoFields in ThreeTen-Backport | [
"from",
"IsoFields",
"in",
"ThreeTen",
"-",
"Backport"
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearWeek.java#L193-L200 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/YearWeek.java | YearWeek.with | private YearWeek with(int newYear, int newWeek) {
if (year == newYear && week == newWeek) {
return this;
}
return of(newYear, newWeek);
} | java | private YearWeek with(int newYear, int newWeek) {
if (year == newYear && week == newWeek) {
return this;
}
return of(newYear, newWeek);
} | [
"private",
"YearWeek",
"with",
"(",
"int",
"newYear",
",",
"int",
"newWeek",
")",
"{",
"if",
"(",
"year",
"==",
"newYear",
"&&",
"week",
"==",
"newWeek",
")",
"{",
"return",
"this",
";",
"}",
"return",
"of",
"(",
"newYear",
",",
"newWeek",
")",
";",
... | Returns a copy of this year-week with the new year and week, checking
to see if a new object is in fact required.
@param newYear the year to represent, validated from MIN_YEAR to MAX_YEAR
@param newWeek the week to represent, validated from 1 to 53
@return the year-week, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"year",
"-",
"week",
"with",
"the",
"new",
"year",
"and",
"week",
"checking",
"to",
"see",
"if",
"a",
"new",
"object",
"is",
"in",
"fact",
"required",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/YearWeek.java#L303-L308 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/scale/SystemUtcRules.java | SystemUtcRules.register | void register(long mjDay, int leapAdjustment) {
if (leapAdjustment != -1 && leapAdjustment != 1) {
throw new IllegalArgumentException("Leap adjustment must be -1 or 1");
}
Data data = dataRef.get();
int pos = Arrays.binarySearch(data.dates, mjDay);
int currentAdj = pos > 0 ? data.offsets[pos] - data.offsets[pos - 1] : 0;
if (currentAdj == leapAdjustment) {
return; // matches previous definition
}
if (mjDay <= data.dates[data.dates.length - 1]) {
throw new IllegalArgumentException("Date must be after the last configured leap second date");
}
long[] dates = Arrays.copyOf(data.dates, data.dates.length + 1);
int[] offsets = Arrays.copyOf(data.offsets, data.offsets.length + 1);
long[] taiSeconds = Arrays.copyOf(data.taiSeconds, data.taiSeconds.length + 1);
int offset = offsets[offsets.length - 2] + leapAdjustment;
dates[dates.length - 1] = mjDay;
offsets[offsets.length - 1] = offset;
taiSeconds[taiSeconds.length - 1] = tai(mjDay, offset);
Data newData = new Data(dates, offsets, taiSeconds);
if (dataRef.compareAndSet(data, newData) == false) {
throw new ConcurrentModificationException("Unable to update leap second rules as they have already been updated");
}
} | java | void register(long mjDay, int leapAdjustment) {
if (leapAdjustment != -1 && leapAdjustment != 1) {
throw new IllegalArgumentException("Leap adjustment must be -1 or 1");
}
Data data = dataRef.get();
int pos = Arrays.binarySearch(data.dates, mjDay);
int currentAdj = pos > 0 ? data.offsets[pos] - data.offsets[pos - 1] : 0;
if (currentAdj == leapAdjustment) {
return; // matches previous definition
}
if (mjDay <= data.dates[data.dates.length - 1]) {
throw new IllegalArgumentException("Date must be after the last configured leap second date");
}
long[] dates = Arrays.copyOf(data.dates, data.dates.length + 1);
int[] offsets = Arrays.copyOf(data.offsets, data.offsets.length + 1);
long[] taiSeconds = Arrays.copyOf(data.taiSeconds, data.taiSeconds.length + 1);
int offset = offsets[offsets.length - 2] + leapAdjustment;
dates[dates.length - 1] = mjDay;
offsets[offsets.length - 1] = offset;
taiSeconds[taiSeconds.length - 1] = tai(mjDay, offset);
Data newData = new Data(dates, offsets, taiSeconds);
if (dataRef.compareAndSet(data, newData) == false) {
throw new ConcurrentModificationException("Unable to update leap second rules as they have already been updated");
}
} | [
"void",
"register",
"(",
"long",
"mjDay",
",",
"int",
"leapAdjustment",
")",
"{",
"if",
"(",
"leapAdjustment",
"!=",
"-",
"1",
"&&",
"leapAdjustment",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Leap adjustment must be -1 or 1\"",
")... | Adds a new leap second to these rules.
@param mjDay the Modified Julian Day that the leap second occurs at the end of
@param leapAdjustment the leap seconds to add/remove at the end of the day, either -1 or 1
@throws IllegalArgumentException if the leap adjustment is invalid
@throws IllegalArgumentException if the day is before or equal the last known leap second day
and the definition does not match a previously registered leap
@throws ConcurrentModificationException if another thread updates the rules at the same time | [
"Adds",
"a",
"new",
"leap",
"second",
"to",
"these",
"rules",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L136-L160 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/scale/SystemUtcRules.java | SystemUtcRules.loadLeapSeconds | private static Data loadLeapSeconds() {
Data bestData = null;
URL url = null;
try {
// this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path
Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/" + LEAP_SECONDS_TXT);
while (en.hasMoreElements()) {
url = en.nextElement();
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
// this location does not work on Java 9 module path because the resource is encapsulated
en = Thread.currentThread().getContextClassLoader().getResources(LEAP_SECONDS_TXT);
while (en.hasMoreElements()) {
url = en.nextElement();
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
// this location is the canonical one, and class-based loading works on Java 9 module path
url = SystemUtcRules.class.getResource("/" + LEAP_SECONDS_TXT);
if (url != null) {
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
} catch (Exception ex) {
throw new RuntimeException("Unable to load time-zone rule data: " + url, ex);
}
if (bestData == null) {
// no data on classpath, but we allow manual registration of leap seconds
// setup basic known data - MJD 1972-01-01 is 41317L, where offset was 10
bestData = new Data(new long[] {41317L}, new int[] {10}, new long[] {tai(41317L, 10)});
}
return bestData;
} | java | private static Data loadLeapSeconds() {
Data bestData = null;
URL url = null;
try {
// this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path
Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/" + LEAP_SECONDS_TXT);
while (en.hasMoreElements()) {
url = en.nextElement();
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
// this location does not work on Java 9 module path because the resource is encapsulated
en = Thread.currentThread().getContextClassLoader().getResources(LEAP_SECONDS_TXT);
while (en.hasMoreElements()) {
url = en.nextElement();
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
// this location is the canonical one, and class-based loading works on Java 9 module path
url = SystemUtcRules.class.getResource("/" + LEAP_SECONDS_TXT);
if (url != null) {
Data candidate = loadLeapSeconds(url);
if (bestData == null || candidate.getNewestDate() > bestData.getNewestDate()) {
bestData = candidate;
}
}
} catch (Exception ex) {
throw new RuntimeException("Unable to load time-zone rule data: " + url, ex);
}
if (bestData == null) {
// no data on classpath, but we allow manual registration of leap seconds
// setup basic known data - MJD 1972-01-01 is 41317L, where offset was 10
bestData = new Data(new long[] {41317L}, new int[] {10}, new long[] {tai(41317L, 10)});
}
return bestData;
} | [
"private",
"static",
"Data",
"loadLeapSeconds",
"(",
")",
"{",
"Data",
"bestData",
"=",
"null",
";",
"URL",
"url",
"=",
"null",
";",
"try",
"{",
"// this is the new location of the file, working on Java 8, Java 9 class path and Java 9 module path",
"Enumeration",
"<",
"UR... | Loads the rules from files in the class loader, often jar files.
@return the list of loaded rules, not null
@throws Exception if an error occurs | [
"Loads",
"the",
"rules",
"from",
"files",
"in",
"the",
"class",
"loader",
"often",
"jar",
"files",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L216-L255 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/scale/SystemUtcRules.java | SystemUtcRules.loadLeapSeconds | private static Data loadLeapSeconds(URL url) throws ClassNotFoundException, IOException {
List<String> lines;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
lines = reader.lines().collect(Collectors.toList());
}
List<Long> dates = new ArrayList<>();
List<Integer> offsets = new ArrayList<>();
for (String line : lines) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
Matcher matcher = LEAP_FILE_FORMAT.matcher(line);
if (matcher.matches() == false) {
throw new StreamCorruptedException("Invalid leap second file");
}
dates.add(LocalDate.parse(matcher.group(1)).getLong(JulianFields.MODIFIED_JULIAN_DAY));
offsets.add(Integer.valueOf(matcher.group(2)));
}
long[] datesData = new long[dates.size()];
int[] offsetsData = new int[dates.size()];
long[] taiData = new long[dates.size()];
for (int i = 0; i < datesData.length; i++) {
datesData[i] = dates.get(i);
offsetsData[i] = offsets.get(i);
taiData[i] = tai(datesData[i], offsetsData[i]);
}
return new Data(datesData, offsetsData, taiData);
} | java | private static Data loadLeapSeconds(URL url) throws ClassNotFoundException, IOException {
List<String> lines;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
lines = reader.lines().collect(Collectors.toList());
}
List<Long> dates = new ArrayList<>();
List<Integer> offsets = new ArrayList<>();
for (String line : lines) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
Matcher matcher = LEAP_FILE_FORMAT.matcher(line);
if (matcher.matches() == false) {
throw new StreamCorruptedException("Invalid leap second file");
}
dates.add(LocalDate.parse(matcher.group(1)).getLong(JulianFields.MODIFIED_JULIAN_DAY));
offsets.add(Integer.valueOf(matcher.group(2)));
}
long[] datesData = new long[dates.size()];
int[] offsetsData = new int[dates.size()];
long[] taiData = new long[dates.size()];
for (int i = 0; i < datesData.length; i++) {
datesData[i] = dates.get(i);
offsetsData[i] = offsets.get(i);
taiData[i] = tai(datesData[i], offsetsData[i]);
}
return new Data(datesData, offsetsData, taiData);
} | [
"private",
"static",
"Data",
"loadLeapSeconds",
"(",
"URL",
"url",
")",
"throws",
"ClassNotFoundException",
",",
"IOException",
"{",
"List",
"<",
"String",
">",
"lines",
";",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"In... | Loads the leap second rules from a URL, often in a jar file.
@param url the jar file to load, not null
@throws Exception if an error occurs | [
"Loads",
"the",
"leap",
"second",
"rules",
"from",
"a",
"URL",
"often",
"in",
"a",
"jar",
"file",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/scale/SystemUtcRules.java#L263-L291 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/InternationalFixedDate.java | InternationalFixedDate.create | static InternationalFixedDate create(int prolepticYear, int month, int dayOfMonth) {
YEAR_RANGE.checkValidValue(prolepticYear, ChronoField.YEAR_OF_ERA);
MONTH_OF_YEAR_RANGE.checkValidValue(month, ChronoField.MONTH_OF_YEAR);
DAY_OF_MONTH_RANGE.checkValidValue(dayOfMonth, ChronoField.DAY_OF_MONTH);
if (dayOfMonth == DAYS_IN_LONG_MONTH && month != 6 && month != MONTHS_IN_YEAR) {
throw new DateTimeException("Invalid date: " + prolepticYear + '/' + month + '/' + dayOfMonth);
}
if (month == 6 && dayOfMonth == DAYS_IN_LONG_MONTH && !INSTANCE.isLeapYear(prolepticYear)) {
throw new DateTimeException("Invalid Leap Day as '" + prolepticYear + "' is not a leap year");
}
return new InternationalFixedDate(prolepticYear, month, dayOfMonth);
} | java | static InternationalFixedDate create(int prolepticYear, int month, int dayOfMonth) {
YEAR_RANGE.checkValidValue(prolepticYear, ChronoField.YEAR_OF_ERA);
MONTH_OF_YEAR_RANGE.checkValidValue(month, ChronoField.MONTH_OF_YEAR);
DAY_OF_MONTH_RANGE.checkValidValue(dayOfMonth, ChronoField.DAY_OF_MONTH);
if (dayOfMonth == DAYS_IN_LONG_MONTH && month != 6 && month != MONTHS_IN_YEAR) {
throw new DateTimeException("Invalid date: " + prolepticYear + '/' + month + '/' + dayOfMonth);
}
if (month == 6 && dayOfMonth == DAYS_IN_LONG_MONTH && !INSTANCE.isLeapYear(prolepticYear)) {
throw new DateTimeException("Invalid Leap Day as '" + prolepticYear + "' is not a leap year");
}
return new InternationalFixedDate(prolepticYear, month, dayOfMonth);
} | [
"static",
"InternationalFixedDate",
"create",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"YEAR_RANGE",
".",
"checkValidValue",
"(",
"prolepticYear",
",",
"ChronoField",
".",
"YEAR_OF_ERA",
")",
";",
"MONTH_OF_YEAR_RANGE",
... | Factory method, validates the given triplet year, month and dayOfMonth.
@param prolepticYear the International fixed proleptic-year
@param month the International fixed month, from 1 to 13
@param dayOfMonth the International fixed day-of-month, from 1 to 28 (29 for Leap Day or Year Day)
@return the International fixed date
@throws DateTimeException if the date is invalid | [
"Factory",
"method",
"validates",
"the",
"given",
"triplet",
"year",
"month",
"and",
"dayOfMonth",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedDate.java#L335-L347 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/JulianChronology.java | JulianChronology.date | @Override
public JulianDate date(int prolepticYear, int month, int dayOfMonth) {
return JulianDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public JulianDate date(int prolepticYear, int month, int dayOfMonth) {
return JulianDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"JulianDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"JulianDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Julian calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Julian local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Julian",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L185-L188 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/JulianChronology.java | JulianChronology.dateYearDay | @Override
public JulianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public JulianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"JulianDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Julian calendar system from the
era, year-of-era and day-of-year fields.
@param era the Julian era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Julian local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code JulianEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Julian",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L201-L204 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/JulianChronology.java | JulianChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<JulianDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<JulianDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<JulianDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<JulianDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"JulianDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"JulianDate",
">",
")",
"super",
... | Obtains a Julian local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Julian local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Julian",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L304-L308 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/JulianChronology.java | JulianChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<JulianDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<JulianDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<JulianDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<JulianDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"JulianDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"JulianDate",
">",
")",
"super",
... | Obtains a Julian zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Julian zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Julian",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/JulianChronology.java#L317-L321 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java | Symmetry454Chronology.date | @Override
public Symmetry454Date date(int prolepticYear, int month, int dayOfMonth) {
return Symmetry454Date.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public Symmetry454Date date(int prolepticYear, int month, int dayOfMonth) {
return Symmetry454Date.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"Symmetry454Date",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"Symmetry454Date",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Symmetry454 calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Symmetry454 local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Symmetry454",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L264-L267 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java | Symmetry454Chronology.dateYearDay | @Override
public Symmetry454Date dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public Symmetry454Date dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"Symmetry454Date",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Symmetry454 calendar system from the
era, year-of-era and day-of-year fields.
@param era the Symmetry454 era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Symmetry454 local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code IsoEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Symmetry454",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L280-L283 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java | Symmetry454Chronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<Symmetry454Date> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<Symmetry454Date>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<Symmetry454Date> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<Symmetry454Date>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"Symmetry454Date",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"Symmetry454Date",
">",
")",
... | Obtains a Symmetry454 local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Symmetry454 local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Symmetry454",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L383-L387 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java | Symmetry454Chronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<Symmetry454Date> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<Symmetry454Date>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<Symmetry454Date> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<Symmetry454Date>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"Symmetry454Date",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"Symmetry454Date",
">",
")",
... | Obtains a Symmetry454 zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Symmetry454 zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Symmetry454",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry454Chronology.java#L396-L400 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java | Symmetry010Chronology.date | @Override
public Symmetry010Date date(int prolepticYear, int month, int dayOfMonth) {
return Symmetry010Date.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public Symmetry010Date date(int prolepticYear, int month, int dayOfMonth) {
return Symmetry010Date.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"Symmetry010Date",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"Symmetry010Date",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Symmetry010 calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Symmetry010 local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Symmetry010",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L271-L274 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java | Symmetry010Chronology.dateYearDay | @Override
public Symmetry010Date dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public Symmetry010Date dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"Symmetry010Date",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Symmetry010 calendar system from the
era, year-of-era and day-of-year fields.
@param era the Symmetry010 era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Symmetry010 local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code IsoEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Symmetry010",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L287-L290 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java | Symmetry010Chronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<Symmetry010Date> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<Symmetry010Date>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<Symmetry010Date> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<Symmetry010Date>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"Symmetry010Date",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"Symmetry010Date",
">",
")",
... | Obtains a Symmetry010 local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Symmetry010 local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Symmetry010",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L390-L394 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java | Symmetry010Chronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<Symmetry010Date> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<Symmetry010Date>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<Symmetry010Date> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<Symmetry010Date>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"Symmetry010Date",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"Symmetry010Date",
">",
")",
... | Obtains a Symmetry010 zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Symmetry010 zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Symmetry010",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Chronology.java#L403-L407 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/PaxChronology.java | PaxChronology.date | @Override
public PaxDate date(int prolepticYear, int month, int dayOfMonth) {
return PaxDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public PaxDate date(int prolepticYear, int month, int dayOfMonth) {
return PaxDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"PaxDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"PaxDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Pax calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Pax local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Pax",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L221-L224 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/PaxChronology.java | PaxChronology.dateYearDay | @Override
public PaxDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public PaxDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"PaxDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Pax calendar system from the
era, year-of-era and day-of-year fields.
@param era the Pax era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Pax local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code PaxEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Pax",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L237-L240 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/PaxChronology.java | PaxChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<PaxDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<PaxDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<PaxDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<PaxDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"PaxDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"PaxDate",
">",
")",
"super",
".",... | Obtains a Pax local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Pax local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Pax",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L340-L344 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/PaxChronology.java | PaxChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<PaxDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<PaxDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<PaxDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<PaxDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"PaxDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"PaxDate",
">",
")",
"super",
".",... | Obtains a Pax zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Pax zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Pax",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/PaxChronology.java#L353-L357 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicChronology.java | EthiopicChronology.date | @Override
public EthiopicDate date(Era era, int yearOfEra, int month, int dayOfMonth) {
return date(prolepticYear(era, yearOfEra), month, dayOfMonth);
} | java | @Override
public EthiopicDate date(Era era, int yearOfEra, int month, int dayOfMonth) {
return date(prolepticYear(era, yearOfEra), month, dayOfMonth);
} | [
"@",
"Override",
"public",
"EthiopicDate",
"date",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"date",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"month",
",",
"dayOfMo... | Obtains a local date in Ethiopic calendar system from the
era, year-of-era, month-of-year and day-of-month fields.
@param era the Ethiopic era, not null
@param yearOfEra the year-of-era
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Ethiopic local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code EthiopicEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Ethiopic",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L152-L155 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicChronology.java | EthiopicChronology.date | @Override
public EthiopicDate date(int prolepticYear, int month, int dayOfMonth) {
return EthiopicDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public EthiopicDate date(int prolepticYear, int month, int dayOfMonth) {
return EthiopicDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"EthiopicDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"EthiopicDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Ethiopic calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Ethiopic local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Ethiopic",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L167-L170 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicChronology.java | EthiopicChronology.dateYearDay | @Override
public EthiopicDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public EthiopicDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"EthiopicDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Ethiopic calendar system from the
era, year-of-era and day-of-year fields.
@param era the Ethiopic era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Ethiopic local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code EthiopicEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Ethiopic",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L183-L186 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicChronology.java | EthiopicChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<EthiopicDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<EthiopicDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<EthiopicDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<EthiopicDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"EthiopicDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"EthiopicDate",
">",
")",
"supe... | Obtains a Ethiopic local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Ethiopic local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Ethiopic",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L286-L290 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicChronology.java | EthiopicChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<EthiopicDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<EthiopicDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<EthiopicDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<EthiopicDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"EthiopicDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"EthiopicDate",
">",
")",
"supe... | Obtains a Ethiopic zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Ethiopic zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Ethiopic",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicChronology.java#L299-L303 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/DiscordianChronology.java | DiscordianChronology.date | @Override
public DiscordianDate date(int prolepticYear, int month, int dayOfMonth) {
return DiscordianDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public DiscordianDate date(int prolepticYear, int month, int dayOfMonth) {
return DiscordianDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"DiscordianDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"DiscordianDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"}"
] | Obtains a local date in Discordian calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the Discordian local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"Discordian",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L229-L232 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/DiscordianChronology.java | DiscordianChronology.dateYearDay | @Override
public DiscordianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public DiscordianDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"DiscordianDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"}"
] | Obtains a local date in Discordian calendar system from the
era, year-of-era and day-of-year fields.
@param era the Discordian era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the Discordian local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code DiscordianEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"Discordian",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L245-L248 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/DiscordianChronology.java | DiscordianChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<DiscordianDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<DiscordianDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<DiscordianDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<DiscordianDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"DiscordianDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"DiscordianDate",
">",
")",
"... | Obtains a Discordian local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Discordian local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Discordian",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L348-L352 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/DiscordianChronology.java | DiscordianChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<DiscordianDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<DiscordianDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<DiscordianDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<DiscordianDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"DiscordianDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"DiscordianDate",
">",
")",
"... | Obtains a Discordian zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the Discordian zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"Discordian",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/DiscordianChronology.java#L361-L365 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java | InternationalFixedChronology.date | @Override
public InternationalFixedDate date(int prolepticYear, int month, int dayOfMonth) {
return InternationalFixedDate.of(prolepticYear, month, dayOfMonth);
} | java | @Override
public InternationalFixedDate date(int prolepticYear, int month, int dayOfMonth) {
return InternationalFixedDate.of(prolepticYear, month, dayOfMonth);
} | [
"@",
"Override",
"public",
"InternationalFixedDate",
"date",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"return",
"InternationalFixedDate",
".",
"of",
"(",
"prolepticYear",
",",
"month",
",",
"dayOfMonth",
")",
";",
"... | Obtains a local date in International Fixed calendar system from the
proleptic-year, month-of-year and day-of-month fields.
@param prolepticYear the proleptic-year
@param month the month-of-year
@param dayOfMonth the day-of-month
@return the International Fixed local date, not null
@throws DateTimeException if unable to create the date | [
"Obtains",
"a",
"local",
"date",
"in",
"International",
"Fixed",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"month",
"-",
"of",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"month",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L239-L242 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java | InternationalFixedChronology.dateYearDay | @Override
public InternationalFixedDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | java | @Override
public InternationalFixedDate dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear);
} | [
"@",
"Override",
"public",
"InternationalFixedDate",
"dateYearDay",
"(",
"Era",
"era",
",",
"int",
"yearOfEra",
",",
"int",
"dayOfYear",
")",
"{",
"return",
"dateYearDay",
"(",
"prolepticYear",
"(",
"era",
",",
"yearOfEra",
")",
",",
"dayOfYear",
")",
";",
"... | Obtains a local date in International Fixed calendar system from the
era, year-of-era and day-of-year fields.
@param era the International Fixed era, not null
@param yearOfEra the year-of-era
@param dayOfYear the day-of-year
@return the International Fixed local date, not null
@throws DateTimeException if unable to create the date
@throws ClassCastException if the {@code era} is not a {@code InternationalFixedEra} | [
"Obtains",
"a",
"local",
"date",
"in",
"International",
"Fixed",
"calendar",
"system",
"from",
"the",
"era",
"year",
"-",
"of",
"-",
"era",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L255-L258 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java | InternationalFixedChronology.localDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<InternationalFixedDate>) super.localDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal) {
return (ChronoLocalDateTime<InternationalFixedDate>) super.localDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoLocalDateTime",
"<",
"InternationalFixedDate",
">",
"localDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoLocalDateTime",
"<",
"InternationalFixedDate",
... | Obtains a International Fixed local date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the International Fixed local date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"International",
"Fixed",
"local",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L358-L362 | train |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java | InternationalFixedChronology.zonedDateTime | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<InternationalFixedDate>) super.zonedDateTime(temporal);
} | java | @Override
@SuppressWarnings("unchecked")
public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(TemporalAccessor temporal) {
return (ChronoZonedDateTime<InternationalFixedDate>) super.zonedDateTime(temporal);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ChronoZonedDateTime",
"<",
"InternationalFixedDate",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"return",
"(",
"ChronoZonedDateTime",
"<",
"InternationalFixedDate",
... | Obtains a International Fixed zoned date-time from another date-time object.
@param temporal the date-time object to convert, not null
@return the International Fixed zoned date-time, not null
@throws DateTimeException if unable to create the date-time | [
"Obtains",
"a",
"International",
"Fixed",
"zoned",
"date",
"-",
"time",
"from",
"another",
"date",
"-",
"time",
"object",
"."
] | e94ecd3592ef70e54d6eea21095239ea9ffbab78 | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/InternationalFixedChronology.java#L371-L375 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java | GoogleMap.boundsProperty | public final ReadOnlyObjectProperty<LatLongBounds> boundsProperty() {
if (bounds == null) {
bounds = new ReadOnlyObjectWrapper<>(getBounds());
addStateEventHandler(MapStateEventType.idle, () -> {
bounds.set(getBounds());
});
}
return bounds.getReadOnlyProperty();
} | java | public final ReadOnlyObjectProperty<LatLongBounds> boundsProperty() {
if (bounds == null) {
bounds = new ReadOnlyObjectWrapper<>(getBounds());
addStateEventHandler(MapStateEventType.idle, () -> {
bounds.set(getBounds());
});
}
return bounds.getReadOnlyProperty();
} | [
"public",
"final",
"ReadOnlyObjectProperty",
"<",
"LatLongBounds",
">",
"boundsProperty",
"(",
")",
"{",
"if",
"(",
"bounds",
"==",
"null",
")",
"{",
"bounds",
"=",
"new",
"ReadOnlyObjectWrapper",
"<>",
"(",
"getBounds",
"(",
")",
")",
";",
"addStateEventHandl... | A property tied to the map, updated when the idle state event is fired.
@return | [
"A",
"property",
"tied",
"to",
"the",
"map",
"updated",
"when",
"the",
"idle",
"state",
"event",
"is",
"fired",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L179-L187 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java | GoogleMap.addMarker | public void addMarker(Marker marker) {
if (markers == null) {
markers = new HashSet<>();
}
markers.add(marker);
marker.setMap(this);
} | java | public void addMarker(Marker marker) {
if (markers == null) {
markers = new HashSet<>();
}
markers.add(marker);
marker.setMap(this);
} | [
"public",
"void",
"addMarker",
"(",
"Marker",
"marker",
")",
"{",
"if",
"(",
"markers",
"==",
"null",
")",
"{",
"markers",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"}",
"markers",
".",
"add",
"(",
"marker",
")",
";",
"marker",
".",
"setMap",
"("... | Adds the supplied marker to the map.
@param marker | [
"Adds",
"the",
"supplied",
"marker",
"to",
"the",
"map",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L202-L208 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java | GoogleMap.removeMarker | public void removeMarker(Marker marker) {
if (markers != null && markers.contains(marker)) {
markers.remove(marker);
}
marker.setMap(null);
} | java | public void removeMarker(Marker marker) {
if (markers != null && markers.contains(marker)) {
markers.remove(marker);
}
marker.setMap(null);
} | [
"public",
"void",
"removeMarker",
"(",
"Marker",
"marker",
")",
"{",
"if",
"(",
"markers",
"!=",
"null",
"&&",
"markers",
".",
"contains",
"(",
"marker",
")",
")",
"{",
"markers",
".",
"remove",
"(",
"marker",
")",
";",
"}",
"marker",
".",
"setMap",
... | Removes the supplied marker from the map.
@param marker | [
"Removes",
"the",
"supplied",
"marker",
"from",
"the",
"map",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L215-L220 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java | GoogleMap.clearMarkers | public void clearMarkers() {
if (markers != null && !markers.isEmpty()) {
markers.forEach((m) -> {
m.setMap(null);
});
markers.clear();
} | java | public void clearMarkers() {
if (markers != null && !markers.isEmpty()) {
markers.forEach((m) -> {
m.setMap(null);
});
markers.clear();
} | [
"public",
"void",
"clearMarkers",
"(",
")",
"{",
"if",
"(",
"markers",
"!=",
"null",
"&&",
"!",
"markers",
".",
"isEmpty",
"(",
")",
")",
"{",
"markers",
".",
"forEach",
"(",
"(",
"m",
")",
"-",
">",
"{",
"m",
".",
"setMap",
"(",
"null",
")",
"... | Removes all of the markers from the map. | [
"Removes",
"all",
"of",
"the",
"markers",
"from",
"the",
"map",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/GoogleMap.java#L226-L232 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.setProperty | protected void setProperty(String propertyName, JavascriptObject propertyValue) {
jsObject.setMember(propertyName, propertyValue.getJSObject());
} | java | protected void setProperty(String propertyName, JavascriptObject propertyValue) {
jsObject.setMember(propertyName, propertyValue.getJSObject());
} | [
"protected",
"void",
"setProperty",
"(",
"String",
"propertyName",
",",
"JavascriptObject",
"propertyValue",
")",
"{",
"jsObject",
".",
"setMember",
"(",
"propertyName",
",",
"propertyValue",
".",
"getJSObject",
"(",
")",
")",
";",
"}"
] | Sets a property on this Javascript object for which the value is a
Javascript object itself.
@param propertyName The name of the property.
@param propertyValue The value of the property. | [
"Sets",
"a",
"property",
"on",
"this",
"Javascript",
"object",
"for",
"which",
"the",
"value",
"is",
"a",
"Javascript",
"object",
"itself",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L156-L158 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.setProperty | protected void setProperty(String propertyName, JavascriptEnum propertyValue) {
jsObject.setMember(propertyName, propertyValue.getEnumValue());
} | java | protected void setProperty(String propertyName, JavascriptEnum propertyValue) {
jsObject.setMember(propertyName, propertyValue.getEnumValue());
} | [
"protected",
"void",
"setProperty",
"(",
"String",
"propertyName",
",",
"JavascriptEnum",
"propertyValue",
")",
"{",
"jsObject",
".",
"setMember",
"(",
"propertyName",
",",
"propertyValue",
".",
"getEnumValue",
"(",
")",
")",
";",
"}"
] | Sets a property on this Javascript object for which the value is a
JavascriptEnum
The value is set to what is returned by the getEnumValue() method on the JavascriptEnum
@param propertyName The name of the property.
@param propertyValue The value of the property. | [
"Sets",
"a",
"property",
"on",
"this",
"Javascript",
"object",
"for",
"which",
"the",
"value",
"is",
"a",
"JavascriptEnum"
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L169-L171 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.getProperty | protected <T> T getProperty(String key, Class<T> type) {
Object returnValue = getProperty(key);
if (returnValue != null) {
return (T) returnValue;
} else {
return null;
}
} | java | protected <T> T getProperty(String key, Class<T> type) {
Object returnValue = getProperty(key);
if (returnValue != null) {
return (T) returnValue;
} else {
return null;
}
} | [
"protected",
"<",
"T",
">",
"T",
"getProperty",
"(",
"String",
"key",
",",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"Object",
"returnValue",
"=",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"returnValue",
"!=",
"null",
")",
"{",
"return",
"(",
... | Gets the property and casts to the appropriate type
@param <T>
@param key The property name
@param type The property type
@return The value of the property | [
"Gets",
"the",
"property",
"and",
"casts",
"to",
"the",
"appropriate",
"type"
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L192-L199 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.invokeJavascriptReturnValue | protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) {
Object returnObject = invokeJavascript(function);
if (returnObject instanceof JSObject) {
try {
Constructor<T> constructor = returnType.getConstructor(JSObject.class);
return constructor.newInstance((JSObject) returnObject);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
} else {
return (T) returnObject;
}
} | java | protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) {
Object returnObject = invokeJavascript(function);
if (returnObject instanceof JSObject) {
try {
Constructor<T> constructor = returnType.getConstructor(JSObject.class);
return constructor.newInstance((JSObject) returnObject);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
} else {
return (T) returnObject;
}
} | [
"protected",
"<",
"T",
">",
"T",
"invokeJavascriptReturnValue",
"(",
"String",
"function",
",",
"Class",
"<",
"T",
">",
"returnType",
")",
"{",
"Object",
"returnObject",
"=",
"invokeJavascript",
"(",
"function",
")",
";",
"if",
"(",
"returnObject",
"instanceof... | Invokes a JavaScript function that takes no arguments.
@param <T>
@param function The function to invoke
@param returnType The type of object to return
@return The result of the function. | [
"Invokes",
"a",
"JavaScript",
"function",
"that",
"takes",
"no",
"arguments",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L241-L253 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.checkUndefined | protected Object checkUndefined(Object val) {
if (val instanceof String && ((String) val).equals("undefined")) {
return null;
}
return val;
} | java | protected Object checkUndefined(Object val) {
if (val instanceof String && ((String) val).equals("undefined")) {
return null;
}
return val;
} | [
"protected",
"Object",
"checkUndefined",
"(",
"Object",
"val",
")",
"{",
"if",
"(",
"val",
"instanceof",
"String",
"&&",
"(",
"(",
"String",
")",
"val",
")",
".",
"equals",
"(",
"\"undefined\"",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"val... | JSObject will return the String "undefined" at certain times, so we
need to make sure we're not getting a value that looks valid, but isn't.
@param val The value from Javascript to be checked.
@return Either null or the value passed in. | [
"JSObject",
"will",
"return",
"the",
"String",
"undefined",
"at",
"certain",
"times",
"so",
"we",
"need",
"to",
"make",
"sure",
"we",
"re",
"not",
"getting",
"a",
"value",
"that",
"looks",
"valid",
"but",
"isn",
"t",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L286-L291 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java | JavascriptObject.checkBoolean | protected Boolean checkBoolean(Object val, Boolean def) {
return (val == null) ? def : (Boolean) val;
} | java | protected Boolean checkBoolean(Object val, Boolean def) {
return (val == null) ? def : (Boolean) val;
} | [
"protected",
"Boolean",
"checkBoolean",
"(",
"Object",
"val",
",",
"Boolean",
"def",
")",
"{",
"return",
"(",
"val",
"==",
"null",
")",
"?",
"def",
":",
"(",
"Boolean",
")",
"val",
";",
"}"
] | Checks a returned Javascript value where we expect a boolean but could
get null.
@param val The value from Javascript to be checked.
@param def The default return value, which can be null.
@return The actual value, or if null, returns false. | [
"Checks",
"a",
"returned",
"Javascript",
"value",
"where",
"we",
"expect",
"a",
"boolean",
"but",
"could",
"get",
"null",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptObject.java#L300-L302 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/event/EventHandlers.java | EventHandlers.registerHandler | public String registerHandler(GFXEventHandler handler) {
String uuid = UUID.randomUUID().toString();
handlers.put(uuid, handler);
return uuid;
} | java | public String registerHandler(GFXEventHandler handler) {
String uuid = UUID.randomUUID().toString();
handlers.put(uuid, handler);
return uuid;
} | [
"public",
"String",
"registerHandler",
"(",
"GFXEventHandler",
"handler",
")",
"{",
"String",
"uuid",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"handlers",
".",
"put",
"(",
"uuid",
",",
"handler",
")",
";",
"return",
"uuid... | Registers a handler and returns the callback key to be passed to
Javascript.
@param handler Handler to be registered.
@return A String random UUID that can be used as the callback key. | [
"Registers",
"a",
"handler",
"and",
"returns",
"the",
"callback",
"key",
"to",
"be",
"passed",
"to",
"Javascript",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/event/EventHandlers.java#L79-L83 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/event/EventHandlers.java | EventHandlers.handleStateEvent | public void handleStateEvent(String callbackKey) {
if (handlers.containsKey(callbackKey) && handlers.get(callbackKey) instanceof StateEventHandler) {
((StateEventHandler) handlers.get(callbackKey)).handle();
} else {
System.err.println("Error in handle: " + callbackKey + " for state handler ");
}
} | java | public void handleStateEvent(String callbackKey) {
if (handlers.containsKey(callbackKey) && handlers.get(callbackKey) instanceof StateEventHandler) {
((StateEventHandler) handlers.get(callbackKey)).handle();
} else {
System.err.println("Error in handle: " + callbackKey + " for state handler ");
}
} | [
"public",
"void",
"handleStateEvent",
"(",
"String",
"callbackKey",
")",
"{",
"if",
"(",
"handlers",
".",
"containsKey",
"(",
"callbackKey",
")",
"&&",
"handlers",
".",
"get",
"(",
"callbackKey",
")",
"instanceof",
"StateEventHandler",
")",
"{",
"(",
"(",
"S... | This method is called from Javascript, passing in the previously created
callback key. It uses that to find the correct handler and then passes on
the call. State events in the Google Maps API don't pass any parameters.
@param callbackKey Key generated by the call to registerHandler. | [
"This",
"method",
"is",
"called",
"from",
"Javascript",
"passing",
"in",
"the",
"previously",
"created",
"callback",
"key",
".",
"It",
"uses",
"that",
"to",
"find",
"the",
"correct",
"handler",
"and",
"then",
"passes",
"on",
"the",
"call",
".",
"State",
"e... | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/event/EventHandlers.java#L113-L119 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java | ArcBuilder.buildClosedArc | public static final PolygonOptions buildClosedArc(LatLong center, LatLong start, LatLong end, ArcType arcType) {
MVCArray res = buildArcPoints(center, start, end);
if (ArcType.ROUND.equals(arcType)) {
res.push(center);
}
return new PolygonOptions().paths(res);
} | java | public static final PolygonOptions buildClosedArc(LatLong center, LatLong start, LatLong end, ArcType arcType) {
MVCArray res = buildArcPoints(center, start, end);
if (ArcType.ROUND.equals(arcType)) {
res.push(center);
}
return new PolygonOptions().paths(res);
} | [
"public",
"static",
"final",
"PolygonOptions",
"buildClosedArc",
"(",
"LatLong",
"center",
",",
"LatLong",
"start",
",",
"LatLong",
"end",
",",
"ArcType",
"arcType",
")",
"{",
"MVCArray",
"res",
"=",
"buildArcPoints",
"(",
"center",
",",
"start",
",",
"end",
... | Builds the path for a closed arc, returning a PolygonOptions that can be
further customised before use.
@param center
@param start
@param end
@param arcType Pass in either ArcType.CHORD or ArcType.ROUND
@return PolygonOptions with the paths element populated. | [
"Builds",
"the",
"path",
"for",
"a",
"closed",
"arc",
"returning",
"a",
"PolygonOptions",
"that",
"can",
"be",
"further",
"customised",
"before",
"use",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java#L34-L40 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java | ArcBuilder.buildOpenArc | public static final PolylineOptions buildOpenArc(LatLong center, LatLong start, LatLong end) {
MVCArray res = buildArcPoints(center, start, end);
return new PolylineOptions().path(res);
} | java | public static final PolylineOptions buildOpenArc(LatLong center, LatLong start, LatLong end) {
MVCArray res = buildArcPoints(center, start, end);
return new PolylineOptions().path(res);
} | [
"public",
"static",
"final",
"PolylineOptions",
"buildOpenArc",
"(",
"LatLong",
"center",
",",
"LatLong",
"start",
",",
"LatLong",
"end",
")",
"{",
"MVCArray",
"res",
"=",
"buildArcPoints",
"(",
"center",
",",
"start",
",",
"end",
")",
";",
"return",
"new",
... | Builds the path for an open arc based on a PolylineOptions.
@param center
@param start
@param end
@return PolylineOptions with the paths element populated. | [
"Builds",
"the",
"path",
"for",
"an",
"open",
"arc",
"based",
"on",
"a",
"PolylineOptions",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java#L50-L53 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java | ArcBuilder.buildArcPoints | public static final MVCArray buildArcPoints(LatLong center, double startBearing, double endBearing, double radius) {
int points = DEFAULT_ARC_POINTS;
MVCArray res = new MVCArray();
if (startBearing > endBearing) {
endBearing += 360.0;
}
double deltaBearing = endBearing - startBearing;
deltaBearing = deltaBearing / points;
for (int i = 0; (i < points + 1); i++) {
res.push(center.getDestinationPoint(startBearing + i * deltaBearing, radius));
}
return res;
} | java | public static final MVCArray buildArcPoints(LatLong center, double startBearing, double endBearing, double radius) {
int points = DEFAULT_ARC_POINTS;
MVCArray res = new MVCArray();
if (startBearing > endBearing) {
endBearing += 360.0;
}
double deltaBearing = endBearing - startBearing;
deltaBearing = deltaBearing / points;
for (int i = 0; (i < points + 1); i++) {
res.push(center.getDestinationPoint(startBearing + i * deltaBearing, radius));
}
return res;
} | [
"public",
"static",
"final",
"MVCArray",
"buildArcPoints",
"(",
"LatLong",
"center",
",",
"double",
"startBearing",
",",
"double",
"endBearing",
",",
"double",
"radius",
")",
"{",
"int",
"points",
"=",
"DEFAULT_ARC_POINTS",
";",
"MVCArray",
"res",
"=",
"new",
... | Generates the points for an arc based on two bearings from a centre point
and a radius.
@param center The LatLong point of the center.
@param startBearing North is 0 degrees, East is 90 degrees, etc.
@param endBearing North is 0 degrees, East is 90 degrees, etc.
@param radius In metres
@return An array of LatLong points in an MVC array representing the arc.
Using this method directly you will need to push the centre point onto
the array in order to close it, if desired. | [
"Generates",
"the",
"points",
"for",
"an",
"arc",
"based",
"on",
"two",
"bearings",
"from",
"a",
"centre",
"point",
"and",
"a",
"radius",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/shapes/ArcBuilder.java#L71-L87 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationResult.java | ElevationResult.getLocation | public LatLong getLocation() {
if (location == null) {
location = new LatLong((JSObject) (getJSObject().getMember("location")));
}
return location;
} | java | public LatLong getLocation() {
if (location == null) {
location = new LatLong((JSObject) (getJSObject().getMember("location")));
}
return location;
} | [
"public",
"LatLong",
"getLocation",
"(",
")",
"{",
"if",
"(",
"location",
"==",
"null",
")",
"{",
"location",
"=",
"new",
"LatLong",
"(",
"(",
"JSObject",
")",
"(",
"getJSObject",
"(",
")",
".",
"getMember",
"(",
"\"location\"",
")",
")",
")",
";",
"... | The location for this elevation.
@return | [
"The",
"location",
"for",
"this",
"elevation",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationResult.java#L39-L44 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptRuntime.java | JavascriptRuntime.getArgString | protected String getArgString(Object arg) {
//if (arg instanceof LatLong) {
// return ((LatLong) arg).getVariableName();
//} else
if (arg instanceof JavascriptObject) {
return ((JavascriptObject) arg).getVariableName();
// return ((JavascriptObject) arg).getPropertiesAsString();
} else if( arg instanceof JavascriptEnum ) {
return ((JavascriptEnum) arg).getEnumValue().toString();
} else {
return arg.toString();
}
} | java | protected String getArgString(Object arg) {
//if (arg instanceof LatLong) {
// return ((LatLong) arg).getVariableName();
//} else
if (arg instanceof JavascriptObject) {
return ((JavascriptObject) arg).getVariableName();
// return ((JavascriptObject) arg).getPropertiesAsString();
} else if( arg instanceof JavascriptEnum ) {
return ((JavascriptEnum) arg).getEnumValue().toString();
} else {
return arg.toString();
}
} | [
"protected",
"String",
"getArgString",
"(",
"Object",
"arg",
")",
"{",
"//if (arg instanceof LatLong) {",
"// return ((LatLong) arg).getVariableName();",
"//} else ",
"if",
"(",
"arg",
"instanceof",
"JavascriptObject",
")",
"{",
"return",
"(",
"(",
"JavascriptObject",
... | Takes the specified object and converts the argument to a String.
@param arg The object to convert
@return A String representation of the argument. | [
"Takes",
"the",
"specified",
"object",
"and",
"converts",
"the",
"argument",
"to",
"a",
"String",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptRuntime.java#L181-L193 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/DirectionsPane.java | DirectionsPane.registerEventHandler | private String registerEventHandler(GFXEventHandler h) {
//checkInitialized();
if (!registeredOnJS) {
JSObject doc = (JSObject) runtime.execute("document");
doc.setMember("jsHandlers", jsHandlers);
registeredOnJS = true;
}
return jsHandlers.registerHandler(h);
} | java | private String registerEventHandler(GFXEventHandler h) {
//checkInitialized();
if (!registeredOnJS) {
JSObject doc = (JSObject) runtime.execute("document");
doc.setMember("jsHandlers", jsHandlers);
registeredOnJS = true;
}
return jsHandlers.registerHandler(h);
} | [
"private",
"String",
"registerEventHandler",
"(",
"GFXEventHandler",
"h",
")",
"{",
"//checkInitialized();",
"if",
"(",
"!",
"registeredOnJS",
")",
"{",
"JSObject",
"doc",
"=",
"(",
"JSObject",
")",
"runtime",
".",
"execute",
"(",
"\"document\"",
")",
";",
"do... | Registers an event handler in the repository shared between Javascript
and Java.
@param h Event handler to be registered.
@return Callback key that Javascript will use to find this handler. | [
"Registers",
"an",
"event",
"handler",
"in",
"the",
"repository",
"shared",
"between",
"Javascript",
"and",
"Java",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/DirectionsPane.java#L211-L219 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/DirectionsPane.java | DirectionsPane.addUIEventHandler | public void addUIEventHandler(JavascriptObject obj, UIEventType type, UIEventHandler h) {
String key = registerEventHandler(h);
String mcall = "google.maps.event.addListener(" + obj.getVariableName() + ", '" + type.name() + "', "
+ "function(event) {document.jsHandlers.handleUIEvent('" + key + "', event);});";//.latLng
//System.out.println("addUIEventHandler mcall: " + mcall);
runtime.execute(mcall);
} | java | public void addUIEventHandler(JavascriptObject obj, UIEventType type, UIEventHandler h) {
String key = registerEventHandler(h);
String mcall = "google.maps.event.addListener(" + obj.getVariableName() + ", '" + type.name() + "', "
+ "function(event) {document.jsHandlers.handleUIEvent('" + key + "', event);});";//.latLng
//System.out.println("addUIEventHandler mcall: " + mcall);
runtime.execute(mcall);
} | [
"public",
"void",
"addUIEventHandler",
"(",
"JavascriptObject",
"obj",
",",
"UIEventType",
"type",
",",
"UIEventHandler",
"h",
")",
"{",
"String",
"key",
"=",
"registerEventHandler",
"(",
"h",
")",
";",
"String",
"mcall",
"=",
"\"google.maps.event.addListener(\"",
... | Adds a handler for a mouse type event on the map.
@param obj The object that the event should be registered on.
@param type Type of the event to register against.
@param h Handler that will be called when the event occurs. | [
"Adds",
"a",
"handler",
"for",
"a",
"mouse",
"type",
"event",
"on",
"the",
"map",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/DirectionsPane.java#L238-L244 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java | LatLong.distanceFrom | public double distanceFrom(LatLong end) {
double dLat = (end.getLatitude() - getLatitude()) * Math.PI / 180;
double dLon = (end.getLongitude() - getLongitude()) * Math.PI / 180;
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
+ Math.cos(getLatitude() * Math.PI / 180)
* Math.cos(end.getLatitude() * Math.PI / 180)
* Math.sin(dLon / 2) * Math.sin(dLon / 2);
double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double d = EarthRadiusMeters * c;
return d;
} | java | public double distanceFrom(LatLong end) {
double dLat = (end.getLatitude() - getLatitude()) * Math.PI / 180;
double dLon = (end.getLongitude() - getLongitude()) * Math.PI / 180;
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
+ Math.cos(getLatitude() * Math.PI / 180)
* Math.cos(end.getLatitude() * Math.PI / 180)
* Math.sin(dLon / 2) * Math.sin(dLon / 2);
double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double d = EarthRadiusMeters * c;
return d;
} | [
"public",
"double",
"distanceFrom",
"(",
"LatLong",
"end",
")",
"{",
"double",
"dLat",
"=",
"(",
"end",
".",
"getLatitude",
"(",
")",
"-",
"getLatitude",
"(",
")",
")",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"double",
"dLon",
"=",
"(",
"end",
"."... | From v3_epoly.js, calculates the distance between this LatLong point and
another.
@param end The end point to calculate the distance to.
@return The distance, in metres, to the end point. | [
"From",
"v3_epoly",
".",
"js",
"calculates",
"the",
"distance",
"between",
"this",
"LatLong",
"point",
"and",
"another",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java#L58-L71 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java | LatLong.getDestinationPoint | public LatLong getDestinationPoint(double bearing, double distance) {
double brng = Math.toRadians(bearing);
double lat1 = latToRadians();
double lon1 = longToRadians();
double lat2 = Math.asin(Math.sin(lat1)
* Math.cos(distance / EarthRadiusMeters)
+ Math.cos(lat1) * Math.sin(distance / EarthRadiusMeters)
* Math.cos(brng));
double lon2 = lon1 + Math.atan2(Math.sin(brng)
* Math.sin(distance / EarthRadiusMeters) * Math.cos(lat1),
Math.cos(distance / EarthRadiusMeters)
- Math.sin(lat1) * Math.sin(lat2));
return new LatLong(Math.toDegrees(lat2), Math.toDegrees(lon2));
} | java | public LatLong getDestinationPoint(double bearing, double distance) {
double brng = Math.toRadians(bearing);
double lat1 = latToRadians();
double lon1 = longToRadians();
double lat2 = Math.asin(Math.sin(lat1)
* Math.cos(distance / EarthRadiusMeters)
+ Math.cos(lat1) * Math.sin(distance / EarthRadiusMeters)
* Math.cos(brng));
double lon2 = lon1 + Math.atan2(Math.sin(brng)
* Math.sin(distance / EarthRadiusMeters) * Math.cos(lat1),
Math.cos(distance / EarthRadiusMeters)
- Math.sin(lat1) * Math.sin(lat2));
return new LatLong(Math.toDegrees(lat2), Math.toDegrees(lon2));
} | [
"public",
"LatLong",
"getDestinationPoint",
"(",
"double",
"bearing",
",",
"double",
"distance",
")",
"{",
"double",
"brng",
"=",
"Math",
".",
"toRadians",
"(",
"bearing",
")",
";",
"double",
"lat1",
"=",
"latToRadians",
"(",
")",
";",
"double",
"lon1",
"=... | Calculates the LatLong position of the end point of a line the specified
distance from this LatLong, along the provided bearing, where North is 0,
East is 90 etc.
@param bearing The bearing, in degrees, with North as 0, East as 90 etc.
@param distance The distance in metres.
@return A new LatLong indicating the end point. | [
"Calculates",
"the",
"LatLong",
"position",
"of",
"the",
"end",
"point",
"of",
"a",
"line",
"the",
"specified",
"distance",
"from",
"this",
"LatLong",
"along",
"the",
"provided",
"bearing",
"where",
"North",
"is",
"0",
"East",
"is",
"90",
"etc",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java#L100-L119 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java | LatLong.getBearing | public double getBearing(LatLong end) {
if (this.equals(end)) {
return 0;
}
double lat1 = latToRadians();
double lon1 = longToRadians();
double lat2 = end.latToRadians();
double lon2 = end.longToRadians();
double angle = -Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2),
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
* Math.cos(lat2) * Math.cos(lon1 - lon2));
if (angle < 0.0) {
angle += Math.PI * 2.0;
}
if (angle > Math.PI) {
angle -= Math.PI * 2.0;
}
return Math.toDegrees(angle);
} | java | public double getBearing(LatLong end) {
if (this.equals(end)) {
return 0;
}
double lat1 = latToRadians();
double lon1 = longToRadians();
double lat2 = end.latToRadians();
double lon2 = end.longToRadians();
double angle = -Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2),
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
* Math.cos(lat2) * Math.cos(lon1 - lon2));
if (angle < 0.0) {
angle += Math.PI * 2.0;
}
if (angle > Math.PI) {
angle -= Math.PI * 2.0;
}
return Math.toDegrees(angle);
} | [
"public",
"double",
"getBearing",
"(",
"LatLong",
"end",
")",
"{",
"if",
"(",
"this",
".",
"equals",
"(",
"end",
")",
")",
"{",
"return",
"0",
";",
"}",
"double",
"lat1",
"=",
"latToRadians",
"(",
")",
";",
"double",
"lon1",
"=",
"longToRadians",
"("... | Calculates the bearing, in degrees, of the end LatLong point from this
LatLong point.
@param end The point that the bearing is calculated for.
@return The bearing, in degrees, of the supplied point from this point. | [
"Calculates",
"the",
"bearing",
"in",
"degrees",
"of",
"the",
"end",
"LatLong",
"point",
"from",
"this",
"LatLong",
"point",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/object/LatLong.java#L128-L150 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationService.java | ElevationService.getElevationForLocations | public void getElevationForLocations(LocationElevationRequest req, ElevationServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getElevationForLocations(")
.append(req.getVariableName())
.append(", ")
.append("function(results, status) {alert('rec:'+status);\ndocument.")
.append(getVariableName())
.append(".processResponse(results, status);});");
LOG.trace("ElevationService direct call: " + r.toString());
getJSObject().eval(r.toString());
} | java | public void getElevationForLocations(LocationElevationRequest req, ElevationServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getElevationForLocations(")
.append(req.getVariableName())
.append(", ")
.append("function(results, status) {alert('rec:'+status);\ndocument.")
.append(getVariableName())
.append(".processResponse(results, status);});");
LOG.trace("ElevationService direct call: " + r.toString());
getJSObject().eval(r.toString());
} | [
"public",
"void",
"getElevationForLocations",
"(",
"LocationElevationRequest",
"req",
",",
"ElevationServiceCallback",
"callback",
")",
"{",
"this",
".",
"callback",
"=",
"callback",
";",
"JSObject",
"doc",
"=",
"(",
"JSObject",
")",
"getJSObject",
"(",
")",
".",
... | Create a request for elevations for multiple locations.
@param req
@param callback | [
"Create",
"a",
"request",
"for",
"elevations",
"for",
"multiple",
"locations",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationService.java#L36-L56 | train |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationService.java | ElevationService.getElevationAlongPath | public void getElevationAlongPath(PathElevationRequest req, ElevationServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getElevationAlongPath(")
.append(req.getVariableName())
.append(", ")
.append("function(results, status) {document.")
.append(getVariableName())
.append(".processResponse(results, status);});");
getJSObject().eval(r.toString());
} | java | public void getElevationAlongPath(PathElevationRequest req, ElevationServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getElevationAlongPath(")
.append(req.getVariableName())
.append(", ")
.append("function(results, status) {document.")
.append(getVariableName())
.append(".processResponse(results, status);});");
getJSObject().eval(r.toString());
} | [
"public",
"void",
"getElevationAlongPath",
"(",
"PathElevationRequest",
"req",
",",
"ElevationServiceCallback",
"callback",
")",
"{",
"this",
".",
"callback",
"=",
"callback",
";",
"JSObject",
"doc",
"=",
"(",
"JSObject",
")",
"getJSObject",
"(",
")",
".",
"eval... | Create a request for elevations for samples along a path.
@param req
@param callback | [
"Create",
"a",
"request",
"for",
"elevations",
"for",
"samples",
"along",
"a",
"path",
"."
] | 4623d3f768e8ad78fc50ee32dd204d236e01059f | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/service/elevation/ElevationService.java#L63-L81 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/comparators/GeopositionComparator.java | GeopositionComparator.distance | public static double distance(double lat1, double lon1,
double lat2, double lon2) {
double dLat = Math.toRadians(lat2-lat1);
double dLon = Math.toRadians(lon2-lon1);
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
} | java | public static double distance(double lat1, double lon1,
double lat2, double lon2) {
double dLat = Math.toRadians(lat2-lat1);
double dLon = Math.toRadians(lon2-lon1);
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
} | [
"public",
"static",
"double",
"distance",
"(",
"double",
"lat1",
",",
"double",
"lon1",
",",
"double",
"lat2",
",",
"double",
"lon2",
")",
"{",
"double",
"dLat",
"=",
"Math",
".",
"toRadians",
"(",
"lat2",
"-",
"lat1",
")",
";",
"double",
"dLon",
"=",
... | Returns the distance between the two points in meters. | [
"Returns",
"the",
"distance",
"between",
"the",
"two",
"points",
"in",
"meters",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/comparators/GeopositionComparator.java#L72-L83 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/comparators/SoundexComparator.java | SoundexComparator.soundex | public static String soundex(String str) {
if (str.length() < 1)
return ""; // no soundex key for the empty string (could use 000)
char[] key = new char[4];
key[0] = str.charAt(0);
int pos = 1;
char prev = '0';
for (int ix = 1; ix < str.length() && pos < 4; ix++) {
char ch = str.charAt(ix);
int charno;
if (ch >= 'A' && ch <= 'Z')
charno = ch - 'A';
else if (ch >= 'a' && ch <= 'z')
charno = ch - 'a';
else
continue;
if (number[charno] != '0' && number[charno] != prev)
key[pos++] = number[charno];
prev = number[charno];
}
for ( ; pos < 4; pos++)
key[pos] = '0';
return new String(key);
} | java | public static String soundex(String str) {
if (str.length() < 1)
return ""; // no soundex key for the empty string (could use 000)
char[] key = new char[4];
key[0] = str.charAt(0);
int pos = 1;
char prev = '0';
for (int ix = 1; ix < str.length() && pos < 4; ix++) {
char ch = str.charAt(ix);
int charno;
if (ch >= 'A' && ch <= 'Z')
charno = ch - 'A';
else if (ch >= 'a' && ch <= 'z')
charno = ch - 'a';
else
continue;
if (number[charno] != '0' && number[charno] != prev)
key[pos++] = number[charno];
prev = number[charno];
}
for ( ; pos < 4; pos++)
key[pos] = '0';
return new String(key);
} | [
"public",
"static",
"String",
"soundex",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"<",
"1",
")",
"return",
"\"\"",
";",
"// no soundex key for the empty string (could use 000)",
"char",
"[",
"]",
"key",
"=",
"new",
"char",
... | Produces the Soundex key for the given string. | [
"Produces",
"the",
"Soundex",
"key",
"for",
"the",
"given",
"string",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/comparators/SoundexComparator.java#L33-L60 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/comparators/SoundexComparator.java | SoundexComparator.buildTable | private static char[] buildTable() {
char[] table = new char[26];
for (int ix = 0; ix < table.length; ix++)
table[ix] = '0';
table['B' - 'A'] = '1';
table['P' - 'A'] = '1';
table['F' - 'A'] = '1';
table['V' - 'A'] = '1';
table['C' - 'A'] = '2';
table['S' - 'A'] = '2';
table['K' - 'A'] = '2';
table['G' - 'A'] = '2';
table['J' - 'A'] = '2';
table['Q' - 'A'] = '2';
table['X' - 'A'] = '2';
table['Z' - 'A'] = '2';
table['D' - 'A'] = '3';
table['T' - 'A'] = '3';
table['L' - 'A'] = '4';
table['M' - 'A'] = '5';
table['N' - 'A'] = '5';
table['R' - 'A'] = '6';
return table;
} | java | private static char[] buildTable() {
char[] table = new char[26];
for (int ix = 0; ix < table.length; ix++)
table[ix] = '0';
table['B' - 'A'] = '1';
table['P' - 'A'] = '1';
table['F' - 'A'] = '1';
table['V' - 'A'] = '1';
table['C' - 'A'] = '2';
table['S' - 'A'] = '2';
table['K' - 'A'] = '2';
table['G' - 'A'] = '2';
table['J' - 'A'] = '2';
table['Q' - 'A'] = '2';
table['X' - 'A'] = '2';
table['Z' - 'A'] = '2';
table['D' - 'A'] = '3';
table['T' - 'A'] = '3';
table['L' - 'A'] = '4';
table['M' - 'A'] = '5';
table['N' - 'A'] = '5';
table['R' - 'A'] = '6';
return table;
} | [
"private",
"static",
"char",
"[",
"]",
"buildTable",
"(",
")",
"{",
"char",
"[",
"]",
"table",
"=",
"new",
"char",
"[",
"26",
"]",
";",
"for",
"(",
"int",
"ix",
"=",
"0",
";",
"ix",
"<",
"table",
".",
"length",
";",
"ix",
"++",
")",
"table",
... | Builds the mapping table. | [
"Builds",
"the",
"mapping",
"table",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/comparators/SoundexComparator.java#L65-L88 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/datasources/NTriplesDataSource.java | NTriplesDataSource.addStatement | private void addStatement(RecordImpl record,
String subject,
String property,
String object) {
Collection<Column> cols = columns.get(property);
if (cols == null) {
if (property.equals(RDF_TYPE) && !types.isEmpty())
addValue(record, subject, property, object);
return;
}
for (Column col : cols) {
String cleaned = object;
if (col.getCleaner() != null)
cleaned = col.getCleaner().clean(object);
if (cleaned != null && !cleaned.equals(""))
addValue(record, subject, col.getProperty(), cleaned);
}
} | java | private void addStatement(RecordImpl record,
String subject,
String property,
String object) {
Collection<Column> cols = columns.get(property);
if (cols == null) {
if (property.equals(RDF_TYPE) && !types.isEmpty())
addValue(record, subject, property, object);
return;
}
for (Column col : cols) {
String cleaned = object;
if (col.getCleaner() != null)
cleaned = col.getCleaner().clean(object);
if (cleaned != null && !cleaned.equals(""))
addValue(record, subject, col.getProperty(), cleaned);
}
} | [
"private",
"void",
"addStatement",
"(",
"RecordImpl",
"record",
",",
"String",
"subject",
",",
"String",
"property",
",",
"String",
"object",
")",
"{",
"Collection",
"<",
"Column",
">",
"cols",
"=",
"columns",
".",
"get",
"(",
"property",
")",
";",
"if",
... | common utility method for adding a statement to a record | [
"common",
"utility",
"method",
"for",
"adding",
"a",
"statement",
"to",
"a",
"record"
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/datasources/NTriplesDataSource.java#L89-L107 | train |
larsga/Duke | duke-lucene/src/main/java/no/priv/garshol/duke/databases/GeoProperty.java | GeoProperty.geoSearch | public Filter geoSearch(String value) {
GeopositionComparator comp = (GeopositionComparator) prop.getComparator();
double dist = comp.getMaxDistance();
double degrees = DistanceUtils.dist2Degrees(dist, DistanceUtils.EARTH_MEAN_RADIUS_KM * 1000.0);
Shape circle = spatialctx.makeCircle(parsePoint(value), degrees);
SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
return strategy.makeFilter(args);
} | java | public Filter geoSearch(String value) {
GeopositionComparator comp = (GeopositionComparator) prop.getComparator();
double dist = comp.getMaxDistance();
double degrees = DistanceUtils.dist2Degrees(dist, DistanceUtils.EARTH_MEAN_RADIUS_KM * 1000.0);
Shape circle = spatialctx.makeCircle(parsePoint(value), degrees);
SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
return strategy.makeFilter(args);
} | [
"public",
"Filter",
"geoSearch",
"(",
"String",
"value",
")",
"{",
"GeopositionComparator",
"comp",
"=",
"(",
"GeopositionComparator",
")",
"prop",
".",
"getComparator",
"(",
")",
";",
"double",
"dist",
"=",
"comp",
".",
"getMaxDistance",
"(",
")",
";",
"dou... | Returns a geoquery. | [
"Returns",
"a",
"geoquery",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-lucene/src/main/java/no/priv/garshol/duke/databases/GeoProperty.java#L57-L64 | train |
larsga/Duke | duke-lucene/src/main/java/no/priv/garshol/duke/databases/GeoProperty.java | GeoProperty.parsePoint | private Point parsePoint(String point) {
int comma = point.indexOf(',');
if (comma == -1)
return null;
float lat = Float.valueOf(point.substring(0, comma));
float lng = Float.valueOf(point.substring(comma + 1));
return spatialctx.makePoint(lng, lat);
} | java | private Point parsePoint(String point) {
int comma = point.indexOf(',');
if (comma == -1)
return null;
float lat = Float.valueOf(point.substring(0, comma));
float lng = Float.valueOf(point.substring(comma + 1));
return spatialctx.makePoint(lng, lat);
} | [
"private",
"Point",
"parsePoint",
"(",
"String",
"point",
")",
"{",
"int",
"comma",
"=",
"point",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"comma",
"==",
"-",
"1",
")",
"return",
"null",
";",
"float",
"lat",
"=",
"Float",
".",
"valueOf",... | Parses coordinates into a Spatial4j point shape. | [
"Parses",
"coordinates",
"into",
"a",
"Spatial4j",
"point",
"shape",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-lucene/src/main/java/no/priv/garshol/duke/databases/GeoProperty.java#L69-L77 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.open | public static Statement open(String jndiPath) {
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(jndiPath);
Connection conn = ds.getConnection();
return conn.createStatement();
} catch (NamingException e) {
throw new DukeException("No database configuration found via JNDI at " +
jndiPath, e);
} catch (SQLException e) {
throw new DukeException("Error connecting to database via " +
jndiPath, e);
}
} | java | public static Statement open(String jndiPath) {
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(jndiPath);
Connection conn = ds.getConnection();
return conn.createStatement();
} catch (NamingException e) {
throw new DukeException("No database configuration found via JNDI at " +
jndiPath, e);
} catch (SQLException e) {
throw new DukeException("Error connecting to database via " +
jndiPath, e);
}
} | [
"public",
"static",
"Statement",
"open",
"(",
"String",
"jndiPath",
")",
"{",
"try",
"{",
"Context",
"ctx",
"=",
"new",
"InitialContext",
"(",
")",
";",
"DataSource",
"ds",
"=",
"(",
"DataSource",
")",
"ctx",
".",
"lookup",
"(",
"jndiPath",
")",
";",
"... | Get a configured database connection via JNDI. | [
"Get",
"a",
"configured",
"database",
"connection",
"via",
"JNDI",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L25-L38 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.open | public static Statement open(String driverklass, String jdbcuri,
Properties props) {
try {
Driver driver = (Driver) ObjectUtils.instantiate(driverklass);
Connection conn = driver.connect(jdbcuri, props);
if (conn == null)
throw new DukeException("Couldn't connect to database at " +
jdbcuri);
return conn.createStatement();
} catch (SQLException e) {
throw new DukeException(e);
}
} | java | public static Statement open(String driverklass, String jdbcuri,
Properties props) {
try {
Driver driver = (Driver) ObjectUtils.instantiate(driverklass);
Connection conn = driver.connect(jdbcuri, props);
if (conn == null)
throw new DukeException("Couldn't connect to database at " +
jdbcuri);
return conn.createStatement();
} catch (SQLException e) {
throw new DukeException(e);
}
} | [
"public",
"static",
"Statement",
"open",
"(",
"String",
"driverklass",
",",
"String",
"jdbcuri",
",",
"Properties",
"props",
")",
"{",
"try",
"{",
"Driver",
"driver",
"=",
"(",
"Driver",
")",
"ObjectUtils",
".",
"instantiate",
"(",
"driverklass",
")",
";",
... | Opens a JDBC connection with the given parameters. | [
"Opens",
"a",
"JDBC",
"connection",
"with",
"the",
"given",
"parameters",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L43-L56 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.close | public static void close(Statement stmt) {
try {
Connection conn = stmt.getConnection();
try {
if (!stmt.isClosed())
stmt.close();
} catch (UnsupportedOperationException e) {
// not all JDBC drivers implement the isClosed() method.
// ugly, but probably the only way to get around this.
// http://stackoverflow.com/questions/12845385/duke-fast-deduplication-java-lang-unsupportedoperationexception-operation-not
stmt.close();
}
if (conn != null && !conn.isClosed())
conn.close();
} catch (SQLException e) {
throw new DukeException(e);
}
} | java | public static void close(Statement stmt) {
try {
Connection conn = stmt.getConnection();
try {
if (!stmt.isClosed())
stmt.close();
} catch (UnsupportedOperationException e) {
// not all JDBC drivers implement the isClosed() method.
// ugly, but probably the only way to get around this.
// http://stackoverflow.com/questions/12845385/duke-fast-deduplication-java-lang-unsupportedoperationexception-operation-not
stmt.close();
}
if (conn != null && !conn.isClosed())
conn.close();
} catch (SQLException e) {
throw new DukeException(e);
}
} | [
"public",
"static",
"void",
"close",
"(",
"Statement",
"stmt",
")",
"{",
"try",
"{",
"Connection",
"conn",
"=",
"stmt",
".",
"getConnection",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"stmt",
".",
"isClosed",
"(",
")",
")",
"stmt",
".",
"close",
"... | Closes the JDBC statement and its associated connection. | [
"Closes",
"the",
"JDBC",
"statement",
"and",
"its",
"associated",
"connection",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L61-L78 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.validate | public static boolean validate(Statement stmt) {
try {
Connection conn = stmt.getConnection();
if (conn == null)
return false;
if (!conn.isClosed() && conn.isValid(10))
return true;
stmt.close();
conn.close();
} catch (SQLException e) {
// this may well fail. that doesn't matter. we're just making an
// attempt to clean up, and if we can't, that's just too bad.
}
return false;
} | java | public static boolean validate(Statement stmt) {
try {
Connection conn = stmt.getConnection();
if (conn == null)
return false;
if (!conn.isClosed() && conn.isValid(10))
return true;
stmt.close();
conn.close();
} catch (SQLException e) {
// this may well fail. that doesn't matter. we're just making an
// attempt to clean up, and if we can't, that's just too bad.
}
return false;
} | [
"public",
"static",
"boolean",
"validate",
"(",
"Statement",
"stmt",
")",
"{",
"try",
"{",
"Connection",
"conn",
"=",
"stmt",
".",
"getConnection",
"(",
")",
";",
"if",
"(",
"conn",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"!",
"conn",
"... | Verifies that the connection is still alive. Returns true if it
is, false if it is not. If the connection is broken we try
closing everything, too, so that the caller need only open a new
connection. | [
"Verifies",
"that",
"the",
"connection",
"is",
"still",
"alive",
".",
"Returns",
"true",
"if",
"it",
"is",
"false",
"if",
"it",
"is",
"not",
".",
"If",
"the",
"connection",
"is",
"broken",
"we",
"try",
"closing",
"everything",
"too",
"so",
"that",
"the",... | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L86-L102 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.queryForInt | public static int queryForInt(Statement stmt, String sql, int nullvalue) {
try {
ResultSet rs = stmt.executeQuery(sql);
try {
if (!rs.next())
return nullvalue;
return rs.getInt(1);
} finally {
rs.close();
}
} catch (SQLException e) {
throw new DukeException(e);
}
} | java | public static int queryForInt(Statement stmt, String sql, int nullvalue) {
try {
ResultSet rs = stmt.executeQuery(sql);
try {
if (!rs.next())
return nullvalue;
return rs.getInt(1);
} finally {
rs.close();
}
} catch (SQLException e) {
throw new DukeException(e);
}
} | [
"public",
"static",
"int",
"queryForInt",
"(",
"Statement",
"stmt",
",",
"String",
"sql",
",",
"int",
"nullvalue",
")",
"{",
"try",
"{",
"ResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"sql",
")",
";",
"try",
"{",
"if",
"(",
"!",
"rs",
".",... | Runs a query that returns a single int. | [
"Runs",
"a",
"query",
"that",
"returns",
"a",
"single",
"int",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L107-L121 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java | JDBCUtils.queryHasResult | public static boolean queryHasResult(Statement stmt, String sql) {
try {
ResultSet rs = stmt.executeQuery(sql);
try {
return rs.next();
} finally {
rs.close();
}
} catch (SQLException e) {
throw new DukeException(e);
}
} | java | public static boolean queryHasResult(Statement stmt, String sql) {
try {
ResultSet rs = stmt.executeQuery(sql);
try {
return rs.next();
} finally {
rs.close();
}
} catch (SQLException e) {
throw new DukeException(e);
}
} | [
"public",
"static",
"boolean",
"queryHasResult",
"(",
"Statement",
"stmt",
",",
"String",
"sql",
")",
"{",
"try",
"{",
"ResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"sql",
")",
";",
"try",
"{",
"return",
"rs",
".",
"next",
"(",
")",
";",
... | Returns true if the query result has at least one row. | [
"Returns",
"true",
"if",
"the",
"query",
"result",
"has",
"at",
"least",
"one",
"row",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/JDBCUtils.java#L126-L137 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java | StringUtils.replaceAnyOf | public static String replaceAnyOf(String value, String chars,
char replacement) {
char[] tmp = new char[value.length()];
int pos = 0;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (chars.indexOf(ch) != -1)
tmp[pos++] = replacement;
else
tmp[pos++] = ch;
}
return new String(tmp, 0, tmp.length);
} | java | public static String replaceAnyOf(String value, String chars,
char replacement) {
char[] tmp = new char[value.length()];
int pos = 0;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (chars.indexOf(ch) != -1)
tmp[pos++] = replacement;
else
tmp[pos++] = ch;
}
return new String(tmp, 0, tmp.length);
} | [
"public",
"static",
"String",
"replaceAnyOf",
"(",
"String",
"value",
",",
"String",
"chars",
",",
"char",
"replacement",
")",
"{",
"char",
"[",
"]",
"tmp",
"=",
"new",
"char",
"[",
"value",
".",
"length",
"(",
")",
"]",
";",
"int",
"pos",
"=",
"0",
... | Replaces all characters in the second parameter found in the first
parameter with the final character.
@param value the string to replace characters in
@param chars the characters to replace
@param replacement the character to insert as replacement | [
"Replaces",
"all",
"characters",
"in",
"the",
"second",
"parameter",
"found",
"in",
"the",
"first",
"parameter",
"with",
"the",
"final",
"character",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java#L13-L25 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java | StringUtils.normalizeWS | public static String normalizeWS(String value) {
char[] tmp = new char[value.length()];
int pos = 0;
boolean prevws = false;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
if (prevws && pos != 0)
tmp[pos++] = ' ';
tmp[pos++] = ch;
prevws = false;
} else
prevws = true;
}
return new String(tmp, 0, pos);
} | java | public static String normalizeWS(String value) {
char[] tmp = new char[value.length()];
int pos = 0;
boolean prevws = false;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
if (prevws && pos != 0)
tmp[pos++] = ' ';
tmp[pos++] = ch;
prevws = false;
} else
prevws = true;
}
return new String(tmp, 0, pos);
} | [
"public",
"static",
"String",
"normalizeWS",
"(",
"String",
"value",
")",
"{",
"char",
"[",
"]",
"tmp",
"=",
"new",
"char",
"[",
"value",
".",
"length",
"(",
")",
"]",
";",
"int",
"pos",
"=",
"0",
";",
"boolean",
"prevws",
"=",
"false",
";",
"for",... | Removes trailing and leading whitespace, and also reduces each
sequence of internal whitespace to a single space. | [
"Removes",
"trailing",
"and",
"leading",
"whitespace",
"and",
"also",
"reduces",
"each",
"sequence",
"of",
"internal",
"whitespace",
"to",
"a",
"single",
"space",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java#L31-L47 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/PropertyUtils.java | PropertyUtils.get | public static String get(Properties props, String name, String defval) {
String value = props.getProperty(name);
if (value == null)
value = defval;
return value;
} | java | public static String get(Properties props, String name, String defval) {
String value = props.getProperty(name);
if (value == null)
value = defval;
return value;
} | [
"public",
"static",
"String",
"get",
"(",
"Properties",
"props",
",",
"String",
"name",
",",
"String",
"defval",
")",
"{",
"String",
"value",
"=",
"props",
".",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"value",
"=",
... | Returns the value of an optional property, if the property is
set. If it is not set defval is returned. | [
"Returns",
"the",
"value",
"of",
"an",
"optional",
"property",
"if",
"the",
"property",
"is",
"set",
".",
"If",
"it",
"is",
"not",
"set",
"defval",
"is",
"returned",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/PropertyUtils.java#L28-L33 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/ConfigurationImpl.java | ConfigurationImpl.getDataSources | public Collection<DataSource> getDataSources(int groupno) {
if (groupno == 1)
return group1;
else if (groupno == 2)
return group2;
else
throw new DukeConfigException("Invalid group number: " + groupno);
} | java | public Collection<DataSource> getDataSources(int groupno) {
if (groupno == 1)
return group1;
else if (groupno == 2)
return group2;
else
throw new DukeConfigException("Invalid group number: " + groupno);
} | [
"public",
"Collection",
"<",
"DataSource",
">",
"getDataSources",
"(",
"int",
"groupno",
")",
"{",
"if",
"(",
"groupno",
"==",
"1",
")",
"return",
"group1",
";",
"else",
"if",
"(",
"groupno",
"==",
"2",
")",
"return",
"group2",
";",
"else",
"throw",
"n... | Returns the data sources belonging to a particular group of data
sources. Data sources are grouped in record linkage mode, but not
in deduplication mode, so only use this method in record linkage
mode. | [
"Returns",
"the",
"data",
"sources",
"belonging",
"to",
"a",
"particular",
"group",
"of",
"data",
"sources",
".",
"Data",
"sources",
"are",
"grouped",
"in",
"record",
"linkage",
"mode",
"but",
"not",
"in",
"deduplication",
"mode",
"so",
"only",
"use",
"this"... | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/ConfigurationImpl.java#L59-L66 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/ConfigurationImpl.java | ConfigurationImpl.addDataSource | public void addDataSource(int groupno, DataSource datasource) {
// the loader takes care of validation
if (groupno == 0)
datasources.add(datasource);
else if (groupno == 1)
group1.add(datasource);
else if (groupno == 2)
group2.add(datasource);
} | java | public void addDataSource(int groupno, DataSource datasource) {
// the loader takes care of validation
if (groupno == 0)
datasources.add(datasource);
else if (groupno == 1)
group1.add(datasource);
else if (groupno == 2)
group2.add(datasource);
} | [
"public",
"void",
"addDataSource",
"(",
"int",
"groupno",
",",
"DataSource",
"datasource",
")",
"{",
"// the loader takes care of validation",
"if",
"(",
"groupno",
"==",
"0",
")",
"datasources",
".",
"add",
"(",
"datasource",
")",
";",
"else",
"if",
"(",
"gro... | Adds a data source to the configuration. If in deduplication mode
groupno == 0, otherwise it gives the number of the group to which
the data source belongs. | [
"Adds",
"a",
"data",
"source",
"to",
"the",
"configuration",
".",
"If",
"in",
"deduplication",
"mode",
"groupno",
"==",
"0",
"otherwise",
"it",
"gives",
"the",
"number",
"of",
"the",
"group",
"to",
"which",
"the",
"data",
"source",
"belongs",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/ConfigurationImpl.java#L73-L81 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/PropertyImpl.java | PropertyImpl.compare | public double compare(String v1, String v2) {
// FIXME: it should be possible here to say that, actually, we
// didn't learn anything from comparing these two values, so that
// probability is set to 0.5.
if (comparator == null)
return 0.5; // we ignore properties with no comparator
// first, we call the comparator, to get a measure of how similar
// these two values are. note that this is not the same as what we
// are going to return, which is a probability.
double sim = comparator.compare(v1, v2);
// we have been configured with a high probability (for equal
// values) and a low probability (for different values). given
// sim, which is a measure of the similarity somewhere in between
// equal and different, we now compute our estimate of the
// probability.
// if sim = 1.0, we return high. if sim = 0.0, we return low. for
// values in between we need to compute a little. the obvious
// formula to use would be (sim * (high - low)) + low, which
// spreads the values out equally spaced between high and low.
// however, if the similarity is higher than 0.5 we don't want to
// consider this negative evidence, and so there's a threshold
// there. also, users felt Duke was too eager to merge records,
// and wanted probabilities to fall off faster with lower
// probabilities, and so we square sim in order to achieve this.
if (sim >= 0.5)
return ((high - 0.5) * (sim * sim)) + 0.5;
else
return low;
} | java | public double compare(String v1, String v2) {
// FIXME: it should be possible here to say that, actually, we
// didn't learn anything from comparing these two values, so that
// probability is set to 0.5.
if (comparator == null)
return 0.5; // we ignore properties with no comparator
// first, we call the comparator, to get a measure of how similar
// these two values are. note that this is not the same as what we
// are going to return, which is a probability.
double sim = comparator.compare(v1, v2);
// we have been configured with a high probability (for equal
// values) and a low probability (for different values). given
// sim, which is a measure of the similarity somewhere in between
// equal and different, we now compute our estimate of the
// probability.
// if sim = 1.0, we return high. if sim = 0.0, we return low. for
// values in between we need to compute a little. the obvious
// formula to use would be (sim * (high - low)) + low, which
// spreads the values out equally spaced between high and low.
// however, if the similarity is higher than 0.5 we don't want to
// consider this negative evidence, and so there's a threshold
// there. also, users felt Duke was too eager to merge records,
// and wanted probabilities to fall off faster with lower
// probabilities, and so we square sim in order to achieve this.
if (sim >= 0.5)
return ((high - 0.5) * (sim * sim)) + 0.5;
else
return low;
} | [
"public",
"double",
"compare",
"(",
"String",
"v1",
",",
"String",
"v2",
")",
"{",
"// FIXME: it should be possible here to say that, actually, we",
"// didn't learn anything from comparing these two values, so that",
"// probability is set to 0.5.",
"if",
"(",
"comparator",
"==",
... | Returns the probability that the records v1 and v2 came from
represent the same entity, based on high and low probability
settings etc. | [
"Returns",
"the",
"probability",
"that",
"the",
"records",
"v1",
"and",
"v2",
"came",
"from",
"represent",
"the",
"same",
"entity",
"based",
"on",
"high",
"and",
"low",
"probability",
"settings",
"etc",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/PropertyImpl.java#L121-L155 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/datasources/SparqlDataSource.java | SparqlDataSource.runQuery | public SparqlResult runQuery(String endpoint, String query) {
return SparqlClient.execute(endpoint, query, username, password);
} | java | public SparqlResult runQuery(String endpoint, String query) {
return SparqlClient.execute(endpoint, query, username, password);
} | [
"public",
"SparqlResult",
"runQuery",
"(",
"String",
"endpoint",
",",
"String",
"query",
")",
"{",
"return",
"SparqlClient",
".",
"execute",
"(",
"endpoint",
",",
"query",
",",
"username",
",",
"password",
")",
";",
"}"
] | An extension point so we can control how the query gets executed.
This exists for testing purposes, not because we believe it will
actually be used for real. | [
"An",
"extension",
"point",
"so",
"we",
"can",
"control",
"how",
"the",
"query",
"gets",
"executed",
".",
"This",
"exists",
"for",
"testing",
"purposes",
"not",
"because",
"we",
"believe",
"it",
"will",
"actually",
"be",
"used",
"for",
"real",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/datasources/SparqlDataSource.java#L123-L125 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/InMemoryClassDatabase.java | InMemoryClassDatabase.merge | private void merge(Integer cid1, Integer cid2) {
Collection<String> klass1 = classix.get(cid1);
Collection<String> klass2 = classix.get(cid2);
// if klass1 is the smaller, swap the two
if (klass1.size() < klass2.size()) {
Collection<String> tmp = klass2;
klass2 = klass1;
klass1 = tmp;
Integer itmp = cid2;
cid2 = cid1;
cid1 = itmp;
}
// now perform the actual merge
for (String id : klass2) {
klass1.add(id);
recordix.put(id, cid1);
}
// delete the smaller class, and we're done
classix.remove(cid2);
} | java | private void merge(Integer cid1, Integer cid2) {
Collection<String> klass1 = classix.get(cid1);
Collection<String> klass2 = classix.get(cid2);
// if klass1 is the smaller, swap the two
if (klass1.size() < klass2.size()) {
Collection<String> tmp = klass2;
klass2 = klass1;
klass1 = tmp;
Integer itmp = cid2;
cid2 = cid1;
cid1 = itmp;
}
// now perform the actual merge
for (String id : klass2) {
klass1.add(id);
recordix.put(id, cid1);
}
// delete the smaller class, and we're done
classix.remove(cid2);
} | [
"private",
"void",
"merge",
"(",
"Integer",
"cid1",
",",
"Integer",
"cid2",
")",
"{",
"Collection",
"<",
"String",
">",
"klass1",
"=",
"classix",
".",
"get",
"(",
"cid1",
")",
";",
"Collection",
"<",
"String",
">",
"klass2",
"=",
"classix",
".",
"get",... | Merges the two classes into a single class. The smaller class is
removed, while the largest class is kept. | [
"Merges",
"the",
"two",
"classes",
"into",
"a",
"single",
"class",
".",
"The",
"smaller",
"class",
"is",
"removed",
"while",
"the",
"largest",
"class",
"is",
"kept",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/InMemoryClassDatabase.java#L91-L114 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java | KeyValueDatabase.bumpScores | private void bumpScores(Map<Long, Score> candidates,
List<Bucket> buckets,
int ix) {
for (; ix < buckets.size(); ix++) {
Bucket b = buckets.get(ix);
if (b.nextfree > CUTOFF_FACTOR_2 * candidates.size())
return;
double score = b.getScore();
for (Score s : candidates.values())
if (b.contains(s.id))
s.score += score;
}
} | java | private void bumpScores(Map<Long, Score> candidates,
List<Bucket> buckets,
int ix) {
for (; ix < buckets.size(); ix++) {
Bucket b = buckets.get(ix);
if (b.nextfree > CUTOFF_FACTOR_2 * candidates.size())
return;
double score = b.getScore();
for (Score s : candidates.values())
if (b.contains(s.id))
s.score += score;
}
} | [
"private",
"void",
"bumpScores",
"(",
"Map",
"<",
"Long",
",",
"Score",
">",
"candidates",
",",
"List",
"<",
"Bucket",
">",
"buckets",
",",
"int",
"ix",
")",
"{",
"for",
"(",
";",
"ix",
"<",
"buckets",
".",
"size",
"(",
")",
";",
"ix",
"++",
")",... | Goes through the buckets from ix and out, checking for each
candidate if it's in one of the buckets, and if so, increasing
its score accordingly. No new candidates are added. | [
"Goes",
"through",
"the",
"buckets",
"from",
"ix",
"and",
"out",
"checking",
"for",
"each",
"candidate",
"if",
"it",
"s",
"in",
"one",
"of",
"the",
"buckets",
"and",
"if",
"so",
"increasing",
"its",
"score",
"accordingly",
".",
"No",
"new",
"candidates",
... | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java#L213-L225 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java | KeyValueDatabase.collectCandidates | private int collectCandidates(Map<Long, Score> candidates,
List<Bucket> buckets,
int threshold) {
int ix;
for (ix = 0; ix < threshold &&
candidates.size() < (CUTOFF_FACTOR_1 * max_search_hits); ix++) {
Bucket b = buckets.get(ix);
long[] ids = b.records;
double score = b.getScore();
for (int ix2 = 0; ix2 < b.nextfree; ix2++) {
Score s = candidates.get(ids[ix2]);
if (s == null) {
s = new Score(ids[ix2]);
candidates.put(ids[ix2], s);
}
s.score += score;
}
if (DEBUG)
System.out.println("Bucket " + b.nextfree + " -> " + candidates.size());
}
return ix;
} | java | private int collectCandidates(Map<Long, Score> candidates,
List<Bucket> buckets,
int threshold) {
int ix;
for (ix = 0; ix < threshold &&
candidates.size() < (CUTOFF_FACTOR_1 * max_search_hits); ix++) {
Bucket b = buckets.get(ix);
long[] ids = b.records;
double score = b.getScore();
for (int ix2 = 0; ix2 < b.nextfree; ix2++) {
Score s = candidates.get(ids[ix2]);
if (s == null) {
s = new Score(ids[ix2]);
candidates.put(ids[ix2], s);
}
s.score += score;
}
if (DEBUG)
System.out.println("Bucket " + b.nextfree + " -> " + candidates.size());
}
return ix;
} | [
"private",
"int",
"collectCandidates",
"(",
"Map",
"<",
"Long",
",",
"Score",
">",
"candidates",
",",
"List",
"<",
"Bucket",
">",
"buckets",
",",
"int",
"threshold",
")",
"{",
"int",
"ix",
";",
"for",
"(",
"ix",
"=",
"0",
";",
"ix",
"<",
"threshold",... | Goes through the first buckets, picking out candidate records and
tallying up their scores.
@return the index of the first bucket we did not process | [
"Goes",
"through",
"the",
"first",
"buckets",
"picking",
"out",
"candidate",
"records",
"and",
"tallying",
"up",
"their",
"scores",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java#L232-L254 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java | KeyValueDatabase.lookup | private List<Bucket> lookup(Record record) {
List<Bucket> buckets = new ArrayList();
for (Property p : config.getLookupProperties()) {
String propname = p.getName();
Collection<String> values = record.getValues(propname);
if (values == null)
continue;
for (String value : values) {
String[] tokens = StringUtils.split(value);
for (int ix = 0; ix < tokens.length; ix++) {
Bucket b = store.lookupToken(propname, tokens[ix]);
if (b == null || b.records == null)
continue;
long[] ids = b.records;
if (DEBUG)
System.out.println(propname + ", " + tokens[ix] + ": " + b.nextfree + " (" + b.getScore() + ")");
buckets.add(b);
}
}
}
return buckets;
} | java | private List<Bucket> lookup(Record record) {
List<Bucket> buckets = new ArrayList();
for (Property p : config.getLookupProperties()) {
String propname = p.getName();
Collection<String> values = record.getValues(propname);
if (values == null)
continue;
for (String value : values) {
String[] tokens = StringUtils.split(value);
for (int ix = 0; ix < tokens.length; ix++) {
Bucket b = store.lookupToken(propname, tokens[ix]);
if (b == null || b.records == null)
continue;
long[] ids = b.records;
if (DEBUG)
System.out.println(propname + ", " + tokens[ix] + ": " + b.nextfree + " (" + b.getScore() + ")");
buckets.add(b);
}
}
}
return buckets;
} | [
"private",
"List",
"<",
"Bucket",
">",
"lookup",
"(",
"Record",
"record",
")",
"{",
"List",
"<",
"Bucket",
">",
"buckets",
"=",
"new",
"ArrayList",
"(",
")",
";",
"for",
"(",
"Property",
"p",
":",
"config",
".",
"getLookupProperties",
"(",
")",
")",
... | Tokenizes lookup fields and returns all matching buckets in the
index. | [
"Tokenizes",
"lookup",
"fields",
"and",
"returns",
"all",
"matching",
"buckets",
"in",
"the",
"index",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/databases/KeyValueDatabase.java#L260-L283 | train |
larsga/Duke | duke-server/src/main/java/no/priv/garshol/duke/server/CommonJTimer.java | CommonJTimer.spawnThread | public void spawnThread(DukeController controller, int check_interval) {
this.controller = controller;
timer = mgr.schedule(this, 0, check_interval * 1000); // convert to ms
} | java | public void spawnThread(DukeController controller, int check_interval) {
this.controller = controller;
timer = mgr.schedule(this, 0, check_interval * 1000); // convert to ms
} | [
"public",
"void",
"spawnThread",
"(",
"DukeController",
"controller",
",",
"int",
"check_interval",
")",
"{",
"this",
".",
"controller",
"=",
"controller",
";",
"timer",
"=",
"mgr",
".",
"schedule",
"(",
"this",
",",
"0",
",",
"check_interval",
"*",
"1000",
... | Starts a background thread which calls the controller every
check_interval milliseconds. Returns immediately, leaving the
background thread running. | [
"Starts",
"a",
"background",
"thread",
"which",
"calls",
"the",
"controller",
"every",
"check_interval",
"milliseconds",
".",
"Returns",
"immediately",
"leaving",
"the",
"background",
"thread",
"running",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-server/src/main/java/no/priv/garshol/duke/server/CommonJTimer.java#L45-L48 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/AbstractCmdlineTool.java | AbstractCmdlineTool.init | public String[] init(String[] argv, int min, int max,
Collection<CommandLineParser.Option> options)
throws IOException, SAXException {
// parse command line
parser = new CommandLineParser();
parser.setMinimumArguments(min);
parser.setMaximumArguments(max);
parser.registerOption(new CommandLineParser.BooleanOption("reindex", 'I'));
if (options != null)
for (CommandLineParser.Option option : options)
parser.registerOption(option);
try {
argv = parser.parse(argv);
} catch (CommandLineParser.CommandLineParserException e) {
System.err.println("ERROR: " + e.getMessage());
usage();
System.exit(1);
}
// do we need to reindex?
boolean reindex = parser.getOptionState("reindex");
// load configuration
config = ConfigLoader.load(argv[0]);
database = config.getDatabase(reindex); // overwrite iff reindex
if (database.isInMemory())
reindex = true; // no other way to do it in this case
// reindex, if requested
if (reindex)
reindex(config, database);
return argv;
} | java | public String[] init(String[] argv, int min, int max,
Collection<CommandLineParser.Option> options)
throws IOException, SAXException {
// parse command line
parser = new CommandLineParser();
parser.setMinimumArguments(min);
parser.setMaximumArguments(max);
parser.registerOption(new CommandLineParser.BooleanOption("reindex", 'I'));
if (options != null)
for (CommandLineParser.Option option : options)
parser.registerOption(option);
try {
argv = parser.parse(argv);
} catch (CommandLineParser.CommandLineParserException e) {
System.err.println("ERROR: " + e.getMessage());
usage();
System.exit(1);
}
// do we need to reindex?
boolean reindex = parser.getOptionState("reindex");
// load configuration
config = ConfigLoader.load(argv[0]);
database = config.getDatabase(reindex); // overwrite iff reindex
if (database.isInMemory())
reindex = true; // no other way to do it in this case
// reindex, if requested
if (reindex)
reindex(config, database);
return argv;
} | [
"public",
"String",
"[",
"]",
"init",
"(",
"String",
"[",
"]",
"argv",
",",
"int",
"min",
",",
"int",
"max",
",",
"Collection",
"<",
"CommandLineParser",
".",
"Option",
">",
"options",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"// parse comma... | These exact lines are shared between three different tools, so
they have been moved here to reduce code duplication.
@return The parsed command-line, with options removed. | [
"These",
"exact",
"lines",
"are",
"shared",
"between",
"three",
"different",
"tools",
"so",
"they",
"have",
"been",
"moved",
"here",
"to",
"reduce",
"code",
"duplication",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/AbstractCmdlineTool.java#L26-L60 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/Utils.java | Utils.createTempDirectory | public static File createTempDirectory(String prefix) {
File temp = null;
try {
temp = File.createTempFile(prefix != null ? prefix : "temp", Long.toString(System.nanoTime()));
if (!(temp.delete())) {
throw new IOException("Could not delete temp file: "
+ temp.getAbsolutePath());
}
if (!(temp.mkdir())) {
throw new IOException("Could not create temp directory: "
+ temp.getAbsolutePath());
}
} catch (IOException e) {
throw new DukeException("Unable to create temporary directory with prefix " + prefix, e);
}
return temp;
} | java | public static File createTempDirectory(String prefix) {
File temp = null;
try {
temp = File.createTempFile(prefix != null ? prefix : "temp", Long.toString(System.nanoTime()));
if (!(temp.delete())) {
throw new IOException("Could not delete temp file: "
+ temp.getAbsolutePath());
}
if (!(temp.mkdir())) {
throw new IOException("Could not create temp directory: "
+ temp.getAbsolutePath());
}
} catch (IOException e) {
throw new DukeException("Unable to create temporary directory with prefix " + prefix, e);
}
return temp;
} | [
"public",
"static",
"File",
"createTempDirectory",
"(",
"String",
"prefix",
")",
"{",
"File",
"temp",
"=",
"null",
";",
"try",
"{",
"temp",
"=",
"File",
".",
"createTempFile",
"(",
"prefix",
"!=",
"null",
"?",
"prefix",
":",
"\"temp\"",
",",
"Long",
".",... | Creates a temporary folder using the given prefix to generate its name.
@param prefix the prefix string to be used in generating the directory's name; may be <i>null</i>
@return the <code>File</code> to the newly created folder
@throws IOException | [
"Creates",
"a",
"temporary",
"folder",
"using",
"the",
"given",
"prefix",
"to",
"generate",
"its",
"name",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/Utils.java#L36-L56 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/ConfigLoader.java | ConfigLoader.loadFromString | public static Configuration loadFromString(String config)
throws IOException, SAXException {
ConfigurationImpl cfg = new ConfigurationImpl();
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(new ConfigHandler(cfg, null));
Reader reader = new StringReader(config);
parser.parse(new InputSource(reader));
return cfg;
} | java | public static Configuration loadFromString(String config)
throws IOException, SAXException {
ConfigurationImpl cfg = new ConfigurationImpl();
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(new ConfigHandler(cfg, null));
Reader reader = new StringReader(config);
parser.parse(new InputSource(reader));
return cfg;
} | [
"public",
"static",
"Configuration",
"loadFromString",
"(",
"String",
"config",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"ConfigurationImpl",
"cfg",
"=",
"new",
"ConfigurationImpl",
"(",
")",
";",
"XMLReader",
"parser",
"=",
"XMLReaderFactory",
".",
... | Loads the configuration XML from the given string.
@since 1.3 | [
"Loads",
"the",
"configuration",
"XML",
"from",
"the",
"given",
"string",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/ConfigLoader.java#L58-L67 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/matchers/LinkDatabaseMatchListener.java | LinkDatabaseMatchListener.endRecord_ | public void endRecord_() {
// this is where we actually update the link database. basically,
// all we need to do is to retract those links which weren't seen
// this time around, and that can be done via assertLink, since it
// can override existing links.
// get all the existing links
Collection<Link> oldlinks = linkdb.getAllLinksFor(getIdentity(current));
// build a hashmap so we can look up corresponding old links from
// new links
if (oldlinks != null) {
Map<String, Link> oldmap = new HashMap(oldlinks.size());
for (Link l : oldlinks)
oldmap.put(makeKey(l), l);
// removing all the links we found this time around from the set of
// old links. any links remaining after this will be stale, and need
// to be retracted
for (Link newl : new ArrayList<Link>(curlinks)) {
String key = makeKey(newl);
Link oldl = oldmap.get(key);
if (oldl == null)
continue;
if (oldl.overrides(newl))
// previous information overrides this link, so ignore
curlinks.remove(newl);
else if (sameAs(oldl, newl)) {
// there's no new information here, so just ignore this
curlinks.remove(newl);
oldmap.remove(key); // we don't want to retract the old one
} else
// the link is out of date, but will be overwritten, so remove
oldmap.remove(key);
}
// all the inferred links left in oldmap are now old links we
// didn't find on this pass. there is no longer any evidence
// supporting them, and so we can retract them.
for (Link oldl : oldmap.values())
if (oldl.getStatus() == LinkStatus.INFERRED) {
oldl.retract(); // changes to retracted, updates timestamp
curlinks.add(oldl);
}
}
// okay, now we write it all to the database
for (Link l : curlinks)
linkdb.assertLink(l);
} | java | public void endRecord_() {
// this is where we actually update the link database. basically,
// all we need to do is to retract those links which weren't seen
// this time around, and that can be done via assertLink, since it
// can override existing links.
// get all the existing links
Collection<Link> oldlinks = linkdb.getAllLinksFor(getIdentity(current));
// build a hashmap so we can look up corresponding old links from
// new links
if (oldlinks != null) {
Map<String, Link> oldmap = new HashMap(oldlinks.size());
for (Link l : oldlinks)
oldmap.put(makeKey(l), l);
// removing all the links we found this time around from the set of
// old links. any links remaining after this will be stale, and need
// to be retracted
for (Link newl : new ArrayList<Link>(curlinks)) {
String key = makeKey(newl);
Link oldl = oldmap.get(key);
if (oldl == null)
continue;
if (oldl.overrides(newl))
// previous information overrides this link, so ignore
curlinks.remove(newl);
else if (sameAs(oldl, newl)) {
// there's no new information here, so just ignore this
curlinks.remove(newl);
oldmap.remove(key); // we don't want to retract the old one
} else
// the link is out of date, but will be overwritten, so remove
oldmap.remove(key);
}
// all the inferred links left in oldmap are now old links we
// didn't find on this pass. there is no longer any evidence
// supporting them, and so we can retract them.
for (Link oldl : oldmap.values())
if (oldl.getStatus() == LinkStatus.INFERRED) {
oldl.retract(); // changes to retracted, updates timestamp
curlinks.add(oldl);
}
}
// okay, now we write it all to the database
for (Link l : curlinks)
linkdb.assertLink(l);
} | [
"public",
"void",
"endRecord_",
"(",
")",
"{",
"// this is where we actually update the link database. basically,",
"// all we need to do is to retract those links which weren't seen",
"// this time around, and that can be done via assertLink, since it",
"// can override existing links.",
"// ge... | this method is called from the event methods | [
"this",
"method",
"is",
"called",
"from",
"the",
"event",
"methods"
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/matchers/LinkDatabaseMatchListener.java#L87-L137 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/ConfigWriter.java | ConfigWriter.write | public void write(Configuration config)
throws IOException {
pp.startDocument();
pp.startElement("duke", null);
// FIXME: here we should write the objects, but that's not
// possible with the current API. we don't need that for the
// genetic algorithm at the moment, but it would be useful.
pp.startElement("schema", null);
writeElement("threshold", "" + config.getThreshold());
if (config.getMaybeThreshold() != 0.0)
writeElement("maybe-threshold", "" + config.getMaybeThreshold());
for (Property p : config.getProperties())
writeProperty(p);
pp.endElement("schema");
String dbclass = config.getDatabase(false).getClass().getName();
AttributeListImpl atts = new AttributeListImpl();
atts.addAttribute("class", "CDATA", dbclass);
pp.startElement("database", atts);
pp.endElement("database");
if (config.isDeduplicationMode())
for (DataSource src : config.getDataSources())
writeDataSource(src);
else {
pp.startElement("group", null);
for (DataSource src : config.getDataSources(1))
writeDataSource(src);
pp.endElement("group");
pp.startElement("group", null);
for (DataSource src : config.getDataSources(2))
writeDataSource(src);
pp.endElement("group");
}
pp.endElement("duke");
pp.endDocument();
} | java | public void write(Configuration config)
throws IOException {
pp.startDocument();
pp.startElement("duke", null);
// FIXME: here we should write the objects, but that's not
// possible with the current API. we don't need that for the
// genetic algorithm at the moment, but it would be useful.
pp.startElement("schema", null);
writeElement("threshold", "" + config.getThreshold());
if (config.getMaybeThreshold() != 0.0)
writeElement("maybe-threshold", "" + config.getMaybeThreshold());
for (Property p : config.getProperties())
writeProperty(p);
pp.endElement("schema");
String dbclass = config.getDatabase(false).getClass().getName();
AttributeListImpl atts = new AttributeListImpl();
atts.addAttribute("class", "CDATA", dbclass);
pp.startElement("database", atts);
pp.endElement("database");
if (config.isDeduplicationMode())
for (DataSource src : config.getDataSources())
writeDataSource(src);
else {
pp.startElement("group", null);
for (DataSource src : config.getDataSources(1))
writeDataSource(src);
pp.endElement("group");
pp.startElement("group", null);
for (DataSource src : config.getDataSources(2))
writeDataSource(src);
pp.endElement("group");
}
pp.endElement("duke");
pp.endDocument();
} | [
"public",
"void",
"write",
"(",
"Configuration",
"config",
")",
"throws",
"IOException",
"{",
"pp",
".",
"startDocument",
"(",
")",
";",
"pp",
".",
"startElement",
"(",
"\"duke\"",
",",
"null",
")",
";",
"// FIXME: here we should write the objects, but that's not",
... | Writes the given configuration to the given file. | [
"Writes",
"the",
"given",
"configuration",
"to",
"the",
"given",
"file",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/ConfigWriter.java#L28-L72 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/NTriplesParser.java | NTriplesParser.parse | public static void parse(Reader src, StatementHandler handler)
throws IOException {
new NTriplesParser(src, handler).parse();
} | java | public static void parse(Reader src, StatementHandler handler)
throws IOException {
new NTriplesParser(src, handler).parse();
} | [
"public",
"static",
"void",
"parse",
"(",
"Reader",
"src",
",",
"StatementHandler",
"handler",
")",
"throws",
"IOException",
"{",
"new",
"NTriplesParser",
"(",
"src",
",",
"handler",
")",
".",
"parse",
"(",
")",
";",
"}"
] | Reads the NTriples file from the reader, pushing statements into
the handler. | [
"Reads",
"the",
"NTriples",
"file",
"from",
"the",
"reader",
"pushing",
"statements",
"into",
"the",
"handler",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/NTriplesParser.java#L25-L28 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/comparators/Levenshtein.java | Levenshtein.distance | public static int distance(String s1, String s2) {
if (s1.length() == 0)
return s2.length();
if (s2.length() == 0)
return s1.length();
int s1len = s1.length();
// we use a flat array for better performance. we address it by
// s1ix + s1len * s2ix. this modification improves performance
// by about 30%, which is definitely worth the extra complexity.
int[] matrix = new int[(s1len + 1) * (s2.length() + 1)];
for (int col = 0; col <= s2.length(); col++)
matrix[col * s1len] = col;
for (int row = 0; row <= s1len; row++)
matrix[row] = row;
for (int ix1 = 0; ix1 < s1len; ix1++) {
char ch1 = s1.charAt(ix1);
for (int ix2 = 0; ix2 < s2.length(); ix2++) {
int cost;
if (ch1 == s2.charAt(ix2))
cost = 0;
else
cost = 1;
int left = matrix[ix1 + ((ix2 + 1) * s1len)] + 1;
int above = matrix[ix1 + 1 + (ix2 * s1len)] + 1;
int aboveleft = matrix[ix1 + (ix2 * s1len)] + cost;
matrix[ix1 + 1 + ((ix2 + 1) * s1len)] =
Math.min(left, Math.min(above, aboveleft));
}
}
// for (int ix1 = 0; ix1 <= s1len; ix1++) {
// for (int ix2 = 0; ix2 <= s2.length(); ix2++) {
// System.out.print(matrix[ix1 + (ix2 * s1len)] + " ");
// }
// System.out.println();
// }
return matrix[s1len + (s2.length() * s1len)];
} | java | public static int distance(String s1, String s2) {
if (s1.length() == 0)
return s2.length();
if (s2.length() == 0)
return s1.length();
int s1len = s1.length();
// we use a flat array for better performance. we address it by
// s1ix + s1len * s2ix. this modification improves performance
// by about 30%, which is definitely worth the extra complexity.
int[] matrix = new int[(s1len + 1) * (s2.length() + 1)];
for (int col = 0; col <= s2.length(); col++)
matrix[col * s1len] = col;
for (int row = 0; row <= s1len; row++)
matrix[row] = row;
for (int ix1 = 0; ix1 < s1len; ix1++) {
char ch1 = s1.charAt(ix1);
for (int ix2 = 0; ix2 < s2.length(); ix2++) {
int cost;
if (ch1 == s2.charAt(ix2))
cost = 0;
else
cost = 1;
int left = matrix[ix1 + ((ix2 + 1) * s1len)] + 1;
int above = matrix[ix1 + 1 + (ix2 * s1len)] + 1;
int aboveleft = matrix[ix1 + (ix2 * s1len)] + cost;
matrix[ix1 + 1 + ((ix2 + 1) * s1len)] =
Math.min(left, Math.min(above, aboveleft));
}
}
// for (int ix1 = 0; ix1 <= s1len; ix1++) {
// for (int ix2 = 0; ix2 <= s2.length(); ix2++) {
// System.out.print(matrix[ix1 + (ix2 * s1len)] + " ");
// }
// System.out.println();
// }
return matrix[s1len + (s2.length() * s1len)];
} | [
"public",
"static",
"int",
"distance",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"s1",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"s2",
".",
"length",
"(",
")",
";",
"if",
"(",
"s2",
".",
"length",
"(",
")",
"==",
... | This is the original, naive implementation, using the Wagner &
Fischer algorithm from 1974. It uses a flattened matrix for
speed, but still computes the entire matrix. | [
"This",
"is",
"the",
"original",
"naive",
"implementation",
"using",
"the",
"Wagner",
"&",
"Fischer",
"algorithm",
"from",
"1974",
".",
"It",
"uses",
"a",
"flattened",
"matrix",
"for",
"speed",
"but",
"still",
"computes",
"the",
"entire",
"matrix",
"."
] | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/comparators/Levenshtein.java#L53-L94 | train |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/comparators/Levenshtein.java | Levenshtein.compactDistance | public static int compactDistance(String s1, String s2) {
if (s1.length() == 0)
return s2.length();
if (s2.length() == 0)
return s1.length();
// the maximum edit distance there is any point in reporting.
int maxdist = Math.min(s1.length(), s2.length()) / 2;
// we allocate just one column instead of the entire matrix, in
// order to save space. this also enables us to implement the
// algorithm somewhat faster. the first cell is always the
// virtual first row.
int s1len = s1.length();
int[] column = new int[s1len + 1];
// first we need to fill in the initial column. we use a separate
// loop for this, because in this case our basis for comparison is
// not the previous column, but a virtual first column.
int ix2 = 0;
char ch2 = s2.charAt(ix2);
column[0] = 1; // virtual first row
for (int ix1 = 1; ix1 <= s1len; ix1++) {
int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
// Lowest of three: above (column[ix1 - 1]), aboveleft: ix1 - 1,
// left: ix1. Latter cannot possibly be lowest, so is
// ignored.
column[ix1] = Math.min(column[ix1 - 1], ix1 - 1) + cost;
}
// okay, now we have an initialized first column, and we can
// compute the rest of the matrix.
int above = 0;
for (ix2 = 1; ix2 < s2.length(); ix2++) {
ch2 = s2.charAt(ix2);
above = ix2 + 1; // virtual first row
int smallest = s1len * 2; // used to implement cutoff
for (int ix1 = 1; ix1 <= s1len; ix1++) {
int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
// above: above
// aboveleft: column[ix1 - 1]
// left: column[ix1]
int value = Math.min(Math.min(above, column[ix1 - 1]), column[ix1]) +
cost;
column[ix1 - 1] = above; // write previous
above = value; // keep current
smallest = Math.min(smallest, value);
}
column[s1len] = above;
// check if we can stop because we'll be going over the max distance
if (smallest > maxdist)
return smallest;
}
// ok, we're done
return above;
} | java | public static int compactDistance(String s1, String s2) {
if (s1.length() == 0)
return s2.length();
if (s2.length() == 0)
return s1.length();
// the maximum edit distance there is any point in reporting.
int maxdist = Math.min(s1.length(), s2.length()) / 2;
// we allocate just one column instead of the entire matrix, in
// order to save space. this also enables us to implement the
// algorithm somewhat faster. the first cell is always the
// virtual first row.
int s1len = s1.length();
int[] column = new int[s1len + 1];
// first we need to fill in the initial column. we use a separate
// loop for this, because in this case our basis for comparison is
// not the previous column, but a virtual first column.
int ix2 = 0;
char ch2 = s2.charAt(ix2);
column[0] = 1; // virtual first row
for (int ix1 = 1; ix1 <= s1len; ix1++) {
int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
// Lowest of three: above (column[ix1 - 1]), aboveleft: ix1 - 1,
// left: ix1. Latter cannot possibly be lowest, so is
// ignored.
column[ix1] = Math.min(column[ix1 - 1], ix1 - 1) + cost;
}
// okay, now we have an initialized first column, and we can
// compute the rest of the matrix.
int above = 0;
for (ix2 = 1; ix2 < s2.length(); ix2++) {
ch2 = s2.charAt(ix2);
above = ix2 + 1; // virtual first row
int smallest = s1len * 2; // used to implement cutoff
for (int ix1 = 1; ix1 <= s1len; ix1++) {
int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
// above: above
// aboveleft: column[ix1 - 1]
// left: column[ix1]
int value = Math.min(Math.min(above, column[ix1 - 1]), column[ix1]) +
cost;
column[ix1 - 1] = above; // write previous
above = value; // keep current
smallest = Math.min(smallest, value);
}
column[s1len] = above;
// check if we can stop because we'll be going over the max distance
if (smallest > maxdist)
return smallest;
}
// ok, we're done
return above;
} | [
"public",
"static",
"int",
"compactDistance",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"s1",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"s2",
".",
"length",
"(",
")",
";",
"if",
"(",
"s2",
".",
"length",
"(",
")",
... | Optimized version of the Wagner & Fischer algorithm that only
keeps a single column in the matrix in memory at a time. It
implements the simple cutoff, but otherwise computes the entire
matrix. It is roughly twice as fast as the original function. | [
"Optimized",
"version",
"of",
"the",
"Wagner",
"&",
"Fischer",
"algorithm",
"that",
"only",
"keeps",
"a",
"single",
"column",
"in",
"the",
"matrix",
"in",
"memory",
"at",
"a",
"time",
".",
"It",
"implements",
"the",
"simple",
"cutoff",
"but",
"otherwise",
... | 6263f9c6e984c26362a76241c7c7ea3bb4469bac | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/comparators/Levenshtein.java#L228-L288 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.