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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
casmi/casmi | src/main/java/casmi/util/FileUtil.java | FileUtil.recursiveSearch | private static String recursiveSearch(java.io.File dir, String fileName) {
for (String name : dir.list()) {
java.io.File file = new java.io.File(dir.getAbsolutePath() + "/" + name);
if (name.compareTo(fileName) == 0) return file.getAbsolutePath();
if (file.isDirectory()) {
String filePath = recursiveSearch(file, fileName);
if (filePath != null) return filePath;
}
}
return null;
} | java | private static String recursiveSearch(java.io.File dir, String fileName) {
for (String name : dir.list()) {
java.io.File file = new java.io.File(dir.getAbsolutePath() + "/" + name);
if (name.compareTo(fileName) == 0) return file.getAbsolutePath();
if (file.isDirectory()) {
String filePath = recursiveSearch(file, fileName);
if (filePath != null) return filePath;
}
}
return null;
} | [
"private",
"static",
"String",
"recursiveSearch",
"(",
"java",
".",
"io",
".",
"File",
"dir",
",",
"String",
"fileName",
")",
"{",
"for",
"(",
"String",
"name",
":",
"dir",
".",
"list",
"(",
")",
")",
"{",
"java",
".",
"io",
".",
"File",
"file",
"=... | Recursive method for searching file path.
@param dir
@param fileName
@return | [
"Recursive",
"method",
"for",
"searching",
"file",
"path",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/util/FileUtil.java#L201-L212 | train |
casmi/casmi | src/main/java/casmi/util/FileUtil.java | FileUtil.touch | public static void touch(File file) throws FileNotFoundException {
if (!file.exists()) {
OutputStream out = new FileOutputStream(file);
try {
out.close();
} catch (IOException e) {
// Ignore.
}
}
file.setLastModified(System.currentTimeMillis());
} | java | public static void touch(File file) throws FileNotFoundException {
if (!file.exists()) {
OutputStream out = new FileOutputStream(file);
try {
out.close();
} catch (IOException e) {
// Ignore.
}
}
file.setLastModified(System.currentTimeMillis());
} | [
"public",
"static",
"void",
"touch",
"(",
"File",
"file",
")",
"throws",
"FileNotFoundException",
"{",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"try",
"{",
... | Implements the same behavior as the "touch" utility on Unix.
It creates a new file with size 0 byte or, if the file exists already, it
is opened and closed without modifying it, but updating the file date and
time.
@param file The file to "touch."
@throws FileNotFoundException
If the file is not found. | [
"Implements",
"the",
"same",
"behavior",
"as",
"the",
"touch",
"utility",
"on",
"Unix",
".",
"It",
"creates",
"a",
"new",
"file",
"with",
"size",
"0",
"byte",
"or",
"if",
"the",
"file",
"exists",
"already",
"it",
"is",
"opened",
"and",
"closed",
"without... | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/util/FileUtil.java#L225-L237 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/ci/CIType.java | CIType.isType | public boolean isType(final org.efaps.admin.datamodel.Type _type)
{
return getType().equals(_type);
} | java | public boolean isType(final org.efaps.admin.datamodel.Type _type)
{
return getType().equals(_type);
} | [
"public",
"boolean",
"isType",
"(",
"final",
"org",
".",
"efaps",
".",
"admin",
".",
"datamodel",
".",
"Type",
"_type",
")",
"{",
"return",
"getType",
"(",
")",
".",
"equals",
"(",
"_type",
")",
";",
"}"
] | Tests, if this type the type in the parameter .
@param _type type to test
@return true if this type otherwise false | [
"Tests",
"if",
"this",
"type",
"the",
"type",
"in",
"the",
"parameter",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/ci/CIType.java#L104-L107 | train |
casmi/casmi | src/main/java/casmi/image/Texture.java | Texture.rotation | public void rotation(TextureRotationMode mode){
float[][] tmp = corner.clone();
switch (mode) {
case HALF:
corner[0] = tmp[2];
corner[1] = tmp[3];
corner[2] = tmp[0];
corner[3] = tmp[1];
break;
case CLOCKWIZE:
corner[0] = tmp[3];
corner[1] = tmp[0];
corner[2] = tmp[1];
corner[3] = tmp[2];
break;
case COUNTERCLOCKWIZE:
corner[0] = tmp[1];
corner[1] = tmp[2];
corner[2] = tmp[3];
corner[3] = tmp[0];
break;
default:
break;
}
} | java | public void rotation(TextureRotationMode mode){
float[][] tmp = corner.clone();
switch (mode) {
case HALF:
corner[0] = tmp[2];
corner[1] = tmp[3];
corner[2] = tmp[0];
corner[3] = tmp[1];
break;
case CLOCKWIZE:
corner[0] = tmp[3];
corner[1] = tmp[0];
corner[2] = tmp[1];
corner[3] = tmp[2];
break;
case COUNTERCLOCKWIZE:
corner[0] = tmp[1];
corner[1] = tmp[2];
corner[2] = tmp[3];
corner[3] = tmp[0];
break;
default:
break;
}
} | [
"public",
"void",
"rotation",
"(",
"TextureRotationMode",
"mode",
")",
"{",
"float",
"[",
"]",
"[",
"]",
"tmp",
"=",
"corner",
".",
"clone",
"(",
")",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"HALF",
":",
"corner",
"[",
"0",
"]",
"=",
"tmp",
... | Rotates the way of mapping the texture.
@param mode The alignment of the position of the Texture.
@see casmi.image.ImageMode | [
"Rotates",
"the",
"way",
"of",
"mapping",
"the",
"texture",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/image/Texture.java#L135-L159 | train |
casmi/casmi | src/main/java/casmi/image/Texture.java | Texture.flip | public void flip(TextureFlipMode mode){
float[][] tmp = corner.clone();
switch (mode) {
case VERTICAL:
corner[0] = tmp[1];
corner[1] = tmp[0];
corner[2] = tmp[3];
corner[3] = tmp[2];
break;
case HORIZONTAL:
corner[0] = tmp[3];
corner[1] = tmp[2];
corner[2] = tmp[1];
corner[3] = tmp[0];
break;
default:
break;
}
} | java | public void flip(TextureFlipMode mode){
float[][] tmp = corner.clone();
switch (mode) {
case VERTICAL:
corner[0] = tmp[1];
corner[1] = tmp[0];
corner[2] = tmp[3];
corner[3] = tmp[2];
break;
case HORIZONTAL:
corner[0] = tmp[3];
corner[1] = tmp[2];
corner[2] = tmp[1];
corner[3] = tmp[0];
break;
default:
break;
}
} | [
"public",
"void",
"flip",
"(",
"TextureFlipMode",
"mode",
")",
"{",
"float",
"[",
"]",
"[",
"]",
"tmp",
"=",
"corner",
".",
"clone",
"(",
")",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"VERTICAL",
":",
"corner",
"[",
"0",
"]",
"=",
"tmp",
"["... | Flips the way of mapping the texture.
@param mode The alignment of the position of the Texture.
@see casmi.image.ImageMode | [
"Flips",
"the",
"way",
"of",
"mapping",
"the",
"texture",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/image/Texture.java#L168-L186 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/stmt/selection/Select.java | Select.addObject | public void addObject(final Object[] _row)
throws EFapsException
{
this.objects.add(this.elements.get(0).getObject(_row));
} | java | public void addObject(final Object[] _row)
throws EFapsException
{
this.objects.add(this.elements.get(0).getObject(_row));
} | [
"public",
"void",
"addObject",
"(",
"final",
"Object",
"[",
"]",
"_row",
")",
"throws",
"EFapsException",
"{",
"this",
".",
"objects",
".",
"add",
"(",
"this",
".",
"elements",
".",
"get",
"(",
"0",
")",
".",
"getObject",
"(",
"_row",
")",
")",
";",
... | Adds the object.
@param _row the row
@throws EFapsException the e faps exception | [
"Adds",
"the",
"object",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/stmt/selection/Select.java#L120-L124 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/version/Dependency.java | Dependency.resolve | public void resolve()
throws InstallationException
{
final IvySettings ivySettings = new IvySettings();
try {
ivySettings.load(this.getClass().getResource("/org/efaps/update/version/ivy.xml"));
} catch (final IOException e) {
throw new InstallationException("IVY setting file could not be read", e);
} catch (final ParseException e) {
throw new InstallationException("IVY setting file could not be parsed", e);
}
final Ivy ivy = Ivy.newInstance(ivySettings);
ivy.getLoggerEngine().pushLogger(new IvyOverSLF4JLogger());
final Map<String, String> attr = new HashMap<String, String>();
attr.put("changing", "true");
final ModuleRevisionId modRevId = ModuleRevisionId.newInstance(this.groupId,
this.artifactId,
this.version,
attr);
final ResolveOptions options = new ResolveOptions();
options.setConfs(new String[] {"runtime"});
final ResolvedModuleRevision resModRev = ivy.findModule(modRevId);
Artifact dw = null;
for (final Artifact artifact : resModRev.getDescriptor().getAllArtifacts()) {
if ("jar".equals(artifact.getType())) {
dw = artifact;
break;
}
}
final DownloadOptions dwOptions = new DownloadOptions();
final ArtifactOrigin ao = resModRev.getArtifactResolver().locate(dw);
resModRev.getArtifactResolver().getRepositoryCacheManager().clean();
final ArtifactDownloadReport adw = resModRev.getArtifactResolver().download(ao, dwOptions);
this.jarFile = adw.getLocalFile();
} | java | public void resolve()
throws InstallationException
{
final IvySettings ivySettings = new IvySettings();
try {
ivySettings.load(this.getClass().getResource("/org/efaps/update/version/ivy.xml"));
} catch (final IOException e) {
throw new InstallationException("IVY setting file could not be read", e);
} catch (final ParseException e) {
throw new InstallationException("IVY setting file could not be parsed", e);
}
final Ivy ivy = Ivy.newInstance(ivySettings);
ivy.getLoggerEngine().pushLogger(new IvyOverSLF4JLogger());
final Map<String, String> attr = new HashMap<String, String>();
attr.put("changing", "true");
final ModuleRevisionId modRevId = ModuleRevisionId.newInstance(this.groupId,
this.artifactId,
this.version,
attr);
final ResolveOptions options = new ResolveOptions();
options.setConfs(new String[] {"runtime"});
final ResolvedModuleRevision resModRev = ivy.findModule(modRevId);
Artifact dw = null;
for (final Artifact artifact : resModRev.getDescriptor().getAllArtifacts()) {
if ("jar".equals(artifact.getType())) {
dw = artifact;
break;
}
}
final DownloadOptions dwOptions = new DownloadOptions();
final ArtifactOrigin ao = resModRev.getArtifactResolver().locate(dw);
resModRev.getArtifactResolver().getRepositoryCacheManager().clean();
final ArtifactDownloadReport adw = resModRev.getArtifactResolver().download(ao, dwOptions);
this.jarFile = adw.getLocalFile();
} | [
"public",
"void",
"resolve",
"(",
")",
"throws",
"InstallationException",
"{",
"final",
"IvySettings",
"ivySettings",
"=",
"new",
"IvySettings",
"(",
")",
";",
"try",
"{",
"ivySettings",
".",
"load",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getResource"... | Resolves this dependency.
@throws InstallationException if dependency could not be resolved
because the ivy settings could not be
loaded | [
"Resolves",
"this",
"dependency",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/version/Dependency.java#L100-L145 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/schema/program/jasperreport/JasperReportCompiler.java | JasperReportCompiler.compileJasperReport | private void compileJasperReport(final Instance _instSource,
final Instance _instCompiled)
throws EFapsException
{
// make the classPath
final String sep = System.getProperty("os.name").startsWith("Windows") ? ";" : ":";
final StringBuilder classPath = new StringBuilder();
for (final String classPathElement : this.classPathElements) {
classPath.append(classPathElement).append(sep);
}
final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext.getInstance();
reportContext.setProperty(JRCompiler.COMPILER_CLASSPATH, classPath.toString());
reportContext.setProperty("net.sf.jasperreports.compiler.groovy", JasperGroovyCompiler.class.getName());
reportContext.setProperty("net.sf.jasperreports.query.executer.factory.eFaps",
FakeQueryExecuterFactory.class.getName());
try {
final JasperDesign jasperDesign = JasperUtil.getJasperDesign(_instSource);
// the fault value for the language is no information but the used compiler needs a value,
// therefore it must be set explicitly
if (jasperDesign.getLanguage() == null) {
jasperDesign.setLanguage(JRReport.LANGUAGE_JAVA);
}
final ByteArrayOutputStream out = new ByteArrayOutputStream();
JasperCompileManager.compileReportToStream(jasperDesign, out);
final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
final Checkin checkin = new Checkin(_instCompiled);
checkin.executeWithoutAccessCheck(jasperDesign.getName() + ".jasper", in, in.available());
out.close();
in.close();
} catch (final JRException e) {
throw new EFapsException(JasperReportCompiler.class, "JRException", e);
} catch (final IOException e) {
throw new EFapsException(JasperReportCompiler.class, "IOException", e);
}
} | java | private void compileJasperReport(final Instance _instSource,
final Instance _instCompiled)
throws EFapsException
{
// make the classPath
final String sep = System.getProperty("os.name").startsWith("Windows") ? ";" : ":";
final StringBuilder classPath = new StringBuilder();
for (final String classPathElement : this.classPathElements) {
classPath.append(classPathElement).append(sep);
}
final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext.getInstance();
reportContext.setProperty(JRCompiler.COMPILER_CLASSPATH, classPath.toString());
reportContext.setProperty("net.sf.jasperreports.compiler.groovy", JasperGroovyCompiler.class.getName());
reportContext.setProperty("net.sf.jasperreports.query.executer.factory.eFaps",
FakeQueryExecuterFactory.class.getName());
try {
final JasperDesign jasperDesign = JasperUtil.getJasperDesign(_instSource);
// the fault value for the language is no information but the used compiler needs a value,
// therefore it must be set explicitly
if (jasperDesign.getLanguage() == null) {
jasperDesign.setLanguage(JRReport.LANGUAGE_JAVA);
}
final ByteArrayOutputStream out = new ByteArrayOutputStream();
JasperCompileManager.compileReportToStream(jasperDesign, out);
final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
final Checkin checkin = new Checkin(_instCompiled);
checkin.executeWithoutAccessCheck(jasperDesign.getName() + ".jasper", in, in.available());
out.close();
in.close();
} catch (final JRException e) {
throw new EFapsException(JasperReportCompiler.class, "JRException", e);
} catch (final IOException e) {
throw new EFapsException(JasperReportCompiler.class, "IOException", e);
}
} | [
"private",
"void",
"compileJasperReport",
"(",
"final",
"Instance",
"_instSource",
",",
"final",
"Instance",
"_instCompiled",
")",
"throws",
"EFapsException",
"{",
"// make the classPath",
"final",
"String",
"sep",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\""... | Method to compile one JasperReport.
@param _instSource instance of the source
@param _instCompiled instance of the compiled source
@throws EFapsException on error | [
"Method",
"to",
"compile",
"one",
"JasperReport",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/schema/program/jasperreport/JasperReportCompiler.java#L117-L154 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/rest/RestEQLInvoker.java | RestEQLInvoker.registerEQLStmt | protected void registerEQLStmt(final String _origin,
final String _stmt)
throws EFapsException
{
// Common_HistoryEQL
final Insert insert = new Insert(UUID.fromString("c96c63b5-2d4c-4bf9-9627-f335fd9c7a84"));
insert.add("Origin", "REST: " + (_origin == null ? "" : _origin));
insert.add("EQLStatement", _stmt);
insert.execute();
} | java | protected void registerEQLStmt(final String _origin,
final String _stmt)
throws EFapsException
{
// Common_HistoryEQL
final Insert insert = new Insert(UUID.fromString("c96c63b5-2d4c-4bf9-9627-f335fd9c7a84"));
insert.add("Origin", "REST: " + (_origin == null ? "" : _origin));
insert.add("EQLStatement", _stmt);
insert.execute();
} | [
"protected",
"void",
"registerEQLStmt",
"(",
"final",
"String",
"_origin",
",",
"final",
"String",
"_stmt",
")",
"throws",
"EFapsException",
"{",
"// Common_HistoryEQL",
"final",
"Insert",
"insert",
"=",
"new",
"Insert",
"(",
"UUID",
".",
"fromString",
"(",
"\"c... | Register eql stmt.
@param _origin the origin
@param _stmt the stmt
@throws EFapsException on error | [
"Register",
"eql",
"stmt",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/rest/RestEQLInvoker.java#L308-L317 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/print/value/EsjpValueSelect.java | EsjpValueSelect.getValue | @Override
public Object getValue(final Object _object)
throws EFapsException
{
final Instance inst = (Instance) super.getValue(_object);
if (this.esjp == null) {
try {
final Class<?> clazz = Class.forName(this.className, false, EFapsClassLoader.getInstance());
this.esjp = (IEsjpSelect) clazz.newInstance();
final List<Instance> instances = new ArrayList<>();
for (final Object obj : getOneSelect().getObjectList()) {
instances.add((Instance) super.getValue(obj));
}
if (this.parameters.isEmpty()) {
this.esjp.initialize(instances);
} else {
this.esjp.initialize(instances, this.parameters.toArray(new String[this.parameters.size()]));
}
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
LOG.error("Catched error", e);
}
}
return this.esjp.getValue(inst);
} | java | @Override
public Object getValue(final Object _object)
throws EFapsException
{
final Instance inst = (Instance) super.getValue(_object);
if (this.esjp == null) {
try {
final Class<?> clazz = Class.forName(this.className, false, EFapsClassLoader.getInstance());
this.esjp = (IEsjpSelect) clazz.newInstance();
final List<Instance> instances = new ArrayList<>();
for (final Object obj : getOneSelect().getObjectList()) {
instances.add((Instance) super.getValue(obj));
}
if (this.parameters.isEmpty()) {
this.esjp.initialize(instances);
} else {
this.esjp.initialize(instances, this.parameters.toArray(new String[this.parameters.size()]));
}
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
LOG.error("Catched error", e);
}
}
return this.esjp.getValue(inst);
} | [
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"final",
"Object",
"_object",
")",
"throws",
"EFapsException",
"{",
"final",
"Instance",
"inst",
"=",
"(",
"Instance",
")",
"super",
".",
"getValue",
"(",
"_object",
")",
";",
"if",
"(",
"this",
".",
... | Method to get the value for the current object.
@param _object current object
@throws EFapsException on error
@return object | [
"Method",
"to",
"get",
"the",
"value",
"for",
"the",
"current",
"object",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/print/value/EsjpValueSelect.java#L95-L118 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java | AbstractStaticSourceImporter.evalApplication | @Override
protected String evalApplication()
{
String ret = null;
final Pattern revisionPattern = Pattern.compile("@eFapsApplication[\\s].*");
final Matcher revisionMatcher = revisionPattern.matcher(getCode());
if (revisionMatcher.find()) {
ret = revisionMatcher.group().replaceFirst("^@eFapsApplication", "");
}
return ret == null ? null : ret.trim();
} | java | @Override
protected String evalApplication()
{
String ret = null;
final Pattern revisionPattern = Pattern.compile("@eFapsApplication[\\s].*");
final Matcher revisionMatcher = revisionPattern.matcher(getCode());
if (revisionMatcher.find()) {
ret = revisionMatcher.group().replaceFirst("^@eFapsApplication", "");
}
return ret == null ? null : ret.trim();
} | [
"@",
"Override",
"protected",
"String",
"evalApplication",
"(",
")",
"{",
"String",
"ret",
"=",
"null",
";",
"final",
"Pattern",
"revisionPattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"@eFapsApplication[\\\\s].*\"",
")",
";",
"final",
"Matcher",
"revisionMatche... | This Method extracts the Revision from the program.
@return Revision of the program | [
"This",
"Method",
"extracts",
"the",
"Revision",
"from",
"the",
"program",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java#L84-L94 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java | AbstractStaticSourceImporter.evalUUID | @Override
protected UUID evalUUID()
{
UUID uuid = null;
final Pattern uuidPattern = Pattern.compile("@eFapsUUID[\\s]*[0-9a-z\\-]*");
final Matcher uuidMatcher = uuidPattern.matcher(getCode());
if (uuidMatcher.find()) {
final String uuidStr = uuidMatcher.group().replaceFirst("^@eFapsUUID", "");
uuid = UUID.fromString(uuidStr.trim());
}
return uuid;
} | java | @Override
protected UUID evalUUID()
{
UUID uuid = null;
final Pattern uuidPattern = Pattern.compile("@eFapsUUID[\\s]*[0-9a-z\\-]*");
final Matcher uuidMatcher = uuidPattern.matcher(getCode());
if (uuidMatcher.find()) {
final String uuidStr = uuidMatcher.group().replaceFirst("^@eFapsUUID", "");
uuid = UUID.fromString(uuidStr.trim());
}
return uuid;
} | [
"@",
"Override",
"protected",
"UUID",
"evalUUID",
"(",
")",
"{",
"UUID",
"uuid",
"=",
"null",
";",
"final",
"Pattern",
"uuidPattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"@eFapsUUID[\\\\s]*[0-9a-z\\\\-]*\"",
")",
";",
"final",
"Matcher",
"uuidMatcher",
"=",
... | This Method extracts the UUID from the source.
@return UUID of the source | [
"This",
"Method",
"extracts",
"the",
"UUID",
"from",
"the",
"source",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java#L101-L114 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java | AbstractStaticSourceImporter.evalExtends | protected String evalExtends()
{
String ret = null;
// regular expression for the package name
final Pattern exPattern = Pattern.compile("@eFapsExtends[\\s]*[a-zA-Z\\._-]*\\b");
final Matcher exMatcher = exPattern.matcher(getCode());
if (exMatcher.find()) {
ret = exMatcher.group().replaceFirst("^@eFapsExtends", "");
}
return ret == null ? null : ret.trim();
} | java | protected String evalExtends()
{
String ret = null;
// regular expression for the package name
final Pattern exPattern = Pattern.compile("@eFapsExtends[\\s]*[a-zA-Z\\._-]*\\b");
final Matcher exMatcher = exPattern.matcher(getCode());
if (exMatcher.find()) {
ret = exMatcher.group().replaceFirst("^@eFapsExtends", "");
}
return ret == null ? null : ret.trim();
} | [
"protected",
"String",
"evalExtends",
"(",
")",
"{",
"String",
"ret",
"=",
"null",
";",
"// regular expression for the package name",
"final",
"Pattern",
"exPattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"@eFapsExtends[\\\\s]*[a-zA-Z\\\\._-]*\\\\b\"",
")",
";",
"final... | This Method extracts the extend from the source.
@return extend of the source | [
"This",
"Method",
"extracts",
"the",
"extend",
"from",
"the",
"source",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/schema/program/staticsource/AbstractStaticSourceImporter.java#L121-L131 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setBackground | public void setBackground(float x, float y, float z, float a) {
gl.glClearColor(x / 255, y / 255, z / 255, a / 255);
} | java | public void setBackground(float x, float y, float z, float a) {
gl.glClearColor(x / 255, y / 255, z / 255, a / 255);
} | [
"public",
"void",
"setBackground",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
",",
"float",
"a",
")",
"{",
"gl",
".",
"glClearColor",
"(",
"x",
"/",
"255",
",",
"y",
"/",
"255",
",",
"z",
"/",
"255",
",",
"a",
"/",
"255",
")",
"... | Sets the background to a RGB and alpha value.
@param x
The R value of the background.
@param y
The G value of the background.
@param z
The B value of the background.
@param a
The alpha opacity of the background. | [
"Sets",
"the",
"background",
"to",
"a",
"RGB",
"and",
"alpha",
"value",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L174-L176 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setBackgroud | public void setBackgroud(Color color) {
gl.glClearColor((float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)(color.getAlpha() * getAlpha()));
} | java | public void setBackgroud(Color color) {
gl.glClearColor((float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)(color.getAlpha() * getAlpha()));
} | [
"public",
"void",
"setBackgroud",
"(",
"Color",
"color",
")",
"{",
"gl",
".",
"glClearColor",
"(",
"(",
"float",
")",
"color",
".",
"getRed",
"(",
")",
",",
"(",
"float",
")",
"color",
".",
"getGreen",
"(",
")",
",",
"(",
"float",
")",
"color",
"."... | Sets the background to a RGB or HSB and alpha value.
@param color
The RGB or HSB value of the background. | [
"Sets",
"the",
"background",
"to",
"a",
"RGB",
"or",
"HSB",
"and",
"alpha",
"value",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L184-L189 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.matrixMode | public void matrixMode(MatrixMode mode) {
switch (mode) {
case PROJECTION:
gl.glMatrixMode(GL2.GL_PROJECTION);
break;
case MODELVIEW:
gl.glMatrixMode(GL2.GL_MODELVIEW);
break;
default:
break;
}
} | java | public void matrixMode(MatrixMode mode) {
switch (mode) {
case PROJECTION:
gl.glMatrixMode(GL2.GL_PROJECTION);
break;
case MODELVIEW:
gl.glMatrixMode(GL2.GL_MODELVIEW);
break;
default:
break;
}
} | [
"public",
"void",
"matrixMode",
"(",
"MatrixMode",
"mode",
")",
"{",
"switch",
"(",
"mode",
")",
"{",
"case",
"PROJECTION",
":",
"gl",
".",
"glMatrixMode",
"(",
"GL2",
".",
"GL_PROJECTION",
")",
";",
"break",
";",
"case",
"MODELVIEW",
":",
"gl",
".",
"... | Sets the MatrixMode.
@param mode
Either PROJECTION or MODELVIEW | [
"Sets",
"the",
"MatrixMode",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L280-L291 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setAmbientLight | public void setAmbientLight(float r, float g, float b) {
float ambient[] = { r, g, b, 255 };
normalize(ambient);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0);
} | java | public void setAmbientLight(float r, float g, float b) {
float ambient[] = { r, g, b, 255 };
normalize(ambient);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0);
} | [
"public",
"void",
"setAmbientLight",
"(",
"float",
"r",
",",
"float",
"g",
",",
"float",
"b",
")",
"{",
"float",
"ambient",
"[",
"]",
"=",
"{",
"r",
",",
"g",
",",
"b",
",",
"255",
"}",
";",
"normalize",
"(",
"ambient",
")",
";",
"gl",
".",
"gl... | Sets the RGB value of the ambientLight | [
"Sets",
"the",
"RGB",
"value",
"of",
"the",
"ambientLight"
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L362-L368 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setAmbientLight | public void setAmbientLight(int i, Color color, boolean enableColor) {
float ambient[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_AMBIENT, ambient, 0);
} | java | public void setAmbientLight(int i, Color color, boolean enableColor) {
float ambient[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_AMBIENT, ambient, 0);
} | [
"public",
"void",
"setAmbientLight",
"(",
"int",
"i",
",",
"Color",
"color",
",",
"boolean",
"enableColor",
")",
"{",
"float",
"ambient",
"[",
"]",
"=",
"{",
"(",
"float",
")",
"color",
".",
"getRed",
"(",
")",
",",
"(",
"float",
")",
"color",
".",
... | Sets the color value of the No.i ambientLight | [
"Sets",
"the",
"color",
"value",
"of",
"the",
"No",
".",
"i",
"ambientLight"
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L476-L487 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setAmbientLight | public void setAmbientLight(int i, Color color, boolean enableColor, Vector3D v) {
float ambient[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
float position[] = { (float)v.getX(), (float)v.getY(), (float)v.getZ(), 1.0f };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_POSITION, position, 0);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_AMBIENT, ambient, 0);
} | java | public void setAmbientLight(int i, Color color, boolean enableColor, Vector3D v) {
float ambient[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
float position[] = { (float)v.getX(), (float)v.getY(), (float)v.getZ(), 1.0f };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_POSITION, position, 0);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_AMBIENT, ambient, 0);
} | [
"public",
"void",
"setAmbientLight",
"(",
"int",
"i",
",",
"Color",
"color",
",",
"boolean",
"enableColor",
",",
"Vector3D",
"v",
")",
"{",
"float",
"ambient",
"[",
"]",
"=",
"{",
"(",
"float",
")",
"color",
".",
"getRed",
"(",
")",
",",
"(",
"float"... | Sets the color value and the position of the No.i ambientLight | [
"Sets",
"the",
"color",
"value",
"and",
"the",
"position",
"of",
"the",
"No",
".",
"i",
"ambientLight"
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L492-L505 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setSpotLight | public void setSpotLight(int i, Color color, boolean enableColor, Vector3D v, float nx, float ny, float nz, float angle) {
float spotColor[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
float pos[] = {
(float)v.getX(),
(float)v.getY(),
(float)v.getZ(),
0.0f
};
float direction[] = { nx, ny, nz };
float a[] = { angle };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_POSITION, pos, 0);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_DIFFUSE, spotColor, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPOT_DIRECTION, direction, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPOT_CUTOFF, a, 0);
} | java | public void setSpotLight(int i, Color color, boolean enableColor, Vector3D v, float nx, float ny, float nz, float angle) {
float spotColor[] = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
float pos[] = {
(float)v.getX(),
(float)v.getY(),
(float)v.getZ(),
0.0f
};
float direction[] = { nx, ny, nz };
float a[] = { angle };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_POSITION, pos, 0);
if(enableColor)
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_DIFFUSE, spotColor, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPOT_DIRECTION, direction, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPOT_CUTOFF, a, 0);
} | [
"public",
"void",
"setSpotLight",
"(",
"int",
"i",
",",
"Color",
"color",
",",
"boolean",
"enableColor",
",",
"Vector3D",
"v",
",",
"float",
"nx",
",",
"float",
"ny",
",",
"float",
"nz",
",",
"float",
"angle",
")",
"{",
"float",
"spotColor",
"[",
"]",
... | Sets the color value, position, direction and the angle of the spotlight cone of the No.i spotLight | [
"Sets",
"the",
"color",
"value",
"position",
"direction",
"and",
"the",
"angle",
"of",
"the",
"spotlight",
"cone",
"of",
"the",
"No",
".",
"i",
"spotLight"
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L586-L608 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setLightAttenuation | public void setLightAttenuation(int i, float constant, float liner, float quadratic) {
float c[] = { constant };
float l[] = { liner };
float q[] = { quadratic };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_CONSTANT_ATTENUATION, c, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_LINEAR_ATTENUATION, l, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_QUADRATIC_ATTENUATION, q, 0);
} | java | public void setLightAttenuation(int i, float constant, float liner, float quadratic) {
float c[] = { constant };
float l[] = { liner };
float q[] = { quadratic };
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0 + i);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_CONSTANT_ATTENUATION, c, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_LINEAR_ATTENUATION, l, 0);
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_QUADRATIC_ATTENUATION, q, 0);
} | [
"public",
"void",
"setLightAttenuation",
"(",
"int",
"i",
",",
"float",
"constant",
",",
"float",
"liner",
",",
"float",
"quadratic",
")",
"{",
"float",
"c",
"[",
"]",
"=",
"{",
"constant",
"}",
";",
"float",
"l",
"[",
"]",
"=",
"{",
"liner",
"}",
... | Set attenuation rates for point lights, spot lights, and ambient lights. | [
"Set",
"attenuation",
"rates",
"for",
"point",
"lights",
"spot",
"lights",
"and",
"ambient",
"lights",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L613-L622 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setLightSpecular | public void setLightSpecular(int i, Color color) {
float[] tmpColor = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPECULAR, tmpColor, 0);
} | java | public void setLightSpecular(int i, Color color) {
float[] tmpColor = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPECULAR, tmpColor, 0);
} | [
"public",
"void",
"setLightSpecular",
"(",
"int",
"i",
",",
"Color",
"color",
")",
"{",
"float",
"[",
"]",
"tmpColor",
"=",
"{",
"(",
"float",
")",
"color",
".",
"getRed",
"(",
")",
",",
"(",
"float",
")",
"color",
".",
"getGreen",
"(",
")",
",",
... | Sets the specular color for No.i light. | [
"Sets",
"the",
"specular",
"color",
"for",
"No",
".",
"i",
"light",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L627-L635 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setLightDiffuse | public void setLightDiffuse(int i, Color color) {
float[] tmpColor = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_DIFFUSE, tmpColor, 0);
} | java | public void setLightDiffuse(int i, Color color) {
float[] tmpColor = {
(float)color.getRed(),
(float)color.getGreen(),
(float)color.getBlue(),
(float)color.getAlpha()
};
gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_DIFFUSE, tmpColor, 0);
} | [
"public",
"void",
"setLightDiffuse",
"(",
"int",
"i",
",",
"Color",
"color",
")",
"{",
"float",
"[",
"]",
"tmpColor",
"=",
"{",
"(",
"float",
")",
"color",
".",
"getRed",
"(",
")",
",",
"(",
"float",
")",
"color",
".",
"getGreen",
"(",
")",
",",
... | Sets the diffuse color for No.i light. | [
"Sets",
"the",
"diffuse",
"color",
"for",
"No",
".",
"i",
"light",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L640-L648 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.normalize | private static float[] normalize(float[] in) {
float[] out = new float[in.length];
for (int i = 0; i < in.length; i++) {
out[i] = (in[i] / 255.0f);
}
return out;
} | java | private static float[] normalize(float[] in) {
float[] out = new float[in.length];
for (int i = 0; i < in.length; i++) {
out[i] = (in[i] / 255.0f);
}
return out;
} | [
"private",
"static",
"float",
"[",
"]",
"normalize",
"(",
"float",
"[",
"]",
"in",
")",
"{",
"float",
"[",
"]",
"out",
"=",
"new",
"float",
"[",
"in",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"in",
".",
"lengt... | Returns the array normalized from 0-255 to 0-1.0. | [
"Returns",
"the",
"array",
"normalized",
"from",
"0",
"-",
"255",
"to",
"0",
"-",
"1",
".",
"0",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L653-L659 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setPerspective | public void setPerspective(double fov, double aspect, double zNear, double zFar) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
glu.gluPerspective(fov, aspect, zNear, zFar);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | java | public void setPerspective(double fov, double aspect, double zNear, double zFar) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
glu.gluPerspective(fov, aspect, zNear, zFar);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | [
"public",
"void",
"setPerspective",
"(",
"double",
"fov",
",",
"double",
"aspect",
",",
"double",
"zNear",
",",
"double",
"zFar",
")",
"{",
"matrixMode",
"(",
"MatrixMode",
".",
"PROJECTION",
")",
";",
"resetMatrix",
"(",
")",
";",
"glu",
".",
"gluPerspect... | Sets a perspective projection applying foreshortening, making distant objects appear smaller
than closer ones. The parameters define a viewing volume with the shape of truncated pyramid.
Objects near to the front of the volume appear their actual size, while farther objects appear
smaller. This projection simulates the perspective of the world more accurately than orthographic
projection.
@param fov
field-of-view angle for vertical direction
@param aspect
ratio of width to height
@param zNear
z-position of nearest clipping plane
@param zFar
z-position of nearest farthest plane | [
"Sets",
"a",
"perspective",
"projection",
"applying",
"foreshortening",
"making",
"distant",
"objects",
"appear",
"smaller",
"than",
"closer",
"ones",
".",
"The",
"parameters",
"define",
"a",
"viewing",
"volume",
"with",
"the",
"shape",
"of",
"truncated",
"pyramid... | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L730-L736 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setPerspective | public void setPerspective() {
double cameraZ = ((height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0));
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
glu.gluPerspective(Math.PI / 3.0, this.width
/ this.height, cameraZ / 10.0, cameraZ * 10.0);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | java | public void setPerspective() {
double cameraZ = ((height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0));
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
glu.gluPerspective(Math.PI / 3.0, this.width
/ this.height, cameraZ / 10.0, cameraZ * 10.0);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | [
"public",
"void",
"setPerspective",
"(",
")",
"{",
"double",
"cameraZ",
"=",
"(",
"(",
"height",
"/",
"2.0",
")",
"/",
"Math",
".",
"tan",
"(",
"Math",
".",
"PI",
"*",
"60.0",
"/",
"360.0",
")",
")",
";",
"matrixMode",
"(",
"MatrixMode",
".",
"PROJ... | Sets a default perspective. | [
"Sets",
"a",
"default",
"perspective",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L745-L753 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setOrtho | public void setOrtho(double left, double right, double bottom, double top,
double near, double far) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glOrtho(left, right, bottom, top, near, far);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | java | public void setOrtho(double left, double right, double bottom, double top,
double near, double far) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glOrtho(left, right, bottom, top, near, far);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | [
"public",
"void",
"setOrtho",
"(",
"double",
"left",
",",
"double",
"right",
",",
"double",
"bottom",
",",
"double",
"top",
",",
"double",
"near",
",",
"double",
"far",
")",
"{",
"matrixMode",
"(",
"MatrixMode",
".",
"PROJECTION",
")",
";",
"resetMatrix",
... | Sets an orthographic projection and defines a parallel clipping volume. All objects with the same
dimension appear the same size, regardless of whether they are near or far from the camera. The parameters
to this function specify the clipping volume where left and right are the minimum and maximum x values,
top and bottom are the minimum and maximum y values, and near and far are the minimum and maximum z values.
@param left
left plane of the clipping volume
@param right
right plane of the clipping volume
@param bottom
bottom plane of the clipping volume
@param top
top plane of the clipping volume
@param near
maximum distance from the origin to the viewer
@param far
maximum distance from the origin away from the viewer | [
"Sets",
"an",
"orthographic",
"projection",
"and",
"defines",
"a",
"parallel",
"clipping",
"volume",
".",
"All",
"objects",
"with",
"the",
"same",
"dimension",
"appear",
"the",
"same",
"size",
"regardless",
"of",
"whether",
"they",
"are",
"near",
"or",
"far",
... | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L780-L787 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setOrtho | public void setOrtho() {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glOrtho(0, this.width, 0, this.height, -1.0e10, 1.0e10);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | java | public void setOrtho() {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glOrtho(0, this.width, 0, this.height, -1.0e10, 1.0e10);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | [
"public",
"void",
"setOrtho",
"(",
")",
"{",
"matrixMode",
"(",
"MatrixMode",
".",
"PROJECTION",
")",
";",
"resetMatrix",
"(",
")",
";",
"gl",
".",
"glOrtho",
"(",
"0",
",",
"this",
".",
"width",
",",
"0",
",",
"this",
".",
"height",
",",
"-",
"1.0... | Sets the default orthographic projection. | [
"Sets",
"the",
"default",
"orthographic",
"projection",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L797-L803 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setFrustum | public void setFrustum(double left, double right, double bottom, double top,
double near, double far) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glFrustum(left, right, bottom, top, near, far);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | java | public void setFrustum(double left, double right, double bottom, double top,
double near, double far) {
matrixMode(MatrixMode.PROJECTION);
resetMatrix();
gl.glFrustum(left, right, bottom, top, near, far);
matrixMode(MatrixMode.MODELVIEW);
resetMatrix();
} | [
"public",
"void",
"setFrustum",
"(",
"double",
"left",
",",
"double",
"right",
",",
"double",
"bottom",
",",
"double",
"top",
",",
"double",
"near",
",",
"double",
"far",
")",
"{",
"matrixMode",
"(",
"MatrixMode",
".",
"PROJECTION",
")",
";",
"resetMatrix"... | Sets a perspective matrix defined through the parameters. Works like
glFrustum, except it wipes out the current perspective matrix rather
than multiplying itself with it.
@param left
left coordinate of the clipping plane
@param right
right coordinate of the clipping plane
@param bottom
bottom coordinate of the clipping plane
@param top
top coordinate of the clipping plane
@param near
near component of the clipping plane
@param far
far component of the clipping plane | [
"Sets",
"a",
"perspective",
"matrix",
"defined",
"through",
"the",
"parameters",
".",
"Works",
"like",
"glFrustum",
"except",
"it",
"wipes",
"out",
"the",
"current",
"perspective",
"matrix",
"rather",
"than",
"multiplying",
"itself",
"with",
"it",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L826-L833 | train |
casmi/casmi | src/main/java/casmi/graphics/Graphics.java | Graphics.setCamera | public void setCamera() {
glu.gluLookAt(width / 2.0, height / 2.0,
(height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0), width / 2.0,
height / 2.0, 0, 0, 1, 0);
} | java | public void setCamera() {
glu.gluLookAt(width / 2.0, height / 2.0,
(height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0), width / 2.0,
height / 2.0, 0, 0, 1, 0);
} | [
"public",
"void",
"setCamera",
"(",
")",
"{",
"glu",
".",
"gluLookAt",
"(",
"width",
"/",
"2.0",
",",
"height",
"/",
"2.0",
",",
"(",
"height",
"/",
"2.0",
")",
"/",
"Math",
".",
"tan",
"(",
"Math",
".",
"PI",
"*",
"60.0",
"/",
"360.0",
")",
",... | Sets the default camera position. | [
"Sets",
"the",
"default",
"camera",
"position",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/Graphics.java#L886-L890 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/access/user/PermissionSet.java | PermissionSet.getKey | public Key getKey()
{
final Key ret = new Key().setPersonId(getPersonId())
.setCompanyId(getCompanyId())
.setTypeId(getTypeId());
return ret;
} | java | public Key getKey()
{
final Key ret = new Key().setPersonId(getPersonId())
.setCompanyId(getCompanyId())
.setTypeId(getTypeId());
return ret;
} | [
"public",
"Key",
"getKey",
"(",
")",
"{",
"final",
"Key",
"ret",
"=",
"new",
"Key",
"(",
")",
".",
"setPersonId",
"(",
"getPersonId",
"(",
")",
")",
".",
"setCompanyId",
"(",
"getCompanyId",
"(",
")",
")",
".",
"setTypeId",
"(",
"getTypeId",
"(",
")"... | Gets the key.
@return the key | [
"Gets",
"the",
"key",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/access/user/PermissionSet.java#L170-L176 | train |
impossibl/stencil | engine/src/main/java/com/impossibl/stencil/api/impl/URLTemplateSource.java | URLTemplateSource.getTag | @Override
public String getTag() throws IOException {
URLConnection urlConnection = url.openConnection();
String tag = urlConnection.getHeaderField(ETAG);
if(tag == null) {
String key = url.toString() + "@" + urlConnection.getLastModified();
tag = md5Cache.getIfPresent(key);
if(tag == null) {
try(InputStream urlStream = urlConnection.getInputStream()) {
byte[] data = ByteStreams.toByteArray(urlConnection.getInputStream());
tag = Hashing.md5().hashBytes(data).toString();
md5Cache.put(key, tag);
}
}
}
return tag;
} | java | @Override
public String getTag() throws IOException {
URLConnection urlConnection = url.openConnection();
String tag = urlConnection.getHeaderField(ETAG);
if(tag == null) {
String key = url.toString() + "@" + urlConnection.getLastModified();
tag = md5Cache.getIfPresent(key);
if(tag == null) {
try(InputStream urlStream = urlConnection.getInputStream()) {
byte[] data = ByteStreams.toByteArray(urlConnection.getInputStream());
tag = Hashing.md5().hashBytes(data).toString();
md5Cache.put(key, tag);
}
}
}
return tag;
} | [
"@",
"Override",
"public",
"String",
"getTag",
"(",
")",
"throws",
"IOException",
"{",
"URLConnection",
"urlConnection",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"String",
"tag",
"=",
"urlConnection",
".",
"getHeaderField",
"(",
"ETAG",
")",
";",
"i... | Gets the tag using either the ETAG header of the URL connection or
calculates it and caches it based on the URL & last modified date | [
"Gets",
"the",
"tag",
"using",
"either",
"the",
"ETAG",
"header",
"of",
"the",
"URL",
"connection",
"or",
"calculates",
"it",
"and",
"caches",
"it",
"based",
"on",
"the",
"URL",
"&",
"last",
"modified",
"date"
] | 4aac1be605542b4248be95bf8916be4e2f755d1c | https://github.com/impossibl/stencil/blob/4aac1be605542b4248be95bf8916be4e2f755d1c/engine/src/main/java/com/impossibl/stencil/api/impl/URLTemplateSource.java#L64-L92 | train |
javabits/yar | yar-guice/src/main/java/org/javabits/yar/guice/RegistrationBindingHandler.java | RegistrationBindingHandler.getSuppliers | private List<Pair<Id, GuiceSupplier>> getSuppliers() {
ImmutableList.Builder<Pair<Id, GuiceSupplier>> suppliersBuilder = ImmutableList.builder();
for (Binding<GuiceRegistration> registrationBinding : injector.findBindingsByType(TypeLiteral.get(GuiceRegistration.class))) {
Key<?> key = registrationBinding.getProvider().get().key();
suppliersBuilder.add(newPair(key));
}
return suppliersBuilder.build();
} | java | private List<Pair<Id, GuiceSupplier>> getSuppliers() {
ImmutableList.Builder<Pair<Id, GuiceSupplier>> suppliersBuilder = ImmutableList.builder();
for (Binding<GuiceRegistration> registrationBinding : injector.findBindingsByType(TypeLiteral.get(GuiceRegistration.class))) {
Key<?> key = registrationBinding.getProvider().get().key();
suppliersBuilder.add(newPair(key));
}
return suppliersBuilder.build();
} | [
"private",
"List",
"<",
"Pair",
"<",
"Id",
",",
"GuiceSupplier",
">",
">",
"getSuppliers",
"(",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"Pair",
"<",
"Id",
",",
"GuiceSupplier",
">",
">",
"suppliersBuilder",
"=",
"ImmutableList",
".",
"builder",
"("... | enforce load all providers before register them | [
"enforce",
"load",
"all",
"providers",
"before",
"register",
"them"
] | e146a86611ca4831e8334c9a98fd7086cee9c03e | https://github.com/javabits/yar/blob/e146a86611ca4831e8334c9a98fd7086cee9c03e/yar-guice/src/main/java/org/javabits/yar/guice/RegistrationBindingHandler.java#L73-L80 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.column | public SQLSelect column(final String _name)
{
columns.add(new Column(tablePrefix, null, _name));
return this;
} | java | public SQLSelect column(final String _name)
{
columns.add(new Column(tablePrefix, null, _name));
return this;
} | [
"public",
"SQLSelect",
"column",
"(",
"final",
"String",
"_name",
")",
"{",
"columns",
".",
"add",
"(",
"new",
"Column",
"(",
"tablePrefix",
",",
"null",
",",
"_name",
")",
")",
";",
"return",
"this",
";",
"}"
] | Appends a selected column.
@param _name name of the column
@return this SQL select statement
@see #columns | [
"Appends",
"a",
"selected",
"column",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L108-L112 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.columnIndex | public int columnIndex(final int _tableIndex, final String _columnName)
{
final Optional<Column> colOpt = getColumns().stream()
.filter(column -> column.tableIndex == _tableIndex && column.columnName.equals(_columnName))
.findFirst();
final int ret;
if (colOpt.isPresent()) {
ret = getColumns().indexOf(colOpt.get());
} else {
columns.add(new Column(tablePrefix, _tableIndex, _columnName));
ret = getColumnIdx();
}
return ret;
} | java | public int columnIndex(final int _tableIndex, final String _columnName)
{
final Optional<Column> colOpt = getColumns().stream()
.filter(column -> column.tableIndex == _tableIndex && column.columnName.equals(_columnName))
.findFirst();
final int ret;
if (colOpt.isPresent()) {
ret = getColumns().indexOf(colOpt.get());
} else {
columns.add(new Column(tablePrefix, _tableIndex, _columnName));
ret = getColumnIdx();
}
return ret;
} | [
"public",
"int",
"columnIndex",
"(",
"final",
"int",
"_tableIndex",
",",
"final",
"String",
"_columnName",
")",
"{",
"final",
"Optional",
"<",
"Column",
">",
"colOpt",
"=",
"getColumns",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"column",
"-... | Column index.
@param _tableIndex the table index
@param _columnName the column name
@return the int | [
"Column",
"index",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L137-L150 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.getSQL | public String getSQL()
{
final StringBuilder cmd = new StringBuilder().append(" ")
.append(Context.getDbType().getSQLPart(SQLPart.SELECT)).append(" ");
if (distinct) {
cmd.append(Context.getDbType().getSQLPart(SQLPart.DISTINCT)).append(" ");
}
boolean first = true;
for (final Column column : columns) {
if (first) {
first = false;
} else {
cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
}
column.appendSQL(cmd);
}
cmd.append(" ").append(Context.getDbType().getSQLPart(SQLPart.FROM)).append(" ");
first = true;
for (final FromTable fromTable : fromTables) {
fromTable.appendSQL(first, cmd);
if (first) {
first = false;
}
}
cmd.append(" ");
boolean whereAdded = false;
for (final SQLSelectPart part : parts) {
part.appendSQL(cmd);
cmd.append(" ");
whereAdded = whereAdded || !whereAdded && SQLPart.WHERE.equals(part.sqlpart);
}
if (where != null) {
where.setStarted(whereAdded);
where.appendSQL(tablePrefix, cmd);
}
if (order != null) {
order.appendSQL(tablePrefix, cmd);
}
return cmd.toString();
} | java | public String getSQL()
{
final StringBuilder cmd = new StringBuilder().append(" ")
.append(Context.getDbType().getSQLPart(SQLPart.SELECT)).append(" ");
if (distinct) {
cmd.append(Context.getDbType().getSQLPart(SQLPart.DISTINCT)).append(" ");
}
boolean first = true;
for (final Column column : columns) {
if (first) {
first = false;
} else {
cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
}
column.appendSQL(cmd);
}
cmd.append(" ").append(Context.getDbType().getSQLPart(SQLPart.FROM)).append(" ");
first = true;
for (final FromTable fromTable : fromTables) {
fromTable.appendSQL(first, cmd);
if (first) {
first = false;
}
}
cmd.append(" ");
boolean whereAdded = false;
for (final SQLSelectPart part : parts) {
part.appendSQL(cmd);
cmd.append(" ");
whereAdded = whereAdded || !whereAdded && SQLPart.WHERE.equals(part.sqlpart);
}
if (where != null) {
where.setStarted(whereAdded);
where.appendSQL(tablePrefix, cmd);
}
if (order != null) {
order.appendSQL(tablePrefix, cmd);
}
return cmd.toString();
} | [
"public",
"String",
"getSQL",
"(",
")",
"{",
"final",
"StringBuilder",
"cmd",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"Context",
".",
"getDbType",
"(",
")",
".",
"getSQLPart",
"(",
"SQLPart",
".",
"S... | Returns the depending SQL statement.
@return SQL statement | [
"Returns",
"the",
"depending",
"SQL",
"statement",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L307-L348 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.addColumnPart | public SQLSelect addColumnPart(final Integer _tableIndex,
final String _columnName)
{
parts.add(new Column(tablePrefix, _tableIndex, _columnName));
return this;
} | java | public SQLSelect addColumnPart(final Integer _tableIndex,
final String _columnName)
{
parts.add(new Column(tablePrefix, _tableIndex, _columnName));
return this;
} | [
"public",
"SQLSelect",
"addColumnPart",
"(",
"final",
"Integer",
"_tableIndex",
",",
"final",
"String",
"_columnName",
")",
"{",
"parts",
".",
"add",
"(",
"new",
"Column",
"(",
"tablePrefix",
",",
"_tableIndex",
",",
"_columnName",
")",
")",
";",
"return",
"... | Add a column as part.
@param _tableIndex index of the table
@param _columnName name of the column
@return this | [
"Add",
"a",
"column",
"as",
"part",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L392-L397 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.addTablePart | public SQLSelect addTablePart(final String _tableName,
final Integer _tableIndex)
{
parts.add(new FromTable(tablePrefix, _tableName, _tableIndex));
return this;
} | java | public SQLSelect addTablePart(final String _tableName,
final Integer _tableIndex)
{
parts.add(new FromTable(tablePrefix, _tableName, _tableIndex));
return this;
} | [
"public",
"SQLSelect",
"addTablePart",
"(",
"final",
"String",
"_tableName",
",",
"final",
"Integer",
"_tableIndex",
")",
"{",
"parts",
".",
"add",
"(",
"new",
"FromTable",
"(",
"tablePrefix",
",",
"_tableName",
",",
"_tableIndex",
")",
")",
";",
"return",
"... | Add a table as part.
@param _tableName name of the table
@param _tableIndex index of the table
@return this | [
"Add",
"a",
"table",
"as",
"part",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L405-L410 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/wrapper/SQLSelect.java | SQLSelect.addTimestampValue | public SQLSelect addTimestampValue(final String _isoDateTime)
{
parts.add(new Value(Context.getDbType().getTimestampValue(_isoDateTime)));
return this;
} | java | public SQLSelect addTimestampValue(final String _isoDateTime)
{
parts.add(new Value(Context.getDbType().getTimestampValue(_isoDateTime)));
return this;
} | [
"public",
"SQLSelect",
"addTimestampValue",
"(",
"final",
"String",
"_isoDateTime",
")",
"{",
"parts",
".",
"add",
"(",
"new",
"Value",
"(",
"Context",
".",
"getDbType",
"(",
")",
".",
"getTimestampValue",
"(",
"_isoDateTime",
")",
")",
")",
";",
"return",
... | Add a timestamp value to the select.
@param _isoDateTime String to be casted to a timestamp
@return this | [
"Add",
"a",
"timestamp",
"value",
"to",
"the",
"select",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/wrapper/SQLSelect.java#L447-L451 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/CachedPrintQuery.java | CachedPrintQuery.get4Request | public static CachedPrintQuery get4Request(final Instance _instance)
throws EFapsException
{
return new CachedPrintQuery(_instance, Context.getThreadContext().getRequestId()).setLifespan(5)
.setLifespanUnit(TimeUnit.MINUTES);
} | java | public static CachedPrintQuery get4Request(final Instance _instance)
throws EFapsException
{
return new CachedPrintQuery(_instance, Context.getThreadContext().getRequestId()).setLifespan(5)
.setLifespanUnit(TimeUnit.MINUTES);
} | [
"public",
"static",
"CachedPrintQuery",
"get4Request",
"(",
"final",
"Instance",
"_instance",
")",
"throws",
"EFapsException",
"{",
"return",
"new",
"CachedPrintQuery",
"(",
"_instance",
",",
"Context",
".",
"getThreadContext",
"(",
")",
".",
"getRequestId",
"(",
... | Get a CachedPrintQuery that will only cache during a request.
@param _instance instance to be updated.
@return the 4 request
@throws EFapsException on error | [
"Get",
"a",
"CachedPrintQuery",
"that",
"will",
"only",
"cache",
"during",
"a",
"request",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/CachedPrintQuery.java#L194-L199 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/datamodel/attributetype/OwnerLinkType.java | OwnerLinkType.prepare | @Override
protected void prepare(final AbstractSQLInsertUpdate<?> _insertUpdate,
final Attribute _attribute,
final Object... _values)
throws SQLException
{
checkSQLColumnSize(_attribute, 1);
try {
_insertUpdate.column(_attribute.getSqlColNames().get(0),
Context.getThreadContext().getPerson().getId());
} catch (final EFapsException e) {
throw new SQLException("could not fetch current context person id", e);
}
} | java | @Override
protected void prepare(final AbstractSQLInsertUpdate<?> _insertUpdate,
final Attribute _attribute,
final Object... _values)
throws SQLException
{
checkSQLColumnSize(_attribute, 1);
try {
_insertUpdate.column(_attribute.getSqlColNames().get(0),
Context.getThreadContext().getPerson().getId());
} catch (final EFapsException e) {
throw new SQLException("could not fetch current context person id", e);
}
} | [
"@",
"Override",
"protected",
"void",
"prepare",
"(",
"final",
"AbstractSQLInsertUpdate",
"<",
"?",
">",
"_insertUpdate",
",",
"final",
"Attribute",
"_attribute",
",",
"final",
"Object",
"...",
"_values",
")",
"throws",
"SQLException",
"{",
"checkSQLColumnSize",
"... | The instance method sets the value in the insert statement to the id of
the current context user.
@param _insertUpdate SQL insert / update statement
@param _attribute SQL update statement
@param _values new object value to set; values are localized and
are coming from the user interface
@throws SQLException on error | [
"The",
"instance",
"method",
"sets",
"the",
"value",
"in",
"the",
"insert",
"statement",
"to",
"the",
"id",
"of",
"the",
"current",
"context",
"user",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/datamodel/attributetype/OwnerLinkType.java#L52-L65 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.addMapping | protected void addMapping(final ColumnType _columnType,
final String _writeTypeName,
final String _nullValueSelect,
final String... _readTypeNames)
{
this.writeColTypeMap.put(_columnType, _writeTypeName);
this.nullValueColTypeMap.put(_columnType, _nullValueSelect);
for (final String readTypeName : _readTypeNames) {
Set<AbstractDatabase.ColumnType> colTypes = this.readColTypeMap.get(readTypeName);
if (colTypes == null) {
colTypes = new HashSet<>();
this.readColTypeMap.put(readTypeName, colTypes);
}
colTypes.add(_columnType);
}
} | java | protected void addMapping(final ColumnType _columnType,
final String _writeTypeName,
final String _nullValueSelect,
final String... _readTypeNames)
{
this.writeColTypeMap.put(_columnType, _writeTypeName);
this.nullValueColTypeMap.put(_columnType, _nullValueSelect);
for (final String readTypeName : _readTypeNames) {
Set<AbstractDatabase.ColumnType> colTypes = this.readColTypeMap.get(readTypeName);
if (colTypes == null) {
colTypes = new HashSet<>();
this.readColTypeMap.put(readTypeName, colTypes);
}
colTypes.add(_columnType);
}
} | [
"protected",
"void",
"addMapping",
"(",
"final",
"ColumnType",
"_columnType",
",",
"final",
"String",
"_writeTypeName",
",",
"final",
"String",
"_nullValueSelect",
",",
"final",
"String",
"...",
"_readTypeNames",
")",
"{",
"this",
".",
"writeColTypeMap",
".",
"put... | Adds a new mapping for given eFaps column type used for mapping from and
to the SQL database.
@param _columnType column type within eFaps
@param _writeTypeName SQL type name used to write (create new column
within a SQL table)
@param _nullValueSelect null value select used within the query if a link
target could be a null (and so all selected values must null
in the SQL statement for objects without this link)
@param _readTypeNames list of SQL type names returned from the database
meta data reading
@see #readColTypeMap to map from an eFaps column type to a SQL type name
@see #writeColTypeMap to map from a SQL type name to possible eFaps
column types | [
"Adds",
"a",
"new",
"mapping",
"for",
"given",
"eFaps",
"column",
"type",
"used",
"for",
"mapping",
"from",
"and",
"to",
"the",
"SQL",
"database",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L251-L266 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.existsView | public boolean existsView(final Connection _con,
final String _viewName)
throws SQLException
{
boolean ret = false;
final DatabaseMetaData metaData = _con.getMetaData();
// first test with lower case
final ResultSet rs = metaData.getTables(null, null, _viewName.toLowerCase(), new String[] { "VIEW" });
if (rs.next()) {
ret = true;
}
rs.close();
// then test with upper case
if (!ret) {
final ResultSet rsUC = metaData.getTables(null, null, _viewName.toUpperCase(), new String[] { "VIEW" });
if (rsUC.next()) {
ret = true;
}
rsUC.close();
}
return ret;
} | java | public boolean existsView(final Connection _con,
final String _viewName)
throws SQLException
{
boolean ret = false;
final DatabaseMetaData metaData = _con.getMetaData();
// first test with lower case
final ResultSet rs = metaData.getTables(null, null, _viewName.toLowerCase(), new String[] { "VIEW" });
if (rs.next()) {
ret = true;
}
rs.close();
// then test with upper case
if (!ret) {
final ResultSet rsUC = metaData.getTables(null, null, _viewName.toUpperCase(), new String[] { "VIEW" });
if (rsUC.next()) {
ret = true;
}
rsUC.close();
}
return ret;
} | [
"public",
"boolean",
"existsView",
"(",
"final",
"Connection",
"_con",
",",
"final",
"String",
"_viewName",
")",
"throws",
"SQLException",
"{",
"boolean",
"ret",
"=",
"false",
";",
"final",
"DatabaseMetaData",
"metaData",
"=",
"_con",
".",
"getMetaData",
"(",
... | The method tests, if a view with given name exists.
@param _con sql connection
@param _viewName name of view to test
@return <i>true</i> if view exists, otherwise <i>false</i>
@throws SQLException if the exist check failed | [
"The",
"method",
"tests",
"if",
"a",
"view",
"with",
"given",
"name",
"exists",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L412-L437 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.updateColumn | public T updateColumn(final Connection _con,
final String _tableName,
final String _columnName,
final ColumnType _columnType,
final int _length,
final int _scale)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(getTableQuote()).append(_tableName).append(getTableQuote())
.append(getAlterColumn(_columnName, _columnType));
if (_length > 0) {
cmd.append("(").append(_length);
if (_scale > 0) {
cmd.append(",").append(_scale);
}
cmd.append(")");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | java | public T updateColumn(final Connection _con,
final String _tableName,
final String _columnName,
final ColumnType _columnType,
final int _length,
final int _scale)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(getTableQuote()).append(_tableName).append(getTableQuote())
.append(getAlterColumn(_columnName, _columnType));
if (_length > 0) {
cmd.append("(").append(_length);
if (_scale > 0) {
cmd.append(",").append(_scale);
}
cmd.append(")");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | [
"public",
"T",
"updateColumn",
"(",
"final",
"Connection",
"_con",
",",
"final",
"String",
"_tableName",
",",
"final",
"String",
"_columnName",
",",
"final",
"ColumnType",
"_columnType",
",",
"final",
"int",
"_length",
",",
"final",
"int",
"_scale",
")",
"thro... | Adds a column to a SQL table.
@param _con SQL connection
@param _tableName name of table to update
@param _columnName column to update
@param _columnType type of column to update
@param _length length of column to update (or 0 if not specified)
@param _scale scale of the column (or 0 if not specified)
@return this instance
@throws SQLException if the column could not be added to the tables | [
"Adds",
"a",
"column",
"to",
"a",
"SQL",
"table",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L797-L826 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.addUniqueKey | public T addUniqueKey(final Connection _con,
final String _tableName,
final String _uniqueKeyName,
final String _columns)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_uniqueKeyName).append(" ")
.append("unique(").append(_columns).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked") final T ret = (T) this;
return ret;
} | java | public T addUniqueKey(final Connection _con,
final String _tableName,
final String _uniqueKeyName,
final String _columns)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_uniqueKeyName).append(" ")
.append("unique(").append(_columns).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked") final T ret = (T) this;
return ret;
} | [
"public",
"T",
"addUniqueKey",
"(",
"final",
"Connection",
"_con",
",",
"final",
"String",
"_tableName",
",",
"final",
"String",
"_uniqueKeyName",
",",
"final",
"String",
"_columns",
")",
"throws",
"SQLException",
"{",
"final",
"StringBuilder",
"cmd",
"=",
"new"... | Adds a new unique key to given table name.
@param _con SQL connection
@param _tableName name of table for which the unique key must be created
@param _uniqueKeyName name of unique key
@param _columns comma separated list of column names for which the unique
key is created
@return this instance
@throws SQLException if the unique key could not be created | [
"Adds",
"a",
"new",
"unique",
"key",
"to",
"given",
"table",
"name",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L847-L869 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.addForeignKey | public T addForeignKey(final Connection _con,
final String _tableName,
final String _foreignKeyName,
final String _key,
final String _reference,
final boolean _cascade)
throws InstallationException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_foreignKeyName).append(" ")
.append("foreign key(").append(_key).append(") ")
.append("references ").append(_reference);
if (_cascade) {
cmd.append(" on delete cascade");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
try {
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} catch (final SQLException e) {
throw new InstallationException("Foreign key could not be created. SQL statement was:\n"
+ cmd.toString(), e);
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | java | public T addForeignKey(final Connection _con,
final String _tableName,
final String _foreignKeyName,
final String _key,
final String _reference,
final boolean _cascade)
throws InstallationException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_foreignKeyName).append(" ")
.append("foreign key(").append(_key).append(") ")
.append("references ").append(_reference);
if (_cascade) {
cmd.append(" on delete cascade");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
try {
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} catch (final SQLException e) {
throw new InstallationException("Foreign key could not be created. SQL statement was:\n"
+ cmd.toString(), e);
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | [
"public",
"T",
"addForeignKey",
"(",
"final",
"Connection",
"_con",
",",
"final",
"String",
"_tableName",
",",
"final",
"String",
"_foreignKeyName",
",",
"final",
"String",
"_key",
",",
"final",
"String",
"_reference",
",",
"final",
"boolean",
"_cascade",
")",
... | Adds a foreign key to given SQL table.
@param _con SQL connection
@param _tableName name of table for which the foreign key must be created
@param _foreignKeyName name of foreign key to create
@param _key key in the table (column name)
@param _reference external reference (external table and column name)
@param _cascade if the value in the external table is deleted, should
this value also automatically deleted?
@return this instance
@throws InstallationException if foreign key could not be defined for SQL
table | [
"Adds",
"a",
"foreign",
"key",
"to",
"given",
"SQL",
"table",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L885-L917 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.addCheckKey | public void addCheckKey(final Connection _con,
final String _tableName,
final String _checkKeyName,
final String _condition)
throws SQLException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_checkKeyName).append(" ")
.append("check(").append(_condition).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
// excecute statement
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} | java | public void addCheckKey(final Connection _con,
final String _tableName,
final String _checkKeyName,
final String _condition)
throws SQLException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_checkKeyName).append(" ")
.append("check(").append(_condition).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
// excecute statement
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} | [
"public",
"void",
"addCheckKey",
"(",
"final",
"Connection",
"_con",
",",
"final",
"String",
"_tableName",
",",
"final",
"String",
"_checkKeyName",
",",
"final",
"String",
"_condition",
")",
"throws",
"SQLException",
"{",
"final",
"StringBuilder",
"cmd",
"=",
"n... | Adds a new check key to given SQL table.
@param _con SQL connection
@param _tableName name of the SQL table for which the check key must be
created
@param _checkKeyName name of check key to create
@param _condition condition of the check key
@throws SQLException if check key could not be defined for SQL table | [
"Adds",
"a",
"new",
"check",
"key",
"to",
"given",
"SQL",
"table",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L929-L948 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/databases/AbstractDatabase.java | AbstractDatabase.findByClassName | public static AbstractDatabase<?> findByClassName(final String _dbClassName)
throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
return (AbstractDatabase<?>) Class.forName(_dbClassName).newInstance();
} | java | public static AbstractDatabase<?> findByClassName(final String _dbClassName)
throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
return (AbstractDatabase<?>) Class.forName(_dbClassName).newInstance();
} | [
"public",
"static",
"AbstractDatabase",
"<",
"?",
">",
"findByClassName",
"(",
"final",
"String",
"_dbClassName",
")",
"throws",
"ClassNotFoundException",
",",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"return",
"(",
"AbstractDatabase",
"<",
"?",
"... | Instantiate the given DB class name and returns them.
@param _dbClassName name of the class to instantiate
@return new database definition instance
@throws ClassNotFoundException if class for the DB is not found
@throws InstantiationException if DB class could not be instantiated
@throws IllegalAccessException if DB class could not be accessed | [
"Instantiate",
"the",
"given",
"DB",
"class",
"name",
"and",
"returns",
"them",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/databases/AbstractDatabase.java#L1148-L1152 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/AttachmentController.java | AttachmentController.upload | private Collection<Observable<Attachment>> upload(RxComapiClient client, List<Attachment> data) {
Collection<Observable<Attachment>> obsList = new ArrayList<>();
for (Attachment a : data) {
obsList.add(upload(client, a));
}
return obsList;
} | java | private Collection<Observable<Attachment>> upload(RxComapiClient client, List<Attachment> data) {
Collection<Observable<Attachment>> obsList = new ArrayList<>();
for (Attachment a : data) {
obsList.add(upload(client, a));
}
return obsList;
} | [
"private",
"Collection",
"<",
"Observable",
"<",
"Attachment",
">",
">",
"upload",
"(",
"RxComapiClient",
"client",
",",
"List",
"<",
"Attachment",
">",
"data",
")",
"{",
"Collection",
"<",
"Observable",
"<",
"Attachment",
">>",
"obsList",
"=",
"new",
"Array... | Create list of upload attachment observables. | [
"Create",
"list",
"of",
"upload",
"attachment",
"observables",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/AttachmentController.java#L91-L97 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/AttachmentController.java | AttachmentController.upload | private Observable<Attachment> upload(RxComapiClient client, Attachment a) {
return client.service().messaging().uploadContent(a.getFolder(), a.getData())
.map(response -> a.updateWithUploadDetails(response.getResult()))
.doOnError(t -> log.e("Error uploading attachment. " + t.getLocalizedMessage()))
.onErrorReturn(a::setError);
} | java | private Observable<Attachment> upload(RxComapiClient client, Attachment a) {
return client.service().messaging().uploadContent(a.getFolder(), a.getData())
.map(response -> a.updateWithUploadDetails(response.getResult()))
.doOnError(t -> log.e("Error uploading attachment. " + t.getLocalizedMessage()))
.onErrorReturn(a::setError);
} | [
"private",
"Observable",
"<",
"Attachment",
">",
"upload",
"(",
"RxComapiClient",
"client",
",",
"Attachment",
"a",
")",
"{",
"return",
"client",
".",
"service",
"(",
")",
".",
"messaging",
"(",
")",
".",
"uploadContent",
"(",
"a",
".",
"getFolder",
"(",
... | Upload single attachment and update the details in it from the response. | [
"Upload",
"single",
"attachment",
"and",
"update",
"the",
"details",
"in",
"it",
"from",
"the",
"response",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/AttachmentController.java#L102-L107 | train |
casmi/casmi | src/main/java/casmi/graphics/object/Ortho.java | Ortho.set | public void set(double left, double right,
double bottom, double top,
double near, double far) {
this.left = left;
this.right = right;
this.bottom = bottom;
this.top = top;
this.near = near;
this.far = far;
} | java | public void set(double left, double right,
double bottom, double top,
double near, double far) {
this.left = left;
this.right = right;
this.bottom = bottom;
this.top = top;
this.near = near;
this.far = far;
} | [
"public",
"void",
"set",
"(",
"double",
"left",
",",
"double",
"right",
",",
"double",
"bottom",
",",
"double",
"top",
",",
"double",
"near",
",",
"double",
"far",
")",
"{",
"this",
".",
"left",
"=",
"left",
";",
"this",
".",
"right",
"=",
"right",
... | Sets the clipping plane.
@param left
The left coordinate of the clipping plane.
@param right
The right coordinate of the clipping plane.
@param bottom
The bottom coordinate of the clipping plane.
@param top
The top coordinate of the clipping plane.
@param near
The near coordinate of the clipping plane.
@param far
The far coordinate of the clipping plane. | [
"Sets",
"the",
"clipping",
"plane",
"."
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/object/Ortho.java#L92-L101 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/eql/EQL.java | EQL.getStatement | public static AbstractStmt getStatement(final CharSequence _stmt)
{
AbstractStmt ret = null;
final IStatement<?> stmt = parse(_stmt);
if (stmt instanceof IPrintStatement) {
ret = PrintStmt.get((IPrintStatement<?>) stmt);
} else if (stmt instanceof IDeleteStatement) {
ret = DeleteStmt.get((IDeleteStatement<?>) stmt);
} else if (stmt instanceof IInsertStatement) {
ret = InsertStmt.get((IInsertStatement) stmt);
} else if (stmt instanceof IUpdateStatement) {
ret = UpdateStmt.get((IUpdateStatement<?>) stmt);
}
return ret;
} | java | public static AbstractStmt getStatement(final CharSequence _stmt)
{
AbstractStmt ret = null;
final IStatement<?> stmt = parse(_stmt);
if (stmt instanceof IPrintStatement) {
ret = PrintStmt.get((IPrintStatement<?>) stmt);
} else if (stmt instanceof IDeleteStatement) {
ret = DeleteStmt.get((IDeleteStatement<?>) stmt);
} else if (stmt instanceof IInsertStatement) {
ret = InsertStmt.get((IInsertStatement) stmt);
} else if (stmt instanceof IUpdateStatement) {
ret = UpdateStmt.get((IUpdateStatement<?>) stmt);
}
return ret;
} | [
"public",
"static",
"AbstractStmt",
"getStatement",
"(",
"final",
"CharSequence",
"_stmt",
")",
"{",
"AbstractStmt",
"ret",
"=",
"null",
";",
"final",
"IStatement",
"<",
"?",
">",
"stmt",
"=",
"parse",
"(",
"_stmt",
")",
";",
"if",
"(",
"stmt",
"instanceof... | Parses the stmt.
@param _stmt the stmt
@return the abstract stmt | [
"Parses",
"the",
"stmt",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/eql/EQL.java#L266-L280 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/eql/QueryBldrUtil.java | QueryBldrUtil.getInstances | public static List<Instance> getInstances(final AbstractQueryPart _queryPart)
throws EFapsException
{
return getQueryBldr(_queryPart).getQuery().execute();
} | java | public static List<Instance> getInstances(final AbstractQueryPart _queryPart)
throws EFapsException
{
return getQueryBldr(_queryPart).getQuery().execute();
} | [
"public",
"static",
"List",
"<",
"Instance",
">",
"getInstances",
"(",
"final",
"AbstractQueryPart",
"_queryPart",
")",
"throws",
"EFapsException",
"{",
"return",
"getQueryBldr",
"(",
"_queryPart",
")",
".",
"getQuery",
"(",
")",
".",
"execute",
"(",
")",
";",... | Gets the instances.
@param _queryPart the _query part
@return the instances
@throws EFapsException on error | [
"Gets",
"the",
"instances",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/eql/QueryBldrUtil.java#L62-L66 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/datamodel/attributetype/DecimalType.java | DecimalType.parseLocalized | public static BigDecimal parseLocalized(final String _value) throws EFapsException
{
final DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Context.getThreadContext()
.getLocale());
format.setParseBigDecimal(true);
try {
return (BigDecimal) format.parse(_value);
} catch (final ParseException e) {
throw new EFapsException(DecimalType.class, "ParseException", e);
}
} | java | public static BigDecimal parseLocalized(final String _value) throws EFapsException
{
final DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Context.getThreadContext()
.getLocale());
format.setParseBigDecimal(true);
try {
return (BigDecimal) format.parse(_value);
} catch (final ParseException e) {
throw new EFapsException(DecimalType.class, "ParseException", e);
}
} | [
"public",
"static",
"BigDecimal",
"parseLocalized",
"(",
"final",
"String",
"_value",
")",
"throws",
"EFapsException",
"{",
"final",
"DecimalFormat",
"format",
"=",
"(",
"DecimalFormat",
")",
"NumberFormat",
".",
"getInstance",
"(",
"Context",
".",
"getThreadContext... | Method to parse a localized String to an BigDecimal.
@param _value value to be parsed
@return BigDecimal
@throws EFapsException on error | [
"Method",
"to",
"parse",
"a",
"localized",
"String",
"to",
"an",
"BigDecimal",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/datamodel/attributetype/DecimalType.java#L117-L127 | train |
gpein/jcache-jee7 | src/main/java/io/github/gpein/jcache/service/JCacheService.java | JCacheService.update | public void update(String cacheName, Cache cache) {
cacheManager.enableManagement(cacheName, cache.isManagementEnabled());
updateStatistics(cacheName, cache);
} | java | public void update(String cacheName, Cache cache) {
cacheManager.enableManagement(cacheName, cache.isManagementEnabled());
updateStatistics(cacheName, cache);
} | [
"public",
"void",
"update",
"(",
"String",
"cacheName",
",",
"Cache",
"cache",
")",
"{",
"cacheManager",
".",
"enableManagement",
"(",
"cacheName",
",",
"cache",
".",
"isManagementEnabled",
"(",
")",
")",
";",
"updateStatistics",
"(",
"cacheName",
",",
"cache"... | Update mutable information of cache configuration such as management and statistics support
@param cacheName name of cache to update
@param cache containing new values | [
"Update",
"mutable",
"information",
"of",
"cache",
"configuration",
"such",
"as",
"management",
"and",
"statistics",
"support"
] | 492dd3bb6423cdfb064e7005952a7b79fe4cd7aa | https://github.com/gpein/jcache-jee7/blob/492dd3bb6423cdfb064e7005952a7b79fe4cd7aa/src/main/java/io/github/gpein/jcache/service/JCacheService.java#L52-L55 | train |
gpein/jcache-jee7 | src/main/java/io/github/gpein/jcache/service/JCacheService.java | JCacheService.setStatistics | public void setStatistics(boolean enabled) {
all().forEach(cache -> updateStatistics(cache.getName(), new Cache(false, enabled)));
} | java | public void setStatistics(boolean enabled) {
all().forEach(cache -> updateStatistics(cache.getName(), new Cache(false, enabled)));
} | [
"public",
"void",
"setStatistics",
"(",
"boolean",
"enabled",
")",
"{",
"all",
"(",
")",
".",
"forEach",
"(",
"cache",
"->",
"updateStatistics",
"(",
"cache",
".",
"getName",
"(",
")",
",",
"new",
"Cache",
"(",
"false",
",",
"enabled",
")",
")",
")",
... | Enable or disable statistics for all caches
@param enabled true for enabling all | [
"Enable",
"or",
"disable",
"statistics",
"for",
"all",
"caches"
] | 492dd3bb6423cdfb064e7005952a7b79fe4cd7aa | https://github.com/gpein/jcache-jee7/blob/492dd3bb6423cdfb064e7005952a7b79fe4cd7aa/src/main/java/io/github/gpein/jcache/service/JCacheService.java#L90-L92 | train |
gpein/jcache-jee7 | src/main/java/io/github/gpein/jcache/service/JCacheService.java | JCacheService.getStatistics | public Optional<CacheStatistics> getStatistics(String cacheName) {
javax.cache.Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return Optional.empty();
}
if (((CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class)).isStatisticsEnabled() && cache instanceof ICache) {
com.hazelcast.cache.CacheStatistics stats = ((ICache) cache).getLocalCacheStatistics();
CacheStatistics statistics = new CacheStatistics(
stats.getCacheHits(),
stats.getCacheMisses(),
stats.getCacheHitPercentage(),
stats.getCacheMissPercentage(),
stats.getCacheGets(),
stats.getCachePuts(),
stats.getCacheRemovals(),
stats.getCacheEvictions(),
stats.getAverageGetTime(),
stats.getAveragePutTime(),
stats.getAverageRemoveTime());
return Optional.of(statistics);
}
return Optional.empty();
} | java | public Optional<CacheStatistics> getStatistics(String cacheName) {
javax.cache.Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return Optional.empty();
}
if (((CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class)).isStatisticsEnabled() && cache instanceof ICache) {
com.hazelcast.cache.CacheStatistics stats = ((ICache) cache).getLocalCacheStatistics();
CacheStatistics statistics = new CacheStatistics(
stats.getCacheHits(),
stats.getCacheMisses(),
stats.getCacheHitPercentage(),
stats.getCacheMissPercentage(),
stats.getCacheGets(),
stats.getCachePuts(),
stats.getCacheRemovals(),
stats.getCacheEvictions(),
stats.getAverageGetTime(),
stats.getAveragePutTime(),
stats.getAverageRemoveTime());
return Optional.of(statistics);
}
return Optional.empty();
} | [
"public",
"Optional",
"<",
"CacheStatistics",
">",
"getStatistics",
"(",
"String",
"cacheName",
")",
"{",
"javax",
".",
"cache",
".",
"Cache",
"cache",
"=",
"cacheManager",
".",
"getCache",
"(",
"cacheName",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",... | Get a cache statistic information if available
@param cacheName name of cache
@return cache statistics or <code>Optional.empty()</code> if either cache does exist or does not provide statistics datas | [
"Get",
"a",
"cache",
"statistic",
"information",
"if",
"available"
] | 492dd3bb6423cdfb064e7005952a7b79fe4cd7aa | https://github.com/gpein/jcache-jee7/blob/492dd3bb6423cdfb064e7005952a7b79fe4cd7aa/src/main/java/io/github/gpein/jcache/service/JCacheService.java#L100-L127 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.setAttrValue | private void setAttrValue(final AttrName _attrName,
final String _value)
{
synchronized (this.attrValues) {
this.attrValues.put(_attrName, _value);
}
} | java | private void setAttrValue(final AttrName _attrName,
final String _value)
{
synchronized (this.attrValues) {
this.attrValues.put(_attrName, _value);
}
} | [
"private",
"void",
"setAttrValue",
"(",
"final",
"AttrName",
"_attrName",
",",
"final",
"String",
"_value",
")",
"{",
"synchronized",
"(",
"this",
".",
"attrValues",
")",
"{",
"this",
".",
"attrValues",
".",
"put",
"(",
"_attrName",
",",
"_value",
")",
";"... | The method sets the attribute values in the cache for given attribute
name to given new attribute value.
@param _attrName name of attribute to set
@param _value new value to set
@see #attrValues | [
"The",
"method",
"sets",
"the",
"attribute",
"values",
"in",
"the",
"cache",
"for",
"given",
"attribute",
"name",
"to",
"given",
"new",
"attribute",
"value",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L464-L470 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.getLocale | public Locale getLocale()
{
final Locale ret;
if (this.attrValues.get(Person.AttrName.LOCALE) != null) {
final String localeStr = this.attrValues.get(Person.AttrName.LOCALE);
final String[] countries = localeStr.split("_");
if (countries.length == 2) {
ret = new Locale(countries[0], countries[1]);
} else if (countries.length == 3) {
ret = new Locale(countries[0], countries[1], countries[2]);
} else {
ret = new Locale(localeStr);
}
} else {
ret = Locale.ENGLISH;
}
return ret;
} | java | public Locale getLocale()
{
final Locale ret;
if (this.attrValues.get(Person.AttrName.LOCALE) != null) {
final String localeStr = this.attrValues.get(Person.AttrName.LOCALE);
final String[] countries = localeStr.split("_");
if (countries.length == 2) {
ret = new Locale(countries[0], countries[1]);
} else if (countries.length == 3) {
ret = new Locale(countries[0], countries[1], countries[2]);
} else {
ret = new Locale(localeStr);
}
} else {
ret = Locale.ENGLISH;
}
return ret;
} | [
"public",
"Locale",
"getLocale",
"(",
")",
"{",
"final",
"Locale",
"ret",
";",
"if",
"(",
"this",
".",
"attrValues",
".",
"get",
"(",
"Person",
".",
"AttrName",
".",
"LOCALE",
")",
"!=",
"null",
")",
"{",
"final",
"String",
"localeStr",
"=",
"this",
... | Method to get the Locale of this Person. Default is the "English" Locale.
@return Locale of this Person | [
"Method",
"to",
"get",
"the",
"Locale",
"of",
"this",
"Person",
".",
"Default",
"is",
"the",
"English",
"Locale",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L504-L521 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.getLanguage | public String getLanguage()
{
return this.attrValues.get(Person.AttrName.LANGUAGE) != null
? this.attrValues.get(Person.AttrName.LANGUAGE)
: Locale.ENGLISH.getISO3Language();
} | java | public String getLanguage()
{
return this.attrValues.get(Person.AttrName.LANGUAGE) != null
? this.attrValues.get(Person.AttrName.LANGUAGE)
: Locale.ENGLISH.getISO3Language();
} | [
"public",
"String",
"getLanguage",
"(",
")",
"{",
"return",
"this",
".",
"attrValues",
".",
"get",
"(",
"Person",
".",
"AttrName",
".",
"LANGUAGE",
")",
"!=",
"null",
"?",
"this",
".",
"attrValues",
".",
"get",
"(",
"Person",
".",
"AttrName",
".",
"LAN... | Method to get the Language of the UserInterface for this Person. Default
is english.
@return iso code of a language | [
"Method",
"to",
"get",
"the",
"Language",
"of",
"the",
"UserInterface",
"for",
"this",
"Person",
".",
"Default",
"is",
"english",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L529-L534 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.getTimeZone | public DateTimeZone getTimeZone()
{
return this.attrValues.get(Person.AttrName.TIMZONE) != null
? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE))
: DateTimeZone.UTC;
} | java | public DateTimeZone getTimeZone()
{
return this.attrValues.get(Person.AttrName.TIMZONE) != null
? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE))
: DateTimeZone.UTC;
} | [
"public",
"DateTimeZone",
"getTimeZone",
"(",
")",
"{",
"return",
"this",
".",
"attrValues",
".",
"get",
"(",
"Person",
".",
"AttrName",
".",
"TIMZONE",
")",
"!=",
"null",
"?",
"DateTimeZone",
".",
"forID",
"(",
"this",
".",
"attrValues",
".",
"get",
"("... | Method to get the Timezone of this Person. Default is the "UTC" Timezone.
@return Timezone of this Person | [
"Method",
"to",
"get",
"the",
"Timezone",
"of",
"this",
"Person",
".",
"Default",
"is",
"the",
"UTC",
"Timezone",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L541-L546 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.getChronologyType | public ChronologyType getChronologyType()
{
final String chronoKey = this.attrValues.get(Person.AttrName.CHRONOLOGY);
final ChronologyType chronoType;
if (chronoKey != null) {
chronoType = ChronologyType.getByKey(chronoKey);
} else {
chronoType = ChronologyType.ISO8601;
}
return chronoType;
} | java | public ChronologyType getChronologyType()
{
final String chronoKey = this.attrValues.get(Person.AttrName.CHRONOLOGY);
final ChronologyType chronoType;
if (chronoKey != null) {
chronoType = ChronologyType.getByKey(chronoKey);
} else {
chronoType = ChronologyType.ISO8601;
}
return chronoType;
} | [
"public",
"ChronologyType",
"getChronologyType",
"(",
")",
"{",
"final",
"String",
"chronoKey",
"=",
"this",
".",
"attrValues",
".",
"get",
"(",
"Person",
".",
"AttrName",
".",
"CHRONOLOGY",
")",
";",
"final",
"ChronologyType",
"chronoType",
";",
"if",
"(",
... | Method to get the ChronologyType of this Person. Default is the "ISO8601"
ChronologyType.
@return ChronologyType of this Person | [
"Method",
"to",
"get",
"the",
"ChronologyType",
"of",
"this",
"Person",
".",
"Default",
"is",
"the",
"ISO8601",
"ChronologyType",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L565-L575 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.checkPassword | public boolean checkPassword(final String _passwd)
throws EFapsException
{
boolean ret = false;
final PrintQuery query = new PrintQuery(CIAdminUser.Person.getType(), getId());
query.addAttribute(CIAdminUser.Person.Password,
CIAdminUser.Person.LastLogin,
CIAdminUser.Person.LoginTry,
CIAdminUser.Person.LoginTriesCounter,
CIAdminUser.Person.Status);
if (query.executeWithoutAccessCheck()) {
final PasswordStore pwd = query.<PasswordStore>getAttribute(CIAdminUser.Person.Password);
if (pwd.checkCurrent(_passwd)) {
ret = query.<Boolean>getAttribute(CIAdminUser.Person.Status);
} else {
setFalseLogin(query.<DateTime>getAttribute(CIAdminUser.Person.LoginTry),
query.<Integer>getAttribute(CIAdminUser.Person.LoginTriesCounter));
}
}
return ret;
} | java | public boolean checkPassword(final String _passwd)
throws EFapsException
{
boolean ret = false;
final PrintQuery query = new PrintQuery(CIAdminUser.Person.getType(), getId());
query.addAttribute(CIAdminUser.Person.Password,
CIAdminUser.Person.LastLogin,
CIAdminUser.Person.LoginTry,
CIAdminUser.Person.LoginTriesCounter,
CIAdminUser.Person.Status);
if (query.executeWithoutAccessCheck()) {
final PasswordStore pwd = query.<PasswordStore>getAttribute(CIAdminUser.Person.Password);
if (pwd.checkCurrent(_passwd)) {
ret = query.<Boolean>getAttribute(CIAdminUser.Person.Status);
} else {
setFalseLogin(query.<DateTime>getAttribute(CIAdminUser.Person.LoginTry),
query.<Integer>getAttribute(CIAdminUser.Person.LoginTriesCounter));
}
}
return ret;
} | [
"public",
"boolean",
"checkPassword",
"(",
"final",
"String",
"_passwd",
")",
"throws",
"EFapsException",
"{",
"boolean",
"ret",
"=",
"false",
";",
"final",
"PrintQuery",
"query",
"=",
"new",
"PrintQuery",
"(",
"CIAdminUser",
".",
"Person",
".",
"getType",
"("... | The instance method checks if the given password is the same password as
the password in the database.
@param _passwd password to check for this person
@return <i>true</i> if password is correct, otherwise <i>false</i>
@throws EFapsException if query for the password check failed | [
"The",
"instance",
"method",
"checks",
"if",
"the",
"given",
"password",
"is",
"the",
"same",
"password",
"as",
"the",
"password",
"in",
"the",
"database",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L703-L723 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.setFalseLogin | private void setFalseLogin(final DateTime _logintry,
final int _count)
throws EFapsException
{
if (_count > 0) {
final DateTime now = new DateTime(DateTimeUtil.getCurrentTimeFromDB().getTime());
final SystemConfiguration kernelConfig = EFapsSystemConfiguration.get();
final int minutes = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_TIME_RETRY);
final int maxtries = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_MAX_TRIES);
final int count = _count + 1;
if (minutes > 0 && _logintry.minusMinutes(minutes).isBefore(now)) {
updateFalseLoginDB(1);
} else {
updateFalseLoginDB(count);
}
if (maxtries > 0 && count > maxtries && getStatus()) {
setStatusInDB(false);
}
} else {
updateFalseLoginDB(1);
}
} | java | private void setFalseLogin(final DateTime _logintry,
final int _count)
throws EFapsException
{
if (_count > 0) {
final DateTime now = new DateTime(DateTimeUtil.getCurrentTimeFromDB().getTime());
final SystemConfiguration kernelConfig = EFapsSystemConfiguration.get();
final int minutes = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_TIME_RETRY);
final int maxtries = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_MAX_TRIES);
final int count = _count + 1;
if (minutes > 0 && _logintry.minusMinutes(minutes).isBefore(now)) {
updateFalseLoginDB(1);
} else {
updateFalseLoginDB(count);
}
if (maxtries > 0 && count > maxtries && getStatus()) {
setStatusInDB(false);
}
} else {
updateFalseLoginDB(1);
}
} | [
"private",
"void",
"setFalseLogin",
"(",
"final",
"DateTime",
"_logintry",
",",
"final",
"int",
"_count",
")",
"throws",
"EFapsException",
"{",
"if",
"(",
"_count",
">",
"0",
")",
"{",
"final",
"DateTime",
"now",
"=",
"new",
"DateTime",
"(",
"DateTimeUtil",
... | Method that sets the time and the number of failed logins.
@param _logintry time of the false Login
@param _count number of tries
@throws EFapsException on error | [
"Method",
"that",
"sets",
"the",
"time",
"and",
"the",
"number",
"of",
"failed",
"logins",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L732-L756 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.updateFalseLoginDB | private void updateFalseLoginDB(final int _tries)
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
final StringBuilder cmd = new StringBuilder();
try {
cmd.append("update T_USERPERSON ").append("set LOGINTRY=").append(
Context.getDbType().getCurrentTimeStamp()).append(", LOGINTRIES=").append(_tries)
.append(" where ID=").append(getId());
stmt = con.createStatement();
final int rows = stmt.executeUpdate(cmd.toString());
if (rows == 0) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'");
throw new EFapsException(getClass(), "updateLastLogin.NotUpdated", cmd.toString(), getName());
}
} catch (final SQLException e) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'", e);
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (final SQLException e) {
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
}
}
con.commit();
con.close();
} catch (final SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} | java | private void updateFalseLoginDB(final int _tries)
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
final StringBuilder cmd = new StringBuilder();
try {
cmd.append("update T_USERPERSON ").append("set LOGINTRY=").append(
Context.getDbType().getCurrentTimeStamp()).append(", LOGINTRIES=").append(_tries)
.append(" where ID=").append(getId());
stmt = con.createStatement();
final int rows = stmt.executeUpdate(cmd.toString());
if (rows == 0) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'");
throw new EFapsException(getClass(), "updateLastLogin.NotUpdated", cmd.toString(), getName());
}
} catch (final SQLException e) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'", e);
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (final SQLException e) {
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
}
}
con.commit();
con.close();
} catch (final SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} | [
"private",
"void",
"updateFalseLoginDB",
"(",
"final",
"int",
"_tries",
")",
"throws",
"EFapsException",
"{",
"Connection",
"con",
"=",
"null",
";",
"try",
"{",
"con",
"=",
"Context",
".",
"getConnection",
"(",
")",
";",
"Statement",
"stmt",
"=",
"null",
"... | Method to set the number of false Login tries in the eFaps-DataBase.
@param _tries number or tries
@throws EFapsException on error | [
"Method",
"to",
"set",
"the",
"number",
"of",
"false",
"Login",
"tries",
"in",
"the",
"eFaps",
"-",
"DataBase",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L764-L804 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.setPassword | public Status setPassword(final String _newPasswd)
throws EFapsException
{
final Type type = CIAdminUser.Person.getType();
if (_newPasswd.length() == 0) {
throw new EFapsException(getClass(), "PassWordLength", 1, _newPasswd.length());
}
final Update update = new Update(type, "" + getId());
final Status status = update.add(CIAdminUser.Person.Password, _newPasswd);
if (status.isOk()) {
update.execute();
update.close();
} else {
Person.LOG.error("Password could not be set by the Update, due to restrictions " + "e.g. length???");
throw new EFapsException(getClass(), "TODO");
}
return status;
} | java | public Status setPassword(final String _newPasswd)
throws EFapsException
{
final Type type = CIAdminUser.Person.getType();
if (_newPasswd.length() == 0) {
throw new EFapsException(getClass(), "PassWordLength", 1, _newPasswd.length());
}
final Update update = new Update(type, "" + getId());
final Status status = update.add(CIAdminUser.Person.Password, _newPasswd);
if (status.isOk()) {
update.execute();
update.close();
} else {
Person.LOG.error("Password could not be set by the Update, due to restrictions " + "e.g. length???");
throw new EFapsException(getClass(), "TODO");
}
return status;
} | [
"public",
"Status",
"setPassword",
"(",
"final",
"String",
"_newPasswd",
")",
"throws",
"EFapsException",
"{",
"final",
"Type",
"type",
"=",
"CIAdminUser",
".",
"Person",
".",
"getType",
"(",
")",
";",
"if",
"(",
"_newPasswd",
".",
"length",
"(",
")",
"=="... | The instance method sets the new password for the current context user.
Before the new password is set, some checks are made.
@param _newPasswd new Password to set
@throws EFapsException on error
@return true if password set, else false | [
"The",
"instance",
"method",
"sets",
"the",
"new",
"password",
"for",
"the",
"current",
"context",
"user",
".",
"Before",
"the",
"new",
"password",
"is",
"set",
"some",
"checks",
"are",
"made",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L814-L831 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.readFromDB | protected void readFromDB()
throws EFapsException
{
readFromDBAttributes();
this.roles.clear();
for (final Role role : getRolesFromDB()) {
add(role);
}
this.groups.clear();
for (final Group group : getGroupsFromDB(null)) {
add(group);
}
this.companies.clear();
for (final Company company : getCompaniesFromDB(null)) {
add(company);
}
this.associations.clear();
for (final Association association : getAssociationsFromDB(null)) {
add(association);
}
} | java | protected void readFromDB()
throws EFapsException
{
readFromDBAttributes();
this.roles.clear();
for (final Role role : getRolesFromDB()) {
add(role);
}
this.groups.clear();
for (final Group group : getGroupsFromDB(null)) {
add(group);
}
this.companies.clear();
for (final Company company : getCompaniesFromDB(null)) {
add(company);
}
this.associations.clear();
for (final Association association : getAssociationsFromDB(null)) {
add(association);
}
} | [
"protected",
"void",
"readFromDB",
"(",
")",
"throws",
"EFapsException",
"{",
"readFromDBAttributes",
"(",
")",
";",
"this",
".",
"roles",
".",
"clear",
"(",
")",
";",
"for",
"(",
"final",
"Role",
"role",
":",
"getRolesFromDB",
"(",
")",
")",
"{",
"add",... | The instance method reads all information from the database.
@throws EFapsException on error
@see #readFromDBAttributes() | [
"The",
"instance",
"method",
"reads",
"all",
"information",
"from",
"the",
"database",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L839-L859 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.readFromDBAttributes | private void readFromDBAttributes()
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
try {
stmt = con.createStatement();
final StringBuilder cmd = new StringBuilder("select ");
for (final AttrName attrName : Person.AttrName.values()) {
cmd.append(attrName.sqlColumn).append(",");
}
cmd.append("0 as DUMMY ").append("from V_USERPERSON ").append("where V_USERPERSON.ID=").append(getId());
final ResultSet resultset = stmt.executeQuery(cmd.toString());
if (resultset.next()) {
for (final AttrName attrName : Person.AttrName.values()) {
final String tmp = resultset.getString(attrName.sqlColumn);
setAttrValue(attrName, tmp == null ? null : tmp.trim());
}
}
resultset.close();
} catch (final SQLException e) {
Person.LOG.error("read attributes for person with SQL statement is not " + "possible", e);
throw new EFapsException(Person.class, "readFromDBAttributes.SQLException", e, getName(), getId());
} finally {
try {
if (stmt != null) {
stmt.close();
}
con.commit();
} catch (final SQLException e) {
Person.LOG.error("close of SQL statement is not possible", e);
}
}
} finally {
try {
if (con != null && !con.isClosed()) {
con.close();
}
} catch (final SQLException e) {
throw new CacheReloadException("could not read child type ids", e);
}
}
} | java | private void readFromDBAttributes()
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
try {
stmt = con.createStatement();
final StringBuilder cmd = new StringBuilder("select ");
for (final AttrName attrName : Person.AttrName.values()) {
cmd.append(attrName.sqlColumn).append(",");
}
cmd.append("0 as DUMMY ").append("from V_USERPERSON ").append("where V_USERPERSON.ID=").append(getId());
final ResultSet resultset = stmt.executeQuery(cmd.toString());
if (resultset.next()) {
for (final AttrName attrName : Person.AttrName.values()) {
final String tmp = resultset.getString(attrName.sqlColumn);
setAttrValue(attrName, tmp == null ? null : tmp.trim());
}
}
resultset.close();
} catch (final SQLException e) {
Person.LOG.error("read attributes for person with SQL statement is not " + "possible", e);
throw new EFapsException(Person.class, "readFromDBAttributes.SQLException", e, getName(), getId());
} finally {
try {
if (stmt != null) {
stmt.close();
}
con.commit();
} catch (final SQLException e) {
Person.LOG.error("close of SQL statement is not possible", e);
}
}
} finally {
try {
if (con != null && !con.isClosed()) {
con.close();
}
} catch (final SQLException e) {
throw new CacheReloadException("could not read child type ids", e);
}
}
} | [
"private",
"void",
"readFromDBAttributes",
"(",
")",
"throws",
"EFapsException",
"{",
"Connection",
"con",
"=",
"null",
";",
"try",
"{",
"con",
"=",
"Context",
".",
"getConnection",
"(",
")",
";",
"Statement",
"stmt",
"=",
"null",
";",
"try",
"{",
"stmt",
... | All attributes from this person are read from the database.
@throws EFapsException if the attributes for this person could not be
read | [
"All",
"attributes",
"from",
"this",
"person",
"are",
"read",
"from",
"the",
"database",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L867-L913 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.setGroups | public void setGroups(final JAASSystem _jaasSystem,
final Set<Group> _groups)
throws EFapsException
{
if (_jaasSystem == null) {
throw new EFapsException(getClass(), "setGroups.nojaasSystem", getName());
}
if (_groups == null) {
throw new EFapsException(getClass(), "setGroups.noGroups", getName());
}
for (final Group group : _groups) {
add(group);
}
// current groups
final Set<Group> groupsInDb = getGroupsFromDB(_jaasSystem);
// compare new roles with current groups (add missing groups)
for (final Group group : _groups) {
if (!groupsInDb.contains(group)) {
assignGroupInDb(_jaasSystem, group);
}
}
// compare current roles with new groups (remove groups which are to
// much)
for (final Group group : groupsInDb) {
if (!_groups.contains(group)) {
unassignGroupInDb(_jaasSystem, group);
}
}
} | java | public void setGroups(final JAASSystem _jaasSystem,
final Set<Group> _groups)
throws EFapsException
{
if (_jaasSystem == null) {
throw new EFapsException(getClass(), "setGroups.nojaasSystem", getName());
}
if (_groups == null) {
throw new EFapsException(getClass(), "setGroups.noGroups", getName());
}
for (final Group group : _groups) {
add(group);
}
// current groups
final Set<Group> groupsInDb = getGroupsFromDB(_jaasSystem);
// compare new roles with current groups (add missing groups)
for (final Group group : _groups) {
if (!groupsInDb.contains(group)) {
assignGroupInDb(_jaasSystem, group);
}
}
// compare current roles with new groups (remove groups which are to
// much)
for (final Group group : groupsInDb) {
if (!_groups.contains(group)) {
unassignGroupInDb(_jaasSystem, group);
}
}
} | [
"public",
"void",
"setGroups",
"(",
"final",
"JAASSystem",
"_jaasSystem",
",",
"final",
"Set",
"<",
"Group",
">",
"_groups",
")",
"throws",
"EFapsException",
"{",
"if",
"(",
"_jaasSystem",
"==",
"null",
")",
"{",
"throw",
"new",
"EFapsException",
"(",
"getCl... | The depending groups for the user are set for the given JAAS system. All
groups are added to the loaded groups in the cache of this person.
@param _jaasSystem JAAS system for which the roles are set
@param _groups set of groups to set for the JAAS system
@see #assignGroupInDb(JAASSystem, Group)
@see #unassignGroupInDb(JAASSystem, Group)
@throws EFapsException from calling methods | [
"The",
"depending",
"groups",
"for",
"the",
"user",
"are",
"set",
"for",
"the",
"given",
"JAAS",
"system",
".",
"All",
"groups",
"are",
"added",
"to",
"the",
"loaded",
"groups",
"in",
"the",
"cache",
"of",
"this",
"person",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L1351-L1383 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.assignGroupInDb | public void assignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
assignToUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | java | public void assignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
assignToUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | [
"public",
"void",
"assignGroupInDb",
"(",
"final",
"JAASSystem",
"_jaasSystem",
",",
"final",
"Group",
"_group",
")",
"throws",
"EFapsException",
"{",
"assignToUserObjectInDb",
"(",
"CIAdminUser",
".",
"Person2Group",
".",
"getType",
"(",
")",
",",
"_jaasSystem",
... | For this person, a group is assigned for the given JAAS system.
@param _jaasSystem JAAS system for which the group is assigned
@param _group group to assign
@throws EFapsException on error
@see AbstractUserObject#assignToUserObjectInDb | [
"For",
"this",
"person",
"a",
"group",
"is",
"assigned",
"for",
"the",
"given",
"JAAS",
"system",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L1393-L1398 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.unassignGroupInDb | public void unassignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
unassignFromUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | java | public void unassignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
unassignFromUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | [
"public",
"void",
"unassignGroupInDb",
"(",
"final",
"JAASSystem",
"_jaasSystem",
",",
"final",
"Group",
"_group",
")",
"throws",
"EFapsException",
"{",
"unassignFromUserObjectInDb",
"(",
"CIAdminUser",
".",
"Person2Group",
".",
"getType",
"(",
")",
",",
"_jaasSyste... | The given group is unassigned for the given JAAS system from this person.
@param _jaasSystem JAAS system for which the role is assigned
@param _group group to unassign
@throws EFapsException on error
@see AbstractUserObject#unassignFromUserObjectInDb | [
"The",
"given",
"group",
"is",
"unassigned",
"for",
"the",
"given",
"JAAS",
"system",
"from",
"this",
"person",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L1408-L1413 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/admin/user/Person.java | Person.reset | public static void reset(final String _key)
throws EFapsException
{
final Person person;
if (UUIDUtil.isUUID(_key)) {
person = Person.get(UUID.fromString(_key));
} else {
person = Person.get(_key);
}
if (person != null) {
InfinispanCache.get().<Long, Person>getCache(Person.IDCACHE).remove(person.getId());
InfinispanCache.get().<String, Person>getCache(Person.NAMECACHE).remove(person.getName());
if (person.getUUID() != null) {
InfinispanCache.get().<UUID, Person>getCache(Person.UUIDCACHE).remove(person.getUUID());
}
}
} | java | public static void reset(final String _key)
throws EFapsException
{
final Person person;
if (UUIDUtil.isUUID(_key)) {
person = Person.get(UUID.fromString(_key));
} else {
person = Person.get(_key);
}
if (person != null) {
InfinispanCache.get().<Long, Person>getCache(Person.IDCACHE).remove(person.getId());
InfinispanCache.get().<String, Person>getCache(Person.NAMECACHE).remove(person.getName());
if (person.getUUID() != null) {
InfinispanCache.get().<UUID, Person>getCache(Person.UUIDCACHE).remove(person.getUUID());
}
}
} | [
"public",
"static",
"void",
"reset",
"(",
"final",
"String",
"_key",
")",
"throws",
"EFapsException",
"{",
"final",
"Person",
"person",
";",
"if",
"(",
"UUIDUtil",
".",
"isUUID",
"(",
"_key",
")",
")",
"{",
"person",
"=",
"Person",
".",
"get",
"(",
"UU... | Reset a person. Meaning ti will be removed from all Caches.
@param _key for the Person to be cleaned from Cache. UUID or Name.
@throws EFapsException the e faps exception | [
"Reset",
"a",
"person",
".",
"Meaning",
"ti",
"will",
"be",
"removed",
"from",
"all",
"Caches",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/user/Person.java#L1639-L1655 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.preparePostUpload | public void preparePostUpload(final List<Attachment> attachments) {
tempParts.clear();
if (!attachments.isEmpty()) {
for (Attachment a : attachments) {
if (a.getError() != null) {
errorParts.add(createErrorPart(a));
} else {
publicParts.add(createPart(a));
}
}
}
} | java | public void preparePostUpload(final List<Attachment> attachments) {
tempParts.clear();
if (!attachments.isEmpty()) {
for (Attachment a : attachments) {
if (a.getError() != null) {
errorParts.add(createErrorPart(a));
} else {
publicParts.add(createPart(a));
}
}
}
} | [
"public",
"void",
"preparePostUpload",
"(",
"final",
"List",
"<",
"Attachment",
">",
"attachments",
")",
"{",
"tempParts",
".",
"clear",
"(",
")",
";",
"if",
"(",
"!",
"attachments",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"Attachment",
"a",
":... | Replace temporary attachment parts with final parts with upload details or error message.
@param attachments List of attachments details. | [
"Replace",
"temporary",
"attachment",
"parts",
"with",
"final",
"parts",
"with",
"upload",
"details",
"or",
"error",
"message",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L118-L129 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.createErrorPart | private Part createErrorPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
} | java | private Part createErrorPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
} | [
"private",
"Part",
"createErrorPart",
"(",
"Attachment",
"a",
")",
"{",
"return",
"Part",
".",
"builder",
"(",
")",
".",
"setName",
"(",
"String",
".",
"valueOf",
"(",
"a",
".",
"hashCode",
"(",
")",
")",
")",
".",
"setSize",
"(",
"0",
")",
".",
"s... | Create message part based on attachment upload error details.
@return Message part. | [
"Create",
"message",
"part",
"based",
"on",
"attachment",
"upload",
"error",
"details",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L136-L138 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.createTempPart | private Part createTempPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_UPLOADING).setUrl(null).setData(null).build();
} | java | private Part createTempPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_UPLOADING).setUrl(null).setData(null).build();
} | [
"private",
"Part",
"createTempPart",
"(",
"Attachment",
"a",
")",
"{",
"return",
"Part",
".",
"builder",
"(",
")",
".",
"setName",
"(",
"String",
".",
"valueOf",
"(",
"a",
".",
"hashCode",
"(",
")",
")",
")",
".",
"setSize",
"(",
"0",
")",
".",
"se... | Create message part based on attachment upload. This is a temporary message to indicate that one of the attachments for this message is being uploaded.
@return Message part. | [
"Create",
"message",
"part",
"based",
"on",
"attachment",
"upload",
".",
"This",
"is",
"a",
"temporary",
"message",
"to",
"indicate",
"that",
"one",
"of",
"the",
"attachments",
"for",
"this",
"message",
"is",
"being",
"uploaded",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L145-L147 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.createPart | private Part createPart(Attachment a) {
return Part.builder().setName(a.getName() != null ? a.getName() : a.getId()).setSize(a.getSize()).setType(a.getType()).setUrl(a.getUrl()).build();
} | java | private Part createPart(Attachment a) {
return Part.builder().setName(a.getName() != null ? a.getName() : a.getId()).setSize(a.getSize()).setType(a.getType()).setUrl(a.getUrl()).build();
} | [
"private",
"Part",
"createPart",
"(",
"Attachment",
"a",
")",
"{",
"return",
"Part",
".",
"builder",
"(",
")",
".",
"setName",
"(",
"a",
".",
"getName",
"(",
")",
"!=",
"null",
"?",
"a",
".",
"getName",
"(",
")",
":",
"a",
".",
"getId",
"(",
")",... | Create message part based on attachment details.
@return Message part. | [
"Create",
"message",
"part",
"based",
"on",
"attachment",
"details",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L154-L156 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.prepareMessageToSend | public MessageToSend prepareMessageToSend() {
originalMessage.getParts().clear();
originalMessage.getParts().addAll(publicParts);
return originalMessage;
} | java | public MessageToSend prepareMessageToSend() {
originalMessage.getParts().clear();
originalMessage.getParts().addAll(publicParts);
return originalMessage;
} | [
"public",
"MessageToSend",
"prepareMessageToSend",
"(",
")",
"{",
"originalMessage",
".",
"getParts",
"(",
")",
".",
"clear",
"(",
")",
";",
"originalMessage",
".",
"getParts",
"(",
")",
".",
"addAll",
"(",
"publicParts",
")",
";",
"return",
"originalMessage",... | Prepare message to be sent through messaging service.
@return Message to be sent with messaging service. | [
"Prepare",
"message",
"to",
"be",
"sent",
"through",
"messaging",
"service",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L220-L224 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java | MessageProcessor.createFinalMessage | public ChatMessage createFinalMessage(MessageSentResponse response) {
return ChatMessage.builder()
.setMessageId(response.getId())
.setSentEventId(response.getEventId())
.setConversationId(conversationId)
.setSentBy(sender)
.setFromWhom(new Sender(sender, sender))
.setSentOn(System.currentTimeMillis())
.setParts(getAllParts())
.setMetadata(originalMessage.getMetadata()).build();
} | java | public ChatMessage createFinalMessage(MessageSentResponse response) {
return ChatMessage.builder()
.setMessageId(response.getId())
.setSentEventId(response.getEventId())
.setConversationId(conversationId)
.setSentBy(sender)
.setFromWhom(new Sender(sender, sender))
.setSentOn(System.currentTimeMillis())
.setParts(getAllParts())
.setMetadata(originalMessage.getMetadata()).build();
} | [
"public",
"ChatMessage",
"createFinalMessage",
"(",
"MessageSentResponse",
"response",
")",
"{",
"return",
"ChatMessage",
".",
"builder",
"(",
")",
".",
"setMessageId",
"(",
"response",
".",
"getId",
"(",
")",
")",
".",
"setSentEventId",
"(",
"response",
".",
... | Create a final message for a conversation. At this point we know message id and sent event id.
@param response Response from sending message call.
@return Final message to be saved in persistance store. | [
"Create",
"a",
"final",
"message",
"for",
"a",
"conversation",
".",
"At",
"this",
"point",
"we",
"know",
"message",
"id",
"and",
"sent",
"event",
"id",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L250-L260 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/Insert.java | Insert.addTables | private void addTables()
{
for (final SQLTable table : getType().getTables()) {
if (!getTable2values().containsKey(table)) {
getTable2values().put(table, new ArrayList<Value>());
}
}
} | java | private void addTables()
{
for (final SQLTable table : getType().getTables()) {
if (!getTable2values().containsKey(table)) {
getTable2values().put(table, new ArrayList<Value>());
}
}
} | [
"private",
"void",
"addTables",
"(",
")",
"{",
"for",
"(",
"final",
"SQLTable",
"table",
":",
"getType",
"(",
")",
".",
"getTables",
"(",
")",
")",
"{",
"if",
"(",
"!",
"getTable2values",
"(",
")",
".",
"containsKey",
"(",
"table",
")",
")",
"{",
"... | Add all tables of the type to the expressions, because for the type an
insert must be made for all tables!!! | [
"Add",
"all",
"tables",
"of",
"the",
"type",
"to",
"the",
"expressions",
"because",
"for",
"the",
"type",
"an",
"insert",
"must",
"be",
"made",
"for",
"all",
"tables!!!"
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/Insert.java#L115-L122 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/Insert.java | Insert.addCreateUpdateAttributes | private void addCreateUpdateAttributes() throws EFapsException
{
final Iterator<?> iter = getType().getAttributes().entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next();
final Attribute attr = (Attribute) entry.getValue();
final AttributeType attrType = attr.getAttributeType();
if (attrType.isCreateUpdate()) {
addInternal(attr, false, (Object) null);
}
if (attr.getDefaultValue() != null) {
addInternal(attr, false, attr.getDefaultValue());
}
}
} | java | private void addCreateUpdateAttributes() throws EFapsException
{
final Iterator<?> iter = getType().getAttributes().entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next();
final Attribute attr = (Attribute) entry.getValue();
final AttributeType attrType = attr.getAttributeType();
if (attrType.isCreateUpdate()) {
addInternal(attr, false, (Object) null);
}
if (attr.getDefaultValue() != null) {
addInternal(attr, false, attr.getDefaultValue());
}
}
} | [
"private",
"void",
"addCreateUpdateAttributes",
"(",
")",
"throws",
"EFapsException",
"{",
"final",
"Iterator",
"<",
"?",
">",
"iter",
"=",
"getType",
"(",
")",
".",
"getAttributes",
"(",
")",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"w... | Add all attributes of the type which must be always updated and the
default values.
@throws EFapsException from called method | [
"Add",
"all",
"attributes",
"of",
"the",
"type",
"which",
"must",
"be",
"always",
"updated",
"and",
"the",
"default",
"values",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/Insert.java#L130-L144 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/Insert.java | Insert.setExchangeIds | public Insert setExchangeIds(final Long _exchangeSystemId,
final Long _exchangeId)
{
this.exchangeSystemId = _exchangeSystemId;
this.exchangeId = _exchangeId;
return this;
} | java | public Insert setExchangeIds(final Long _exchangeSystemId,
final Long _exchangeId)
{
this.exchangeSystemId = _exchangeSystemId;
this.exchangeId = _exchangeId;
return this;
} | [
"public",
"Insert",
"setExchangeIds",
"(",
"final",
"Long",
"_exchangeSystemId",
",",
"final",
"Long",
"_exchangeId",
")",
"{",
"this",
".",
"exchangeSystemId",
"=",
"_exchangeSystemId",
";",
"this",
".",
"exchangeId",
"=",
"_exchangeId",
";",
"return",
"this",
... | Set the exchangeids for the new object.
@param _exchangeSystemId exchange system id
@param _exchangeId exhange id
@return this | [
"Set",
"the",
"exchangeids",
"for",
"the",
"new",
"object",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/Insert.java#L152-L158 | train |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/Insert.java | Insert.executeWithoutTrigger | @Override
public void executeWithoutTrigger()
throws EFapsException
{
final Context context = Context.getThreadContext();
ConnectionResource con = null;
try {
con = context.getConnectionResource();
final SQLTable mainTable = getType().getMainTable();
final long id = executeOneStatement(con, mainTable, getTable2values().get(mainTable), 0);
setInstance(Instance.get(getInstance().getType(), id));
getInstance().setExchangeId(this.exchangeId);
getInstance().setExchangeSystemId(this.exchangeSystemId);
GeneralInstance.insert(getInstance(), con);
for (final Entry<SQLTable, List<Value>> entry : getTable2values().entrySet()) {
final SQLTable table = entry.getKey();
if (!table.equals(mainTable) && !table.isReadOnly()) {
executeOneStatement(con, table, entry.getValue(), id);
}
}
Queue.registerUpdate(getInstance());
} finally {
}
} | java | @Override
public void executeWithoutTrigger()
throws EFapsException
{
final Context context = Context.getThreadContext();
ConnectionResource con = null;
try {
con = context.getConnectionResource();
final SQLTable mainTable = getType().getMainTable();
final long id = executeOneStatement(con, mainTable, getTable2values().get(mainTable), 0);
setInstance(Instance.get(getInstance().getType(), id));
getInstance().setExchangeId(this.exchangeId);
getInstance().setExchangeSystemId(this.exchangeSystemId);
GeneralInstance.insert(getInstance(), con);
for (final Entry<SQLTable, List<Value>> entry : getTable2values().entrySet()) {
final SQLTable table = entry.getKey();
if (!table.equals(mainTable) && !table.isReadOnly()) {
executeOneStatement(con, table, entry.getValue(), id);
}
}
Queue.registerUpdate(getInstance());
} finally {
}
} | [
"@",
"Override",
"public",
"void",
"executeWithoutTrigger",
"(",
")",
"throws",
"EFapsException",
"{",
"final",
"Context",
"context",
"=",
"Context",
".",
"getThreadContext",
"(",
")",
";",
"ConnectionResource",
"con",
"=",
"null",
";",
"try",
"{",
"con",
"=",... | The insert is done without calling triggers and check of access rights.
@throws EFapsException if update not possible (unique key, object does
not exists, etc...) | [
"The",
"insert",
"is",
"done",
"without",
"calling",
"triggers",
"and",
"check",
"of",
"access",
"rights",
"."
] | 04b96548f518c2386a93f5ec2b9349f9b9063859 | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/Insert.java#L209-L240 | train |
casmi/casmi | src/main/java/casmi/util/Random.java | Random.randVertex2d | public static final Vector3D randVertex2d() {
float theta = random((float)(Math.PI*2.0));
return new Vector3D(Math.cos(theta),Math.sin(theta));
} | java | public static final Vector3D randVertex2d() {
float theta = random((float)(Math.PI*2.0));
return new Vector3D(Math.cos(theta),Math.sin(theta));
} | [
"public",
"static",
"final",
"Vector3D",
"randVertex2d",
"(",
")",
"{",
"float",
"theta",
"=",
"random",
"(",
"(",
"float",
")",
"(",
"Math",
".",
"PI",
"*",
"2.0",
")",
")",
";",
"return",
"new",
"Vector3D",
"(",
"Math",
".",
"cos",
"(",
"theta",
... | returns a random Vertex that represents a point on the unit circle
@return vertex | [
"returns",
"a",
"random",
"Vertex",
"that",
"represents",
"a",
"point",
"on",
"the",
"unit",
"circle"
] | 90f6514a9cbce0685186e7a92beb69e22a3b11c4 | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/util/Random.java#L84-L87 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/model/ChatMessage.java | ChatMessage.addStatusUpdate | @SuppressLint("UseSparseArrays")
public void addStatusUpdate(ChatMessageStatus status) {
int unique = (status.getMessageId() + status.getProfileId() + status.getMessageStatus().name()).hashCode();
if (statusUpdates == null) {
statusUpdates = new HashMap<>();
}
statusUpdates.put(unique, status);
} | java | @SuppressLint("UseSparseArrays")
public void addStatusUpdate(ChatMessageStatus status) {
int unique = (status.getMessageId() + status.getProfileId() + status.getMessageStatus().name()).hashCode();
if (statusUpdates == null) {
statusUpdates = new HashMap<>();
}
statusUpdates.put(unique, status);
} | [
"@",
"SuppressLint",
"(",
"\"UseSparseArrays\"",
")",
"public",
"void",
"addStatusUpdate",
"(",
"ChatMessageStatus",
"status",
")",
"{",
"int",
"unique",
"=",
"(",
"status",
".",
"getMessageId",
"(",
")",
"+",
"status",
".",
"getProfileId",
"(",
")",
"+",
"s... | Update status list with a new status.
@param status New message status details. | [
"Update",
"status",
"list",
"with",
"a",
"new",
"status",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/model/ChatMessage.java#L176-L183 | train |
navnorth/LRJavaLib | src/com/navnorth/learningregistry/util/MapUtil.java | MapUtil.put | public static void put(Map<String,Object> structure, String name, Object object)
{
if (name != null && object != null)
{
structure.put(name, object);
}
} | java | public static void put(Map<String,Object> structure, String name, Object object)
{
if (name != null && object != null)
{
structure.put(name, object);
}
} | [
"public",
"static",
"void",
"put",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"structure",
",",
"String",
"name",
",",
"Object",
"object",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"object",
"!=",
"null",
")",
"{",
"structure",
".",
"put",... | Puts an object into a map
@param structure Map to put the object into
@param name Name of the object to add
@param object Object to add | [
"Puts",
"an",
"object",
"into",
"a",
"map"
] | 27af28b9f80d772273592414e7d0dccffaac09e1 | https://github.com/navnorth/LRJavaLib/blob/27af28b9f80d772273592414e7d0dccffaac09e1/src/com/navnorth/learningregistry/util/MapUtil.java#L41-L47 | train |
labai/ted | ted-driver/src/main/java/ted/driver/sys/TedDaoMysql.java | TedDaoMysql.createTaskInternal | protected long createTaskInternal(final String name, final String channel, final String data, final String key1, final String key2, final Long batchId, int postponeSec, TedStatus status) {
final String sqlLogId = "create_task";
if (status == null)
status = TedStatus.NEW;
String nextts = (status == TedStatus.NEW ? dbType.sql.now() + " + " + dbType.sql.intervalSeconds(postponeSec) : "null");
String sql = " insert into tedtask (taskId, `system`, name, channel, bno, status, createTs, nextTs, retries, data, key1, key2, batchId)" +
" values(null, '$sys', ?, ?, null, '$status', $now, $nextts, 0, ?, ?, ?, ?)" +
" ";
sql = sql.replace("$nextTaskId", dbType.sql.sequenceSql("SEQ_TEDTASK_ID"));
sql = sql.replace("$now", dbType.sql.now());
sql = sql.replace("$sys", thisSystem);
sql = sql.replace("$nextts", nextts);
sql = sql.replace("$status", status.toString());
final String finalSql = sql;
Long taskId = JdbcSelectTed.runInConn(dataSource, new ExecInConn<Long>() {
@Override
public Long execute(Connection connection) throws SQLException {
int res = JdbcSelectTedImpl.executeUpdate(connection, finalSql, asList(
sqlParam(name, JetJdbcParamType.STRING),
sqlParam(channel, JetJdbcParamType.STRING),
sqlParam(data, JetJdbcParamType.STRING),
sqlParam(key1, JetJdbcParamType.STRING),
sqlParam(key2, JetJdbcParamType.STRING),
sqlParam(batchId, JetJdbcParamType.LONG)
));
if (res != 1)
throw new IllegalStateException("expected 1 insert");
String sql = "select last_insert_id()";
return JdbcSelectTedImpl.selectSingleLong(connection, sql, Collections.<SqlParam>emptyList());
}
});
logger.trace("Task {} {} created successfully. ", name, taskId);
return taskId;
} | java | protected long createTaskInternal(final String name, final String channel, final String data, final String key1, final String key2, final Long batchId, int postponeSec, TedStatus status) {
final String sqlLogId = "create_task";
if (status == null)
status = TedStatus.NEW;
String nextts = (status == TedStatus.NEW ? dbType.sql.now() + " + " + dbType.sql.intervalSeconds(postponeSec) : "null");
String sql = " insert into tedtask (taskId, `system`, name, channel, bno, status, createTs, nextTs, retries, data, key1, key2, batchId)" +
" values(null, '$sys', ?, ?, null, '$status', $now, $nextts, 0, ?, ?, ?, ?)" +
" ";
sql = sql.replace("$nextTaskId", dbType.sql.sequenceSql("SEQ_TEDTASK_ID"));
sql = sql.replace("$now", dbType.sql.now());
sql = sql.replace("$sys", thisSystem);
sql = sql.replace("$nextts", nextts);
sql = sql.replace("$status", status.toString());
final String finalSql = sql;
Long taskId = JdbcSelectTed.runInConn(dataSource, new ExecInConn<Long>() {
@Override
public Long execute(Connection connection) throws SQLException {
int res = JdbcSelectTedImpl.executeUpdate(connection, finalSql, asList(
sqlParam(name, JetJdbcParamType.STRING),
sqlParam(channel, JetJdbcParamType.STRING),
sqlParam(data, JetJdbcParamType.STRING),
sqlParam(key1, JetJdbcParamType.STRING),
sqlParam(key2, JetJdbcParamType.STRING),
sqlParam(batchId, JetJdbcParamType.LONG)
));
if (res != 1)
throw new IllegalStateException("expected 1 insert");
String sql = "select last_insert_id()";
return JdbcSelectTedImpl.selectSingleLong(connection, sql, Collections.<SqlParam>emptyList());
}
});
logger.trace("Task {} {} created successfully. ", name, taskId);
return taskId;
} | [
"protected",
"long",
"createTaskInternal",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"channel",
",",
"final",
"String",
"data",
",",
"final",
"String",
"key1",
",",
"final",
"String",
"key2",
",",
"final",
"Long",
"batchId",
",",
"int",
"postpo... | taskid is autonumber in MySql | [
"taskid",
"is",
"autonumber",
"in",
"MySql"
] | 2ee197246a78d842c18d6780c48fd903b00608a6 | https://github.com/labai/ted/blob/2ee197246a78d842c18d6780c48fd903b00608a6/ted-driver/src/main/java/ted/driver/sys/TedDaoMysql.java#L36-L73 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.escape | public static String escape(String literal)
{
StringBuilder sb = new StringBuilder();
for (int ii = 0; ii < literal.length(); ii++)
{
char cc = literal.charAt(ii);
switch (cc)
{
case '[':
case ']':
case '(':
case ')':
case '\\':
case '-':
case '^':
case '*':
case '+':
case '?':
case '|':
case '.':
case '{':
case '}':
case '&':
case '$':
case ',':
sb.append("\\").append(cc);
break;
default:
sb.append(cc);
break;
}
}
return sb.toString();
} | java | public static String escape(String literal)
{
StringBuilder sb = new StringBuilder();
for (int ii = 0; ii < literal.length(); ii++)
{
char cc = literal.charAt(ii);
switch (cc)
{
case '[':
case ']':
case '(':
case ')':
case '\\':
case '-':
case '^':
case '*':
case '+':
case '?':
case '|':
case '.':
case '{':
case '}':
case '&':
case '$':
case ',':
sb.append("\\").append(cc);
break;
default:
sb.append(cc);
break;
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"escape",
"(",
"String",
"literal",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"literal",
".",
"length",
"(",
")",
";",
"ii",
"++",
"... | Escapes all regex control characters returning expression suitable for
literal parsing.
@param literal
@return Escaped string | [
"Escapes",
"all",
"regex",
"control",
"characters",
"returning",
"expression",
"suitable",
"for",
"literal",
"parsing",
"."
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L183-L216 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.isMatch | public boolean isMatch(CharSequence text)
{
try
{
if (text.length() == 0)
{
return acceptEmpty;
}
InputReader reader = Input.getInstance(text);
return isMatch(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | public boolean isMatch(CharSequence text)
{
try
{
if (text.length() == 0)
{
return acceptEmpty;
}
InputReader reader = Input.getInstance(text);
return isMatch(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | [
"public",
"boolean",
"isMatch",
"(",
"CharSequence",
"text",
")",
"{",
"try",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"acceptEmpty",
";",
"}",
"InputReader",
"reader",
"=",
"Input",
".",
"getInstance",
"(",
"text... | Return true if text matches the regex
@param text
@return
@throws IOException | [
"Return",
"true",
"if",
"text",
"matches",
"the",
"regex"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L283-L298 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.isMatch | public boolean isMatch(PushbackReader input, int size) throws IOException
{
InputReader reader = Input.getInstance(input, size);
return isMatch(reader);
} | java | public boolean isMatch(PushbackReader input, int size) throws IOException
{
InputReader reader = Input.getInstance(input, size);
return isMatch(reader);
} | [
"public",
"boolean",
"isMatch",
"(",
"PushbackReader",
"input",
",",
"int",
"size",
")",
"throws",
"IOException",
"{",
"InputReader",
"reader",
"=",
"Input",
".",
"getInstance",
"(",
"input",
",",
"size",
")",
";",
"return",
"isMatch",
"(",
"reader",
")",
... | Return true if input matches the regex
@param input
@param size
@return
@throws IOException | [
"Return",
"true",
"if",
"input",
"matches",
"the",
"regex"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L307-L311 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.isMatch | public boolean isMatch(InputReader reader) throws IOException
{
int rc = match(reader);
return (rc == 1 && reader.read() == -1);
} | java | public boolean isMatch(InputReader reader) throws IOException
{
int rc = match(reader);
return (rc == 1 && reader.read() == -1);
} | [
"public",
"boolean",
"isMatch",
"(",
"InputReader",
"reader",
")",
"throws",
"IOException",
"{",
"int",
"rc",
"=",
"match",
"(",
"reader",
")",
";",
"return",
"(",
"rc",
"==",
"1",
"&&",
"reader",
".",
"read",
"(",
")",
"==",
"-",
"1",
")",
";",
"}... | Return true if input matches the regex.
@param reader
@return
@throws IOException
@throws SyntaxErrorException | [
"Return",
"true",
"if",
"input",
"matches",
"the",
"regex",
"."
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L335-L339 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.match | public String match(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
int rc = match(reader);
if (rc == 1 && reader.read() == -1)
{
return reader.getString();
}
else
{
throw new SyntaxErrorException("syntax error"
+ "\n"
+ reader.getLineNumber() + ": " + reader.getLine()
+ "\n"
+ pointer(reader.getColumnNumber() + 2));
}
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | public String match(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
int rc = match(reader);
if (rc == 1 && reader.read() == -1)
{
return reader.getString();
}
else
{
throw new SyntaxErrorException("syntax error"
+ "\n"
+ reader.getLineNumber() + ": " + reader.getLine()
+ "\n"
+ pointer(reader.getColumnNumber() + 2));
}
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | [
"public",
"String",
"match",
"(",
"CharSequence",
"text",
")",
"{",
"try",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"if",
"(",
"acceptEmpty",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"throw",
"new",
"SyntaxErr... | Attempts to match input to regex
@param text
@return
@throws SyntaxErrorException | [
"Attempts",
"to",
"match",
"input",
"to",
"regex"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L347-L381 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.lookingAt | public String lookingAt(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
return lookingAt(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | public String lookingAt(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
return lookingAt(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | [
"public",
"String",
"lookingAt",
"(",
"CharSequence",
"text",
")",
"{",
"try",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"if",
"(",
"acceptEmpty",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"throw",
"new",
"Synta... | Matches the start of text and returns the matched string
@param text
@return
@throws SyntaxErrorException | [
"Matches",
"the",
"start",
"of",
"text",
"and",
"returns",
"the",
"matched",
"string"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L546-L568 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.replace | public String replace(CharSequence text, CharSequence replacement)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(replacement);
replace(reader, caw, fsp);
return caw.toString();
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen", ex);
}
} | java | public String replace(CharSequence text, CharSequence replacement)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(replacement);
replace(reader, caw, fsp);
return caw.toString();
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen", ex);
}
} | [
"public",
"String",
"replace",
"(",
"CharSequence",
"text",
",",
"CharSequence",
"replacement",
")",
"{",
"try",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"if",
"(",
"acceptEmpty",
")",
"{",
"return",
"\"\"",
";",
"}",
"}"... | Replaces regular expression matches in text with replacement string
@param text
@param replacement
@return | [
"Replaces",
"regular",
"expression",
"matches",
"in",
"text",
"with",
"replacement",
"string"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L712-L733 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.replace | public String replace(CharSequence text, ObsoleteReplacer replacer) throws IOException
{
if (text.length() == 0)
{
return "";
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
replace(reader, caw, replacer);
return caw.toString();
} | java | public String replace(CharSequence text, ObsoleteReplacer replacer) throws IOException
{
if (text.length() == 0)
{
return "";
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
replace(reader, caw, replacer);
return caw.toString();
} | [
"public",
"String",
"replace",
"(",
"CharSequence",
"text",
",",
"ObsoleteReplacer",
"replacer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"CharArrayWriter",
"caw",
"=",
... | Replaces regular expression matches in text using replacer
@param text
@param replacer
@return
@throws IOException | [
"Replaces",
"regular",
"expression",
"matches",
"in",
"text",
"using",
"replacer"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L742-L752 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.replace | public void replace(PushbackReader in, int bufferSize, Writer out, String format) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(format);
replace(reader, out, fsp);
} | java | public void replace(PushbackReader in, int bufferSize, Writer out, String format) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(format);
replace(reader, out, fsp);
} | [
"public",
"void",
"replace",
"(",
"PushbackReader",
"in",
",",
"int",
"bufferSize",
",",
"Writer",
"out",
",",
"String",
"format",
")",
"throws",
"IOException",
"{",
"InputReader",
"reader",
"=",
"Input",
".",
"getInstance",
"(",
"in",
",",
"bufferSize",
")"... | Writes in to out replacing every match with a string
@param in
@param bufferSize
@param out
@param format
@throws java.io.IOException
@see String.format | [
"Writes",
"in",
"to",
"out",
"replacing",
"every",
"match",
"with",
"a",
"string"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L782-L787 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.replace | public void replace(PushbackReader in, int bufferSize, Writer out, ObsoleteReplacer replacer) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
replace(reader, out, replacer);
} | java | public void replace(PushbackReader in, int bufferSize, Writer out, ObsoleteReplacer replacer) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
replace(reader, out, replacer);
} | [
"public",
"void",
"replace",
"(",
"PushbackReader",
"in",
",",
"int",
"bufferSize",
",",
"Writer",
"out",
",",
"ObsoleteReplacer",
"replacer",
")",
"throws",
"IOException",
"{",
"InputReader",
"reader",
"=",
"Input",
".",
"getInstance",
"(",
"in",
",",
"buffer... | Replaces regular expression matches in input using replacer
@param in
@param bufferSize
@param out
@param replacer
@throws IOException | [
"Replaces",
"regular",
"expression",
"matches",
"in",
"input",
"using",
"replacer"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L807-L811 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.literal | public static Regex literal(String expression, Option... options) throws IOException
{
return compile(escape(expression), options);
} | java | public static Regex literal(String expression, Option... options) throws IOException
{
return compile(escape(expression), options);
} | [
"public",
"static",
"Regex",
"literal",
"(",
"String",
"expression",
",",
"Option",
"...",
"options",
")",
"throws",
"IOException",
"{",
"return",
"compile",
"(",
"escape",
"(",
"expression",
")",
",",
"options",
")",
";",
"}"
] | Compiles a literal string into RegexImpl class. This is ok for testing. use RegexBuilder
ant task for release classes
@param expression
@param options
@return
@throws IOException | [
"Compiles",
"a",
"literal",
"string",
"into",
"RegexImpl",
"class",
".",
"This",
"is",
"ok",
"for",
"testing",
".",
"use",
"RegexBuilder",
"ant",
"task",
"for",
"release",
"classes"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L1037-L1040 | train |
tvesalainen/lpg | src/main/java/org/vesalainen/regex/Regex.java | Regex.createDFA | public static DFA<Integer> createDFA(String expression, int reducer, Option... options)
{
NFA<Integer> nfa = createNFA(new Scope<NFAState<Integer>>(expression), expression, reducer, options);
DFA<Integer> dfa = nfa.constructDFA(new Scope<DFAState<Integer>>(expression));
return dfa;
} | java | public static DFA<Integer> createDFA(String expression, int reducer, Option... options)
{
NFA<Integer> nfa = createNFA(new Scope<NFAState<Integer>>(expression), expression, reducer, options);
DFA<Integer> dfa = nfa.constructDFA(new Scope<DFAState<Integer>>(expression));
return dfa;
} | [
"public",
"static",
"DFA",
"<",
"Integer",
">",
"createDFA",
"(",
"String",
"expression",
",",
"int",
"reducer",
",",
"Option",
"...",
"options",
")",
"{",
"NFA",
"<",
"Integer",
">",
"nfa",
"=",
"createNFA",
"(",
"new",
"Scope",
"<",
"NFAState",
"<",
... | Creates a DFA from regular expression
@param expression
@param reducer Reducer marks the accepting state with unique identifier
@param options
@return | [
"Creates",
"a",
"DFA",
"from",
"regular",
"expression"
] | 0917b8d295e9772b9f8a0affc258a08530cd567a | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/regex/Regex.java#L1080-L1085 | train |
labai/ted | ted-driver/src/main/java/ted/driver/sys/JdbcSelectTedImpl.java | JdbcSelectTedImpl.executeOraBlock | static <T> List<T> executeOraBlock(Connection connection, String sql, Class<T> clazz, List<SqlParam> sqlParams) throws SQLException {
String cursorParam = null;
List<T> list = new ArrayList<T>();
//boolean autoCommitOrig = connection.getAutoCommit();
//if (autoCommitOrig == true) {
// connection.setAutoCommit(false); // to able to read from temp-tables
//}
CallableStatement stmt = null;
ResultSet resultSet = null;
try {
stmt = connection.prepareCall(sql);
cursorParam = stmtAssignSqlParams(stmt, sqlParams);
boolean hasRs = stmt.execute();
if (cursorParam != null) {
resultSet = (ResultSet) stmt.getObject(cursorParam);
list = resultSetToList(resultSet, clazz);
}
} finally {
try { if (resultSet != null) resultSet.close(); } catch (Exception e) {logger.error("Cannot close resultSet", e);};
//if (autoCommitOrig == true)
// connection.setAutoCommit(autoCommitOrig);
try { if (stmt != null) stmt.close(); } catch (Exception e) {logger.error("Cannot close statement", e);};
}
return list;
} | java | static <T> List<T> executeOraBlock(Connection connection, String sql, Class<T> clazz, List<SqlParam> sqlParams) throws SQLException {
String cursorParam = null;
List<T> list = new ArrayList<T>();
//boolean autoCommitOrig = connection.getAutoCommit();
//if (autoCommitOrig == true) {
// connection.setAutoCommit(false); // to able to read from temp-tables
//}
CallableStatement stmt = null;
ResultSet resultSet = null;
try {
stmt = connection.prepareCall(sql);
cursorParam = stmtAssignSqlParams(stmt, sqlParams);
boolean hasRs = stmt.execute();
if (cursorParam != null) {
resultSet = (ResultSet) stmt.getObject(cursorParam);
list = resultSetToList(resultSet, clazz);
}
} finally {
try { if (resultSet != null) resultSet.close(); } catch (Exception e) {logger.error("Cannot close resultSet", e);};
//if (autoCommitOrig == true)
// connection.setAutoCommit(autoCommitOrig);
try { if (stmt != null) stmt.close(); } catch (Exception e) {logger.error("Cannot close statement", e);};
}
return list;
} | [
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"executeOraBlock",
"(",
"Connection",
"connection",
",",
"String",
"sql",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"List",
"<",
"SqlParam",
">",
"sqlParams",
")",
"throws",
"SQLException",
"{",
"String",
... | Execute sql block or stored procedure.
If exists output parameter with type CURSOR, then return resultSet as List of clazz type objects. | [
"Execute",
"sql",
"block",
"or",
"stored",
"procedure",
".",
"If",
"exists",
"output",
"parameter",
"with",
"type",
"CURSOR",
"then",
"return",
"resultSet",
"as",
"List",
"of",
"clazz",
"type",
"objects",
"."
] | 2ee197246a78d842c18d6780c48fd903b00608a6 | https://github.com/labai/ted/blob/2ee197246a78d842c18d6780c48fd903b00608a6/ted-driver/src/main/java/ted/driver/sys/JdbcSelectTedImpl.java#L259-L284 | train |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/PersistenceController.java | PersistenceController.loadAllConversations | Observable<List<ChatConversationBase>> loadAllConversations() {
return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
store.open();
List<ChatConversationBase> conversations = store.getAllConversations();
store.close();
emitter.onNext(conversations);
emitter.onCompleted();
}
}), Emitter.BackpressureMode.LATEST);
} | java | Observable<List<ChatConversationBase>> loadAllConversations() {
return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
store.open();
List<ChatConversationBase> conversations = store.getAllConversations();
store.close();
emitter.onNext(conversations);
emitter.onCompleted();
}
}), Emitter.BackpressureMode.LATEST);
} | [
"Observable",
"<",
"List",
"<",
"ChatConversationBase",
">",
">",
"loadAllConversations",
"(",
")",
"{",
"return",
"Observable",
".",
"create",
"(",
"emitter",
"->",
"storeFactory",
".",
"execute",
"(",
"new",
"StoreTransaction",
"<",
"ChatStore",
">",
"(",
")... | Wraps loading all conversations from store implementation into an Observable.
@return Observable returning all conversations from store. | [
"Wraps",
"loading",
"all",
"conversations",
"from",
"store",
"implementation",
"into",
"an",
"Observable",
"."
] | 388f37bfacb7793ce30c92ab70e5f32848bbe460 | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/PersistenceController.java#L81-L93 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.