repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java | ComponentExposedTypeGenerator.getSuperMethodCallParameters | private String getSuperMethodCallParameters(ExecutableElement sourceMethod) {
return sourceMethod
.getParameters()
.stream()
.map(parameter -> parameter.getSimpleName().toString())
.collect(Collectors.joining(", "));
} | java | private String getSuperMethodCallParameters(ExecutableElement sourceMethod) {
return sourceMethod
.getParameters()
.stream()
.map(parameter -> parameter.getSimpleName().toString())
.collect(Collectors.joining(", "));
} | [
"private",
"String",
"getSuperMethodCallParameters",
"(",
"ExecutableElement",
"sourceMethod",
")",
"{",
"return",
"sourceMethod",
".",
"getParameters",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"parameter",
"->",
"parameter",
".",
"getSimpleName",
"(",
... | Return the list of parameters name to pass to the super call on proxy methods.
@param sourceMethod The source method
@return A string which is the list of parameters name joined by ", " | [
"Return",
"the",
"list",
"of",
"parameters",
"name",
"to",
"pass",
"to",
"the",
"super",
"call",
"on",
"proxy",
"methods",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java#L854-L860 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java | ComponentExposedTypeGenerator.addEmitEventCall | private void addEmitEventCall(ExecutableElement originalMethod,
MethodSpec.Builder proxyMethodBuilder, String methodCallParameters) {
String methodName = "$emit";
if (methodCallParameters != null && !"".equals(methodCallParameters)) {
proxyMethodBuilder.addStatement("vue().$L($S, $L)",
methodName,
methodToEventName(originalMethod),
methodCallParameters);
} else {
proxyMethodBuilder.addStatement("vue().$L($S)",
methodName,
methodToEventName(originalMethod));
}
} | java | private void addEmitEventCall(ExecutableElement originalMethod,
MethodSpec.Builder proxyMethodBuilder, String methodCallParameters) {
String methodName = "$emit";
if (methodCallParameters != null && !"".equals(methodCallParameters)) {
proxyMethodBuilder.addStatement("vue().$L($S, $L)",
methodName,
methodToEventName(originalMethod),
methodCallParameters);
} else {
proxyMethodBuilder.addStatement("vue().$L($S)",
methodName,
methodToEventName(originalMethod));
}
} | [
"private",
"void",
"addEmitEventCall",
"(",
"ExecutableElement",
"originalMethod",
",",
"MethodSpec",
".",
"Builder",
"proxyMethodBuilder",
",",
"String",
"methodCallParameters",
")",
"{",
"String",
"methodName",
"=",
"\"$emit\"",
";",
"if",
"(",
"methodCallParameters",... | Add a call to emit an event at the end of the function
@param originalMethod Method we are emitting an event for
@param proxyMethodBuilder Method we are building
@param methodCallParameters Chained parameters name of the method | [
"Add",
"a",
"call",
"to",
"emit",
"an",
"event",
"at",
"the",
"end",
"of",
"the",
"function"
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java#L869-L882 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java | ComponentExposedTypeGenerator.isHookMethod | private boolean isHookMethod(TypeElement component, ExecutableElement method,
Set<ExecutableElement> hookMethodsFromInterfaces) {
if (hasAnnotation(method, HookMethod.class)) {
validateHookMethod(method);
return true;
}
for (ExecutableElement hookMethodsFromInterface : hookMethodsFromInterfaces) {
if (elements.overrides(method, hookMethodsFromInterface, component)) {
return true;
}
}
return false;
} | java | private boolean isHookMethod(TypeElement component, ExecutableElement method,
Set<ExecutableElement> hookMethodsFromInterfaces) {
if (hasAnnotation(method, HookMethod.class)) {
validateHookMethod(method);
return true;
}
for (ExecutableElement hookMethodsFromInterface : hookMethodsFromInterfaces) {
if (elements.overrides(method, hookMethodsFromInterface, component)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"isHookMethod",
"(",
"TypeElement",
"component",
",",
"ExecutableElement",
"method",
",",
"Set",
"<",
"ExecutableElement",
">",
"hookMethodsFromInterfaces",
")",
"{",
"if",
"(",
"hasAnnotation",
"(",
"method",
",",
"HookMethod",
".",
"class",
... | Return true of the given method is a proxy method
@param component {@link IsVueComponent} this method belongs to
@param method The java method to check
@param hookMethodsFromInterfaces All the hook methods in the implement interfaces
@return True if this method is a hook method, false otherwise | [
"Return",
"true",
"of",
"the",
"given",
"method",
"is",
"a",
"proxy",
"method"
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java#L892-L906 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java | ComponentExposedTypeGenerator.getNativeNameForJavaType | private String getNativeNameForJavaType(TypeMirror typeMirror) {
TypeName typeName = TypeName.get(typeMirror);
if (typeName.equals(TypeName.INT)
|| typeName.equals(TypeName.BYTE)
|| typeName.equals(TypeName.SHORT)
|| typeName.equals(TypeName.LONG)
|| typeName.equals(TypeName.FLOAT)
|| typeName.equals(TypeName.DOUBLE)) {
return "Number";
} else if (typeName.equals(TypeName.BOOLEAN)) {
return "Boolean";
} else if (typeName.equals(TypeName.get(String.class)) || typeName.equals(TypeName.CHAR)) {
return "String";
} else if (typeMirror.toString().startsWith(JsArray.class.getCanonicalName())) {
return "Array";
} else {
return "Object";
}
} | java | private String getNativeNameForJavaType(TypeMirror typeMirror) {
TypeName typeName = TypeName.get(typeMirror);
if (typeName.equals(TypeName.INT)
|| typeName.equals(TypeName.BYTE)
|| typeName.equals(TypeName.SHORT)
|| typeName.equals(TypeName.LONG)
|| typeName.equals(TypeName.FLOAT)
|| typeName.equals(TypeName.DOUBLE)) {
return "Number";
} else if (typeName.equals(TypeName.BOOLEAN)) {
return "Boolean";
} else if (typeName.equals(TypeName.get(String.class)) || typeName.equals(TypeName.CHAR)) {
return "String";
} else if (typeMirror.toString().startsWith(JsArray.class.getCanonicalName())) {
return "Array";
} else {
return "Object";
}
} | [
"private",
"String",
"getNativeNameForJavaType",
"(",
"TypeMirror",
"typeMirror",
")",
"{",
"TypeName",
"typeName",
"=",
"TypeName",
".",
"get",
"(",
"typeMirror",
")",
";",
"if",
"(",
"typeName",
".",
"equals",
"(",
"TypeName",
".",
"INT",
")",
"||",
"typeN... | Transform a Java type name into a JavaScript type name. Takes care of primitive types.
@param typeMirror A type to convert
@return A String representing the JavaScript type name | [
"Transform",
"a",
"Java",
"type",
"name",
"into",
"a",
"JavaScript",
"type",
"name",
".",
"Takes",
"care",
"of",
"primitive",
"types",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentExposedTypeGenerator.java#L922-L941 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java | ComponentInjectedDependenciesBuilder.processInjectedFields | private void processInjectedFields(TypeElement component) {
getInjectedFields(component).stream().peek(this::validateField).forEach(field -> {
String fieldName = field.getSimpleName().toString();
addInjectedVariable(field, fieldName);
injectedFieldsName.add(fieldName);
});
} | java | private void processInjectedFields(TypeElement component) {
getInjectedFields(component).stream().peek(this::validateField).forEach(field -> {
String fieldName = field.getSimpleName().toString();
addInjectedVariable(field, fieldName);
injectedFieldsName.add(fieldName);
});
} | [
"private",
"void",
"processInjectedFields",
"(",
"TypeElement",
"component",
")",
"{",
"getInjectedFields",
"(",
"component",
")",
".",
"stream",
"(",
")",
".",
"peek",
"(",
"this",
"::",
"validateField",
")",
".",
"forEach",
"(",
"field",
"->",
"{",
"String... | Process all the injected fields from our Component.
@param component The {@link IsVueComponent} we are processing | [
"Process",
"all",
"the",
"injected",
"fields",
"from",
"our",
"Component",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java#L88-L94 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java | ComponentInjectedDependenciesBuilder.processInjectedMethods | private void processInjectedMethods(TypeElement component) {
getInjectedMethods(component)
.stream()
.peek(this::validateMethod)
.forEach(this::processInjectedMethod);
} | java | private void processInjectedMethods(TypeElement component) {
getInjectedMethods(component)
.stream()
.peek(this::validateMethod)
.forEach(this::processInjectedMethod);
} | [
"private",
"void",
"processInjectedMethods",
"(",
"TypeElement",
"component",
")",
"{",
"getInjectedMethods",
"(",
"component",
")",
".",
"stream",
"(",
")",
".",
"peek",
"(",
"this",
"::",
"validateMethod",
")",
".",
"forEach",
"(",
"this",
"::",
"processInje... | Process all the injected methods from our Component.
@param component The {@link IsVueComponent} we are processing | [
"Process",
"all",
"the",
"injected",
"methods",
"from",
"our",
"Component",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java#L101-L106 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java | ComponentInjectedDependenciesBuilder.addInjectedVariable | private void addInjectedVariable(VariableElement element, String fieldName) {
TypeName typeName = resolveVariableTypeName(element, messager);
// Create field
FieldSpec.Builder fieldBuilder = FieldSpec.builder(typeName, fieldName, Modifier.PUBLIC);
// Copy field annotations
element
.getAnnotationMirrors()
.stream()
.map(AnnotationSpec::get)
.forEach(fieldBuilder::addAnnotation);
// If the variable element is a method parameter, it might not have the Inject annotation
if (!hasInjectAnnotation(element)) {
fieldBuilder.addAnnotation(Inject.class);
}
// And add field
builder.addField(fieldBuilder.build());
} | java | private void addInjectedVariable(VariableElement element, String fieldName) {
TypeName typeName = resolveVariableTypeName(element, messager);
// Create field
FieldSpec.Builder fieldBuilder = FieldSpec.builder(typeName, fieldName, Modifier.PUBLIC);
// Copy field annotations
element
.getAnnotationMirrors()
.stream()
.map(AnnotationSpec::get)
.forEach(fieldBuilder::addAnnotation);
// If the variable element is a method parameter, it might not have the Inject annotation
if (!hasInjectAnnotation(element)) {
fieldBuilder.addAnnotation(Inject.class);
}
// And add field
builder.addField(fieldBuilder.build());
} | [
"private",
"void",
"addInjectedVariable",
"(",
"VariableElement",
"element",
",",
"String",
"fieldName",
")",
"{",
"TypeName",
"typeName",
"=",
"resolveVariableTypeName",
"(",
"element",
",",
"messager",
")",
";",
"// Create field",
"FieldSpec",
".",
"Builder",
"fie... | Add an injected variable to our component
@param element The {@link VariableElement} that was injected
@param fieldName The name of the field | [
"Add",
"an",
"injected",
"variable",
"to",
"our",
"component"
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/ComponentInjectedDependenciesBuilder.java#L176-L196 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.addLocalVariable | public LocalVariableInfo addLocalVariable(String typeQualifiedName, String name) {
return contextLayers.getFirst().addLocalVariable(typeQualifiedName, name);
} | java | public LocalVariableInfo addLocalVariable(String typeQualifiedName, String name) {
return contextLayers.getFirst().addLocalVariable(typeQualifiedName, name);
} | [
"public",
"LocalVariableInfo",
"addLocalVariable",
"(",
"String",
"typeQualifiedName",
",",
"String",
"name",
")",
"{",
"return",
"contextLayers",
".",
"getFirst",
"(",
")",
".",
"addLocalVariable",
"(",
"typeQualifiedName",
",",
"name",
")",
";",
"}"
] | Add a local variable in the current context.
@param typeQualifiedName The type of the variable
@param name The name of the variable
@return {@link LocalVariableInfo} for the added variable | [
"Add",
"a",
"local",
"variable",
"in",
"the",
"current",
"context",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L117-L119 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.addDestructuredProperty | public DestructuredPropertyInfo addDestructuredProperty(String propertyType,
String propertyName,
LocalVariableInfo destructuredVariable) {
return contextLayers.getFirst()
.addDestructuredProperty(propertyType, propertyName, destructuredVariable);
} | java | public DestructuredPropertyInfo addDestructuredProperty(String propertyType,
String propertyName,
LocalVariableInfo destructuredVariable) {
return contextLayers.getFirst()
.addDestructuredProperty(propertyType, propertyName, destructuredVariable);
} | [
"public",
"DestructuredPropertyInfo",
"addDestructuredProperty",
"(",
"String",
"propertyType",
",",
"String",
"propertyName",
",",
"LocalVariableInfo",
"destructuredVariable",
")",
"{",
"return",
"contextLayers",
".",
"getFirst",
"(",
")",
".",
"addDestructuredProperty",
... | Add a local variable coming from a Variable destructuring to the current context.
@param propertyType The type of the property on the destructured variable
@param propertyName The name of the property on the destructured variable
@param destructuredVariable The local variable that is getting destructured
@return {@link DestructuredPropertyInfo} for the added variable | [
"Add",
"a",
"local",
"variable",
"coming",
"from",
"a",
"Variable",
"destructuring",
"to",
"the",
"current",
"context",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L129-L134 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.findVariable | public VariableInfo findVariable(String name) {
for (ContextLayer contextLayer : contextLayers) {
VariableInfo variableInfo = contextLayer.getVariableInfo(name);
if (variableInfo != null) {
return variableInfo;
}
}
return null;
} | java | public VariableInfo findVariable(String name) {
for (ContextLayer contextLayer : contextLayers) {
VariableInfo variableInfo = contextLayer.getVariableInfo(name);
if (variableInfo != null) {
return variableInfo;
}
}
return null;
} | [
"public",
"VariableInfo",
"findVariable",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"ContextLayer",
"contextLayer",
":",
"contextLayers",
")",
"{",
"VariableInfo",
"variableInfo",
"=",
"contextLayer",
".",
"getVariableInfo",
"(",
"name",
")",
";",
"if",
"(",
... | Find a variable in the context stack.
@param name Name of the variable to get
@return Information about the variable | [
"Find",
"a",
"variable",
"in",
"the",
"context",
"stack",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L152-L161 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.addImport | public void addImport(String fullyQualifiedName) {
String[] importSplit = fullyQualifiedName.split("\\.");
String className = importSplit[importSplit.length - 1];
classNameToFullyQualifiedName.put(className, fullyQualifiedName);
} | java | public void addImport(String fullyQualifiedName) {
String[] importSplit = fullyQualifiedName.split("\\.");
String className = importSplit[importSplit.length - 1];
classNameToFullyQualifiedName.put(className, fullyQualifiedName);
} | [
"public",
"void",
"addImport",
"(",
"String",
"fullyQualifiedName",
")",
"{",
"String",
"[",
"]",
"importSplit",
"=",
"fullyQualifiedName",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"String",
"className",
"=",
"importSplit",
"[",
"importSplit",
".",
"length",
... | Add a Java Import to the context.
@param fullyQualifiedName The fully qualified name of the class to import | [
"Add",
"a",
"Java",
"Import",
"to",
"the",
"context",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L193-L198 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.getFullyQualifiedNameForClassName | public String getFullyQualifiedNameForClassName(String className) {
if (!classNameToFullyQualifiedName.containsKey(className)) {
return className;
}
return classNameToFullyQualifiedName.get(className);
} | java | public String getFullyQualifiedNameForClassName(String className) {
if (!classNameToFullyQualifiedName.containsKey(className)) {
return className;
}
return classNameToFullyQualifiedName.get(className);
} | [
"public",
"String",
"getFullyQualifiedNameForClassName",
"(",
"String",
"className",
")",
"{",
"if",
"(",
"!",
"classNameToFullyQualifiedName",
".",
"containsKey",
"(",
"className",
")",
")",
"{",
"return",
"className",
";",
"}",
"return",
"classNameToFullyQualifiedNa... | Return the fully qualified name for a given class. Only works if the class has been imported.
@param className The name of the class to get the fully qualified name of
@return The fully qualified name, or the className if it's unknown | [
"Return",
"the",
"fully",
"qualified",
"name",
"for",
"a",
"given",
"class",
".",
"Only",
"works",
"if",
"the",
"class",
"has",
"been",
"imported",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L206-L212 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.addStaticImport | public void addStaticImport(String fullyQualifiedName) {
String[] importSplit = fullyQualifiedName.split("\\.");
String symbolName = importSplit[importSplit.length - 1];
methodNameToFullyQualifiedName.put(symbolName, fullyQualifiedName);
propertyNameToFullyQualifiedName.put(symbolName, fullyQualifiedName);
} | java | public void addStaticImport(String fullyQualifiedName) {
String[] importSplit = fullyQualifiedName.split("\\.");
String symbolName = importSplit[importSplit.length - 1];
methodNameToFullyQualifiedName.put(symbolName, fullyQualifiedName);
propertyNameToFullyQualifiedName.put(symbolName, fullyQualifiedName);
} | [
"public",
"void",
"addStaticImport",
"(",
"String",
"fullyQualifiedName",
")",
"{",
"String",
"[",
"]",
"importSplit",
"=",
"fullyQualifiedName",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"String",
"symbolName",
"=",
"importSplit",
"[",
"importSplit",
".",
"leng... | Add a Java Static Import to the context.
@param fullyQualifiedName The fully qualified name of the method to import | [
"Add",
"a",
"Java",
"Static",
"Import",
"to",
"the",
"context",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L229-L235 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.getFullyQualifiedNameForMethodName | public String getFullyQualifiedNameForMethodName(String methodName) {
if (!methodNameToFullyQualifiedName.containsKey(methodName)) {
return methodName;
}
return methodNameToFullyQualifiedName.get(methodName);
} | java | public String getFullyQualifiedNameForMethodName(String methodName) {
if (!methodNameToFullyQualifiedName.containsKey(methodName)) {
return methodName;
}
return methodNameToFullyQualifiedName.get(methodName);
} | [
"public",
"String",
"getFullyQualifiedNameForMethodName",
"(",
"String",
"methodName",
")",
"{",
"if",
"(",
"!",
"methodNameToFullyQualifiedName",
".",
"containsKey",
"(",
"methodName",
")",
")",
"{",
"return",
"methodName",
";",
"}",
"return",
"methodNameToFullyQuali... | Return the fully qualified name for a given method. Only works if the method has been
statically imported.
@param methodName The name of the method to get the fully qualified name of
@return The fully qualified name, or the method name if it's unknown | [
"Return",
"the",
"fully",
"qualified",
"name",
"for",
"a",
"given",
"method",
".",
"Only",
"works",
"if",
"the",
"method",
"has",
"been",
"statically",
"imported",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L244-L250 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.getFullyQualifiedNameForPropertyName | public String getFullyQualifiedNameForPropertyName(String propertyName) {
if (!propertyNameToFullyQualifiedName.containsKey(propertyName)) {
return propertyName;
}
return propertyNameToFullyQualifiedName.get(propertyName);
} | java | public String getFullyQualifiedNameForPropertyName(String propertyName) {
if (!propertyNameToFullyQualifiedName.containsKey(propertyName)) {
return propertyName;
}
return propertyNameToFullyQualifiedName.get(propertyName);
} | [
"public",
"String",
"getFullyQualifiedNameForPropertyName",
"(",
"String",
"propertyName",
")",
"{",
"if",
"(",
"!",
"propertyNameToFullyQualifiedName",
".",
"containsKey",
"(",
"propertyName",
")",
")",
"{",
"return",
"propertyName",
";",
"}",
"return",
"propertyName... | Return the fully qualified name for a given property. Only works if the property has been
statically imported.
@param propertyName The name of the property to get the fully qualified name of
@return The fully qualified name, or the property name if it's unknown | [
"Return",
"the",
"fully",
"qualified",
"name",
"for",
"a",
"given",
"property",
".",
"Only",
"works",
"if",
"the",
"property",
"has",
"been",
"statically",
"imported",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L259-L265 | train |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java | TemplateParserContext.getCurrentLine | public Optional<Integer> getCurrentLine() {
if (currentSegment == null) {
return Optional.empty();
}
return Optional.of(currentSegment.getSource().getRow(currentSegment.getBegin()));
} | java | public Optional<Integer> getCurrentLine() {
if (currentSegment == null) {
return Optional.empty();
}
return Optional.of(currentSegment.getSource().getRow(currentSegment.getBegin()));
} | [
"public",
"Optional",
"<",
"Integer",
">",
"getCurrentLine",
"(",
")",
"{",
"if",
"(",
"currentSegment",
"==",
"null",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"return",
"Optional",
".",
"of",
"(",
"currentSegment",
".",
"getSour... | Return the number of the line currently processed in the HTML
@return The number of the current line being processed or empty | [
"Return",
"the",
"number",
"of",
"the",
"line",
"currently",
"processed",
"in",
"the",
"HTML"
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/context/TemplateParserContext.java#L307-L313 | train |
VueGWT/vue-gwt | core/src/main/java/com/axellience/vuegwt/core/client/VueGWT.java | VueGWT.initWithoutVueLib | @JsIgnore
public static void initWithoutVueLib() {
if (!isVueLibInjected()) {
throw new RuntimeException(
"Couldn't find Vue.js on init. Either include it Vue.js in your index.html or call VueGWT.init() instead of initWithoutVueLib.");
}
// Register custom observers for Collection and Maps
VueGWTObserverManager.get().registerVueGWTObserver(new CollectionObserver());
VueGWTObserverManager.get().registerVueGWTObserver(new MapObserver());
isReady = true;
// Call on ready callbacks
for (Runnable onReadyCbk : onReadyCallbacks) {
onReadyCbk.run();
}
onReadyCallbacks.clear();
} | java | @JsIgnore
public static void initWithoutVueLib() {
if (!isVueLibInjected()) {
throw new RuntimeException(
"Couldn't find Vue.js on init. Either include it Vue.js in your index.html or call VueGWT.init() instead of initWithoutVueLib.");
}
// Register custom observers for Collection and Maps
VueGWTObserverManager.get().registerVueGWTObserver(new CollectionObserver());
VueGWTObserverManager.get().registerVueGWTObserver(new MapObserver());
isReady = true;
// Call on ready callbacks
for (Runnable onReadyCbk : onReadyCallbacks) {
onReadyCbk.run();
}
onReadyCallbacks.clear();
} | [
"@",
"JsIgnore",
"public",
"static",
"void",
"initWithoutVueLib",
"(",
")",
"{",
"if",
"(",
"!",
"isVueLibInjected",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't find Vue.js on init. Either include it Vue.js in your index.html or call VueGWT.init... | Inject scripts necessary for Vue GWT to work Requires Vue to be defined in Window. | [
"Inject",
"scripts",
"necessary",
"for",
"Vue",
"GWT",
"to",
"work",
"Requires",
"Vue",
"to",
"be",
"defined",
"in",
"Window",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/core/src/main/java/com/axellience/vuegwt/core/client/VueGWT.java#L45-L63 | train |
VueGWT/vue-gwt | core/src/main/java/com/axellience/vuegwt/core/client/VueGWT.java | VueGWT.onReady | @JsIgnore
public static void onReady(Runnable callback) {
if (isReady) {
callback.run();
return;
}
onReadyCallbacks.push(callback);
} | java | @JsIgnore
public static void onReady(Runnable callback) {
if (isReady) {
callback.run();
return;
}
onReadyCallbacks.push(callback);
} | [
"@",
"JsIgnore",
"public",
"static",
"void",
"onReady",
"(",
"Runnable",
"callback",
")",
"{",
"if",
"(",
"isReady",
")",
"{",
"callback",
".",
"run",
"(",
")",
";",
"return",
";",
"}",
"onReadyCallbacks",
".",
"push",
"(",
"callback",
")",
";",
"}"
] | Ask to be warned when Vue GWT is ready. If Vue GWT is ready, the callback is called
immediately.
@param callback The callback to call when Vue GWT is ready. | [
"Ask",
"to",
"be",
"warned",
"when",
"Vue",
"GWT",
"is",
"ready",
".",
"If",
"Vue",
"GWT",
"is",
"ready",
"the",
"callback",
"is",
"called",
"immediately",
"."
] | 961cd83aed6fe8e2dd80c279847f1b3f62918a1f | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/core/src/main/java/com/axellience/vuegwt/core/client/VueGWT.java#L71-L79 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/rich/RichTextFactory.java | RichTextFactory.resolveRichTextField | public static void resolveRichTextField(ArrayResource array, CDAClient client) {
for (CDAEntry entry : array.entries().values()) {
ensureContentType(entry, client);
for (CDAField field : entry.contentType().fields()) {
if ("RichText".equals(field.type())) {
resolveRichDocument(entry, field);
resolveRichLink(array, entry, field);
}
}
}
} | java | public static void resolveRichTextField(ArrayResource array, CDAClient client) {
for (CDAEntry entry : array.entries().values()) {
ensureContentType(entry, client);
for (CDAField field : entry.contentType().fields()) {
if ("RichText".equals(field.type())) {
resolveRichDocument(entry, field);
resolveRichLink(array, entry, field);
}
}
}
} | [
"public",
"static",
"void",
"resolveRichTextField",
"(",
"ArrayResource",
"array",
",",
"CDAClient",
"client",
")",
"{",
"for",
"(",
"CDAEntry",
"entry",
":",
"array",
".",
"entries",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"ensureContentType",
"(",
"... | Walk through the given array and resolve all rich text fields.
@param array the array to be walked.
@param client the client to be used if updating of types is needed. | [
"Walk",
"through",
"the",
"given",
"array",
"and",
"resolve",
"all",
"rich",
"text",
"fields",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/rich/RichTextFactory.java#L267-L277 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/rich/RichTextFactory.java | RichTextFactory.resolveRichDocument | private static void resolveRichDocument(CDAEntry entry, CDAField field) {
final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id());
if (rawValue == null) {
return;
}
for (final String locale : rawValue.keySet()) {
final Object raw = rawValue.get(locale);
if (raw == null || raw instanceof CDARichNode) {
// ignore null and already parsed values
continue;
}
final Map<String, Object> map = (Map<String, Object>) rawValue.get(locale);
entry.setField(locale, field.id(), RESOLVER_MAP.get("document").resolve(map));
}
} | java | private static void resolveRichDocument(CDAEntry entry, CDAField field) {
final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id());
if (rawValue == null) {
return;
}
for (final String locale : rawValue.keySet()) {
final Object raw = rawValue.get(locale);
if (raw == null || raw instanceof CDARichNode) {
// ignore null and already parsed values
continue;
}
final Map<String, Object> map = (Map<String, Object>) rawValue.get(locale);
entry.setField(locale, field.id(), RESOLVER_MAP.get("document").resolve(map));
}
} | [
"private",
"static",
"void",
"resolveRichDocument",
"(",
"CDAEntry",
"entry",
",",
"CDAField",
"field",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"rawValue",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"entry",
".",
"rawFi... | Resolve all children of the top most document block.
@param entry the entry to contain the field to be walked
@param field the id of the field to be walked. | [
"Resolve",
"all",
"children",
"of",
"the",
"top",
"most",
"document",
"block",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/rich/RichTextFactory.java#L285-L301 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/rich/RichTextFactory.java | RichTextFactory.resolveRichLink | private static void resolveRichLink(ArrayResource array, CDAEntry entry, CDAField field) {
final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id());
if (rawValue == null) {
return;
}
for (final String locale : rawValue.keySet()) {
final CDARichDocument document = entry.getField(locale, field.id());
for (final CDARichNode node : document.getContent()) {
resolveOneLink(array, field, locale, node);
}
}
} | java | private static void resolveRichLink(ArrayResource array, CDAEntry entry, CDAField field) {
final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id());
if (rawValue == null) {
return;
}
for (final String locale : rawValue.keySet()) {
final CDARichDocument document = entry.getField(locale, field.id());
for (final CDARichNode node : document.getContent()) {
resolveOneLink(array, field, locale, node);
}
}
} | [
"private",
"static",
"void",
"resolveRichLink",
"(",
"ArrayResource",
"array",
",",
"CDAEntry",
"entry",
",",
"CDAField",
"field",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"rawValue",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
... | Resolve all links if possible. If linked to entry is not found, null it's field.
@param array the array containing the complete response
@param entry the entry to be completed.
@param field the field pointing to a link. | [
"Resolve",
"all",
"links",
"if",
"possible",
".",
"If",
"linked",
"to",
"entry",
"is",
"not",
"found",
"null",
"it",
"s",
"field",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/rich/RichTextFactory.java#L350-L362 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/rich/RichTextFactory.java | RichTextFactory.resolveOneLink | private static void resolveOneLink(ArrayResource array, CDAField field, String locale,
CDARichNode node) {
if (node instanceof CDARichHyperLink
&& ((CDARichHyperLink) node).data instanceof Map) {
final CDARichHyperLink link = (CDARichHyperLink) node;
final Map<String, Object> data = (Map<String, Object>) link.data;
final Object target = data.get("target");
if (target instanceof Map) {
if (isLink(target)) {
final Map<String, Object> map = (Map<String, Object>) target;
final Map<String, Object> sys = (Map<String, Object>) map.get("sys");
final String linkType = (String) sys.get("linkType");
final String id = (String) sys.get("id");
if ("Asset".equals(linkType)) {
link.data = array.assets().get(id);
} else if ("Entry".equals(linkType)) {
link.data = array.entries().get(id);
}
} else {
throw new IllegalStateException("Could not parse content of data field '"
+ field.id() + "' for locale '" + locale + "' at node '" + node
+ "'. Please check your content type model.");
}
} else if (target == null && data.containsKey("uri")) {
link.data = data.get("uri");
}
} else if (node instanceof CDARichParagraph) {
for (final CDARichNode child : ((CDARichParagraph) node).getContent()) {
resolveOneLink(array, field, locale, child);
}
}
} | java | private static void resolveOneLink(ArrayResource array, CDAField field, String locale,
CDARichNode node) {
if (node instanceof CDARichHyperLink
&& ((CDARichHyperLink) node).data instanceof Map) {
final CDARichHyperLink link = (CDARichHyperLink) node;
final Map<String, Object> data = (Map<String, Object>) link.data;
final Object target = data.get("target");
if (target instanceof Map) {
if (isLink(target)) {
final Map<String, Object> map = (Map<String, Object>) target;
final Map<String, Object> sys = (Map<String, Object>) map.get("sys");
final String linkType = (String) sys.get("linkType");
final String id = (String) sys.get("id");
if ("Asset".equals(linkType)) {
link.data = array.assets().get(id);
} else if ("Entry".equals(linkType)) {
link.data = array.entries().get(id);
}
} else {
throw new IllegalStateException("Could not parse content of data field '"
+ field.id() + "' for locale '" + locale + "' at node '" + node
+ "'. Please check your content type model.");
}
} else if (target == null && data.containsKey("uri")) {
link.data = data.get("uri");
}
} else if (node instanceof CDARichParagraph) {
for (final CDARichNode child : ((CDARichParagraph) node).getContent()) {
resolveOneLink(array, field, locale, child);
}
}
} | [
"private",
"static",
"void",
"resolveOneLink",
"(",
"ArrayResource",
"array",
",",
"CDAField",
"field",
",",
"String",
"locale",
",",
"CDARichNode",
"node",
")",
"{",
"if",
"(",
"node",
"instanceof",
"CDARichHyperLink",
"&&",
"(",
"(",
"CDARichHyperLink",
")",
... | Link found, resolve it.
@param array the complete response from Contentful.
@param field the field containing a link.
@param locale the locale of the link to be updated.
@param node the node build from the response. | [
"Link",
"found",
"resolve",
"it",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/rich/RichTextFactory.java#L372-L406 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/rich/RichTextFactory.java | RichTextFactory.isLink | private static boolean isLink(Object data) {
try {
final Map<String, Object> map = (Map<String, Object>) data;
final Map<String, Object> sys = (Map<String, Object>) map.get("sys");
final String type = (String) sys.get("type");
final String linkType = (String) sys.get("linkType");
final String id = (String) sys.get("id");
if ("Link".equals(type)
&& ("Entry".equals(linkType) || "Asset".equals(linkType)
&& id != null)) {
return true;
}
} catch (ClassCastException cast) {
return false;
}
return false;
} | java | private static boolean isLink(Object data) {
try {
final Map<String, Object> map = (Map<String, Object>) data;
final Map<String, Object> sys = (Map<String, Object>) map.get("sys");
final String type = (String) sys.get("type");
final String linkType = (String) sys.get("linkType");
final String id = (String) sys.get("id");
if ("Link".equals(type)
&& ("Entry".equals(linkType) || "Asset".equals(linkType)
&& id != null)) {
return true;
}
} catch (ClassCastException cast) {
return false;
}
return false;
} | [
"private",
"static",
"boolean",
"isLink",
"(",
"Object",
"data",
")",
"{",
"try",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"data",
";",
"final",
"Map",
"<",
"String",
",... | Is the give object a link of any kind? | [
"Is",
"the",
"give",
"object",
"a",
"link",
"of",
"any",
"kind?"
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/rich/RichTextFactory.java#L411-L428 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/LocalizedResource.java | LocalizedResource.getField | public <T> T getField(String locale, String key) {
return localize(locale).getField(key);
} | java | public <T> T getField(String locale, String key) {
return localize(locale).getField(key);
} | [
"public",
"<",
"T",
">",
"T",
"getField",
"(",
"String",
"locale",
",",
"String",
"key",
")",
"{",
"return",
"localize",
"(",
"locale",
")",
".",
"getField",
"(",
"key",
")",
";",
"}"
] | Extracts a field from the fields set of the active locale, result type is inferred.
@param locale locale to be used.
@param key field key.
@param <T> type.
@return field value, null if it doesn't exist. | [
"Extracts",
"a",
"field",
"from",
"the",
"fields",
"set",
"of",
"the",
"active",
"locale",
"result",
"type",
"is",
"inferred",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/LocalizedResource.java#L87-L89 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/TransformQuery.java | TransformQuery.one | public Flowable<Transformed> one(String id) {
try {
return baseQuery()
.one(id)
.filter(new Predicate<CDAEntry>() {
@Override
public boolean test(CDAEntry entry) {
return entry.contentType().id()
.equals(contentTypeId);
}
})
.map(new Function<CDAEntry, Transformed>() {
@Override
public Transformed apply(CDAEntry entry) throws Exception {
return TransformQuery.this.transform(entry);
}
});
} catch (NullPointerException e) {
throw new CDAResourceNotFoundException(CDAEntry.class, id);
}
} | java | public Flowable<Transformed> one(String id) {
try {
return baseQuery()
.one(id)
.filter(new Predicate<CDAEntry>() {
@Override
public boolean test(CDAEntry entry) {
return entry.contentType().id()
.equals(contentTypeId);
}
})
.map(new Function<CDAEntry, Transformed>() {
@Override
public Transformed apply(CDAEntry entry) throws Exception {
return TransformQuery.this.transform(entry);
}
});
} catch (NullPointerException e) {
throw new CDAResourceNotFoundException(CDAEntry.class, id);
}
} | [
"public",
"Flowable",
"<",
"Transformed",
">",
"one",
"(",
"String",
"id",
")",
"{",
"try",
"{",
"return",
"baseQuery",
"(",
")",
".",
"one",
"(",
"id",
")",
".",
"filter",
"(",
"new",
"Predicate",
"<",
"CDAEntry",
">",
"(",
")",
"{",
"@",
"Overrid... | Retrieve the transformed entry from Contentful.
@param id the id of the entry of type Transformed.
@return the Transformed entry.
@throws CDAResourceNotFoundException if no such resource was found.
@throws IllegalStateException if the transformed class could not be created.
@throws IllegalStateException if the transformed class could not be accessed. | [
"Retrieve",
"the",
"transformed",
"entry",
"from",
"Contentful",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/TransformQuery.java#L148-L168 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/TransformQuery.java | TransformQuery.one | public CDACallback<Transformed> one(String id, CDACallback<Transformed> callback) {
return Callbacks.subscribeAsync(
baseQuery()
.one(id)
.filter(new Predicate<CDAEntry>() {
@Override
public boolean test(CDAEntry entry) {
return entry.contentType().id().equals(contentTypeId);
}
})
.map(this::transform),
callback,
client);
} | java | public CDACallback<Transformed> one(String id, CDACallback<Transformed> callback) {
return Callbacks.subscribeAsync(
baseQuery()
.one(id)
.filter(new Predicate<CDAEntry>() {
@Override
public boolean test(CDAEntry entry) {
return entry.contentType().id().equals(contentTypeId);
}
})
.map(this::transform),
callback,
client);
} | [
"public",
"CDACallback",
"<",
"Transformed",
">",
"one",
"(",
"String",
"id",
",",
"CDACallback",
"<",
"Transformed",
">",
"callback",
")",
"{",
"return",
"Callbacks",
".",
"subscribeAsync",
"(",
"baseQuery",
"(",
")",
".",
"one",
"(",
"id",
")",
".",
"f... | Retrieve the transformed entry from Contentful by using the given callback.
@param id the id of the entry of type transformed.
@return the input callback for chaining.
@throws CDAResourceNotFoundException if no such resource was found.
@throws IllegalStateException if the transformed class could not be created.
@throws IllegalStateException if the transformed class could not be accessed. | [
"Retrieve",
"the",
"transformed",
"entry",
"from",
"Contentful",
"by",
"using",
"the",
"given",
"callback",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/TransformQuery.java#L179-L192 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/TransformQuery.java | TransformQuery.all | public Flowable<Collection<Transformed>> all() {
return baseQuery()
.all()
.map(
new Function<CDAArray, Collection<Transformed>>() {
@Override
public Collection<Transformed> apply(CDAArray array) {
final ArrayList<Transformed> result = new ArrayList<>(array.total());
for (final CDAResource resource : array.items) {
if (resource instanceof CDAEntry
&& ((CDAEntry) resource).contentType().id().equals(contentTypeId)) {
result.add(TransformQuery.this.transform((CDAEntry) resource));
}
}
return result;
}
}
);
} | java | public Flowable<Collection<Transformed>> all() {
return baseQuery()
.all()
.map(
new Function<CDAArray, Collection<Transformed>>() {
@Override
public Collection<Transformed> apply(CDAArray array) {
final ArrayList<Transformed> result = new ArrayList<>(array.total());
for (final CDAResource resource : array.items) {
if (resource instanceof CDAEntry
&& ((CDAEntry) resource).contentType().id().equals(contentTypeId)) {
result.add(TransformQuery.this.transform((CDAEntry) resource));
}
}
return result;
}
}
);
} | [
"public",
"Flowable",
"<",
"Collection",
"<",
"Transformed",
">",
">",
"all",
"(",
")",
"{",
"return",
"baseQuery",
"(",
")",
".",
"all",
"(",
")",
".",
"map",
"(",
"new",
"Function",
"<",
"CDAArray",
",",
"Collection",
"<",
"Transformed",
">",
">",
... | Retrieve all transformed entries from Contentful.
@return a collection of transformed entry.
@throws CDAResourceNotFoundException if no such resource was found.
@throws IllegalStateException if the transformed class could not be created.
@throws IllegalStateException if the transformed class could not be accessed. | [
"Retrieve",
"all",
"transformed",
"entries",
"from",
"Contentful",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/TransformQuery.java#L202-L221 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/TransformQuery.java | TransformQuery.all | public CDACallback<Collection<Transformed>> all(CDACallback<Collection<Transformed>> callback) {
return Callbacks.subscribeAsync(
baseQuery()
.all()
.map(
new Function<CDAArray, List<Transformed>>() {
@Override
public List<Transformed> apply(CDAArray array) {
final ArrayList<Transformed> result = new ArrayList<>(array.total());
for (final CDAResource resource : array.items) {
if (resource instanceof CDAEntry
&& ((CDAEntry) resource).contentType().id().equals(contentTypeId)) {
result.add(TransformQuery.this.transform((CDAEntry) resource));
}
}
return result;
}
}
),
callback,
client);
} | java | public CDACallback<Collection<Transformed>> all(CDACallback<Collection<Transformed>> callback) {
return Callbacks.subscribeAsync(
baseQuery()
.all()
.map(
new Function<CDAArray, List<Transformed>>() {
@Override
public List<Transformed> apply(CDAArray array) {
final ArrayList<Transformed> result = new ArrayList<>(array.total());
for (final CDAResource resource : array.items) {
if (resource instanceof CDAEntry
&& ((CDAEntry) resource).contentType().id().equals(contentTypeId)) {
result.add(TransformQuery.this.transform((CDAEntry) resource));
}
}
return result;
}
}
),
callback,
client);
} | [
"public",
"CDACallback",
"<",
"Collection",
"<",
"Transformed",
">",
">",
"all",
"(",
"CDACallback",
"<",
"Collection",
"<",
"Transformed",
">",
">",
"callback",
")",
"{",
"return",
"Callbacks",
".",
"subscribeAsync",
"(",
"baseQuery",
"(",
")",
".",
"all",
... | Retrieve all transformed entries from Contentful by the use of a callback.
@return a callback containing a collection of transformed entries.
@throws CDAResourceNotFoundException if no such resource was found.
@throws IllegalStateException if the transformed class could not be created.
@throws IllegalStateException if the transformed class could not be accessed. | [
"Retrieve",
"all",
"transformed",
"entries",
"from",
"Contentful",
"by",
"the",
"use",
"of",
"a",
"callback",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/TransformQuery.java#L231-L253 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/CDAResource.java | CDAResource.getAttribute | @SuppressWarnings("unchecked")
public <T> T getAttribute(String key) {
return (T) attrs.get(key);
} | java | @SuppressWarnings("unchecked")
public <T> T getAttribute(String key) {
return (T) attrs.get(key);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getAttribute",
"(",
"String",
"key",
")",
"{",
"return",
"(",
"T",
")",
"attrs",
".",
"get",
"(",
"key",
")",
";",
"}"
] | Retrieve a specific attribute of this resource.
@param key a string key associated with the value to be retrieved.
@param <T> the type of the attribute to be retrieved.
@return the actual value of the attribute, or null, if there the key was not found. | [
"Retrieve",
"a",
"specific",
"attribute",
"of",
"this",
"resource",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/CDAResource.java#L48-L51 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/ObserveQuery.java | ObserveQuery.all | public Flowable<CDAArray> all() {
return client.cacheAll(false)
.flatMap(
new Function<Cache, Publisher<Response<CDAArray>>>() {
@Override
public Publisher<Response<CDAArray>> apply(Cache cache) {
return client.service.array(client.spaceId, client.environmentId, path(), params);
}
}
).map(new Function<Response<CDAArray>, CDAArray>() {
@Override
public CDAArray apply(Response<CDAArray> response) {
return ResourceFactory.array(response, client);
}
});
} | java | public Flowable<CDAArray> all() {
return client.cacheAll(false)
.flatMap(
new Function<Cache, Publisher<Response<CDAArray>>>() {
@Override
public Publisher<Response<CDAArray>> apply(Cache cache) {
return client.service.array(client.spaceId, client.environmentId, path(), params);
}
}
).map(new Function<Response<CDAArray>, CDAArray>() {
@Override
public CDAArray apply(Response<CDAArray> response) {
return ResourceFactory.array(response, client);
}
});
} | [
"public",
"Flowable",
"<",
"CDAArray",
">",
"all",
"(",
")",
"{",
"return",
"client",
".",
"cacheAll",
"(",
"false",
")",
".",
"flatMap",
"(",
"new",
"Function",
"<",
"Cache",
",",
"Publisher",
"<",
"Response",
"<",
"CDAArray",
">",
">",
">",
"(",
")... | Observe an array of all resources matching the type of this query.
@return {@link Flowable} instance. | [
"Observe",
"an",
"array",
"of",
"all",
"resources",
"matching",
"the",
"type",
"of",
"this",
"query",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/ObserveQuery.java#L93-L108 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/image/ImageOption.java | ImageOption.jpegQualityOf | public static ImageOption jpegQualityOf(int quality) {
if (quality < 1 || quality > 100) {
throw new IllegalArgumentException("Quality has to be in the range from 1 to 100.");
}
return new ImageOption("q", Integer.toString(quality));
} | java | public static ImageOption jpegQualityOf(int quality) {
if (quality < 1 || quality > 100) {
throw new IllegalArgumentException("Quality has to be in the range from 1 to 100.");
}
return new ImageOption("q", Integer.toString(quality));
} | [
"public",
"static",
"ImageOption",
"jpegQualityOf",
"(",
"int",
"quality",
")",
"{",
"if",
"(",
"quality",
"<",
"1",
"||",
"quality",
">",
"100",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Quality has to be in the range from 1 to 100.\"",
")",
"... | Define the quality of the jpg image to be returned.
@param quality an positive integer between 1 and 100.
@return an image option for updating the url.
@throws IllegalArgumentException if quality is not between 1 and 100. | [
"Define",
"the",
"quality",
"of",
"the",
"jpg",
"image",
"to",
"be",
"returned",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/image/ImageOption.java#L161-L167 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/image/ImageOption.java | ImageOption.apply | public String apply(String url) {
return format(
getDefault(),
"%s%s%s=%s",
url,
concatenationOperator(url),
operation,
argument);
} | java | public String apply(String url) {
return format(
getDefault(),
"%s%s%s=%s",
url,
concatenationOperator(url),
operation,
argument);
} | [
"public",
"String",
"apply",
"(",
"String",
"url",
")",
"{",
"return",
"format",
"(",
"getDefault",
"(",
")",
",",
"\"%s%s%s=%s\"",
",",
"url",
",",
"concatenationOperator",
"(",
"url",
")",
",",
"operation",
",",
"argument",
")",
";",
"}"
] | Apply this image option to a url, replacing and updating this url.
@param url a url to be handled
@return the changed url. | [
"Apply",
"this",
"image",
"option",
"to",
"a",
"url",
"replacing",
"and",
"updating",
"this",
"url",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/image/ImageOption.java#L340-L348 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/CDAClient.java | CDAClient.fetchSpace | @SuppressWarnings("unchecked")
public <C extends CDACallback<CDASpace>> C fetchSpace(C callback) {
return (C) Callbacks.subscribeAsync(observeSpace(), callback, this);
} | java | @SuppressWarnings("unchecked")
public <C extends CDACallback<CDASpace>> C fetchSpace(C callback) {
return (C) Callbacks.subscribeAsync(observeSpace(), callback, this);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"C",
"extends",
"CDACallback",
"<",
"CDASpace",
">",
">",
"C",
"fetchSpace",
"(",
"C",
"callback",
")",
"{",
"return",
"(",
"C",
")",
"Callbacks",
".",
"subscribeAsync",
"(",
"observeSpace",
... | Asynchronously fetch the space.
@param <C> the type of the callback to be used.
@param callback the value of the callback to be called back.
@return the space for this client (asynchronously). | [
"Asynchronously",
"fetch",
"the",
"space",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/CDAClient.java#L373-L376 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/ResourceUtils.java | ResourceUtils.ensureContentType | public static void ensureContentType(CDAEntry entry, CDAClient client) {
CDAContentType contentType = entry.contentType();
if (contentType != null) {
return;
}
String contentTypeId = extractNested(entry.attrs(), "contentType", "sys", "id");
try {
contentType = client.cacheTypeWithId(contentTypeId).blockingFirst();
} catch (CDAResourceNotFoundException e) {
throw new CDAContentTypeNotFoundException(entry.id(), CDAEntry.class, contentTypeId, e);
}
entry.setContentType(contentType);
} | java | public static void ensureContentType(CDAEntry entry, CDAClient client) {
CDAContentType contentType = entry.contentType();
if (contentType != null) {
return;
}
String contentTypeId = extractNested(entry.attrs(), "contentType", "sys", "id");
try {
contentType = client.cacheTypeWithId(contentTypeId).blockingFirst();
} catch (CDAResourceNotFoundException e) {
throw new CDAContentTypeNotFoundException(entry.id(), CDAEntry.class, contentTypeId, e);
}
entry.setContentType(contentType);
} | [
"public",
"static",
"void",
"ensureContentType",
"(",
"CDAEntry",
"entry",
",",
"CDAClient",
"client",
")",
"{",
"CDAContentType",
"contentType",
"=",
"entry",
".",
"contentType",
"(",
")",
";",
"if",
"(",
"contentType",
"!=",
"null",
")",
"{",
"return",
";"... | Make sure that the given entry has a filled in content type.
@param entry entry to be filled
@param client to be used if more content types need to be requested. | [
"Make",
"sure",
"that",
"the",
"given",
"entry",
"has",
"a",
"filled",
"in",
"content",
"type",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/ResourceUtils.java#L83-L97 | train |
contentful/contentful.java | src/main/java/com/contentful/java/cda/FetchQuery.java | FetchQuery.all | @SuppressWarnings("unchecked")
public <C extends CDACallback<CDAArray>> C all(C callback) {
return (C) Callbacks.subscribeAsync(baseQuery().all(), callback, client);
} | java | @SuppressWarnings("unchecked")
public <C extends CDACallback<CDAArray>> C all(C callback) {
return (C) Callbacks.subscribeAsync(baseQuery().all(), callback, client);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"C",
"extends",
"CDACallback",
"<",
"CDAArray",
">",
">",
"C",
"all",
"(",
"C",
"callback",
")",
"{",
"return",
"(",
"C",
")",
"Callbacks",
".",
"subscribeAsync",
"(",
"baseQuery",
"(",
"... | Async fetch all resources matching the type of this query.
@param callback callback.
@param <C> callback type.
@return the given {@code callback} instance. | [
"Async",
"fetch",
"all",
"resources",
"matching",
"the",
"type",
"of",
"this",
"query",
"."
] | 6ecc2ace454c674b218b99489dc50697b1dbffcb | https://github.com/contentful/contentful.java/blob/6ecc2ace454c674b218b99489dc50697b1dbffcb/src/main/java/com/contentful/java/cda/FetchQuery.java#L61-L64 | train |
camunda/camunda-bpm-camel | camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/component/producer/CamundaBpmProducerFactory.java | CamundaBpmProducerFactory.createProducer | public static CamundaBpmProducer createProducer(final CamundaBpmEndpoint endpoint, final ParsedUri uri,
final Map<String, Object> parameters) throws IllegalArgumentException {
switch (uri.getType()) {
case StartProcess:
return new StartProcessProducer(endpoint, parameters);
case SendSignal:
case SendMessage:
return new MessageProducer(endpoint, parameters);
default:
throw new IllegalArgumentException("Cannot create a producer for URI '" + uri + "' - new ProducerType '"
+ uri.getType() + "' not yet supported?");
}
} | java | public static CamundaBpmProducer createProducer(final CamundaBpmEndpoint endpoint, final ParsedUri uri,
final Map<String, Object> parameters) throws IllegalArgumentException {
switch (uri.getType()) {
case StartProcess:
return new StartProcessProducer(endpoint, parameters);
case SendSignal:
case SendMessage:
return new MessageProducer(endpoint, parameters);
default:
throw new IllegalArgumentException("Cannot create a producer for URI '" + uri + "' - new ProducerType '"
+ uri.getType() + "' not yet supported?");
}
} | [
"public",
"static",
"CamundaBpmProducer",
"createProducer",
"(",
"final",
"CamundaBpmEndpoint",
"endpoint",
",",
"final",
"ParsedUri",
"uri",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"throws",
"IllegalArgumentException",
"{",
"switc... | Prevent instantiation of helper class | [
"Prevent",
"instantiation",
"of",
"helper",
"class"
] | 224cd7563430f8792287022923ee27491f5a4b60 | https://github.com/camunda/camunda-bpm-camel/blob/224cd7563430f8792287022923ee27491f5a4b60/camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/component/producer/CamundaBpmProducerFactory.java#L19-L33 | train |
camunda/camunda-bpm-camel | camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/component/externaltasks/BatchConsumer.java | BatchConsumer.removeExcessiveInProgressTasks | protected void removeExcessiveInProgressTasks(Queue<Exchange> exchanges, int limit) {
while (exchanges.size() > limit) {
// must remove last
Exchange exchange = exchanges.poll();
releaseTask(exchange);
}
} | java | protected void removeExcessiveInProgressTasks(Queue<Exchange> exchanges, int limit) {
while (exchanges.size() > limit) {
// must remove last
Exchange exchange = exchanges.poll();
releaseTask(exchange);
}
} | [
"protected",
"void",
"removeExcessiveInProgressTasks",
"(",
"Queue",
"<",
"Exchange",
">",
"exchanges",
",",
"int",
"limit",
")",
"{",
"while",
"(",
"exchanges",
".",
"size",
"(",
")",
">",
"limit",
")",
"{",
"// must remove last",
"Exchange",
"exchange",
"=",... | Drain any in progress files as we are done with this batch
@param exchanges
the exchanges
@param limit
the limit | [
"Drain",
"any",
"in",
"progress",
"files",
"as",
"we",
"are",
"done",
"with",
"this",
"batch"
] | 224cd7563430f8792287022923ee27491f5a4b60 | https://github.com/camunda/camunda-bpm-camel/blob/224cd7563430f8792287022923ee27491f5a4b60/camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/component/externaltasks/BatchConsumer.java#L177-L185 | train |
camunda/camunda-bpm-camel | camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/common/ExchangeUtils.java | ExchangeUtils.prepareVariables | @SuppressWarnings("rawtypes")
public static Map<String, Object> prepareVariables(Exchange exchange, Map<String, Object> parameters) {
Map<String, Object> processVariables = new HashMap<String, Object>();
Object camelBody = exchange.getIn().getBody();
if (camelBody instanceof String) {
// If the COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER was passed
// the value of it
// is taken as variable to store the (string) body in
String processVariableName = "camelBody";
if (parameters.containsKey(CamundaBpmConstants.COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER)) {
processVariableName = (String) parameters.get(
CamundaBpmConstants.COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER);
}
processVariables.put(processVariableName, camelBody);
} else if (camelBody instanceof Map<?, ?>) {
Map<?, ?> camelBodyMap = (Map<?, ?>) camelBody;
for (Map.Entry e : camelBodyMap.entrySet()) {
if (e.getKey() instanceof String) {
processVariables.put((String) e.getKey(), e.getValue());
}
}
} else if (camelBody != null) {
log.log(Level.WARNING,
"unkown type of camel body - not handed over to process engine: " + camelBody.getClass());
}
return processVariables;
} | java | @SuppressWarnings("rawtypes")
public static Map<String, Object> prepareVariables(Exchange exchange, Map<String, Object> parameters) {
Map<String, Object> processVariables = new HashMap<String, Object>();
Object camelBody = exchange.getIn().getBody();
if (camelBody instanceof String) {
// If the COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER was passed
// the value of it
// is taken as variable to store the (string) body in
String processVariableName = "camelBody";
if (parameters.containsKey(CamundaBpmConstants.COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER)) {
processVariableName = (String) parameters.get(
CamundaBpmConstants.COPY_MESSAGE_BODY_AS_PROCESS_VARIABLE_PARAMETER);
}
processVariables.put(processVariableName, camelBody);
} else if (camelBody instanceof Map<?, ?>) {
Map<?, ?> camelBodyMap = (Map<?, ?>) camelBody;
for (Map.Entry e : camelBodyMap.entrySet()) {
if (e.getKey() instanceof String) {
processVariables.put((String) e.getKey(), e.getValue());
}
}
} else if (camelBody != null) {
log.log(Level.WARNING,
"unkown type of camel body - not handed over to process engine: " + camelBody.getClass());
}
return processVariables;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"prepareVariables",
"(",
"Exchange",
"exchange",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"Map",
"<",
"String",
"... | Copies variables from Camel into the process engine.
This method will conditionally copy the Camel body to the "camelBody"
variable if it is of type java.lang.String, OR it will copy the Camel
body to individual variables within the process engine if it is of type
Map<String,Object>. If the copyVariablesFromProperties parameter is set
on the endpoint, the properties are copied instead
@param exchange
The Camel Exchange object
@param parameters
@return A Map<String,Object> containing all of the variables to be used
in the process engine | [
"Copies",
"variables",
"from",
"Camel",
"into",
"the",
"process",
"engine",
"."
] | 224cd7563430f8792287022923ee27491f5a4b60 | https://github.com/camunda/camunda-bpm-camel/blob/224cd7563430f8792287022923ee27491f5a4b60/camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/common/ExchangeUtils.java#L49-L82 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Cursor.java | Cursor.close | @Override
public void close() {
if (closed) {
return;
}
if (SHOULD_CHECK && !txn.isReadOnly()) {
txn.checkReady();
}
LIB.mdb_cursor_close(ptrCursor);
kv.close();
closed = true;
} | java | @Override
public void close() {
if (closed) {
return;
}
if (SHOULD_CHECK && !txn.isReadOnly()) {
txn.checkReady();
}
LIB.mdb_cursor_close(ptrCursor);
kv.close();
closed = true;
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"return",
";",
"}",
"if",
"(",
"SHOULD_CHECK",
"&&",
"!",
"txn",
".",
"isReadOnly",
"(",
")",
")",
"{",
"txn",
".",
"checkReady",
"(",
")",
";",
"}",
"LIB",... | Close a cursor handle.
<p>
The cursor handle will be freed and must not be used again after this call.
Its transaction must still be live if it is a write-transaction. | [
"Close",
"a",
"cursor",
"handle",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Cursor.java#L69-L80 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Cursor.java | Cursor.count | public long count() {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
}
final NativeLongByReference longByReference = new NativeLongByReference();
checkRc(LIB.mdb_cursor_count(ptrCursor, longByReference));
return longByReference.longValue();
} | java | public long count() {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
}
final NativeLongByReference longByReference = new NativeLongByReference();
checkRc(LIB.mdb_cursor_count(ptrCursor, longByReference));
return longByReference.longValue();
} | [
"public",
"long",
"count",
"(",
")",
"{",
"if",
"(",
"SHOULD_CHECK",
")",
"{",
"checkNotClosed",
"(",
")",
";",
"txn",
".",
"checkReady",
"(",
")",
";",
"}",
"final",
"NativeLongByReference",
"longByReference",
"=",
"new",
"NativeLongByReference",
"(",
")",
... | Return count of duplicates for current key.
<p>
This call is only valid on databases that support sorted duplicate data
items {@link DbiFlags#MDB_DUPSORT}.
@return count of duplicates for current key | [
"Return",
"count",
"of",
"duplicates",
"for",
"current",
"key",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Cursor.java#L91-L99 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Cursor.java | Cursor.put | public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
if (rc == MDB_KEYEXIST) {
if (isSet(mask, MDB_NOOVERWRITE)) {
kv.valOut(); // marked as in,out in LMDB C docs
} else if (!isSet(mask, MDB_NODUPDATA)) {
checkRc(rc);
}
return false;
}
checkRc(rc);
return true;
} | java | public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
if (rc == MDB_KEYEXIST) {
if (isSet(mask, MDB_NOOVERWRITE)) {
kv.valOut(); // marked as in,out in LMDB C docs
} else if (!isSet(mask, MDB_NODUPDATA)) {
checkRc(rc);
}
return false;
}
checkRc(rc);
return true;
} | [
"public",
"boolean",
"put",
"(",
"final",
"T",
"key",
",",
"final",
"T",
"val",
",",
"final",
"PutFlags",
"...",
"op",
")",
"{",
"if",
"(",
"SHOULD_CHECK",
")",
"{",
"requireNonNull",
"(",
"key",
")",
";",
"requireNonNull",
"(",
"val",
")",
";",
"che... | Store by cursor.
<p>
This function stores key/data pairs into the database.
@param key key to store
@param val data to store
@param op options for this operation
@return true if the value was put, false if MDB_NOOVERWRITE or
MDB_NODUPDATA were set and the key/value existed already. | [
"Store",
"by",
"cursor",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Cursor.java#L205-L228 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Cursor.java | Cursor.renew | public void renew(final Txn<T> newTxn) {
if (SHOULD_CHECK) {
requireNonNull(newTxn);
checkNotClosed();
this.txn.checkReadOnly(); // existing
newTxn.checkReadOnly();
newTxn.checkReady();
}
checkRc(LIB.mdb_cursor_renew(newTxn.pointer(), ptrCursor));
this.txn = newTxn;
} | java | public void renew(final Txn<T> newTxn) {
if (SHOULD_CHECK) {
requireNonNull(newTxn);
checkNotClosed();
this.txn.checkReadOnly(); // existing
newTxn.checkReadOnly();
newTxn.checkReady();
}
checkRc(LIB.mdb_cursor_renew(newTxn.pointer(), ptrCursor));
this.txn = newTxn;
} | [
"public",
"void",
"renew",
"(",
"final",
"Txn",
"<",
"T",
">",
"newTxn",
")",
"{",
"if",
"(",
"SHOULD_CHECK",
")",
"{",
"requireNonNull",
"(",
"newTxn",
")",
";",
"checkNotClosed",
"(",
")",
";",
"this",
".",
"txn",
".",
"checkReadOnly",
"(",
")",
";... | Renew a cursor handle.
<p>
A cursor is associated with a specific transaction and database. Cursors
that are only used in read-only transactions may be re-used, to avoid
unnecessary malloc/free overhead. The cursor may be associated with a new
read-only transaction, and referencing the same database handle as it was
created with. This may be done whether the previous transaction is live or
dead.
@param newTxn transaction handle | [
"Renew",
"a",
"cursor",
"handle",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Cursor.java#L279-L289 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Verifier.java | Verifier.runFor | public long runFor(final long duration, final TimeUnit unit) {
final long deadline = System.currentTimeMillis() + unit.toMillis(duration);
final ExecutorService es = Executors.newSingleThreadExecutor();
final Future<Long> future = es.submit(this);
try {
while (System.currentTimeMillis() < deadline && !future.isDone()) {
Thread.sleep(unit.toMillis(1));
}
} catch (final InterruptedException ignored) {
} finally {
stop();
}
final long result;
try {
result = future.get();
} catch (final InterruptedException | ExecutionException ex) {
throw new IllegalStateException(ex);
} finally {
es.shutdown();
}
return result;
} | java | public long runFor(final long duration, final TimeUnit unit) {
final long deadline = System.currentTimeMillis() + unit.toMillis(duration);
final ExecutorService es = Executors.newSingleThreadExecutor();
final Future<Long> future = es.submit(this);
try {
while (System.currentTimeMillis() < deadline && !future.isDone()) {
Thread.sleep(unit.toMillis(1));
}
} catch (final InterruptedException ignored) {
} finally {
stop();
}
final long result;
try {
result = future.get();
} catch (final InterruptedException | ExecutionException ex) {
throw new IllegalStateException(ex);
} finally {
es.shutdown();
}
return result;
} | [
"public",
"long",
"runFor",
"(",
"final",
"long",
"duration",
",",
"final",
"TimeUnit",
"unit",
")",
"{",
"final",
"long",
"deadline",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"unit",
".",
"toMillis",
"(",
"duration",
")",
";",
"final",
"E... | Execute the verifier for the given duration.
<p>
This provides a simple way to execute the verifier for those applications
which do not wish to manage threads directly.
@param duration amount of time to execute
@param unit units used to express the duration
@return number of database rows successfully verified | [
"Execute",
"the",
"verifier",
"for",
"the",
"given",
"duration",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Verifier.java#L166-L187 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Meta.java | Meta.version | public static Version version() {
final IntByReference major = new IntByReference();
final IntByReference minor = new IntByReference();
final IntByReference patch = new IntByReference();
LIB.mdb_version(major, minor, patch);
return new Version(major.intValue(), minor.intValue(), patch.
intValue());
} | java | public static Version version() {
final IntByReference major = new IntByReference();
final IntByReference minor = new IntByReference();
final IntByReference patch = new IntByReference();
LIB.mdb_version(major, minor, patch);
return new Version(major.intValue(), minor.intValue(), patch.
intValue());
} | [
"public",
"static",
"Version",
"version",
"(",
")",
"{",
"final",
"IntByReference",
"major",
"=",
"new",
"IntByReference",
"(",
")",
";",
"final",
"IntByReference",
"minor",
"=",
"new",
"IntByReference",
"(",
")",
";",
"final",
"IntByReference",
"patch",
"=",
... | Obtains the LMDB C library version information.
@return the version data | [
"Obtains",
"the",
"LMDB",
"C",
"library",
"version",
"information",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Meta.java#L56-L65 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.copy | public void copy(final File path, final CopyFlags... flags) {
requireNonNull(path);
if (!path.exists()) {
throw new InvalidCopyDestination("Path must exist");
}
if (!path.isDirectory()) {
throw new InvalidCopyDestination("Path must be a directory");
}
final String[] files = path.list();
if (files != null && files.length > 0) {
throw new InvalidCopyDestination("Path must contain no files");
}
final int flagsMask = mask(flags);
checkRc(LIB.mdb_env_copy2(ptr, path.getAbsolutePath(), flagsMask));
} | java | public void copy(final File path, final CopyFlags... flags) {
requireNonNull(path);
if (!path.exists()) {
throw new InvalidCopyDestination("Path must exist");
}
if (!path.isDirectory()) {
throw new InvalidCopyDestination("Path must be a directory");
}
final String[] files = path.list();
if (files != null && files.length > 0) {
throw new InvalidCopyDestination("Path must contain no files");
}
final int flagsMask = mask(flags);
checkRc(LIB.mdb_env_copy2(ptr, path.getAbsolutePath(), flagsMask));
} | [
"public",
"void",
"copy",
"(",
"final",
"File",
"path",
",",
"final",
"CopyFlags",
"...",
"flags",
")",
"{",
"requireNonNull",
"(",
"path",
")",
";",
"if",
"(",
"!",
"path",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidCopyDestination",
"... | Copies an LMDB environment to the specified destination path.
<p>
This function may be used to make a backup of an existing environment. No
lockfile is created, since it gets recreated at need.
<p>
Note: This call can trigger significant file size growth if run in parallel
with write transactions, because it employs a read-only transaction. See
long-lived transactions under "Caveats" in the LMDB native documentation.
@param path destination directory, which must exist, be writable and empty
@param flags special options for this copy | [
"Copies",
"an",
"LMDB",
"environment",
"to",
"the",
"specified",
"destination",
"path",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L147-L161 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.getDbiNames | public List<byte[]> getDbiNames() {
final List<byte[]> result = new ArrayList<>();
final Dbi<T> names = openDbi((byte[]) null);
try (Txn<T> txn = txnRead();
Cursor<T> cursor = names.openCursor(txn)) {
if (!cursor.first()) {
return Collections.emptyList();
}
do {
final byte[] name = proxy.getBytes(cursor.key());
result.add(name);
} while (cursor.next());
}
return result;
} | java | public List<byte[]> getDbiNames() {
final List<byte[]> result = new ArrayList<>();
final Dbi<T> names = openDbi((byte[]) null);
try (Txn<T> txn = txnRead();
Cursor<T> cursor = names.openCursor(txn)) {
if (!cursor.first()) {
return Collections.emptyList();
}
do {
final byte[] name = proxy.getBytes(cursor.key());
result.add(name);
} while (cursor.next());
}
return result;
} | [
"public",
"List",
"<",
"byte",
"[",
"]",
">",
"getDbiNames",
"(",
")",
"{",
"final",
"List",
"<",
"byte",
"[",
"]",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"Dbi",
"<",
"T",
">",
"names",
"=",
"openDbi",
"(",
"(",
"... | Obtain the DBI names.
<p>
This method is only compatible with {@link Env}s that use named databases.
If an unnamed {@link Dbi} is being used to store data, this method will
attempt to return all such keys from the unnamed database.
@return a list of DBI names (never null) | [
"Obtain",
"the",
"DBI",
"names",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L173-L188 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.info | public EnvInfo info() {
if (closed) {
throw new AlreadyClosedException();
}
final MDB_envinfo info = new MDB_envinfo(RUNTIME);
checkRc(LIB.mdb_env_info(ptr, info));
final long mapAddress;
if (info.f0_me_mapaddr.get() == null) {
mapAddress = 0;
} else {
mapAddress = info.f0_me_mapaddr.get().address();
}
return new EnvInfo(
mapAddress,
info.f1_me_mapsize.longValue(),
info.f2_me_last_pgno.longValue(),
info.f3_me_last_txnid.longValue(),
info.f4_me_maxreaders.intValue(),
info.f5_me_numreaders.intValue());
} | java | public EnvInfo info() {
if (closed) {
throw new AlreadyClosedException();
}
final MDB_envinfo info = new MDB_envinfo(RUNTIME);
checkRc(LIB.mdb_env_info(ptr, info));
final long mapAddress;
if (info.f0_me_mapaddr.get() == null) {
mapAddress = 0;
} else {
mapAddress = info.f0_me_mapaddr.get().address();
}
return new EnvInfo(
mapAddress,
info.f1_me_mapsize.longValue(),
info.f2_me_last_pgno.longValue(),
info.f3_me_last_txnid.longValue(),
info.f4_me_maxreaders.intValue(),
info.f5_me_numreaders.intValue());
} | [
"public",
"EnvInfo",
"info",
"(",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"throw",
"new",
"AlreadyClosedException",
"(",
")",
";",
"}",
"final",
"MDB_envinfo",
"info",
"=",
"new",
"MDB_envinfo",
"(",
"RUNTIME",
")",
";",
"checkRc",
"(",
"LIB",
".",
"m... | Return information about this environment.
@return an immutable information object. | [
"Return",
"information",
"about",
"this",
"environment",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L213-L234 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.stat | public Stat stat() {
if (closed) {
throw new AlreadyClosedException();
}
final MDB_stat stat = new MDB_stat(RUNTIME);
checkRc(LIB.mdb_env_stat(ptr, stat));
return new Stat(
stat.f0_ms_psize.intValue(),
stat.f1_ms_depth.intValue(),
stat.f2_ms_branch_pages.longValue(),
stat.f3_ms_leaf_pages.longValue(),
stat.f4_ms_overflow_pages.longValue(),
stat.f5_ms_entries.longValue());
} | java | public Stat stat() {
if (closed) {
throw new AlreadyClosedException();
}
final MDB_stat stat = new MDB_stat(RUNTIME);
checkRc(LIB.mdb_env_stat(ptr, stat));
return new Stat(
stat.f0_ms_psize.intValue(),
stat.f1_ms_depth.intValue(),
stat.f2_ms_branch_pages.longValue(),
stat.f3_ms_leaf_pages.longValue(),
stat.f4_ms_overflow_pages.longValue(),
stat.f5_ms_entries.longValue());
} | [
"public",
"Stat",
"stat",
"(",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"throw",
"new",
"AlreadyClosedException",
"(",
")",
";",
"}",
"final",
"MDB_stat",
"stat",
"=",
"new",
"MDB_stat",
"(",
"RUNTIME",
")",
";",
"checkRc",
"(",
"LIB",
".",
"mdb_env_st... | Return statistics about this environment.
@return an immutable statistics object. | [
"Return",
"statistics",
"about",
"this",
"environment",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L329-L342 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.sync | public void sync(final boolean force) {
if (closed) {
throw new AlreadyClosedException();
}
final int f = force ? 1 : 0;
checkRc(LIB.mdb_env_sync(ptr, f));
} | java | public void sync(final boolean force) {
if (closed) {
throw new AlreadyClosedException();
}
final int f = force ? 1 : 0;
checkRc(LIB.mdb_env_sync(ptr, f));
} | [
"public",
"void",
"sync",
"(",
"final",
"boolean",
"force",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"throw",
"new",
"AlreadyClosedException",
"(",
")",
";",
"}",
"final",
"int",
"f",
"=",
"force",
"?",
"1",
":",
"0",
";",
"checkRc",
"(",
"LIB",
".... | Flushes the data buffers to disk.
@param force force a synchronous flush (otherwise if the environment has
the MDB_NOSYNC flag set the flushes will be omitted, and with
MDB_MAPASYNC they will be asynchronous) | [
"Flushes",
"the",
"data",
"buffers",
"to",
"disk",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L351-L357 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Env.java | Env.txn | public Txn<T> txn(final Txn<T> parent, final TxnFlags... flags) {
if (closed) {
throw new AlreadyClosedException();
}
return new Txn<>(this, parent, proxy, flags);
} | java | public Txn<T> txn(final Txn<T> parent, final TxnFlags... flags) {
if (closed) {
throw new AlreadyClosedException();
}
return new Txn<>(this, parent, proxy, flags);
} | [
"public",
"Txn",
"<",
"T",
">",
"txn",
"(",
"final",
"Txn",
"<",
"T",
">",
"parent",
",",
"final",
"TxnFlags",
"...",
"flags",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"throw",
"new",
"AlreadyClosedException",
"(",
")",
";",
"}",
"return",
"new",
"... | Obtain a transaction with the requested parent and flags.
@param parent parent transaction (may be null if no parent)
@param flags applicable flags (eg for a reusable, read-only transaction)
@return a transaction (never null) | [
"Obtain",
"a",
"transaction",
"with",
"the",
"requested",
"parent",
"and",
"flags",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Env.java#L366-L371 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/DirectBufferProxy.java | DirectBufferProxy.compareBuff | @SuppressWarnings("checkstyle:ReturnCount")
public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
requireNonNull(o1);
requireNonNull(o2);
if (o1.equals(o2)) {
return 0;
}
final int minLength = Math.min(o1.capacity(), o2.capacity());
final int minWords = minLength / Long.BYTES;
for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
final long lw = o1.getLong(i, BIG_ENDIAN);
final long rw = o2.getLong(i, BIG_ENDIAN);
final int diff = Long.compareUnsigned(lw, rw);
if (diff != 0) {
return diff;
}
}
for (int i = minWords * Long.BYTES; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1.getByte(i));
final int rw = Byte.toUnsignedInt(o2.getByte(i));
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.capacity() - o2.capacity();
} | java | @SuppressWarnings("checkstyle:ReturnCount")
public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
requireNonNull(o1);
requireNonNull(o2);
if (o1.equals(o2)) {
return 0;
}
final int minLength = Math.min(o1.capacity(), o2.capacity());
final int minWords = minLength / Long.BYTES;
for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
final long lw = o1.getLong(i, BIG_ENDIAN);
final long rw = o2.getLong(i, BIG_ENDIAN);
final int diff = Long.compareUnsigned(lw, rw);
if (diff != 0) {
return diff;
}
}
for (int i = minWords * Long.BYTES; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1.getByte(i));
final int rw = Byte.toUnsignedInt(o2.getByte(i));
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.capacity() - o2.capacity();
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:ReturnCount\"",
")",
"public",
"static",
"int",
"compareBuff",
"(",
"final",
"DirectBuffer",
"o1",
",",
"final",
"DirectBuffer",
"o2",
")",
"{",
"requireNonNull",
"(",
"o1",
")",
";",
"requireNonNull",
"(",
"o2",
")",
... | Lexicographically compare two buffers.
@param o1 left operand (required)
@param o2 right operand (required)
@return as specified by {@link Comparable} interface | [
"Lexicographically",
"compare",
"two",
"buffers",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/DirectBufferProxy.java#L66-L95 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Dbi.java | Dbi.delete | public boolean delete(final T key) {
try (Txn<T> txn = env.txnWrite()) {
final boolean ret = delete(txn, key);
txn.commit();
return ret;
}
} | java | public boolean delete(final T key) {
try (Txn<T> txn = env.txnWrite()) {
final boolean ret = delete(txn, key);
txn.commit();
return ret;
}
} | [
"public",
"boolean",
"delete",
"(",
"final",
"T",
"key",
")",
"{",
"try",
"(",
"Txn",
"<",
"T",
">",
"txn",
"=",
"env",
".",
"txnWrite",
"(",
")",
")",
"{",
"final",
"boolean",
"ret",
"=",
"delete",
"(",
"txn",
",",
"key",
")",
";",
"txn",
".",... | Starts a new read-write transaction and deletes the key.
@param key key to delete from the database (not null)
@return true if the key/data pair was found, false otherwise
@see #delete(org.lmdbjava.Txn, java.lang.Object, java.lang.Object) | [
"Starts",
"a",
"new",
"read",
"-",
"write",
"transaction",
"and",
"deletes",
"the",
"key",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Dbi.java#L119-L125 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Dbi.java | Dbi.delete | public boolean delete(final Txn<T> txn, final T key) {
return delete(txn, key, null);
} | java | public boolean delete(final Txn<T> txn, final T key) {
return delete(txn, key, null);
} | [
"public",
"boolean",
"delete",
"(",
"final",
"Txn",
"<",
"T",
">",
"txn",
",",
"final",
"T",
"key",
")",
"{",
"return",
"delete",
"(",
"txn",
",",
"key",
",",
"null",
")",
";",
"}"
] | Deletes the key using the passed transaction.
@param txn transaction handle (not null; not committed; must be R-W)
@param key key to delete from the database (not null)
@return true if the key/data pair was found, false otherwise
@see #delete(org.lmdbjava.Txn, java.lang.Object, java.lang.Object) | [
"Deletes",
"the",
"key",
"using",
"the",
"passed",
"transaction",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Dbi.java#L136-L138 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Dbi.java | Dbi.openCursor | public Cursor<T> openCursor(final Txn<T> txn) {
if (SHOULD_CHECK) {
requireNonNull(txn);
txn.checkReady();
}
final PointerByReference cursorPtr = new PointerByReference();
checkRc(LIB.mdb_cursor_open(txn.pointer(), ptr, cursorPtr));
return new Cursor<>(cursorPtr.getValue(), txn);
} | java | public Cursor<T> openCursor(final Txn<T> txn) {
if (SHOULD_CHECK) {
requireNonNull(txn);
txn.checkReady();
}
final PointerByReference cursorPtr = new PointerByReference();
checkRc(LIB.mdb_cursor_open(txn.pointer(), ptr, cursorPtr));
return new Cursor<>(cursorPtr.getValue(), txn);
} | [
"public",
"Cursor",
"<",
"T",
">",
"openCursor",
"(",
"final",
"Txn",
"<",
"T",
">",
"txn",
")",
"{",
"if",
"(",
"SHOULD_CHECK",
")",
"{",
"requireNonNull",
"(",
"txn",
")",
";",
"txn",
".",
"checkReady",
"(",
")",
";",
"}",
"final",
"PointerByRefere... | Create a cursor handle.
<p>
A cursor is associated with a specific transaction and database. A cursor
cannot be used when its database handle is closed. Nor when its transaction
has ended, except with {@link Cursor#renew(org.lmdbjava.Txn)}. It can be
discarded with {@link Cursor#close()}. A cursor in a write-transaction can
be closed before its transaction ends, and will otherwise be closed when
its transaction ends. A cursor in a read-only transaction must be closed
explicitly, before or after its transaction ends. It can be reused with
{@link Cursor#renew(org.lmdbjava.Txn)} before finally closing it.
@param txn transaction handle (not null; not committed)
@return cursor handle | [
"Create",
"a",
"cursor",
"handle",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Dbi.java#L370-L378 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Dbi.java | Dbi.stat | public Stat stat(final Txn<T> txn) {
if (SHOULD_CHECK) {
requireNonNull(txn);
txn.checkReady();
}
final MDB_stat stat = new MDB_stat(RUNTIME);
checkRc(LIB.mdb_stat(txn.pointer(), ptr, stat));
return new Stat(
stat.f0_ms_psize.intValue(),
stat.f1_ms_depth.intValue(),
stat.f2_ms_branch_pages.longValue(),
stat.f3_ms_leaf_pages.longValue(),
stat.f4_ms_overflow_pages.longValue(),
stat.f5_ms_entries.longValue());
} | java | public Stat stat(final Txn<T> txn) {
if (SHOULD_CHECK) {
requireNonNull(txn);
txn.checkReady();
}
final MDB_stat stat = new MDB_stat(RUNTIME);
checkRc(LIB.mdb_stat(txn.pointer(), ptr, stat));
return new Stat(
stat.f0_ms_psize.intValue(),
stat.f1_ms_depth.intValue(),
stat.f2_ms_branch_pages.longValue(),
stat.f3_ms_leaf_pages.longValue(),
stat.f4_ms_overflow_pages.longValue(),
stat.f5_ms_entries.longValue());
} | [
"public",
"Stat",
"stat",
"(",
"final",
"Txn",
"<",
"T",
">",
"txn",
")",
"{",
"if",
"(",
"SHOULD_CHECK",
")",
"{",
"requireNonNull",
"(",
"txn",
")",
";",
"txn",
".",
"checkReady",
"(",
")",
";",
"}",
"final",
"MDB_stat",
"stat",
"=",
"new",
"MDB_... | Return statistics about this database.
@param txn transaction handle (not null; not committed)
@return an immutable statistics object. | [
"Return",
"statistics",
"about",
"this",
"database",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Dbi.java#L477-L491 | train |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Txn.java | Txn.close | @Override
public void close() {
if (state == RELEASED) {
return;
}
if (state == READY) {
LIB.mdb_txn_abort(ptr);
}
keyVal.close();
state = RELEASED;
} | java | @Override
public void close() {
if (state == RELEASED) {
return;
}
if (state == READY) {
LIB.mdb_txn_abort(ptr);
}
keyVal.close();
state = RELEASED;
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"state",
"==",
"RELEASED",
")",
"{",
"return",
";",
"}",
"if",
"(",
"state",
"==",
"READY",
")",
"{",
"LIB",
".",
"mdb_txn_abort",
"(",
"ptr",
")",
";",
"}",
"keyVal",
".",
"cl... | Closes this transaction by aborting if not already committed.
<p>
Closing the transaction will invoke
{@link BufferProxy#deallocate(java.lang.Object)} for each read-only buffer
(ie the key and value). | [
"Closes",
"this",
"transaction",
"by",
"aborting",
"if",
"not",
"already",
"committed",
"."
] | 5912beb1037722c71f3ddc05e70fcbe739dfa272 | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Txn.java#L90-L100 | train |
undera/perfmon-agent | src/kg/apc/perfmon/client/AbstractTransport.java | AbstractTransport.getNextLine | protected String getNextLine(int newlineCount) throws IOException {
if (newlineCount == 0) {
return "";
}
StringBuffer str = new StringBuffer();
int b;
while (pis.available() > 0) {
b = pis.read();
if (b == -1) {
return "";
}
if (b == '\n') {
newlineCount--;
if (newlineCount == 0) {
log.debug("Read lines: " + str.toString());
String[] lines = str.toString().split("\n");
// FIXME: this leads to queuing lines so we will have time lag!
return lines[lines.length - 1];
}
}
str.append((char) b);
}
return "";
} | java | protected String getNextLine(int newlineCount) throws IOException {
if (newlineCount == 0) {
return "";
}
StringBuffer str = new StringBuffer();
int b;
while (pis.available() > 0) {
b = pis.read();
if (b == -1) {
return "";
}
if (b == '\n') {
newlineCount--;
if (newlineCount == 0) {
log.debug("Read lines: " + str.toString());
String[] lines = str.toString().split("\n");
// FIXME: this leads to queuing lines so we will have time lag!
return lines[lines.length - 1];
}
}
str.append((char) b);
}
return "";
} | [
"protected",
"String",
"getNextLine",
"(",
"int",
"newlineCount",
")",
"throws",
"IOException",
"{",
"if",
"(",
"newlineCount",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuffer",
"str",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"int",
"b",
... | Method retrieves next line from received bytes sequence
@param newlineCount
@return next command line
@throws IOException | [
"Method",
"retrieves",
"next",
"line",
"from",
"received",
"bytes",
"sequence"
] | 535c145e588d59acc88684115485d9170c6260fe | https://github.com/undera/perfmon-agent/blob/535c145e588d59acc88684115485d9170c6260fe/src/kg/apc/perfmon/client/AbstractTransport.java#L88-L111 | train |
undera/perfmon-agent | src/kg/apc/perfmon/client/TransportFactory.java | TransportFactory.getTransport | public static Transport getTransport(SocketAddress addr) throws IOException {
Transport trans;
try {
log.debug("Connecting TCP");
trans = TCPInstance(addr);
if (!trans.test()) {
throw new IOException("Agent is unreachable via TCP");
}
return trans;
} catch (IOException e) {
log.info("Can't connect TCP transport for host: " + addr.toString(), e);
try {
log.debug("Connecting UDP");
trans = UDPInstance(addr);
if (!trans.test()) {
throw new IOException("Agent is unreachable via UDP");
}
return trans;
} catch (IOException ex) {
log.info("Can't connect UDP transport for host: " + addr.toString(), ex);
throw ex;
}
}
} | java | public static Transport getTransport(SocketAddress addr) throws IOException {
Transport trans;
try {
log.debug("Connecting TCP");
trans = TCPInstance(addr);
if (!trans.test()) {
throw new IOException("Agent is unreachable via TCP");
}
return trans;
} catch (IOException e) {
log.info("Can't connect TCP transport for host: " + addr.toString(), e);
try {
log.debug("Connecting UDP");
trans = UDPInstance(addr);
if (!trans.test()) {
throw new IOException("Agent is unreachable via UDP");
}
return trans;
} catch (IOException ex) {
log.info("Can't connect UDP transport for host: " + addr.toString(), ex);
throw ex;
}
}
} | [
"public",
"static",
"Transport",
"getTransport",
"(",
"SocketAddress",
"addr",
")",
"throws",
"IOException",
"{",
"Transport",
"trans",
";",
"try",
"{",
"log",
".",
"debug",
"(",
"\"Connecting TCP\"",
")",
";",
"trans",
"=",
"TCPInstance",
"(",
"addr",
")",
... | Primary transport getting method. Tries to connect and test UDP Transport.
If UDP failed, tries TCP transport. If it fails, too, throws IOException
@param addr
@return Transport instance
@throws IOException | [
"Primary",
"transport",
"getting",
"method",
".",
"Tries",
"to",
"connect",
"and",
"test",
"UDP",
"Transport",
".",
"If",
"UDP",
"failed",
"tries",
"TCP",
"transport",
".",
"If",
"it",
"fails",
"too",
"throws",
"IOException"
] | 535c145e588d59acc88684115485d9170c6260fe | https://github.com/undera/perfmon-agent/blob/535c145e588d59acc88684115485d9170c6260fe/src/kg/apc/perfmon/client/TransportFactory.java#L31-L54 | train |
undera/perfmon-agent | src/kg/apc/perfmon/client/TransportFactory.java | TransportFactory.TCPInstance | public static Transport TCPInstance(SocketAddress addr) throws IOException {
Socket sock = new Socket();
sock.setSoTimeout(getTimeout());
sock.connect(addr);
StreamTransport trans = new StreamTransport();
trans.setStreams(sock.getInputStream(), sock.getOutputStream());
trans.setAddressLabel(addr.toString());
return trans;
} | java | public static Transport TCPInstance(SocketAddress addr) throws IOException {
Socket sock = new Socket();
sock.setSoTimeout(getTimeout());
sock.connect(addr);
StreamTransport trans = new StreamTransport();
trans.setStreams(sock.getInputStream(), sock.getOutputStream());
trans.setAddressLabel(addr.toString());
return trans;
} | [
"public",
"static",
"Transport",
"TCPInstance",
"(",
"SocketAddress",
"addr",
")",
"throws",
"IOException",
"{",
"Socket",
"sock",
"=",
"new",
"Socket",
"(",
")",
";",
"sock",
".",
"setSoTimeout",
"(",
"getTimeout",
"(",
")",
")",
";",
"sock",
".",
"connec... | Returns TCP transport instance, connected to specified address
@param addr
@return Transport instance
@throws IOException | [
"Returns",
"TCP",
"transport",
"instance",
"connected",
"to",
"specified",
"address"
] | 535c145e588d59acc88684115485d9170c6260fe | https://github.com/undera/perfmon-agent/blob/535c145e588d59acc88684115485d9170c6260fe/src/kg/apc/perfmon/client/TransportFactory.java#L92-L101 | train |
undera/perfmon-agent | src/kg/apc/perfmon/client/TransportFactory.java | TransportFactory.UDPInstance | public static Transport UDPInstance(SocketAddress addr) throws IOException {
DatagramSocket sock = new DatagramSocket();
sock.setSoTimeout(getTimeout());
sock.connect(addr);
StreamTransport trans = new StreamTransport();
trans.setStreams(new UDPInputStream(sock), new UDPOutputStream(sock));
trans.setAddressLabel(addr.toString());
return trans;
} | java | public static Transport UDPInstance(SocketAddress addr) throws IOException {
DatagramSocket sock = new DatagramSocket();
sock.setSoTimeout(getTimeout());
sock.connect(addr);
StreamTransport trans = new StreamTransport();
trans.setStreams(new UDPInputStream(sock), new UDPOutputStream(sock));
trans.setAddressLabel(addr.toString());
return trans;
} | [
"public",
"static",
"Transport",
"UDPInstance",
"(",
"SocketAddress",
"addr",
")",
"throws",
"IOException",
"{",
"DatagramSocket",
"sock",
"=",
"new",
"DatagramSocket",
"(",
")",
";",
"sock",
".",
"setSoTimeout",
"(",
"getTimeout",
"(",
")",
")",
";",
"sock",
... | Returns new UDP Transport instance
connected to specified socket address
@param addr
@return connected Transport
@throws IOException | [
"Returns",
"new",
"UDP",
"Transport",
"instance",
"connected",
"to",
"specified",
"socket",
"address"
] | 535c145e588d59acc88684115485d9170c6260fe | https://github.com/undera/perfmon-agent/blob/535c145e588d59acc88684115485d9170c6260fe/src/kg/apc/perfmon/client/TransportFactory.java#L115-L124 | train |
ctongfei/progressbar | src/main/java/me/tongfei/progressbar/ProgressBar.java | ProgressBar.maxHint | public ProgressBar maxHint(long n) {
if (n < 0)
progress.setAsIndefinite();
else {
progress.setAsDefinite();
progress.maxHint(n);
}
return this;
} | java | public ProgressBar maxHint(long n) {
if (n < 0)
progress.setAsIndefinite();
else {
progress.setAsDefinite();
progress.maxHint(n);
}
return this;
} | [
"public",
"ProgressBar",
"maxHint",
"(",
"long",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
")",
"progress",
".",
"setAsIndefinite",
"(",
")",
";",
"else",
"{",
"progress",
".",
"setAsDefinite",
"(",
")",
";",
"progress",
".",
"maxHint",
"(",
"n",
")",... | Gives a hint to the maximum value of the progress bar.
@param n Hint of the maximum value | [
"Gives",
"a",
"hint",
"to",
"the",
"maximum",
"value",
"of",
"the",
"progress",
"bar",
"."
] | dd4b49c73f7c0ebcc3b531a75d536625dd820c83 | https://github.com/ctongfei/progressbar/blob/dd4b49c73f7c0ebcc3b531a75d536625dd820c83/src/main/java/me/tongfei/progressbar/ProgressBar.java#L140-L148 | train |
davidmoten/rxjava2-jdbc | rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuple2.java | Tuple2.create | public static <R, S> Tuple2<R, S> create(R r, S s) {
return new Tuple2<R, S>(r, s);
} | java | public static <R, S> Tuple2<R, S> create(R r, S s) {
return new Tuple2<R, S>(r, s);
} | [
"public",
"static",
"<",
"R",
",",
"S",
">",
"Tuple2",
"<",
"R",
",",
"S",
">",
"create",
"(",
"R",
"r",
",",
"S",
"s",
")",
"{",
"return",
"new",
"Tuple2",
"<",
"R",
",",
"S",
">",
"(",
"r",
",",
"s",
")",
";",
"}"
] | Returns a new instance.
@param r
first element
@param s
second element
@param <R> type of first element
@param <S>
type of second element
@return tuple | [
"Returns",
"a",
"new",
"instance",
"."
] | 6f170806a7cd0fd2e40f3af3724ef77fbcdc757a | https://github.com/davidmoten/rxjava2-jdbc/blob/6f170806a7cd0fd2e40f3af3724ef77fbcdc757a/rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuple2.java#L42-L44 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java | BigDecimalMath.factorial | public static BigDecimal factorial(int n) {
if (n < 0) {
throw new ArithmeticException("Illegal factorial(n) for n < 0: n = " + n);
}
if (n < factorialCache.length) {
return factorialCache[n];
}
BigDecimal result = factorialCache[factorialCache.length - 1];
return result.multiply(factorialRecursion(factorialCache.length, n));
} | java | public static BigDecimal factorial(int n) {
if (n < 0) {
throw new ArithmeticException("Illegal factorial(n) for n < 0: n = " + n);
}
if (n < factorialCache.length) {
return factorialCache[n];
}
BigDecimal result = factorialCache[factorialCache.length - 1];
return result.multiply(factorialRecursion(factorialCache.length, n));
} | [
"public",
"static",
"BigDecimal",
"factorial",
"(",
"int",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
")",
"{",
"throw",
"new",
"ArithmeticException",
"(",
"\"Illegal factorial(n) for n < 0: n = \"",
"+",
"n",
")",
";",
"}",
"if",
"(",
"n",
"<",
"factorialCa... | Calculates the factorial of the specified integer argument.
<p>factorial = 1 * 2 * 3 * ... n</p>
@param n the {@link BigDecimal}
@return the factorial {@link BigDecimal}
@throws ArithmeticException if x < 0 | [
"Calculates",
"the",
"factorial",
"of",
"the",
"specified",
"integer",
"argument",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java#L477-L487 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java | BigDecimalMath.pi | public static BigDecimal pi(MathContext mathContext) {
checkMathContext(mathContext);
BigDecimal result = null;
synchronized (piCacheLock) {
if (piCache != null && mathContext.getPrecision() <= piCache.precision()) {
result = piCache;
} else {
piCache = piChudnovski(mathContext);
return piCache;
}
}
return round(result, mathContext);
} | java | public static BigDecimal pi(MathContext mathContext) {
checkMathContext(mathContext);
BigDecimal result = null;
synchronized (piCacheLock) {
if (piCache != null && mathContext.getPrecision() <= piCache.precision()) {
result = piCache;
} else {
piCache = piChudnovski(mathContext);
return piCache;
}
}
return round(result, mathContext);
} | [
"public",
"static",
"BigDecimal",
"pi",
"(",
"MathContext",
"mathContext",
")",
"{",
"checkMathContext",
"(",
"mathContext",
")",
";",
"BigDecimal",
"result",
"=",
"null",
";",
"synchronized",
"(",
"piCacheLock",
")",
"{",
"if",
"(",
"piCache",
"!=",
"null",
... | Returns the number pi.
<p>See <a href="https://en.wikipedia.org/wiki/Pi">Wikipedia: Pi</a></p>
@param mathContext the {@link MathContext} used for the result
@return the number pi with the precision specified in the <code>mathContext</code>
@throws UnsupportedOperationException if the {@link MathContext} has unlimited precision | [
"Returns",
"the",
"number",
"pi",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java#L1118-L1132 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java | BigDecimalMath.e | public static BigDecimal e(MathContext mathContext) {
checkMathContext(mathContext);
BigDecimal result = null;
synchronized (eCacheLock) {
if (eCache != null && mathContext.getPrecision() <= eCache.precision()) {
result = eCache;
} else {
eCache = exp(ONE, mathContext);
return eCache;
}
}
return round(result, mathContext);
} | java | public static BigDecimal e(MathContext mathContext) {
checkMathContext(mathContext);
BigDecimal result = null;
synchronized (eCacheLock) {
if (eCache != null && mathContext.getPrecision() <= eCache.precision()) {
result = eCache;
} else {
eCache = exp(ONE, mathContext);
return eCache;
}
}
return round(result, mathContext);
} | [
"public",
"static",
"BigDecimal",
"e",
"(",
"MathContext",
"mathContext",
")",
"{",
"checkMathContext",
"(",
"mathContext",
")",
";",
"BigDecimal",
"result",
"=",
"null",
";",
"synchronized",
"(",
"eCacheLock",
")",
"{",
"if",
"(",
"eCache",
"!=",
"null",
"&... | Returns the number e.
<p>See <a href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">Wikipedia: E (mathematical_constant)</a></p>
@param mathContext the {@link MathContext} used for the result
@return the number e with the precision specified in the <code>mathContext</code>
@throws UnsupportedOperationException if the {@link MathContext} has unlimited precision | [
"Returns",
"the",
"number",
"e",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java#L1185-L1199 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.multiply | private BigRational multiply(BigDecimal value) {
BigDecimal n = numerator.multiply(value);
BigDecimal d = denominator;
return of(n, d);
} | java | private BigRational multiply(BigDecimal value) {
BigDecimal n = numerator.multiply(value);
BigDecimal d = denominator;
return of(n, d);
} | [
"private",
"BigRational",
"multiply",
"(",
"BigDecimal",
"value",
")",
"{",
"BigDecimal",
"n",
"=",
"numerator",
".",
"multiply",
"(",
"value",
")",
";",
"BigDecimal",
"d",
"=",
"denominator",
";",
"return",
"of",
"(",
"n",
",",
"d",
")",
";",
"}"
] | private, because we want to hide that we use BigDecimal internally | [
"private",
"because",
"we",
"want",
"to",
"hide",
"that",
"we",
"use",
"BigDecimal",
"internally"
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L412-L416 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.valueOf | public static BigRational valueOf(int integer, int fractionNumerator, int fractionDenominator) {
if (fractionNumerator < 0 || fractionDenominator < 0) {
throw new ArithmeticException("Negative value");
}
BigRational integerPart = valueOf(integer);
BigRational fractionPart = valueOf(fractionNumerator, fractionDenominator);
return integerPart.isPositive() ? integerPart.add(fractionPart) : integerPart.subtract(fractionPart);
} | java | public static BigRational valueOf(int integer, int fractionNumerator, int fractionDenominator) {
if (fractionNumerator < 0 || fractionDenominator < 0) {
throw new ArithmeticException("Negative value");
}
BigRational integerPart = valueOf(integer);
BigRational fractionPart = valueOf(fractionNumerator, fractionDenominator);
return integerPart.isPositive() ? integerPart.add(fractionPart) : integerPart.subtract(fractionPart);
} | [
"public",
"static",
"BigRational",
"valueOf",
"(",
"int",
"integer",
",",
"int",
"fractionNumerator",
",",
"int",
"fractionDenominator",
")",
"{",
"if",
"(",
"fractionNumerator",
"<",
"0",
"||",
"fractionDenominator",
"<",
"0",
")",
"{",
"throw",
"new",
"Arith... | Creates a rational number of the specified integer and fraction parts.
<p>Useful to create numbers like 3 1/2 (= three and a half = 3.5) by calling
<code>BigRational.valueOf(3, 1, 2)</code>.</p>
<p>To create a negative rational only the integer part argument is allowed to be negative:
to create -3 1/2 (= minus three and a half = -3.5) call <code>BigRational.valueOf(-3, 1, 2)</code>.</p>
@param integer the integer part int value
@param fractionNumerator the fraction part numerator int value (negative not allowed)
@param fractionDenominator the fraction part denominator int value (0 or negative not allowed)
@return the rational number
@throws ArithmeticException if the fraction part denominator is 0 (division by zero),
or if the fraction part numerator or denominator is negative | [
"Creates",
"a",
"rational",
"number",
"of",
"the",
"specified",
"integer",
"and",
"fraction",
"parts",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L844-L852 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.valueOf | public static BigRational valueOf(double value) {
if (value == 0.0) {
return ZERO;
}
if (value == 1.0) {
return ONE;
}
if (Double.isInfinite(value)) {
throw new NumberFormatException("Infinite");
}
if (Double.isNaN(value)) {
throw new NumberFormatException("NaN");
}
return valueOf(new BigDecimal(String.valueOf(value)));
} | java | public static BigRational valueOf(double value) {
if (value == 0.0) {
return ZERO;
}
if (value == 1.0) {
return ONE;
}
if (Double.isInfinite(value)) {
throw new NumberFormatException("Infinite");
}
if (Double.isNaN(value)) {
throw new NumberFormatException("NaN");
}
return valueOf(new BigDecimal(String.valueOf(value)));
} | [
"public",
"static",
"BigRational",
"valueOf",
"(",
"double",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"0.0",
")",
"{",
"return",
"ZERO",
";",
"}",
"if",
"(",
"value",
"==",
"1.0",
")",
"{",
"return",
"ONE",
";",
"}",
"if",
"(",
"Double",
".",
... | Creates a rational number of the specified double value.
@param value the double value
@return the rational number
@throws NumberFormatException if the double value is Infinite or NaN. | [
"Creates",
"a",
"rational",
"number",
"of",
"the",
"specified",
"double",
"value",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L889-L903 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.valueOf | public static BigRational valueOf(String string) {
String[] strings = string.split("/");
BigRational result = valueOfSimple(strings[0]);
for (int i = 1; i < strings.length; i++) {
result = result.divide(valueOfSimple(strings[i]));
}
return result;
} | java | public static BigRational valueOf(String string) {
String[] strings = string.split("/");
BigRational result = valueOfSimple(strings[0]);
for (int i = 1; i < strings.length; i++) {
result = result.divide(valueOfSimple(strings[i]));
}
return result;
} | [
"public",
"static",
"BigRational",
"valueOf",
"(",
"String",
"string",
")",
"{",
"String",
"[",
"]",
"strings",
"=",
"string",
".",
"split",
"(",
"\"/\"",
")",
";",
"BigRational",
"result",
"=",
"valueOfSimple",
"(",
"strings",
"[",
"0",
"]",
")",
";",
... | Creates a rational number of the specified string representation.
<p>The accepted string representations are:</p>
<ul>
<li>Output of {@link BigRational#toString()} : "integerPart.fractionPart"</li>
<li>Output of {@link BigRational#toRationalString()} : "numerator/denominator"</li>
<li>Output of <code>toString()</code> of {@link BigDecimal}, {@link BigInteger}, {@link Integer}, ...</li>
<li>Output of <code>toString()</code> of {@link Double}, {@link Float} - except "Infinity", "-Infinity" and "NaN"</li>
</ul>
@param string the string representation to convert
@return the rational number
@throws ArithmeticException if the denominator is 0 (division by zero) | [
"Creates",
"a",
"rational",
"number",
"of",
"the",
"specified",
"string",
"representation",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L948-L955 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.min | public static BigRational min(BigRational... values) {
if (values.length == 0) {
return BigRational.ZERO;
}
BigRational result = values[0];
for (int i = 1; i < values.length; i++) {
result = result.min(values[i]);
}
return result;
} | java | public static BigRational min(BigRational... values) {
if (values.length == 0) {
return BigRational.ZERO;
}
BigRational result = values[0];
for (int i = 1; i < values.length; i++) {
result = result.min(values[i]);
}
return result;
} | [
"public",
"static",
"BigRational",
"min",
"(",
"BigRational",
"...",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
"BigRational",
".",
"ZERO",
";",
"}",
"BigRational",
"result",
"=",
"values",
"[",
"0",
"]",
";"... | Returns the smallest of the specified rational numbers.
@param values the rational numbers to compare
@return the smallest rational number, 0 if no numbers are specified | [
"Returns",
"the",
"smallest",
"of",
"the",
"specified",
"rational",
"numbers",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L1019-L1028 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java | BigRational.max | public static BigRational max(BigRational... values) {
if (values.length == 0) {
return BigRational.ZERO;
}
BigRational result = values[0];
for (int i = 1; i < values.length; i++) {
result = result.max(values[i]);
}
return result;
} | java | public static BigRational max(BigRational... values) {
if (values.length == 0) {
return BigRational.ZERO;
}
BigRational result = values[0];
for (int i = 1; i < values.length; i++) {
result = result.max(values[i]);
}
return result;
} | [
"public",
"static",
"BigRational",
"max",
"(",
"BigRational",
"...",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
"BigRational",
".",
"ZERO",
";",
"}",
"BigRational",
"result",
"=",
"values",
"[",
"0",
"]",
";"... | Returns the largest of the specified rational numbers.
@param values the rational numbers to compare
@return the largest rational number, 0 if no numbers are specified
@see #max(BigRational) | [
"Returns",
"the",
"largest",
"of",
"the",
"specified",
"rational",
"numbers",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigRational.java#L1037-L1046 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.add | public BigComplex add(BigComplex value) {
return valueOf(
re.add(value.re),
im.add(value.im));
} | java | public BigComplex add(BigComplex value) {
return valueOf(
re.add(value.re),
im.add(value.im));
} | [
"public",
"BigComplex",
"add",
"(",
"BigComplex",
"value",
")",
"{",
"return",
"valueOf",
"(",
"re",
".",
"add",
"(",
"value",
".",
"re",
")",
",",
"im",
".",
"add",
"(",
"value",
".",
"im",
")",
")",
";",
"}"
] | Calculates the addition of the given complex value to this complex number.
<p>This methods <strong>does not</strong> modify this instance.</p>
@param value the {@link BigComplex} value to add
@return the calculated {@link BigComplex} result | [
"Calculates",
"the",
"addition",
"of",
"the",
"given",
"complex",
"value",
"to",
"this",
"complex",
"number",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L61-L65 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.subtract | public BigComplex subtract(BigComplex value) {
return valueOf(
re.subtract(value.re),
im.subtract(value.im));
} | java | public BigComplex subtract(BigComplex value) {
return valueOf(
re.subtract(value.re),
im.subtract(value.im));
} | [
"public",
"BigComplex",
"subtract",
"(",
"BigComplex",
"value",
")",
"{",
"return",
"valueOf",
"(",
"re",
".",
"subtract",
"(",
"value",
".",
"re",
")",
",",
"im",
".",
"subtract",
"(",
"value",
".",
"im",
")",
")",
";",
"}"
] | Calculates the subtraction of the given complex value from this complex number.
<p>This methods <strong>does not</strong> modify this instance.</p>
@param value the {@link BigComplex} value to subtract
@return the calculated {@link BigComplex} result | [
"Calculates",
"the",
"subtraction",
"of",
"the",
"given",
"complex",
"value",
"from",
"this",
"complex",
"number",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L131-L135 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.multiply | public BigComplex multiply(BigComplex value) {
return valueOf(
re.multiply(value.re).subtract(im.multiply(value.im)),
re.multiply(value.im).add(im.multiply(value.re)));
} | java | public BigComplex multiply(BigComplex value) {
return valueOf(
re.multiply(value.re).subtract(im.multiply(value.im)),
re.multiply(value.im).add(im.multiply(value.re)));
} | [
"public",
"BigComplex",
"multiply",
"(",
"BigComplex",
"value",
")",
"{",
"return",
"valueOf",
"(",
"re",
".",
"multiply",
"(",
"value",
".",
"re",
")",
".",
"subtract",
"(",
"im",
".",
"multiply",
"(",
"value",
".",
"im",
")",
")",
",",
"re",
".",
... | Calculates the multiplication of the given complex value to this complex number.
<p>This methods <strong>does not</strong> modify this instance.</p>
@param value the {@link BigComplex} value to multiply
@return the calculated {@link BigComplex} result | [
"Calculates",
"the",
"multiplication",
"of",
"the",
"given",
"complex",
"value",
"to",
"this",
"complex",
"number",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L201-L205 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.absSquare | public BigDecimal absSquare(MathContext mathContext) {
return re.multiply(re, mathContext).add(im.multiply(im, mathContext), mathContext);
} | java | public BigDecimal absSquare(MathContext mathContext) {
return re.multiply(re, mathContext).add(im.multiply(im, mathContext), mathContext);
} | [
"public",
"BigDecimal",
"absSquare",
"(",
"MathContext",
"mathContext",
")",
"{",
"return",
"re",
".",
"multiply",
"(",
"re",
",",
"mathContext",
")",
".",
"add",
"(",
"im",
".",
"multiply",
"(",
"im",
",",
"mathContext",
")",
",",
"mathContext",
")",
";... | Calculates the square of the absolute value of this complex number.
<p>This method is faster than {@link #abs(MathContext)} since it does not need to calculate the {@link BigDecimalMath#sqrt(BigDecimal, MathContext)}.</p>
<p>This methods <strong>does not</strong> modify this instance.</p>
@param mathContext the {@link MathContext} used to calculate the result
@return the calculated {@link BigComplex} result
@see #abs(MathContext) | [
"Calculates",
"the",
"square",
"of",
"the",
"absolute",
"value",
"of",
"this",
"complex",
"number",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L379-L381 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.round | public BigComplex round(MathContext mathContext) {
return valueOf(re.round(mathContext), im.round(mathContext));
} | java | public BigComplex round(MathContext mathContext) {
return valueOf(re.round(mathContext), im.round(mathContext));
} | [
"public",
"BigComplex",
"round",
"(",
"MathContext",
"mathContext",
")",
"{",
"return",
"valueOf",
"(",
"re",
".",
"round",
"(",
"mathContext",
")",
",",
"im",
".",
"round",
"(",
"mathContext",
")",
")",
";",
"}"
] | Returns this complex nuber rounded to the specified precision.
<p>This methods <strong>does not</strong> modify this instance.</p>
@param mathContext the {@link MathContext} used to calculate the result
@return the rounded {@link BigComplex} result | [
"Returns",
"this",
"complex",
"nuber",
"rounded",
"to",
"the",
"specified",
"precision",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L418-L420 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java | BigComplex.strictEquals | public boolean strictEquals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BigComplex other = (BigComplex) obj;
return re.equals(other.re) && im.equals(other.im);
} | java | public boolean strictEquals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BigComplex other = (BigComplex) obj;
return re.equals(other.re) && im.equals(other.im);
} | [
"public",
"boolean",
"strictEquals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"this",
"==",
"obj",
")",
"return",
"true",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"getClass",
"(",
")",
"!=",
"obj",
".",
"getCla... | Returns whether the real and imaginary parts of this complex number are strictly equal.
<p>This method uses the strict equality as defined by {@link BigDecimal#equals(Object)} on the real and imaginary parts.</p>
<p>Please note that {@link #equals(Object) BigComplex.equals(Object)} implements <strong>mathematical</strong> equality instead
(by calling {@link BigDecimal#compareTo(BigDecimal) on the real and imaginary parts}).</p>
@param obj the object to compare for strict equality
@return {@code true} if the specified object is strictly equal to this complex number
@see #equals(Object) | [
"Returns",
"whether",
"the",
"real",
"and",
"imaginary",
"parts",
"of",
"this",
"complex",
"number",
"are",
"strictly",
"equal",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigComplex.java#L460-L470 | train |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/internal/SeriesCalculator.java | SeriesCalculator.getFactor | protected BigRational getFactor(int index) {
while (factors.size() <= index) {
BigRational factor = getCurrentFactor();
factors.add(factor);
calculateNextFactor();
}
return factors.get(index);
} | java | protected BigRational getFactor(int index) {
while (factors.size() <= index) {
BigRational factor = getCurrentFactor();
factors.add(factor);
calculateNextFactor();
}
return factors.get(index);
} | [
"protected",
"BigRational",
"getFactor",
"(",
"int",
"index",
")",
"{",
"while",
"(",
"factors",
".",
"size",
"(",
")",
"<=",
"index",
")",
"{",
"BigRational",
"factor",
"=",
"getCurrentFactor",
"(",
")",
";",
"factors",
".",
"add",
"(",
"factor",
")",
... | Returns the factor of the term with specified index.
@param index the index (starting with 0)
@return the factor of the specified term | [
"Returns",
"the",
"factor",
"of",
"the",
"term",
"with",
"specified",
"index",
"."
] | 52c4fc334d0d722b295de740c1018ee400e3e8f2 | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/internal/SeriesCalculator.java#L95-L102 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFField.java | DBFField.createField | protected static DBFField createField(DataInput in, Charset charset, boolean useFieldFlags) throws IOException {
DBFField field = new DBFField();
byte t_byte = in.readByte(); /* 0 */
if (t_byte == (byte) 0x0d) {
return null;
}
byte[] fieldName = new byte[11];
in.readFully(fieldName, 1, 10); /* 1-10 */
fieldName[0] = t_byte;
int nameNullIndex = fieldName.length -1;
for (int i = 0; i < fieldName.length; i++) {
if (fieldName[i] == (byte) 0) {
nameNullIndex = i;
break;
}
}
field.name = new String(fieldName, 0, nameNullIndex,charset);
try {
field.type = DBFDataType.fromCode(in.readByte()); /* 11 */
} catch (Exception e) {
field.type = DBFDataType.UNKNOWN;
}
field.reserv1 = DBFUtils.readLittleEndianInt(in); /* 12-15 */
field.length = in.readUnsignedByte(); /* 16 */
field.decimalCount = in.readByte(); /* 17 */
field.reserv2 = DBFUtils.readLittleEndianShort(in); /* 18-19 */
field.workAreaId = in.readByte(); /* 20 */
field.reserv3 = DBFUtils.readLittleEndianShort(in); /* 21-22 */
field.setFieldsFlag = in.readByte(); /* 23 */
in.readFully(field.reserv4); /* 24-30 */
field.indexFieldFlag = in.readByte(); /* 31 */
adjustLengthForLongCharSupport(field);
if (!useFieldFlags) {
field.reserv2 = 0;
}
return field;
} | java | protected static DBFField createField(DataInput in, Charset charset, boolean useFieldFlags) throws IOException {
DBFField field = new DBFField();
byte t_byte = in.readByte(); /* 0 */
if (t_byte == (byte) 0x0d) {
return null;
}
byte[] fieldName = new byte[11];
in.readFully(fieldName, 1, 10); /* 1-10 */
fieldName[0] = t_byte;
int nameNullIndex = fieldName.length -1;
for (int i = 0; i < fieldName.length; i++) {
if (fieldName[i] == (byte) 0) {
nameNullIndex = i;
break;
}
}
field.name = new String(fieldName, 0, nameNullIndex,charset);
try {
field.type = DBFDataType.fromCode(in.readByte()); /* 11 */
} catch (Exception e) {
field.type = DBFDataType.UNKNOWN;
}
field.reserv1 = DBFUtils.readLittleEndianInt(in); /* 12-15 */
field.length = in.readUnsignedByte(); /* 16 */
field.decimalCount = in.readByte(); /* 17 */
field.reserv2 = DBFUtils.readLittleEndianShort(in); /* 18-19 */
field.workAreaId = in.readByte(); /* 20 */
field.reserv3 = DBFUtils.readLittleEndianShort(in); /* 21-22 */
field.setFieldsFlag = in.readByte(); /* 23 */
in.readFully(field.reserv4); /* 24-30 */
field.indexFieldFlag = in.readByte(); /* 31 */
adjustLengthForLongCharSupport(field);
if (!useFieldFlags) {
field.reserv2 = 0;
}
return field;
} | [
"protected",
"static",
"DBFField",
"createField",
"(",
"DataInput",
"in",
",",
"Charset",
"charset",
",",
"boolean",
"useFieldFlags",
")",
"throws",
"IOException",
"{",
"DBFField",
"field",
"=",
"new",
"DBFField",
"(",
")",
";",
"byte",
"t_byte",
"=",
"in",
... | Creates a DBFField object from the data read from the given
DataInputStream.
The data in the DataInputStream object is supposed to be organised
correctly and the stream "pointer" is supposed to be positioned properly.
@param in DataInputStream
@param charset charset to use
@param useFieldFlags If the file can store field flags (setting this to false ignore any data in byes 18-19)
@return Returns the created DBFField object.
@throws IOException If any stream reading problems occures. | [
"Creates",
"a",
"DBFField",
"object",
"from",
"the",
"data",
"read",
"from",
"the",
"given",
"DataInputStream",
"."
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFField.java#L173-L213 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFField.java | DBFField.write | protected void write(DataOutput out, Charset charset) throws IOException {
// Field Name
out.write(this.name.getBytes(charset)); /* 0-10 */
out.write(new byte[11 - this.name.length()]);
// data type
out.writeByte(this.type.getCode()); /* 11 */
out.writeInt(0x00); /* 12-15 */
out.writeByte(this.length); /* 16 */
out.writeByte(this.decimalCount); /* 17 */
out.writeShort((short) 0x00); /* 18-19 */
out.writeByte((byte) 0x00); /* 20 */
out.writeShort((short) 0x00); /* 21-22 */
out.writeByte((byte) 0x00); /* 23 */
out.write(new byte[7]); /* 24-30 */
out.writeByte((byte) 0x00); /* 31 */
} | java | protected void write(DataOutput out, Charset charset) throws IOException {
// Field Name
out.write(this.name.getBytes(charset)); /* 0-10 */
out.write(new byte[11 - this.name.length()]);
// data type
out.writeByte(this.type.getCode()); /* 11 */
out.writeInt(0x00); /* 12-15 */
out.writeByte(this.length); /* 16 */
out.writeByte(this.decimalCount); /* 17 */
out.writeShort((short) 0x00); /* 18-19 */
out.writeByte((byte) 0x00); /* 20 */
out.writeShort((short) 0x00); /* 21-22 */
out.writeByte((byte) 0x00); /* 23 */
out.write(new byte[7]); /* 24-30 */
out.writeByte((byte) 0x00); /* 31 */
} | [
"protected",
"void",
"write",
"(",
"DataOutput",
"out",
",",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"// Field Name",
"out",
".",
"write",
"(",
"this",
".",
"name",
".",
"getBytes",
"(",
"charset",
")",
")",
";",
"/* 0-10 */",
"out",
".",
... | Writes the content of DBFField object into the stream as per DBF format
specifications.
@param out OutputStream
@param charset dbf file's charset
@throws IOException if any stream related issues occur. | [
"Writes",
"the",
"content",
"of",
"DBFField",
"object",
"into",
"the",
"stream",
"as",
"per",
"DBF",
"format",
"specifications",
"."
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFField.java#L271-L287 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFField.java | DBFField.setName | public void setName(String name) {
if (name == null) {
throw new IllegalArgumentException("Field name cannot be null");
}
if (name.length() == 0 || name.length() > 10) {
throw new IllegalArgumentException("Field name should be of length 0-10");
}
if (!DBFUtils.isPureAscii(name)) {
throw new IllegalArgumentException("Field name must be ASCII");
}
this.name = name;
} | java | public void setName(String name) {
if (name == null) {
throw new IllegalArgumentException("Field name cannot be null");
}
if (name.length() == 0 || name.length() > 10) {
throw new IllegalArgumentException("Field name should be of length 0-10");
}
if (!DBFUtils.isPureAscii(name)) {
throw new IllegalArgumentException("Field name must be ASCII");
}
this.name = name;
} | [
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Field name cannot be null\"",
")",
";",
"}",
"if",
"(",
"name",
".",
"length",
"(",
")",
"==",
"0... | Sets the name of the field.
@param name of the field as String.
@since 0.3.3.1 | [
"Sets",
"the",
"name",
"of",
"the",
"field",
"."
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFField.java#L333-L345 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFField.java | DBFField.setType | public void setType(DBFDataType type) {
if (!type.isWriteSupported()) {
throw new IllegalArgumentException("No support for writting " + type);
}
this.type = type;
if (type.getDefaultSize() > 0) {
this.length = type.getDefaultSize();
}
} | java | public void setType(DBFDataType type) {
if (!type.isWriteSupported()) {
throw new IllegalArgumentException("No support for writting " + type);
}
this.type = type;
if (type.getDefaultSize() > 0) {
this.length = type.getDefaultSize();
}
} | [
"public",
"void",
"setType",
"(",
"DBFDataType",
"type",
")",
"{",
"if",
"(",
"!",
"type",
".",
"isWriteSupported",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No support for writting \"",
"+",
"type",
")",
";",
"}",
"this",
".",
... | Set the type for this field
@param type The type for this field
@throws IllegalArgumentException if type is not write supported | [
"Set",
"the",
"type",
"for",
"this",
"field"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFField.java#L424-L433 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFCharsetHelper.java | DBFCharsetHelper.getCharsetByByte | public static Charset getCharsetByByte(int b) {
switch (b) {
case 0x01:
// U.S. MS-DOS
return forName("IBM437");
case 0x02:
// International MS-DOS
return forName("IBM850");
case 0x03:
// Windows ANSI
return forName("windows-1252");
case 0x04:
// Standard Macintosh
return forName("MacRoman");
case 0x57:
// ESRI shape files use code 0x57 to indicate that
// data is written in ANSI (whatever that means).
// http://www.esricanada.com/english/support/faqs/arcview/avfaq21.asp
return forName("windows-1252");
case 0x59:
return forName("windows-1252");
case 0x64:
// Eastern European MS-DOS
return forName("IBM852");
case 0x65:
// Russian MS-DOS
return forName("IBM866");
case 0x66:
// Nordic MS-DOS
return forName("IBM865");
case 0x67:
// Icelandic MS-DOS
return forName("IBM861");
// case 0x68:
// Kamenicky (Czech) MS-DOS
// return Charset.forName("895");
// case 0x69:
// Mazovia (Polish) MS-DOS
// return Charset.forName("620");
case 0x6A:
// Greek MS-DOS (437G)
return forName("x-IBM737");
case 0x6B:
// Turkish MS-DOS
return forName("IBM857");
case 0x78:
// Chinese (Hong Kong SAR, Taiwan) Windows
return forName("windows-950");
case 0x79:
// Korean Windows
return Charset.forName("windows-949");
case 0x7A:
// Chinese (PRC, Singapore) Windows
return forName("GBK");
case 0x7B:
// Japanese Windows
return forName("windows-932");
case 0x7C:
// Thai Windows
return forName("windows-874");
case 0x7D:
// Hebrew Windows
return forName("windows-1255");
case 0x7E:
// Arabic Windows
return forName("windows-1256");
case 0x96:
// Russian Macintosh
return forName("x-MacCyrillic");
case 0x97:
// Macintosh EE
return forName("x-MacCentralEurope");
case 0x98:
// Greek Macintosh
return forName("x-MacGreek");
case 0xC8:
// Eastern European Windows
return forName("windows-1250");
case 0xC9:
// Russian Windows
return forName("windows-1251");
case 0xCA:
// Turkish Windows
return forName("windows-1254");
case 0xCB:
// Greek Windows
return forName("windows-1253");
}
return null;
} | java | public static Charset getCharsetByByte(int b) {
switch (b) {
case 0x01:
// U.S. MS-DOS
return forName("IBM437");
case 0x02:
// International MS-DOS
return forName("IBM850");
case 0x03:
// Windows ANSI
return forName("windows-1252");
case 0x04:
// Standard Macintosh
return forName("MacRoman");
case 0x57:
// ESRI shape files use code 0x57 to indicate that
// data is written in ANSI (whatever that means).
// http://www.esricanada.com/english/support/faqs/arcview/avfaq21.asp
return forName("windows-1252");
case 0x59:
return forName("windows-1252");
case 0x64:
// Eastern European MS-DOS
return forName("IBM852");
case 0x65:
// Russian MS-DOS
return forName("IBM866");
case 0x66:
// Nordic MS-DOS
return forName("IBM865");
case 0x67:
// Icelandic MS-DOS
return forName("IBM861");
// case 0x68:
// Kamenicky (Czech) MS-DOS
// return Charset.forName("895");
// case 0x69:
// Mazovia (Polish) MS-DOS
// return Charset.forName("620");
case 0x6A:
// Greek MS-DOS (437G)
return forName("x-IBM737");
case 0x6B:
// Turkish MS-DOS
return forName("IBM857");
case 0x78:
// Chinese (Hong Kong SAR, Taiwan) Windows
return forName("windows-950");
case 0x79:
// Korean Windows
return Charset.forName("windows-949");
case 0x7A:
// Chinese (PRC, Singapore) Windows
return forName("GBK");
case 0x7B:
// Japanese Windows
return forName("windows-932");
case 0x7C:
// Thai Windows
return forName("windows-874");
case 0x7D:
// Hebrew Windows
return forName("windows-1255");
case 0x7E:
// Arabic Windows
return forName("windows-1256");
case 0x96:
// Russian Macintosh
return forName("x-MacCyrillic");
case 0x97:
// Macintosh EE
return forName("x-MacCentralEurope");
case 0x98:
// Greek Macintosh
return forName("x-MacGreek");
case 0xC8:
// Eastern European Windows
return forName("windows-1250");
case 0xC9:
// Russian Windows
return forName("windows-1251");
case 0xCA:
// Turkish Windows
return forName("windows-1254");
case 0xCB:
// Greek Windows
return forName("windows-1253");
}
return null;
} | [
"public",
"static",
"Charset",
"getCharsetByByte",
"(",
"int",
"b",
")",
"{",
"switch",
"(",
"b",
")",
"{",
"case",
"0x01",
":",
"// U.S. MS-DOS",
"return",
"forName",
"(",
"\"IBM437\"",
")",
";",
"case",
"0x02",
":",
"// International MS-DOS",
"return",
"fo... | Gets Java charset from DBF code
@param b the code stored in DBF file
@return Java charset, null if unknown. | [
"Gets",
"Java",
"charset",
"from",
"DBF",
"code"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFCharsetHelper.java#L47-L138 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFCharsetHelper.java | DBFCharsetHelper.getDBFCodeForCharset | public static int getDBFCodeForCharset(Charset charset) {
if (charset == null) {
return 0;
}
String charsetName = charset.toString();
if ("ibm437".equalsIgnoreCase(charsetName)) {
return 0x01;
}
if ("ibm850".equalsIgnoreCase(charsetName)) {
return 0x02;
}
if ("windows-1252".equalsIgnoreCase(charsetName)) {
return 0x03;
}
if ("iso-8859-1".equalsIgnoreCase(charsetName)) {
return 0x03;
}
if ("MacRoman".equalsIgnoreCase(charsetName)) {
return 0x04;
}
if ("IBM852".equalsIgnoreCase(charsetName)) {
return 0x64;
}
if ("IBM865".equalsIgnoreCase(charsetName)) {
return 0x66;
}
if ("IBM866".equalsIgnoreCase(charsetName)) {
return 0x65;
}
if ("IBM861".equalsIgnoreCase(charsetName)) {
return 0x67;
}
// 0x68
// 0x69
if ("IBM737".equalsIgnoreCase(charsetName)) {
return 0x6a;
}
if ("IBM857".equalsIgnoreCase(charsetName)) {
return 0x6b;
}
if ("windows-950".equalsIgnoreCase(charsetName)) {
return 0x78;
}
if ("windows-949".equalsIgnoreCase(charsetName)) {
return 0x79;
}
if ("gbk".equalsIgnoreCase(charsetName)) {
return 0x7a;
}
if ("windows-932".equalsIgnoreCase(charsetName)) {
return 0x7b;
}
if ("windows-874".equalsIgnoreCase(charsetName)) {
return 0x7c;
}
if ("windows-1255".equalsIgnoreCase(charsetName)) {
return 0x7d;
}
if ("windows-1256".equalsIgnoreCase(charsetName)) {
return 0x7e;
}
if ("x-MacCyrillic".equalsIgnoreCase(charsetName)) {
return 0x96;
}
if ("x-MacCentralEurope".equalsIgnoreCase(charsetName)) {
return 0x97;
}
if ("x-MacGreek".equalsIgnoreCase(charsetName)) {
return 0x98;
}
if ("windows-1250".equalsIgnoreCase(charsetName)) {
return 0xc8;
}
if ("windows-1251".equalsIgnoreCase(charsetName)) {
return 0xc9;
}
if ("windows-1254".equalsIgnoreCase(charsetName)) {
return 0xca;
}
if ("windows-1253".equalsIgnoreCase(charsetName)) {
return 0xcb;
}
// Unsupported charsets returns 0
return 0;
} | java | public static int getDBFCodeForCharset(Charset charset) {
if (charset == null) {
return 0;
}
String charsetName = charset.toString();
if ("ibm437".equalsIgnoreCase(charsetName)) {
return 0x01;
}
if ("ibm850".equalsIgnoreCase(charsetName)) {
return 0x02;
}
if ("windows-1252".equalsIgnoreCase(charsetName)) {
return 0x03;
}
if ("iso-8859-1".equalsIgnoreCase(charsetName)) {
return 0x03;
}
if ("MacRoman".equalsIgnoreCase(charsetName)) {
return 0x04;
}
if ("IBM852".equalsIgnoreCase(charsetName)) {
return 0x64;
}
if ("IBM865".equalsIgnoreCase(charsetName)) {
return 0x66;
}
if ("IBM866".equalsIgnoreCase(charsetName)) {
return 0x65;
}
if ("IBM861".equalsIgnoreCase(charsetName)) {
return 0x67;
}
// 0x68
// 0x69
if ("IBM737".equalsIgnoreCase(charsetName)) {
return 0x6a;
}
if ("IBM857".equalsIgnoreCase(charsetName)) {
return 0x6b;
}
if ("windows-950".equalsIgnoreCase(charsetName)) {
return 0x78;
}
if ("windows-949".equalsIgnoreCase(charsetName)) {
return 0x79;
}
if ("gbk".equalsIgnoreCase(charsetName)) {
return 0x7a;
}
if ("windows-932".equalsIgnoreCase(charsetName)) {
return 0x7b;
}
if ("windows-874".equalsIgnoreCase(charsetName)) {
return 0x7c;
}
if ("windows-1255".equalsIgnoreCase(charsetName)) {
return 0x7d;
}
if ("windows-1256".equalsIgnoreCase(charsetName)) {
return 0x7e;
}
if ("x-MacCyrillic".equalsIgnoreCase(charsetName)) {
return 0x96;
}
if ("x-MacCentralEurope".equalsIgnoreCase(charsetName)) {
return 0x97;
}
if ("x-MacGreek".equalsIgnoreCase(charsetName)) {
return 0x98;
}
if ("windows-1250".equalsIgnoreCase(charsetName)) {
return 0xc8;
}
if ("windows-1251".equalsIgnoreCase(charsetName)) {
return 0xc9;
}
if ("windows-1254".equalsIgnoreCase(charsetName)) {
return 0xca;
}
if ("windows-1253".equalsIgnoreCase(charsetName)) {
return 0xcb;
}
// Unsupported charsets returns 0
return 0;
} | [
"public",
"static",
"int",
"getDBFCodeForCharset",
"(",
"Charset",
"charset",
")",
"{",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"String",
"charsetName",
"=",
"charset",
".",
"toString",
"(",
")",
";",
"if",
"(",
"\"ibm437\"... | gets the DBF code for a given Java charset
@param charset the Java charset
@return the DBF code, 0 if unknown | [
"gets",
"the",
"DBF",
"code",
"for",
"a",
"given",
"Java",
"charset"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFCharsetHelper.java#L153-L242 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFHeader.java | DBFHeader.getLastModificationDate | public Date getLastModificationDate() {
if (this.year == 0 || this.month == 0 || this.day == 0){
return null;
}
try {
Calendar calendar = Calendar.getInstance();
calendar.set(this.year, this.month, this.day, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
catch (Exception e) {
return null;
}
} | java | public Date getLastModificationDate() {
if (this.year == 0 || this.month == 0 || this.day == 0){
return null;
}
try {
Calendar calendar = Calendar.getInstance();
calendar.set(this.year, this.month, this.day, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
catch (Exception e) {
return null;
}
} | [
"public",
"Date",
"getLastModificationDate",
"(",
")",
"{",
"if",
"(",
"this",
".",
"year",
"==",
"0",
"||",
"this",
".",
"month",
"==",
"0",
"||",
"this",
".",
"day",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"Calendar",
"calend... | Gets the date the file was modified
@return The date de file was created | [
"Gets",
"the",
"date",
"the",
"file",
"was",
"modified"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFHeader.java#L281-L294 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.readNumericStoredAsText | public static Number readNumericStoredAsText(DataInputStream dataInput, int length) throws IOException {
try {
byte t_float[] = new byte[length];
int readed = dataInput.read(t_float);
if (readed != length) {
throw new EOFException("failed to read:" + length + " bytes");
}
t_float = DBFUtils.removeSpaces(t_float);
t_float = DBFUtils.removeNullBytes(t_float);
if (t_float.length > 0 && DBFUtils.isPureAscii(t_float) && !DBFUtils.contains(t_float, (byte) '?') && !DBFUtils.contains(t_float, (byte) '*')) {
String aux = new String(t_float, StandardCharsets.US_ASCII).replace(',', '.');
if (".".equals(aux)) {
return BigDecimal.ZERO;
}
return new BigDecimal(aux);
} else {
return null;
}
} catch (NumberFormatException e) {
throw new DBFException("Failed to parse Float: " + e.getMessage(), e);
}
} | java | public static Number readNumericStoredAsText(DataInputStream dataInput, int length) throws IOException {
try {
byte t_float[] = new byte[length];
int readed = dataInput.read(t_float);
if (readed != length) {
throw new EOFException("failed to read:" + length + " bytes");
}
t_float = DBFUtils.removeSpaces(t_float);
t_float = DBFUtils.removeNullBytes(t_float);
if (t_float.length > 0 && DBFUtils.isPureAscii(t_float) && !DBFUtils.contains(t_float, (byte) '?') && !DBFUtils.contains(t_float, (byte) '*')) {
String aux = new String(t_float, StandardCharsets.US_ASCII).replace(',', '.');
if (".".equals(aux)) {
return BigDecimal.ZERO;
}
return new BigDecimal(aux);
} else {
return null;
}
} catch (NumberFormatException e) {
throw new DBFException("Failed to parse Float: " + e.getMessage(), e);
}
} | [
"public",
"static",
"Number",
"readNumericStoredAsText",
"(",
"DataInputStream",
"dataInput",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"try",
"{",
"byte",
"t_float",
"[",
"]",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"int",
"readed",
"=",... | Reads a number from a stream,
@param dataInput the stream data
@param length the legth of the number
@return The number as a Number (BigDecimal)
@throws IOException if an IO error happens
@throws EOFException if reached end of file before length bytes | [
"Reads",
"a",
"number",
"from",
"a",
"stream"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L62-L83 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.littleEndian | public static int littleEndian(int value) {
int num1 = value;
int mask = 0xff;
int num2 = 0x00;
num2 |= num1 & mask;
for (int i = 1; i < 4; i++) {
num2 <<= 8;
mask <<= 8;
num2 |= (num1 & mask) >> (8 * i);
}
return num2;
} | java | public static int littleEndian(int value) {
int num1 = value;
int mask = 0xff;
int num2 = 0x00;
num2 |= num1 & mask;
for (int i = 1; i < 4; i++) {
num2 <<= 8;
mask <<= 8;
num2 |= (num1 & mask) >> (8 * i);
}
return num2;
} | [
"public",
"static",
"int",
"littleEndian",
"(",
"int",
"value",
")",
"{",
"int",
"num1",
"=",
"value",
";",
"int",
"mask",
"=",
"0xff",
";",
"int",
"num2",
"=",
"0x00",
";",
"num2",
"|=",
"num1",
"&",
"mask",
";",
"for",
"(",
"int",
"i",
"=",
"1"... | Convert an int value to littleEndian
@param value value to be converted
@return littleEndian int | [
"Convert",
"an",
"int",
"value",
"to",
"littleEndian"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L166-L181 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.doubleFormating | public static byte[] doubleFormating(Number num, Charset charset, int fieldLength, int sizeDecimalPart) {
int sizeWholePart = fieldLength - (sizeDecimalPart > 0 ? (sizeDecimalPart + 1) : 0);
StringBuilder format = new StringBuilder(fieldLength);
for (int i = 0; i < sizeWholePart-1; i++) {
format.append("#");
}
if (format.length() < sizeWholePart) {
format.append("0");
}
if (sizeDecimalPart > 0) {
format.append(".");
for (int i = 0; i < sizeDecimalPart; i++) {
format.append("0");
}
}
DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(Locale.ENGLISH);
df.applyPattern(format.toString());
return textPadding(df.format(num).toString(), charset, fieldLength, DBFAlignment.RIGHT,
(byte) ' ');
} | java | public static byte[] doubleFormating(Number num, Charset charset, int fieldLength, int sizeDecimalPart) {
int sizeWholePart = fieldLength - (sizeDecimalPart > 0 ? (sizeDecimalPart + 1) : 0);
StringBuilder format = new StringBuilder(fieldLength);
for (int i = 0; i < sizeWholePart-1; i++) {
format.append("#");
}
if (format.length() < sizeWholePart) {
format.append("0");
}
if (sizeDecimalPart > 0) {
format.append(".");
for (int i = 0; i < sizeDecimalPart; i++) {
format.append("0");
}
}
DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(Locale.ENGLISH);
df.applyPattern(format.toString());
return textPadding(df.format(num).toString(), charset, fieldLength, DBFAlignment.RIGHT,
(byte) ' ');
} | [
"public",
"static",
"byte",
"[",
"]",
"doubleFormating",
"(",
"Number",
"num",
",",
"Charset",
"charset",
",",
"int",
"fieldLength",
",",
"int",
"sizeDecimalPart",
")",
"{",
"int",
"sizeWholePart",
"=",
"fieldLength",
"-",
"(",
"sizeDecimalPart",
">",
"0",
"... | Format a double number to write to a dbf file
@param num number to format
@param charset charset to use
@param fieldLength field length
@param sizeDecimalPart decimal part size
@return bytes to write to the dbf file | [
"Format",
"a",
"double",
"number",
"to",
"write",
"to",
"a",
"dbf",
"file"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L237-L258 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.contains | public static boolean contains(byte[] array, byte value) {
if (array != null) {
for (byte data : array) {
if (data == value) {
return true;
}
}
}
return false;
} | java | public static boolean contains(byte[] array, byte value) {
if (array != null) {
for (byte data : array) {
if (data == value) {
return true;
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"contains",
"(",
"byte",
"[",
"]",
"array",
",",
"byte",
"value",
")",
"{",
"if",
"(",
"array",
"!=",
"null",
")",
"{",
"for",
"(",
"byte",
"data",
":",
"array",
")",
"{",
"if",
"(",
"data",
"==",
"value",
")",
"{",... | Checks that a byte array contains some specific byte
@param array The array to search in
@param value The byte to search for
@return true if the array contains spcified value | [
"Checks",
"that",
"a",
"byte",
"array",
"contains",
"some",
"specific",
"byte"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L266-L275 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.isPureAscii | public static boolean isPureAscii(String stringToCheck) {
if (stringToCheck == null || stringToCheck.length() == 0) {
return true;
}
synchronized (ASCII_ENCODER) {
return ASCII_ENCODER.canEncode(stringToCheck);
}
} | java | public static boolean isPureAscii(String stringToCheck) {
if (stringToCheck == null || stringToCheck.length() == 0) {
return true;
}
synchronized (ASCII_ENCODER) {
return ASCII_ENCODER.canEncode(stringToCheck);
}
} | [
"public",
"static",
"boolean",
"isPureAscii",
"(",
"String",
"stringToCheck",
")",
"{",
"if",
"(",
"stringToCheck",
"==",
"null",
"||",
"stringToCheck",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"synchronized",
"(",
"ASCII_E... | Checks if a string is pure Ascii
@param stringToCheck the string
@return true if is ascci | [
"Checks",
"if",
"a",
"string",
"is",
"pure",
"Ascii"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L282-L289 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.isPureAscii | public static boolean isPureAscii(byte[] data) {
if (data == null) {
return false;
}
for (byte b : data) {
if (b < 0x20) {
return false;
}
}
return true;
} | java | public static boolean isPureAscii(byte[] data) {
if (data == null) {
return false;
}
for (byte b : data) {
if (b < 0x20) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isPureAscii",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"byte",
"b",
":",
"data",
")",
"{",
"if",
"(",
"b",
"<",
"0x20",
")",
"{"... | Test if the data in the array is pure ASCII
@param data data to check
@return true if there are only ASCII characters | [
"Test",
"if",
"the",
"data",
"in",
"the",
"array",
"is",
"pure",
"ASCII"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L296-L306 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFUtils.java | DBFUtils.trimRightSpaces | public static byte[] trimRightSpaces(byte[] b_array) {
if (b_array == null || b_array.length == 0) {
return new byte[0];
}
int pos = getRightPos(b_array);
int length = pos + 1;
byte[] newBytes = new byte[length];
System.arraycopy(b_array, 0, newBytes, 0, length);
return newBytes;
} | java | public static byte[] trimRightSpaces(byte[] b_array) {
if (b_array == null || b_array.length == 0) {
return new byte[0];
}
int pos = getRightPos(b_array);
int length = pos + 1;
byte[] newBytes = new byte[length];
System.arraycopy(b_array, 0, newBytes, 0, length);
return newBytes;
} | [
"public",
"static",
"byte",
"[",
"]",
"trimRightSpaces",
"(",
"byte",
"[",
"]",
"b_array",
")",
"{",
"if",
"(",
"b_array",
"==",
"null",
"||",
"b_array",
".",
"length",
"==",
"0",
")",
"{",
"return",
"new",
"byte",
"[",
"0",
"]",
";",
"}",
"int",
... | Trims right spaces from string
@param b_array the string
@return the string without right spaces | [
"Trims",
"right",
"spaces",
"from",
"string"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFUtils.java#L327-L336 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFWriter.java | DBFWriter.setFields | public void setFields(DBFField[] fields) {
if (this.closed) {
throw new IllegalStateException("You can not set fields to a closed DBFWriter");
}
if (this.header.fieldArray != null) {
throw new DBFException("Fields has already been set");
}
if (fields == null || fields.length == 0) {
throw new DBFException("Should have at least one field");
}
for (int i = 0; i < fields.length; i++) {
if (fields[i] == null) {
throw new DBFException("Field " + i + " is null");
}
}
this.header.fieldArray = new DBFField[fields.length];
for (int i = 0; i < fields.length; i++) {
this.header.fieldArray[i] = new DBFField(fields[i]);
}
try {
if (this.raf != null && this.raf.length() == 0) {
// this is a new/non-existent file. So write header before proceeding
this.header.write(this.raf);
}
} catch (IOException e) {
throw new DBFException("Error accesing file:" + e.getMessage(), e);
}
} | java | public void setFields(DBFField[] fields) {
if (this.closed) {
throw new IllegalStateException("You can not set fields to a closed DBFWriter");
}
if (this.header.fieldArray != null) {
throw new DBFException("Fields has already been set");
}
if (fields == null || fields.length == 0) {
throw new DBFException("Should have at least one field");
}
for (int i = 0; i < fields.length; i++) {
if (fields[i] == null) {
throw new DBFException("Field " + i + " is null");
}
}
this.header.fieldArray = new DBFField[fields.length];
for (int i = 0; i < fields.length; i++) {
this.header.fieldArray[i] = new DBFField(fields[i]);
}
try {
if (this.raf != null && this.raf.length() == 0) {
// this is a new/non-existent file. So write header before proceeding
this.header.write(this.raf);
}
} catch (IOException e) {
throw new DBFException("Error accesing file:" + e.getMessage(), e);
}
} | [
"public",
"void",
"setFields",
"(",
"DBFField",
"[",
"]",
"fields",
")",
"{",
"if",
"(",
"this",
".",
"closed",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You can not set fields to a closed DBFWriter\"",
")",
";",
"}",
"if",
"(",
"this",
".",
... | Sets fields definition
@param fields fields definition | [
"Sets",
"fields",
"definition"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFWriter.java#L183-L210 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFWriter.java | DBFWriter.addRecord | public void addRecord(Object[] values) {
if (this.closed) {
throw new IllegalStateException("You can add records a closed DBFWriter");
}
if (this.header.fieldArray == null) {
throw new DBFException("Fields should be set before adding records");
}
if (values == null) {
throw new DBFException("Null cannot be added as row");
}
if (values.length != this.header.fieldArray.length) {
throw new DBFException("Invalid record. Invalid number of fields in row");
}
for (int i = 0; i < this.header.fieldArray.length; i++) {
Object value = values[i];
if (value == null) {
continue;
}
switch (this.header.fieldArray[i].getType()) {
case CHARACTER:
if (!(value instanceof String)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case LOGICAL:
if (!(value instanceof Boolean)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case DATE:
if (!(value instanceof Date)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case NUMERIC:
case FLOATING_POINT:
if (!(value instanceof Number)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
default:
throw new DBFException("Unsupported writting of field type " + i + " "
+ this.header.fieldArray[i].getType());
}
}
if (this.raf == null) {
this.v_records.add(values);
} else {
try {
writeRecord(this.raf, values);
this.recordCount++;
} catch (IOException e) {
throw new DBFException("Error occured while writing record. " + e.getMessage(), e);
}
}
} | java | public void addRecord(Object[] values) {
if (this.closed) {
throw new IllegalStateException("You can add records a closed DBFWriter");
}
if (this.header.fieldArray == null) {
throw new DBFException("Fields should be set before adding records");
}
if (values == null) {
throw new DBFException("Null cannot be added as row");
}
if (values.length != this.header.fieldArray.length) {
throw new DBFException("Invalid record. Invalid number of fields in row");
}
for (int i = 0; i < this.header.fieldArray.length; i++) {
Object value = values[i];
if (value == null) {
continue;
}
switch (this.header.fieldArray[i].getType()) {
case CHARACTER:
if (!(value instanceof String)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case LOGICAL:
if (!(value instanceof Boolean)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case DATE:
if (!(value instanceof Date)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
case NUMERIC:
case FLOATING_POINT:
if (!(value instanceof Number)) {
throw new DBFException("Invalid value for field " + i + ":" + value);
}
break;
default:
throw new DBFException("Unsupported writting of field type " + i + " "
+ this.header.fieldArray[i].getType());
}
}
if (this.raf == null) {
this.v_records.add(values);
} else {
try {
writeRecord(this.raf, values);
this.recordCount++;
} catch (IOException e) {
throw new DBFException("Error occured while writing record. " + e.getMessage(), e);
}
}
} | [
"public",
"void",
"addRecord",
"(",
"Object",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"this",
".",
"closed",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You can add records a closed DBFWriter\"",
")",
";",
"}",
"if",
"(",
"this",
".",
"header... | Add a record.
@param values fields of the record | [
"Add",
"a",
"record",
"."
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFWriter.java#L216-L280 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFWriter.java | DBFWriter.close | @Override
public void close() {
if (this.closed) {
return;
}
this.closed = true;
if (this.raf != null) {
/*
* everything is written already. just update the header for
* record count and the END_OF_DATA mark
*/
try {
this.header.numberOfRecords = this.recordCount;
this.raf.seek(0);
this.header.write(this.raf);
this.raf.seek(this.raf.length());
this.raf.writeByte(END_OF_DATA);
}
catch (IOException e) {
throw new DBFException(e.getMessage(), e);
}
finally {
DBFUtils.close(this.raf);
}
}
else if (this.outputStream != null) {
try {
writeToStream(this.outputStream);
}
finally {
DBFUtils.close(this.outputStream);
}
}
} | java | @Override
public void close() {
if (this.closed) {
return;
}
this.closed = true;
if (this.raf != null) {
/*
* everything is written already. just update the header for
* record count and the END_OF_DATA mark
*/
try {
this.header.numberOfRecords = this.recordCount;
this.raf.seek(0);
this.header.write(this.raf);
this.raf.seek(this.raf.length());
this.raf.writeByte(END_OF_DATA);
}
catch (IOException e) {
throw new DBFException(e.getMessage(), e);
}
finally {
DBFUtils.close(this.raf);
}
}
else if (this.outputStream != null) {
try {
writeToStream(this.outputStream);
}
finally {
DBFUtils.close(this.outputStream);
}
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"this",
".",
"closed",
")",
"{",
"return",
";",
"}",
"this",
".",
"closed",
"=",
"true",
";",
"if",
"(",
"this",
".",
"raf",
"!=",
"null",
")",
"{",
"/*\n\t\t\t * everything is wri... | In sync mode, write the header and close the file | [
"In",
"sync",
"mode",
"write",
"the",
"header",
"and",
"close",
"the",
"file"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFWriter.java#L306-L340 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getString | public String getString(int columnIndex) {
if (columnIndex < 0 || columnIndex >= data.length) {
throw new IllegalArgumentException("Invalid index field: (" + columnIndex+"). Valid range is 0 to " + (data.length - 1));
}
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof String) {
return (String) fieldValue;
}
return fieldValue.toString();
} | java | public String getString(int columnIndex) {
if (columnIndex < 0 || columnIndex >= data.length) {
throw new IllegalArgumentException("Invalid index field: (" + columnIndex+"). Valid range is 0 to " + (data.length - 1));
}
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof String) {
return (String) fieldValue;
}
return fieldValue.toString();
} | [
"public",
"String",
"getString",
"(",
"int",
"columnIndex",
")",
"{",
"if",
"(",
"columnIndex",
"<",
"0",
"||",
"columnIndex",
">=",
"data",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid index field: (\"",
"+",
"columnIndex... | Reads the data as string
@param columnIndex
columnIndex
@return the value converted to String | [
"Reads",
"the",
"data",
"as",
"string"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L106-L118 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getBigDecimal | public BigDecimal getBigDecimal(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof BigDecimal) {
return (BigDecimal) fieldValue;
}
throw new DBFException("Unsupported type for BigDecimal at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public BigDecimal getBigDecimal(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof BigDecimal) {
return (BigDecimal) fieldValue;
}
throw new DBFException("Unsupported type for BigDecimal at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"BigDecimal",
"getBigDecimal",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"fieldValue",
"instance... | Reads the data as BigDecimal
@param columnIndex
columnIndex
@return the data as BigDecimal | [
"Reads",
"the",
"data",
"as",
"BigDecimal"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L138-L148 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getBoolean | public boolean getBoolean(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return Boolean.FALSE;
}
if (fieldValue instanceof Boolean) {
return (Boolean) fieldValue;
}
throw new DBFException("Unsupported type for Boolean at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public boolean getBoolean(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return Boolean.FALSE;
}
if (fieldValue instanceof Boolean) {
return (Boolean) fieldValue;
}
throw new DBFException("Unsupported type for Boolean at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"boolean",
"getBoolean",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"if",
"(",
"fieldValu... | Reads the data as Boolean
@param columnIndex
columnIndex
@return the data as Boolean | [
"Reads",
"the",
"data",
"as",
"Boolean"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L168-L178 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getDate | public Date getDate(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof Date) {
return (Date) fieldValue;
}
throw new DBFException(
"Unsupported type for Date at column:" + columnIndex + " " + fieldValue.getClass().getCanonicalName());
} | java | public Date getDate(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof Date) {
return (Date) fieldValue;
}
throw new DBFException(
"Unsupported type for Date at column:" + columnIndex + " " + fieldValue.getClass().getCanonicalName());
} | [
"public",
"Date",
"getDate",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"fieldValue",
"instanceof",
"Date... | Reads the data as Date
@param columnIndex
columnIndex
@return the data as Date | [
"Reads",
"the",
"data",
"as",
"Date"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L230-L240 | train |
albfernandez/javadbf | src/main/java/com/linuxense/javadbf/DBFRow.java | DBFRow.getDouble | public double getDouble(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0.0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).doubleValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | java | public double getDouble(int columnIndex) {
Object fieldValue = data[columnIndex];
if (fieldValue == null) {
return 0.0;
}
if (fieldValue instanceof Number) {
return ((Number) fieldValue).doubleValue();
}
throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
+ fieldValue.getClass().getCanonicalName());
} | [
"public",
"double",
"getDouble",
"(",
"int",
"columnIndex",
")",
"{",
"Object",
"fieldValue",
"=",
"data",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"fieldValue",
"==",
"null",
")",
"{",
"return",
"0.0",
";",
"}",
"if",
"(",
"fieldValue",
"instanceof",
"N... | Reads the data as Double
@param columnIndex
columnIndex
@return the data as Double | [
"Reads",
"the",
"data",
"as",
"Double"
] | ac9867b46786cb055bce9323e2cf074365207693 | https://github.com/albfernandez/javadbf/blob/ac9867b46786cb055bce9323e2cf074365207693/src/main/java/com/linuxense/javadbf/DBFRow.java#L261-L271 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.