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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MenoData/Time4J | base/src/main/java/net/time4j/calendar/astro/JulianDay.java | JulianDay.getValue | static double getValue(
Moment moment,
TimeScale scale
) {
long elapsedTime = moment.getElapsedTime(scale) + jdOffset(scale);
int nano = moment.getNanosecond(scale);
double secs = elapsedTime + nano / (MRD * 1.0);
return secs / DAY_IN_SECONDS;
} | java | static double getValue(
Moment moment,
TimeScale scale
) {
long elapsedTime = moment.getElapsedTime(scale) + jdOffset(scale);
int nano = moment.getNanosecond(scale);
double secs = elapsedTime + nano / (MRD * 1.0);
return secs / DAY_IN_SECONDS;
} | [
"static",
"double",
"getValue",
"(",
"Moment",
"moment",
",",
"TimeScale",
"scale",
")",
"{",
"long",
"elapsedTime",
"=",
"moment",
".",
"getElapsedTime",
"(",
"scale",
")",
"+",
"jdOffset",
"(",
"scale",
")",
";",
"int",
"nano",
"=",
"moment",
".",
"get... | obtains the JD-value for given moment and scale | [
"obtains",
"the",
"JD",
"-",
"value",
"for",
"given",
"moment",
"and",
"scale"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/astro/JulianDay.java#L543-L553 | train |
MenoData/Time4J | base/src/main/java/net/time4j/DayPeriod.java | DayPeriod.of | static DayPeriod of(
Locale locale,
String calendarType
) {
String lang = locale.getLanguage(); // NPE-check
if (lang.equals("nn")) {
locale = new Locale("nb"); // CLDR 29 contains no data for language nn
}
Map<String, String> resourceMap = loadTextForm... | java | static DayPeriod of(
Locale locale,
String calendarType
) {
String lang = locale.getLanguage(); // NPE-check
if (lang.equals("nn")) {
locale = new Locale("nb"); // CLDR 29 contains no data for language nn
}
Map<String, String> resourceMap = loadTextForm... | [
"static",
"DayPeriod",
"of",
"(",
"Locale",
"locale",
",",
"String",
"calendarType",
")",
"{",
"String",
"lang",
"=",
"locale",
".",
"getLanguage",
"(",
")",
";",
"// NPE-check",
"if",
"(",
"lang",
".",
"equals",
"(",
"\"nn\"",
")",
")",
"{",
"locale",
... | package-private because used in deserialization | [
"package",
"-",
"private",
"because",
"used",
"in",
"deserialization"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/DayPeriod.java#L441-L495 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/astro/SolarTime.java | SolarTime.getHighestElevationOfSun | double getHighestElevationOfSun(PlainDate date) {
Moment noon = date.get(this.transitAtNoon());
double jde = JulianDay.getValue(noon, TimeScale.TT);
double decInRad = Math.toRadians(this.getCalculator().getFeature(jde, DECLINATION));
double latInRad = Math.toRadians(this.latitude);
... | java | double getHighestElevationOfSun(PlainDate date) {
Moment noon = date.get(this.transitAtNoon());
double jde = JulianDay.getValue(noon, TimeScale.TT);
double decInRad = Math.toRadians(this.getCalculator().getFeature(jde, DECLINATION));
double latInRad = Math.toRadians(this.latitude);
... | [
"double",
"getHighestElevationOfSun",
"(",
"PlainDate",
"date",
")",
"{",
"Moment",
"noon",
"=",
"date",
".",
"get",
"(",
"this",
".",
"transitAtNoon",
"(",
")",
")",
";",
"double",
"jde",
"=",
"JulianDay",
".",
"getValue",
"(",
"noon",
",",
"TimeScale",
... | used in test classes, too | [
"used",
"in",
"test",
"classes",
"too"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/astro/SolarTime.java#L1066-L1083 | train |
MenoData/Time4J | base/src/main/java/net/time4j/history/EraPreference.java | EraPreference.getPreferredEra | HistoricEra getPreferredEra(
HistoricDate hd,
PlainDate date
) {
if ((this.era == null) || date.isBefore(this.start) || date.isAfter(this.end)) {
return ((hd.compareTo(AD1) < 0) ? HistoricEra.BC : HistoricEra.AD);
} else if ((this.era == HistoricEra.HISPANIC) && (hd.comp... | java | HistoricEra getPreferredEra(
HistoricDate hd,
PlainDate date
) {
if ((this.era == null) || date.isBefore(this.start) || date.isAfter(this.end)) {
return ((hd.compareTo(AD1) < 0) ? HistoricEra.BC : HistoricEra.AD);
} else if ((this.era == HistoricEra.HISPANIC) && (hd.comp... | [
"HistoricEra",
"getPreferredEra",
"(",
"HistoricDate",
"hd",
",",
"PlainDate",
"date",
")",
"{",
"if",
"(",
"(",
"this",
".",
"era",
"==",
"null",
")",
"||",
"date",
".",
"isBefore",
"(",
"this",
".",
"start",
")",
"||",
"date",
".",
"isAfter",
"(",
... | determines the preferred era for a given historic date | [
"determines",
"the",
"preferred",
"era",
"for",
"a",
"given",
"historic",
"date"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/history/EraPreference.java#L324-L337 | train |
MenoData/Time4J | base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java | ArrayTransitionModel.dump | void dump(
int size,
Appendable buffer
) throws IOException {
for (int i = 0; i < size; i++) {
ZonalTransition transition = this.transitions[i];
TransitionModel.dump(transition, buffer);
}
} | java | void dump(
int size,
Appendable buffer
) throws IOException {
for (int i = 0; i < size; i++) {
ZonalTransition transition = this.transitions[i];
TransitionModel.dump(transition, buffer);
}
} | [
"void",
"dump",
"(",
"int",
"size",
",",
"Appendable",
"buffer",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"ZonalTransition",
"transition",
"=",
"this",
".",
"transitions",
"... | Called by CompositeTransitionModel | [
"Called",
"by",
"CompositeTransitionModel"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java#L336-L346 | train |
MenoData/Time4J | base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java | ArrayTransitionModel.search | private static int search(
long posixTime,
ZonalTransition[] transitions
) {
int low = 0;
int high = transitions.length - 1;
while (low <= high) {
int middle = (low + high) / 2;
if (transitions[middle].getPosixTime() <= posixTime) {
... | java | private static int search(
long posixTime,
ZonalTransition[] transitions
) {
int low = 0;
int high = transitions.length - 1;
while (low <= high) {
int middle = (low + high) / 2;
if (transitions[middle].getPosixTime() <= posixTime) {
... | [
"private",
"static",
"int",
"search",
"(",
"long",
"posixTime",
",",
"ZonalTransition",
"[",
"]",
"transitions",
")",
"{",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"transitions",
".",
"length",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"high",
... | returns index of first transition after posixTime | [
"returns",
"index",
"of",
"first",
"transition",
"after",
"posixTime"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java#L475-L495 | train |
MenoData/Time4J | base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java | ArrayTransitionModel.searchLocal | private static int searchLocal(
long localSecs,
ZonalTransition[] transitions
) {
int low = 0;
int high = transitions.length - 1;
while (low <= high) {
int middle = (low + high) / 2;
ZonalTransition zt = transitions[middle];
int offset = ... | java | private static int searchLocal(
long localSecs,
ZonalTransition[] transitions
) {
int low = 0;
int high = transitions.length - 1;
while (low <= high) {
int middle = (low + high) / 2;
ZonalTransition zt = transitions[middle];
int offset = ... | [
"private",
"static",
"int",
"searchLocal",
"(",
"long",
"localSecs",
",",
"ZonalTransition",
"[",
"]",
"transitions",
")",
"{",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"transitions",
".",
"length",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"hi... | returns index of first transition after local date and time | [
"returns",
"index",
"of",
"first",
"transition",
"after",
"local",
"date",
"and",
"time"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/tz/model/ArrayTransitionModel.java#L498-L520 | train |
MenoData/Time4J | base/src/main/java/net/time4j/engine/ChronoEntity.java | ChronoEntity.getRule | <V> ElementRule<T, V> getRule(ChronoElement<V> element) {
return this.getChronology().getRule(element);
} | java | <V> ElementRule<T, V> getRule(ChronoElement<V> element) {
return this.getChronology().getRule(element);
} | [
"<",
"V",
">",
"ElementRule",
"<",
"T",
",",
"V",
">",
"getRule",
"(",
"ChronoElement",
"<",
"V",
">",
"element",
")",
"{",
"return",
"this",
".",
"getChronology",
"(",
")",
".",
"getRule",
"(",
"element",
")",
";",
"}"
] | Determines the associated element rule.
@param <V> value type of element
@param element chronological element to be evaluated
@return element rule
@throws RuleNotFoundException if a rule cannot be determined | [
"Determines",
"the",
"associated",
"element",
"rule",
"."
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/engine/ChronoEntity.java#L616-L620 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/Nengo.java | Nengo.getValue | int getValue() {
if (this.matches(Selector.NORTHERN_COURT)) {
return (this.index - NORTHERN_NENGOS.length + NENGO_OEI.index - Nengo.SHOWA.index + 1);
}
return (this.index - Nengo.SHOWA.index + 1);
} | java | int getValue() {
if (this.matches(Selector.NORTHERN_COURT)) {
return (this.index - NORTHERN_NENGOS.length + NENGO_OEI.index - Nengo.SHOWA.index + 1);
}
return (this.index - Nengo.SHOWA.index + 1);
} | [
"int",
"getValue",
"(",
")",
"{",
"if",
"(",
"this",
".",
"matches",
"(",
"Selector",
".",
"NORTHERN_COURT",
")",
")",
"{",
"return",
"(",
"this",
".",
"index",
"-",
"NORTHERN_NENGOS",
".",
"length",
"+",
"NENGO_OEI",
".",
"index",
"-",
"Nengo",
".",
... | verwendet in JapaneseCalendar | [
"verwendet",
"in",
"JapaneseCalendar"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/Nengo.java#L1030-L1038 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/JapaneseCalendar.java | JapaneseCalendar.transform | static long transform(
int relgregyear,
int dayOfYear
) {
if (relgregyear >= 1873) {
return PlainDate.of(relgregyear, dayOfYear).getDaysSinceEpochUTC();
} else {
return START_OF_YEAR[relgregyear - 701] + dayOfYear - 1;
}
} | java | static long transform(
int relgregyear,
int dayOfYear
) {
if (relgregyear >= 1873) {
return PlainDate.of(relgregyear, dayOfYear).getDaysSinceEpochUTC();
} else {
return START_OF_YEAR[relgregyear - 701] + dayOfYear - 1;
}
} | [
"static",
"long",
"transform",
"(",
"int",
"relgregyear",
",",
"int",
"dayOfYear",
")",
"{",
"if",
"(",
"relgregyear",
">=",
"1873",
")",
"{",
"return",
"PlainDate",
".",
"of",
"(",
"relgregyear",
",",
"dayOfYear",
")",
".",
"getDaysSinceEpochUTC",
"(",
")... | also used in serialization | [
"also",
"used",
"in",
"serialization"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/JapaneseCalendar.java#L1546-L1557 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/LiteralProcessor.java | LiteralProcessor.getPrefixedDigitArea | int getPrefixedDigitArea() {
if (this.multi == null) {
return 0;
}
int digits = 0;
for (int i = 0, n = this.multi.length(); i < n && Character.isDigit(this.multi.charAt(i)); i++) {
digits++;
}
return digits;
} | java | int getPrefixedDigitArea() {
if (this.multi == null) {
return 0;
}
int digits = 0;
for (int i = 0, n = this.multi.length(); i < n && Character.isDigit(this.multi.charAt(i)); i++) {
digits++;
}
return digits;
} | [
"int",
"getPrefixedDigitArea",
"(",
")",
"{",
"if",
"(",
"this",
".",
"multi",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"int",
"digits",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"this",
".",
"multi",
".",
"length"... | count of leading digits | [
"count",
"of",
"leading",
"digits"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/LiteralProcessor.java#L417-L431 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/LiteralProcessor.java | LiteralProcessor.subSequenceEquals | static int subSequenceEquals(
CharSequence test,
int offset,
CharSequence expected,
boolean caseInsensitive,
boolean rtl
) {
int j = 0;
int max = test.length();
int len = expected.length();
for (int i = 0; i < len; i++) {
char c =... | java | static int subSequenceEquals(
CharSequence test,
int offset,
CharSequence expected,
boolean caseInsensitive,
boolean rtl
) {
int j = 0;
int max = test.length();
int len = expected.length();
for (int i = 0; i < len; i++) {
char c =... | [
"static",
"int",
"subSequenceEquals",
"(",
"CharSequence",
"test",
",",
"int",
"offset",
",",
"CharSequence",
"expected",
",",
"boolean",
"caseInsensitive",
",",
"boolean",
"rtl",
")",
"{",
"int",
"j",
"=",
"0",
";",
"int",
"max",
"=",
"test",
".",
"length... | also used by LocalizedGMTProcessor | [
"also",
"used",
"by",
"LocalizedGMTProcessor"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/LiteralProcessor.java#L434-L485 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/ChronoFormatter.java | ChronoFormatter.with | ChronoFormatter<T> with(
Map<ChronoElement<?>, Object> outerDefaults,
AttributeSet outerAttrs
) {
AttributeSet merged = AttributeSet.merge(outerAttrs, this.globalAttributes);
return new ChronoFormatter<>(
new ChronoFormatter<>(this, outerDefaults),
merged,
... | java | ChronoFormatter<T> with(
Map<ChronoElement<?>, Object> outerDefaults,
AttributeSet outerAttrs
) {
AttributeSet merged = AttributeSet.merge(outerAttrs, this.globalAttributes);
return new ChronoFormatter<>(
new ChronoFormatter<>(this, outerDefaults),
merged,
... | [
"ChronoFormatter",
"<",
"T",
">",
"with",
"(",
"Map",
"<",
"ChronoElement",
"<",
"?",
">",
",",
"Object",
">",
"outerDefaults",
",",
"AttributeSet",
"outerAttrs",
")",
"{",
"AttributeSet",
"merged",
"=",
"AttributeSet",
".",
"merge",
"(",
"outerAttrs",
",",
... | used by CustomizedProcessor | [
"used",
"by",
"CustomizedProcessor"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/ChronoFormatter.java#L2039-L2051 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/ChronoFormatter.java | ChronoFormatter.hasUnixChronology | static boolean hasUnixChronology(Chronology<?> chronology) {
Chronology<?> c = chronology;
do {
if (UnixTime.class.isAssignableFrom(c.getChronoType())) {
return true;
}
} while ((c = c.preparser()) != null);
return false;
} | java | static boolean hasUnixChronology(Chronology<?> chronology) {
Chronology<?> c = chronology;
do {
if (UnixTime.class.isAssignableFrom(c.getChronoType())) {
return true;
}
} while ((c = c.preparser()) != null);
return false;
} | [
"static",
"boolean",
"hasUnixChronology",
"(",
"Chronology",
"<",
"?",
">",
"chronology",
")",
"{",
"Chronology",
"<",
"?",
">",
"c",
"=",
"chronology",
";",
"do",
"{",
"if",
"(",
"UnixTime",
".",
"class",
".",
"isAssignableFrom",
"(",
"c",
".",
"getChro... | also called in PatternType | [
"also",
"called",
"in",
"PatternType"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/ChronoFormatter.java#L3080-L3092 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/astro/LunarTime.java | LunarTime.sinAlt | private static double sinAlt(
double mjd0, // earliest moment of calendar date (usually midnight)
double hour,
double longitudeRad,
double cosLatitude,
double sinLatitude,
double geodeticAngle,
double refraction,
double deltaT
) {
double mjd =... | java | private static double sinAlt(
double mjd0, // earliest moment of calendar date (usually midnight)
double hour,
double longitudeRad,
double cosLatitude,
double sinLatitude,
double geodeticAngle,
double refraction,
double deltaT
) {
double mjd =... | [
"private",
"static",
"double",
"sinAlt",
"(",
"double",
"mjd0",
",",
"// earliest moment of calendar date (usually midnight)",
"double",
"hour",
",",
"double",
"longitudeRad",
",",
"double",
"cosLatitude",
",",
"double",
"sinLatitude",
",",
"double",
"geodeticAngle",
",... | sinus of moon altitude above or below horizon | [
"sinus",
"of",
"moon",
"altitude",
"above",
"or",
"below",
"horizon"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/astro/LunarTime.java#L427-L454 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/internal/FormatUtils.java | FormatUtils.removeZones | public static String removeZones(String pattern) {
boolean literal = false;
StringBuilder sb = new StringBuilder();
for (int i = 0, n = pattern.length(); i < n; i++) {
char c = pattern.charAt(i);
if (c == '\'') {
if (i + 1 < n && pattern.charAt(i + 1) =... | java | public static String removeZones(String pattern) {
boolean literal = false;
StringBuilder sb = new StringBuilder();
for (int i = 0, n = pattern.length(); i < n; i++) {
char c = pattern.charAt(i);
if (c == '\'') {
if (i + 1 < n && pattern.charAt(i + 1) =... | [
"public",
"static",
"String",
"removeZones",
"(",
"String",
"pattern",
")",
"{",
"boolean",
"literal",
"=",
"false",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"pattern",
"."... | Strips off any timezone symbols in clock time patterns. | [
"Strips",
"off",
"any",
"timezone",
"symbols",
"in",
"clock",
"time",
"patterns",
"."
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/internal/FormatUtils.java#L104-L149 | train |
MenoData/Time4J | base/src/main/java/net/time4j/PlainTime.java | PlainTime.printNanos | static void printNanos(
StringBuilder sb,
int nano
) {
sb.append(PlainTime.ISO_DECIMAL_SEPARATOR);
String num = Integer.toString(nano);
int len;
if ((nano % MIO) == 0) {
len = 3;
} else if ((nano % KILO) == 0) {
len = 6;
} els... | java | static void printNanos(
StringBuilder sb,
int nano
) {
sb.append(PlainTime.ISO_DECIMAL_SEPARATOR);
String num = Integer.toString(nano);
int len;
if ((nano % MIO) == 0) {
len = 3;
} else if ((nano % KILO) == 0) {
len = 6;
} els... | [
"static",
"void",
"printNanos",
"(",
"StringBuilder",
"sb",
",",
"int",
"nano",
")",
"{",
"sb",
".",
"append",
"(",
"PlainTime",
".",
"ISO_DECIMAL_SEPARATOR",
")",
";",
"String",
"num",
"=",
"Integer",
".",
"toString",
"(",
"nano",
")",
";",
"int",
"len"... | also called by ZonalDateTime | [
"also",
"called",
"by",
"ZonalDateTime"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/PlainTime.java#L1768-L1793 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/AttributeSet.java | AttributeSet.merge | static AttributeSet merge(
AttributeSet outer,
AttributeSet inner
) {
Map<String, Object> internalsNew = new HashMap<>();
internalsNew.putAll(inner.internals);
internalsNew.putAll(outer.internals);
Attributes attributesNew =
new Attributes.Builder()
... | java | static AttributeSet merge(
AttributeSet outer,
AttributeSet inner
) {
Map<String, Object> internalsNew = new HashMap<>();
internalsNew.putAll(inner.internals);
internalsNew.putAll(outer.internals);
Attributes attributesNew =
new Attributes.Builder()
... | [
"static",
"AttributeSet",
"merge",
"(",
"AttributeSet",
"outer",
",",
"AttributeSet",
"inner",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"internalsNew",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"internalsNew",
".",
"putAll",
"(",
"inner",
".",... | used to create merged global attributes for a new formatter | [
"used",
"to",
"create",
"merged",
"global",
"attributes",
"for",
"a",
"new",
"formatter"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/AttributeSet.java#L442-L458 | train |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/ParsedValues.java | ParsedValues.reset | void reset() {
if (this.keys == null) {
this.len = Integer.MIN_VALUE;
this.mask = Integer.MIN_VALUE;
this.threshold = Integer.MIN_VALUE;
this.count = Integer.MIN_VALUE;
for (int i = 0; i < 3; i++) {
this.ints[i] = Integer.MIN_VALUE;
... | java | void reset() {
if (this.keys == null) {
this.len = Integer.MIN_VALUE;
this.mask = Integer.MIN_VALUE;
this.threshold = Integer.MIN_VALUE;
this.count = Integer.MIN_VALUE;
for (int i = 0; i < 3; i++) {
this.ints[i] = Integer.MIN_VALUE;
... | [
"void",
"reset",
"(",
")",
"{",
"if",
"(",
"this",
".",
"keys",
"==",
"null",
")",
"{",
"this",
".",
"len",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"this",
".",
"mask",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"this",
".",
"threshold",
"=",
"Integer",... | called in context of erraneous or-block | [
"called",
"in",
"context",
"of",
"erraneous",
"or",
"-",
"block"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/ParsedValues.java#L545-L562 | train |
MenoData/Time4J | base/src/main/java/net/time4j/range/SingleUnitTimeSpan.java | SingleUnitTimeSpan.parsePeriod | static int parsePeriod(
String period,
char symbol
) throws ParseException {
if (period.isEmpty()) {
throw new ParseException("Empty period.", 0);
}
boolean negative = false;
int index = 0;
int len = period.length();
if (period.charAt(0)... | java | static int parsePeriod(
String period,
char symbol
) throws ParseException {
if (period.isEmpty()) {
throw new ParseException("Empty period.", 0);
}
boolean negative = false;
int index = 0;
int len = period.length();
if (period.charAt(0)... | [
"static",
"int",
"parsePeriod",
"(",
"String",
"period",
",",
"char",
"symbol",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"period",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"\"Empty period.\"",
",",
"0",
")",
";",
... | called by subclasses | [
"called",
"by",
"subclasses"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/range/SingleUnitTimeSpan.java#L464-L519 | train |
MenoData/Time4J | base/src/main/java/net/time4j/tz/model/SPX.java | SPX.writeTransitions | static void writeTransitions(
ZonalTransition[] transitions,
int size,
DataOutput out
) throws IOException {
int n = Math.min(size, transitions.length);
out.writeInt(n);
if (n > 0) {
int stdOffset = transitions[0].getPreviousOffset();
writeOf... | java | static void writeTransitions(
ZonalTransition[] transitions,
int size,
DataOutput out
) throws IOException {
int n = Math.min(size, transitions.length);
out.writeInt(n);
if (n > 0) {
int stdOffset = transitions[0].getPreviousOffset();
writeOf... | [
"static",
"void",
"writeTransitions",
"(",
"ZonalTransition",
"[",
"]",
"transitions",
",",
"int",
"size",
",",
"DataOutput",
"out",
")",
"throws",
"IOException",
"{",
"int",
"n",
"=",
"Math",
".",
"min",
"(",
"size",
",",
"transitions",
".",
"length",
")"... | called by ArrayTransitionModel | [
"called",
"by",
"ArrayTransitionModel"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/tz/model/SPX.java#L218-L236 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/service/StdEnumDateElement.java | StdEnumDateElement.accessor | protected TextAccessor accessor(
AttributeQuery attributes,
OutputContext outputContext,
boolean leap
) {
Locale lang = attributes.get(Attributes.LANGUAGE, Locale.ROOT);
TextWidth textWidth = attributes.get(Attributes.TEXT_WIDTH, TextWidth.WIDE);
CalendarText cnames ... | java | protected TextAccessor accessor(
AttributeQuery attributes,
OutputContext outputContext,
boolean leap
) {
Locale lang = attributes.get(Attributes.LANGUAGE, Locale.ROOT);
TextWidth textWidth = attributes.get(Attributes.TEXT_WIDTH, TextWidth.WIDE);
CalendarText cnames ... | [
"protected",
"TextAccessor",
"accessor",
"(",
"AttributeQuery",
"attributes",
",",
"OutputContext",
"outputContext",
",",
"boolean",
"leap",
")",
"{",
"Locale",
"lang",
"=",
"attributes",
".",
"get",
"(",
"Attributes",
".",
"LANGUAGE",
",",
"Locale",
".",
"ROOT"... | Might be overridden in special cases.
@param attributes format attributes
@param outputContext the output context
@param leap leap month flag
@return TextAccessor
@since 5.3 | [
"Might",
"be",
"overridden",
"in",
"special",
"cases",
"."
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/service/StdEnumDateElement.java#L309-L333 | train |
MenoData/Time4J | base/src/main/java/net/time4j/calendar/HijriAdjustment.java | HijriAdjustment.from | static HijriAdjustment from(String variant) {
int index = variant.indexOf(':');
if (index == -1) {
return new HijriAdjustment(variant, 0);
} else {
try {
int adjustment = Integer.parseInt(variant.substring(index + 1));
return new HijriAdj... | java | static HijriAdjustment from(String variant) {
int index = variant.indexOf(':');
if (index == -1) {
return new HijriAdjustment(variant, 0);
} else {
try {
int adjustment = Integer.parseInt(variant.substring(index + 1));
return new HijriAdj... | [
"static",
"HijriAdjustment",
"from",
"(",
"String",
"variant",
")",
"{",
"int",
"index",
"=",
"variant",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"new",
"HijriAdjustment",
"(",
"variant",
",",
"... | also called by Hijri calendar systems | [
"also",
"called",
"by",
"Hijri",
"calendar",
"systems"
] | 08b2eda6b2dbb140b92011cf7071bb087edd46a5 | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/calendar/HijriAdjustment.java#L196-L211 | train |
TonicArtos/StickyGridHeaders | Library/src/com/tonicartos/widget/stickygridheaders/StickyGridHeadersBaseAdapterWrapper.java | StickyGridHeadersBaseAdapterWrapper.unFilledSpacesInHeaderGroup | private int unFilledSpacesInHeaderGroup(int header) {
//If mNumColumns is equal to zero we will have a divide by 0 exception
if(mNumColumns == 0){
return 0;
}
int remainder = mDelegate.getCountForHeader(header) % mNumColumns;
return remainder == 0 ? 0 : mNumColumns -... | java | private int unFilledSpacesInHeaderGroup(int header) {
//If mNumColumns is equal to zero we will have a divide by 0 exception
if(mNumColumns == 0){
return 0;
}
int remainder = mDelegate.getCountForHeader(header) % mNumColumns;
return remainder == 0 ? 0 : mNumColumns -... | [
"private",
"int",
"unFilledSpacesInHeaderGroup",
"(",
"int",
"header",
")",
"{",
"//If mNumColumns is equal to zero we will have a divide by 0 exception",
"if",
"(",
"mNumColumns",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"int",
"remainder",
"=",
"mDelegate",
"."... | Counts the number of items that would be need to fill out the last row in
the group of items with the given header.
@param header Header set of items are grouped by.
@return The count of unfilled spaces in the last row. | [
"Counts",
"the",
"number",
"of",
"items",
"that",
"would",
"be",
"need",
"to",
"fill",
"out",
"the",
"last",
"row",
"in",
"the",
"group",
"of",
"items",
"with",
"the",
"given",
"header",
"."
] | e3e4f8fa5d5c01edc9af26ff800302a931103b31 | https://github.com/TonicArtos/StickyGridHeaders/blob/e3e4f8fa5d5c01edc9af26ff800302a931103b31/Library/src/com/tonicartos/widget/stickygridheaders/StickyGridHeadersBaseAdapterWrapper.java#L279-L287 | train |
TonicArtos/StickyGridHeaders | Library/src/com/tonicartos/widget/stickygridheaders/StickyGridHeadersGridView.java | StickyGridHeadersGridView.getHeaderAt | public View getHeaderAt(int position) {
if (position == MATCHED_STICKIED_HEADER) {
return mStickiedHeader;
}
try {
return (View)getChildAt(position).getTag();
} catch (Exception e) {
}
return null;
} | java | public View getHeaderAt(int position) {
if (position == MATCHED_STICKIED_HEADER) {
return mStickiedHeader;
}
try {
return (View)getChildAt(position).getTag();
} catch (Exception e) {
}
return null;
} | [
"public",
"View",
"getHeaderAt",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"==",
"MATCHED_STICKIED_HEADER",
")",
"{",
"return",
"mStickiedHeader",
";",
"}",
"try",
"{",
"return",
"(",
"View",
")",
"getChildAt",
"(",
"position",
")",
".",
"ge... | Gets the header at an item position. However, the position must be that
of a HeaderFiller.
@param position Position of HeaderFiller.
@return Header View wrapped in HeaderFiller or null if no header was
found. | [
"Gets",
"the",
"header",
"at",
"an",
"item",
"position",
".",
"However",
"the",
"position",
"must",
"be",
"that",
"of",
"a",
"HeaderFiller",
"."
] | e3e4f8fa5d5c01edc9af26ff800302a931103b31 | https://github.com/TonicArtos/StickyGridHeaders/blob/e3e4f8fa5d5c01edc9af26ff800302a931103b31/Library/src/com/tonicartos/widget/stickygridheaders/StickyGridHeadersGridView.java#L212-L222 | train |
TonicArtos/StickyGridHeaders | Example/src/com/tonicartos/stickygridheadersexample/ItemListFragment.java | ItemListFragment.setActivateOnItemClick | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setActivateOnItemClick(boolean activateOnItemClick) {
// When setting CHOICE_MODE_SINGLE, ListView will automatically
// give items the 'activated' state when touched.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
... | java | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setActivateOnItemClick(boolean activateOnItemClick) {
// When setting CHOICE_MODE_SINGLE, ListView will automatically
// give items the 'activated' state when touched.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
... | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"void",
"setActivateOnItemClick",
"(",
"boolean",
"activateOnItemClick",
")",
"{",
"// When setting CHOICE_MODE_SINGLE, ListView will automatically",
"// give items the 'activated' state when t... | Turns on activate-on-click mode. When this mode is on, list items will be
given the 'activated' state when touched. | [
"Turns",
"on",
"activate",
"-",
"on",
"-",
"click",
"mode",
".",
"When",
"this",
"mode",
"is",
"on",
"list",
"items",
"will",
"be",
"given",
"the",
"activated",
"state",
"when",
"touched",
"."
] | e3e4f8fa5d5c01edc9af26ff800302a931103b31 | https://github.com/TonicArtos/StickyGridHeaders/blob/e3e4f8fa5d5c01edc9af26ff800302a931103b31/Example/src/com/tonicartos/stickygridheadersexample/ItemListFragment.java#L241-L250 | train |
emilsjolander/android-FlipView | library/src/se/emilsjolander/flipview/Recycler.java | Recycler.addScrapView | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void addScrapView(View scrap, int position, int viewType) {
// create a new Scrap
Scrap item = new Scrap(scrap, true);
if (viewTypeCount == 1) {
currentScraps.put(position, item);
} else {
scraps[viewType].put(position, item);
}
if (Build.VERSION.... | java | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void addScrapView(View scrap, int position, int viewType) {
// create a new Scrap
Scrap item = new Scrap(scrap, true);
if (viewTypeCount == 1) {
currentScraps.put(position, item);
} else {
scraps[viewType].put(position, item);
}
if (Build.VERSION.... | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"void",
"addScrapView",
"(",
"View",
"scrap",
",",
"int",
"position",
",",
"int",
"viewType",
")",
"{",
"// create a new Scrap",
"Scrap",
"item",
"=",
"new",
"Scrap",
"(",
... | Put a view into the ScrapViews list. These views are unordered.
@param scrap
The view to add | [
"Put",
"a",
"view",
"into",
"the",
"ScrapViews",
"list",
".",
"These",
"views",
"are",
"unordered",
"."
] | 7dc0dbd37339dc9691934b60a1c2763b5ed29ffe | https://github.com/emilsjolander/android-FlipView/blob/7dc0dbd37339dc9691934b60a1c2763b5ed29ffe/library/src/se/emilsjolander/flipview/Recycler.java#L61-L74 | train |
emilsjolander/android-FlipView | library/src/se/emilsjolander/flipview/FlipView.java | FlipView.setDrawWithLayer | private void setDrawWithLayer(View v, boolean drawWithLayer) {
if (isHardwareAccelerated()) {
if (v.getLayerType() != LAYER_TYPE_HARDWARE && drawWithLayer) {
v.setLayerType(LAYER_TYPE_HARDWARE, null);
} else if (v.getLayerType() != LAYER_TYPE_NONE && !drawWithLayer) {
v.setLayerType(LAYER_TYPE_NONE, nul... | java | private void setDrawWithLayer(View v, boolean drawWithLayer) {
if (isHardwareAccelerated()) {
if (v.getLayerType() != LAYER_TYPE_HARDWARE && drawWithLayer) {
v.setLayerType(LAYER_TYPE_HARDWARE, null);
} else if (v.getLayerType() != LAYER_TYPE_NONE && !drawWithLayer) {
v.setLayerType(LAYER_TYPE_NONE, nul... | [
"private",
"void",
"setDrawWithLayer",
"(",
"View",
"v",
",",
"boolean",
"drawWithLayer",
")",
"{",
"if",
"(",
"isHardwareAccelerated",
"(",
")",
")",
"{",
"if",
"(",
"v",
".",
"getLayerType",
"(",
")",
"!=",
"LAYER_TYPE_HARDWARE",
"&&",
"drawWithLayer",
")"... | Enable a hardware layer for the view.
@param v
@param drawWithLayer | [
"Enable",
"a",
"hardware",
"layer",
"for",
"the",
"view",
"."
] | 7dc0dbd37339dc9691934b60a1c2763b5ed29ffe | https://github.com/emilsjolander/android-FlipView/blob/7dc0dbd37339dc9691934b60a1c2763b5ed29ffe/library/src/se/emilsjolander/flipview/FlipView.java#L875-L883 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/Scanners.java | Scanners.many | public static Parser<Void> many(CharPredicate predicate) {
return Patterns.isChar(predicate).many().toScanner(predicate + "*");
} | java | public static Parser<Void> many(CharPredicate predicate) {
return Patterns.isChar(predicate).many().toScanner(predicate + "*");
} | [
"public",
"static",
"Parser",
"<",
"Void",
">",
"many",
"(",
"CharPredicate",
"predicate",
")",
"{",
"return",
"Patterns",
".",
"isChar",
"(",
"predicate",
")",
".",
"many",
"(",
")",
".",
"toScanner",
"(",
"predicate",
"+",
"\"*\"",
")",
";",
"}"
] | A scanner that scans greedily for 0 or more characters that satisfies the given CharPredicate.
@param predicate the predicate object.
@return the Parser object. | [
"A",
"scanner",
"that",
"scans",
"greedily",
"for",
"0",
"or",
"more",
"characters",
"that",
"satisfies",
"the",
"given",
"CharPredicate",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Scanners.java#L161-L163 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/Scanners.java | Scanners.many1 | public static Parser<Void> many1(CharPredicate predicate) {
return Patterns.many1(predicate).toScanner(predicate + "+");
} | java | public static Parser<Void> many1(CharPredicate predicate) {
return Patterns.many1(predicate).toScanner(predicate + "+");
} | [
"public",
"static",
"Parser",
"<",
"Void",
">",
"many1",
"(",
"CharPredicate",
"predicate",
")",
"{",
"return",
"Patterns",
".",
"many1",
"(",
"predicate",
")",
".",
"toScanner",
"(",
"predicate",
"+",
"\"+\"",
")",
";",
"}"
] | A scanner that scans greedily for 1 or more characters that satisfies the given CharPredicate.
@param predicate the predicate object.
@return the Parser object. | [
"A",
"scanner",
"that",
"scans",
"greedily",
"for",
"1",
"or",
"more",
"characters",
"that",
"satisfies",
"the",
"given",
"CharPredicate",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Scanners.java#L171-L173 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/Scanners.java | Scanners.many1 | @Deprecated
public static Parser<Void> many1(Pattern pattern, String name) {
return pattern.many1().toScanner(name);
} | java | @Deprecated
public static Parser<Void> many1(Pattern pattern, String name) {
return pattern.many1().toScanner(name);
} | [
"@",
"Deprecated",
"public",
"static",
"Parser",
"<",
"Void",
">",
"many1",
"(",
"Pattern",
"pattern",
",",
"String",
"name",
")",
"{",
"return",
"pattern",
".",
"many1",
"(",
")",
".",
"toScanner",
"(",
"name",
")",
";",
"}"
] | A scanner that scans greedily for 1 or more occurrences of the given pattern.
@param pattern the pattern object.
@param name the name of what's expected logically. Is used in error message.
@return the Parser object.
@deprecated Use {@code pattern.many1().toScanner(name)}. | [
"A",
"scanner",
"that",
"scans",
"greedily",
"for",
"1",
"or",
"more",
"occurrences",
"of",
"the",
"given",
"pattern",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Scanners.java#L196-L199 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/Scanners.java | Scanners.stringCaseInsensitive | public static Parser<Void> stringCaseInsensitive(String str) {
return Patterns.stringCaseInsensitive(str).toScanner(str);
} | java | public static Parser<Void> stringCaseInsensitive(String str) {
return Patterns.stringCaseInsensitive(str).toScanner(str);
} | [
"public",
"static",
"Parser",
"<",
"Void",
">",
"stringCaseInsensitive",
"(",
"String",
"str",
")",
"{",
"return",
"Patterns",
".",
"stringCaseInsensitive",
"(",
"str",
")",
".",
"toScanner",
"(",
"str",
")",
";",
"}"
] | A scanner that matches the input against the specified string case insensitively.
@param str the string to match
@return the scanner. | [
"A",
"scanner",
"that",
"matches",
"the",
"input",
"against",
"the",
"specified",
"string",
"case",
"insensitively",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Scanners.java#L271-L273 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/internal/util/Checks.java | Checks.checkState | public static void checkState(boolean condition, String message, Object... args)
throws IllegalStateException {
if (!condition) {
throw new IllegalStateException(String.format(message, args));
}
} | java | public static void checkState(boolean condition, String message, Object... args)
throws IllegalStateException {
if (!condition) {
throw new IllegalStateException(String.format(message, args));
}
} | [
"public",
"static",
"void",
"checkState",
"(",
"boolean",
"condition",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"!",
"condition",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"St... | Checks a certain state.
@param condition the condition of the state that has to be true
@param message the error message if {@code condition} is false
@param args the arguments to the error message
@throws IllegalStateException if {@code condition} is false | [
"Checks",
"a",
"certain",
"state",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/internal/util/Checks.java#L90-L95 | train |
jparsec/jparsec | jparsec-examples/src/main/java/org/jparsec/examples/java/parser/ExpressionParser.java | ExpressionParser.simpleNewExpression | static Parser<Expression> simpleNewExpression(Parser<Expression> arg, Parser<DefBody> body) {
return Parsers.sequence(
term("new").next(TypeLiteralParser.ELEMENT_TYPE_LITERAL),
argumentList(arg),
body.optional(),
(type, args, defBody) -> new NewExpression(null, type, args, defBody));... | java | static Parser<Expression> simpleNewExpression(Parser<Expression> arg, Parser<DefBody> body) {
return Parsers.sequence(
term("new").next(TypeLiteralParser.ELEMENT_TYPE_LITERAL),
argumentList(arg),
body.optional(),
(type, args, defBody) -> new NewExpression(null, type, args, defBody));... | [
"static",
"Parser",
"<",
"Expression",
">",
"simpleNewExpression",
"(",
"Parser",
"<",
"Expression",
">",
"arg",
",",
"Parser",
"<",
"DefBody",
">",
"body",
")",
"{",
"return",
"Parsers",
".",
"sequence",
"(",
"term",
"(",
"\"new\"",
")",
".",
"next",
"(... | new a class instance | [
"new",
"a",
"class",
"instance"
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec-examples/src/main/java/org/jparsec/examples/java/parser/ExpressionParser.java#L132-L138 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.prefix | public OperatorTable<T> prefix(
Parser<? extends Function<? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.PREFIX));
return this;
} | java | public OperatorTable<T> prefix(
Parser<? extends Function<? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.PREFIX));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"prefix",
"(",
"Parser",
"<",
"?",
"extends",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add",
"(",
"new",
"Operator",
... | Adds a prefix unary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"a",
"prefix",
"unary",
"operator",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L89-L93 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.postfix | public OperatorTable<T> postfix(
Parser<? extends Function<? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.POSTFIX));
return this;
} | java | public OperatorTable<T> postfix(
Parser<? extends Function<? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.POSTFIX));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"postfix",
"(",
"Parser",
"<",
"?",
"extends",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add",
"(",
"new",
"Operator",
... | Adds a postfix unary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"a",
"postfix",
"unary",
"operator",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L102-L106 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.infixl | public OperatorTable<T> infixl(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.LASSOC));
return this;
} | java | public OperatorTable<T> infixl(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.LASSOC));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"infixl",
"(",
"Parser",
"<",
"?",
"extends",
"BiFunction",
"<",
"?",
"super",
"T",
",",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add... | Adds an infix left-associative binary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"an",
"infix",
"left",
"-",
"associative",
"binary",
"operator",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L115-L119 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.infixr | public OperatorTable<T> infixr(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.RASSOC));
return this;
} | java | public OperatorTable<T> infixr(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.RASSOC));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"infixr",
"(",
"Parser",
"<",
"?",
"extends",
"BiFunction",
"<",
"?",
"super",
"T",
",",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add... | Adds an infix right-associative binary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"an",
"infix",
"right",
"-",
"associative",
"binary",
"operator",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L128-L132 | train |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.infixn | public OperatorTable<T> infixn(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.NASSOC));
return this;
} | java | public OperatorTable<T> infixn(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.NASSOC));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"infixn",
"(",
"Parser",
"<",
"?",
"extends",
"BiFunction",
"<",
"?",
"super",
"T",
",",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add... | Adds an infix non-associative binary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"an",
"infix",
"non",
"-",
"associative",
"binary",
"operator",
"."
] | df1280259f5da9eb5ffc537437569dddba66cb94 | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L140-L144 | train |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/Cryptors.java | Cryptors.cleartextSize | public static long cleartextSize(long ciphertextSize, Cryptor cryptor) {
checkArgument(ciphertextSize >= 0, "expected ciphertextSize to be positive, but was %s", ciphertextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ci... | java | public static long cleartextSize(long ciphertextSize, Cryptor cryptor) {
checkArgument(ciphertextSize >= 0, "expected ciphertextSize to be positive, but was %s", ciphertextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ci... | [
"public",
"static",
"long",
"cleartextSize",
"(",
"long",
"ciphertextSize",
",",
"Cryptor",
"cryptor",
")",
"{",
"checkArgument",
"(",
"ciphertextSize",
">=",
"0",
",",
"\"expected ciphertextSize to be positive, but was %s\"",
",",
"ciphertextSize",
")",
";",
"long",
... | Calculates the size of the cleartext resulting from the given ciphertext decrypted with the given cryptor.
@param ciphertextSize Length of encrypted payload. Not including the {@link FileHeader#getFilesize() length of the header}.
@param cryptor The cryptor which defines the cleartext/ciphertext ratio
@return Cleartex... | [
"Calculates",
"the",
"size",
"of",
"the",
"cleartext",
"resulting",
"from",
"the",
"given",
"ciphertext",
"decrypted",
"with",
"the",
"given",
"cryptor",
"."
] | 33bc881f6ee7d4924043ea6309efd2c063ec3638 | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/Cryptors.java#L41-L54 | train |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/Cryptors.java | Cryptors.ciphertextSize | public static long ciphertextSize(long cleartextSize, Cryptor cryptor) {
checkArgument(cleartextSize >= 0, "expected cleartextSize to be positive, but was %s", cleartextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ciphe... | java | public static long ciphertextSize(long cleartextSize, Cryptor cryptor) {
checkArgument(cleartextSize >= 0, "expected cleartextSize to be positive, but was %s", cleartextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ciphe... | [
"public",
"static",
"long",
"ciphertextSize",
"(",
"long",
"cleartextSize",
",",
"Cryptor",
"cryptor",
")",
"{",
"checkArgument",
"(",
"cleartextSize",
">=",
"0",
",",
"\"expected cleartextSize to be positive, but was %s\"",
",",
"cleartextSize",
")",
";",
"long",
"cl... | Calculates the size of the ciphertext resulting from the given cleartext encrypted with the given cryptor.
@param cleartextSize Length of a unencrypted payload.
@param cryptor The cryptor which defines the cleartext/ciphertext ratio
@return Ciphertext length of a <code>cleartextSize</code>-sized cleartext encrypted w... | [
"Calculates",
"the",
"size",
"of",
"the",
"ciphertext",
"resulting",
"from",
"the",
"given",
"cleartext",
"encrypted",
"with",
"the",
"given",
"cryptor",
"."
] | 33bc881f6ee7d4924043ea6309efd2c063ec3638 | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/Cryptors.java#L65-L75 | train |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/common/ByteBuffers.java | ByteBuffers.copy | public static int copy(ByteBuffer source, ByteBuffer destination) {
final int numBytes = Math.min(source.remaining(), destination.remaining());
final ByteBuffer tmp = source.asReadOnlyBuffer();
tmp.limit(tmp.position() + numBytes);
destination.put(tmp);
source.position(tmp.position()); // until now only tmp p... | java | public static int copy(ByteBuffer source, ByteBuffer destination) {
final int numBytes = Math.min(source.remaining(), destination.remaining());
final ByteBuffer tmp = source.asReadOnlyBuffer();
tmp.limit(tmp.position() + numBytes);
destination.put(tmp);
source.position(tmp.position()); // until now only tmp p... | [
"public",
"static",
"int",
"copy",
"(",
"ByteBuffer",
"source",
",",
"ByteBuffer",
"destination",
")",
"{",
"final",
"int",
"numBytes",
"=",
"Math",
".",
"min",
"(",
"source",
".",
"remaining",
"(",
")",
",",
"destination",
".",
"remaining",
"(",
")",
")... | Copies as many bytes as possible from the given source to the destination buffer.
The position of both buffers will be incremented by as many bytes as have been copied.
@param source ByteBuffer from which bytes are read
@param destination ByteBuffer into which bytes are written
@return number of bytes copied, i.e. {@l... | [
"Copies",
"as",
"many",
"bytes",
"as",
"possible",
"from",
"the",
"given",
"source",
"to",
"the",
"destination",
"buffer",
".",
"The",
"position",
"of",
"both",
"buffers",
"will",
"be",
"incremented",
"by",
"as",
"many",
"bytes",
"as",
"have",
"been",
"cop... | 33bc881f6ee7d4924043ea6309efd2c063ec3638 | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/common/ByteBuffers.java#L23-L30 | train |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/api/KeyFile.java | KeyFile.parse | public static KeyFile parse(byte[] serialized) {
try (InputStream in = new ByteArrayInputStream(serialized); //
Reader reader = new InputStreamReader(in, UTF_8); //
JsonReader jsonReader = GSON.newJsonReader(reader)) {
JsonObject jsonObj = new JsonParser().parse(jsonReader).getAsJsonObject();
KeyFile re... | java | public static KeyFile parse(byte[] serialized) {
try (InputStream in = new ByteArrayInputStream(serialized); //
Reader reader = new InputStreamReader(in, UTF_8); //
JsonReader jsonReader = GSON.newJsonReader(reader)) {
JsonObject jsonObj = new JsonParser().parse(jsonReader).getAsJsonObject();
KeyFile re... | [
"public",
"static",
"KeyFile",
"parse",
"(",
"byte",
"[",
"]",
"serialized",
")",
"{",
"try",
"(",
"InputStream",
"in",
"=",
"new",
"ByteArrayInputStream",
"(",
"serialized",
")",
";",
"//",
"Reader",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"in",
"... | Parses a json keyfile.
@param serialized Json content.
@return A new KeyFile instance. | [
"Parses",
"a",
"json",
"keyfile",
"."
] | 33bc881f6ee7d4924043ea6309efd2c063ec3638 | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/api/KeyFile.java#L77-L88 | train |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/api/KeyFile.java | KeyFile.as | public <T extends KeyFile> T as(Class<T> clazz) {
T result = GSON.fromJson(jsonObj, clazz);
((KeyFile) result).jsonObj = jsonObj;
return result;
} | java | public <T extends KeyFile> T as(Class<T> clazz) {
T result = GSON.fromJson(jsonObj, clazz);
((KeyFile) result).jsonObj = jsonObj;
return result;
} | [
"public",
"<",
"T",
"extends",
"KeyFile",
">",
"T",
"as",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"T",
"result",
"=",
"GSON",
".",
"fromJson",
"(",
"jsonObj",
",",
"clazz",
")",
";",
"(",
"(",
"KeyFile",
")",
"result",
")",
".",
"jsonObj"... | Creates a new version-specific KeyFile instance from this instance.
@param clazz Version-specific subclass of KeyFile.
@param <T> Specific KeyFile implementation type.
@return New instance of the given class. | [
"Creates",
"a",
"new",
"version",
"-",
"specific",
"KeyFile",
"instance",
"from",
"this",
"instance",
"."
] | 33bc881f6ee7d4924043ea6309efd2c063ec3638 | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/api/KeyFile.java#L106-L110 | train |
diffplug/durian | src/com/diffplug/common/base/DurianPlugins.java | DurianPlugins.register | public static <T> void register(Class<T> pluginClass, T pluginImpl) throws IllegalStateException {
INSTANCE.registerInternal(pluginClass, pluginImpl);
} | java | public static <T> void register(Class<T> pluginClass, T pluginImpl) throws IllegalStateException {
INSTANCE.registerInternal(pluginClass, pluginImpl);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"register",
"(",
"Class",
"<",
"T",
">",
"pluginClass",
",",
"T",
"pluginImpl",
")",
"throws",
"IllegalStateException",
"{",
"INSTANCE",
".",
"registerInternal",
"(",
"pluginClass",
",",
"pluginImpl",
")",
";",
"}"
... | Registers an implementation as a global override of any injected or default implementations.
@param pluginClass The interface which is being registered.
@param pluginImpl The implementation of that interface which is being registered.
@throws IllegalStateException If called more than once or if a value has already be... | [
"Registers",
"an",
"implementation",
"as",
"a",
"global",
"override",
"of",
"any",
"injected",
"or",
"default",
"implementations",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/DurianPlugins.java#L68-L70 | train |
diffplug/durian | src/com/diffplug/common/base/DurianPlugins.java | DurianPlugins.getPluginImplementationViaProperty | private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
String className = pluginClass.getCanonicalName();
if (className == null) {
throw new IllegalArgumentException("Class " + pluginClass + " does not have a canonical name!");
}
// Check system properties for plugin class.
// Thi... | java | private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
String className = pluginClass.getCanonicalName();
if (className == null) {
throw new IllegalArgumentException("Class " + pluginClass + " does not have a canonical name!");
}
// Check system properties for plugin class.
// Thi... | [
"private",
"static",
"Object",
"getPluginImplementationViaProperty",
"(",
"Class",
"<",
"?",
">",
"pluginClass",
")",
"{",
"String",
"className",
"=",
"pluginClass",
".",
"getCanonicalName",
"(",
")",
";",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"throw... | Returns an implementation of the given class using the system properties as a registry. | [
"Returns",
"an",
"implementation",
"of",
"the",
"given",
"class",
"using",
"the",
"system",
"properties",
"as",
"a",
"registry",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/DurianPlugins.java#L109-L136 | train |
diffplug/durian | src/com/diffplug/common/base/Functions.java | Functions.forPredicate | public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
return predicate::test;
} | java | public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
return predicate::test;
} | [
"public",
"static",
"<",
"T",
">",
"Function",
"<",
"T",
",",
"Boolean",
">",
"forPredicate",
"(",
"Predicate",
"<",
"T",
">",
"predicate",
")",
"{",
"return",
"predicate",
"::",
"test",
";",
"}"
] | Creates a function that returns the same boolean output as the given predicate for all inputs.
<p>The returned function is <i>consistent with equals</i> (as documented at {@link
Function#apply}) if and only if {@code predicate} is itself consistent with equals. | [
"Creates",
"a",
"function",
"that",
"returns",
"the",
"same",
"boolean",
"output",
"as",
"the",
"given",
"predicate",
"for",
"all",
"inputs",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Functions.java#L97-L99 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.asOptionalLeft | public final Optional<L> asOptionalLeft() {
return fold(Optional::of, val -> Optional.<L> empty());
} | java | public final Optional<L> asOptionalLeft() {
return fold(Optional::of, val -> Optional.<L> empty());
} | [
"public",
"final",
"Optional",
"<",
"L",
">",
"asOptionalLeft",
"(",
")",
"{",
"return",
"fold",
"(",
"Optional",
"::",
"of",
",",
"val",
"->",
"Optional",
".",
"<",
"L",
">",
"empty",
"(",
")",
")",
";",
"}"
] | Returns the left side as an Optional. | [
"Returns",
"the",
"left",
"side",
"as",
"an",
"Optional",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L58-L60 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.asOptionalRight | public final Optional<R> asOptionalRight() {
return fold(val -> Optional.<R> empty(), Optional::of);
} | java | public final Optional<R> asOptionalRight() {
return fold(val -> Optional.<R> empty(), Optional::of);
} | [
"public",
"final",
"Optional",
"<",
"R",
">",
"asOptionalRight",
"(",
")",
"{",
"return",
"fold",
"(",
"val",
"->",
"Optional",
".",
"<",
"R",
">",
"empty",
"(",
")",
",",
"Optional",
"::",
"of",
")",
";",
"}"
] | Returns the right side as an Optional. | [
"Returns",
"the",
"right",
"side",
"as",
"an",
"Optional",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L63-L65 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.fold | public final <T> T fold(Function<? super L, ? extends T> left, Function<? super R, ? extends T> right) {
if (isLeft()) {
return left.apply(getLeft());
} else {
return right.apply(getRight());
}
} | java | public final <T> T fold(Function<? super L, ? extends T> left, Function<? super R, ? extends T> right) {
if (isLeft()) {
return left.apply(getLeft());
} else {
return right.apply(getRight());
}
} | [
"public",
"final",
"<",
"T",
">",
"T",
"fold",
"(",
"Function",
"<",
"?",
"super",
"L",
",",
"?",
"extends",
"T",
">",
"left",
",",
"Function",
"<",
"?",
"super",
"R",
",",
"?",
"extends",
"T",
">",
"right",
")",
"{",
"if",
"(",
"isLeft",
"(",
... | Applies either the left or the right function as appropriate. | [
"Applies",
"either",
"the",
"left",
"or",
"the",
"right",
"function",
"as",
"appropriate",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L68-L74 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.accept | public final void accept(Consumer<? super L> left, Consumer<? super R> right) {
if (isLeft()) {
left.accept(getLeft());
} else {
right.accept(getRight());
}
} | java | public final void accept(Consumer<? super L> left, Consumer<? super R> right) {
if (isLeft()) {
left.accept(getLeft());
} else {
right.accept(getRight());
}
} | [
"public",
"final",
"void",
"accept",
"(",
"Consumer",
"<",
"?",
"super",
"L",
">",
"left",
",",
"Consumer",
"<",
"?",
"super",
"R",
">",
"right",
")",
"{",
"if",
"(",
"isLeft",
"(",
")",
")",
"{",
"left",
".",
"accept",
"(",
"getLeft",
"(",
")",
... | Accepts either the left or the right consumer as appropriate. | [
"Accepts",
"either",
"the",
"left",
"or",
"the",
"right",
"consumer",
"as",
"appropriate",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L77-L83 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.acceptBoth | public final void acceptBoth(Consumer<? super L> left, Consumer<? super R> right, L defaultLeft, R defaultRight) {
left.accept(isLeft() ? getLeft() : defaultLeft);
right.accept(isRight() ? getRight() : defaultRight);
} | java | public final void acceptBoth(Consumer<? super L> left, Consumer<? super R> right, L defaultLeft, R defaultRight) {
left.accept(isLeft() ? getLeft() : defaultLeft);
right.accept(isRight() ? getRight() : defaultRight);
} | [
"public",
"final",
"void",
"acceptBoth",
"(",
"Consumer",
"<",
"?",
"super",
"L",
">",
"left",
",",
"Consumer",
"<",
"?",
"super",
"R",
">",
"right",
",",
"L",
"defaultLeft",
",",
"R",
"defaultRight",
")",
"{",
"left",
".",
"accept",
"(",
"isLeft",
"... | Accepts both the left and right consumers, using the default values to set the empty side. | [
"Accepts",
"both",
"the",
"left",
"and",
"right",
"consumers",
"using",
"the",
"default",
"values",
"to",
"set",
"the",
"empty",
"side",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L104-L107 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.create | public static <L, R> Either<L, R> create(L l, R r) {
if (l == null && r != null) {
return createRight(r);
} else if (l != null && r == null) {
return createLeft(l);
} else {
if (l == null) {
throw new IllegalArgumentException("Both arguments were null.");
} else {
throw new IllegalArgumentExce... | java | public static <L, R> Either<L, R> create(L l, R r) {
if (l == null && r != null) {
return createRight(r);
} else if (l != null && r == null) {
return createLeft(l);
} else {
if (l == null) {
throw new IllegalArgumentException("Both arguments were null.");
} else {
throw new IllegalArgumentExce... | [
"public",
"static",
"<",
"L",
",",
"R",
">",
"Either",
"<",
"L",
",",
"R",
">",
"create",
"(",
"L",
"l",
",",
"R",
"r",
")",
"{",
"if",
"(",
"l",
"==",
"null",
"&&",
"r",
"!=",
"null",
")",
"{",
"return",
"createRight",
"(",
"r",
")",
";",
... | Creates a left or right, depending on which element is non-null. Precisely one element should be non-null. | [
"Creates",
"a",
"left",
"or",
"right",
"depending",
"on",
"which",
"element",
"is",
"non",
"-",
"null",
".",
"Precisely",
"one",
"element",
"should",
"be",
"non",
"-",
"null",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L110-L122 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.createLeft | public static <L, R> Either<L, R> createLeft(L l) {
return new Left<>(l);
} | java | public static <L, R> Either<L, R> createLeft(L l) {
return new Left<>(l);
} | [
"public",
"static",
"<",
"L",
",",
"R",
">",
"Either",
"<",
"L",
",",
"R",
">",
"createLeft",
"(",
"L",
"l",
")",
"{",
"return",
"new",
"Left",
"<>",
"(",
"l",
")",
";",
"}"
] | Creates an instance of Left. | [
"Creates",
"an",
"instance",
"of",
"Left",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L125-L127 | train |
diffplug/durian | src/com/diffplug/common/base/Either.java | Either.createRight | public static <L, R> Either<L, R> createRight(R r) {
return new Right<>(r);
} | java | public static <L, R> Either<L, R> createRight(R r) {
return new Right<>(r);
} | [
"public",
"static",
"<",
"L",
",",
"R",
">",
"Either",
"<",
"L",
",",
"R",
">",
"createRight",
"(",
"R",
"r",
")",
"{",
"return",
"new",
"Right",
"<>",
"(",
"r",
")",
";",
"}"
] | Creates an instance of Right. | [
"Creates",
"an",
"instance",
"of",
"Right",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Either.java#L130-L132 | train |
diffplug/durian | src/com/diffplug/common/base/TreeComparison.java | TreeComparison.decorateErrorsWith | public TreeComparison<E, A> decorateErrorsWith(Function<? super E, String> expectedToString, Function<? super A, String> actualToString) {
this.expectedToString = expectedToString;
this.actualToString = actualToString;
return this;
} | java | public TreeComparison<E, A> decorateErrorsWith(Function<? super E, String> expectedToString, Function<? super A, String> actualToString) {
this.expectedToString = expectedToString;
this.actualToString = actualToString;
return this;
} | [
"public",
"TreeComparison",
"<",
"E",
",",
"A",
">",
"decorateErrorsWith",
"(",
"Function",
"<",
"?",
"super",
"E",
",",
"String",
">",
"expectedToString",
",",
"Function",
"<",
"?",
"super",
"A",
",",
"String",
">",
"actualToString",
")",
"{",
"this",
"... | Decorates errors thrown by any assertions with the given functions. | [
"Decorates",
"errors",
"thrown",
"by",
"any",
"assertions",
"with",
"the",
"given",
"functions",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeComparison.java#L102-L106 | train |
diffplug/durian | src/com/diffplug/common/base/TreeComparison.java | TreeComparison.createComparisonFailure | private AssertionError createComparisonFailure(String className, String expected, String actual) throws Exception {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(String.class, String.class, String.class);
return (AssertionError) constructor.newInstance("", expected, ... | java | private AssertionError createComparisonFailure(String className, String expected, String actual) throws Exception {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(String.class, String.class, String.class);
return (AssertionError) constructor.newInstance("", expected, ... | [
"private",
"AssertionError",
"createComparisonFailure",
"(",
"String",
"className",
",",
"String",
"expected",
",",
"String",
"actual",
")",
"throws",
"Exception",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
... | Attempts to create an instance of junit's ComparisonFailure exception using reflection. | [
"Attempts",
"to",
"create",
"an",
"instance",
"of",
"junit",
"s",
"ComparisonFailure",
"exception",
"using",
"reflection",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeComparison.java#L136-L140 | train |
diffplug/durian | src/com/diffplug/common/base/TreeComparison.java | TreeComparison.mapToSame | public <T> SameType<T> mapToSame(Function<? super E, ? extends T> mapExpected, Function<? super A, ? extends T> mapActual) {
return new SameTypeImp<>(this, mapExpected, mapActual);
} | java | public <T> SameType<T> mapToSame(Function<? super E, ? extends T> mapExpected, Function<? super A, ? extends T> mapActual) {
return new SameTypeImp<>(this, mapExpected, mapActual);
} | [
"public",
"<",
"T",
">",
"SameType",
"<",
"T",
">",
"mapToSame",
"(",
"Function",
"<",
"?",
"super",
"E",
",",
"?",
"extends",
"T",
">",
"mapExpected",
",",
"Function",
"<",
"?",
"super",
"A",
",",
"?",
"extends",
"T",
">",
"mapActual",
")",
"{",
... | Maps both sides of the comparison to the same type, for easier comparison and assertions. | [
"Maps",
"both",
"sides",
"of",
"the",
"comparison",
"to",
"the",
"same",
"type",
"for",
"easier",
"comparison",
"and",
"assertions",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeComparison.java#L143-L145 | train |
diffplug/durian | src/com/diffplug/common/base/TreeNode.java | TreeNode.sortChildrenByContent | public void sortChildrenByContent(Comparator<? super T> comparator) {
Comparator<TreeNode<T>> byContent = Comparator.comparing(TreeNode::getContent, comparator);
sortChildrenByNode(byContent);
} | java | public void sortChildrenByContent(Comparator<? super T> comparator) {
Comparator<TreeNode<T>> byContent = Comparator.comparing(TreeNode::getContent, comparator);
sortChildrenByNode(byContent);
} | [
"public",
"void",
"sortChildrenByContent",
"(",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"Comparator",
"<",
"TreeNode",
"<",
"T",
">>",
"byContent",
"=",
"Comparator",
".",
"comparing",
"(",
"TreeNode",
"::",
"getContent",
",",
"com... | Recursively sorts all children using the given comparator of their content. | [
"Recursively",
"sorts",
"all",
"children",
"using",
"the",
"given",
"comparator",
"of",
"their",
"content",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeNode.java#L123-L126 | train |
diffplug/durian | src/com/diffplug/common/base/TreeNode.java | TreeNode.sortChildrenByNode | public void sortChildrenByNode(Comparator<TreeNode<T>> comparator) {
Collections.sort(children, comparator);
for (TreeNode<T> child : children) {
child.sortChildrenByNode(comparator);
}
} | java | public void sortChildrenByNode(Comparator<TreeNode<T>> comparator) {
Collections.sort(children, comparator);
for (TreeNode<T> child : children) {
child.sortChildrenByNode(comparator);
}
} | [
"public",
"void",
"sortChildrenByNode",
"(",
"Comparator",
"<",
"TreeNode",
"<",
"T",
">",
">",
"comparator",
")",
"{",
"Collections",
".",
"sort",
"(",
"children",
",",
"comparator",
")",
";",
"for",
"(",
"TreeNode",
"<",
"T",
">",
"child",
":",
"childr... | Recursively sorts all children using the given comparator of TreeNode. | [
"Recursively",
"sorts",
"all",
"children",
"using",
"the",
"given",
"comparator",
"of",
"TreeNode",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeNode.java#L129-L134 | train |
diffplug/durian | src/com/diffplug/common/base/TreeNode.java | TreeNode.copy | public static <T> TreeNode<T> copy(TreeDef<T> treeDef, T root) {
return copy(treeDef, root, Function.identity());
} | java | public static <T> TreeNode<T> copy(TreeDef<T> treeDef, T root) {
return copy(treeDef, root, Function.identity());
} | [
"public",
"static",
"<",
"T",
">",
"TreeNode",
"<",
"T",
">",
"copy",
"(",
"TreeDef",
"<",
"T",
">",
"treeDef",
",",
"T",
"root",
")",
"{",
"return",
"copy",
"(",
"treeDef",
",",
"root",
",",
"Function",
".",
"identity",
"(",
")",
")",
";",
"}"
] | Creates a hierarchy of TreeNodes that copies the structure and content of the given tree. | [
"Creates",
"a",
"hierarchy",
"of",
"TreeNodes",
"that",
"copies",
"the",
"structure",
"and",
"content",
"of",
"the",
"given",
"tree",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeNode.java#L137-L139 | train |
diffplug/durian | src/com/diffplug/common/base/TreeNode.java | TreeNode.findByContent | public TreeNode<T> findByContent(T content) {
Optional<TreeNode<T>> opt = TreeStream.breadthFirst(treeDef(), this).filter(node -> node.getContent().equals(content)).findFirst();
if (opt.isPresent()) {
return opt.get();
} else {
throw new IllegalArgumentException(this.toString() + " has no child with content... | java | public TreeNode<T> findByContent(T content) {
Optional<TreeNode<T>> opt = TreeStream.breadthFirst(treeDef(), this).filter(node -> node.getContent().equals(content)).findFirst();
if (opt.isPresent()) {
return opt.get();
} else {
throw new IllegalArgumentException(this.toString() + " has no child with content... | [
"public",
"TreeNode",
"<",
"T",
">",
"findByContent",
"(",
"T",
"content",
")",
"{",
"Optional",
"<",
"TreeNode",
"<",
"T",
">>",
"opt",
"=",
"TreeStream",
".",
"breadthFirst",
"(",
"treeDef",
"(",
")",
",",
"this",
")",
".",
"filter",
"(",
"node",
"... | Searches breadth-first for the TreeNode with the given content.
@throws IllegalArgumentException if no such node exists | [
"Searches",
"breadth",
"-",
"first",
"for",
"the",
"TreeNode",
"with",
"the",
"given",
"content",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeNode.java#L271-L278 | train |
diffplug/durian | src/com/diffplug/common/base/TreeQuery.java | TreeQuery.isDescendantOf | public static <T> boolean isDescendantOf(TreeDef.Parented<T> treeDef, T child, T parent) {
T candidateParent = treeDef.parentOf(child);
while (candidateParent != null) {
if (candidateParent.equals(parent)) {
return true;
} else {
candidateParent = treeDef.parentOf(candidateParent);
}
}
return f... | java | public static <T> boolean isDescendantOf(TreeDef.Parented<T> treeDef, T child, T parent) {
T candidateParent = treeDef.parentOf(child);
while (candidateParent != null) {
if (candidateParent.equals(parent)) {
return true;
} else {
candidateParent = treeDef.parentOf(candidateParent);
}
}
return f... | [
"public",
"static",
"<",
"T",
">",
"boolean",
"isDescendantOf",
"(",
"TreeDef",
".",
"Parented",
"<",
"T",
">",
"treeDef",
",",
"T",
"child",
",",
"T",
"parent",
")",
"{",
"T",
"candidateParent",
"=",
"treeDef",
".",
"parentOf",
"(",
"child",
")",
";",... | Returns true iff child is a descendant of parent. | [
"Returns",
"true",
"iff",
"child",
"is",
"a",
"descendant",
"of",
"parent",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L34-L44 | train |
diffplug/durian | src/com/diffplug/common/base/TreeQuery.java | TreeQuery.isDescendantOfOrEqualTo | public static <T> boolean isDescendantOfOrEqualTo(TreeDef.Parented<T> treeDef, T child, T parent) {
if (child.equals(parent)) {
return true;
} else {
return isDescendantOf(treeDef, child, parent);
}
} | java | public static <T> boolean isDescendantOfOrEqualTo(TreeDef.Parented<T> treeDef, T child, T parent) {
if (child.equals(parent)) {
return true;
} else {
return isDescendantOf(treeDef, child, parent);
}
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"isDescendantOfOrEqualTo",
"(",
"TreeDef",
".",
"Parented",
"<",
"T",
">",
"treeDef",
",",
"T",
"child",
",",
"T",
"parent",
")",
"{",
"if",
"(",
"child",
".",
"equals",
"(",
"parent",
")",
")",
"{",
"ret... | Returns true iff child is a descendant of parent, or if child is equal to parent. | [
"Returns",
"true",
"iff",
"child",
"is",
"a",
"descendant",
"of",
"parent",
"or",
"if",
"child",
"is",
"equal",
"to",
"parent",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L47-L53 | train |
diffplug/durian | src/com/diffplug/common/base/TreeQuery.java | TreeQuery.root | public static <T> T root(TreeDef.Parented<T> treeDef, T node) {
T lastParent;
T parent = node;
do {
lastParent = parent;
parent = treeDef.parentOf(lastParent);
} while (parent != null);
return lastParent;
} | java | public static <T> T root(TreeDef.Parented<T> treeDef, T node) {
T lastParent;
T parent = node;
do {
lastParent = parent;
parent = treeDef.parentOf(lastParent);
} while (parent != null);
return lastParent;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"root",
"(",
"TreeDef",
".",
"Parented",
"<",
"T",
">",
"treeDef",
",",
"T",
"node",
")",
"{",
"T",
"lastParent",
";",
"T",
"parent",
"=",
"node",
";",
"do",
"{",
"lastParent",
"=",
"parent",
";",
"parent",
... | Returns the root of the given tree. | [
"Returns",
"the",
"root",
"of",
"the",
"given",
"tree",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L56-L64 | train |
diffplug/durian | src/com/diffplug/common/base/TreeQuery.java | TreeQuery.lowestCommonAncestor | private static <T> Optional<T> lowestCommonAncestor(TreeDef.Parented<T> treeDef, T nodeA, T nodeB) {
class TreeSearcher {
private T tip;
private final Set<T> visited;
public TreeSearcher(T start) {
this.tip = start;
this.visited = new HashSet<>();
}
public boolean hasMore() {
return tip !... | java | private static <T> Optional<T> lowestCommonAncestor(TreeDef.Parented<T> treeDef, T nodeA, T nodeB) {
class TreeSearcher {
private T tip;
private final Set<T> visited;
public TreeSearcher(T start) {
this.tip = start;
this.visited = new HashSet<>();
}
public boolean hasMore() {
return tip !... | [
"private",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"lowestCommonAncestor",
"(",
"TreeDef",
".",
"Parented",
"<",
"T",
">",
"treeDef",
",",
"T",
"nodeA",
",",
"T",
"nodeB",
")",
"{",
"class",
"TreeSearcher",
"{",
"private",
"T",
"tip",
";",
... | Returns the common parent of the two given elements. | [
"Returns",
"the",
"common",
"parent",
"of",
"the",
"two",
"given",
"elements",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L141-L189 | train |
diffplug/durian | src/com/diffplug/common/base/TreeQuery.java | TreeQuery.path | public static <T> String path(TreeDef.Parented<T> treeDef, T node, Function<? super T, String> toString, String delimiter) {
List<T> toRoot = toRoot(treeDef, node);
ListIterator<T> iterator = toRoot.listIterator(toRoot.size());
StringBuilder builder = new StringBuilder();
while (iterator.hasPrevious()) {
T s... | java | public static <T> String path(TreeDef.Parented<T> treeDef, T node, Function<? super T, String> toString, String delimiter) {
List<T> toRoot = toRoot(treeDef, node);
ListIterator<T> iterator = toRoot.listIterator(toRoot.size());
StringBuilder builder = new StringBuilder();
while (iterator.hasPrevious()) {
T s... | [
"public",
"static",
"<",
"T",
">",
"String",
"path",
"(",
"TreeDef",
".",
"Parented",
"<",
"T",
">",
"treeDef",
",",
"T",
"node",
",",
"Function",
"<",
"?",
"super",
"T",
",",
"String",
">",
"toString",
",",
"String",
"delimiter",
")",
"{",
"List",
... | Returns the path of the given node.
@param treeDef the treeDef
@param node the root of the tree
@param toString a function to map each node to a string in the path
@param delimiter a string to use as a path separator | [
"Returns",
"the",
"path",
"of",
"the",
"given",
"node",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L218-L232 | train |
diffplug/durian | src/com/diffplug/common/base/Errors.java | Errors.wrap | public Runnable wrap(Throwing.Runnable runnable) {
return () -> {
try {
runnable.run();
} catch (Throwable e) {
handler.accept(e);
}
};
} | java | public Runnable wrap(Throwing.Runnable runnable) {
return () -> {
try {
runnable.run();
} catch (Throwable e) {
handler.accept(e);
}
};
} | [
"public",
"Runnable",
"wrap",
"(",
"Throwing",
".",
"Runnable",
"runnable",
")",
"{",
"return",
"(",
")",
"->",
"{",
"try",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"handler",
".",
"accept",
"(",
"e... | Returns a Runnable whose exceptions are handled by this Errors. | [
"Returns",
"a",
"Runnable",
"whose",
"exceptions",
"are",
"handled",
"by",
"this",
"Errors",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Errors.java#L168-L176 | train |
diffplug/durian | src/com/diffplug/common/base/Errors.java | Errors.wrap | public <T> Consumer<T> wrap(Throwing.Consumer<T> consumer) {
return val -> {
try {
consumer.accept(val);
} catch (Throwable e) {
handler.accept(e);
}
};
} | java | public <T> Consumer<T> wrap(Throwing.Consumer<T> consumer) {
return val -> {
try {
consumer.accept(val);
} catch (Throwable e) {
handler.accept(e);
}
};
} | [
"public",
"<",
"T",
">",
"Consumer",
"<",
"T",
">",
"wrap",
"(",
"Throwing",
".",
"Consumer",
"<",
"T",
">",
"consumer",
")",
"{",
"return",
"val",
"->",
"{",
"try",
"{",
"consumer",
".",
"accept",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"Throwa... | Returns a Consumer whose exceptions are handled by this Errors. | [
"Returns",
"a",
"Consumer",
"whose",
"exceptions",
"are",
"handled",
"by",
"this",
"Errors",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Errors.java#L179-L187 | train |
diffplug/durian | src/com/diffplug/common/base/Errors.java | Errors.asRuntime | public static RuntimeException asRuntime(Throwable e) {
if (e instanceof RuntimeException) {
return (RuntimeException) e;
} else {
return new WrappedAsRuntimeException(e);
}
} | java | public static RuntimeException asRuntime(Throwable e) {
if (e instanceof RuntimeException) {
return (RuntimeException) e;
} else {
return new WrappedAsRuntimeException(e);
}
} | [
"public",
"static",
"RuntimeException",
"asRuntime",
"(",
"Throwable",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"RuntimeException",
")",
"{",
"return",
"(",
"RuntimeException",
")",
"e",
";",
"}",
"else",
"{",
"return",
"new",
"WrappedAsRuntimeException",
... | Casts or wraps the given exception to be a RuntimeException. | [
"Casts",
"or",
"wraps",
"the",
"given",
"exception",
"to",
"be",
"a",
"RuntimeException",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/Errors.java#L343-L349 | train |
diffplug/durian | src/com/diffplug/common/base/FieldsAndGetters.java | FieldsAndGetters.tryCall | private static Object tryCall(String methodName, Throwing.Supplier<Object> supplier) {
try {
return supplier.get();
} catch (Throwable error) {
return new CallException(methodName, error);
}
} | java | private static Object tryCall(String methodName, Throwing.Supplier<Object> supplier) {
try {
return supplier.get();
} catch (Throwable error) {
return new CallException(methodName, error);
}
} | [
"private",
"static",
"Object",
"tryCall",
"(",
"String",
"methodName",
",",
"Throwing",
".",
"Supplier",
"<",
"Object",
">",
"supplier",
")",
"{",
"try",
"{",
"return",
"supplier",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"error",
")",
... | Executes the given function, return any exceptions it might throw as wrapped values. | [
"Executes",
"the",
"given",
"function",
"return",
"any",
"exceptions",
"it",
"might",
"throw",
"as",
"wrapped",
"values",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/FieldsAndGetters.java#L102-L108 | train |
diffplug/durian | src/com/diffplug/common/base/FieldsAndGetters.java | FieldsAndGetters.createEntry | private static <K, V> Map.Entry<K, V> createEntry(K key, V value) {
return new Map.Entry<K, V>() {
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public V setValue(V value) {
throw new UnsupportedOperationException();
}
... | java | private static <K, V> Map.Entry<K, V> createEntry(K key, V value) {
return new Map.Entry<K, V>() {
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public V setValue(V value) {
throw new UnsupportedOperationException();
}
... | [
"private",
"static",
"<",
"K",
",",
"V",
">",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"createEntry",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"return",
"new",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"(",
")",
"{",
"@",
"Ove... | Creates an immutable Map.Entry. | [
"Creates",
"an",
"immutable",
"Map",
".",
"Entry",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/FieldsAndGetters.java#L198-L215 | train |
diffplug/durian | src/com/diffplug/common/base/StackDumper.java | StackDumper.dump | public static void dump(String message, Throwable exception) {
printEmphasized(StringPrinter.buildString(printer -> {
printer.println(message);
exception.printStackTrace(printer.toPrintWriter());
}));
} | java | public static void dump(String message, Throwable exception) {
printEmphasized(StringPrinter.buildString(printer -> {
printer.println(message);
exception.printStackTrace(printer.toPrintWriter());
}));
} | [
"public",
"static",
"void",
"dump",
"(",
"String",
"message",
",",
"Throwable",
"exception",
")",
"{",
"printEmphasized",
"(",
"StringPrinter",
".",
"buildString",
"(",
"printer",
"->",
"{",
"printer",
".",
"println",
"(",
"message",
")",
";",
"exception",
"... | Dumps the given message and exception stack to the system error console | [
"Dumps",
"the",
"given",
"message",
"and",
"exception",
"stack",
"to",
"the",
"system",
"error",
"console"
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StackDumper.java#L45-L50 | train |
diffplug/durian | src/com/diffplug/common/base/StackDumper.java | StackDumper.wrapAndDumpWhenContains | public static PrintStream wrapAndDumpWhenContains(PrintStream source, String trigger) {
StringPrinter wrapped = new StringPrinter(StringPrinter.stringsToLines(perLine -> {
source.println(perLine);
if (perLine.contains(trigger)) {
dump("Triggered by " + trigger);
}
}));
return wrapped.toPrintStream();... | java | public static PrintStream wrapAndDumpWhenContains(PrintStream source, String trigger) {
StringPrinter wrapped = new StringPrinter(StringPrinter.stringsToLines(perLine -> {
source.println(perLine);
if (perLine.contains(trigger)) {
dump("Triggered by " + trigger);
}
}));
return wrapped.toPrintStream();... | [
"public",
"static",
"PrintStream",
"wrapAndDumpWhenContains",
"(",
"PrintStream",
"source",
",",
"String",
"trigger",
")",
"{",
"StringPrinter",
"wrapped",
"=",
"new",
"StringPrinter",
"(",
"StringPrinter",
".",
"stringsToLines",
"(",
"perLine",
"->",
"{",
"source",... | Returns a PrintStream which will redirect all of its output to the source PrintStream. If
the trigger string is passed through the wrapped PrintStream, then it will dump the
stack trace of the call that printed the trigger.
@param source
the returned PrintStream will delegate to this stream
@param trigger
the string w... | [
"Returns",
"a",
"PrintStream",
"which",
"will",
"redirect",
"all",
"of",
"its",
"output",
"to",
"the",
"source",
"PrintStream",
".",
"If",
"the",
"trigger",
"string",
"is",
"passed",
"through",
"the",
"wrapped",
"PrintStream",
"then",
"it",
"will",
"dump",
"... | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StackDumper.java#L98-L106 | train |
diffplug/durian | src/com/diffplug/common/base/StackDumper.java | StackDumper.captureStackBelow | public static List<StackTraceElement> captureStackBelow(Class<?>... clazzes) {
List<Class<?>> toIgnore = new ArrayList<>(clazzes.length + 1);
toIgnore.addAll(Arrays.asList(clazzes));
toIgnore.add(StackDumper.class);
Predicate<StackTraceElement> isSkipped = element -> toIgnore.stream().anyMatch(clazz -> {
St... | java | public static List<StackTraceElement> captureStackBelow(Class<?>... clazzes) {
List<Class<?>> toIgnore = new ArrayList<>(clazzes.length + 1);
toIgnore.addAll(Arrays.asList(clazzes));
toIgnore.add(StackDumper.class);
Predicate<StackTraceElement> isSkipped = element -> toIgnore.stream().anyMatch(clazz -> {
St... | [
"public",
"static",
"List",
"<",
"StackTraceElement",
">",
"captureStackBelow",
"(",
"Class",
"<",
"?",
">",
"...",
"clazzes",
")",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"toIgnore",
"=",
"new",
"ArrayList",
"<>",
"(",
"clazzes",
".",
"length",
... | Captures all of the current stack which is below the given classes. | [
"Captures",
"all",
"of",
"the",
"current",
"stack",
"which",
"is",
"below",
"the",
"given",
"classes",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StackDumper.java#L126-L152 | train |
diffplug/durian | src/com/diffplug/common/base/StackDumper.java | StackDumper.printEmphasized | private static void printEmphasized(String toPrint) {
// print the triggered header
pristineSysErr.println("+----------\\");
for (String line : toPrint.split("\n")) {
pristineSysErr.println("| " + line);
}
pristineSysErr.println("+----------/");
} | java | private static void printEmphasized(String toPrint) {
// print the triggered header
pristineSysErr.println("+----------\\");
for (String line : toPrint.split("\n")) {
pristineSysErr.println("| " + line);
}
pristineSysErr.println("+----------/");
} | [
"private",
"static",
"void",
"printEmphasized",
"(",
"String",
"toPrint",
")",
"{",
"// print the triggered header",
"pristineSysErr",
".",
"println",
"(",
"\"+----------\\\\\"",
")",
";",
"for",
"(",
"String",
"line",
":",
"toPrint",
".",
"split",
"(",
"\"\\n\"",... | Prints the given string to the the given printer, wrapped in hierarchy-friendly
braces. Useful for emphasizing a specific event from a sea of logging statements. | [
"Prints",
"the",
"given",
"string",
"to",
"the",
"the",
"given",
"printer",
"wrapped",
"in",
"hierarchy",
"-",
"friendly",
"braces",
".",
"Useful",
"for",
"emphasizing",
"a",
"specific",
"event",
"from",
"a",
"sea",
"of",
"logging",
"statements",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StackDumper.java#L158-L165 | train |
diffplug/durian | src/com/diffplug/common/base/StringPrinter.java | StringPrinter.buildString | public static String buildString(Consumer<StringPrinter> printer) {
StringBuilder builder = new StringBuilder();
printer.accept(new StringPrinter(builder::append));
return builder.toString();
} | java | public static String buildString(Consumer<StringPrinter> printer) {
StringBuilder builder = new StringBuilder();
printer.accept(new StringPrinter(builder::append));
return builder.toString();
} | [
"public",
"static",
"String",
"buildString",
"(",
"Consumer",
"<",
"StringPrinter",
">",
"printer",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"printer",
".",
"accept",
"(",
"new",
"StringPrinter",
"(",
"builder",
"::",
... | Easy way to create a String using a StringPrinter. | [
"Easy",
"way",
"to",
"create",
"a",
"String",
"using",
"a",
"StringPrinter",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StringPrinter.java#L57-L61 | train |
diffplug/durian | src/com/diffplug/common/base/StringPrinter.java | StringPrinter.buildStringFromLines | public static String buildStringFromLines(String... lines) {
int numChars = lines.length;
for (String line : lines) {
numChars += line.length();
}
StringBuilder builder = new StringBuilder(numChars);
for (String line : lines) {
builder.append(line);
builder.append('\n');
}
return builder.toString... | java | public static String buildStringFromLines(String... lines) {
int numChars = lines.length;
for (String line : lines) {
numChars += line.length();
}
StringBuilder builder = new StringBuilder(numChars);
for (String line : lines) {
builder.append(line);
builder.append('\n');
}
return builder.toString... | [
"public",
"static",
"String",
"buildStringFromLines",
"(",
"String",
"...",
"lines",
")",
"{",
"int",
"numChars",
"=",
"lines",
".",
"length",
";",
"for",
"(",
"String",
"line",
":",
"lines",
")",
"{",
"numChars",
"+=",
"line",
".",
"length",
"(",
")",
... | Easy way to create a String from a bunch of lines. | [
"Easy",
"way",
"to",
"create",
"a",
"String",
"from",
"a",
"bunch",
"of",
"lines",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StringPrinter.java#L64-L75 | train |
diffplug/durian | src/com/diffplug/common/base/StringPrinter.java | StringPrinter.toPrintStream | public PrintStream toPrintStream(Charset charset) {
return Errors.rethrow().get(() -> {
return new PrintStream(toOutputStream(charset), true, charset.name());
});
} | java | public PrintStream toPrintStream(Charset charset) {
return Errors.rethrow().get(() -> {
return new PrintStream(toOutputStream(charset), true, charset.name());
});
} | [
"public",
"PrintStream",
"toPrintStream",
"(",
"Charset",
"charset",
")",
"{",
"return",
"Errors",
".",
"rethrow",
"(",
")",
".",
"get",
"(",
"(",
")",
"->",
"{",
"return",
"new",
"PrintStream",
"(",
"toOutputStream",
"(",
"charset",
")",
",",
"true",
",... | Creates a PrintStream of the given charset, which passes its content to this StringPrinter. | [
"Creates",
"a",
"PrintStream",
"of",
"the",
"given",
"charset",
"which",
"passes",
"its",
"content",
"to",
"this",
"StringPrinter",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StringPrinter.java#L154-L158 | train |
diffplug/durian | src/com/diffplug/common/base/StringPrinter.java | StringPrinter.toWriter | public Writer toWriter() {
return new Writer() {
@Override
public Writer append(char c) {
consumer.accept(new String(new char[]{c}));
return this;
}
@Override
public Writer append(CharSequence csq) {
if (csq instanceof String) {
consumer.accept((String) csq);
} else {
consume... | java | public Writer toWriter() {
return new Writer() {
@Override
public Writer append(char c) {
consumer.accept(new String(new char[]{c}));
return this;
}
@Override
public Writer append(CharSequence csq) {
if (csq instanceof String) {
consumer.accept((String) csq);
} else {
consume... | [
"public",
"Writer",
"toWriter",
"(",
")",
"{",
"return",
"new",
"Writer",
"(",
")",
"{",
"@",
"Override",
"public",
"Writer",
"append",
"(",
"char",
"c",
")",
"{",
"consumer",
".",
"accept",
"(",
"new",
"String",
"(",
"new",
"char",
"[",
"]",
"{",
... | Creates a Writer which passes its content to this StringPrinter. | [
"Creates",
"a",
"Writer",
"which",
"passes",
"its",
"content",
"to",
"this",
"StringPrinter",
"."
] | 10631a3480e5491eb6eb6ee06e752d8596914232 | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StringPrinter.java#L161-L227 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.getDouble | public static double getDouble(final String key) {
return Double.longBitsToDouble(getPreferences().getLong(key, Double.doubleToLongBits(0.0d)));
} | java | public static double getDouble(final String key) {
return Double.longBitsToDouble(getPreferences().getLong(key, Double.doubleToLongBits(0.0d)));
} | [
"public",
"static",
"double",
"getDouble",
"(",
"final",
"String",
"key",
")",
"{",
"return",
"Double",
".",
"longBitsToDouble",
"(",
"getPreferences",
"(",
")",
".",
"getLong",
"(",
"key",
",",
"Double",
".",
"doubleToLongBits",
"(",
"0.0d",
")",
")",
")"... | Returns the double that has been saved as a long raw bits value in the long preferences.
Returns 0 if the preference does not exist.
@param key The name of the preference to retrieve.
@return Returns the preference value if it exists, or 0.
@throws ClassCastException if there is a preference with this name that i... | [
"Returns",
"the",
"double",
"that",
"has",
"been",
"saved",
"as",
"a",
"long",
"raw",
"bits",
"value",
"in",
"the",
"long",
"preferences",
".",
"Returns",
"0",
"if",
"the",
"preference",
"does",
"not",
"exist",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L162-L164 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.getString | public static String getString(final String key, final String defValue) {
return getPreferences().getString(key, defValue);
} | java | public static String getString(final String key, final String defValue) {
return getPreferences().getString(key, defValue);
} | [
"public",
"static",
"String",
"getString",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"defValue",
")",
"{",
"return",
"getPreferences",
"(",
")",
".",
"getString",
"(",
"key",
",",
"defValue",
")",
";",
"}"
] | Retrieves a stored String value.
@param key The name of the preference to retrieve.
@param defValue Value to return if this preference does not exist.
@return Returns the preference value if it exists, or defValue.
@throws ClassCastException if there is a preference with this name that is not a String.
@see andro... | [
"Retrieves",
"a",
"stored",
"String",
"value",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L200-L202 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.putLong | public static void putLong(final String key, final long value) {
final Editor editor = getPreferences().edit();
editor.putLong(key, value);
editor.apply();
} | java | public static void putLong(final String key, final long value) {
final Editor editor = getPreferences().edit();
editor.putLong(key, value);
editor.apply();
} | [
"public",
"static",
"void",
"putLong",
"(",
"final",
"String",
"key",
",",
"final",
"long",
"value",
")",
"{",
"final",
"Editor",
"editor",
"=",
"getPreferences",
"(",
")",
".",
"edit",
"(",
")",
";",
"editor",
".",
"putLong",
"(",
"key",
",",
"value",... | Stores a long value.
@param key The name of the preference to modify.
@param value The new value for the preference.
@see android.content.SharedPreferences.Editor#putLong(String, long) | [
"Stores",
"a",
"long",
"value",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L277-L281 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.putDouble | public static void putDouble(final String key, final double value) {
final Editor editor = getPreferences().edit();
editor.putLong(key, Double.doubleToRawLongBits(value));
editor.apply();
} | java | public static void putDouble(final String key, final double value) {
final Editor editor = getPreferences().edit();
editor.putLong(key, Double.doubleToRawLongBits(value));
editor.apply();
} | [
"public",
"static",
"void",
"putDouble",
"(",
"final",
"String",
"key",
",",
"final",
"double",
"value",
")",
"{",
"final",
"Editor",
"editor",
"=",
"getPreferences",
"(",
")",
".",
"edit",
"(",
")",
";",
"editor",
".",
"putLong",
"(",
"key",
",",
"Dou... | Stores a double value as a long raw bits value.
@param key The name of the preference to modify.
@param value The double value to be save in the preferences.
@see android.content.SharedPreferences.Editor#putLong(String, long) | [
"Stores",
"a",
"double",
"value",
"as",
"a",
"long",
"raw",
"bits",
"value",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L303-L307 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.remove | public static void remove(final String key) {
SharedPreferences prefs = getPreferences();
final Editor editor = prefs.edit();
if (prefs.contains(key + LENGTH)) {
// Workaround for pre-HC's lack of StringSets
int stringSetLength = prefs.getInt(key + LENGTH, -1);
... | java | public static void remove(final String key) {
SharedPreferences prefs = getPreferences();
final Editor editor = prefs.edit();
if (prefs.contains(key + LENGTH)) {
// Workaround for pre-HC's lack of StringSets
int stringSetLength = prefs.getInt(key + LENGTH, -1);
... | [
"public",
"static",
"void",
"remove",
"(",
"final",
"String",
"key",
")",
"{",
"SharedPreferences",
"prefs",
"=",
"getPreferences",
"(",
")",
";",
"final",
"Editor",
"editor",
"=",
"prefs",
".",
"edit",
"(",
")",
";",
"if",
"(",
"prefs",
".",
"contains",... | Removes a preference value.
@param key The name of the preference to remove.
@see android.content.SharedPreferences.Editor#remove(String) | [
"Removes",
"a",
"preference",
"value",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L412-L428 | train |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.clear | public static Editor clear() {
final Editor editor = getPreferences().edit().clear();
editor.apply();
return editor;
} | java | public static Editor clear() {
final Editor editor = getPreferences().edit().clear();
editor.apply();
return editor;
} | [
"public",
"static",
"Editor",
"clear",
"(",
")",
"{",
"final",
"Editor",
"editor",
"=",
"getPreferences",
"(",
")",
".",
"edit",
"(",
")",
".",
"clear",
"(",
")",
";",
"editor",
".",
"apply",
"(",
")",
";",
"return",
"editor",
";",
"}"
] | Removed all the stored keys and values.
@return the {@link Editor} for chaining. The changes have already been committed/applied
through the execution of this method.
@see android.content.SharedPreferences.Editor#clear() | [
"Removed",
"all",
"the",
"stored",
"keys",
"and",
"values",
"."
] | 0ca13a403bf099019a13d68b38edcf55fca5a653 | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L448-L452 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/MarkdownTagletBase.java | MarkdownTagletBase.fetchMarkdownTagletDescriptionFile | protected String fetchMarkdownTagletDescriptionFile(String resourceName) {
final URL url = this.getClass().getResource(resourceName);
if( url!=null ) {
try {
return FileUtils.readFileToString(new File(url.toURI()));
} catch (Exception e) {
e.printS... | java | protected String fetchMarkdownTagletDescriptionFile(String resourceName) {
final URL url = this.getClass().getResource(resourceName);
if( url!=null ) {
try {
return FileUtils.readFileToString(new File(url.toURI()));
} catch (Exception e) {
e.printS... | [
"protected",
"String",
"fetchMarkdownTagletDescriptionFile",
"(",
"String",
"resourceName",
")",
"{",
"final",
"URL",
"url",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getResource",
"(",
"resourceName",
")",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
... | Fetch the markdown taglet description from a resource within your classpath.
@param resourceName the resourceName
@return the content of the resource file or *empty string*. | [
"Fetch",
"the",
"markdown",
"taglet",
"description",
"from",
"a",
"resource",
"within",
"your",
"classpath",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/MarkdownTagletBase.java#L148-L158 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/tags/TodoTagRenderer.java | TodoTagRenderer.render | @Override
public void render(Tag tag, StringBuilder target, MarkdownDoclet doclet) {
Counter counter;
if ( tag.holder() instanceof MemberDoc ) {
counter = getCounter(((MemberDoc)tag.holder()).containingClass());
}
else {
counter = getCounter(tag.holder());
... | java | @Override
public void render(Tag tag, StringBuilder target, MarkdownDoclet doclet) {
Counter counter;
if ( tag.holder() instanceof MemberDoc ) {
counter = getCounter(((MemberDoc)tag.holder()).containingClass());
}
else {
counter = getCounter(tag.holder());
... | [
"@",
"Override",
"public",
"void",
"render",
"(",
"Tag",
"tag",
",",
"StringBuilder",
"target",
",",
"MarkdownDoclet",
"doclet",
")",
"{",
"Counter",
"counter",
";",
"if",
"(",
"tag",
".",
"holder",
"(",
")",
"instanceof",
"MemberDoc",
")",
"{",
"counter",... | Render the tag.
@todo TODOs can also be used in member docs ...
@param tag The tag to render.
@param target The target {@link StringBuilder}.
@todo ... or even parameter docs -- which is a little strange, actually. ;)
@param doclet The doclet. | [
"Render",
"the",
"tag",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/tags/TodoTagRenderer.java#L67-L85 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/RootDocWrapper.java | RootDocWrapper.appendOption | public void appendOption(String... option) {
options = Arrays.copyOf(options, options.length + 1);
options[options.length - 1] = option;
} | java | public void appendOption(String... option) {
options = Arrays.copyOf(options, options.length + 1);
options[options.length - 1] = option;
} | [
"public",
"void",
"appendOption",
"(",
"String",
"...",
"option",
")",
"{",
"options",
"=",
"Arrays",
".",
"copyOf",
"(",
"options",
",",
"options",
".",
"length",
"+",
"1",
")",
";",
"options",
"[",
"options",
".",
"length",
"-",
"1",
"]",
"=",
"opt... | Append an option to the doclet options.
@param option The option to append. | [
"Append",
"an",
"option",
"to",
"the",
"doclet",
"options",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/RootDocWrapper.java#L52-L55 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.processOverview | protected void processOverview() {
if ( options.getOverviewFile() != null ) {
try {
rootDoc.setRawCommentText(Files.toString(options.getOverviewFile(), options.getEncoding()));
defaultProcess(rootDoc, false);
}
catch ( IOException e ) {
... | java | protected void processOverview() {
if ( options.getOverviewFile() != null ) {
try {
rootDoc.setRawCommentText(Files.toString(options.getOverviewFile(), options.getEncoding()));
defaultProcess(rootDoc, false);
}
catch ( IOException e ) {
... | [
"protected",
"void",
"processOverview",
"(",
")",
"{",
"if",
"(",
"options",
".",
"getOverviewFile",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"rootDoc",
".",
"setRawCommentText",
"(",
"Files",
".",
"toString",
"(",
"options",
".",
"getOverviewFile",
"... | Process the overview file, if specified. | [
"Process",
"the",
"overview",
"file",
"if",
"specified",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L289-L300 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.processClass | protected void processClass(ClassDoc doc) {
defaultProcess(doc, true);
for ( MemberDoc member : doc.fields() ) {
processMember(member);
}
for ( MemberDoc member : doc.constructors() ) {
processMember(member);
}
for ( MemberDoc member : doc.methods(... | java | protected void processClass(ClassDoc doc) {
defaultProcess(doc, true);
for ( MemberDoc member : doc.fields() ) {
processMember(member);
}
for ( MemberDoc member : doc.constructors() ) {
processMember(member);
}
for ( MemberDoc member : doc.methods(... | [
"protected",
"void",
"processClass",
"(",
"ClassDoc",
"doc",
")",
"{",
"defaultProcess",
"(",
"doc",
",",
"true",
")",
";",
"for",
"(",
"MemberDoc",
"member",
":",
"doc",
".",
"fields",
"(",
")",
")",
"{",
"processMember",
"(",
"member",
")",
";",
"}",... | Process the class documentation.
@param doc The class documentation. | [
"Process",
"the",
"class",
"documentation",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L307-L323 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.processPackage | protected void processPackage(PackageDoc doc) {
// (#1) Set foundDoc to false if possible.
// foundDoc will be set to true when setRawCommentText() is called, if the method
// is called again, JavaDoc will issue a warning about multiple sources for the
// package documentation. If there ... | java | protected void processPackage(PackageDoc doc) {
// (#1) Set foundDoc to false if possible.
// foundDoc will be set to true when setRawCommentText() is called, if the method
// is called again, JavaDoc will issue a warning about multiple sources for the
// package documentation. If there ... | [
"protected",
"void",
"processPackage",
"(",
"PackageDoc",
"doc",
")",
"{",
"// (#1) Set foundDoc to false if possible.",
"// foundDoc will be set to true when setRawCommentText() is called, if the method",
"// is called again, JavaDoc will issue a warning about multiple sources for the",
"// p... | Process the package documentation.
@param doc The package documentation. | [
"Process",
"the",
"package",
"documentation",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L339-L357 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.defaultProcess | protected void defaultProcess(Doc doc, boolean fixLeadingSpaces) {
try {
StringBuilder buf = new StringBuilder();
buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces));
buf.append('\n');
for ( Tag tag : doc.tags() ) {
processTag(tag,... | java | protected void defaultProcess(Doc doc, boolean fixLeadingSpaces) {
try {
StringBuilder buf = new StringBuilder();
buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces));
buf.append('\n');
for ( Tag tag : doc.tags() ) {
processTag(tag,... | [
"protected",
"void",
"defaultProcess",
"(",
"Doc",
"doc",
",",
"boolean",
"fixLeadingSpaces",
")",
"{",
"try",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"getOptions",
"(",
")",
".",
"toHtml",
"(",
... | Default processing of any documentation node.
@param doc The documentation.
@param fixLeadingSpaces `true` if leading spaces should be fixed.
@see Options#toHtml(String, boolean) | [
"Default",
"processing",
"of",
"any",
"documentation",
"node",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L367-L399 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.processTag | @SuppressWarnings("unchecked")
protected void processTag(Tag tag, StringBuilder target) {
TagRenderer<Tag> renderer = (TagRenderer<Tag>)tagRenderers.get(tag.kind());
if ( renderer == null ) {
renderer = TagRenderer.VERBATIM;
}
renderer.render(tag, target, this);
} | java | @SuppressWarnings("unchecked")
protected void processTag(Tag tag, StringBuilder target) {
TagRenderer<Tag> renderer = (TagRenderer<Tag>)tagRenderers.get(tag.kind());
if ( renderer == null ) {
renderer = TagRenderer.VERBATIM;
}
renderer.render(tag, target, this);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"processTag",
"(",
"Tag",
"tag",
",",
"StringBuilder",
"target",
")",
"{",
"TagRenderer",
"<",
"Tag",
">",
"renderer",
"=",
"(",
"TagRenderer",
"<",
"Tag",
">",
")",
"tagRenderers",
"."... | Process a tag.
@param tag The tag.
@param target The target string builder. | [
"Process",
"a",
"tag",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L407-L414 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java | MarkdownDoclet.main | public static void main(String[] args) throws Exception {
args = Arrays.copyOf(args, args.length + 2);
args[args.length - 2] = "-doclet";
args[args.length - 1] = MarkdownDoclet.class.getName();
Main.main(args);
} | java | public static void main(String[] args) throws Exception {
args = Arrays.copyOf(args, args.length + 2);
args[args.length - 2] = "-doclet";
args[args.length - 1] = MarkdownDoclet.class.getName();
Main.main(args);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"args",
"=",
"Arrays",
".",
"copyOf",
"(",
"args",
",",
"args",
".",
"length",
"+",
"2",
")",
";",
"args",
"[",
"args",
".",
"length",
"-",
"2",
... | Just a main method for debugging.
@param args The command line arguments.
@throws Exception If anything goes wrong. | [
"Just",
"a",
"main",
"method",
"for",
"debugging",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/MarkdownDoclet.java#L520-L525 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/Options.java | Options.load | public String[][] load(String[][] options, DocErrorReporter errorReporter) {
LinkedList<String[]> optionsList = new LinkedList<>(Arrays.asList(options));
Iterator<String[]> optionsIter = optionsList.iterator();
while ( optionsIter.hasNext() ) {
String[] opt = optionsIter.next();
... | java | public String[][] load(String[][] options, DocErrorReporter errorReporter) {
LinkedList<String[]> optionsList = new LinkedList<>(Arrays.asList(options));
Iterator<String[]> optionsIter = optionsList.iterator();
while ( optionsIter.hasNext() ) {
String[] opt = optionsIter.next();
... | [
"public",
"String",
"[",
"]",
"[",
"]",
"load",
"(",
"String",
"[",
"]",
"[",
"]",
"options",
",",
"DocErrorReporter",
"errorReporter",
")",
"{",
"LinkedList",
"<",
"String",
"[",
"]",
">",
"optionsList",
"=",
"new",
"LinkedList",
"<>",
"(",
"Arrays",
... | Loads the options from the command line.
@param options The command line options.
@param errorReporter The error reporter for printing messages.
@return The options to be forwarded to the standard doclet. | [
"Loads",
"the",
"options",
"from",
"the",
"command",
"line",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/Options.java#L130-L143 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/Options.java | Options.getJavadocVersion | public JavadocQuirks getJavadocVersion() {
if ( javadocVersion == null ) {
String javaVersion = System.getProperty("java.version");
if ( javaVersion != null && javaVersion.compareTo("1.8") >= 0 ) {
return JavadocQuirks.V8;
}
else {
... | java | public JavadocQuirks getJavadocVersion() {
if ( javadocVersion == null ) {
String javaVersion = System.getProperty("java.version");
if ( javaVersion != null && javaVersion.compareTo("1.8") >= 0 ) {
return JavadocQuirks.V8;
}
else {
... | [
"public",
"JavadocQuirks",
"getJavadocVersion",
"(",
")",
"{",
"if",
"(",
"javadocVersion",
"==",
"null",
")",
"{",
"String",
"javaVersion",
"=",
"System",
".",
"getProperty",
"(",
"\"java.version\"",
")",
";",
"if",
"(",
"javaVersion",
"!=",
"null",
"&&",
"... | Gets the Javadoc version.
@return The Javadoc version. | [
"Gets",
"the",
"Javadoc",
"version",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/Options.java#L355-L366 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/DocletSerializer.java | DocletSerializer.visit | @Override
public void visit(VerbatimNode node) {
if ( options.isHighlightEnabled() && !options.isAutoHighlightEnabled() && node.getType().isEmpty() ) {
VerbatimNode noHighlightNode = new VerbatimNode(node.getText(), "no-highlight");
noHighlightNode.setStartIndex(node.getStartIndex())... | java | @Override
public void visit(VerbatimNode node) {
if ( options.isHighlightEnabled() && !options.isAutoHighlightEnabled() && node.getType().isEmpty() ) {
VerbatimNode noHighlightNode = new VerbatimNode(node.getText(), "no-highlight");
noHighlightNode.setStartIndex(node.getStartIndex())... | [
"@",
"Override",
"public",
"void",
"visit",
"(",
"VerbatimNode",
"node",
")",
"{",
"if",
"(",
"options",
".",
"isHighlightEnabled",
"(",
")",
"&&",
"!",
"options",
".",
"isAutoHighlightEnabled",
"(",
")",
"&&",
"node",
".",
"getType",
"(",
")",
".",
"isE... | Overrides the default implementation to set the language to "no-highlight" no
language is specified. If highlighting is disabled or auto-highlighting is enabled,
this method just calls the default implementation.
@param node The AST node. | [
"Overrides",
"the",
"default",
"implementation",
"to",
"set",
"the",
"language",
"to",
"no",
"-",
"highlight",
"no",
"language",
"is",
"specified",
".",
"If",
"highlighting",
"is",
"disabled",
"or",
"auto",
"-",
"highlighting",
"is",
"enabled",
"this",
"method... | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/DocletSerializer.java#L47-L58 | train |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/MarkdownTagletExecutor.java | MarkdownTagletExecutor.createTagletPattern | private static String createTagletPattern(String tagNames) {
final StringBuilder regex = new StringBuilder();
final int size = STR_TAGS_REGEX_LIST.size();
for (int regexIdx = 0; regexIdx < size; regexIdx++) {
final String tagRegex = STR_TAGS_REGEX_LIST.get(regexIdx);
fina... | java | private static String createTagletPattern(String tagNames) {
final StringBuilder regex = new StringBuilder();
final int size = STR_TAGS_REGEX_LIST.size();
for (int regexIdx = 0; regexIdx < size; regexIdx++) {
final String tagRegex = STR_TAGS_REGEX_LIST.get(regexIdx);
fina... | [
"private",
"static",
"String",
"createTagletPattern",
"(",
"String",
"tagNames",
")",
"{",
"final",
"StringBuilder",
"regex",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"int",
"size",
"=",
"STR_TAGS_REGEX_LIST",
".",
"size",
"(",
")",
";",
"for",
"... | Creates the taglet pattern from `tagNames`.
@param tagNames the tag names
@return the regex for the known taglets. | [
"Creates",
"the",
"taglet",
"pattern",
"from",
"tagNames",
"."
] | e98a9630206fc9c8d813cf2349ff594be8630054 | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/MarkdownTagletExecutor.java#L299-L312 | train |
sculptor/sculptor | sculptor-framework/sculptor-framework-main/src/main/java/org/sculptor/framework/context/ServiceContextFactory.java | ServiceContextFactory.createServiceContext | public static ServiceContext createServiceContext(ServletRequest request) {
if (!(request instanceof HttpServletRequest)) {
throw new IllegalArgumentException("Expected HttpServletRequest");
}
return createServiceContext((HttpServletRequest) request);
} | java | public static ServiceContext createServiceContext(ServletRequest request) {
if (!(request instanceof HttpServletRequest)) {
throw new IllegalArgumentException("Expected HttpServletRequest");
}
return createServiceContext((HttpServletRequest) request);
} | [
"public",
"static",
"ServiceContext",
"createServiceContext",
"(",
"ServletRequest",
"request",
")",
"{",
"if",
"(",
"!",
"(",
"request",
"instanceof",
"HttpServletRequest",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected HttpServletRequest\"... | Convenience method, it requires that the request is a HttpServletRequest.
@see #createServiceContext(HttpServletRequest) | [
"Convenience",
"method",
"it",
"requires",
"that",
"the",
"request",
"is",
"a",
"HttpServletRequest",
"."
] | 38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5 | https://github.com/sculptor/sculptor/blob/38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5/sculptor-framework/sculptor-framework-main/src/main/java/org/sculptor/framework/context/ServiceContextFactory.java#L79-L84 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.