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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java | Player.loadPlayers | public static List<Player> loadPlayers(List<String> playersFiles) throws PlayerException {
log.info("[loadPlayers] Loading all players");
List<Player> players = new ArrayList<>();
if (playersFiles.size() < 1) {
log.warn("[loadPlayers] No players to load");
}
for (String singlePath : playersFiles) {
Player single = new Player(new File(singlePath));
players.add(single);
}
return players;
} | java | public static List<Player> loadPlayers(List<String> playersFiles) throws PlayerException {
log.info("[loadPlayers] Loading all players");
List<Player> players = new ArrayList<>();
if (playersFiles.size() < 1) {
log.warn("[loadPlayers] No players to load");
}
for (String singlePath : playersFiles) {
Player single = new Player(new File(singlePath));
players.add(single);
}
return players;
} | [
"public",
"static",
"List",
"<",
"Player",
">",
"loadPlayers",
"(",
"List",
"<",
"String",
">",
"playersFiles",
")",
"throws",
"PlayerException",
"{",
"log",
".",
"info",
"(",
"\"[loadPlayers] Loading all players\"",
")",
";",
"List",
"<",
"Player",
">",
"play... | Creates a list of players using the paths provided
@param playersFiles list of paths (jars or dirs) to the players code
@return list of all created players
@throws PlayerException if there was a problem loading one of the players | [
"Creates",
"a",
"list",
"of",
"players",
"using",
"the",
"paths",
"provided"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java#L221-L234 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/DashboardCache.java | DashboardCache.add | public void add(Collection<Dashboard> dashboards)
{
for(Dashboard dashboard : dashboards)
this.dashboards.put(dashboard.getId(), dashboard);
} | java | public void add(Collection<Dashboard> dashboards)
{
for(Dashboard dashboard : dashboards)
this.dashboards.put(dashboard.getId(), dashboard);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"Dashboard",
">",
"dashboards",
")",
"{",
"for",
"(",
"Dashboard",
"dashboard",
":",
"dashboards",
")",
"this",
".",
"dashboards",
".",
"put",
"(",
"dashboard",
".",
"getId",
"(",
")",
",",
"dashboard",
")... | Adds the dashboard list to the dashboards for the account.
@param dashboards The dashboards to add | [
"Adds",
"the",
"dashboard",
"list",
"to",
"the",
"dashboards",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/DashboardCache.java#L55-L59 | train |
pierre/serialization | writer/src/main/java/com/ning/metrics/serialization/writer/ThresholdEventWriter.java | ThresholdEventWriter.write | @Override
public synchronized void write(final Event event) throws IOException
{
if (!acceptsEvents) {
log.warn("Writer not ready, discarding event: {}", event);
return;
}
delegate.write(event);
uncommittedWriteCount++;
commitIfNeeded();
} | java | @Override
public synchronized void write(final Event event) throws IOException
{
if (!acceptsEvents) {
log.warn("Writer not ready, discarding event: {}", event);
return;
}
delegate.write(event);
uncommittedWriteCount++;
commitIfNeeded();
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"write",
"(",
"final",
"Event",
"event",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"acceptsEvents",
")",
"{",
"log",
".",
"warn",
"(",
"\"Writer not ready, discarding event: {}\"",
",",
"event",
")",
... | Write an Event via the delegate writer
@param event the Event to write
@throws IOException as thrown by the delegate writer | [
"Write",
"an",
"Event",
"via",
"the",
"delegate",
"writer"
] | b15b7c749ba78bfe94dce8fc22f31b30b2e6830b | https://github.com/pierre/serialization/blob/b15b7c749ba78bfe94dce8fc22f31b30b2e6830b/writer/src/main/java/com/ning/metrics/serialization/writer/ThresholdEventWriter.java#L84-L96 | train |
pierre/serialization | writer/src/main/java/com/ning/metrics/serialization/writer/ThresholdEventWriter.java | ThresholdEventWriter.forceCommit | @Managed(description = "Commit locally spooled events for flushing")
@Override
public synchronized void forceCommit() throws IOException
{
log.debug("Performing commit on delegate EventWriter [{}]", delegate.getClass());
delegate.commit();
uncommittedWriteCount = 0;
lastCommitNanos = getNow();
} | java | @Managed(description = "Commit locally spooled events for flushing")
@Override
public synchronized void forceCommit() throws IOException
{
log.debug("Performing commit on delegate EventWriter [{}]", delegate.getClass());
delegate.commit();
uncommittedWriteCount = 0;
lastCommitNanos = getNow();
} | [
"@",
"Managed",
"(",
"description",
"=",
"\"Commit locally spooled events for flushing\"",
")",
"@",
"Override",
"public",
"synchronized",
"void",
"forceCommit",
"(",
")",
"throws",
"IOException",
"{",
"log",
".",
"debug",
"(",
"\"Performing commit on delegate EventWriter... | Perform a commit via the delegate writer
@throws IOException as thrown by the delegate writer | [
"Perform",
"a",
"commit",
"via",
"the",
"delegate",
"writer"
] | b15b7c749ba78bfe94dce8fc22f31b30b2e6830b | https://github.com/pierre/serialization/blob/b15b7c749ba78bfe94dce8fc22f31b30b2e6830b/writer/src/main/java/com/ning/metrics/serialization/writer/ThresholdEventWriter.java#L103-L112 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/util/OptionalFunction.java | OptionalFunction.orElse | public OptionalFunction<T, R> orElse(Supplier<R> supplier) {
return new OptionalFunction<>(function, supplier);
} | java | public OptionalFunction<T, R> orElse(Supplier<R> supplier) {
return new OptionalFunction<>(function, supplier);
} | [
"public",
"OptionalFunction",
"<",
"T",
",",
"R",
">",
"orElse",
"(",
"Supplier",
"<",
"R",
">",
"supplier",
")",
"{",
"return",
"new",
"OptionalFunction",
"<>",
"(",
"function",
",",
"supplier",
")",
";",
"}"
] | Creates a new OptionalFunction that will use the given function for null values.
@param supplier the supplier to use for null values.
@return a new OptionalFunction | [
"Creates",
"a",
"new",
"OptionalFunction",
"that",
"will",
"use",
"the",
"given",
"function",
"for",
"null",
"values",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/util/OptionalFunction.java#L52-L54 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/util/OptionalFunction.java | OptionalFunction.orElseThrow | public OptionalFunction<T, R> orElseThrow(Supplier<? extends RuntimeException> exceptionSupplier) {
return new OptionalFunction<>(this.function, () -> {
throw exceptionSupplier.get();
});
} | java | public OptionalFunction<T, R> orElseThrow(Supplier<? extends RuntimeException> exceptionSupplier) {
return new OptionalFunction<>(this.function, () -> {
throw exceptionSupplier.get();
});
} | [
"public",
"OptionalFunction",
"<",
"T",
",",
"R",
">",
"orElseThrow",
"(",
"Supplier",
"<",
"?",
"extends",
"RuntimeException",
">",
"exceptionSupplier",
")",
"{",
"return",
"new",
"OptionalFunction",
"<>",
"(",
"this",
".",
"function",
",",
"(",
")",
"->",
... | Creates a new OptionalFunction that will throw the exception supplied by the given
supplier for null values.
@param exceptionSupplier the supplier to use when this function is called with a null value
@return a new OptionalFunction | [
"Creates",
"a",
"new",
"OptionalFunction",
"that",
"will",
"throw",
"the",
"exception",
"supplied",
"by",
"the",
"given",
"supplier",
"for",
"null",
"values",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/util/OptionalFunction.java#L74-L78 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/AppTimeZone.java | AppTimeZone.getTimeZone | public static TimeZone getTimeZone(String name)
{
TimeZone ret = null;
if(timezones != null)
{
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getName().equals(name))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | java | public static TimeZone getTimeZone(String name)
{
TimeZone ret = null;
if(timezones != null)
{
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getName().equals(name))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | [
"public",
"static",
"TimeZone",
"getTimeZone",
"(",
"String",
"name",
")",
"{",
"TimeZone",
"ret",
"=",
"null",
";",
"if",
"(",
"timezones",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"timezones",
".",
"length",
"&&",
... | Returns the cached timezone with the given name.
@param name The name of the timezone
@return The cached timezone with the given name | [
"Returns",
"the",
"cached",
"timezone",
"with",
"the",
"given",
"name",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/AppTimeZone.java#L176-L188 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/AppTimeZone.java | AppTimeZone.getTimeZoneById | public static TimeZone getTimeZoneById(String id)
{
TimeZone ret = null;
if(timezones != null)
{
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getId().equals(id))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | java | public static TimeZone getTimeZoneById(String id)
{
TimeZone ret = null;
if(timezones != null)
{
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getId().equals(id))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | [
"public",
"static",
"TimeZone",
"getTimeZoneById",
"(",
"String",
"id",
")",
"{",
"TimeZone",
"ret",
"=",
"null",
";",
"if",
"(",
"timezones",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"timezones",
".",
"length",
"&&",
... | Returns the cached timezone with the given ID.
@param id The id of the timezone
@return The cached timezone with the given ID | [
"Returns",
"the",
"cached",
"timezone",
"with",
"the",
"given",
"ID",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/AppTimeZone.java#L195-L207 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/AppTimeZone.java | AppTimeZone.getTimeZoneByIdIgnoreCase | public static TimeZone getTimeZoneByIdIgnoreCase(String id)
{
TimeZone ret = null;
if(timezones != null)
{
id = id.toLowerCase();
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getId().toLowerCase().equals(id))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | java | public static TimeZone getTimeZoneByIdIgnoreCase(String id)
{
TimeZone ret = null;
if(timezones != null)
{
id = id.toLowerCase();
for(int i = 0; i < timezones.length && ret == null; i++)
{
if(timezones[i].getId().toLowerCase().equals(id))
ret = timezones[i].getTimeZone();
}
}
return ret;
} | [
"public",
"static",
"TimeZone",
"getTimeZoneByIdIgnoreCase",
"(",
"String",
"id",
")",
"{",
"TimeZone",
"ret",
"=",
"null",
";",
"if",
"(",
"timezones",
"!=",
"null",
")",
"{",
"id",
"=",
"id",
".",
"toLowerCase",
"(",
")",
";",
"for",
"(",
"int",
"i",... | Returns the cached timezone with the given ID ignoring case.
@param id The id of the timezone
@return The cached timezone with the given ID | [
"Returns",
"the",
"cached",
"timezone",
"with",
"the",
"given",
"ID",
"ignoring",
"case",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/AppTimeZone.java#L214-L227 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/AppTimeZone.java | AppTimeZone.getDisplayName | private String getDisplayName()
{
long hours = TimeUnit.MILLISECONDS.toHours(tz.getRawOffset());
long minutes = Math.abs(TimeUnit.MILLISECONDS.toMinutes(tz.getRawOffset())
-TimeUnit.HOURS.toMinutes(hours));
return String.format("(GMT%+d:%02d) %s", hours, minutes, tz.getID());
} | java | private String getDisplayName()
{
long hours = TimeUnit.MILLISECONDS.toHours(tz.getRawOffset());
long minutes = Math.abs(TimeUnit.MILLISECONDS.toMinutes(tz.getRawOffset())
-TimeUnit.HOURS.toMinutes(hours));
return String.format("(GMT%+d:%02d) %s", hours, minutes, tz.getID());
} | [
"private",
"String",
"getDisplayName",
"(",
")",
"{",
"long",
"hours",
"=",
"TimeUnit",
".",
"MILLISECONDS",
".",
"toHours",
"(",
"tz",
".",
"getRawOffset",
"(",
")",
")",
";",
"long",
"minutes",
"=",
"Math",
".",
"abs",
"(",
"TimeUnit",
".",
"MILLISECON... | Returns the display name of the timezone.
@return The display name of the timezone | [
"Returns",
"the",
"display",
"name",
"of",
"the",
"timezone",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/AppTimeZone.java#L233-L239 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java | MandatoryWarningHandler.report | public void report(DiagnosticPosition pos, String msg, Object... args) {
JavaFileObject currentSource = log.currentSourceFile();
if (verbose) {
if (sourcesWithReportedWarnings == null)
sourcesWithReportedWarnings = new HashSet<JavaFileObject>();
if (log.nwarnings < log.MaxWarnings) {
// generate message and remember the source file
logMandatoryWarning(pos, msg, args);
sourcesWithReportedWarnings.add(currentSource);
} else if (deferredDiagnosticKind == null) {
// set up deferred message
if (sourcesWithReportedWarnings.contains(currentSource)) {
// more errors in a file that already has reported warnings
deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILE;
} else {
// warnings in a new source file
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
}
deferredDiagnosticSource = currentSource;
deferredDiagnosticArg = currentSource;
} else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE
|| deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE)
&& !equal(deferredDiagnosticSource, currentSource)) {
// additional errors in more than one source file
deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES;
deferredDiagnosticArg = null;
}
} else {
if (deferredDiagnosticKind == null) {
// warnings in a single source
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
deferredDiagnosticSource = currentSource;
deferredDiagnosticArg = currentSource;
} else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE &&
!equal(deferredDiagnosticSource, currentSource)) {
// warnings in multiple source files
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES;
deferredDiagnosticArg = null;
}
}
} | java | public void report(DiagnosticPosition pos, String msg, Object... args) {
JavaFileObject currentSource = log.currentSourceFile();
if (verbose) {
if (sourcesWithReportedWarnings == null)
sourcesWithReportedWarnings = new HashSet<JavaFileObject>();
if (log.nwarnings < log.MaxWarnings) {
// generate message and remember the source file
logMandatoryWarning(pos, msg, args);
sourcesWithReportedWarnings.add(currentSource);
} else if (deferredDiagnosticKind == null) {
// set up deferred message
if (sourcesWithReportedWarnings.contains(currentSource)) {
// more errors in a file that already has reported warnings
deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILE;
} else {
// warnings in a new source file
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
}
deferredDiagnosticSource = currentSource;
deferredDiagnosticArg = currentSource;
} else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE
|| deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE)
&& !equal(deferredDiagnosticSource, currentSource)) {
// additional errors in more than one source file
deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES;
deferredDiagnosticArg = null;
}
} else {
if (deferredDiagnosticKind == null) {
// warnings in a single source
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
deferredDiagnosticSource = currentSource;
deferredDiagnosticArg = currentSource;
} else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE &&
!equal(deferredDiagnosticSource, currentSource)) {
// warnings in multiple source files
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES;
deferredDiagnosticArg = null;
}
}
} | [
"public",
"void",
"report",
"(",
"DiagnosticPosition",
"pos",
",",
"String",
"msg",
",",
"Object",
"...",
"args",
")",
"{",
"JavaFileObject",
"currentSource",
"=",
"log",
".",
"currentSourceFile",
"(",
")",
";",
"if",
"(",
"verbose",
")",
"{",
"if",
"(",
... | Report a mandatory warning. | [
"Report",
"a",
"mandatory",
"warning",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java#L124-L166 | train |
syphr42/libmythtv-java | protocol/src/main/java/org/syphr/mythtv/protocol/impl/ProtocolUtils.java | ProtocolUtils.combineInts | public static long combineInts(String high, String low) throws NumberFormatException
{
int highInt = Integer.parseInt(high);
int lowInt = Integer.parseInt(low);
/*
* Shift the high integer into the upper 32 bits and add the low
* integer. However, since this is really a single set of bits split in
* half, the low part cannot be treated as negative by itself. Since
* Java has no unsigned types, the top half of the long created by
* up-casting the lower integer must be zeroed out before it's added.
*/
return ((long)highInt << 32) + (lowInt & 0x00000000FFFFFFFFL);
} | java | public static long combineInts(String high, String low) throws NumberFormatException
{
int highInt = Integer.parseInt(high);
int lowInt = Integer.parseInt(low);
/*
* Shift the high integer into the upper 32 bits and add the low
* integer. However, since this is really a single set of bits split in
* half, the low part cannot be treated as negative by itself. Since
* Java has no unsigned types, the top half of the long created by
* up-casting the lower integer must be zeroed out before it's added.
*/
return ((long)highInt << 32) + (lowInt & 0x00000000FFFFFFFFL);
} | [
"public",
"static",
"long",
"combineInts",
"(",
"String",
"high",
",",
"String",
"low",
")",
"throws",
"NumberFormatException",
"{",
"int",
"highInt",
"=",
"Integer",
".",
"parseInt",
"(",
"high",
")",
";",
"int",
"lowInt",
"=",
"Integer",
".",
"parseInt",
... | Combine two numbers that represent the high and low bits of a 64-bit
number.
@see #splitLong(long)
@param high
the high 32 bits
@param low
the low 32 bits
@return a 64 bit number comprised of the given high and low bits
concatenated together
@throws NumberFormatException
if the strings cannot be parsed as integers | [
"Combine",
"two",
"numbers",
"that",
"represent",
"the",
"high",
"and",
"low",
"bits",
"of",
"a",
"64",
"-",
"bit",
"number",
"."
] | cc7a2012fbd4a4ba2562dda6b2614fb0548526ea | https://github.com/syphr42/libmythtv-java/blob/cc7a2012fbd4a4ba2562dda6b2614fb0548526ea/protocol/src/main/java/org/syphr/mythtv/protocol/impl/ProtocolUtils.java#L43-L56 | train |
syphr42/libmythtv-java | protocol/src/main/java/org/syphr/mythtv/protocol/impl/ProtocolUtils.java | ProtocolUtils.splitLong | public static Pair<String, String> splitLong(long value)
{
return Pair.of(String.valueOf((int)(value >> 32)), String.valueOf((int)value));
} | java | public static Pair<String, String> splitLong(long value)
{
return Pair.of(String.valueOf((int)(value >> 32)), String.valueOf((int)value));
} | [
"public",
"static",
"Pair",
"<",
"String",
",",
"String",
">",
"splitLong",
"(",
"long",
"value",
")",
"{",
"return",
"Pair",
".",
"of",
"(",
"String",
".",
"valueOf",
"(",
"(",
"int",
")",
"(",
"value",
">>",
"32",
")",
")",
",",
"String",
".",
... | Split a single 64 bit number into integers representing the high and low
32 bits.
@see #combineInts(String, String)
@param value
the value to split
@return a pair of integers where the left is the high 32 bits and the
right is the low 32 bits, represented as strings | [
"Split",
"a",
"single",
"64",
"bit",
"number",
"into",
"integers",
"representing",
"the",
"high",
"and",
"low",
"32",
"bits",
"."
] | cc7a2012fbd4a4ba2562dda6b2614fb0548526ea | https://github.com/syphr42/libmythtv-java/blob/cc7a2012fbd4a4ba2562dda6b2614fb0548526ea/protocol/src/main/java/org/syphr/mythtv/protocol/impl/ProtocolUtils.java#L69-L72 | train |
syphr42/libmythtv-java | commons/src/main/java/org/syphr/mythtv/commons/socket/CommandUtils.java | CommandUtils.sendExpectOk | public static void sendExpectOk(SocketManager socketManager, String message) throws IOException
{
expectOk(socketManager.sendAndWait(message));
} | java | public static void sendExpectOk(SocketManager socketManager, String message) throws IOException
{
expectOk(socketManager.sendAndWait(message));
} | [
"public",
"static",
"void",
"sendExpectOk",
"(",
"SocketManager",
"socketManager",
",",
"String",
"message",
")",
"throws",
"IOException",
"{",
"expectOk",
"(",
"socketManager",
".",
"sendAndWait",
"(",
"message",
")",
")",
";",
"}"
] | Send a message via the given socket manager which should always receive a case
insensitive "OK" as the reply.
@param socketManager
the socket manager that will be used to send and receive over the
network
@param message
the message to send
@throws IOException
if there is a communication error or an unexpected response | [
"Send",
"a",
"message",
"via",
"the",
"given",
"socket",
"manager",
"which",
"should",
"always",
"receive",
"a",
"case",
"insensitive",
"OK",
"as",
"the",
"reply",
"."
] | cc7a2012fbd4a4ba2562dda6b2614fb0548526ea | https://github.com/syphr42/libmythtv-java/blob/cc7a2012fbd4a4ba2562dda6b2614fb0548526ea/commons/src/main/java/org/syphr/mythtv/commons/socket/CommandUtils.java#L37-L40 | train |
syphr42/libmythtv-java | commons/src/main/java/org/syphr/mythtv/commons/socket/CommandUtils.java | CommandUtils.expectOk | public static void expectOk(String response) throws ProtocolException
{
if (!"OK".equalsIgnoreCase(response))
{
throw new ProtocolException(response, Direction.RECEIVE);
}
} | java | public static void expectOk(String response) throws ProtocolException
{
if (!"OK".equalsIgnoreCase(response))
{
throw new ProtocolException(response, Direction.RECEIVE);
}
} | [
"public",
"static",
"void",
"expectOk",
"(",
"String",
"response",
")",
"throws",
"ProtocolException",
"{",
"if",
"(",
"!",
"\"OK\"",
".",
"equalsIgnoreCase",
"(",
"response",
")",
")",
"{",
"throw",
"new",
"ProtocolException",
"(",
"response",
",",
"Direction... | Check the response for an "OK" message. Throw an exception if response is not
expected.
@param response
the response to check
@throws ProtocolException
if the response is not the expected case-insensitive "OK" | [
"Check",
"the",
"response",
"for",
"an",
"OK",
"message",
".",
"Throw",
"an",
"exception",
"if",
"response",
"is",
"not",
"expected",
"."
] | cc7a2012fbd4a4ba2562dda6b2614fb0548526ea | https://github.com/syphr42/libmythtv-java/blob/cc7a2012fbd4a4ba2562dda6b2614fb0548526ea/commons/src/main/java/org/syphr/mythtv/commons/socket/CommandUtils.java#L51-L57 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/Messager.java | Messager.printError | public void printError(SourcePosition pos, String msg) {
if (diagListener != null) {
report(DiagnosticType.ERROR, pos, msg);
return;
}
if (nerrors < MaxErrors) {
String prefix = (pos == null) ? programName : pos.toString();
errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
errWriter.flush();
prompt();
nerrors++;
}
} | java | public void printError(SourcePosition pos, String msg) {
if (diagListener != null) {
report(DiagnosticType.ERROR, pos, msg);
return;
}
if (nerrors < MaxErrors) {
String prefix = (pos == null) ? programName : pos.toString();
errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
errWriter.flush();
prompt();
nerrors++;
}
} | [
"public",
"void",
"printError",
"(",
"SourcePosition",
"pos",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"diagListener",
"!=",
"null",
")",
"{",
"report",
"(",
"DiagnosticType",
".",
"ERROR",
",",
"pos",
",",
"msg",
")",
";",
"return",
";",
"}",
"if",
... | Print error message, increment error count.
Part of DocErrorReporter.
@param pos the position where the error occurs
@param msg message to print | [
"Print",
"error",
"message",
"increment",
"error",
"count",
".",
"Part",
"of",
"DocErrorReporter",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/Messager.java#L165-L178 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/StructTypeConverter.java | StructTypeConverter.unmarshal | public Object unmarshal(Object map) throws RpcException {
return unmarshal(getTypeClass(), map, this.s, this.isOptional);
} | java | public Object unmarshal(Object map) throws RpcException {
return unmarshal(getTypeClass(), map, this.s, this.isOptional);
} | [
"public",
"Object",
"unmarshal",
"(",
"Object",
"map",
")",
"throws",
"RpcException",
"{",
"return",
"unmarshal",
"(",
"getTypeClass",
"(",
")",
",",
"map",
",",
"this",
".",
"s",
",",
"this",
".",
"isOptional",
")",
";",
"}"
] | Converts o from a Map back to the Java Class associated with this Struct.
Recursively unmarshals all the members of the map.
@param map Map to unmarshal
@throws RpcException If o does not comply with the IDL definition for this Struct | [
"Converts",
"o",
"from",
"a",
"Map",
"back",
"to",
"the",
"Java",
"Class",
"associated",
"with",
"this",
"Struct",
".",
"Recursively",
"unmarshals",
"all",
"the",
"members",
"of",
"the",
"map",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/StructTypeConverter.java#L52-L54 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/StructTypeConverter.java | StructTypeConverter.marshal | @SuppressWarnings("unchecked")
public Object marshal(Object o) throws RpcException {
if (o == null) {
return returnNullIfOptional();
}
else if (o instanceof BStruct) {
return validateMap(structToMap(o, this.s), this.s);
}
else if (o instanceof Map) {
return validateMap((Map)o, this.s);
}
else {
String msg = "Unable to convert class: " + o.getClass().getName();
throw RpcException.Error.INVALID_RESP.exc(msg);
}
} | java | @SuppressWarnings("unchecked")
public Object marshal(Object o) throws RpcException {
if (o == null) {
return returnNullIfOptional();
}
else if (o instanceof BStruct) {
return validateMap(structToMap(o, this.s), this.s);
}
else if (o instanceof Map) {
return validateMap((Map)o, this.s);
}
else {
String msg = "Unable to convert class: " + o.getClass().getName();
throw RpcException.Error.INVALID_RESP.exc(msg);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Object",
"marshal",
"(",
"Object",
"o",
")",
"throws",
"RpcException",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"returnNullIfOptional",
"(",
")",
";",
"}",
"else",
"if",
"(",
"o... | Marshals native Java type o to a Map that can be serialized.
Recursively marshals all of the Struct fields from o onto the map.
@param o Java object to marshal to Map
@return Map containing the marshaled data
@throws RpcException If o does not validate against the Struct spec in the IDL.
The most common validation error will be null properties on o for Struct
fields that are not marked optional. | [
"Marshals",
"native",
"Java",
"type",
"o",
"to",
"a",
"Map",
"that",
"can",
"be",
"serialized",
".",
"Recursively",
"marshals",
"all",
"of",
"the",
"Struct",
"fields",
"from",
"o",
"onto",
"the",
"map",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/StructTypeConverter.java#L66-L81 | train |
Wadpam/guja | guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java | GAEBlobServlet.getUploadUrl | private void getUploadUrl(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
LOGGER.debug("Get blobstore upload url");
String callback = req.getParameter(CALLBACK_PARAM);
if (null == callback) {
callback = req.getRequestURI();
}
String keepQueryParam = req.getParameter(KEEP_QUERY_PARAM);
// Forward any existing query parameters, e.g. access_token
if (null != keepQueryParam) {
final String queryString = req.getQueryString();
callback = String.format("%s?%s", callback, null != queryString ? queryString : "");
}
Map<String, String> response = ImmutableMap.of("uploadUrl", blobstoreService.createUploadUrl(callback));
PrintWriter out = resp.getWriter();
resp.setContentType(JsonCharacterEncodingResponseFilter.APPLICATION_JSON_UTF8);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(out, response);
out.close();
} | java | private void getUploadUrl(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
LOGGER.debug("Get blobstore upload url");
String callback = req.getParameter(CALLBACK_PARAM);
if (null == callback) {
callback = req.getRequestURI();
}
String keepQueryParam = req.getParameter(KEEP_QUERY_PARAM);
// Forward any existing query parameters, e.g. access_token
if (null != keepQueryParam) {
final String queryString = req.getQueryString();
callback = String.format("%s?%s", callback, null != queryString ? queryString : "");
}
Map<String, String> response = ImmutableMap.of("uploadUrl", blobstoreService.createUploadUrl(callback));
PrintWriter out = resp.getWriter();
resp.setContentType(JsonCharacterEncodingResponseFilter.APPLICATION_JSON_UTF8);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(out, response);
out.close();
} | [
"private",
"void",
"getUploadUrl",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Get blobstore upload url\"",
")",
";",
"String",
"callback",
"=",
"re... | Get an upload URL
@param req
@param resp
@throws ServletException
@throws IOException | [
"Get",
"an",
"upload",
"URL"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java#L104-L128 | train |
Wadpam/guja | guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java | GAEBlobServlet.getEncodeFileName | private static String getEncodeFileName(String userAgent, String fileName) {
String encodedFileName = fileName;
try {
if (userAgent.contains("MSIE") || userAgent.contains("Opera")) {
encodedFileName = URLEncoder.encode(fileName, "UTF-8");
} else {
encodedFileName = "=?UTF-8?B?" + new String(BaseEncoding.base64().encode(fileName.getBytes("UTF-8"))) + "?=";
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
return encodedFileName;
} | java | private static String getEncodeFileName(String userAgent, String fileName) {
String encodedFileName = fileName;
try {
if (userAgent.contains("MSIE") || userAgent.contains("Opera")) {
encodedFileName = URLEncoder.encode(fileName, "UTF-8");
} else {
encodedFileName = "=?UTF-8?B?" + new String(BaseEncoding.base64().encode(fileName.getBytes("UTF-8"))) + "?=";
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
return encodedFileName;
} | [
"private",
"static",
"String",
"getEncodeFileName",
"(",
"String",
"userAgent",
",",
"String",
"fileName",
")",
"{",
"String",
"encodedFileName",
"=",
"fileName",
";",
"try",
"{",
"if",
"(",
"userAgent",
".",
"contains",
"(",
"\"MSIE\"",
")",
"||",
"userAgent"... | Encode header value for Content-Disposition | [
"Encode",
"header",
"value",
"for",
"Content",
"-",
"Disposition"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java#L215-L228 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/comp/Annotate.java | Annotate.enterAnnotation | Attribute.Compound enterAnnotation(JCAnnotation a,
Type expected,
Env<AttrContext> env) {
return enterAnnotation(a, expected, env, false);
} | java | Attribute.Compound enterAnnotation(JCAnnotation a,
Type expected,
Env<AttrContext> env) {
return enterAnnotation(a, expected, env, false);
} | [
"Attribute",
".",
"Compound",
"enterAnnotation",
"(",
"JCAnnotation",
"a",
",",
"Type",
"expected",
",",
"Env",
"<",
"AttrContext",
">",
"env",
")",
"{",
"return",
"enterAnnotation",
"(",
"a",
",",
"expected",
",",
"env",
",",
"false",
")",
";",
"}"
] | Process a single compound annotation, returning its
Attribute. Used from MemberEnter for attaching the attributes
to the annotated symbol. | [
"Process",
"a",
"single",
"compound",
"annotation",
"returning",
"its",
"Attribute",
".",
"Used",
"from",
"MemberEnter",
"for",
"attaching",
"the",
"attributes",
"to",
"the",
"annotated",
"symbol",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/comp/Annotate.java#L233-L237 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/comp/Annotate.java | Annotate.getContainingType | private Type getContainingType(Attribute.Compound currentAnno,
DiagnosticPosition pos,
boolean reportError)
{
Type origAnnoType = currentAnno.type;
TypeSymbol origAnnoDecl = origAnnoType.tsym;
// Fetch the Repeatable annotation from the current
// annotation's declaration, or null if it has none
Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym);
if (ca == null) { // has no Repeatable annotation
if (reportError)
log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
return null;
}
return filterSame(extractContainingType(ca, pos, origAnnoDecl),
origAnnoType);
} | java | private Type getContainingType(Attribute.Compound currentAnno,
DiagnosticPosition pos,
boolean reportError)
{
Type origAnnoType = currentAnno.type;
TypeSymbol origAnnoDecl = origAnnoType.tsym;
// Fetch the Repeatable annotation from the current
// annotation's declaration, or null if it has none
Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym);
if (ca == null) { // has no Repeatable annotation
if (reportError)
log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
return null;
}
return filterSame(extractContainingType(ca, pos, origAnnoDecl),
origAnnoType);
} | [
"private",
"Type",
"getContainingType",
"(",
"Attribute",
".",
"Compound",
"currentAnno",
",",
"DiagnosticPosition",
"pos",
",",
"boolean",
"reportError",
")",
"{",
"Type",
"origAnnoType",
"=",
"currentAnno",
".",
"type",
";",
"TypeSymbol",
"origAnnoDecl",
"=",
"o... | Fetches the actual Type that should be the containing annotation. | [
"Fetches",
"the",
"actual",
"Type",
"that",
"should",
"be",
"the",
"containing",
"annotation",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/comp/Annotate.java#L556-L574 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.getSheetNames | @Override
public String[] getSheetNames()
{
String[] ret = null;
if(sheets != null)
{
ret = new String[sheets.size()];
for(int i = 0; i < sheets.size(); i++)
{
Sheet sheet = (Sheet)sheets.get(i);
ret[i] = sheet.getName();
}
}
return ret;
} | java | @Override
public String[] getSheetNames()
{
String[] ret = null;
if(sheets != null)
{
ret = new String[sheets.size()];
for(int i = 0; i < sheets.size(); i++)
{
Sheet sheet = (Sheet)sheets.get(i);
ret[i] = sheet.getName();
}
}
return ret;
} | [
"@",
"Override",
"public",
"String",
"[",
"]",
"getSheetNames",
"(",
")",
"{",
"String",
"[",
"]",
"ret",
"=",
"null",
";",
"if",
"(",
"sheets",
"!=",
"null",
")",
"{",
"ret",
"=",
"new",
"String",
"[",
"sheets",
".",
"size",
"(",
")",
"]",
";",
... | Returns the list of worksheet names from the given Excel XLSX file.
@return The list of worksheet names from the given workbook | [
"Returns",
"the",
"list",
"of",
"worksheet",
"names",
"from",
"the",
"given",
"Excel",
"XLSX",
"file",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L308-L322 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.getSharedString | public String getSharedString(int i)
{
String ret = null;
CTRst string = strings.getSi().get(i);
if(string != null && string.getT() != null)
ret = string.getT().getValue();
if(ret == null) // cell has multiple formats or fonts
{
List<CTRElt> list = string.getR();
if(list.size() > 0)
{
for(CTRElt lt : list)
{
String str = lt.getT().getValue();
if(str != null)
{
if(ret == null)
ret = "";
ret += str;
}
}
}
}
return ret;
} | java | public String getSharedString(int i)
{
String ret = null;
CTRst string = strings.getSi().get(i);
if(string != null && string.getT() != null)
ret = string.getT().getValue();
if(ret == null) // cell has multiple formats or fonts
{
List<CTRElt> list = string.getR();
if(list.size() > 0)
{
for(CTRElt lt : list)
{
String str = lt.getT().getValue();
if(str != null)
{
if(ret == null)
ret = "";
ret += str;
}
}
}
}
return ret;
} | [
"public",
"String",
"getSharedString",
"(",
"int",
"i",
")",
"{",
"String",
"ret",
"=",
"null",
";",
"CTRst",
"string",
"=",
"strings",
".",
"getSi",
"(",
")",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"string",
"!=",
"null",
"&&",
"string",
".",
... | Returns the string at the given index in SharedStrings.xml.
@param i The index of the string
@return The string at the given index in SharedStrings.xml | [
"Returns",
"the",
"string",
"at",
"the",
"given",
"index",
"in",
"SharedStrings",
".",
"xml",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L358-L382 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.getFormatCode | public String getFormatCode(long id)
{
if(numFmts == null)
cacheFormatCodes();
return (String)numFmts.get(new Long(id));
} | java | public String getFormatCode(long id)
{
if(numFmts == null)
cacheFormatCodes();
return (String)numFmts.get(new Long(id));
} | [
"public",
"String",
"getFormatCode",
"(",
"long",
"id",
")",
"{",
"if",
"(",
"numFmts",
"==",
"null",
")",
"cacheFormatCodes",
"(",
")",
";",
"return",
"(",
"String",
")",
"numFmts",
".",
"get",
"(",
"new",
"Long",
"(",
"id",
")",
")",
";",
"}"
] | Returns the number format code for given id in styles.xml.
@param id The number format id
@return The number format code for given id in styles.xml | [
"Returns",
"the",
"number",
"format",
"code",
"for",
"given",
"id",
"in",
"styles",
".",
"xml",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L398-L403 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.addFormatCode | private void addFormatCode(CTNumFmt fmt)
{
if(numFmts == null)
numFmts = new HashMap();
numFmts.put(fmt.getNumFmtId(),
fmt.getFormatCode());
} | java | private void addFormatCode(CTNumFmt fmt)
{
if(numFmts == null)
numFmts = new HashMap();
numFmts.put(fmt.getNumFmtId(),
fmt.getFormatCode());
} | [
"private",
"void",
"addFormatCode",
"(",
"CTNumFmt",
"fmt",
")",
"{",
"if",
"(",
"numFmts",
"==",
"null",
")",
"numFmts",
"=",
"new",
"HashMap",
"(",
")",
";",
"numFmts",
".",
"put",
"(",
"fmt",
".",
"getNumFmtId",
"(",
")",
",",
"fmt",
".",
"getForm... | Adds the given number format to the cache.
@param fmt The number format to be added | [
"Adds",
"the",
"given",
"number",
"format",
"to",
"the",
"cache",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L409-L415 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.getFormatId | private long getFormatId(String formatCode)
{
long ret = 0L;
if(formatCode != null && formatCode.length() > 0)
{
if(numFmts != null)
{
Iterator it = numFmts.entrySet().iterator();
while(it.hasNext() && ret == 0L)
{
java.util.Map.Entry entry = (java.util.Map.Entry)it.next();
Long id = (Long)entry.getKey();
String code = (String)entry.getValue();
if(code != null && code.equals(formatCode))
ret = id.longValue();
}
}
// If not found, also search
// the built-in formats
if(ret == 0L)
{
Long l = (Long)builtinNumFmts.get(formatCode);
if(l != null)
ret = l.longValue();
}
// If still not found,
// create a new format
if(ret == 0L)
{
CTNumFmts numFmts = stylesheet.getNumFmts();
if(numFmts == null)
{
numFmts = new CTNumFmts();
stylesheet.setNumFmts(numFmts);
}
List list = numFmts.getNumFmt();
CTNumFmt numFmt = new CTNumFmt();
numFmt.setNumFmtId(getMaxNumFmtId()+1);
numFmt.setFormatCode(formatCode);
list.add(numFmt);
numFmts.setCount((long)list.size());
addFormatCode(numFmt);
ret = numFmt.getNumFmtId();
}
}
return ret;
} | java | private long getFormatId(String formatCode)
{
long ret = 0L;
if(formatCode != null && formatCode.length() > 0)
{
if(numFmts != null)
{
Iterator it = numFmts.entrySet().iterator();
while(it.hasNext() && ret == 0L)
{
java.util.Map.Entry entry = (java.util.Map.Entry)it.next();
Long id = (Long)entry.getKey();
String code = (String)entry.getValue();
if(code != null && code.equals(formatCode))
ret = id.longValue();
}
}
// If not found, also search
// the built-in formats
if(ret == 0L)
{
Long l = (Long)builtinNumFmts.get(formatCode);
if(l != null)
ret = l.longValue();
}
// If still not found,
// create a new format
if(ret == 0L)
{
CTNumFmts numFmts = stylesheet.getNumFmts();
if(numFmts == null)
{
numFmts = new CTNumFmts();
stylesheet.setNumFmts(numFmts);
}
List list = numFmts.getNumFmt();
CTNumFmt numFmt = new CTNumFmt();
numFmt.setNumFmtId(getMaxNumFmtId()+1);
numFmt.setFormatCode(formatCode);
list.add(numFmt);
numFmts.setCount((long)list.size());
addFormatCode(numFmt);
ret = numFmt.getNumFmtId();
}
}
return ret;
} | [
"private",
"long",
"getFormatId",
"(",
"String",
"formatCode",
")",
"{",
"long",
"ret",
"=",
"0L",
";",
"if",
"(",
"formatCode",
"!=",
"null",
"&&",
"formatCode",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"numFmts",
"!=",
"null",
")",
... | Returns the id for the given number format from the cache.
@param formatCode The number format code to be checked
@return The id for the given number format from the cache | [
"Returns",
"the",
"id",
"for",
"the",
"given",
"number",
"format",
"from",
"the",
"cache",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L422-L473 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java | XlsxWorkbook.getMaxNumFmtId | private long getMaxNumFmtId()
{
long ret = 163;
List list = stylesheet.getNumFmts().getNumFmt();
for(int i = 0; i < list.size(); i++)
{
CTNumFmt numFmt = (CTNumFmt)list.get(i);
if(numFmt.getNumFmtId() > ret)
ret = numFmt.getNumFmtId();
}
return ret;
} | java | private long getMaxNumFmtId()
{
long ret = 163;
List list = stylesheet.getNumFmts().getNumFmt();
for(int i = 0; i < list.size(); i++)
{
CTNumFmt numFmt = (CTNumFmt)list.get(i);
if(numFmt.getNumFmtId() > ret)
ret = numFmt.getNumFmtId();
}
return ret;
} | [
"private",
"long",
"getMaxNumFmtId",
"(",
")",
"{",
"long",
"ret",
"=",
"163",
";",
"List",
"list",
"=",
"stylesheet",
".",
"getNumFmts",
"(",
")",
".",
"getNumFmt",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"si... | Returns the maximum numFmtId in styles.xml.
@return The maximum numFmtId in styles.xml | [
"Returns",
"the",
"maximum",
"numFmtId",
"in",
"styles",
".",
"xml",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/XlsxWorkbook.java#L479-L490 | train |
jcuda/jcufft | JCufftJava/src/main/java/jcuda/jcufft/cufftHandle.java | cufftHandle.setSize | void setSize(int x, int y, int z)
{
this.sizeX = x;
this.sizeY = y;
this.sizeZ = z;
} | java | void setSize(int x, int y, int z)
{
this.sizeX = x;
this.sizeY = y;
this.sizeZ = z;
} | [
"void",
"setSize",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"z",
")",
"{",
"this",
".",
"sizeX",
"=",
"x",
";",
"this",
".",
"sizeY",
"=",
"y",
";",
"this",
".",
"sizeZ",
"=",
"z",
";",
"}"
] | Set the size of this plan
@param x Size in x
@param y Size in y
@param z Size in z | [
"Set",
"the",
"size",
"of",
"this",
"plan"
] | 833c87ffb0864f7ee7270fddef8af57f48939b3a | https://github.com/jcuda/jcufft/blob/833c87ffb0864f7ee7270fddef8af57f48939b3a/JCufftJava/src/main/java/jcuda/jcufft/cufftHandle.java#L137-L142 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/MethodUtils.java | MethodUtils.invoke | public static Object invoke(Object source, String methodName, Class<?>[] parameterTypes,
Object[] parameterValues) throws MethodException {
Class<? extends Object> clazz = source.getClass();
Method method;
if (ArrayUtils.isEmpty(parameterTypes)) {
method = findMethod(clazz, methodName, EMPTY_PARAMETER_CLASSTYPES);
return invoke(source, method, EMPTY_PARAMETER_VALUES);
}
method = findMethod(clazz, methodName, parameterTypes);
return invoke(source, method, parameterValues);
} | java | public static Object invoke(Object source, String methodName, Class<?>[] parameterTypes,
Object[] parameterValues) throws MethodException {
Class<? extends Object> clazz = source.getClass();
Method method;
if (ArrayUtils.isEmpty(parameterTypes)) {
method = findMethod(clazz, methodName, EMPTY_PARAMETER_CLASSTYPES);
return invoke(source, method, EMPTY_PARAMETER_VALUES);
}
method = findMethod(clazz, methodName, parameterTypes);
return invoke(source, method, parameterValues);
} | [
"public",
"static",
"Object",
"invoke",
"(",
"Object",
"source",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
",",
"Object",
"[",
"]",
"parameterValues",
")",
"throws",
"MethodException",
"{",
"Class",
"<",
"?",
"ex... | Invokes method which name equals given method name and parameter types
equals given parameter types on the given source with the given
parameters.
@param source
the object which you want to handle.
@param methodName
the name of the method which you want to call.
@param parameterTypes
the parameter types of the method which you want to call.
@param parameterValues
the parameter values of the method which you want to call.
@return an object which is invoked method returns.
@throws MethodException | [
"Invokes",
"method",
"which",
"name",
"equals",
"given",
"method",
"name",
"and",
"parameter",
"types",
"equals",
"given",
"parameter",
"types",
"on",
"the",
"given",
"source",
"with",
"the",
"given",
"parameters",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/MethodUtils.java#L97-L108 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/MethodUtils.java | MethodUtils.invoke | public static Object invoke(Object source, Method method, Object[] parameterValues)
throws MethodException {
try {
return method.invoke(source, parameterValues);
} catch (Exception e) {
throw new MethodException(INVOKE_METHOD_FAILED, e);
}
} | java | public static Object invoke(Object source, Method method, Object[] parameterValues)
throws MethodException {
try {
return method.invoke(source, parameterValues);
} catch (Exception e) {
throw new MethodException(INVOKE_METHOD_FAILED, e);
}
} | [
"public",
"static",
"Object",
"invoke",
"(",
"Object",
"source",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"parameterValues",
")",
"throws",
"MethodException",
"{",
"try",
"{",
"return",
"method",
".",
"invoke",
"(",
"source",
",",
"parameterValues",
... | Invokes given method on the given source object with the specified
parameters.
@param source
the object which you want to handle.
@param method
the method which you want to call.
@param parameterValues
the parameter values of the method which you want to call.
@return an object which is invoked method returns.
@throws MethodException | [
"Invokes",
"given",
"method",
"on",
"the",
"given",
"source",
"object",
"with",
"the",
"specified",
"parameters",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/MethodUtils.java#L123-L131 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java | ApplicationHostCache.add | public void add(Collection<ApplicationHost> applicationHosts)
{
for(ApplicationHost applicationHost : applicationHosts)
this.applicationHosts.put(applicationHost.getId(), applicationHost);
} | java | public void add(Collection<ApplicationHost> applicationHosts)
{
for(ApplicationHost applicationHost : applicationHosts)
this.applicationHosts.put(applicationHost.getId(), applicationHost);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"ApplicationHost",
">",
"applicationHosts",
")",
"{",
"for",
"(",
"ApplicationHost",
"applicationHost",
":",
"applicationHosts",
")",
"this",
".",
"applicationHosts",
".",
"put",
"(",
"applicationHost",
".",
"getId"... | Adds the application host list to the application hosts for the account.
@param applicationHosts The application hosts to add | [
"Adds",
"the",
"application",
"host",
"list",
"to",
"the",
"application",
"hosts",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java#L72-L76 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java | ApplicationHostCache.applicationInstances | public ApplicationInstanceCache applicationInstances(long applicationHostId)
{
ApplicationInstanceCache cache = applicationInstances.get(applicationHostId);
if(cache == null)
applicationInstances.put(applicationHostId, cache = new ApplicationInstanceCache(applicationHostId));
return cache;
} | java | public ApplicationInstanceCache applicationInstances(long applicationHostId)
{
ApplicationInstanceCache cache = applicationInstances.get(applicationHostId);
if(cache == null)
applicationInstances.put(applicationHostId, cache = new ApplicationInstanceCache(applicationHostId));
return cache;
} | [
"public",
"ApplicationInstanceCache",
"applicationInstances",
"(",
"long",
"applicationHostId",
")",
"{",
"ApplicationInstanceCache",
"cache",
"=",
"applicationInstances",
".",
"get",
"(",
"applicationHostId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"applicat... | Returns the cache of application instances for the given application host, creating one if it doesn't exist .
@param applicationHostId The id of the application host for the cache of application instances
@return The cache of application instances for the given application host | [
"Returns",
"the",
"cache",
"of",
"application",
"instances",
"for",
"the",
"given",
"application",
"host",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java#L118-L124 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java | ApplicationHostCache.addApplicationInstances | public void addApplicationInstances(Collection<ApplicationInstance> applicationInstances)
{
for(ApplicationInstance applicationInstance : applicationInstances)
{
// Add the instance to any application hosts it is associated with
long applicationHostId = applicationInstance.getLinks().getApplicationHost();
ApplicationHost applicationHost = applicationHosts.get(applicationHostId);
if(applicationHost != null)
applicationInstances(applicationHostId).add(applicationInstance);
else
logger.severe(String.format("Unable to find application host for application instance '%s': %d", applicationInstance.getName(), applicationHostId));
}
} | java | public void addApplicationInstances(Collection<ApplicationInstance> applicationInstances)
{
for(ApplicationInstance applicationInstance : applicationInstances)
{
// Add the instance to any application hosts it is associated with
long applicationHostId = applicationInstance.getLinks().getApplicationHost();
ApplicationHost applicationHost = applicationHosts.get(applicationHostId);
if(applicationHost != null)
applicationInstances(applicationHostId).add(applicationInstance);
else
logger.severe(String.format("Unable to find application host for application instance '%s': %d", applicationInstance.getName(), applicationHostId));
}
} | [
"public",
"void",
"addApplicationInstances",
"(",
"Collection",
"<",
"ApplicationInstance",
">",
"applicationInstances",
")",
"{",
"for",
"(",
"ApplicationInstance",
"applicationInstance",
":",
"applicationInstances",
")",
"{",
"// Add the instance to any application hosts it i... | Adds the application instances to the applications for the account.
@param applicationInstances The application instances to add | [
"Adds",
"the",
"application",
"instances",
"to",
"the",
"applications",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/ApplicationHostCache.java#L130-L142 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/ClassReader.java | ClassReader.instance | public static ClassReader instance(Context context) {
ClassReader instance = context.get(classReaderKey);
if (instance == null)
instance = new ClassReader(context, true);
return instance;
} | java | public static ClassReader instance(Context context) {
ClassReader instance = context.get(classReaderKey);
if (instance == null)
instance = new ClassReader(context, true);
return instance;
} | [
"public",
"static",
"ClassReader",
"instance",
"(",
"Context",
"context",
")",
"{",
"ClassReader",
"instance",
"=",
"context",
".",
"get",
"(",
"classReaderKey",
")",
";",
"if",
"(",
"instance",
"==",
"null",
")",
"instance",
"=",
"new",
"ClassReader",
"(",
... | Get the ClassReader instance for this invocation. | [
"Get",
"the",
"ClassReader",
"instance",
"for",
"this",
"invocation",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#L250-L255 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/ClassReader.java | ClassReader.init | private void init(Symtab syms, boolean definitive) {
if (classes != null) return;
if (definitive) {
Assert.check(packages == null || packages == syms.packages);
packages = syms.packages;
Assert.check(classes == null || classes == syms.classes);
classes = syms.classes;
} else {
packages = new HashMap<Name, PackageSymbol>();
classes = new HashMap<Name, ClassSymbol>();
}
packages.put(names.empty, syms.rootPackage);
syms.rootPackage.completer = thisCompleter;
syms.unnamedPackage.completer = thisCompleter;
} | java | private void init(Symtab syms, boolean definitive) {
if (classes != null) return;
if (definitive) {
Assert.check(packages == null || packages == syms.packages);
packages = syms.packages;
Assert.check(classes == null || classes == syms.classes);
classes = syms.classes;
} else {
packages = new HashMap<Name, PackageSymbol>();
classes = new HashMap<Name, ClassSymbol>();
}
packages.put(names.empty, syms.rootPackage);
syms.rootPackage.completer = thisCompleter;
syms.unnamedPackage.completer = thisCompleter;
} | [
"private",
"void",
"init",
"(",
"Symtab",
"syms",
",",
"boolean",
"definitive",
")",
"{",
"if",
"(",
"classes",
"!=",
"null",
")",
"return",
";",
"if",
"(",
"definitive",
")",
"{",
"Assert",
".",
"check",
"(",
"packages",
"==",
"null",
"||",
"packages"... | Initialize classes and packages, optionally treating this as
the definitive classreader. | [
"Initialize",
"classes",
"and",
"packages",
"optionally",
"treating",
"this",
"as",
"the",
"definitive",
"classreader",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#L265-L281 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/ClassReader.java | ClassReader.readClassFile | private void readClassFile(ClassSymbol c) throws IOException {
int magic = nextInt();
if (magic != JAVA_MAGIC)
throw badClassFile("illegal.start.of.class.file");
minorVersion = nextChar();
majorVersion = nextChar();
int maxMajor = Target.MAX().majorVersion;
int maxMinor = Target.MAX().minorVersion;
if (majorVersion > maxMajor ||
majorVersion * 1000 + minorVersion <
Target.MIN().majorVersion * 1000 + Target.MIN().minorVersion)
{
if (majorVersion == (maxMajor + 1))
log.warning("big.major.version",
currentClassFile,
majorVersion,
maxMajor);
else
throw badClassFile("wrong.version",
Integer.toString(majorVersion),
Integer.toString(minorVersion),
Integer.toString(maxMajor),
Integer.toString(maxMinor));
}
else if (checkClassFile &&
majorVersion == maxMajor &&
minorVersion > maxMinor)
{
printCCF("found.later.version",
Integer.toString(minorVersion));
}
indexPool();
if (signatureBuffer.length < bp) {
int ns = Integer.highestOneBit(bp) << 1;
signatureBuffer = new byte[ns];
}
readClass(c);
} | java | private void readClassFile(ClassSymbol c) throws IOException {
int magic = nextInt();
if (magic != JAVA_MAGIC)
throw badClassFile("illegal.start.of.class.file");
minorVersion = nextChar();
majorVersion = nextChar();
int maxMajor = Target.MAX().majorVersion;
int maxMinor = Target.MAX().minorVersion;
if (majorVersion > maxMajor ||
majorVersion * 1000 + minorVersion <
Target.MIN().majorVersion * 1000 + Target.MIN().minorVersion)
{
if (majorVersion == (maxMajor + 1))
log.warning("big.major.version",
currentClassFile,
majorVersion,
maxMajor);
else
throw badClassFile("wrong.version",
Integer.toString(majorVersion),
Integer.toString(minorVersion),
Integer.toString(maxMajor),
Integer.toString(maxMinor));
}
else if (checkClassFile &&
majorVersion == maxMajor &&
minorVersion > maxMinor)
{
printCCF("found.later.version",
Integer.toString(minorVersion));
}
indexPool();
if (signatureBuffer.length < bp) {
int ns = Integer.highestOneBit(bp) << 1;
signatureBuffer = new byte[ns];
}
readClass(c);
} | [
"private",
"void",
"readClassFile",
"(",
"ClassSymbol",
"c",
")",
"throws",
"IOException",
"{",
"int",
"magic",
"=",
"nextInt",
"(",
")",
";",
"if",
"(",
"magic",
"!=",
"JAVA_MAGIC",
")",
"throw",
"badClassFile",
"(",
"\"illegal.start.of.class.file\"",
")",
";... | Read a class file. | [
"Read",
"a",
"class",
"file",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#L2300-L2338 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/ClassReader.java | ClassReader.enterPackage | public PackageSymbol enterPackage(Name name, PackageSymbol owner) {
return enterPackage(TypeSymbol.formFullName(name, owner));
} | java | public PackageSymbol enterPackage(Name name, PackageSymbol owner) {
return enterPackage(TypeSymbol.formFullName(name, owner));
} | [
"public",
"PackageSymbol",
"enterPackage",
"(",
"Name",
"name",
",",
"PackageSymbol",
"owner",
")",
"{",
"return",
"enterPackage",
"(",
"TypeSymbol",
".",
"formFullName",
"(",
"name",
",",
"owner",
")",
")",
";",
"}"
] | Make a package, given its unqualified name and enclosing package. | [
"Make",
"a",
"package",
"given",
"its",
"unqualified",
"name",
"and",
"enclosing",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#L2672-L2674 | train |
brianwhu/xillium | gear/src/main/java/org/xillium/gear/util/DaySchedule.java | DaySchedule.shutdown | public void shutdown() {
interrupt();
try { join(); } catch (Exception x) { _logger.log(Level.WARNING, "Failed to see DaySchedule thread joining", x); }
} | java | public void shutdown() {
interrupt();
try { join(); } catch (Exception x) { _logger.log(Level.WARNING, "Failed to see DaySchedule thread joining", x); }
} | [
"public",
"void",
"shutdown",
"(",
")",
"{",
"interrupt",
"(",
")",
";",
"try",
"{",
"join",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"x",
")",
"{",
"_logger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Failed to see DaySchedule thread joini... | Shuts down the DaySchedule thread. | [
"Shuts",
"down",
"the",
"DaySchedule",
"thread",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/gear/src/main/java/org/xillium/gear/util/DaySchedule.java#L353-L356 | train |
eiichiro/gig | gig-core/src/main/java/org/eiichiro/gig/WebListener.java | WebListener.contextInitialized | @Override
public void contextInitialized(ServletContextEvent sce) {
Gig.bootstrap(sce.getServletContext());
Jaguar.assemble(this);
} | java | @Override
public void contextInitialized(ServletContextEvent sce) {
Gig.bootstrap(sce.getServletContext());
Jaguar.assemble(this);
} | [
"@",
"Override",
"public",
"void",
"contextInitialized",
"(",
"ServletContextEvent",
"sce",
")",
"{",
"Gig",
".",
"bootstrap",
"(",
"sce",
".",
"getServletContext",
"(",
")",
")",
";",
"Jaguar",
".",
"assemble",
"(",
"this",
")",
";",
"}"
] | Bootstraps Gig application in web environment.
@param sce {@code ServletContextEvent}. | [
"Bootstraps",
"Gig",
"application",
"in",
"web",
"environment",
"."
] | 21181fb36a17d2154f989e5e8c6edbb39fc81900 | https://github.com/eiichiro/gig/blob/21181fb36a17d2154f989e5e8c6edbb39fc81900/gig-core/src/main/java/org/eiichiro/gig/WebListener.java#L35-L39 | train |
incodehq-legacy/incode-module-document | dom/src/main/java/org/incode/module/document/fixture/DocumentTemplateFSAbstract.java | DocumentTemplateFSAbstract.upsertType | protected DocumentType upsertType(
String reference,
String name,
ExecutionContext executionContext) {
DocumentType documentType = documentTypeRepository.findByReference(reference);
if(documentType != null) {
documentType.setName(name);
} else {
documentType = documentTypeRepository.create(reference, name);
}
return executionContext.addResult(this, documentType);
} | java | protected DocumentType upsertType(
String reference,
String name,
ExecutionContext executionContext) {
DocumentType documentType = documentTypeRepository.findByReference(reference);
if(documentType != null) {
documentType.setName(name);
} else {
documentType = documentTypeRepository.create(reference, name);
}
return executionContext.addResult(this, documentType);
} | [
"protected",
"DocumentType",
"upsertType",
"(",
"String",
"reference",
",",
"String",
"name",
",",
"ExecutionContext",
"executionContext",
")",
"{",
"DocumentType",
"documentType",
"=",
"documentTypeRepository",
".",
"findByReference",
"(",
"reference",
")",
";",
"if"... | convenience, as templates and types often created together
@param reference
@param name
@param executionContext
@return | [
"convenience",
"as",
"templates",
"and",
"types",
"often",
"created",
"together"
] | c62f064e96d6e6007f7fd6a4bc06e03b78b1816c | https://github.com/incodehq-legacy/incode-module-document/blob/c62f064e96d6e6007f7fd6a4bc06e03b78b1816c/dom/src/main/java/org/incode/module/document/fixture/DocumentTemplateFSAbstract.java#L46-L58 | train |
wanglinsong/th-lipermi | src/main/java/net/sf/lipermi/handler/CallLookup.java | CallLookup.getCurrentSocket | public static Socket getCurrentSocket() {
ConnectionHandler handler = connectionMap.get(Thread.currentThread());
return (handler == null ? null : handler.getSocket());
} | java | public static Socket getCurrentSocket() {
ConnectionHandler handler = connectionMap.get(Thread.currentThread());
return (handler == null ? null : handler.getSocket());
} | [
"public",
"static",
"Socket",
"getCurrentSocket",
"(",
")",
"{",
"ConnectionHandler",
"handler",
"=",
"connectionMap",
".",
"get",
"(",
"Thread",
".",
"currentThread",
"(",
")",
")",
";",
"return",
"(",
"handler",
"==",
"null",
"?",
"null",
":",
"handler",
... | Get the current Socket for this call.
Only works in the main thread call.
@return Socket which started the Delegator Thread | [
"Get",
"the",
"current",
"Socket",
"for",
"this",
"call",
".",
"Only",
"works",
"in",
"the",
"main",
"thread",
"call",
"."
] | 5fa9ab1d7085b5133dc37ce3ba201d44a7bf25f0 | https://github.com/wanglinsong/th-lipermi/blob/5fa9ab1d7085b5133dc37ce3ba201d44a7bf25f0/src/main/java/net/sf/lipermi/handler/CallLookup.java#L50-L53 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/report/parameterTypes/ParamConfig.java | ParamConfig.prepareParameter | public void prepareParameter(Map<String, Object> extra) {
if (from != null)
{
from.prepareParameter(extra);
}
} | java | public void prepareParameter(Map<String, Object> extra) {
if (from != null)
{
from.prepareParameter(extra);
}
} | [
"public",
"void",
"prepareParameter",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"extra",
")",
"{",
"if",
"(",
"from",
"!=",
"null",
")",
"{",
"from",
".",
"prepareParameter",
"(",
"extra",
")",
";",
"}",
"}"
] | Prepares the parameter's datasource, passing it the extra options and if necessary executing the appropriate
code and caching the value.
@param extra | [
"Prepares",
"the",
"parameter",
"s",
"datasource",
"passing",
"it",
"the",
"extra",
"options",
"and",
"if",
"necessary",
"executing",
"the",
"appropriate",
"code",
"and",
"caching",
"the",
"value",
"."
] | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/report/parameterTypes/ParamConfig.java#L263-L268 | train |
eiichiro/gig | gig-jpa-heroku-postgres/src/main/java/org/eiichiro/gig/heroku/PersistenceXMLProcessor.java | PersistenceXMLProcessor.process | public void process() {
try {
Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("META-INF/persistence.xml");
XMLInputFactory factory = XMLInputFactory.newInstance();
List<String> persistenceUnits = new ArrayList<String>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
XMLStreamReader reader = factory.createXMLStreamReader(url.openStream());
while (reader.hasNext()) {
if (reader.next() == XMLStreamConstants.START_ELEMENT
&& reader.getName().getLocalPart().equals("persistence-unit")) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
if (reader.getAttributeLocalName(i).equals("name")) {
persistenceUnits.add(reader.getAttributeValue(i));
break;
}
}
}
}
}
this.persistenceUnits = persistenceUnits;
} catch (Exception e) {
logger.error("Failed to parse persistence.xml", e);
}
} | java | public void process() {
try {
Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("META-INF/persistence.xml");
XMLInputFactory factory = XMLInputFactory.newInstance();
List<String> persistenceUnits = new ArrayList<String>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
XMLStreamReader reader = factory.createXMLStreamReader(url.openStream());
while (reader.hasNext()) {
if (reader.next() == XMLStreamConstants.START_ELEMENT
&& reader.getName().getLocalPart().equals("persistence-unit")) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
if (reader.getAttributeLocalName(i).equals("name")) {
persistenceUnits.add(reader.getAttributeValue(i));
break;
}
}
}
}
}
this.persistenceUnits = persistenceUnits;
} catch (Exception e) {
logger.error("Failed to parse persistence.xml", e);
}
} | [
"public",
"void",
"process",
"(",
")",
"{",
"try",
"{",
"Enumeration",
"<",
"URL",
">",
"urls",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResources",
"(",
"\"META-INF/persistence.xml\"",
")",
";",
"XMLInp... | Parses persistence.xml files on the current ClassLoader's search path
entries and detects persistence unit declarations from them. | [
"Parses",
"persistence",
".",
"xml",
"files",
"on",
"the",
"current",
"ClassLoader",
"s",
"search",
"path",
"entries",
"and",
"detects",
"persistence",
"unit",
"declarations",
"from",
"them",
"."
] | 21181fb36a17d2154f989e5e8c6edbb39fc81900 | https://github.com/eiichiro/gig/blob/21181fb36a17d2154f989e5e8c6edbb39fc81900/gig-jpa-heroku-postgres/src/main/java/org/eiichiro/gig/heroku/PersistenceXMLProcessor.java#L46-L73 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/DownloadUtils.java | DownloadUtils.getInputStreamFromHttp | public static InputStream getInputStreamFromHttp(String httpFileURL) throws IOException {
URLConnection urlConnection = null;
urlConnection = new URL(httpFileURL).openConnection();
urlConnection.connect();
return urlConnection.getInputStream();
} | java | public static InputStream getInputStreamFromHttp(String httpFileURL) throws IOException {
URLConnection urlConnection = null;
urlConnection = new URL(httpFileURL).openConnection();
urlConnection.connect();
return urlConnection.getInputStream();
} | [
"public",
"static",
"InputStream",
"getInputStreamFromHttp",
"(",
"String",
"httpFileURL",
")",
"throws",
"IOException",
"{",
"URLConnection",
"urlConnection",
"=",
"null",
";",
"urlConnection",
"=",
"new",
"URL",
"(",
"httpFileURL",
")",
".",
"openConnection",
"(",... | Get destination web file input stream.
@param httpFileURL
the web file url which you want to download.
@return the destination page input stream.
@throws IOException | [
"Get",
"destination",
"web",
"file",
"input",
"stream",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/DownloadUtils.java#L33-L39 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/DownloadUtils.java | DownloadUtils.getBytesFromHttp | public static byte[] getBytesFromHttp(String httpFileURL) throws IOException {
InputStream bufferedInputStream = null;
try {
bufferedInputStream = getInputStreamFromHttp(httpFileURL);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
for (int len = 0; (len = bufferedInputStream.read(buffer)) != -1;) {
byteArrayOutputStream.write(buffer, 0, len);
}
byte[] arrayOfByte1 = byteArrayOutputStream.toByteArray();
return arrayOfByte1;
} finally {
if (bufferedInputStream != null)
bufferedInputStream.close();
}
} | java | public static byte[] getBytesFromHttp(String httpFileURL) throws IOException {
InputStream bufferedInputStream = null;
try {
bufferedInputStream = getInputStreamFromHttp(httpFileURL);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
for (int len = 0; (len = bufferedInputStream.read(buffer)) != -1;) {
byteArrayOutputStream.write(buffer, 0, len);
}
byte[] arrayOfByte1 = byteArrayOutputStream.toByteArray();
return arrayOfByte1;
} finally {
if (bufferedInputStream != null)
bufferedInputStream.close();
}
} | [
"public",
"static",
"byte",
"[",
"]",
"getBytesFromHttp",
"(",
"String",
"httpFileURL",
")",
"throws",
"IOException",
"{",
"InputStream",
"bufferedInputStream",
"=",
"null",
";",
"try",
"{",
"bufferedInputStream",
"=",
"getInputStreamFromHttp",
"(",
"httpFileURL",
"... | Get destination web file bytes.
@param httpFileURL
the web file url which you want to download.
@return the destination file bytes.
@throws IOException | [
"Get",
"destination",
"web",
"file",
"bytes",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/DownloadUtils.java#L49-L65 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/util/Link.java | Link.make | public static <T> Link<T> make(Link<T> root, T object) {
Link<T> link = new Link<>(object);
if (root == null) {
root = link;
} else if (root.last == null) {
root.next = link;
} else {
root.last.next = link;
}
root.last = link;
return root;
} | java | public static <T> Link<T> make(Link<T> root, T object) {
Link<T> link = new Link<>(object);
if (root == null) {
root = link;
} else if (root.last == null) {
root.next = link;
} else {
root.last.next = link;
}
root.last = link;
return root;
} | [
"public",
"static",
"<",
"T",
">",
"Link",
"<",
"T",
">",
"make",
"(",
"Link",
"<",
"T",
">",
"root",
",",
"T",
"object",
")",
"{",
"Link",
"<",
"T",
">",
"link",
"=",
"new",
"Link",
"<>",
"(",
"object",
")",
";",
"if",
"(",
"root",
"==",
"... | Adds a new object at the end of the list identified by the root link.
@param root - the root link of the list, which can be null
@param object - the data object to add
@return the root link | [
"Adds",
"a",
"new",
"object",
"at",
"the",
"end",
"of",
"the",
"list",
"identified",
"by",
"the",
"root",
"link",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/util/Link.java#L38-L50 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java | Group.foundGroupFormat | boolean foundGroupFormat(Map<String,?> map, String pkgFormat) {
if (map.containsKey(pkgFormat)) {
configuration.message.error("doclet.Same_package_name_used", pkgFormat);
return true;
}
return false;
} | java | boolean foundGroupFormat(Map<String,?> map, String pkgFormat) {
if (map.containsKey(pkgFormat)) {
configuration.message.error("doclet.Same_package_name_used", pkgFormat);
return true;
}
return false;
} | [
"boolean",
"foundGroupFormat",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
",",
"String",
"pkgFormat",
")",
"{",
"if",
"(",
"map",
".",
"containsKey",
"(",
"pkgFormat",
")",
")",
"{",
"configuration",
".",
"message",
".",
"error",
"(",
"\"doclet.Sam... | Search if the given map has given the package format.
@param map Map to be searched.
@param pkgFormat The pacakge format to search.
@return true if package name format found in the map, else false. | [
"Search",
"if",
"the",
"given",
"map",
"has",
"given",
"the",
"package",
"format",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java#L157-L163 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java | Group.groupPackages | public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) {
Map<String,List<PackageDoc>> groupPackageMap = new HashMap<String,List<PackageDoc>>();
String defaultGroupName =
(pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())?
configuration.message.getText("doclet.Packages") :
configuration.message.getText("doclet.Other_Packages");
// if the user has not used the default group name, add it
if (!groupList.contains(defaultGroupName)) {
groupList.add(defaultGroupName);
}
for (int i = 0; i < packages.length; i++) {
PackageDoc pkg = packages[i];
String pkgName = pkg.name();
String groupName = pkgNameGroupMap.get(pkgName);
// if this package is not explicitly assigned to a group,
// try matching it to group specified by regular expression
if (groupName == null) {
groupName = regExpGroupName(pkgName);
}
// if it is in neither group map, put it in the default
// group
if (groupName == null) {
groupName = defaultGroupName;
}
getPkgList(groupPackageMap, groupName).add(pkg);
}
return groupPackageMap;
} | java | public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) {
Map<String,List<PackageDoc>> groupPackageMap = new HashMap<String,List<PackageDoc>>();
String defaultGroupName =
(pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())?
configuration.message.getText("doclet.Packages") :
configuration.message.getText("doclet.Other_Packages");
// if the user has not used the default group name, add it
if (!groupList.contains(defaultGroupName)) {
groupList.add(defaultGroupName);
}
for (int i = 0; i < packages.length; i++) {
PackageDoc pkg = packages[i];
String pkgName = pkg.name();
String groupName = pkgNameGroupMap.get(pkgName);
// if this package is not explicitly assigned to a group,
// try matching it to group specified by regular expression
if (groupName == null) {
groupName = regExpGroupName(pkgName);
}
// if it is in neither group map, put it in the default
// group
if (groupName == null) {
groupName = defaultGroupName;
}
getPkgList(groupPackageMap, groupName).add(pkg);
}
return groupPackageMap;
} | [
"public",
"Map",
"<",
"String",
",",
"List",
"<",
"PackageDoc",
">",
">",
"groupPackages",
"(",
"PackageDoc",
"[",
"]",
"packages",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"PackageDoc",
">",
">",
"groupPackageMap",
"=",
"new",
"HashMap",
"<",
... | Group the packages according the grouping information provided on the
command line. Given a list of packages, search each package name in
regular expression map as well as package name map to get the
corresponding group name. Create another map with mapping of group name
to the package list, which will fall under the specified group. If any
package doesen't belong to any specified group on the comamnd line, then
a new group named "Other Packages" will be created for it. If there are
no groups found, in other words if "-group" option is not at all used,
then all the packages will be grouped under group "Packages".
@param packages Packages specified on the command line. | [
"Group",
"the",
"packages",
"according",
"the",
"grouping",
"information",
"provided",
"on",
"the",
"command",
"line",
".",
"Given",
"a",
"list",
"of",
"packages",
"search",
"each",
"package",
"name",
"in",
"regular",
"expression",
"map",
"as",
"well",
"as",
... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java#L178-L205 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java | Group.regExpGroupName | String regExpGroupName(String pkgName) {
for (int j = 0; j < sortedRegExpList.size(); j++) {
String regexp = sortedRegExpList.get(j);
if (pkgName.startsWith(regexp)) {
return regExpGroupMap.get(regexp);
}
}
return null;
} | java | String regExpGroupName(String pkgName) {
for (int j = 0; j < sortedRegExpList.size(); j++) {
String regexp = sortedRegExpList.get(j);
if (pkgName.startsWith(regexp)) {
return regExpGroupMap.get(regexp);
}
}
return null;
} | [
"String",
"regExpGroupName",
"(",
"String",
"pkgName",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"sortedRegExpList",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"String",
"regexp",
"=",
"sortedRegExpList",
".",
"get",
"(",
"j",
... | Search for package name in the sorted regular expression
list, if found return the group name. If not, return null.
@param pkgName Name of package to be found in the regular
expression list. | [
"Search",
"for",
"package",
"name",
"in",
"the",
"sorted",
"regular",
"expression",
"list",
"if",
"found",
"return",
"the",
"group",
"name",
".",
"If",
"not",
"return",
"null",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java#L214-L222 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/RpcRequest.java | RpcRequest.marshal | @SuppressWarnings("unchecked")
public Map marshal(Contract contract) throws RpcException {
Map map = new HashMap();
map.put("jsonrpc", "2.0");
if (id != null)
map.put("id", id);
map.put("method", method.getMethod());
if (params != null && params.length > 0) {
Function f = contract.getFunction(getIface(), getFunc());
map.put("params", f.marshalParams(this));
}
return map;
} | java | @SuppressWarnings("unchecked")
public Map marshal(Contract contract) throws RpcException {
Map map = new HashMap();
map.put("jsonrpc", "2.0");
if (id != null)
map.put("id", id);
map.put("method", method.getMethod());
if (params != null && params.length > 0) {
Function f = contract.getFunction(getIface(), getFunc());
map.put("params", f.marshalParams(this));
}
return map;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"marshal",
"(",
"Contract",
"contract",
")",
"throws",
"RpcException",
"{",
"Map",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"jsonrpc\"",
",",
"\"2.0\"",
")",... | Marshals this request to a Map that can be serialized and sent over the wire.
Uses the Contract to resolve the Function associated with the method.
@param contract Contract to use to resolve Function
@return JSON-RPC formatted Map based on the request id, method, and params | [
"Marshals",
"this",
"request",
"to",
"a",
"Map",
"that",
"can",
"be",
"serialized",
"and",
"sent",
"over",
"the",
"wire",
".",
"Uses",
"the",
"Contract",
"to",
"resolve",
"the",
"Function",
"associated",
"with",
"the",
"method",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/RpcRequest.java#L94-L110 | train |
DDTH/ddth-redis | src/main/java/com/github/ddth/redis/RedisClientFactory.java | RedisClientFactory.init | public void init() {
int numProcessors = Runtime.getRuntime().availableProcessors();
cacheRedisClientPools = CacheBuilder.newBuilder().concurrencyLevel(numProcessors)
.expireAfterAccess(3600, TimeUnit.SECONDS)
.removalListener(new RemovalListener<String, JedisClientPool>() {
@Override
public void onRemoval(RemovalNotification<String, JedisClientPool> notification) {
JedisClientPool pool = notification.getValue();
pool.destroy();
}
}).build();
} | java | public void init() {
int numProcessors = Runtime.getRuntime().availableProcessors();
cacheRedisClientPools = CacheBuilder.newBuilder().concurrencyLevel(numProcessors)
.expireAfterAccess(3600, TimeUnit.SECONDS)
.removalListener(new RemovalListener<String, JedisClientPool>() {
@Override
public void onRemoval(RemovalNotification<String, JedisClientPool> notification) {
JedisClientPool pool = notification.getValue();
pool.destroy();
}
}).build();
} | [
"public",
"void",
"init",
"(",
")",
"{",
"int",
"numProcessors",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
";",
"cacheRedisClientPools",
"=",
"CacheBuilder",
".",
"newBuilder",
"(",
")",
".",
"concurrencyLevel",
"(",
... | Initializes the factory. | [
"Initializes",
"the",
"factory",
"."
] | 7e6abc3e43c9efe7e9c293d421c94227253ded87 | https://github.com/DDTH/ddth-redis/blob/7e6abc3e43c9efe7e9c293d421c94227253ded87/src/main/java/com/github/ddth/redis/RedisClientFactory.java#L50-L61 | train |
DDTH/ddth-redis | src/main/java/com/github/ddth/redis/RedisClientFactory.java | RedisClientFactory.calcRedisPoolName | protected static String calcRedisPoolName(String host, int port, String username,
String password, PoolConfig poolConfig) {
StringBuilder sb = new StringBuilder();
sb.append(host != null ? host : "NULL");
sb.append(".");
sb.append(port);
sb.append(".");
sb.append(username != null ? username : "NULL");
sb.append(".");
int passwordHashcode = password != null ? password.hashCode() : "NULL".hashCode();
int poolHashcode = poolConfig != null ? poolConfig.hashCode() : "NULL".hashCode();
return sb.append(passwordHashcode).append(".").append(poolHashcode).toString();
} | java | protected static String calcRedisPoolName(String host, int port, String username,
String password, PoolConfig poolConfig) {
StringBuilder sb = new StringBuilder();
sb.append(host != null ? host : "NULL");
sb.append(".");
sb.append(port);
sb.append(".");
sb.append(username != null ? username : "NULL");
sb.append(".");
int passwordHashcode = password != null ? password.hashCode() : "NULL".hashCode();
int poolHashcode = poolConfig != null ? poolConfig.hashCode() : "NULL".hashCode();
return sb.append(passwordHashcode).append(".").append(poolHashcode).toString();
} | [
"protected",
"static",
"String",
"calcRedisPoolName",
"(",
"String",
"host",
",",
"int",
"port",
",",
"String",
"username",
",",
"String",
"password",
",",
"PoolConfig",
"poolConfig",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",... | Builds a unique pool name from configurations.
@param host
@param port
@param username
@param password
@param poolConfig
@return | [
"Builds",
"a",
"unique",
"pool",
"name",
"from",
"configurations",
"."
] | 7e6abc3e43c9efe7e9c293d421c94227253ded87 | https://github.com/DDTH/ddth-redis/blob/7e6abc3e43c9efe7e9c293d421c94227253ded87/src/main/java/com/github/ddth/redis/RedisClientFactory.java#L94-L106 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java | JavacProcessingEnvironment.importStringToPattern | private static Pattern importStringToPattern(String s, Processor p, Log log) {
if (isValidImportString(s)) {
return validImportStringToPattern(s);
} else {
log.warning("proc.malformed.supported.string", s, p.getClass().getName());
return noMatches; // won't match any valid identifier
}
} | java | private static Pattern importStringToPattern(String s, Processor p, Log log) {
if (isValidImportString(s)) {
return validImportStringToPattern(s);
} else {
log.warning("proc.malformed.supported.string", s, p.getClass().getName());
return noMatches; // won't match any valid identifier
}
} | [
"private",
"static",
"Pattern",
"importStringToPattern",
"(",
"String",
"s",
",",
"Processor",
"p",
",",
"Log",
"log",
")",
"{",
"if",
"(",
"isValidImportString",
"(",
"s",
")",
")",
"{",
"return",
"validImportStringToPattern",
"(",
"s",
")",
";",
"}",
"el... | Convert import-style string for supported annotations into a
regex matching that string. If the string is a valid
import-style string, return a regex that won't match anything. | [
"Convert",
"import",
"-",
"style",
"string",
"for",
"supported",
"annotations",
"into",
"a",
"regex",
"matching",
"that",
"string",
".",
"If",
"the",
"string",
"is",
"a",
"valid",
"import",
"-",
"style",
"string",
"return",
"a",
"regex",
"that",
"won",
"t"... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java#L1456-L1463 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java | BuilderFactory.getProfileSummaryBuilder | public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
Profile nextProfile) throws Exception {
return ProfileSummaryBuilder.getInstance(context, profile,
writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
} | java | public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
Profile nextProfile) throws Exception {
return ProfileSummaryBuilder.getInstance(context, profile,
writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
} | [
"public",
"AbstractBuilder",
"getProfileSummaryBuilder",
"(",
"Profile",
"profile",
",",
"Profile",
"prevProfile",
",",
"Profile",
"nextProfile",
")",
"throws",
"Exception",
"{",
"return",
"ProfileSummaryBuilder",
".",
"getInstance",
"(",
"context",
",",
"profile",
",... | Return the builder that builds the profile summary.
@param profile the profile being documented.
@param prevProfile the previous profile being documented.
@param nextProfile the next profile being documented.
@return the builder that builds the profile summary. | [
"Return",
"the",
"builder",
"that",
"builds",
"the",
"profile",
"summary",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java#L107-L111 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java | BuilderFactory.getProfilePackageSummaryBuilder | public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
PackageDoc nextPkg, Profile profile) throws Exception {
return ProfilePackageSummaryBuilder.getInstance(context, pkg,
writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
profile), profile);
} | java | public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
PackageDoc nextPkg, Profile profile) throws Exception {
return ProfilePackageSummaryBuilder.getInstance(context, pkg,
writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
profile), profile);
} | [
"public",
"AbstractBuilder",
"getProfilePackageSummaryBuilder",
"(",
"PackageDoc",
"pkg",
",",
"PackageDoc",
"prevPkg",
",",
"PackageDoc",
"nextPkg",
",",
"Profile",
"profile",
")",
"throws",
"Exception",
"{",
"return",
"ProfilePackageSummaryBuilder",
".",
"getInstance",
... | Return the builder that builds the profile package summary.
@param pkg the profile package being documented.
@param prevPkg the previous profile package being documented.
@param nextPkg the next profile package being documented.
@param profile the profile being documented.
@return the builder that builds the profile package summary. | [
"Return",
"the",
"builder",
"that",
"builds",
"the",
"profile",
"package",
"summary",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java#L122-L127 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java | ParamTaglet.getInheritedTagletOutput | private Content getInheritedTagletOutput(boolean isNonTypeParams, Doc holder,
TagletWriter writer, Object[] formalParameters,
Set<String> alreadyDocumented) {
Content result = writer.getOutputInstance();
if ((! alreadyDocumented.contains(null)) &&
holder instanceof MethodDoc) {
for (int i = 0; i < formalParameters.length; i++) {
if (alreadyDocumented.contains(String.valueOf(i))) {
continue;
}
//This parameter does not have any @param documentation.
//Try to inherit it.
DocFinder.Output inheritedDoc =
DocFinder.search(new DocFinder.Input((MethodDoc) holder, this,
String.valueOf(i), ! isNonTypeParams));
if (inheritedDoc.inlineTags != null &&
inheritedDoc.inlineTags.length > 0) {
result.addContent(
processParamTag(isNonTypeParams, writer,
(ParamTag) inheritedDoc.holderTag,
isNonTypeParams ?
((Parameter) formalParameters[i]).name():
((TypeVariable) formalParameters[i]).typeName(),
alreadyDocumented.size() == 0));
}
alreadyDocumented.add(String.valueOf(i));
}
}
return result;
} | java | private Content getInheritedTagletOutput(boolean isNonTypeParams, Doc holder,
TagletWriter writer, Object[] formalParameters,
Set<String> alreadyDocumented) {
Content result = writer.getOutputInstance();
if ((! alreadyDocumented.contains(null)) &&
holder instanceof MethodDoc) {
for (int i = 0; i < formalParameters.length; i++) {
if (alreadyDocumented.contains(String.valueOf(i))) {
continue;
}
//This parameter does not have any @param documentation.
//Try to inherit it.
DocFinder.Output inheritedDoc =
DocFinder.search(new DocFinder.Input((MethodDoc) holder, this,
String.valueOf(i), ! isNonTypeParams));
if (inheritedDoc.inlineTags != null &&
inheritedDoc.inlineTags.length > 0) {
result.addContent(
processParamTag(isNonTypeParams, writer,
(ParamTag) inheritedDoc.holderTag,
isNonTypeParams ?
((Parameter) formalParameters[i]).name():
((TypeVariable) formalParameters[i]).typeName(),
alreadyDocumented.size() == 0));
}
alreadyDocumented.add(String.valueOf(i));
}
}
return result;
} | [
"private",
"Content",
"getInheritedTagletOutput",
"(",
"boolean",
"isNonTypeParams",
",",
"Doc",
"holder",
",",
"TagletWriter",
"writer",
",",
"Object",
"[",
"]",
"formalParameters",
",",
"Set",
"<",
"String",
">",
"alreadyDocumented",
")",
"{",
"Content",
"result... | Loop through each indivitual parameter. It it does not have a
corresponding param tag, try to inherit it. | [
"Loop",
"through",
"each",
"indivitual",
"parameter",
".",
"It",
"it",
"does",
"not",
"have",
"a",
"corresponding",
"param",
"tag",
"try",
"to",
"inherit",
"it",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java#L218-L247 | train |
brianwhu/xillium | gear/src/main/java/org/xillium/gear/util/TimeLimitedStrategy.java | TimeLimitedStrategy.observe | @Override
public void observe(int age) throws InterruptedException {
if (System.currentTimeMillis() >= _limit) {
throw new InterruptedException("Time{" + System.currentTimeMillis() + "}HasPassed{" + _limit + '}');
}
} | java | @Override
public void observe(int age) throws InterruptedException {
if (System.currentTimeMillis() >= _limit) {
throw new InterruptedException("Time{" + System.currentTimeMillis() + "}HasPassed{" + _limit + '}');
}
} | [
"@",
"Override",
"public",
"void",
"observe",
"(",
"int",
"age",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
">=",
"_limit",
")",
"{",
"throw",
"new",
"InterruptedException",
"(",
"\"Time{\"",
"+",
"Sy... | Checks the current system time against the time limit, throwing an InterruptedException if the time is up. | [
"Checks",
"the",
"current",
"system",
"time",
"against",
"the",
"time",
"limit",
"throwing",
"an",
"InterruptedException",
"if",
"the",
"time",
"is",
"up",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/gear/src/main/java/org/xillium/gear/util/TimeLimitedStrategy.java#L21-L26 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/model/JavacElements.java | JavacElements.nameToSymbol | private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
} | java | private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
} | [
"private",
"<",
"S",
"extends",
"Symbol",
">",
"S",
"nameToSymbol",
"(",
"String",
"nameStr",
",",
"Class",
"<",
"S",
">",
"clazz",
")",
"{",
"Name",
"name",
"=",
"names",
".",
"fromString",
"(",
"nameStr",
")",
";",
"// First check cache.",
"Symbol",
"s... | Returns a symbol given the type's or packages's canonical name,
or null if the name isn't found. | [
"Returns",
"a",
"symbol",
"given",
"the",
"type",
"s",
"or",
"packages",
"s",
"canonical",
"name",
"or",
"null",
"if",
"the",
"name",
"isn",
"t",
"found",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/model/JavacElements.java#L116-L138 | train |
seedstack/shed | src/main/java/org/seedstack/shed/text/TextUtils.java | TextUtils.leftPad | public static String leftPad(String text, String padding, int linesToIgnore) {
StringBuilder result = new StringBuilder();
Matcher matcher = LINE_START_PATTERN.matcher(text);
while (matcher.find()) {
if (linesToIgnore > 0) {
linesToIgnore--;
} else {
result.append(padding);
}
result.append(matcher.group()).append("\n");
}
return result.toString();
} | java | public static String leftPad(String text, String padding, int linesToIgnore) {
StringBuilder result = new StringBuilder();
Matcher matcher = LINE_START_PATTERN.matcher(text);
while (matcher.find()) {
if (linesToIgnore > 0) {
linesToIgnore--;
} else {
result.append(padding);
}
result.append(matcher.group()).append("\n");
}
return result.toString();
} | [
"public",
"static",
"String",
"leftPad",
"(",
"String",
"text",
",",
"String",
"padding",
",",
"int",
"linesToIgnore",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Matcher",
"matcher",
"=",
"LINE_START_PATTERN",
".",
"match... | Inserts the specified string at the beginning of each newline of the specified text.
@param text the text to pad.
@param padding the padding.
@param linesToIgnore the number of lines to ignore before starting the padding.
@return the padded text. | [
"Inserts",
"the",
"specified",
"string",
"at",
"the",
"beginning",
"of",
"each",
"newline",
"of",
"the",
"specified",
"text",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/text/TextUtils.java#L37-L50 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java | AnnotationPredicates.classOrAncestorAnnotatedWith | public static Predicate<Class<?>> classOrAncestorAnnotatedWith(final Class<? extends Annotation> annotationClass,
boolean includeMetaAnnotations) {
return candidate -> candidate != null && Classes.from(candidate)
.traversingSuperclasses()
.traversingInterfaces()
.classes()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | java | public static Predicate<Class<?>> classOrAncestorAnnotatedWith(final Class<? extends Annotation> annotationClass,
boolean includeMetaAnnotations) {
return candidate -> candidate != null && Classes.from(candidate)
.traversingSuperclasses()
.traversingInterfaces()
.classes()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"classOrAncestorAnnotatedWith",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"boolean",
"includeMetaAnnotations",
")",
"{",
"return",
"candidate",
"->",
... | Checks if the candidate or one of its superclasses or interfaces is annotated with the
specified annotation.
@param annotationClass the requested annotation
@param includeMetaAnnotations if true, meta-annotations are included in the search.
@return the predicate. | [
"Checks",
"if",
"the",
"candidate",
"or",
"one",
"of",
"its",
"superclasses",
"or",
"interfaces",
"is",
"annotated",
"with",
"the",
"specified",
"annotation",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java#L61-L68 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java | AnnotationPredicates.annotationIsOfClass | public static Predicate<Annotation> annotationIsOfClass(final Class<? extends Annotation> annotationClass) {
return candidate -> candidate != null && candidate.annotationType().equals(annotationClass);
} | java | public static Predicate<Annotation> annotationIsOfClass(final Class<? extends Annotation> annotationClass) {
return candidate -> candidate != null && candidate.annotationType().equals(annotationClass);
} | [
"public",
"static",
"Predicate",
"<",
"Annotation",
">",
"annotationIsOfClass",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"return",
"candidate",
"->",
"candidate",
"!=",
"null",
"&&",
"candidate",
".",
"annotatio... | Checks if the candidate annotation is of the specified annotation class.
@param annotationClass the annotation class to check for.
@return the predicate. | [
"Checks",
"if",
"the",
"candidate",
"annotation",
"is",
"of",
"the",
"specified",
"annotation",
"class",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java#L76-L78 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java | AnnotationPredicates.atLeastOneFieldAnnotatedWith | public static Predicate<Class<?>> atLeastOneFieldAnnotatedWith(final Class<? extends Annotation> annotationClass,
boolean includeMetaAnnotations) {
return candidate -> candidate != null && Classes.from(candidate)
.traversingSuperclasses()
.fields()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | java | public static Predicate<Class<?>> atLeastOneFieldAnnotatedWith(final Class<? extends Annotation> annotationClass,
boolean includeMetaAnnotations) {
return candidate -> candidate != null && Classes.from(candidate)
.traversingSuperclasses()
.fields()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"atLeastOneFieldAnnotatedWith",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"boolean",
"includeMetaAnnotations",
")",
"{",
"return",
"candidate",
"->",
... | Checks if the candidate or one of its superclasses has at least one field annotated or
meta-annotated by the given annotation.
@param annotationClass the requested annotation
@param includeMetaAnnotations if true, meta-annotations are included in the search.
@return the predicate. | [
"Checks",
"if",
"the",
"candidate",
"or",
"one",
"of",
"its",
"superclasses",
"has",
"at",
"least",
"one",
"field",
"annotated",
"or",
"meta",
"-",
"annotated",
"by",
"the",
"given",
"annotation",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java#L88-L94 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java | AnnotationPredicates.atLeastOneMethodAnnotatedWith | public static Predicate<Class<?>> atLeastOneMethodAnnotatedWith(final Class<? extends Annotation>
annotationClass, boolean includeMetaAnnotations) {
return candidate -> Classes.from(candidate)
.traversingInterfaces()
.traversingSuperclasses()
.methods()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | java | public static Predicate<Class<?>> atLeastOneMethodAnnotatedWith(final Class<? extends Annotation>
annotationClass, boolean includeMetaAnnotations) {
return candidate -> Classes.from(candidate)
.traversingInterfaces()
.traversingSuperclasses()
.methods()
.anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations));
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"atLeastOneMethodAnnotatedWith",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"boolean",
"includeMetaAnnotations",
")",
"{",
"return",
"candidate",
"->",
... | Checks if the candidate or one of its superclasses or interfaces has at least one method
annotated or meta-annotated
by the given annotation.
@param annotationClass the requested annotation
@param includeMetaAnnotations if true, meta-annotations are included in the search.
@return the predicate. | [
"Checks",
"if",
"the",
"candidate",
"or",
"one",
"of",
"its",
"superclasses",
"or",
"interfaces",
"has",
"at",
"least",
"one",
"method",
"annotated",
"or",
"meta",
"-",
"annotated",
"by",
"the",
"given",
"annotation",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/AnnotationPredicates.java#L105-L113 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINSyntaxChecker.java | VATINSyntaxChecker.isValidVATIN | public static boolean isValidVATIN (@Nonnull final String sVATIN, final boolean bIfNoValidator)
{
ValueEnforcer.notNull (sVATIN, "VATIN");
if (sVATIN.length () > 2)
{
final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US);
final IToBooleanFunction <String> aValidator = s_aMap.get (sCountryCode);
if (aValidator != null)
return aValidator.applyAsBoolean (sVATIN.substring (2));
}
// No validator
return bIfNoValidator;
} | java | public static boolean isValidVATIN (@Nonnull final String sVATIN, final boolean bIfNoValidator)
{
ValueEnforcer.notNull (sVATIN, "VATIN");
if (sVATIN.length () > 2)
{
final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US);
final IToBooleanFunction <String> aValidator = s_aMap.get (sCountryCode);
if (aValidator != null)
return aValidator.applyAsBoolean (sVATIN.substring (2));
}
// No validator
return bIfNoValidator;
} | [
"public",
"static",
"boolean",
"isValidVATIN",
"(",
"@",
"Nonnull",
"final",
"String",
"sVATIN",
",",
"final",
"boolean",
"bIfNoValidator",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sVATIN",
",",
"\"VATIN\"",
")",
";",
"if",
"(",
"sVATIN",
".",
"lengt... | Check if the provided VATIN is valid. This method handles VATINs for all
countries. This check uses only the checksum algorithm and does not call
any webservice etc.
@param sVATIN
VATIN to check. May not be <code>null</code>.
@param bIfNoValidator
What to return if no validator was found?
@return <code>true</code> if the VATIN is valid (or unknown).
@since 6.0.1 | [
"Check",
"if",
"the",
"provided",
"VATIN",
"is",
"valid",
".",
"This",
"method",
"handles",
"VATINs",
"for",
"all",
"countries",
".",
"This",
"check",
"uses",
"only",
"the",
"checksum",
"algorithm",
"and",
"does",
"not",
"call",
"any",
"webservice",
"etc",
... | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINSyntaxChecker.java#L105-L118 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINSyntaxChecker.java | VATINSyntaxChecker.isValidatorPresent | public static boolean isValidatorPresent (@Nonnull final String sVATIN)
{
ValueEnforcer.notNull (sVATIN, "VATIN");
if (sVATIN.length () <= 2)
return false;
final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US);
return s_aMap.containsKey (sCountryCode);
} | java | public static boolean isValidatorPresent (@Nonnull final String sVATIN)
{
ValueEnforcer.notNull (sVATIN, "VATIN");
if (sVATIN.length () <= 2)
return false;
final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US);
return s_aMap.containsKey (sCountryCode);
} | [
"public",
"static",
"boolean",
"isValidatorPresent",
"(",
"@",
"Nonnull",
"final",
"String",
"sVATIN",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sVATIN",
",",
"\"VATIN\"",
")",
";",
"if",
"(",
"sVATIN",
".",
"length",
"(",
")",
"<=",
"2",
")",
"re... | Check if a validator is present for the provided VATIN.
@param sVATIN
VATIN to check. May not be <code>null</code>.
@return <code>true</code> if a validator is present, <code>false</code> if
not. | [
"Check",
"if",
"a",
"validator",
"is",
"present",
"for",
"the",
"provided",
"VATIN",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINSyntaxChecker.java#L128-L136 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java | HtmlDocWriter.printFramesetDocument | public void printFramesetDocument(String title, boolean noTimeStamp,
Content frameset) throws IOException {
Content htmlDocType = DocType.FRAMESET;
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
Content head = new HtmlTree(HtmlTag.HEAD);
head.addContent(getGeneratedBy(!noTimeStamp));
if (configuration.charset.length() > 0) {
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
configuration.charset);
head.addContent(meta);
}
Content windowTitle = HtmlTree.TITLE(new StringContent(title));
head.addContent(windowTitle);
head.addContent(getFramesetJavaScript());
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
head, frameset);
Content htmlDocument = new HtmlDocument(htmlDocType,
htmlComment, htmlTree);
write(htmlDocument);
} | java | public void printFramesetDocument(String title, boolean noTimeStamp,
Content frameset) throws IOException {
Content htmlDocType = DocType.FRAMESET;
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
Content head = new HtmlTree(HtmlTag.HEAD);
head.addContent(getGeneratedBy(!noTimeStamp));
if (configuration.charset.length() > 0) {
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
configuration.charset);
head.addContent(meta);
}
Content windowTitle = HtmlTree.TITLE(new StringContent(title));
head.addContent(windowTitle);
head.addContent(getFramesetJavaScript());
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
head, frameset);
Content htmlDocument = new HtmlDocument(htmlDocType,
htmlComment, htmlTree);
write(htmlDocument);
} | [
"public",
"void",
"printFramesetDocument",
"(",
"String",
"title",
",",
"boolean",
"noTimeStamp",
",",
"Content",
"frameset",
")",
"throws",
"IOException",
"{",
"Content",
"htmlDocType",
"=",
"DocType",
".",
"FRAMESET",
";",
"Content",
"htmlComment",
"=",
"new",
... | Print the frameset version of the Html file header.
Called only when generating an HTML frameset file.
@param title Title of this HTML document
@param noTimeStamp If true, don't print time stamp in header
@param frameset the frameset to be added to the HTML document | [
"Print",
"the",
"frameset",
"version",
"of",
"the",
"Html",
"file",
"header",
".",
"Called",
"only",
"when",
"generating",
"an",
"HTML",
"frameset",
"file",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java#L308-L327 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.skip | private void skip(boolean stopAtImport, boolean stopAtMemberDecl, boolean stopAtIdentifier, boolean stopAtStatement) {
while (true) {
switch (token.kind) {
case SEMI:
nextToken();
return;
case PUBLIC:
case FINAL:
case ABSTRACT:
case MONKEYS_AT:
case EOF:
case CLASS:
case INTERFACE:
case ENUM:
return;
case IMPORT:
if (stopAtImport)
return;
break;
case LBRACE:
case RBRACE:
case PRIVATE:
case PROTECTED:
case STATIC:
case TRANSIENT:
case NATIVE:
case VOLATILE:
case SYNCHRONIZED:
case STRICTFP:
case LT:
case BYTE:
case SHORT:
case CHAR:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case BOOLEAN:
case VOID:
if (stopAtMemberDecl)
return;
break;
case UNDERSCORE:
case IDENTIFIER:
if (stopAtIdentifier)
return;
break;
case CASE:
case DEFAULT:
case IF:
case FOR:
case WHILE:
case DO:
case TRY:
case SWITCH:
case RETURN:
case THROW:
case BREAK:
case CONTINUE:
case ELSE:
case FINALLY:
case CATCH:
if (stopAtStatement)
return;
break;
}
nextToken();
}
} | java | private void skip(boolean stopAtImport, boolean stopAtMemberDecl, boolean stopAtIdentifier, boolean stopAtStatement) {
while (true) {
switch (token.kind) {
case SEMI:
nextToken();
return;
case PUBLIC:
case FINAL:
case ABSTRACT:
case MONKEYS_AT:
case EOF:
case CLASS:
case INTERFACE:
case ENUM:
return;
case IMPORT:
if (stopAtImport)
return;
break;
case LBRACE:
case RBRACE:
case PRIVATE:
case PROTECTED:
case STATIC:
case TRANSIENT:
case NATIVE:
case VOLATILE:
case SYNCHRONIZED:
case STRICTFP:
case LT:
case BYTE:
case SHORT:
case CHAR:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case BOOLEAN:
case VOID:
if (stopAtMemberDecl)
return;
break;
case UNDERSCORE:
case IDENTIFIER:
if (stopAtIdentifier)
return;
break;
case CASE:
case DEFAULT:
case IF:
case FOR:
case WHILE:
case DO:
case TRY:
case SWITCH:
case RETURN:
case THROW:
case BREAK:
case CONTINUE:
case ELSE:
case FINALLY:
case CATCH:
if (stopAtStatement)
return;
break;
}
nextToken();
}
} | [
"private",
"void",
"skip",
"(",
"boolean",
"stopAtImport",
",",
"boolean",
"stopAtMemberDecl",
",",
"boolean",
"stopAtIdentifier",
",",
"boolean",
"stopAtStatement",
")",
"{",
"while",
"(",
"true",
")",
"{",
"switch",
"(",
"token",
".",
"kind",
")",
"{",
"ca... | Skip forward until a suitable stop token is found. | [
"Skip",
"forward",
"until",
"a",
"suitable",
"stop",
"token",
"is",
"found",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L368-L436 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.checkNoMods | void checkNoMods(long mods) {
if (mods != 0) {
long lowestMod = mods & -mods;
error(token.pos, "mod.not.allowed.here",
Flags.asFlagSet(lowestMod));
}
} | java | void checkNoMods(long mods) {
if (mods != 0) {
long lowestMod = mods & -mods;
error(token.pos, "mod.not.allowed.here",
Flags.asFlagSet(lowestMod));
}
} | [
"void",
"checkNoMods",
"(",
"long",
"mods",
")",
"{",
"if",
"(",
"mods",
"!=",
"0",
")",
"{",
"long",
"lowestMod",
"=",
"mods",
"&",
"-",
"mods",
";",
"error",
"(",
"token",
".",
"pos",
",",
"\"mod.not.allowed.here\"",
",",
"Flags",
".",
"asFlagSet",
... | Diagnose a modifier flag from the set, if any. | [
"Diagnose",
"a",
"modifier",
"flag",
"from",
"the",
"set",
"if",
"any",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L529-L535 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.attach | void attach(JCTree tree, Comment dc) {
if (keepDocComments && dc != null) {
// System.out.println("doc comment = ");System.out.println(dc);//DEBUG
docComments.putComment(tree, dc);
}
} | java | void attach(JCTree tree, Comment dc) {
if (keepDocComments && dc != null) {
// System.out.println("doc comment = ");System.out.println(dc);//DEBUG
docComments.putComment(tree, dc);
}
} | [
"void",
"attach",
"(",
"JCTree",
"tree",
",",
"Comment",
"dc",
")",
"{",
"if",
"(",
"keepDocComments",
"&&",
"dc",
"!=",
"null",
")",
"{",
"// System.out.println(\"doc comment = \");System.out.println(dc);//DEBUG",
"docComments",
".",
"putComment",
"(",
"tree... | Make an entry into docComments hashtable,
provided flag keepDocComments is set and given doc comment is non-null.
@param tree The tree to be used as index in the hashtable
@param dc The doc comment to associate with the tree, or null. | [
"Make",
"an",
"entry",
"into",
"docComments",
"hashtable",
"provided",
"flag",
"keepDocComments",
"is",
"set",
"and",
"given",
"doc",
"comment",
"is",
"non",
"-",
"null",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L550-L555 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.forInit | List<JCStatement> forInit() {
ListBuffer<JCStatement> stats = new ListBuffer<>();
int pos = token.pos;
if (token.kind == FINAL || token.kind == MONKEYS_AT) {
return variableDeclarators(optFinal(0), parseType(), stats).toList();
} else {
JCExpression t = term(EXPR | TYPE);
if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList();
} else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
error(pos, "bad.initializer", "for-loop");
return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null));
} else {
return moreStatementExpressions(pos, t, stats).toList();
}
}
} | java | List<JCStatement> forInit() {
ListBuffer<JCStatement> stats = new ListBuffer<>();
int pos = token.pos;
if (token.kind == FINAL || token.kind == MONKEYS_AT) {
return variableDeclarators(optFinal(0), parseType(), stats).toList();
} else {
JCExpression t = term(EXPR | TYPE);
if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList();
} else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
error(pos, "bad.initializer", "for-loop");
return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null));
} else {
return moreStatementExpressions(pos, t, stats).toList();
}
}
} | [
"List",
"<",
"JCStatement",
">",
"forInit",
"(",
")",
"{",
"ListBuffer",
"<",
"JCStatement",
">",
"stats",
"=",
"new",
"ListBuffer",
"<>",
"(",
")",
";",
"int",
"pos",
"=",
"token",
".",
"pos",
";",
"if",
"(",
"token",
".",
"kind",
"==",
"FINAL",
"... | ForInit = StatementExpression MoreStatementExpressions
| { FINAL | '@' Annotation } Type VariableDeclarators | [
"ForInit",
"=",
"StatementExpression",
"MoreStatementExpressions",
"|",
"{",
"FINAL",
"|"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L2769-L2785 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.resource | protected JCTree resource() {
JCModifiers optFinal = optFinal(Flags.FINAL);
JCExpression type = parseType();
int pos = token.pos;
Name ident = ident();
return variableDeclaratorRest(pos, optFinal, type, ident, true, null);
} | java | protected JCTree resource() {
JCModifiers optFinal = optFinal(Flags.FINAL);
JCExpression type = parseType();
int pos = token.pos;
Name ident = ident();
return variableDeclaratorRest(pos, optFinal, type, ident, true, null);
} | [
"protected",
"JCTree",
"resource",
"(",
")",
"{",
"JCModifiers",
"optFinal",
"=",
"optFinal",
"(",
"Flags",
".",
"FINAL",
")",
";",
"JCExpression",
"type",
"=",
"parseType",
"(",
")",
";",
"int",
"pos",
"=",
"token",
".",
"pos",
";",
"Name",
"ident",
"... | Resource = VariableModifiersOpt Type VariableDeclaratorId = Expression | [
"Resource",
"=",
"VariableModifiersOpt",
"Type",
"VariableDeclaratorId",
"=",
"Expression"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L3122-L3128 | train |
brianwhu/xillium | gear/src/main/java/org/xillium/gear/util/VitalTask.java | VitalTask.run | public final void run() {
_interrupted = null;
_age = 0;
while (true) {
try {
_strategy.observe(_age);
if (_preparation != null) _preparation.run();
_result = execute();
if (_age > 0) {
_reporting.emit(Level.INFO, "Failure recovered: " + toString(), _age, _logger);
}
break;
} catch (InterruptedException x) {
_logger.log(Level.WARNING, "Interrupted, age = " + _age, x);
_interrupted = x;
break;
} catch (Exception x) {
_reporting.emit(x, "Failure detected, age = " + _age, _age, _logger);
try {
_strategy.backoff(_age);
} catch (InterruptedException i) {
_logger.log(Level.WARNING, "Interrupted, age = " + _age, x);
_interrupted = i;
break;
}
++_age;
}
}
} | java | public final void run() {
_interrupted = null;
_age = 0;
while (true) {
try {
_strategy.observe(_age);
if (_preparation != null) _preparation.run();
_result = execute();
if (_age > 0) {
_reporting.emit(Level.INFO, "Failure recovered: " + toString(), _age, _logger);
}
break;
} catch (InterruptedException x) {
_logger.log(Level.WARNING, "Interrupted, age = " + _age, x);
_interrupted = x;
break;
} catch (Exception x) {
_reporting.emit(x, "Failure detected, age = " + _age, _age, _logger);
try {
_strategy.backoff(_age);
} catch (InterruptedException i) {
_logger.log(Level.WARNING, "Interrupted, age = " + _age, x);
_interrupted = i;
break;
}
++_age;
}
}
} | [
"public",
"final",
"void",
"run",
"(",
")",
"{",
"_interrupted",
"=",
"null",
";",
"_age",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"_strategy",
".",
"observe",
"(",
"_age",
")",
";",
"if",
"(",
"_preparation",
"!=",
"null",
")",
... | Task entry point. | [
"Task",
"entry",
"point",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/gear/src/main/java/org/xillium/gear/util/VitalTask.java#L117-L145 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/storage/FileReportsProvider.java | FileReportsProvider.loadReport | protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
if (report.isDirectory())
{
FilenameFilter configYamlFilter = new PatternFilenameFilter("^reportconf.(yaml|json)$");
File[] selectYaml = report.listFiles(configYamlFilter);
if (selectYaml != null && selectYaml.length == 1)
{
File selectedYaml = selectYaml[0];
loadReport(result, FileUtils.openInputStream(selectedYaml), reportId);
}
}
} | java | protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
if (report.isDirectory())
{
FilenameFilter configYamlFilter = new PatternFilenameFilter("^reportconf.(yaml|json)$");
File[] selectYaml = report.listFiles(configYamlFilter);
if (selectYaml != null && selectYaml.length == 1)
{
File selectedYaml = selectYaml[0];
loadReport(result, FileUtils.openInputStream(selectedYaml), reportId);
}
}
} | [
"protected",
"void",
"loadReport",
"(",
"ReportsConfig",
"result",
",",
"File",
"report",
",",
"String",
"reportId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"report",
".",
"isDirectory",
"(",
")",
")",
"{",
"FilenameFilter",
"configYamlFilter",
"=",
"new... | Custom separate dload report component, so it can be called elsewhere, or overwritten by child Providers. Checks
the "report" to ensure it is a directory then looks for reportconf.yaml or reportconf.json inside the file. If it
exists loads it.
@param result The collection of reports to load the contents into.
@param report The directory that contains the report files.
@param reportId The report id
@throws IOException | [
"Custom",
"separate",
"dload",
"report",
"component",
"so",
"it",
"can",
"be",
"called",
"elsewhere",
"or",
"overwritten",
"by",
"child",
"Providers",
".",
"Checks",
"the",
"report",
"to",
"ensure",
"it",
"is",
"a",
"directory",
"then",
"looks",
"for",
"repo... | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/storage/FileReportsProvider.java#L74-L85 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/RpcException.java | RpcException.toMap | @SuppressWarnings("unchecked")
public Map toMap() {
HashMap map = new HashMap();
map.put("code", code);
map.put("message", message);
if (data != null)
map.put("data", data);
return map;
} | java | @SuppressWarnings("unchecked")
public Map toMap() {
HashMap map = new HashMap();
map.put("code", code);
map.put("message", message);
if (data != null)
map.put("data", data);
return map;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"toMap",
"(",
")",
"{",
"HashMap",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"code\"",
",",
"code",
")",
";",
"map",
".",
"put",
"(",
"\"message\"",
","... | Used to marshal this exception to a Map suiteable for serialization to JSON | [
"Used",
"to",
"marshal",
"this",
"exception",
"to",
"a",
"Map",
"suiteable",
"for",
"serialization",
"to",
"JSON"
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/RpcException.java#L99-L107 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/util/Options.java | Options.lint | public boolean lint(String s) {
// return true if either the specific option is enabled, or
// they are all enabled without the specific one being
// disabled
return
isSet(XLINT_CUSTOM, s) ||
(isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) &&
isUnset(XLINT_CUSTOM, "-" + s);
} | java | public boolean lint(String s) {
// return true if either the specific option is enabled, or
// they are all enabled without the specific one being
// disabled
return
isSet(XLINT_CUSTOM, s) ||
(isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) &&
isUnset(XLINT_CUSTOM, "-" + s);
} | [
"public",
"boolean",
"lint",
"(",
"String",
"s",
")",
"{",
"// return true if either the specific option is enabled, or",
"// they are all enabled without the specific one being",
"// disabled",
"return",
"isSet",
"(",
"XLINT_CUSTOM",
",",
"s",
")",
"||",
"(",
"isSet",
"(",... | Check for a lint suboption. | [
"Check",
"for",
"a",
"lint",
"suboption",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/Options.java#L174-L182 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java | OAuth2AuthorizationResource.refreshAccessToken | @POST
@Path("refresh")
@Consumes(MediaType.APPLICATION_JSON)
public Response refreshAccessToken(RefreshTokenRequest refreshToken) {
// Perform all validation here to control the exact error message returned to comply with the Oauth2 standard
if (null == refreshToken.getRefresh_token() ||
null == refreshToken.getGrant_type()) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request"));
}
if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) {
// Unsupported grant type
throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type"));
}
DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token());
if (null == connection) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant"));
}
// Invalidate the old cache key
connectionDao.invalidateCacheKey(connection.getAccessToken());
connection.setAccessToken(accessTokenGenerator.generate());
connection.setExpireTime(calculateExpirationDate(tokenExpiresIn));
connectionDao.putWithCacheKey(connection.getAccessToken(), connection);
return Response.ok(ImmutableMap.builder()
.put("access_token", connection.getAccessToken())
.put("refresh_token", connection.getRefreshToken())
.put("expires_in", tokenExpiresIn)
.build())
.cookie(createCookie(connection.getAccessToken(), tokenExpiresIn))
.build();
} | java | @POST
@Path("refresh")
@Consumes(MediaType.APPLICATION_JSON)
public Response refreshAccessToken(RefreshTokenRequest refreshToken) {
// Perform all validation here to control the exact error message returned to comply with the Oauth2 standard
if (null == refreshToken.getRefresh_token() ||
null == refreshToken.getGrant_type()) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request"));
}
if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) {
// Unsupported grant type
throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type"));
}
DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token());
if (null == connection) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant"));
}
// Invalidate the old cache key
connectionDao.invalidateCacheKey(connection.getAccessToken());
connection.setAccessToken(accessTokenGenerator.generate());
connection.setExpireTime(calculateExpirationDate(tokenExpiresIn));
connectionDao.putWithCacheKey(connection.getAccessToken(), connection);
return Response.ok(ImmutableMap.builder()
.put("access_token", connection.getAccessToken())
.put("refresh_token", connection.getRefreshToken())
.put("expires_in", tokenExpiresIn)
.build())
.cookie(createCookie(connection.getAccessToken(), tokenExpiresIn))
.build();
} | [
"@",
"POST",
"@",
"Path",
"(",
"\"refresh\"",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"public",
"Response",
"refreshAccessToken",
"(",
"RefreshTokenRequest",
"refreshToken",
")",
"{",
"// Perform all validation here to control the exact error... | Refresh an access_token using the refresh token
@param refreshToken refresh token
@return @return access_token and refresh token if successful.
Success response http://tools.ietf.org/html/rfc6749#section-5.1
Failure response http://tools.ietf.org/html/rfc6749#section-5.2 | [
"Refresh",
"an",
"access_token",
"using",
"the",
"refresh",
"token"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java#L206-L243 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java | OAuth2AuthorizationResource.validate | @GET
@Path("tokeninfo")
public Response validate(@QueryParam("access_token") String access_token) {
checkNotNull(access_token);
DConnection connection = connectionDao.findByAccessToken(access_token);
LOGGER.debug("Connection {}", connection);
if (null == connection || hasAccessTokenExpired(connection)) {
throw new BadRequestRestException("Invalid access_token");
}
return Response.ok(ImmutableMap.builder()
.put("user_id", connection.getUserId())
.put("expires_in", Seconds.secondsBetween(DateTime.now(), new DateTime(connection.getExpireTime())).getSeconds())
.build())
.build();
} | java | @GET
@Path("tokeninfo")
public Response validate(@QueryParam("access_token") String access_token) {
checkNotNull(access_token);
DConnection connection = connectionDao.findByAccessToken(access_token);
LOGGER.debug("Connection {}", connection);
if (null == connection || hasAccessTokenExpired(connection)) {
throw new BadRequestRestException("Invalid access_token");
}
return Response.ok(ImmutableMap.builder()
.put("user_id", connection.getUserId())
.put("expires_in", Seconds.secondsBetween(DateTime.now(), new DateTime(connection.getExpireTime())).getSeconds())
.build())
.build();
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"tokeninfo\"",
")",
"public",
"Response",
"validate",
"(",
"@",
"QueryParam",
"(",
"\"access_token\"",
")",
"String",
"access_token",
")",
"{",
"checkNotNull",
"(",
"access_token",
")",
";",
"DConnection",
"connection",
"=",
"co... | Validate an access_token.
The Oauth2 specification does not specify how this should be done. Do similar to what Google does
@param access_token access token to validate. Be careful about using url safe tokens or use url encoding.
@return http 200 if success and some basic info about the access_token | [
"Validate",
"an",
"access_token",
".",
"The",
"Oauth2",
"specification",
"does",
"not",
"specify",
"how",
"this",
"should",
"be",
"done",
".",
"Do",
"similar",
"to",
"what",
"Google",
"does"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java#L357-L374 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java | OAuth2AuthorizationResource.logout | @GET
@Path("logout")
public Response logout() throws URISyntaxException {
return Response
.temporaryRedirect(new URI("/"))
.cookie(createCookie(null, 0))
.build();
} | java | @GET
@Path("logout")
public Response logout() throws URISyntaxException {
return Response
.temporaryRedirect(new URI("/"))
.cookie(createCookie(null, 0))
.build();
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"logout\"",
")",
"public",
"Response",
"logout",
"(",
")",
"throws",
"URISyntaxException",
"{",
"return",
"Response",
".",
"temporaryRedirect",
"(",
"new",
"URI",
"(",
"\"/\"",
")",
")",
".",
"cookie",
"(",
"createCookie",
"... | Remove cookie from the user agent.
@return Redirect to requests
@throws URISyntaxException | [
"Remove",
"cookie",
"from",
"the",
"user",
"agent",
"."
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java#L387-L394 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java | DocFinder.search | public static Output search(Input input) {
Output output = new Output();
if (input.isInheritDocTag) {
//Do nothing because "element" does not have any documentation.
//All it has it {@inheritDoc}.
} else if (input.taglet == null) {
//We want overall documentation.
output.inlineTags = input.isFirstSentence ?
input.element.firstSentenceTags() :
input.element.inlineTags();
output.holder = input.element;
} else {
input.taglet.inherit(input, output);
}
if (output.inlineTags != null && output.inlineTags.length > 0) {
return output;
}
output.isValidInheritDocTag = false;
Input inheritedSearchInput = input.copy();
inheritedSearchInput.isInheritDocTag = false;
if (input.element instanceof MethodDoc) {
MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod();
if (overriddenMethod != null) {
inheritedSearchInput.element = overriddenMethod;
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
//NOTE: When we fix the bug where ClassDoc.interfaceTypes() does
// not pass all implemented interfaces, we will use the
// appropriate element here.
MethodDoc[] implementedMethods =
(new ImplementedMethods((MethodDoc) input.element, null)).build(false);
for (int i = 0; i < implementedMethods.length; i++) {
inheritedSearchInput.element = implementedMethods[i];
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
} else if (input.element instanceof ClassDoc) {
ProgramElementDoc superclass = ((ClassDoc) input.element).superclass();
if (superclass != null) {
inheritedSearchInput.element = superclass;
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
}
return output;
} | java | public static Output search(Input input) {
Output output = new Output();
if (input.isInheritDocTag) {
//Do nothing because "element" does not have any documentation.
//All it has it {@inheritDoc}.
} else if (input.taglet == null) {
//We want overall documentation.
output.inlineTags = input.isFirstSentence ?
input.element.firstSentenceTags() :
input.element.inlineTags();
output.holder = input.element;
} else {
input.taglet.inherit(input, output);
}
if (output.inlineTags != null && output.inlineTags.length > 0) {
return output;
}
output.isValidInheritDocTag = false;
Input inheritedSearchInput = input.copy();
inheritedSearchInput.isInheritDocTag = false;
if (input.element instanceof MethodDoc) {
MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod();
if (overriddenMethod != null) {
inheritedSearchInput.element = overriddenMethod;
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
//NOTE: When we fix the bug where ClassDoc.interfaceTypes() does
// not pass all implemented interfaces, we will use the
// appropriate element here.
MethodDoc[] implementedMethods =
(new ImplementedMethods((MethodDoc) input.element, null)).build(false);
for (int i = 0; i < implementedMethods.length; i++) {
inheritedSearchInput.element = implementedMethods[i];
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
} else if (input.element instanceof ClassDoc) {
ProgramElementDoc superclass = ((ClassDoc) input.element).superclass();
if (superclass != null) {
inheritedSearchInput.element = superclass;
output = search(inheritedSearchInput);
output.isValidInheritDocTag = true;
if (output.inlineTags.length > 0) {
return output;
}
}
}
return output;
} | [
"public",
"static",
"Output",
"search",
"(",
"Input",
"input",
")",
"{",
"Output",
"output",
"=",
"new",
"Output",
"(",
")",
";",
"if",
"(",
"input",
".",
"isInheritDocTag",
")",
"{",
"//Do nothing because \"element\" does not have any documentation.",
"//All it has... | Search for the requested comments in the given element. If it does not
have comments, return documentation from the overriden element if possible.
If the overriden element does not exist or does not have documentation to
inherit, search for documentation to inherit from implemented methods.
@param input the input object used to perform the search.
@return an Output object representing the documentation that was found. | [
"Search",
"for",
"the",
"requested",
"comments",
"in",
"the",
"given",
"element",
".",
"If",
"it",
"does",
"not",
"have",
"comments",
"return",
"documentation",
"from",
"the",
"overriden",
"element",
"if",
"possible",
".",
"If",
"the",
"overriden",
"element",
... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java#L187-L243 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/BarristerServlet.java | BarristerServlet.init | public void init(ServletConfig config) throws ServletException {
try {
String idlPath = config.getInitParameter("idl");
if (idlPath == null) {
throw new ServletException("idl init param is required. Set to path to .json file, or classpath:/mycontract.json");
}
if (idlPath.startsWith("classpath:")) {
idlPath = idlPath.substring(10);
contract = Contract.load(getClass().getResourceAsStream(idlPath));
}
else {
contract = Contract.load(new File(idlPath));
}
server = new Server(contract);
int handlerCount = 0;
Enumeration params = config.getInitParameterNames();
while (params.hasMoreElements()) {
String key = params.nextElement().toString();
if (key.indexOf("handler.") == 0) {
String val = config.getInitParameter(key);
int pos = val.indexOf("=");
if (pos == -1) {
throw new ServletException("Invalid init param: key=" + key +
" value=" + val +
" -- should be: interfaceClass=implClass");
}
String ifaceCname = val.substring(0, pos);
String implCname = val.substring(pos+1);
Class ifaceClazz = Class.forName(ifaceCname);
Class implClazz = Class.forName(implCname);
server.addHandler(ifaceClazz, implClazz.newInstance());
handlerCount++;
}
}
if (handlerCount == 0) {
throw new ServletException("At least one handler.x init property is required");
}
}
catch (ServletException e) {
throw e;
}
catch (Exception e) {
throw new ServletException(e);
}
} | java | public void init(ServletConfig config) throws ServletException {
try {
String idlPath = config.getInitParameter("idl");
if (idlPath == null) {
throw new ServletException("idl init param is required. Set to path to .json file, or classpath:/mycontract.json");
}
if (idlPath.startsWith("classpath:")) {
idlPath = idlPath.substring(10);
contract = Contract.load(getClass().getResourceAsStream(idlPath));
}
else {
contract = Contract.load(new File(idlPath));
}
server = new Server(contract);
int handlerCount = 0;
Enumeration params = config.getInitParameterNames();
while (params.hasMoreElements()) {
String key = params.nextElement().toString();
if (key.indexOf("handler.") == 0) {
String val = config.getInitParameter(key);
int pos = val.indexOf("=");
if (pos == -1) {
throw new ServletException("Invalid init param: key=" + key +
" value=" + val +
" -- should be: interfaceClass=implClass");
}
String ifaceCname = val.substring(0, pos);
String implCname = val.substring(pos+1);
Class ifaceClazz = Class.forName(ifaceCname);
Class implClazz = Class.forName(implCname);
server.addHandler(ifaceClazz, implClazz.newInstance());
handlerCount++;
}
}
if (handlerCount == 0) {
throw new ServletException("At least one handler.x init property is required");
}
}
catch (ServletException e) {
throw e;
}
catch (Exception e) {
throw new ServletException(e);
}
} | [
"public",
"void",
"init",
"(",
"ServletConfig",
"config",
")",
"throws",
"ServletException",
"{",
"try",
"{",
"String",
"idlPath",
"=",
"config",
".",
"getInitParameter",
"(",
"\"idl\"",
")",
";",
"if",
"(",
"idlPath",
"==",
"null",
")",
"{",
"throw",
"new... | Initializes the servlet based on the init parameters in web.xml | [
"Initializes",
"the",
"servlet",
"based",
"on",
"the",
"init",
"parameters",
"in",
"web",
".",
"xml"
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/BarristerServlet.java#L72-L122 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getTargetProfilePackageLink | public Content getTargetProfilePackageLink(PackageDoc pd, String target,
Content label, String profileName) {
return getHyperLink(pathString(pd, DocPaths.profilePackageSummary(profileName)),
label, "", target);
} | java | public Content getTargetProfilePackageLink(PackageDoc pd, String target,
Content label, String profileName) {
return getHyperLink(pathString(pd, DocPaths.profilePackageSummary(profileName)),
label, "", target);
} | [
"public",
"Content",
"getTargetProfilePackageLink",
"(",
"PackageDoc",
"pd",
",",
"String",
"target",
",",
"Content",
"label",
",",
"String",
"profileName",
")",
"{",
"return",
"getHyperLink",
"(",
"pathString",
"(",
"pd",
",",
"DocPaths",
".",
"profilePackageSumm... | Get Profile Package link, with target frame.
@param pd the packageDoc object
@param target name of the target frame
@param label tag for the link
@param profileName the name of the profile being documented
@return a content for the target profile packages link | [
"Get",
"Profile",
"Package",
"link",
"with",
"target",
"frame",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L291-L295 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getTargetProfileLink | public Content getTargetProfileLink(String target, Content label,
String profileName) {
return getHyperLink(pathToRoot.resolve(
DocPaths.profileSummary(profileName)), label, "", target);
} | java | public Content getTargetProfileLink(String target, Content label,
String profileName) {
return getHyperLink(pathToRoot.resolve(
DocPaths.profileSummary(profileName)), label, "", target);
} | [
"public",
"Content",
"getTargetProfileLink",
"(",
"String",
"target",
",",
"Content",
"label",
",",
"String",
"profileName",
")",
"{",
"return",
"getHyperLink",
"(",
"pathToRoot",
".",
"resolve",
"(",
"DocPaths",
".",
"profileSummary",
"(",
"profileName",
")",
"... | Get Profile link, with target frame.
@param target name of the target frame
@param label tag for the link
@param profileName the name of the profile being documented
@return a content for the target profile link | [
"Get",
"Profile",
"link",
"with",
"target",
"frame",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L305-L309 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getTypeNameForProfile | public String getTypeNameForProfile(ClassDoc cd) {
StringBuilder typeName =
new StringBuilder((cd.containingPackage()).name().replace(".", "/"));
typeName.append("/")
.append(cd.name().replace(".", "$"));
return typeName.toString();
} | java | public String getTypeNameForProfile(ClassDoc cd) {
StringBuilder typeName =
new StringBuilder((cd.containingPackage()).name().replace(".", "/"));
typeName.append("/")
.append(cd.name().replace(".", "$"));
return typeName.toString();
} | [
"public",
"String",
"getTypeNameForProfile",
"(",
"ClassDoc",
"cd",
")",
"{",
"StringBuilder",
"typeName",
"=",
"new",
"StringBuilder",
"(",
"(",
"cd",
".",
"containingPackage",
"(",
")",
")",
".",
"name",
"(",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"/\... | Get the type name for profile search.
@param cd the classDoc object for which the type name conversion is needed
@return a type name string for the type | [
"Get",
"the",
"type",
"name",
"for",
"profile",
"search",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L317-L323 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.isTypeInProfile | public boolean isTypeInProfile(ClassDoc cd, int profileValue) {
return (configuration.profiles.getProfile(getTypeNameForProfile(cd)) <= profileValue);
} | java | public boolean isTypeInProfile(ClassDoc cd, int profileValue) {
return (configuration.profiles.getProfile(getTypeNameForProfile(cd)) <= profileValue);
} | [
"public",
"boolean",
"isTypeInProfile",
"(",
"ClassDoc",
"cd",
",",
"int",
"profileValue",
")",
"{",
"return",
"(",
"configuration",
".",
"profiles",
".",
"getProfile",
"(",
"getTypeNameForProfile",
"(",
"cd",
")",
")",
"<=",
"profileValue",
")",
";",
"}"
] | Check if a type belongs to a profile.
@param cd the classDoc object that needs to be checked
@param profileValue the profile in which the type needs to be checked
@return true if the type is in the profile | [
"Check",
"if",
"a",
"type",
"belongs",
"to",
"a",
"profile",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L332-L334 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.addBottom | public void addBottom(Content body) {
Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
Content small = HtmlTree.SMALL(bottom);
Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
body.addContent(p);
} | java | public void addBottom(Content body) {
Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
Content small = HtmlTree.SMALL(bottom);
Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
body.addContent(p);
} | [
"public",
"void",
"addBottom",
"(",
"Content",
"body",
")",
"{",
"Content",
"bottom",
"=",
"new",
"RawHtml",
"(",
"replaceDocRootDir",
"(",
"configuration",
".",
"bottom",
")",
")",
";",
"Content",
"small",
"=",
"HtmlTree",
".",
"SMALL",
"(",
"bottom",
")"... | Adds the user specified bottom.
@param body the content tree to which user specified bottom will be added | [
"Adds",
"the",
"user",
"specified",
"bottom",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L472-L477 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.addPackageDeprecatedAPI | protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey,
String tableSummary, String[] tableHeader, Content contentTree) {
if (deprPkgs.size() > 0) {
Content table = HtmlTree.TABLE(HtmlStyle.deprecatedSummary, 0, 3, 0, tableSummary,
getTableCaption(configuration.getResource(headingKey)));
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < deprPkgs.size(); i++) {
PackageDoc pkg = (PackageDoc) deprPkgs.get(i);
HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
getPackageLink(pkg, getPackageName(pkg)));
if (pkg.tags("deprecated").length > 0) {
addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td);
}
HtmlTree tr = HtmlTree.TR(td);
if (i % 2 == 0) {
tr.addStyle(HtmlStyle.altColor);
} else {
tr.addStyle(HtmlStyle.rowColor);
}
tbody.addContent(tr);
}
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
contentTree.addContent(ul);
}
} | java | protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey,
String tableSummary, String[] tableHeader, Content contentTree) {
if (deprPkgs.size() > 0) {
Content table = HtmlTree.TABLE(HtmlStyle.deprecatedSummary, 0, 3, 0, tableSummary,
getTableCaption(configuration.getResource(headingKey)));
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < deprPkgs.size(); i++) {
PackageDoc pkg = (PackageDoc) deprPkgs.get(i);
HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
getPackageLink(pkg, getPackageName(pkg)));
if (pkg.tags("deprecated").length > 0) {
addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td);
}
HtmlTree tr = HtmlTree.TR(td);
if (i % 2 == 0) {
tr.addStyle(HtmlStyle.altColor);
} else {
tr.addStyle(HtmlStyle.rowColor);
}
tbody.addContent(tr);
}
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
contentTree.addContent(ul);
}
} | [
"protected",
"void",
"addPackageDeprecatedAPI",
"(",
"List",
"<",
"Doc",
">",
"deprPkgs",
",",
"String",
"headingKey",
",",
"String",
"tableSummary",
",",
"String",
"[",
"]",
"tableHeader",
",",
"Content",
"contentTree",
")",
"{",
"if",
"(",
"deprPkgs",
".",
... | Add package deprecation information to the documentation tree
@param deprPkgs list of deprecated packages
@param headingKey the caption for the deprecated package table
@param tableSummary the summary for the deprecated package table
@param tableHeader table headers for the deprecated package table
@param contentTree the content tree to which the deprecated package table will be added | [
"Add",
"package",
"deprecation",
"information",
"to",
"the",
"documentation",
"tree"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L940-L967 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getScriptProperties | public HtmlTree getScriptProperties() {
HtmlTree script = HtmlTree.SCRIPT("text/javascript",
pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
return script;
} | java | public HtmlTree getScriptProperties() {
HtmlTree script = HtmlTree.SCRIPT("text/javascript",
pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
return script;
} | [
"public",
"HtmlTree",
"getScriptProperties",
"(",
")",
"{",
"HtmlTree",
"script",
"=",
"HtmlTree",
".",
"SCRIPT",
"(",
"\"text/javascript\"",
",",
"pathToRoot",
".",
"resolve",
"(",
"DocPaths",
".",
"JAVASCRIPT",
")",
".",
"getPath",
"(",
")",
")",
";",
"ret... | Returns a link to the JavaScript file.
@return an HtmlTree for the Script tag which provides the JavaScript location | [
"Returns",
"a",
"link",
"to",
"the",
"JavaScript",
"file",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L1815-L1819 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.addAnnotationInfo | private boolean addAnnotationInfo(int indent, Doc doc,
AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
List<Content> annotations = getAnnotations(indent, descList, lineBreak);
String sep ="";
if (annotations.isEmpty()) {
return false;
}
for (Content annotation: annotations) {
htmltree.addContent(sep);
htmltree.addContent(annotation);
sep = " ";
}
return true;
} | java | private boolean addAnnotationInfo(int indent, Doc doc,
AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
List<Content> annotations = getAnnotations(indent, descList, lineBreak);
String sep ="";
if (annotations.isEmpty()) {
return false;
}
for (Content annotation: annotations) {
htmltree.addContent(sep);
htmltree.addContent(annotation);
sep = " ";
}
return true;
} | [
"private",
"boolean",
"addAnnotationInfo",
"(",
"int",
"indent",
",",
"Doc",
"doc",
",",
"AnnotationDesc",
"[",
"]",
"descList",
",",
"boolean",
"lineBreak",
",",
"Content",
"htmltree",
")",
"{",
"List",
"<",
"Content",
">",
"annotations",
"=",
"getAnnotations... | Adds the annotation types for the given doc.
@param indent the number of extra spaces to indent the annotations.
@param doc the doc to write annotations for.
@param descList the array of {@link AnnotationDesc}.
@param htmltree the documentation tree to which the annotation info will be
added | [
"Adds",
"the",
"annotation",
"types",
"for",
"the",
"given",
"doc",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L1899-L1912 | train |
apruve/apruve-java | src/main/java/com/apruve/models/Payment.java | Payment.get | public static ApruveResponse<Payment> get(String paymentRequestId, String paymentId) {
return ApruveClient.getInstance().get(
getPaymentsPath(paymentRequestId) + paymentId, Payment.class);
} | java | public static ApruveResponse<Payment> get(String paymentRequestId, String paymentId) {
return ApruveClient.getInstance().get(
getPaymentsPath(paymentRequestId) + paymentId, Payment.class);
} | [
"public",
"static",
"ApruveResponse",
"<",
"Payment",
">",
"get",
"(",
"String",
"paymentRequestId",
",",
"String",
"paymentId",
")",
"{",
"return",
"ApruveClient",
".",
"getInstance",
"(",
")",
".",
"get",
"(",
"getPaymentsPath",
"(",
"paymentRequestId",
")",
... | Fetches the Payment with the given ID from Apruve.
@see <a
href="https://www.apruve.com/doc/developers/rest-api/">https://www.apruve.com/doc/developers/rest-api/</a>
@param paymentRequestId
The ID of the PaymentRequest that owns the Payment
@param paymentId
The ID of the Payment
@return Payment, or null if not found | [
"Fetches",
"the",
"Payment",
"with",
"the",
"given",
"ID",
"from",
"Apruve",
"."
] | b188d6b17f777823c2e46427847318849978685e | https://github.com/apruve/apruve-java/blob/b188d6b17f777823c2e46427847318849978685e/src/main/java/com/apruve/models/Payment.java#L102-L105 | train |
apruve/apruve-java | src/main/java/com/apruve/models/Payment.java | Payment.getAll | public static ApruveResponse<List<Payment>> getAll(String paymentRequestId) {
return ApruveClient.getInstance().index(
getPaymentsPath(paymentRequestId),
new GenericType<List<Payment>>() {
});
} | java | public static ApruveResponse<List<Payment>> getAll(String paymentRequestId) {
return ApruveClient.getInstance().index(
getPaymentsPath(paymentRequestId),
new GenericType<List<Payment>>() {
});
} | [
"public",
"static",
"ApruveResponse",
"<",
"List",
"<",
"Payment",
">",
">",
"getAll",
"(",
"String",
"paymentRequestId",
")",
"{",
"return",
"ApruveClient",
".",
"getInstance",
"(",
")",
".",
"index",
"(",
"getPaymentsPath",
"(",
"paymentRequestId",
")",
",",... | Fetches all Payments belonging to the PaymentRequest with the specified
ID.
@see <a
href="https://www.apruve.com/doc/developers/rest-api/">https://www.apruve.com/doc/developers/rest-api/</a>
@param paymentRequestId
The ID of the PaymentRequest that owns the Payment
@return List of Payments, or null if the PaymentRequest is not found | [
"Fetches",
"all",
"Payments",
"belonging",
"to",
"the",
"PaymentRequest",
"with",
"the",
"specified",
"ID",
"."
] | b188d6b17f777823c2e46427847318849978685e | https://github.com/apruve/apruve-java/blob/b188d6b17f777823c2e46427847318849978685e/src/main/java/com/apruve/models/Payment.java#L117-L122 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.init | public void init()
{
Dictionary<String, String> properties = getConfigurationProperties(this.getProperties(), false);
this.setProperties(properties);
this.setProperty(BundleConstants.SERVICE_PID, getServicePid());
this.setProperty(BundleConstants.SERVICE_CLASS, getServiceClassName());
} | java | public void init()
{
Dictionary<String, String> properties = getConfigurationProperties(this.getProperties(), false);
this.setProperties(properties);
this.setProperty(BundleConstants.SERVICE_PID, getServicePid());
this.setProperty(BundleConstants.SERVICE_CLASS, getServiceClassName());
} | [
"public",
"void",
"init",
"(",
")",
"{",
"Dictionary",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"getConfigurationProperties",
"(",
"this",
".",
"getProperties",
"(",
")",
",",
"false",
")",
";",
"this",
".",
"setProperties",
"(",
"properties",
... | Setup the application properties.
Override this to set the properties.
@param bundleContext BundleContext | [
"Setup",
"the",
"application",
"properties",
".",
"Override",
"this",
"to",
"set",
"the",
"properties",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L70-L76 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.start | public void start(BundleContext context) throws Exception {
ClassServiceUtility.log(context, LogService.LOG_INFO, "Starting " + this.getClass().getName() + " Bundle");
this.context = context;
this.init(); // Setup the properties
String interfaceClassName = getInterfaceClassName();
this.setProperty(BundleConstants.ACTIVATOR, this.getClass().getName()); // In case I have to find this service by activator class
try {
context.addServiceListener(this, ClassServiceUtility.addToFilter((String)null, Constants.OBJECTCLASS, interfaceClassName));
} catch (InvalidSyntaxException e) {
e.printStackTrace();
}
if (service == null)
{
boolean allStarted = this.checkDependentServices(context);
if (allStarted)
{
service = this.startupService(context);
this.registerService(service);
}
}
} | java | public void start(BundleContext context) throws Exception {
ClassServiceUtility.log(context, LogService.LOG_INFO, "Starting " + this.getClass().getName() + " Bundle");
this.context = context;
this.init(); // Setup the properties
String interfaceClassName = getInterfaceClassName();
this.setProperty(BundleConstants.ACTIVATOR, this.getClass().getName()); // In case I have to find this service by activator class
try {
context.addServiceListener(this, ClassServiceUtility.addToFilter((String)null, Constants.OBJECTCLASS, interfaceClassName));
} catch (InvalidSyntaxException e) {
e.printStackTrace();
}
if (service == null)
{
boolean allStarted = this.checkDependentServices(context);
if (allStarted)
{
service = this.startupService(context);
this.registerService(service);
}
}
} | [
"public",
"void",
"start",
"(",
"BundleContext",
"context",
")",
"throws",
"Exception",
"{",
"ClassServiceUtility",
".",
"log",
"(",
"context",
",",
"LogService",
".",
"LOG_INFO",
",",
"\"Starting \"",
"+",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
... | Bundle starting up.
Don't override this, override startupService. | [
"Bundle",
"starting",
"up",
".",
"Don",
"t",
"override",
"this",
"override",
"startupService",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L113-L137 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.stop | public void stop(BundleContext context) throws Exception {
ClassServiceUtility.log(context, LogService.LOG_INFO, "Stopping " + this.getClass().getName() + " Bundle");
if (this.shutdownService(service, context))
service = null;
// Unregisters automatically
this.context = null;
} | java | public void stop(BundleContext context) throws Exception {
ClassServiceUtility.log(context, LogService.LOG_INFO, "Stopping " + this.getClass().getName() + " Bundle");
if (this.shutdownService(service, context))
service = null;
// Unregisters automatically
this.context = null;
} | [
"public",
"void",
"stop",
"(",
"BundleContext",
"context",
")",
"throws",
"Exception",
"{",
"ClassServiceUtility",
".",
"log",
"(",
"context",
",",
"LogService",
".",
"LOG_INFO",
",",
"\"Stopping \"",
"+",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"... | Bundle stopping.
Don't override this, override shutdownService. | [
"Bundle",
"stopping",
".",
"Don",
"t",
"override",
"this",
"override",
"shutdownService",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L142-L148 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.registerService | public void registerService(Object service)
{
this.setService(service);
String serviceClass = getInterfaceClassName();
if (service != null)
serviceRegistration = context.registerService(serviceClass, this.service, properties);
} | java | public void registerService(Object service)
{
this.setService(service);
String serviceClass = getInterfaceClassName();
if (service != null)
serviceRegistration = context.registerService(serviceClass, this.service, properties);
} | [
"public",
"void",
"registerService",
"(",
"Object",
"service",
")",
"{",
"this",
".",
"setService",
"(",
"service",
")",
";",
"String",
"serviceClass",
"=",
"getInterfaceClassName",
"(",
")",
";",
"if",
"(",
"service",
"!=",
"null",
")",
"serviceRegistration",... | Get the service for this implementation class.
@param interfaceClassName
@return | [
"Get",
"the",
"service",
"for",
"this",
"implementation",
"class",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L253-L260 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.getService | public Object getService(String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String,String> filter)
{
return ClassServiceUtility.getClassService().getClassFinder(context).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, -1);
} | java | public Object getService(String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String,String> filter)
{
return ClassServiceUtility.getClassService().getClassFinder(context).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, -1);
} | [
"public",
"Object",
"getService",
"(",
"String",
"interfaceClassName",
",",
"String",
"serviceClassName",
",",
"String",
"versionRange",
",",
"Dictionary",
"<",
"String",
",",
"String",
">",
"filter",
")",
"{",
"return",
"ClassServiceUtility",
".",
"getClassService"... | Convenience method to get the service for this implementation class.
@param interfaceClassName
@return | [
"Convenience",
"method",
"to",
"get",
"the",
"service",
"for",
"this",
"implementation",
"class",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L284-L287 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.getServicePid | public String getServicePid()
{
String servicePid = context.getProperty(BundleConstants.SERVICE_PID);
if (servicePid != null)
return servicePid;
servicePid = this.getServiceClassName();
if (servicePid == null)
servicePid = this.getClass().getName();
return ClassFinderActivator.getPackageName(servicePid, false);
} | java | public String getServicePid()
{
String servicePid = context.getProperty(BundleConstants.SERVICE_PID);
if (servicePid != null)
return servicePid;
servicePid = this.getServiceClassName();
if (servicePid == null)
servicePid = this.getClass().getName();
return ClassFinderActivator.getPackageName(servicePid, false);
} | [
"public",
"String",
"getServicePid",
"(",
")",
"{",
"String",
"servicePid",
"=",
"context",
".",
"getProperty",
"(",
"BundleConstants",
".",
"SERVICE_PID",
")",
";",
"if",
"(",
"servicePid",
"!=",
"null",
")",
"return",
"servicePid",
";",
"servicePid",
"=",
... | The service key in the config admin system.
@return By default the package name, else override this. | [
"The",
"service",
"key",
"in",
"the",
"config",
"admin",
"system",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L293-L302 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.putAll | public static Dictionary<String, String> putAll(Dictionary<String, String> sourceDictionary, Dictionary<String, String> destDictionary)
{
if (destDictionary == null)
destDictionary = new Hashtable<String, String>();
if (sourceDictionary != null)
{
Enumeration<String> keys = sourceDictionary.keys();
while (keys.hasMoreElements())
{
String key = keys.nextElement();
destDictionary.put(key, sourceDictionary.get(key));
}
}
return destDictionary;
} | java | public static Dictionary<String, String> putAll(Dictionary<String, String> sourceDictionary, Dictionary<String, String> destDictionary)
{
if (destDictionary == null)
destDictionary = new Hashtable<String, String>();
if (sourceDictionary != null)
{
Enumeration<String> keys = sourceDictionary.keys();
while (keys.hasMoreElements())
{
String key = keys.nextElement();
destDictionary.put(key, sourceDictionary.get(key));
}
}
return destDictionary;
} | [
"public",
"static",
"Dictionary",
"<",
"String",
",",
"String",
">",
"putAll",
"(",
"Dictionary",
"<",
"String",
",",
"String",
">",
"sourceDictionary",
",",
"Dictionary",
"<",
"String",
",",
"String",
">",
"destDictionary",
")",
"{",
"if",
"(",
"destDiction... | Copy all the values from one dictionary to another.
@param sourceDictionary
@param destDictionary
@return | [
"Copy",
"all",
"the",
"values",
"from",
"one",
"dictionary",
"to",
"another",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L409-L423 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/CollectionUtils.java | CollectionUtils.getFirstNotNullValue | public static <T> T getFirstNotNullValue(final Collection<T> collection) {
if (isNotEmpty(collection)) {
for (T element : collection) {
if (element != null) {
return element;
}
}
}
return null;
} | java | public static <T> T getFirstNotNullValue(final Collection<T> collection) {
if (isNotEmpty(collection)) {
for (T element : collection) {
if (element != null) {
return element;
}
}
}
return null;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getFirstNotNullValue",
"(",
"final",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"if",
"(",
"isNotEmpty",
"(",
"collection",
")",
")",
"{",
"for",
"(",
"T",
"element",
":",
"collection",
")",
"{",
"if",... | Returns the first not null element if the collection is not null and have
not null value, else return null.
@param collection
the collection to be handled.
@return the first not null element if the collection is not null and have
not null value, else null. | [
"Returns",
"the",
"first",
"not",
"null",
"element",
"if",
"the",
"collection",
"is",
"not",
"null",
"and",
"have",
"not",
"null",
"value",
"else",
"return",
"null",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/CollectionUtils.java#L90-L100 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/CollectionUtils.java | CollectionUtils.toList | public static <T> List<T> toList(final Collection<T> collection) {
if (isEmpty(collection)) {
return new ArrayList<T>(0);
} else {
return new ArrayList<T>(collection);
}
} | java | public static <T> List<T> toList(final Collection<T> collection) {
if (isEmpty(collection)) {
return new ArrayList<T>(0);
} else {
return new ArrayList<T>(collection);
}
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"final",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"collection",
")",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"0",
... | Convert given collection to a list.
@param collection
source collection.
@return a list has full given collection element and order by collection
index. | [
"Convert",
"given",
"collection",
"to",
"a",
"list",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/CollectionUtils.java#L110-L117 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.