id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
115,400 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/printer/file/naming/DateFileNameGenerator.java | DateFileNameGenerator.generateFileName | @Override
public String generateFileName(int logLevel, long timestamp) {
SimpleDateFormat sdf = mLocalDateFormat.get();
sdf.setTimeZone(TimeZone.getDefault());
return sdf.format(new Date(timestamp));
} | java | @Override
public String generateFileName(int logLevel, long timestamp) {
SimpleDateFormat sdf = mLocalDateFormat.get();
sdf.setTimeZone(TimeZone.getDefault());
return sdf.format(new Date(timestamp));
} | [
"@",
"Override",
"public",
"String",
"generateFileName",
"(",
"int",
"logLevel",
",",
"long",
"timestamp",
")",
"{",
"SimpleDateFormat",
"sdf",
"=",
"mLocalDateFormat",
".",
"get",
"(",
")",
";",
"sdf",
".",
"setTimeZone",
"(",
"TimeZone",
".",
"getDefault",
... | Generate a file name which represent a specific date. | [
"Generate",
"a",
"file",
"name",
"which",
"represent",
"a",
"specific",
"date",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/printer/file/naming/DateFileNameGenerator.java#L45-L50 |
115,401 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/Logger.java | Logger.println | private <T> void println(int logLevel, T object) {
if (logLevel < logConfiguration.logLevel) {
return;
}
String objectString;
if (object != null) {
ObjectFormatter<? super T> objectFormatter = logConfiguration.getObjectFormatter(object);
if (objectFormatter != null) {
objectStr... | java | private <T> void println(int logLevel, T object) {
if (logLevel < logConfiguration.logLevel) {
return;
}
String objectString;
if (object != null) {
ObjectFormatter<? super T> objectFormatter = logConfiguration.getObjectFormatter(object);
if (objectFormatter != null) {
objectStr... | [
"private",
"<",
"T",
">",
"void",
"println",
"(",
"int",
"logLevel",
",",
"T",
"object",
")",
"{",
"if",
"(",
"logLevel",
"<",
"logConfiguration",
".",
"logLevel",
")",
"{",
"return",
";",
"}",
"String",
"objectString",
";",
"if",
"(",
"object",
"!=",
... | Print an object in a new line.
@param logLevel the log level of the printing object
@param object the object to print | [
"Print",
"an",
"object",
"in",
"a",
"new",
"line",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/Logger.java#L477-L493 |
115,402 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/Logger.java | Logger.println | private void println(int logLevel, Object[] array) {
if (logLevel < logConfiguration.logLevel) {
return;
}
printlnInternal(logLevel, Arrays.deepToString(array));
} | java | private void println(int logLevel, Object[] array) {
if (logLevel < logConfiguration.logLevel) {
return;
}
printlnInternal(logLevel, Arrays.deepToString(array));
} | [
"private",
"void",
"println",
"(",
"int",
"logLevel",
",",
"Object",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"logLevel",
"<",
"logConfiguration",
".",
"logLevel",
")",
"{",
"return",
";",
"}",
"printlnInternal",
"(",
"logLevel",
",",
"Arrays",
".",
"deep... | Print an array in a new line.
@param logLevel the log level of the printing array
@param array the array to print | [
"Print",
"an",
"array",
"in",
"a",
"new",
"line",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/Logger.java#L501-L506 |
115,403 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/Logger.java | Logger.printlnInternal | private void printlnInternal(int logLevel, String msg) {
String tag = logConfiguration.tag;
String thread = logConfiguration.withThread
? logConfiguration.threadFormatter.format(Thread.currentThread())
: null;
String stackTrace = logConfiguration.withStackTrace
? logConfiguration.sta... | java | private void printlnInternal(int logLevel, String msg) {
String tag = logConfiguration.tag;
String thread = logConfiguration.withThread
? logConfiguration.threadFormatter.format(Thread.currentThread())
: null;
String stackTrace = logConfiguration.withStackTrace
? logConfiguration.sta... | [
"private",
"void",
"printlnInternal",
"(",
"int",
"logLevel",
",",
"String",
"msg",
")",
"{",
"String",
"tag",
"=",
"logConfiguration",
".",
"tag",
";",
"String",
"thread",
"=",
"logConfiguration",
".",
"withThread",
"?",
"logConfiguration",
".",
"threadFormatte... | Print a log in a new line internally.
@param logLevel the log level of the printing log
@param msg the message you would like to log | [
"Print",
"a",
"log",
"in",
"a",
"new",
"line",
"internally",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/Logger.java#L557-L600 |
115,404 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/Logger.java | Logger.formatArgs | private String formatArgs(String format, Object... args) {
if (format != null) {
return String.format(format, args);
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0, N = args.length; i < N; i++) {
if (i != 0) {
sb.append(", ");
}
sb.append(args... | java | private String formatArgs(String format, Object... args) {
if (format != null) {
return String.format(format, args);
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0, N = args.length; i < N; i++) {
if (i != 0) {
sb.append(", ");
}
sb.append(args... | [
"private",
"String",
"formatArgs",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"format",
"!=",
"null",
")",
"{",
"return",
"String",
".",
"format",
"(",
"format",
",",
"args",
")",
";",
"}",
"else",
"{",
"StringBuilder",... | Format a string with arguments.
@param format the format string, null if just to concat the arguments
@param args the arguments
@return the formatted string | [
"Format",
"a",
"string",
"with",
"arguments",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/Logger.java#L609-L622 |
115,405 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java | StackTraceUtil.getCroppedRealStackTrack | public static StackTraceElement[] getCroppedRealStackTrack(StackTraceElement[] stackTrace,
String stackTraceOrigin,
int maxDepth) {
return cropStackTrace(getRealStackTrack(stackTrace, stackTrace... | java | public static StackTraceElement[] getCroppedRealStackTrack(StackTraceElement[] stackTrace,
String stackTraceOrigin,
int maxDepth) {
return cropStackTrace(getRealStackTrack(stackTrace, stackTrace... | [
"public",
"static",
"StackTraceElement",
"[",
"]",
"getCroppedRealStackTrack",
"(",
"StackTraceElement",
"[",
"]",
"stackTrace",
",",
"String",
"stackTraceOrigin",
",",
"int",
"maxDepth",
")",
"{",
"return",
"cropStackTrace",
"(",
"getRealStackTrack",
"(",
"stackTrace... | Get the real stack trace and then crop it with a max depth.
@param stackTrace the full stack trace
@param maxDepth the max depth of real stack trace that will be cropped, 0 means no limitation
@return the cropped real stack trace | [
"Get",
"the",
"real",
"stack",
"trace",
"and",
"then",
"crop",
"it",
"with",
"a",
"max",
"depth",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java#L72-L76 |
115,406 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java | StackTraceUtil.getRealStackTrack | private static StackTraceElement[] getRealStackTrack(StackTraceElement[] stackTrace,
String stackTraceOrigin) {
int ignoreDepth = 0;
int allDepth = stackTrace.length;
String className;
for (int i = allDepth - 1; i >= 0; i--) {
className = stac... | java | private static StackTraceElement[] getRealStackTrack(StackTraceElement[] stackTrace,
String stackTraceOrigin) {
int ignoreDepth = 0;
int allDepth = stackTrace.length;
String className;
for (int i = allDepth - 1; i >= 0; i--) {
className = stac... | [
"private",
"static",
"StackTraceElement",
"[",
"]",
"getRealStackTrack",
"(",
"StackTraceElement",
"[",
"]",
"stackTrace",
",",
"String",
"stackTraceOrigin",
")",
"{",
"int",
"ignoreDepth",
"=",
"0",
";",
"int",
"allDepth",
"=",
"stackTrace",
".",
"length",
";",... | Get the real stack trace, all elements that come from XLog library would be dropped.
@param stackTrace the full stack trace
@return the real stack trace, all elements come from system and library user | [
"Get",
"the",
"real",
"stack",
"trace",
"all",
"elements",
"that",
"come",
"from",
"XLog",
"library",
"would",
"be",
"dropped",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java#L84-L101 |
115,407 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java | StackTraceUtil.cropStackTrace | private static StackTraceElement[] cropStackTrace(StackTraceElement[] callStack,
int maxDepth) {
int realDepth = callStack.length;
if (maxDepth > 0) {
realDepth = Math.min(maxDepth, realDepth);
}
StackTraceElement[] realStack = new StackTraceElem... | java | private static StackTraceElement[] cropStackTrace(StackTraceElement[] callStack,
int maxDepth) {
int realDepth = callStack.length;
if (maxDepth > 0) {
realDepth = Math.min(maxDepth, realDepth);
}
StackTraceElement[] realStack = new StackTraceElem... | [
"private",
"static",
"StackTraceElement",
"[",
"]",
"cropStackTrace",
"(",
"StackTraceElement",
"[",
"]",
"callStack",
",",
"int",
"maxDepth",
")",
"{",
"int",
"realDepth",
"=",
"callStack",
".",
"length",
";",
"if",
"(",
"maxDepth",
">",
"0",
")",
"{",
"r... | Crop the stack trace with a max depth.
@param callStack the original stack trace
@param maxDepth the max depth of real stack trace that will be cropped,
0 means no limitation
@return the cropped stack trace | [
"Crop",
"the",
"stack",
"trace",
"with",
"a",
"max",
"depth",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/internal/util/StackTraceUtil.java#L111-L120 |
115,408 | elvishew/xLog | sample/src/main/java/com/elvishew/xlogsample/MainActivity.java | MainActivity.showPermissionRequestDialog | private void showPermissionRequestDialog(final boolean gotoSettings) {
new AlertDialog.Builder(this)
.setTitle(R.string.permission_request)
.setMessage(R.string.permission_explanation)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(gotoSettings ? R.string.go_to_... | java | private void showPermissionRequestDialog(final boolean gotoSettings) {
new AlertDialog.Builder(this)
.setTitle(R.string.permission_request)
.setMessage(R.string.permission_explanation)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(gotoSettings ? R.string.go_to_... | [
"private",
"void",
"showPermissionRequestDialog",
"(",
"final",
"boolean",
"gotoSettings",
")",
"{",
"new",
"AlertDialog",
".",
"Builder",
"(",
"this",
")",
".",
"setTitle",
"(",
"R",
".",
"string",
".",
"permission_request",
")",
".",
"setMessage",
"(",
"R",
... | Show a dialog for user to explain about the permission. | [
"Show",
"a",
"dialog",
"for",
"user",
"to",
"explain",
"about",
"the",
"permission",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/sample/src/main/java/com/elvishew/xlogsample/MainActivity.java#L195-L212 |
115,409 | elvishew/xLog | sample/src/main/java/com/elvishew/xlogsample/MainActivity.java | MainActivity.showChangeTagDialog | private void showChangeTagDialog() {
View view = getLayoutInflater().inflate(R.layout.dialog_change_tag, null, false);
final EditText tagEditText = (EditText) view.findViewById(R.id.tag);
tagEditText.setText(tagView.getText());
new AlertDialog.Builder(this)
.setTitle(R.string.change_tag)
... | java | private void showChangeTagDialog() {
View view = getLayoutInflater().inflate(R.layout.dialog_change_tag, null, false);
final EditText tagEditText = (EditText) view.findViewById(R.id.tag);
tagEditText.setText(tagView.getText());
new AlertDialog.Builder(this)
.setTitle(R.string.change_tag)
... | [
"private",
"void",
"showChangeTagDialog",
"(",
")",
"{",
"View",
"view",
"=",
"getLayoutInflater",
"(",
")",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"dialog_change_tag",
",",
"null",
",",
"false",
")",
";",
"final",
"EditText",
"tagEditText",
"=",
"(... | Show a dialog for user to change the tag, empty text is not allowed. | [
"Show",
"a",
"dialog",
"for",
"user",
"to",
"change",
"the",
"tag",
"empty",
"text",
"is",
"not",
"allowed",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/sample/src/main/java/com/elvishew/xlogsample/MainActivity.java#L223-L242 |
115,410 | elvishew/xLog | sample/src/main/java/com/elvishew/xlogsample/MainActivity.java | MainActivity.printLog | private void printLog() {
Logger.Builder builder = new Logger.Builder();
String tag = tagView.getText().toString();
if (!TextUtils.isEmpty(tag)) {
builder.tag(tag);
}
if (threadInfo.isChecked()) {
builder.t();
} else {
builder.nt();
}
if (stackTraceInfo.isChecked()) ... | java | private void printLog() {
Logger.Builder builder = new Logger.Builder();
String tag = tagView.getText().toString();
if (!TextUtils.isEmpty(tag)) {
builder.tag(tag);
}
if (threadInfo.isChecked()) {
builder.t();
} else {
builder.nt();
}
if (stackTraceInfo.isChecked()) ... | [
"private",
"void",
"printLog",
"(",
")",
"{",
"Logger",
".",
"Builder",
"builder",
"=",
"new",
"Logger",
".",
"Builder",
"(",
")",
";",
"String",
"tag",
"=",
"tagView",
".",
"getText",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"Text... | Print the configured log. | [
"Print",
"the",
"configured",
"log",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/sample/src/main/java/com/elvishew/xlogsample/MainActivity.java#L261-L320 |
115,411 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java | FilePrinter.doPrintln | private void doPrintln(long timeMillis, int logLevel, String tag, String msg) {
String lastFileName = writer.getLastFileName();
if (lastFileName == null || fileNameGenerator.isFileNameChangeable()) {
String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis());
if (n... | java | private void doPrintln(long timeMillis, int logLevel, String tag, String msg) {
String lastFileName = writer.getLastFileName();
if (lastFileName == null || fileNameGenerator.isFileNameChangeable()) {
String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis());
if (n... | [
"private",
"void",
"doPrintln",
"(",
"long",
"timeMillis",
",",
"int",
"logLevel",
",",
"String",
"tag",
",",
"String",
"msg",
")",
"{",
"String",
"lastFileName",
"=",
"writer",
".",
"getLastFileName",
"(",
")",
";",
"if",
"(",
"lastFileName",
"==",
"null"... | Do the real job of writing log to file. | [
"Do",
"the",
"real",
"job",
"of",
"writing",
"log",
"to",
"file",
"."
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java#L119-L153 |
115,412 | elvishew/xLog | library/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java | FilePrinter.cleanLogFilesIfNecessary | private void cleanLogFilesIfNecessary() {
File logDir = new File(folderPath);
File[] files = logDir.listFiles();
if (files == null) {
return;
}
for (File file : files) {
if (cleanStrategy.shouldClean(file)) {
file.delete();
}
}
} | java | private void cleanLogFilesIfNecessary() {
File logDir = new File(folderPath);
File[] files = logDir.listFiles();
if (files == null) {
return;
}
for (File file : files) {
if (cleanStrategy.shouldClean(file)) {
file.delete();
}
}
} | [
"private",
"void",
"cleanLogFilesIfNecessary",
"(",
")",
"{",
"File",
"logDir",
"=",
"new",
"File",
"(",
"folderPath",
")",
";",
"File",
"[",
"]",
"files",
"=",
"logDir",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"==",
"null",
")",
"{",
"r... | Clean log files if should clean follow strategy | [
"Clean",
"log",
"files",
"if",
"should",
"clean",
"follow",
"strategy"
] | c6fb95555ce619d3e527f5ba6c45d4d247c5a838 | https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java#L158-L169 |
115,413 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java | AttributesBuilder.attributes | public static AttributesBuilder attributes(String[] arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
} | java | public static AttributesBuilder attributes(String[] arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
} | [
"public",
"static",
"AttributesBuilder",
"attributes",
"(",
"String",
"[",
"]",
"arguments",
")",
"{",
"AttributesBuilder",
"attributesBuilder",
"=",
"new",
"AttributesBuilder",
"(",
")",
";",
"attributesBuilder",
".",
"arguments",
"(",
"arguments",
")",
";",
"ret... | Creates attributes builder.
@return atributes builder. | [
"Creates",
"attributes",
"builder",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java#L29-L33 |
115,414 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java | AttributesBuilder.attribute | public AttributesBuilder attribute(String attributeName, Object attributeValue) {
this.attributes.setAttribute(attributeName, attributeValue);
return this;
} | java | public AttributesBuilder attribute(String attributeName, Object attributeValue) {
this.attributes.setAttribute(attributeName, attributeValue);
return this;
} | [
"public",
"AttributesBuilder",
"attribute",
"(",
"String",
"attributeName",
",",
"Object",
"attributeValue",
")",
"{",
"this",
".",
"attributes",
".",
"setAttribute",
"(",
"attributeName",
",",
"attributeValue",
")",
";",
"return",
"this",
";",
"}"
] | Sets custom or unlisted attribute
@param attributeName
@param attributeValue
@return this instance. | [
"Sets",
"custom",
"or",
"unlisted",
"attribute"
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java#L548-L551 |
115,415 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/OptionsBuilder.java | OptionsBuilder.templateDirs | public OptionsBuilder templateDirs(File... templateDirs) {
for (File templateDir : templateDirs) {
this.options.setTemplateDirs(templateDir.getAbsolutePath());
}
return this;
} | java | public OptionsBuilder templateDirs(File... templateDirs) {
for (File templateDir : templateDirs) {
this.options.setTemplateDirs(templateDir.getAbsolutePath());
}
return this;
} | [
"public",
"OptionsBuilder",
"templateDirs",
"(",
"File",
"...",
"templateDirs",
")",
"{",
"for",
"(",
"File",
"templateDir",
":",
"templateDirs",
")",
"{",
"this",
".",
"options",
".",
"setTemplateDirs",
"(",
"templateDir",
".",
"getAbsolutePath",
"(",
")",
")... | Sets template directories.
@param templateDirs
directories where templates are stored.
@return this instance. | [
"Sets",
"template",
"directories",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/OptionsBuilder.java#L91-L96 |
115,416 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/OptionsBuilder.java | OptionsBuilder.option | public OptionsBuilder option(String option, Object value) {
this.options.setOption(option, value);
return this;
} | java | public OptionsBuilder option(String option, Object value) {
this.options.setOption(option, value);
return this;
} | [
"public",
"OptionsBuilder",
"option",
"(",
"String",
"option",
",",
"Object",
"value",
")",
"{",
"this",
".",
"options",
".",
"setOption",
"(",
"option",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets a custom or unlisted option.
@param option
name.
@param value
for given option.
@return this instance. | [
"Sets",
"a",
"custom",
"or",
"unlisted",
"option",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/OptionsBuilder.java#L283-L286 |
115,417 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java | Attributes.setTableOfContents2 | public void setTableOfContents2(Placement placement) {
this.attributes.put(TOC_2, toAsciidoctorFlag(true));
this.attributes.put(TOC_POSITION, placement.getPosition());
} | java | public void setTableOfContents2(Placement placement) {
this.attributes.put(TOC_2, toAsciidoctorFlag(true));
this.attributes.put(TOC_POSITION, placement.getPosition());
} | [
"public",
"void",
"setTableOfContents2",
"(",
"Placement",
"placement",
")",
"{",
"this",
".",
"attributes",
".",
"put",
"(",
"TOC_2",
",",
"toAsciidoctorFlag",
"(",
"true",
")",
")",
";",
"this",
".",
"attributes",
".",
"put",
"(",
"TOC_POSITION",
",",
"p... | Sets table of contents 2 attribute.
@param placement
where toc is rendered. | [
"Sets",
"table",
"of",
"contents",
"2",
"attribute",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java#L313-L316 |
115,418 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java | Attributes.setTableOfContents | public void setTableOfContents(Placement placement) {
this.attributes.put(TOC, toAsciidoctorFlag(true));
this.attributes.put(TOC_POSITION, placement.getPosition());
} | java | public void setTableOfContents(Placement placement) {
this.attributes.put(TOC, toAsciidoctorFlag(true));
this.attributes.put(TOC_POSITION, placement.getPosition());
} | [
"public",
"void",
"setTableOfContents",
"(",
"Placement",
"placement",
")",
"{",
"this",
".",
"attributes",
".",
"put",
"(",
"TOC",
",",
"toAsciidoctorFlag",
"(",
"true",
")",
")",
";",
"this",
".",
"attributes",
".",
"put",
"(",
"TOC_POSITION",
",",
"plac... | Sets if a table of contents should be rendered or not.
@param placement
position of toc. | [
"Sets",
"if",
"a",
"table",
"of",
"contents",
"should",
"be",
"rendered",
"or",
"not",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java#L324-L327 |
115,419 | asciidoctor/asciidoctorj | asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java | Attributes.setShowTitle | public void setShowTitle(boolean showTitle) {
if (showTitle) {
this.attributes.put(SHOW_TITLE, true);
this.attributes.remove(NOTITLE);
} else {
this.attributes.put(NOTITLE, true);
this.attributes.remove(SHOW_TITLE);
}
} | java | public void setShowTitle(boolean showTitle) {
if (showTitle) {
this.attributes.put(SHOW_TITLE, true);
this.attributes.remove(NOTITLE);
} else {
this.attributes.put(NOTITLE, true);
this.attributes.remove(SHOW_TITLE);
}
} | [
"public",
"void",
"setShowTitle",
"(",
"boolean",
"showTitle",
")",
"{",
"if",
"(",
"showTitle",
")",
"{",
"this",
".",
"attributes",
".",
"put",
"(",
"SHOW_TITLE",
",",
"true",
")",
";",
"this",
".",
"attributes",
".",
"remove",
"(",
"NOTITLE",
")",
"... | Sets showtitle value as an alias for notitle!
@param showTitle
value. | [
"Sets",
"showtitle",
"value",
"as",
"an",
"alias",
"for",
"notitle!"
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java#L335-L343 |
115,420 | asciidoctor/asciidoctorj | asciidoctorj-core/src/main/java/org/asciidoctor/jruby/GlobDirectoryWalker.java | GlobDirectoryWalker.findIndexOfUnglobbedPart | private int findIndexOfUnglobbedPart(String globExpression) {
int result = -1;
for (int i = 0; i < globExpression.length(); i++) {
switch (globExpression.charAt(i)) {
case '/':
case '\\':
result = i;
break;
... | java | private int findIndexOfUnglobbedPart(String globExpression) {
int result = -1;
for (int i = 0; i < globExpression.length(); i++) {
switch (globExpression.charAt(i)) {
case '/':
case '\\':
result = i;
break;
... | [
"private",
"int",
"findIndexOfUnglobbedPart",
"(",
"String",
"globExpression",
")",
"{",
"int",
"result",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"globExpression",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"switc... | This method computes the index of the last separator that splits
the given glob expression into a leading part not containing wildcards
and a trailing part containing wildcards.
The last part of the path will never be counted to the leading part.
<p>Example</p>
<code><pre>
src/main/asciidoc/*.adoc
^ 17
/tmp/test.adoc
... | [
"This",
"method",
"computes",
"the",
"index",
"of",
"the",
"last",
"separator",
"that",
"splits",
"the",
"given",
"glob",
"expression",
"into",
"a",
"leading",
"part",
"not",
"containing",
"wildcards",
"and",
"a",
"trailing",
"part",
"containing",
"wildcards",
... | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/GlobDirectoryWalker.java#L63-L79 |
115,421 | asciidoctor/asciidoctorj | asciidoctorj-core/src/main/java/org/asciidoctor/jruby/AbstractDirectoryWalker.java | AbstractDirectoryWalker.scan | @Override
public List<File> scan() {
File baseDirFile = new File(baseDir);
List<File> includedFiles = walkDirectory(baseDirFile);
return includedFiles;
} | java | @Override
public List<File> scan() {
File baseDirFile = new File(baseDir);
List<File> includedFiles = walkDirectory(baseDirFile);
return includedFiles;
} | [
"@",
"Override",
"public",
"List",
"<",
"File",
">",
"scan",
"(",
")",
"{",
"File",
"baseDirFile",
"=",
"new",
"File",
"(",
"baseDir",
")",
";",
"List",
"<",
"File",
">",
"includedFiles",
"=",
"walkDirectory",
"(",
"baseDirFile",
")",
";",
"return",
"i... | Method that finds all files that meets some criteria.
@return List of files which meets the defined criteria. | [
"Method",
"that",
"finds",
"all",
"files",
"that",
"meets",
"some",
"criteria",
"."
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/AbstractDirectoryWalker.java#L27-L34 |
115,422 | asciidoctor/asciidoctorj | asciidoctorj-arquillian-extension/src/main/java/org/asciidoctor/arquillian/SecurityActions.java | SecurityActions.setFieldValue | public static void setFieldValue(final Class<?> source, final Object target, final String fieldName, final Object value) throws NoSuchFieldException
{
try
{
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
{
@Override
public ... | java | public static void setFieldValue(final Class<?> source, final Object target, final String fieldName, final Object value) throws NoSuchFieldException
{
try
{
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
{
@Override
public ... | [
"public",
"static",
"void",
"setFieldValue",
"(",
"final",
"Class",
"<",
"?",
">",
"source",
",",
"final",
"Object",
"target",
",",
"final",
"String",
"fieldName",
",",
"final",
"Object",
"value",
")",
"throws",
"NoSuchFieldException",
"{",
"try",
"{",
"Acce... | Set a single Field value
@param target The object to set it on
@param fieldName The field name
@param value The new value | [
"Set",
"a",
"single",
"Field",
"value"
] | e348c9a12b54c33fea7b05d70224c007e2ee75a9 | https://github.com/asciidoctor/asciidoctorj/blob/e348c9a12b54c33fea7b05d70224c007e2ee75a9/asciidoctorj-arquillian-extension/src/main/java/org/asciidoctor/arquillian/SecurityActions.java#L199-L241 |
115,423 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy._processMetadata | private void _processMetadata(HashMap<String, Object> result) {
// the collections in the result can be either an object[] or a HashSet<object>, depending on the serializer that is used
Object methods = result.get("methods");
Object attrs = result.get("attrs");
Object oneways = result.get("oneways");
if(meth... | java | private void _processMetadata(HashMap<String, Object> result) {
// the collections in the result can be either an object[] or a HashSet<object>, depending on the serializer that is used
Object methods = result.get("methods");
Object attrs = result.get("attrs");
Object oneways = result.get("oneways");
if(meth... | [
"private",
"void",
"_processMetadata",
"(",
"HashMap",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"// the collections in the result can be either an object[] or a HashSet<object>, depending on the serializer that is used",
"Object",
"methods",
"=",
"result",
".",
"g... | Extract meta data and store it in the relevant properties on the proxy.
If no attribute or method is exposed at all, throw an exception. | [
"Extract",
"meta",
"data",
"and",
"store",
"it",
"in",
"the",
"relevant",
"properties",
"on",
"the",
"proxy",
".",
"If",
"no",
"attribute",
"or",
"method",
"is",
"exposed",
"at",
"all",
"throw",
"an",
"exception",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L117-L154 |
115,424 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy.getSetOfStrings | @SuppressWarnings("unchecked")
protected HashSet<String> getSetOfStrings(Object strings)
{
try {
return (HashSet<String>) strings;
} catch (ClassCastException ex) {
Collection<String> list = (Collection<String>) strings;
return new HashSet<String>(list);
}
} | java | @SuppressWarnings("unchecked")
protected HashSet<String> getSetOfStrings(Object strings)
{
try {
return (HashSet<String>) strings;
} catch (ClassCastException ex) {
Collection<String> list = (Collection<String>) strings;
return new HashSet<String>(list);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"HashSet",
"<",
"String",
">",
"getSetOfStrings",
"(",
"Object",
"strings",
")",
"{",
"try",
"{",
"return",
"(",
"HashSet",
"<",
"String",
">",
")",
"strings",
";",
"}",
"catch",
"(",
"ClassC... | Converts the given object into a set of strings.
The object must either be a HashSet already, or a different collection type. | [
"Converts",
"the",
"given",
"object",
"into",
"a",
"set",
"of",
"strings",
".",
"The",
"object",
"must",
"either",
"be",
"a",
"HashSet",
"already",
"or",
"a",
"different",
"collection",
"type",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L160-L169 |
115,425 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy.call | public Object call(String method, Object... arguments) throws PickleException, PyroException, IOException {
return internal_call(method, null, 0, true, arguments);
} | java | public Object call(String method, Object... arguments) throws PickleException, PyroException, IOException {
return internal_call(method, null, 0, true, arguments);
} | [
"public",
"Object",
"call",
"(",
"String",
"method",
",",
"Object",
"...",
"arguments",
")",
"throws",
"PickleException",
",",
"PyroException",
",",
"IOException",
"{",
"return",
"internal_call",
"(",
"method",
",",
"null",
",",
"0",
",",
"true",
",",
"argum... | Call a method on the remote Pyro object this proxy is for.
@param method the name of the method you want to call
@param arguments zero or more arguments for the remote method
@return the result Object from the remote method call (can be anything, you need to typecast/introspect yourself). | [
"Call",
"a",
"method",
"on",
"the",
"remote",
"Pyro",
"object",
"this",
"proxy",
"is",
"for",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L177-L179 |
115,426 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy.getattr | public Object getattr(String attr) throws PickleException, PyroException, IOException {
return this.internal_call("__getattr__", null, 0, false, attr);
} | java | public Object getattr(String attr) throws PickleException, PyroException, IOException {
return this.internal_call("__getattr__", null, 0, false, attr);
} | [
"public",
"Object",
"getattr",
"(",
"String",
"attr",
")",
"throws",
"PickleException",
",",
"PyroException",
",",
"IOException",
"{",
"return",
"this",
".",
"internal_call",
"(",
"\"__getattr__\"",
",",
"null",
",",
"0",
",",
"false",
",",
"attr",
")",
";",... | Get the value of a remote attribute.
@param attr the attribute name | [
"Get",
"the",
"value",
"of",
"a",
"remote",
"attribute",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L194-L196 |
115,427 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy.setattr | public void setattr(String attr, Object value) throws PickleException, PyroException, IOException {
this.internal_call("__setattr__", null, 0, false, attr, value);
} | java | public void setattr(String attr, Object value) throws PickleException, PyroException, IOException {
this.internal_call("__setattr__", null, 0, false, attr, value);
} | [
"public",
"void",
"setattr",
"(",
"String",
"attr",
",",
"Object",
"value",
")",
"throws",
"PickleException",
",",
"PyroException",
",",
"IOException",
"{",
"this",
".",
"internal_call",
"(",
"\"__setattr__\"",
",",
"null",
",",
"0",
",",
"false",
",",
"attr... | Set a new value on a remote attribute.
@param attr the attribute name
@param value the new value for the attribute | [
"Set",
"a",
"new",
"value",
"on",
"a",
"remote",
"attribute",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L203-L205 |
115,428 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy.close | public void close() {
if (this.sock != null)
try {
this.sock_in.close();
this.sock_out.close();
this.sock.close();
this.sock=null;
this.sock_in=null;
this.sock_out=null;
} catch (IOException e) {
}
} | java | public void close() {
if (this.sock != null)
try {
this.sock_in.close();
this.sock_out.close();
this.sock.close();
this.sock=null;
this.sock_in=null;
this.sock_out=null;
} catch (IOException e) {
}
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"this",
".",
"sock",
"!=",
"null",
")",
"try",
"{",
"this",
".",
"sock_in",
".",
"close",
"(",
")",
";",
"this",
".",
"sock_out",
".",
"close",
"(",
")",
";",
"this",
".",
"sock",
".",
"close... | Close the network connection of this Proxy.
If you re-use the proxy, it will automatically reconnect. | [
"Close",
"the",
"network",
"connection",
"of",
"this",
"Proxy",
".",
"If",
"you",
"re",
"-",
"use",
"the",
"proxy",
"it",
"will",
"automatically",
"reconnect",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L328-L339 |
115,429 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/PyroProxy.java | PyroProxy._handshake | @SuppressWarnings("unchecked")
protected void _handshake() throws IOException {
// do connection handshake
PyroSerializer ser = PyroSerializer.getFor(Config.SERIALIZER);
Map<String, Object> handshakedata = new HashMap<String, Object>();
handshakedata.put("handshake", pyroHandshake);
if(Config.METADATA)
h... | java | @SuppressWarnings("unchecked")
protected void _handshake() throws IOException {
// do connection handshake
PyroSerializer ser = PyroSerializer.getFor(Config.SERIALIZER);
Map<String, Object> handshakedata = new HashMap<String, Object>();
handshakedata.put("handshake", pyroHandshake);
if(Config.METADATA)
h... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"_handshake",
"(",
")",
"throws",
"IOException",
"{",
"// do connection handshake",
"PyroSerializer",
"ser",
"=",
"PyroSerializer",
".",
"getFor",
"(",
"Config",
".",
"SERIALIZER",
")",
";",
... | Perform the Pyro protocol connection handshake with the Pyro daemon. | [
"Perform",
"the",
"Pyro",
"protocol",
"connection",
"handshake",
"with",
"the",
"Pyro",
"daemon",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/PyroProxy.java#L344-L397 |
115,430 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/Message.java | Message.from_header | public static Message from_header(byte[] header)
{
if(header==null || header.length!=HEADER_SIZE)
throw new PyroException("header data size mismatch");
if(header[0]!='P'||header[1]!='Y'||header[2]!='R'||header[3]!='O')
throw new PyroException("invalid message");
int version = ((header[4]&0xff) <... | java | public static Message from_header(byte[] header)
{
if(header==null || header.length!=HEADER_SIZE)
throw new PyroException("header data size mismatch");
if(header[0]!='P'||header[1]!='Y'||header[2]!='R'||header[3]!='O')
throw new PyroException("invalid message");
int version = ((header[4]&0xff) <... | [
"public",
"static",
"Message",
"from_header",
"(",
"byte",
"[",
"]",
"header",
")",
"{",
"if",
"(",
"header",
"==",
"null",
"||",
"header",
".",
"length",
"!=",
"HEADER_SIZE",
")",
"throw",
"new",
"PyroException",
"(",
"\"header data size mismatch\"",
")",
"... | Parses a message header. Does not yet process the annotations chunks and message data. | [
"Parses",
"a",
"message",
"header",
".",
"Does",
"not",
"yet",
"process",
"the",
"annotations",
"chunks",
"and",
"message",
"data",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/Message.java#L209-L243 |
115,431 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/serializer/PyroSerializer.java | PyroSerializer.getFor | public static PyroSerializer getFor(Config.SerializerType type)
{
switch(type)
{
case pickle:
return pickleSerializer;
case serpent:
{
synchronized(PyroSerializer.class)
{
if(serpentSerializer==null)
{
// try loading it
try {
serpentSerializer = new S... | java | public static PyroSerializer getFor(Config.SerializerType type)
{
switch(type)
{
case pickle:
return pickleSerializer;
case serpent:
{
synchronized(PyroSerializer.class)
{
if(serpentSerializer==null)
{
// try loading it
try {
serpentSerializer = new S... | [
"public",
"static",
"PyroSerializer",
"getFor",
"(",
"Config",
".",
"SerializerType",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"pickle",
":",
"return",
"pickleSerializer",
";",
"case",
"serpent",
":",
"{",
"synchronized",
"(",
"PyroSerializer... | loaded if serpent.jar is available | [
"loaded",
"if",
"serpent",
".",
"jar",
"is",
"available"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/serializer/PyroSerializer.java#L27-L58 |
115,432 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.dumps | public byte[] dumps(Object o) throws PickleException, IOException {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
dump(o, bo);
bo.flush();
return bo.toByteArray();
} | java | public byte[] dumps(Object o) throws PickleException, IOException {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
dump(o, bo);
bo.flush();
return bo.toByteArray();
} | [
"public",
"byte",
"[",
"]",
"dumps",
"(",
"Object",
"o",
")",
"throws",
"PickleException",
",",
"IOException",
"{",
"ByteArrayOutputStream",
"bo",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"dump",
"(",
"o",
",",
"bo",
")",
";",
"bo",
".",
"flus... | Pickle a given object graph, returning the result as a byte array. | [
"Pickle",
"a",
"given",
"object",
"graph",
"returning",
"the",
"result",
"as",
"a",
"byte",
"array",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L146-L151 |
115,433 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.dump | public void dump(Object o, OutputStream stream) throws IOException, PickleException {
out = stream;
recurse = 0;
if(useMemo)
memo = new HashMap<Integer, Memo>();
out.write(Opcodes.PROTO);
out.write(PROTOCOL);
save(o);
memo = null; // get rid of the memo table
out.write(Opcodes.STOP);
out.flush();
... | java | public void dump(Object o, OutputStream stream) throws IOException, PickleException {
out = stream;
recurse = 0;
if(useMemo)
memo = new HashMap<Integer, Memo>();
out.write(Opcodes.PROTO);
out.write(PROTOCOL);
save(o);
memo = null; // get rid of the memo table
out.write(Opcodes.STOP);
out.flush();
... | [
"public",
"void",
"dump",
"(",
"Object",
"o",
",",
"OutputStream",
"stream",
")",
"throws",
"IOException",
",",
"PickleException",
"{",
"out",
"=",
"stream",
";",
"recurse",
"=",
"0",
";",
"if",
"(",
"useMemo",
")",
"memo",
"=",
"new",
"HashMap",
"<",
... | Pickle a given object graph, writing the result to the output stream. | [
"Pickle",
"a",
"given",
"object",
"graph",
"writing",
"the",
"result",
"to",
"the",
"output",
"stream",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L156-L169 |
115,434 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.save | public void save(Object o) throws PickleException, IOException {
recurse++;
if(recurse>MAX_RECURSE_DEPTH)
throw new java.lang.StackOverflowError("recursion too deep in Pickler.save (>"+MAX_RECURSE_DEPTH+")");
// null type?
if(o==null) {
out.write(Opcodes.NONE);
recurse--;
return;
}
// check th... | java | public void save(Object o) throws PickleException, IOException {
recurse++;
if(recurse>MAX_RECURSE_DEPTH)
throw new java.lang.StackOverflowError("recursion too deep in Pickler.save (>"+MAX_RECURSE_DEPTH+")");
// null type?
if(o==null) {
out.write(Opcodes.NONE);
recurse--;
return;
}
// check th... | [
"public",
"void",
"save",
"(",
"Object",
"o",
")",
"throws",
"PickleException",
",",
"IOException",
"{",
"recurse",
"++",
";",
"if",
"(",
"recurse",
">",
"MAX_RECURSE_DEPTH",
")",
"throw",
"new",
"java",
".",
"lang",
".",
"StackOverflowError",
"(",
"\"recurs... | Pickle a single object and write its pickle representation to the output stream.
Normally this is used internally by the pickler, but you can also utilize it from
within custom picklers. This is handy if as part of the custom pickler, you need
to write a couple of normal objects such as strings or ints, that are alread... | [
"Pickle",
"a",
"single",
"object",
"and",
"write",
"its",
"pickle",
"representation",
"to",
"the",
"output",
"stream",
".",
"Normally",
"this",
"is",
"used",
"internally",
"by",
"the",
"pickler",
"but",
"you",
"can",
"also",
"utilize",
"it",
"from",
"within"... | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L179-L199 |
115,435 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.writeMemo | protected void writeMemo( Object obj ) throws IOException
{
if(!this.useMemo)
return;
int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj);
if(!memo.containsKey(hash))
{
int memo_index = memo.size();
memo.put(hash, new Memo(obj, memo_index));
if(memo_index<=0xFF)
{
out.wri... | java | protected void writeMemo( Object obj ) throws IOException
{
if(!this.useMemo)
return;
int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj);
if(!memo.containsKey(hash))
{
int memo_index = memo.size();
memo.put(hash, new Memo(obj, memo_index));
if(memo_index<=0xFF)
{
out.wri... | [
"protected",
"void",
"writeMemo",
"(",
"Object",
"obj",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"this",
".",
"useMemo",
")",
"return",
";",
"int",
"hash",
"=",
"valueCompare",
"?",
"obj",
".",
"hashCode",
"(",
")",
":",
"System",
".",
"ident... | Write the object to the memo table and output a memo write opcode
Only works for hashable objects | [
"Write",
"the",
"object",
"to",
"the",
"memo",
"table",
"and",
"output",
"a",
"memo",
"write",
"opcode",
"Only",
"works",
"for",
"hashable",
"objects"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L205-L226 |
115,436 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.lookupMemo | private boolean lookupMemo(Class<?> objectType, Object obj) throws IOException {
if(!this.useMemo)
return false;
if(!objectType.isPrimitive()) {
int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj);
if(memo.containsKey(hash) && (valueCompare ? memo.get(hash).obj.equals(obj) : memo.get(ha... | java | private boolean lookupMemo(Class<?> objectType, Object obj) throws IOException {
if(!this.useMemo)
return false;
if(!objectType.isPrimitive()) {
int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj);
if(memo.containsKey(hash) && (valueCompare ? memo.get(hash).obj.equals(obj) : memo.get(ha... | [
"private",
"boolean",
"lookupMemo",
"(",
"Class",
"<",
"?",
">",
"objectType",
",",
"Object",
"obj",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"this",
".",
"useMemo",
")",
"return",
"false",
";",
"if",
"(",
"!",
"objectType",
".",
"isPrimitive",... | Check the memo table and output a memo lookup if the object is found | [
"Check",
"the",
"memo",
"table",
"and",
"output",
"a",
"memo",
"lookup",
"if",
"the",
"object",
"is",
"found"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L231-L250 |
115,437 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Pickler.java | Pickler.getCustomPickler | protected IObjectPickler getCustomPickler(Class<?> t) {
IObjectPickler pickler = customPicklers.get(t);
if(pickler!=null) {
return pickler; // exact match
}
// check if there's a custom pickler registered for an interface or abstract base class
// that this object implements or inherits from.
for(Entry... | java | protected IObjectPickler getCustomPickler(Class<?> t) {
IObjectPickler pickler = customPicklers.get(t);
if(pickler!=null) {
return pickler; // exact match
}
// check if there's a custom pickler registered for an interface or abstract base class
// that this object implements or inherits from.
for(Entry... | [
"protected",
"IObjectPickler",
"getCustomPickler",
"(",
"Class",
"<",
"?",
">",
"t",
")",
"{",
"IObjectPickler",
"pickler",
"=",
"customPicklers",
".",
"get",
"(",
"t",
")",
";",
"if",
"(",
"pickler",
"!=",
"null",
")",
"{",
"return",
"pickler",
";",
"//... | Get the custom pickler fot the given class, to be able to pickle not just built in collection types.
A custom pickler is matched on the interface or abstract base class that the object implements or inherits from.
@param t the class of the object to be pickled
@return null (if no custom pickler found) or a pickler regi... | [
"Get",
"the",
"custom",
"pickler",
"fot",
"the",
"given",
"class",
"to",
"be",
"able",
"to",
"pickle",
"not",
"just",
"built",
"in",
"collection",
"types",
".",
"A",
"custom",
"pickler",
"is",
"matched",
"on",
"the",
"interface",
"or",
"abstract",
"base",
... | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Pickler.java#L393-L408 |
115,438 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PrettyPrint.java | PrettyPrint.print | public static void print(Object o) throws IOException {
OutputStreamWriter w=new OutputStreamWriter(System.out,"UTF-8");
print(o, w, true);
w.flush();
} | java | public static void print(Object o) throws IOException {
OutputStreamWriter w=new OutputStreamWriter(System.out,"UTF-8");
print(o, w, true);
w.flush();
} | [
"public",
"static",
"void",
"print",
"(",
"Object",
"o",
")",
"throws",
"IOException",
"{",
"OutputStreamWriter",
"w",
"=",
"new",
"OutputStreamWriter",
"(",
"System",
".",
"out",
",",
"\"UTF-8\"",
")",
";",
"print",
"(",
"o",
",",
"w",
",",
"true",
")",... | Prettyprint directly to the standard output. | [
"Prettyprint",
"directly",
"to",
"the",
"standard",
"output",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PrettyPrint.java#L41-L45 |
115,439 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Unpickler.java | Unpickler.registerConstructor | public static void registerConstructor(String module, String classname, IObjectConstructor constructor) {
objectConstructors.put(module + "." + classname, constructor);
} | java | public static void registerConstructor(String module, String classname, IObjectConstructor constructor) {
objectConstructors.put(module + "." + classname, constructor);
} | [
"public",
"static",
"void",
"registerConstructor",
"(",
"String",
"module",
",",
"String",
"classname",
",",
"IObjectConstructor",
"constructor",
")",
"{",
"objectConstructors",
".",
"put",
"(",
"module",
"+",
"\".\"",
"+",
"classname",
",",
"constructor",
")",
... | Register additional object constructors for custom classes. | [
"Register",
"additional",
"object",
"constructors",
"for",
"custom",
"classes",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Unpickler.java#L106-L108 |
115,440 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Unpickler.java | Unpickler.load | public Object load(InputStream stream) throws PickleException, IOException {
stack = new UnpickleStack();
input = stream;
while (true) {
short key = PickleUtils.readbyte(input);
if (key == -1)
throw new IOException("premature end of file");
Object value = dispatch(key);
if (value != NO_RETURN_VALU... | java | public Object load(InputStream stream) throws PickleException, IOException {
stack = new UnpickleStack();
input = stream;
while (true) {
short key = PickleUtils.readbyte(input);
if (key == -1)
throw new IOException("premature end of file");
Object value = dispatch(key);
if (value != NO_RETURN_VALU... | [
"public",
"Object",
"load",
"(",
"InputStream",
"stream",
")",
"throws",
"PickleException",
",",
"IOException",
"{",
"stack",
"=",
"new",
"UnpickleStack",
"(",
")",
";",
"input",
"=",
"stream",
";",
"while",
"(",
"true",
")",
"{",
"short",
"key",
"=",
"P... | Read a pickled object representation from the given input stream.
@return the reconstituted object hierarchy specified in the file. | [
"Read",
"a",
"pickled",
"object",
"representation",
"from",
"the",
"given",
"input",
"stream",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Unpickler.java#L115-L127 |
115,441 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/Unpickler.java | Unpickler.close | public void close() {
if(stack!=null) stack.clear();
if(memo!=null) memo.clear();
if(input!=null)
try {
input.close();
} catch (IOException e) {
}
} | java | public void close() {
if(stack!=null) stack.clear();
if(memo!=null) memo.clear();
if(input!=null)
try {
input.close();
} catch (IOException e) {
}
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"stack",
"!=",
"null",
")",
"stack",
".",
"clear",
"(",
")",
";",
"if",
"(",
"memo",
"!=",
"null",
")",
"memo",
".",
"clear",
"(",
")",
";",
"if",
"(",
"input",
"!=",
"null",
")",
"try",
"{... | Close the unpickler and frees the resources such as the unpickle stack and memo table. | [
"Close",
"the",
"unpickler",
"and",
"frees",
"the",
"resources",
"such",
"as",
"the",
"unpickle",
"stack",
"and",
"memo",
"table",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/Unpickler.java#L141-L149 |
115,442 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.readline | public static String readline(InputStream input, boolean includeLF) throws IOException {
StringBuilder sb = new StringBuilder();
while (true) {
int c = input.read();
if (c == -1) {
if (sb.length() == 0)
throw new IOException("premature end of file");
break;
}
if (c != '\n' || inclu... | java | public static String readline(InputStream input, boolean includeLF) throws IOException {
StringBuilder sb = new StringBuilder();
while (true) {
int c = input.read();
if (c == -1) {
if (sb.length() == 0)
throw new IOException("premature end of file");
break;
}
if (c != '\n' || inclu... | [
"public",
"static",
"String",
"readline",
"(",
"InputStream",
"input",
",",
"boolean",
"includeLF",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"c",
"=",
"inpu... | read a line of text, possibly including the terminating LF char | [
"read",
"a",
"line",
"of",
"text",
"possibly",
"including",
"the",
"terminating",
"LF",
"char"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L25-L40 |
115,443 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.readbytes_into | public static void readbytes_into(InputStream input, byte[] buffer, int offset, int length) throws IOException {
while (length > 0) {
int read = input.read(buffer, offset, length);
if (read == -1)
throw new IOException("expected more bytes in input stream");
offset += read;
length -= read;
}
... | java | public static void readbytes_into(InputStream input, byte[] buffer, int offset, int length) throws IOException {
while (length > 0) {
int read = input.read(buffer, offset, length);
if (read == -1)
throw new IOException("expected more bytes in input stream");
offset += read;
length -= read;
}
... | [
"public",
"static",
"void",
"readbytes_into",
"(",
"InputStream",
"input",
",",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"while",
"(",
"length",
">",
"0",
")",
"{",
"int",
"read",
"=",
"... | read a number of signed bytes into the specified location in an existing byte array | [
"read",
"a",
"number",
"of",
"signed",
"bytes",
"into",
"the",
"specified",
"location",
"in",
"an",
"existing",
"byte",
"array"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L71-L79 |
115,444 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.bytes_to_long | public static long bytes_to_long(byte[] bytes, int offset) {
if(bytes.length-offset<8)
throw new PickleException("too few bytes to convert to long");
long i = bytes[7+offset] & 0xff;
i <<= 8;
i |= bytes[6+offset] & 0xff;
i <<= 8;
i |= bytes[5+offset] & 0xff;
i <<= 8;
i |= bytes[4+offset] & 0... | java | public static long bytes_to_long(byte[] bytes, int offset) {
if(bytes.length-offset<8)
throw new PickleException("too few bytes to convert to long");
long i = bytes[7+offset] & 0xff;
i <<= 8;
i |= bytes[6+offset] & 0xff;
i <<= 8;
i |= bytes[5+offset] & 0xff;
i <<= 8;
i |= bytes[4+offset] & 0... | [
"public",
"static",
"long",
"bytes_to_long",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"bytes",
".",
"length",
"-",
"offset",
"<",
"8",
")",
"throw",
"new",
"PickleException",
"(",
"\"too few bytes to convert to long\"",
")",... | Convert 8 little endian bytes into a long | [
"Convert",
"8",
"little",
"endian",
"bytes",
"into",
"a",
"long"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L113-L132 |
115,445 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.bytes_to_double | public static double bytes_to_double(byte[] bytes, int offset) {
try {
long result = bytes[0+offset] & 0xff;
result <<= 8;
result |= bytes[1+offset] & 0xff;
result <<= 8;
result |= bytes[2+offset] & 0xff;
result <<= 8;
result |= bytes[3+offset] & 0xff;
result <<= 8;
result |= byte... | java | public static double bytes_to_double(byte[] bytes, int offset) {
try {
long result = bytes[0+offset] & 0xff;
result <<= 8;
result |= bytes[1+offset] & 0xff;
result <<= 8;
result |= bytes[2+offset] & 0xff;
result <<= 8;
result |= bytes[3+offset] & 0xff;
result <<= 8;
result |= byte... | [
"public",
"static",
"double",
"bytes_to_double",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"try",
"{",
"long",
"result",
"=",
"bytes",
"[",
"0",
"+",
"offset",
"]",
"&",
"0xff",
";",
"result",
"<<=",
"8",
";",
"result",
"|=",
... | Convert a big endian 8-byte to a double. | [
"Convert",
"a",
"big",
"endian",
"8",
"-",
"byte",
"to",
"a",
"double",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L192-L213 |
115,446 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.bytes_to_float | public static float bytes_to_float(byte[] bytes, int offset) {
try {
int result = bytes[0+offset] & 0xff;
result <<= 8;
result |= bytes[1+offset] & 0xff;
result <<= 8;
result |= bytes[2+offset] & 0xff;
result <<= 8;
result |= bytes[3+offset] & 0xff;
return Float.intBitsToFloat(result)... | java | public static float bytes_to_float(byte[] bytes, int offset) {
try {
int result = bytes[0+offset] & 0xff;
result <<= 8;
result |= bytes[1+offset] & 0xff;
result <<= 8;
result |= bytes[2+offset] & 0xff;
result <<= 8;
result |= bytes[3+offset] & 0xff;
return Float.intBitsToFloat(result)... | [
"public",
"static",
"float",
"bytes_to_float",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"try",
"{",
"int",
"result",
"=",
"bytes",
"[",
"0",
"+",
"offset",
"]",
"&",
"0xff",
";",
"result",
"<<=",
"8",
";",
"result",
"|=",
"by... | Convert a big endian 4-byte to a float. | [
"Convert",
"a",
"big",
"endian",
"4",
"-",
"byte",
"to",
"a",
"float",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L218-L231 |
115,447 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.optimizeBigint | public static Number optimizeBigint(BigInteger bigint) {
// final BigInteger MAXINT=BigInteger.valueOf(Integer.MAX_VALUE);
// final BigInteger MININT=BigInteger.valueOf(Integer.MIN_VALUE);
final BigInteger MAXLONG = BigInteger.valueOf(Long.MAX_VALUE);
final BigInteger MINLONG = BigInteger.valueOf(Long.MIN_V... | java | public static Number optimizeBigint(BigInteger bigint) {
// final BigInteger MAXINT=BigInteger.valueOf(Integer.MAX_VALUE);
// final BigInteger MININT=BigInteger.valueOf(Integer.MIN_VALUE);
final BigInteger MAXLONG = BigInteger.valueOf(Long.MAX_VALUE);
final BigInteger MINLONG = BigInteger.valueOf(Long.MIN_V... | [
"public",
"static",
"Number",
"optimizeBigint",
"(",
"BigInteger",
"bigint",
")",
"{",
"// final BigInteger MAXINT=BigInteger.valueOf(Integer.MAX_VALUE);\r",
"// final BigInteger MININT=BigInteger.valueOf(Integer.MIN_VALUE);\r",
"final",
"BigInteger",
"MAXLONG",
"=",
"BigInteger",
".... | Optimize a biginteger, if possible return a long primitive datatype. | [
"Optimize",
"a",
"biginteger",
"if",
"possible",
"return",
"a",
"long",
"primitive",
"datatype",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L262-L282 |
115,448 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.rawStringFromBytes | public static String rawStringFromBytes(byte[] data) {
StringBuilder str = new StringBuilder(data.length);
for (byte b : data) {
str.append((char) (b & 0xff));
}
return str.toString();
} | java | public static String rawStringFromBytes(byte[] data) {
StringBuilder str = new StringBuilder(data.length);
for (byte b : data) {
str.append((char) (b & 0xff));
}
return str.toString();
} | [
"public",
"static",
"String",
"rawStringFromBytes",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"StringBuilder",
"str",
"=",
"new",
"StringBuilder",
"(",
"data",
".",
"length",
")",
";",
"for",
"(",
"byte",
"b",
":",
"data",
")",
"{",
"str",
".",
"append"... | Construct a String from the given bytes where these are directly
converted to the corresponding chars, without using a given character
encoding | [
"Construct",
"a",
"String",
"from",
"the",
"given",
"bytes",
"where",
"these",
"are",
"directly",
"converted",
"to",
"the",
"corresponding",
"chars",
"without",
"using",
"a",
"given",
"character",
"encoding"
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L289-L295 |
115,449 | irmen/Pyrolite | java/src/main/java/net/razorvine/pickle/PickleUtils.java | PickleUtils.str2bytes | public static byte[] str2bytes(String str) throws IOException {
byte[] b=new byte[str.length()];
for(int i=0; i<str.length(); ++i) {
char c=str.charAt(i);
if(c>255) throw new UnsupportedEncodingException("string contained a char > 255, cannot convert to bytes");
b[i]=(byte)c;
}
return b;
} | java | public static byte[] str2bytes(String str) throws IOException {
byte[] b=new byte[str.length()];
for(int i=0; i<str.length(); ++i) {
char c=str.charAt(i);
if(c>255) throw new UnsupportedEncodingException("string contained a char > 255, cannot convert to bytes");
b[i]=(byte)c;
}
return b;
} | [
"public",
"static",
"byte",
"[",
"]",
"str2bytes",
"(",
"String",
"str",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"b",
"=",
"new",
"byte",
"[",
"str",
".",
"length",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<... | Convert a string to a byte array, no encoding is used. String must only contain characters <256. | [
"Convert",
"a",
"string",
"to",
"a",
"byte",
"array",
"no",
"encoding",
"is",
"used",
".",
"String",
"must",
"only",
"contain",
"characters",
"<256",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pickle/PickleUtils.java#L300-L308 |
115,450 | irmen/Pyrolite | java/src/main/java/net/razorvine/pyro/IOUtil.java | IOUtil.recv | public static byte[] recv(InputStream in, int size) throws IOException {
byte [] bytes = new byte [size];
int numRead = in.read(bytes);
if(numRead==-1) {
throw new IOException("premature end of data");
}
while (numRead < size) {
int len = in.read(bytes, numRead, size - numRead);
if(len==-1)... | java | public static byte[] recv(InputStream in, int size) throws IOException {
byte [] bytes = new byte [size];
int numRead = in.read(bytes);
if(numRead==-1) {
throw new IOException("premature end of data");
}
while (numRead < size) {
int len = in.read(bytes, numRead, size - numRead);
if(len==-1)... | [
"public",
"static",
"byte",
"[",
"]",
"recv",
"(",
"InputStream",
"in",
",",
"int",
"size",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"int",
"numRead",
"=",
"in",
".",
"read",
"(",
"byt... | Receive a message of the given size from the inputstream.
Makes sure the complete message is received, raises IOException otherwise. | [
"Receive",
"a",
"message",
"of",
"the",
"given",
"size",
"from",
"the",
"inputstream",
".",
"Makes",
"sure",
"the",
"complete",
"message",
"is",
"received",
"raises",
"IOException",
"otherwise",
"."
] | 060bc3c9069cd31560b6da4f67280736fb2cdf63 | https://github.com/irmen/Pyrolite/blob/060bc3c9069cd31560b6da4f67280736fb2cdf63/java/src/main/java/net/razorvine/pyro/IOUtil.java#L24-L38 |
115,451 | Netflix/suro | suro-server/src/main/java/com/netflix/suro/SuroControl.java | SuroControl.closeAndIgnoreError | private static void closeAndIgnoreError(Socket socket) {
if(socket == null) return;
try{
socket.close();
}catch(IOException e) {
log.warn(String.format("Failed to close the client socket on port %d: %s. Exception ignored.", socket.getPort(), e.getMessage()), e);
... | java | private static void closeAndIgnoreError(Socket socket) {
if(socket == null) return;
try{
socket.close();
}catch(IOException e) {
log.warn(String.format("Failed to close the client socket on port %d: %s. Exception ignored.", socket.getPort(), e.getMessage()), e);
... | [
"private",
"static",
"void",
"closeAndIgnoreError",
"(",
"Socket",
"socket",
")",
"{",
"if",
"(",
"socket",
"==",
"null",
")",
"return",
";",
"try",
"{",
"socket",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
"... | make Suro compilable and runnable under Java 6. | [
"make",
"Suro",
"compilable",
"and",
"runnable",
"under",
"Java",
"6",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-server/src/main/java/com/netflix/suro/SuroControl.java#L107-L115 |
115,452 | Netflix/suro | suro-server/src/main/java/com/netflix/suro/SuroControl.java | SuroControl.respond | private void respond(BufferedWriter out, String response) throws IOException {
out.append(response);
out.append("\n");
out.flush();
} | java | private void respond(BufferedWriter out, String response) throws IOException {
out.append(response);
out.append("\n");
out.flush();
} | [
"private",
"void",
"respond",
"(",
"BufferedWriter",
"out",
",",
"String",
"response",
")",
"throws",
"IOException",
"{",
"out",
".",
"append",
"(",
"response",
")",
";",
"out",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"out",
".",
"flush",
"(",
")",
";... | Writes line-based response.
@param out the channel used to write back response
@param response A string that ends with a new line
@throws IOException | [
"Writes",
"line",
"-",
"based",
"response",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-server/src/main/java/com/netflix/suro/SuroControl.java#L133-L137 |
115,453 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java | FileWriterBase.createSequenceFile | public SequenceFile.Writer createSequenceFile(String newPath) throws IOException {
if (codec != null) {
return SequenceFile.createWriter(
fs, conf, new Path(newPath),
Text.class, MessageWritable.class,
SequenceFile.CompressionType.BLOCK, co... | java | public SequenceFile.Writer createSequenceFile(String newPath) throws IOException {
if (codec != null) {
return SequenceFile.createWriter(
fs, conf, new Path(newPath),
Text.class, MessageWritable.class,
SequenceFile.CompressionType.BLOCK, co... | [
"public",
"SequenceFile",
".",
"Writer",
"createSequenceFile",
"(",
"String",
"newPath",
")",
"throws",
"IOException",
"{",
"if",
"(",
"codec",
"!=",
"null",
")",
"{",
"return",
"SequenceFile",
".",
"createWriter",
"(",
"fs",
",",
"conf",
",",
"new",
"Path",... | Create a new sequence file
@param newPath
@return
@throws java.io.IOException | [
"Create",
"a",
"new",
"sequence",
"file"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java#L109-L121 |
115,454 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java | FileWriterBase.createFSDataOutputStream | public FSDataOutputStream createFSDataOutputStream(String path) throws IOException {
return fs.create(new Path(path), false);
} | java | public FSDataOutputStream createFSDataOutputStream(String path) throws IOException {
return fs.create(new Path(path), false);
} | [
"public",
"FSDataOutputStream",
"createFSDataOutputStream",
"(",
"String",
"path",
")",
"throws",
"IOException",
"{",
"return",
"fs",
".",
"create",
"(",
"new",
"Path",
"(",
"path",
")",
",",
"false",
")",
";",
"}"
] | Create a new FSDataOutputStream from path
@param path
@return
@throws java.io.IOException | [
"Create",
"a",
"new",
"FSDataOutputStream",
"from",
"path"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java#L130-L132 |
115,455 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java | FileWriterBase.createDataOutputStream | public DataOutputStream createDataOutputStream(FSDataOutputStream outputStream) throws IOException {
if (codec != null) {
return new FSDataOutputStream(codec.createOutputStream(outputStream), null);
} else {
return outputStream;
}
} | java | public DataOutputStream createDataOutputStream(FSDataOutputStream outputStream) throws IOException {
if (codec != null) {
return new FSDataOutputStream(codec.createOutputStream(outputStream), null);
} else {
return outputStream;
}
} | [
"public",
"DataOutputStream",
"createDataOutputStream",
"(",
"FSDataOutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"if",
"(",
"codec",
"!=",
"null",
")",
"{",
"return",
"new",
"FSDataOutputStream",
"(",
"codec",
".",
"createOutputStream",
"(",
"ou... | Create a DataOutputStream from FSDataOutputStream. If the codec is available,
it will create compressed DataOutputStream, otherwise, it will return itself.
@param outputStream
@return
@throws java.io.IOException | [
"Create",
"a",
"DataOutputStream",
"from",
"FSDataOutputStream",
".",
"If",
"the",
"codec",
"is",
"available",
"it",
"will",
"create",
"compressed",
"DataOutputStream",
"otherwise",
"it",
"will",
"return",
"itself",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/FileWriterBase.java#L142-L148 |
115,456 | Netflix/suro | suro-kafka-consumer/src/main/java/com/netflix/suro/input/kafka/KafkaConsumer.java | KafkaConsumer.start | @Override
public void start() throws Exception {
executor = Executors.newCachedThreadPool(
new ThreadFactoryBuilder().setNameFormat("KafkaConsumer-%d").build());
connector = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumerProps));
final Map<String, List<Kafka... | java | @Override
public void start() throws Exception {
executor = Executors.newCachedThreadPool(
new ThreadFactoryBuilder().setNameFormat("KafkaConsumer-%d").build());
connector = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumerProps));
final Map<String, List<Kafka... | [
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"executor",
"=",
"Executors",
".",
"newCachedThreadPool",
"(",
"new",
"ThreadFactoryBuilder",
"(",
")",
".",
"setNameFormat",
"(",
"\"KafkaConsumer-%d\"",
")",
".",
"build",
"(",
... | not final for the test | [
"not",
"final",
"for",
"the",
"test"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-kafka-consumer/src/main/java/com/netflix/suro/input/kafka/KafkaConsumer.java#L76-L117 |
115,457 | Netflix/suro | suro-core/src/main/java/com/netflix/suro/sink/QueuedSink.java | QueuedSink.checkPause | public long checkPause() {
if (pauseOnLongQueue &&
(getNumOfPendingMessages() > queue4Sink.remainingCapacity() ||
getNumOfPendingMessages() > MAX_PENDING_MESSAGES_TO_PAUSE)) {
double throughputRate = Math.max(throughput.meanRate(), 1.0);
return (long) (get... | java | public long checkPause() {
if (pauseOnLongQueue &&
(getNumOfPendingMessages() > queue4Sink.remainingCapacity() ||
getNumOfPendingMessages() > MAX_PENDING_MESSAGES_TO_PAUSE)) {
double throughputRate = Math.max(throughput.meanRate(), 1.0);
return (long) (get... | [
"public",
"long",
"checkPause",
"(",
")",
"{",
"if",
"(",
"pauseOnLongQueue",
"&&",
"(",
"getNumOfPendingMessages",
"(",
")",
">",
"queue4Sink",
".",
"remainingCapacity",
"(",
")",
"||",
"getNumOfPendingMessages",
"(",
")",
">",
"MAX_PENDING_MESSAGES_TO_PAUSE",
")... | so, setting up minimum threshold as 1 message per millisecond | [
"so",
"setting",
"up",
"minimum",
"threshold",
"as",
"1",
"message",
"per",
"millisecond"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-core/src/main/java/com/netflix/suro/sink/QueuedSink.java#L51-L60 |
115,458 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java | LocalFileSink.beforePolling | @Override
protected void beforePolling() throws IOException {
// Don't rotate if we are not running
if (isRunning &&
(writer.getLength() > maxFileSize ||
System.currentTimeMillis() > nextRotation)) {
rotate();
}
} | java | @Override
protected void beforePolling() throws IOException {
// Don't rotate if we are not running
if (isRunning &&
(writer.getLength() > maxFileSize ||
System.currentTimeMillis() > nextRotation)) {
rotate();
}
} | [
"@",
"Override",
"protected",
"void",
"beforePolling",
"(",
")",
"throws",
"IOException",
"{",
"// Don't rotate if we are not running",
"if",
"(",
"isRunning",
"&&",
"(",
"writer",
".",
"getLength",
"(",
")",
">",
"maxFileSize",
"||",
"System",
".",
"currentTimeMi... | Before polling messages from the queue, it should check whether to rotate
the file and start to write to new file.
@throws java.io.IOException | [
"Before",
"polling",
"messages",
"from",
"the",
"queue",
"it",
"should",
"check",
"whether",
"to",
"rotate",
"the",
"file",
"and",
"start",
"to",
"write",
"to",
"new",
"file",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java#L211-L219 |
115,459 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java | LocalFileSink.write | @Override
protected void write(List<Message> msgList) throws IOException {
for (Message msg : msgList) {
writer.writeTo(msg);
String routingKey = normalizeRoutingKey(msg);
DynamicCounter.increment(
MonitorConfig.builder("writtenMessages")
... | java | @Override
protected void write(List<Message> msgList) throws IOException {
for (Message msg : msgList) {
writer.writeTo(msg);
String routingKey = normalizeRoutingKey(msg);
DynamicCounter.increment(
MonitorConfig.builder("writtenMessages")
... | [
"@",
"Override",
"protected",
"void",
"write",
"(",
"List",
"<",
"Message",
">",
"msgList",
")",
"throws",
"IOException",
"{",
"for",
"(",
"Message",
"msg",
":",
"msgList",
")",
"{",
"writer",
".",
"writeTo",
"(",
"msg",
")",
";",
"String",
"routingKey",... | Write all messages in msgList to file writer, sync the file,
commit the queue and clear messages
@param msgList
@throws java.io.IOException | [
"Write",
"all",
"messages",
"in",
"msgList",
"to",
"file",
"writer",
"sync",
"the",
"file",
"commit",
"the",
"queue",
"and",
"clear",
"messages"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java#L228-L252 |
115,460 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java | LocalFileSink.cleanUp | public int cleanUp(String dir, boolean fetchAll) {
if (!dir.endsWith("/")) {
dir += "/";
}
int count = 0;
try {
FileSystem fs = writer.getFS();
FileStatus[] files = fs.listStatus(new Path(dir));
for (FileStatus file: files) {
... | java | public int cleanUp(String dir, boolean fetchAll) {
if (!dir.endsWith("/")) {
dir += "/";
}
int count = 0;
try {
FileSystem fs = writer.getFS();
FileStatus[] files = fs.listStatus(new Path(dir));
for (FileStatus file: files) {
... | [
"public",
"int",
"cleanUp",
"(",
"String",
"dir",
",",
"boolean",
"fetchAll",
")",
"{",
"if",
"(",
"!",
"dir",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"dir",
"+=",
"\"/\"",
";",
"}",
"int",
"count",
"=",
"0",
";",
"try",
"{",
"FileSystem",
... | List all files under the directory. If the file is marked as done, the
notice for that file would be sent. Otherwise, it checks the file
is not closed properly, the file is marked as done and the notice
would be sent. That file would cause EOFException when reading.
@param dir
@return the number of files found in the ... | [
"List",
"all",
"files",
"under",
"the",
"directory",
".",
"If",
"the",
"file",
"is",
"marked",
"as",
"done",
"the",
"notice",
"for",
"that",
"file",
"would",
"be",
"sent",
".",
"Otherwise",
"it",
"checks",
"the",
"file",
"is",
"not",
"closed",
"properly"... | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java#L313-L353 |
115,461 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java | LocalFileSink.getFileExt | public static String getFileExt(String fileName) {
int dotPos = fileName.lastIndexOf('.');
if (dotPos != -1 && dotPos != fileName.length() - 1) {
return fileName.substring(dotPos);
} else {
return null;
}
} | java | public static String getFileExt(String fileName) {
int dotPos = fileName.lastIndexOf('.');
if (dotPos != -1 && dotPos != fileName.length() - 1) {
return fileName.substring(dotPos);
} else {
return null;
}
} | [
"public",
"static",
"String",
"getFileExt",
"(",
"String",
"fileName",
")",
"{",
"int",
"dotPos",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"dotPos",
"!=",
"-",
"1",
"&&",
"dotPos",
"!=",
"fileName",
".",
"length",
"(",
... | Simply returns file extension from the file path
@param fileName
@return | [
"Simply",
"returns",
"file",
"extension",
"from",
"the",
"file",
"path"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java#L361-L368 |
115,462 | Netflix/suro | suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java | LocalFileSink.deleteFile | public void deleteFile(String filePath) {
int retryCount = 1;
while (retryCount <= deleteFileRetryCount) {
try {
if (writer.getFS().exists(new Path(filePath))) {
Thread.sleep(1000 * retryCount);
writer.getFS().delete(new Path(filePath),... | java | public void deleteFile(String filePath) {
int retryCount = 1;
while (retryCount <= deleteFileRetryCount) {
try {
if (writer.getFS().exists(new Path(filePath))) {
Thread.sleep(1000 * retryCount);
writer.getFS().delete(new Path(filePath),... | [
"public",
"void",
"deleteFile",
"(",
"String",
"filePath",
")",
"{",
"int",
"retryCount",
"=",
"1",
";",
"while",
"(",
"retryCount",
"<=",
"deleteFileRetryCount",
")",
"{",
"try",
"{",
"if",
"(",
"writer",
".",
"getFS",
"(",
")",
".",
"exists",
"(",
"n... | With AWS EBS, sometimes deletion failure without any IOException was
observed To prevent the surplus files, let's iterate file deletion.
By default, it will try for five times.
@param filePath | [
"With",
"AWS",
"EBS",
"sometimes",
"deletion",
"failure",
"without",
"any",
"IOException",
"was",
"observed",
"To",
"prevent",
"the",
"surplus",
"files",
"let",
"s",
"iterate",
"file",
"deletion",
".",
"By",
"default",
"it",
"will",
"try",
"for",
"five",
"ti... | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-localfile/src/main/java/com/netflix/suro/sink/localfile/LocalFileSink.java#L390-L405 |
115,463 | Netflix/suro | suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java | ConnectionPool.chooseConnection | public SuroConnection chooseConnection() {
SuroConnection connection = connectionQueue.poll();
if (connection == null) {
connection = chooseFromPool();
}
if (config.getEnableOutPool()) {
synchronized (this) {
for (int i = 0; i < config.getRetryCou... | java | public SuroConnection chooseConnection() {
SuroConnection connection = connectionQueue.poll();
if (connection == null) {
connection = chooseFromPool();
}
if (config.getEnableOutPool()) {
synchronized (this) {
for (int i = 0; i < config.getRetryCou... | [
"public",
"SuroConnection",
"chooseConnection",
"(",
")",
"{",
"SuroConnection",
"connection",
"=",
"connectionQueue",
".",
"poll",
"(",
")",
";",
"if",
"(",
"connection",
"==",
"null",
")",
"{",
"connection",
"=",
"chooseFromPool",
"(",
")",
";",
"}",
"if",... | When the client calls this method, it will return the connection.
@return connection | [
"When",
"the",
"client",
"calls",
"this",
"method",
"it",
"will",
"return",
"the",
"connection",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java#L200-L231 |
115,464 | Netflix/suro | suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java | ConnectionPool.endConnection | public void endConnection(SuroConnection connection) {
if (connection != null && shouldChangeConnection(connection)) {
connection.initStat();
connectionPool.put(connection.getServer(), connection);
connection = chooseFromPool();
}
if (connection != null) {
... | java | public void endConnection(SuroConnection connection) {
if (connection != null && shouldChangeConnection(connection)) {
connection.initStat();
connectionPool.put(connection.getServer(), connection);
connection = chooseFromPool();
}
if (connection != null) {
... | [
"public",
"void",
"endConnection",
"(",
"SuroConnection",
"connection",
")",
"{",
"if",
"(",
"connection",
"!=",
"null",
"&&",
"shouldChangeConnection",
"(",
"connection",
")",
")",
"{",
"connection",
".",
"initStat",
"(",
")",
";",
"connectionPool",
".",
"put... | When the client finishes communication with the client, this method
should be called to release the connection and return it to the pool.
@param connection | [
"When",
"the",
"client",
"finishes",
"communication",
"with",
"the",
"client",
"this",
"method",
"should",
"be",
"called",
"to",
"release",
"the",
"connection",
"and",
"return",
"it",
"to",
"the",
"pool",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java#L283-L293 |
115,465 | Netflix/suro | suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java | ConnectionPool.markServerDown | public void markServerDown(SuroConnection connection) {
if (connection != null) {
lb.markServerDown(connection.getServer());
removeConnection(new ImmutableSet.Builder<Server>().add(connection.getServer()).build());
}
} | java | public void markServerDown(SuroConnection connection) {
if (connection != null) {
lb.markServerDown(connection.getServer());
removeConnection(new ImmutableSet.Builder<Server>().add(connection.getServer()).build());
}
} | [
"public",
"void",
"markServerDown",
"(",
"SuroConnection",
"connection",
")",
"{",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"lb",
".",
"markServerDown",
"(",
"connection",
".",
"getServer",
"(",
")",
")",
";",
"removeConnection",
"(",
"new",
"Immutab... | Mark up the server related with the connection as down
When the client fails to communicate with the connection,
this method should be called to remove the server from the pool
@param connection | [
"Mark",
"up",
"the",
"server",
"related",
"with",
"the",
"connection",
"as",
"down",
"When",
"the",
"client",
"fails",
"to",
"communicate",
"with",
"the",
"connection",
"this",
"method",
"should",
"be",
"called",
"to",
"remove",
"the",
"server",
"from",
"the... | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-client/src/main/java/com/netflix/suro/connection/ConnectionPool.java#L301-L306 |
115,466 | Netflix/suro | suro-client/src/main/java/com/netflix/suro/connection/EurekaLoadBalancer.java | EurekaLoadBalancer.chooseServer | @Override
public Server chooseServer(Object key) {
Server server = super.chooseServer(key);
if (server == null) {
return null;
}
server.setPort(port);
return server;
} | java | @Override
public Server chooseServer(Object key) {
Server server = super.chooseServer(key);
if (server == null) {
return null;
}
server.setPort(port);
return server;
} | [
"@",
"Override",
"public",
"Server",
"chooseServer",
"(",
"Object",
"key",
")",
"{",
"Server",
"server",
"=",
"super",
".",
"chooseServer",
"(",
"key",
")",
";",
"if",
"(",
"server",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"server",
".",
... | This function is called from ConnectionPool to retrieve which server to
communicate
@param key can bel null
@return | [
"This",
"function",
"is",
"called",
"from",
"ConnectionPool",
"to",
"retrieve",
"which",
"server",
"to",
"communicate"
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-client/src/main/java/com/netflix/suro/connection/EurekaLoadBalancer.java#L69-L78 |
115,467 | Netflix/suro | suro-core/src/main/java/com/netflix/suro/SuroPlugin.java | SuroPlugin.addSinkType | public <T extends Sink> void addSinkType(String typeName, Class<T> sinkClass) {
LOG.info("Adding sinkType: " + typeName + " -> " + sinkClass.getCanonicalName());
Multibinder<TypeHolder> bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().to... | java | public <T extends Sink> void addSinkType(String typeName, Class<T> sinkClass) {
LOG.info("Adding sinkType: " + typeName + " -> " + sinkClass.getCanonicalName());
Multibinder<TypeHolder> bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().to... | [
"public",
"<",
"T",
"extends",
"Sink",
">",
"void",
"addSinkType",
"(",
"String",
"typeName",
",",
"Class",
"<",
"T",
">",
"sinkClass",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Adding sinkType: \"",
"+",
"typeName",
"+",
"\" -> \"",
"+",
"sinkClass",
".",
"... | Add a sink implementation to Suro. typeName is the expected value of the
'type' field of a JSON configuration.
@param typeName
@param sinkClass | [
"Add",
"a",
"sink",
"implementation",
"to",
"Suro",
".",
"typeName",
"is",
"the",
"expected",
"value",
"of",
"the",
"type",
"field",
"of",
"a",
"JSON",
"configuration",
"."
] | e73d1a2e5b0492e41feb5a57d9e2a2e741a38453 | https://github.com/Netflix/suro/blob/e73d1a2e5b0492e41feb5a57d9e2a2e741a38453/suro-core/src/main/java/com/netflix/suro/SuroPlugin.java#L31-L37 |
115,468 | yegor256/takes | src/main/java/org/takes/rs/RsWithStatus.java | RsWithStatus.head | private static Iterable<String> head(final Response origin,
final int status, final CharSequence reason) throws IOException {
// @checkstyle MagicNumber (1 line)
if (status < 100 || status > 999) {
throw new IllegalArgumentException(
String.format(
... | java | private static Iterable<String> head(final Response origin,
final int status, final CharSequence reason) throws IOException {
// @checkstyle MagicNumber (1 line)
if (status < 100 || status > 999) {
throw new IllegalArgumentException(
String.format(
... | [
"private",
"static",
"Iterable",
"<",
"String",
">",
"head",
"(",
"final",
"Response",
"origin",
",",
"final",
"int",
"status",
",",
"final",
"CharSequence",
"reason",
")",
"throws",
"IOException",
"{",
"// @checkstyle MagicNumber (1 line)",
"if",
"(",
"status",
... | Make head.
@param origin Original response
@param status Status
@param reason Reason
@return Head
@throws IOException If fails | [
"Make",
"head",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsWithStatus.java#L103-L124 |
115,469 | yegor256/takes | src/main/java/org/takes/rs/RsWithStatus.java | RsWithStatus.make | private static Map<Integer, String> make() {
final Map<Integer, String> map = new HashMap<>(0);
map.put(HttpURLConnection.HTTP_OK, "OK");
map.put(HttpURLConnection.HTTP_NO_CONTENT, "No Content");
map.put(HttpURLConnection.HTTP_CREATED, "Created");
map.put(HttpURLConnection.HTTP_A... | java | private static Map<Integer, String> make() {
final Map<Integer, String> map = new HashMap<>(0);
map.put(HttpURLConnection.HTTP_OK, "OK");
map.put(HttpURLConnection.HTTP_NO_CONTENT, "No Content");
map.put(HttpURLConnection.HTTP_CREATED, "Created");
map.put(HttpURLConnection.HTTP_A... | [
"private",
"static",
"Map",
"<",
"Integer",
",",
"String",
">",
"make",
"(",
")",
"{",
"final",
"Map",
"<",
"Integer",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
"0",
")",
";",
"map",
".",
"put",
"(",
"HttpURLConnection",
".",
"HT... | Make all reasons.
@return Map of status codes and reasons
@checkstyle ExecutableStatementCountCheck (100 lines) | [
"Make",
"all",
"reasons",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsWithStatus.java#L140-L169 |
115,470 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.bare | public String bare() {
final StringBuilder text = new StringBuilder(this.uri.toString());
if (this.uri.getPath().isEmpty()) {
text.append('/');
}
return text.toString();
} | java | public String bare() {
final StringBuilder text = new StringBuilder(this.uri.toString());
if (this.uri.getPath().isEmpty()) {
text.append('/');
}
return text.toString();
} | [
"public",
"String",
"bare",
"(",
")",
"{",
"final",
"StringBuilder",
"text",
"=",
"new",
"StringBuilder",
"(",
"this",
".",
"uri",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"this",
".",
"uri",
".",
"getPath",
"(",
")",
".",
"isEmpty",
"(",
")... | Get URI without params.
@return Bare URI
@since 0.14 | [
"Get",
"URI",
"without",
"params",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L170-L176 |
115,471 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.param | public Iterable<String> param(final Object key) {
final List<String> values = this.params.getOrDefault(
key.toString(),
Collections.emptyList()
);
final Iterable<String> iter;
if (values.isEmpty()) {
iter = new VerboseIterable<>(
Collec... | java | public Iterable<String> param(final Object key) {
final List<String> values = this.params.getOrDefault(
key.toString(),
Collections.emptyList()
);
final Iterable<String> iter;
if (values.isEmpty()) {
iter = new VerboseIterable<>(
Collec... | [
"public",
"Iterable",
"<",
"String",
">",
"param",
"(",
"final",
"Object",
"key",
")",
"{",
"final",
"List",
"<",
"String",
">",
"values",
"=",
"this",
".",
"params",
".",
"getOrDefault",
"(",
"key",
".",
"toString",
"(",
")",
",",
"Collections",
".",
... | Get query param.
@param key Param name
@return Values (could be empty)
@since 0.9 | [
"Get",
"query",
"param",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L184-L208 |
115,472 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.path | public Href path(final Object suffix) {
return new Href(
URI.create(
new StringBuilder(
Href.TRAILING_SLASH.matcher(this.uri.toString())
.replaceAll("")
)
.append('/')
.append(Href.encode(suff... | java | public Href path(final Object suffix) {
return new Href(
URI.create(
new StringBuilder(
Href.TRAILING_SLASH.matcher(this.uri.toString())
.replaceAll("")
)
.append('/')
.append(Href.encode(suff... | [
"public",
"Href",
"path",
"(",
"final",
"Object",
"suffix",
")",
"{",
"return",
"new",
"Href",
"(",
"URI",
".",
"create",
"(",
"new",
"StringBuilder",
"(",
"Href",
".",
"TRAILING_SLASH",
".",
"matcher",
"(",
"this",
".",
"uri",
".",
"toString",
"(",
")... | Add this path to the URI.
@param suffix The suffix
@return New HREF | [
"Add",
"this",
"path",
"to",
"the",
"URI",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L215-L228 |
115,473 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.with | public Href with(final Object key, final Object value) {
final SortedMap<String, List<String>> map = new TreeMap<>(this.params);
if (!map.containsKey(key.toString())) {
map.put(key.toString(), new LinkedList<>());
}
map.get(key.toString()).add(value.toString());
retur... | java | public Href with(final Object key, final Object value) {
final SortedMap<String, List<String>> map = new TreeMap<>(this.params);
if (!map.containsKey(key.toString())) {
map.put(key.toString(), new LinkedList<>());
}
map.get(key.toString()).add(value.toString());
retur... | [
"public",
"Href",
"with",
"(",
"final",
"Object",
"key",
",",
"final",
"Object",
"value",
")",
"{",
"final",
"SortedMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
"this",
".",
"params",
")",
";",
... | Add this extra param.
@param key Key of the param
@param value The value
@return New HREF | [
"Add",
"this",
"extra",
"param",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L236-L243 |
115,474 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.without | public Href without(final Object key) {
final SortedMap<String, List<String>> map = new TreeMap<>(this.params);
map.remove(key.toString());
return new Href(this.uri, map, this.fragment);
} | java | public Href without(final Object key) {
final SortedMap<String, List<String>> map = new TreeMap<>(this.params);
map.remove(key.toString());
return new Href(this.uri, map, this.fragment);
} | [
"public",
"Href",
"without",
"(",
"final",
"Object",
"key",
")",
"{",
"final",
"SortedMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
"this",
".",
"params",
")",
";",
"map",
".",
"remove",
"(",
"k... | Without this query param.
@param key Key of the param
@return New HREF | [
"Without",
"this",
"query",
"param",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L250-L254 |
115,475 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.encode | private static String encode(final String txt) {
try {
return URLEncoder.encode(
txt, Charset.defaultCharset().name()
);
} catch (final UnsupportedEncodingException ex) {
throw new IllegalStateException(ex);
}
} | java | private static String encode(final String txt) {
try {
return URLEncoder.encode(
txt, Charset.defaultCharset().name()
);
} catch (final UnsupportedEncodingException ex) {
throw new IllegalStateException(ex);
}
} | [
"private",
"static",
"String",
"encode",
"(",
"final",
"String",
"txt",
")",
"{",
"try",
"{",
"return",
"URLEncoder",
".",
"encode",
"(",
"txt",
",",
"Charset",
".",
"defaultCharset",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"}",
"catch",
"(",
"fin... | Encode into URL.
@param txt Text
@return Encoded | [
"Encode",
"into",
"URL",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L261-L269 |
115,476 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.asMap | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static SortedMap<String, List<String>> asMap(final String query) {
final SortedMap<String, List<String>> params = new TreeMap<>();
if (query != null) {
for (final String pair : query.split("&")) {
final Str... | java | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static SortedMap<String, List<String>> asMap(final String query) {
final SortedMap<String, List<String>> params = new TreeMap<>();
if (query != null) {
for (final String pair : query.split("&")) {
final Str... | [
"@",
"SuppressWarnings",
"(",
"\"PMD.AvoidInstantiatingObjectsInLoops\"",
")",
"private",
"static",
"SortedMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"asMap",
"(",
"final",
"String",
"query",
")",
"{",
"final",
"SortedMap",
"<",
"String",
",",
... | Convert the provided query into a Map.
@param query The query to parse.
@return A map containing all the query arguments and their values. | [
"Convert",
"the",
"provided",
"query",
"into",
"a",
"Map",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L323-L343 |
115,477 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.createBare | private static URI createBare(final URI link) {
final URI uri;
if (link.getRawQuery() == null && link.getRawFragment() == null) {
uri = link;
} else {
final String href = link.toString();
final int idx;
if (link.getRawQuery() == null) {
... | java | private static URI createBare(final URI link) {
final URI uri;
if (link.getRawQuery() == null && link.getRawFragment() == null) {
uri = link;
} else {
final String href = link.toString();
final int idx;
if (link.getRawQuery() == null) {
... | [
"private",
"static",
"URI",
"createBare",
"(",
"final",
"URI",
"link",
")",
"{",
"final",
"URI",
"uri",
";",
"if",
"(",
"link",
".",
"getRawQuery",
"(",
")",
"==",
"null",
"&&",
"link",
".",
"getRawFragment",
"(",
")",
"==",
"null",
")",
"{",
"uri",
... | Remove query and fragment parts from the provided URI and
return the resulting URI.
@param link The link from which parts need to be removed.
@return The URI corresponding to the same provided URI but without
query and fragment parts. | [
"Remove",
"query",
"and",
"fragment",
"parts",
"from",
"the",
"provided",
"URI",
"and",
"return",
"the",
"resulting",
"URI",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L352-L367 |
115,478 | yegor256/takes | src/main/java/org/takes/misc/Href.java | Href.readFragment | private static Opt<String> readFragment(final URI link) {
final Opt<String> fragment;
if (link.getRawFragment() == null) {
fragment = new Opt.Empty<>();
} else {
fragment = new Opt.Single<>(link.getRawFragment());
}
return fragment;
} | java | private static Opt<String> readFragment(final URI link) {
final Opt<String> fragment;
if (link.getRawFragment() == null) {
fragment = new Opt.Empty<>();
} else {
fragment = new Opt.Single<>(link.getRawFragment());
}
return fragment;
} | [
"private",
"static",
"Opt",
"<",
"String",
">",
"readFragment",
"(",
"final",
"URI",
"link",
")",
"{",
"final",
"Opt",
"<",
"String",
">",
"fragment",
";",
"if",
"(",
"link",
".",
"getRawFragment",
"(",
")",
"==",
"null",
")",
"{",
"fragment",
"=",
"... | Read fragment part from the given URI.
@param link The link from which the fragment needs to be returned.
@return Opt with fragment or empty if there is no fragment. | [
"Read",
"fragment",
"part",
"from",
"the",
"given",
"URI",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/misc/Href.java#L374-L382 |
115,479 | yegor256/takes | src/main/java/org/takes/rq/RqGreedy.java | RqGreedy.consume | private static Request consume(final Request req) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new RqPrint(req).printBody(baos);
return new Request() {
@Override
public Iterable<String> head() throws IOException {
re... | java | private static Request consume(final Request req) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new RqPrint(req).printBody(baos);
return new Request() {
@Override
public Iterable<String> head() throws IOException {
re... | [
"private",
"static",
"Request",
"consume",
"(",
"final",
"Request",
"req",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"new",
"RqPrint",
"(",
"req",
")",
".",
"printBody",
"("... | Consume the request.
@param req Request
@return New request
@throws IOException If fails | [
"Consume",
"the",
"request",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rq/RqGreedy.java#L58-L72 |
115,480 | yegor256/takes | src/main/java/org/takes/tk/TkProxy.java | TkProxy.request | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private com.jcabi.http.Request request(final Request req,
final URI dest) throws IOException {
final String method = new RqMethod.Base(req).method();
com.jcabi.http.Request proxied = new JdkRequest(dest).method(method);
final ... | java | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private com.jcabi.http.Request request(final Request req,
final URI dest) throws IOException {
final String method = new RqMethod.Base(req).method();
com.jcabi.http.Request proxied = new JdkRequest(dest).method(method);
final ... | [
"@",
"SuppressWarnings",
"(",
"\"PMD.AvoidInstantiatingObjectsInLoops\"",
")",
"private",
"com",
".",
"jcabi",
".",
"http",
".",
"Request",
"request",
"(",
"final",
"Request",
"req",
",",
"final",
"URI",
"dest",
")",
"throws",
"IOException",
"{",
"final",
"Strin... | Creates the request to be forwarded to the target host.
@param req Original request
@param dest Destination URL
@return Request to be forwarded
@throws IOException If some problem inside | [
"Creates",
"the",
"request",
"to",
"be",
"forwarded",
"to",
"the",
"target",
"host",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/tk/TkProxy.java#L131-L156 |
115,481 | yegor256/takes | src/main/java/org/takes/tk/TkProxy.java | TkProxy.response | private Response response(final String home, final URI dest,
final com.jcabi.http.Response rsp) {
final Collection<String> hdrs = new LinkedList<>();
hdrs.add(
String.format(
"X-Takes-TkProxy: from %s to %s by %s",
home, dest, this.label
)
... | java | private Response response(final String home, final URI dest,
final com.jcabi.http.Response rsp) {
final Collection<String> hdrs = new LinkedList<>();
hdrs.add(
String.format(
"X-Takes-TkProxy: from %s to %s by %s",
home, dest, this.label
)
... | [
"private",
"Response",
"response",
"(",
"final",
"String",
"home",
",",
"final",
"URI",
"dest",
",",
"final",
"com",
".",
"jcabi",
".",
"http",
".",
"Response",
"rsp",
")",
"{",
"final",
"Collection",
"<",
"String",
">",
"hdrs",
"=",
"new",
"LinkedList",... | Creates the response received from the target host.
@param home Home host
@param dest Destination URL
@param rsp Response received from the target host
@return Response | [
"Creates",
"the",
"response",
"received",
"from",
"the",
"target",
"host",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/tk/TkProxy.java#L166-L195 |
115,482 | yegor256/takes | src/main/java/org/takes/facets/fork/FkAgent.java | FkAgent.tokens | private static List<String> tokens(final Request req) throws IOException {
final List<String> tokens = new LinkedList<>();
final Iterable<String> headers =
new RqHeaders.Base(req).header("User-Agent");
for (final String header : headers) {
final Matcher matcher = PATTERN.... | java | private static List<String> tokens(final Request req) throws IOException {
final List<String> tokens = new LinkedList<>();
final Iterable<String> headers =
new RqHeaders.Base(req).header("User-Agent");
for (final String header : headers) {
final Matcher matcher = PATTERN.... | [
"private",
"static",
"List",
"<",
"String",
">",
"tokens",
"(",
"final",
"Request",
"req",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"String",
">",
"tokens",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"final",
"Iterable",
"<",
"String"... | Extract tokens from request.
@param req Request.
@return List of user agent tokens.
@throws IOException If some problems inside. | [
"Extract",
"tokens",
"from",
"request",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/fork/FkAgent.java#L95-L106 |
115,483 | yegor256/takes | src/main/java/org/takes/facets/fork/MediaTypes.java | MediaTypes.contains | public boolean contains(final MediaTypes types) {
boolean contains = false;
for (final MediaType type : types.list) {
if (this.contains(type)) {
contains = true;
break;
}
}
return contains;
} | java | public boolean contains(final MediaTypes types) {
boolean contains = false;
for (final MediaType type : types.list) {
if (this.contains(type)) {
contains = true;
break;
}
}
return contains;
} | [
"public",
"boolean",
"contains",
"(",
"final",
"MediaTypes",
"types",
")",
"{",
"boolean",
"contains",
"=",
"false",
";",
"for",
"(",
"final",
"MediaType",
"type",
":",
"types",
".",
"list",
")",
"{",
"if",
"(",
"this",
".",
"contains",
"(",
"type",
")... | Contains any of these types?
@param types Types
@return TRUE if any of these types are present inside this.list | [
"Contains",
"any",
"of",
"these",
"types?"
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/fork/MediaTypes.java#L78-L87 |
115,484 | yegor256/takes | src/main/java/org/takes/facets/fork/MediaTypes.java | MediaTypes.contains | public boolean contains(final MediaType type) {
boolean contains = false;
for (final MediaType mine : this.list) {
if (mine.matches(type)) {
contains = true;
break;
}
}
return contains;
} | java | public boolean contains(final MediaType type) {
boolean contains = false;
for (final MediaType mine : this.list) {
if (mine.matches(type)) {
contains = true;
break;
}
}
return contains;
} | [
"public",
"boolean",
"contains",
"(",
"final",
"MediaType",
"type",
")",
"{",
"boolean",
"contains",
"=",
"false",
";",
"for",
"(",
"final",
"MediaType",
"mine",
":",
"this",
".",
"list",
")",
"{",
"if",
"(",
"mine",
".",
"matches",
"(",
"type",
")",
... | Contains this type?
@param type Type
@return TRUE if this type is present inside this.list | [
"Contains",
"this",
"type?"
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/fork/MediaTypes.java#L94-L103 |
115,485 | yegor256/takes | src/main/java/org/takes/facets/fork/MediaTypes.java | MediaTypes.merge | public MediaTypes merge(final MediaTypes types) {
final SortedSet<MediaType> set = new TreeSet<>();
set.addAll(this.list);
set.addAll(types.list);
return new MediaTypes(set);
} | java | public MediaTypes merge(final MediaTypes types) {
final SortedSet<MediaType> set = new TreeSet<>();
set.addAll(this.list);
set.addAll(types.list);
return new MediaTypes(set);
} | [
"public",
"MediaTypes",
"merge",
"(",
"final",
"MediaTypes",
"types",
")",
"{",
"final",
"SortedSet",
"<",
"MediaType",
">",
"set",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"set",
".",
"addAll",
"(",
"this",
".",
"list",
")",
";",
"set",
".",
"add... | Merge with this one.
@param types Types
@return Merged list | [
"Merge",
"with",
"this",
"one",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/fork/MediaTypes.java#L110-L115 |
115,486 | yegor256/takes | src/main/java/org/takes/facets/auth/codecs/CcAes.java | CcAes.encrypt | private byte[] encrypt(final byte[] bytes) throws IOException {
try {
final byte[] vector = new byte[CcAes.BLOCK];
this.random.nextBytes(vector);
final byte[] message = this.cipher(
Cipher.ENCRYPT_MODE,
new IvParameterSpec(vector)
)... | java | private byte[] encrypt(final byte[] bytes) throws IOException {
try {
final byte[] vector = new byte[CcAes.BLOCK];
this.random.nextBytes(vector);
final byte[] message = this.cipher(
Cipher.ENCRYPT_MODE,
new IvParameterSpec(vector)
)... | [
"private",
"byte",
"[",
"]",
"encrypt",
"(",
"final",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"try",
"{",
"final",
"byte",
"[",
"]",
"vector",
"=",
"new",
"byte",
"[",
"CcAes",
".",
"BLOCK",
"]",
";",
"this",
".",
"random",
".... | Encrypt the given bytes using AES.
@param bytes Bytes to encrypt
@return Encrypted byte using AES algorithm
@throws IOException for all unexpected exceptions | [
"Encrypt",
"the",
"given",
"bytes",
"using",
"AES",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/auth/codecs/CcAes.java#L141-L162 |
115,487 | yegor256/takes | src/main/java/org/takes/facets/auth/codecs/CcAes.java | CcAes.withCorrectBlockSize | private static byte[] withCorrectBlockSize(final byte[] key) {
if (key.length != CcAes.BLOCK) {
throw new IllegalArgumentException(
String.format(
"the length of the AES key must be exactly %d bytes",
CcAes.BLOCK
)
)... | java | private static byte[] withCorrectBlockSize(final byte[] key) {
if (key.length != CcAes.BLOCK) {
throw new IllegalArgumentException(
String.format(
"the length of the AES key must be exactly %d bytes",
CcAes.BLOCK
)
)... | [
"private",
"static",
"byte",
"[",
"]",
"withCorrectBlockSize",
"(",
"final",
"byte",
"[",
"]",
"key",
")",
"{",
"if",
"(",
"key",
".",
"length",
"!=",
"CcAes",
".",
"BLOCK",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"forma... | Check the block size of the key.
@param key The encryption key
@return The verified encryption key | [
"Check",
"the",
"block",
"size",
"of",
"the",
"key",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/auth/codecs/CcAes.java#L170-L180 |
115,488 | yegor256/takes | src/main/java/org/takes/facets/auth/codecs/CcAes.java | CcAes.decrypt | private byte[] decrypt(final byte[] bytes) throws IOException {
if (bytes.length < CcAes.BLOCK << 1) {
throw new DecodingException("Invalid encrypted message format");
}
try {
final byte[] vector = new byte[CcAes.BLOCK];
final byte[] message = new byte[bytes.l... | java | private byte[] decrypt(final byte[] bytes) throws IOException {
if (bytes.length < CcAes.BLOCK << 1) {
throw new DecodingException("Invalid encrypted message format");
}
try {
final byte[] vector = new byte[CcAes.BLOCK];
final byte[] message = new byte[bytes.l... | [
"private",
"byte",
"[",
"]",
"decrypt",
"(",
"final",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"bytes",
".",
"length",
"<",
"CcAes",
".",
"BLOCK",
"<<",
"1",
")",
"{",
"throw",
"new",
"DecodingException",
"(",
"\"Invalid... | Decrypt the given bytes using AES.
@param bytes Bytes to decrypt
@return Decrypted bytes
@throws IOException for all unexpected exceptions | [
"Decrypt",
"the",
"given",
"bytes",
"using",
"AES",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/auth/codecs/CcAes.java#L189-L211 |
115,489 | yegor256/takes | src/main/java/org/takes/facets/auth/social/PsLinkedin.java | PsLinkedin.fetch | private Identity fetch(final String token) throws IOException {
// @checkstyle LineLength (1 line)
final String uri = this.apihref
.with("oauth2_access_token", token)
.with("format", "json")
.toString();
return PsLinkedin.parse(
new JdkRequest(uri)... | java | private Identity fetch(final String token) throws IOException {
// @checkstyle LineLength (1 line)
final String uri = this.apihref
.with("oauth2_access_token", token)
.with("format", "json")
.toString();
return PsLinkedin.parse(
new JdkRequest(uri)... | [
"private",
"Identity",
"fetch",
"(",
"final",
"String",
"token",
")",
"throws",
"IOException",
"{",
"// @checkstyle LineLength (1 line)",
"final",
"String",
"uri",
"=",
"this",
".",
"apihref",
".",
"with",
"(",
"\"oauth2_access_token\"",
",",
"token",
")",
".",
... | Get user name from Linkedin, with the token provided.
@param token PsLinkedin access token
@return The user found in PsLinkedin
@throws IOException If fails | [
"Get",
"user",
"name",
"from",
"Linkedin",
"with",
"the",
"token",
"provided",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/auth/social/PsLinkedin.java#L139-L152 |
115,490 | yegor256/takes | src/main/java/org/takes/facets/auth/social/PsLinkedin.java | PsLinkedin.token | private String token(final String home, final String code)
throws IOException {
final String uri = this.tkhref.toString();
return new JdkRequest(uri)
.method("POST")
.header("Accept", "application/xml")
.body()
.formParam("grant_type", "authorizati... | java | private String token(final String home, final String code)
throws IOException {
final String uri = this.tkhref.toString();
return new JdkRequest(uri)
.method("POST")
.header("Accept", "application/xml")
.body()
.formParam("grant_type", "authorizati... | [
"private",
"String",
"token",
"(",
"final",
"String",
"home",
",",
"final",
"String",
"code",
")",
"throws",
"IOException",
"{",
"final",
"String",
"uri",
"=",
"this",
".",
"tkhref",
".",
"toString",
"(",
")",
";",
"return",
"new",
"JdkRequest",
"(",
"ur... | Retrieve PsLinkedin access token.
@param home Home of this page
@param code PsLinkedin "authorization code"
@return The token
@throws IOException If failed | [
"Retrieve",
"PsLinkedin",
"access",
"token",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/auth/social/PsLinkedin.java#L161-L178 |
115,491 | yegor256/takes | src/main/java/org/takes/facets/ret/RsReturn.java | RsReturn.validLocation | private static String validLocation(final String loc) throws IOException {
if (!RsReturn.LOC_PTRN.matcher(loc).matches()) {
throw new IOException(
String.format(
"Location \"%s\" should complain RFC 3987",
loc
)
);
... | java | private static String validLocation(final String loc) throws IOException {
if (!RsReturn.LOC_PTRN.matcher(loc).matches()) {
throw new IOException(
String.format(
"Location \"%s\" should complain RFC 3987",
loc
)
);
... | [
"private",
"static",
"String",
"validLocation",
"(",
"final",
"String",
"loc",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"RsReturn",
".",
"LOC_PTRN",
".",
"matcher",
"(",
"loc",
")",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"IOExcepti... | Checks location according to RFC 3987.
@param loc Location to be checked
@return Valid location
@throws IOException If fails | [
"Checks",
"location",
"according",
"to",
"RFC",
"3987",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/facets/ret/RsReturn.java#L97-L107 |
115,492 | yegor256/takes | src/main/java/org/takes/http/Options.java | Options.socket | public ServerSocket socket() throws IOException {
final String port = this.map.get("port");
if (port == null) {
throw new IllegalArgumentException("--port must be specified");
}
final ServerSocket socket;
if (port.matches("\\d+")) {
socket = new ServerSock... | java | public ServerSocket socket() throws IOException {
final String port = this.map.get("port");
if (port == null) {
throw new IllegalArgumentException("--port must be specified");
}
final ServerSocket socket;
if (port.matches("\\d+")) {
socket = new ServerSock... | [
"public",
"ServerSocket",
"socket",
"(",
")",
"throws",
"IOException",
"{",
"final",
"String",
"port",
"=",
"this",
".",
"map",
".",
"get",
"(",
"\"port\"",
")",
";",
"if",
"(",
"port",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
... | Get the socket to listen to.
@return Socket
@throws IOException If fails | [
"Get",
"the",
"socket",
"to",
"listen",
"to",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/http/Options.java#L86-L118 |
115,493 | yegor256/takes | src/main/java/org/takes/http/Options.java | Options.threads | public int threads() {
return Integer.parseInt(
this.map.getOrDefault(
"threads",
String.valueOf(Runtime.getRuntime().availableProcessors() << 2)
)
);
} | java | public int threads() {
return Integer.parseInt(
this.map.getOrDefault(
"threads",
String.valueOf(Runtime.getRuntime().availableProcessors() << 2)
)
);
} | [
"public",
"int",
"threads",
"(",
")",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"this",
".",
"map",
".",
"getOrDefault",
"(",
"\"threads\"",
",",
"String",
".",
"valueOf",
"(",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
... | Get the threads.
@return Threads | [
"Get",
"the",
"threads",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/http/Options.java#L145-L152 |
115,494 | yegor256/takes | src/main/java/org/takes/http/Options.java | Options.asMap | private static Map<String, String> asMap(final Iterable<String> args) {
final Map<String, String> map = new HashMap<>(0);
final Pattern ptn = Pattern.compile("--([a-z\\-]+)(=.+)?");
for (final String arg : args) {
final Matcher matcher = ptn.matcher(arg);
if (!matcher.mat... | java | private static Map<String, String> asMap(final Iterable<String> args) {
final Map<String, String> map = new HashMap<>(0);
final Pattern ptn = Pattern.compile("--([a-z\\-]+)(=.+)?");
for (final String arg : args) {
final Matcher matcher = ptn.matcher(arg);
if (!matcher.mat... | [
"private",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"asMap",
"(",
"final",
"Iterable",
"<",
"String",
">",
"args",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
"0",
")",
";",
"fina... | Convert the provided arguments into a Map.
@param args Arguments to parse.
@return Map A map containing all the arguments and their values.
@throws IllegalStateException If an argument doesn't match with the
expected format which is {@code --([a-z\-]+)(=.+)?}. | [
"Convert",
"the",
"provided",
"arguments",
"into",
"a",
"Map",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/http/Options.java#L174-L192 |
115,495 | yegor256/takes | src/main/java/org/takes/rs/RsPrint.java | RsPrint.print | public String print() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.print(baos);
return new Utf8String(baos.toByteArray()).asString();
} | java | public String print() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.print(baos);
return new Utf8String(baos.toByteArray()).asString();
} | [
"public",
"String",
"print",
"(",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"this",
".",
"print",
"(",
"baos",
")",
";",
"return",
"new",
"Utf8String",
"(",
"baos",
".",
... | Print it into string.
@return Entire HTTP response
@throws IOException If fails | [
"Print",
"it",
"into",
"string",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsPrint.java#L86-L90 |
115,496 | yegor256/takes | src/main/java/org/takes/rs/RsPrint.java | RsPrint.printBody | public String printBody() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.printBody(baos);
return new Utf8String(baos.toByteArray()).asString();
} | java | public String printBody() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.printBody(baos);
return new Utf8String(baos.toByteArray()).asString();
} | [
"public",
"String",
"printBody",
"(",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"this",
".",
"printBody",
"(",
"baos",
")",
";",
"return",
"new",
"Utf8String",
"(",
"baos",
... | Print body into string.
@return Entire body of HTTP response
@throws IOException If fails | [
"Print",
"body",
"into",
"string",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsPrint.java#L102-L106 |
115,497 | yegor256/takes | src/main/java/org/takes/rs/RsPrint.java | RsPrint.printHead | public String printHead() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.printHead(baos);
return new Utf8String(baos.toByteArray()).asString();
} | java | public String printHead() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.printHead(baos);
return new Utf8String(baos.toByteArray()).asString();
} | [
"public",
"String",
"printHead",
"(",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"this",
".",
"printHead",
"(",
"baos",
")",
";",
"return",
"new",
"Utf8String",
"(",
"baos",
... | Print head into string.
@return Entire head of HTTP response
@throws IOException If fails
@since 0.10 | [
"Print",
"head",
"into",
"string",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsPrint.java#L114-L118 |
115,498 | yegor256/takes | src/main/java/org/takes/rs/RsPrint.java | RsPrint.printHead | public void printHead(final Writer writer) throws IOException {
final String eol = "\r\n";
int pos = 0;
try {
for (final String line : this.head()) {
if (pos == 0 && !RsPrint.FIRST.matcher(line).matches()) {
throw new IllegalArgumentException(
... | java | public void printHead(final Writer writer) throws IOException {
final String eol = "\r\n";
int pos = 0;
try {
for (final String line : this.head()) {
if (pos == 0 && !RsPrint.FIRST.matcher(line).matches()) {
throw new IllegalArgumentException(
... | [
"public",
"void",
"printHead",
"(",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"final",
"String",
"eol",
"=",
"\"\\r\\n\"",
";",
"int",
"pos",
"=",
"0",
";",
"try",
"{",
"for",
"(",
"final",
"String",
"line",
":",
"this",
".",
"hea... | Print it into a writer.
@param writer Writer to print into
@throws IOException If fails
@since 2.0 | [
"Print",
"it",
"into",
"a",
"writer",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsPrint.java#L146-L177 |
115,499 | yegor256/takes | src/main/java/org/takes/rs/RsPrint.java | RsPrint.printBody | public void printBody(final OutputStream output) throws IOException {
//@checkstyle MagicNumberCheck (1 line)
final byte[] buf = new byte[4096];
try (InputStream body = this.body()) {
while (true) {
final int bytes = body.read(buf);
if (bytes < 0) {
... | java | public void printBody(final OutputStream output) throws IOException {
//@checkstyle MagicNumberCheck (1 line)
final byte[] buf = new byte[4096];
try (InputStream body = this.body()) {
while (true) {
final int bytes = body.read(buf);
if (bytes < 0) {
... | [
"public",
"void",
"printBody",
"(",
"final",
"OutputStream",
"output",
")",
"throws",
"IOException",
"{",
"//@checkstyle MagicNumberCheck (1 line)",
"final",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"try",
"(",
"InputStream",
"body",
... | Print it into output stream.
@param output Output to print into
@throws IOException If fails | [
"Print",
"it",
"into",
"output",
"stream",
"."
] | a4f4d939c8f8e0af190025716ad7f22b7de40e70 | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsPrint.java#L184-L198 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.