id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
149,900
bwkimmel/jdcp
jdcp-console/src/main/java/ca/eandb/jdcp/client/VerifyCommand.java
VerifyCommand.verify
public void verify(String pkg, File path, Configuration conf) { if (!path.isDirectory()) { throw new IllegalArgumentException(path.getAbsolutePath().concat(" is not a directory.")); } for (File file : path.listFiles()) { if (file.isDirectory()) { verify(combine(pkg, file.getName()), file, conf); } else { String fileName = file.getName(); int extensionSeparator = fileName.lastIndexOf('.'); if (extensionSeparator >= 0) { String extension = fileName.substring(extensionSeparator + 1); if (extension.equals("class")) { String className = combine(pkg, fileName.substring(0, extensionSeparator)); try { byte[] digest = conf.getJobService().getClassDigest(className); if (digest == null) { System.out.print("? "); System.out.println(className); } else if (!matches(file, digest, conf)) { System.out.print("* "); System.out.println(className); } else if (conf.verbose) { System.out.print("= "); System.out.println(className); } } catch (FileNotFoundException e) { throw new UnexpectedException(e); } catch (IOException e) { System.out.print("E "); System.out.println(className); } } } } } }
java
public void verify(String pkg, File path, Configuration conf) { if (!path.isDirectory()) { throw new IllegalArgumentException(path.getAbsolutePath().concat(" is not a directory.")); } for (File file : path.listFiles()) { if (file.isDirectory()) { verify(combine(pkg, file.getName()), file, conf); } else { String fileName = file.getName(); int extensionSeparator = fileName.lastIndexOf('.'); if (extensionSeparator >= 0) { String extension = fileName.substring(extensionSeparator + 1); if (extension.equals("class")) { String className = combine(pkg, fileName.substring(0, extensionSeparator)); try { byte[] digest = conf.getJobService().getClassDigest(className); if (digest == null) { System.out.print("? "); System.out.println(className); } else if (!matches(file, digest, conf)) { System.out.print("* "); System.out.println(className); } else if (conf.verbose) { System.out.print("= "); System.out.println(className); } } catch (FileNotFoundException e) { throw new UnexpectedException(e); } catch (IOException e) { System.out.print("E "); System.out.println(className); } } } } } }
[ "public", "void", "verify", "(", "String", "pkg", ",", "File", "path", ",", "Configuration", "conf", ")", "{", "if", "(", "!", "path", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "path", ".", "getAbsolutePath", "(", ")", ".", "concat", "(", "\" is not a directory.\"", ")", ")", ";", "}", "for", "(", "File", "file", ":", "path", ".", "listFiles", "(", ")", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "verify", "(", "combine", "(", "pkg", ",", "file", ".", "getName", "(", ")", ")", ",", "file", ",", "conf", ")", ";", "}", "else", "{", "String", "fileName", "=", "file", ".", "getName", "(", ")", ";", "int", "extensionSeparator", "=", "fileName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "extensionSeparator", ">=", "0", ")", "{", "String", "extension", "=", "fileName", ".", "substring", "(", "extensionSeparator", "+", "1", ")", ";", "if", "(", "extension", ".", "equals", "(", "\"class\"", ")", ")", "{", "String", "className", "=", "combine", "(", "pkg", ",", "fileName", ".", "substring", "(", "0", ",", "extensionSeparator", ")", ")", ";", "try", "{", "byte", "[", "]", "digest", "=", "conf", ".", "getJobService", "(", ")", ".", "getClassDigest", "(", "className", ")", ";", "if", "(", "digest", "==", "null", ")", "{", "System", ".", "out", ".", "print", "(", "\"? \"", ")", ";", "System", ".", "out", ".", "println", "(", "className", ")", ";", "}", "else", "if", "(", "!", "matches", "(", "file", ",", "digest", ",", "conf", ")", ")", "{", "System", ".", "out", ".", "print", "(", "\"* \"", ")", ";", "System", ".", "out", ".", "println", "(", "className", ")", ";", "}", "else", "if", "(", "conf", ".", "verbose", ")", "{", "System", ".", "out", ".", "print", "(", "\"= \"", ")", ";", "System", ".", "out", ".", "println", "(", "className", ")", ";", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "UnexpectedException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "out", ".", "print", "(", "\"E \"", ")", ";", "System", ".", "out", ".", "println", "(", "className", ")", ";", "}", "}", "}", "}", "}", "}" ]
Reports classes in the specified directory tree which differ from those on the server or which do not exist on the server. @param pkg The package name associated with the root of the directory tree. @param path The <code>File</code> indicating the root of the directory tree. @param conf The application command line options.
[ "Reports", "classes", "in", "the", "specified", "directory", "tree", "which", "differ", "from", "those", "on", "the", "server", "or", "which", "do", "not", "exist", "on", "the", "server", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-console/src/main/java/ca/eandb/jdcp/client/VerifyCommand.java#L62-L99
149,901
bwkimmel/jdcp
jdcp-console/src/main/java/ca/eandb/jdcp/client/VerifyCommand.java
VerifyCommand.matches
private boolean matches(File file, byte[] digest, Configuration conf) throws IOException { byte[] fileDigest = getDigest(file, conf); return Arrays.equals(fileDigest, digest); }
java
private boolean matches(File file, byte[] digest, Configuration conf) throws IOException { byte[] fileDigest = getDigest(file, conf); return Arrays.equals(fileDigest, digest); }
[ "private", "boolean", "matches", "(", "File", "file", ",", "byte", "[", "]", "digest", ",", "Configuration", "conf", ")", "throws", "IOException", "{", "byte", "[", "]", "fileDigest", "=", "getDigest", "(", "file", ",", "conf", ")", ";", "return", "Arrays", ".", "equals", "(", "fileDigest", ",", "digest", ")", ";", "}" ]
Determines whether the digest of the specified file matches the given digest. @param file The <code>File</code> to check. @param digest The digest to compare against. @param conf The application command line options. @return A value indicating whether the digest of the specified file matches the given digest. @throws IOException If an error occurs while trying to read the file.
[ "Determines", "whether", "the", "digest", "of", "the", "specified", "file", "matches", "the", "given", "digest", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-console/src/main/java/ca/eandb/jdcp/client/VerifyCommand.java#L111-L114
149,902
SourcePond/fileobserver
fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/fs/DirectoryRebase.java
DirectoryRebase.collectExistingRoots
private Collection<Directory> collectExistingRoots(final Directory pNewRoot) { final Path parentPath = pNewRoot.getPath(); final Collection<Directory> pathsToRebase = new LinkedList<>(); dirs.entrySet().forEach(e -> { final Path childPath = e.getKey(); if (childPath.startsWith(parentPath) && e.getValue().isRoot()) { pathsToRebase.add(e.getValue()); } }); return pathsToRebase; }
java
private Collection<Directory> collectExistingRoots(final Directory pNewRoot) { final Path parentPath = pNewRoot.getPath(); final Collection<Directory> pathsToRebase = new LinkedList<>(); dirs.entrySet().forEach(e -> { final Path childPath = e.getKey(); if (childPath.startsWith(parentPath) && e.getValue().isRoot()) { pathsToRebase.add(e.getValue()); } }); return pathsToRebase; }
[ "private", "Collection", "<", "Directory", ">", "collectExistingRoots", "(", "final", "Directory", "pNewRoot", ")", "{", "final", "Path", "parentPath", "=", "pNewRoot", ".", "getPath", "(", ")", ";", "final", "Collection", "<", "Directory", ">", "pathsToRebase", "=", "new", "LinkedList", "<>", "(", ")", ";", "dirs", ".", "entrySet", "(", ")", ".", "forEach", "(", "e", "->", "{", "final", "Path", "childPath", "=", "e", ".", "getKey", "(", ")", ";", "if", "(", "childPath", ".", "startsWith", "(", "parentPath", ")", "&&", "e", ".", "getValue", "(", ")", ".", "isRoot", "(", ")", ")", "{", "pathsToRebase", ".", "add", "(", "e", ".", "getValue", "(", ")", ")", ";", "}", "}", ")", ";", "return", "pathsToRebase", ";", "}" ]
Collects all existing root directories which are children of the new root directory specified specified. @param pNewRoot New root directory to match, must not be {@code null} @return Collection of directories, never {@code null}.
[ "Collects", "all", "existing", "root", "directories", "which", "are", "children", "of", "the", "new", "root", "directory", "specified", "specified", "." ]
dfb3055ed35759a47f52f6cfdea49879c415fd6b
https://github.com/SourcePond/fileobserver/blob/dfb3055ed35759a47f52f6cfdea49879c415fd6b/fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/fs/DirectoryRebase.java#L61-L71
149,903
SourcePond/fileobserver
fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/fs/DirectoryRebase.java
DirectoryRebase.cancelAndRebaseDiscardedDirectory
void cancelAndRebaseDiscardedDirectory(final Directory pDiscardedParent) { pDiscardedParent.cancelKey(); dirs.remove(pDiscardedParent.getPath()); final List<Directory> toBeConvertedIntoRoot = new LinkedList<>(); cancelDiscardedDirectories(pDiscardedParent, toBeConvertedIntoRoot); toBeConvertedIntoRoot.forEach(d -> { final Directory root = d.toRootDirectory(); rebaseDirectSubDirectories(root); dirs.replace(d.getPath(), root); }); }
java
void cancelAndRebaseDiscardedDirectory(final Directory pDiscardedParent) { pDiscardedParent.cancelKey(); dirs.remove(pDiscardedParent.getPath()); final List<Directory> toBeConvertedIntoRoot = new LinkedList<>(); cancelDiscardedDirectories(pDiscardedParent, toBeConvertedIntoRoot); toBeConvertedIntoRoot.forEach(d -> { final Directory root = d.toRootDirectory(); rebaseDirectSubDirectories(root); dirs.replace(d.getPath(), root); }); }
[ "void", "cancelAndRebaseDiscardedDirectory", "(", "final", "Directory", "pDiscardedParent", ")", "{", "pDiscardedParent", ".", "cancelKey", "(", ")", ";", "dirs", ".", "remove", "(", "pDiscardedParent", ".", "getPath", "(", ")", ")", ";", "final", "List", "<", "Directory", ">", "toBeConvertedIntoRoot", "=", "new", "LinkedList", "<>", "(", ")", ";", "cancelDiscardedDirectories", "(", "pDiscardedParent", ",", "toBeConvertedIntoRoot", ")", ";", "toBeConvertedIntoRoot", ".", "forEach", "(", "d", "->", "{", "final", "Directory", "root", "=", "d", ".", "toRootDirectory", "(", ")", ";", "rebaseDirectSubDirectories", "(", "root", ")", ";", "dirs", ".", "replace", "(", "d", ".", "getPath", "(", ")", ",", "root", ")", ";", "}", ")", ";", "}" ]
Cancels the watch-key of the discarded directory specified. Additionally, cancels and removes any sub-directory which was not a root itself sometime in the past. Any sub-directory which was a root directory in the past will be converted back to a root-directory. @param pDiscardedParent Discarded directory, never {@code null}
[ "Cancels", "the", "watch", "-", "key", "of", "the", "discarded", "directory", "specified", ".", "Additionally", "cancels", "and", "removes", "any", "sub", "-", "directory", "which", "was", "not", "a", "root", "itself", "sometime", "in", "the", "past", ".", "Any", "sub", "-", "directory", "which", "was", "a", "root", "directory", "in", "the", "past", "will", "be", "converted", "back", "to", "a", "root", "-", "directory", "." ]
dfb3055ed35759a47f52f6cfdea49879c415fd6b
https://github.com/SourcePond/fileobserver/blob/dfb3055ed35759a47f52f6cfdea49879c415fd6b/fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/fs/DirectoryRebase.java#L150-L161
149,904
bwkimmel/jdcp
jdcp-console/src/main/java/ca/eandb/jdcp/console/WorkerState.java
WorkerState.start
@CommandArgument public void start( @OptionArgument("ncpus") int numberOfCpus, @OptionArgument("host") final String host, @OptionArgument("username") final String username, @OptionArgument("password") final String password, @OptionArgument(value="nodb", shortKey='i') final boolean internal, @OptionArgument("courtesy") final String courtesyCommand, @OptionArgument(value="courtesyWorkingDirectory", shortKey='W') File courtesyWorkingDirectory, @OptionArgument(value="courtesyPollingInterval", shortKey='P') long courtesyPollingInterval ) { int availableCpus = Runtime.getRuntime().availableProcessors(); if (numberOfCpus <= 0 || numberOfCpus > availableCpus) { numberOfCpus = availableCpus; } System.out.println("Starting worker with " + Integer.toString(numberOfCpus) + " cpus"); if (worker != null) { logger.info("Shutting down worker"); worker.shutdown(); try { workerThread.join(); } catch (InterruptedException e) { } } logger.info("Starting worker"); JobServiceFactory serviceFactory = new JobServiceFactory() { public JobService connect() { return waitForService( host.equals("") ? "localhost" : host, username.equals("") ? "guest" : username, password, RECONNECT_INTERVAL); } }; CourtesyMonitor courtesyMonitor; if (!courtesyCommand.equals("")) { logger.info("Initializing courtesy monitor"); if (courtesyPollingInterval == 0) { courtesyPollingInterval = DEFAULT_COURTESY_POLLING_INTERVAL; } ExecCourtesyMonitor exec = new ExecCourtesyMonitor(courtesyCommand, courtesyWorkingDirectory); exec.startPolling(courtesyPollingInterval, TimeUnit.SECONDS); courtesyMonitor = exec; } else { courtesyMonitor = new UnconditionalCourtesyMonitor(); } ThreadFactory threadFactory = new BackgroundThreadFactory(); ProgressStateFactory monitorFactory = new ProgressStateFactory(); worker = new ThreadServiceWorker(serviceFactory, threadFactory, monitorFactory, courtesyMonitor); worker.setMaxWorkers(numberOfCpus); taskProgressStates = monitorFactory.getProgressStates(); if (!internal) { logger.info("Preparing data source"); EmbeddedDataSource ds = null; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); ds = new EmbeddedDataSource(); ds.setConnectionAttributes("create=true"); ds.setDatabaseName("classes"); worker.setDataSource(ds); } catch (ClassNotFoundException e) { logger.error("Could not locate database driver.", e); } catch (SQLException e) { logger.error("Error occurred while initializing data source.", e); } } workerThread = new Thread(worker); workerThread.start(); }
java
@CommandArgument public void start( @OptionArgument("ncpus") int numberOfCpus, @OptionArgument("host") final String host, @OptionArgument("username") final String username, @OptionArgument("password") final String password, @OptionArgument(value="nodb", shortKey='i') final boolean internal, @OptionArgument("courtesy") final String courtesyCommand, @OptionArgument(value="courtesyWorkingDirectory", shortKey='W') File courtesyWorkingDirectory, @OptionArgument(value="courtesyPollingInterval", shortKey='P') long courtesyPollingInterval ) { int availableCpus = Runtime.getRuntime().availableProcessors(); if (numberOfCpus <= 0 || numberOfCpus > availableCpus) { numberOfCpus = availableCpus; } System.out.println("Starting worker with " + Integer.toString(numberOfCpus) + " cpus"); if (worker != null) { logger.info("Shutting down worker"); worker.shutdown(); try { workerThread.join(); } catch (InterruptedException e) { } } logger.info("Starting worker"); JobServiceFactory serviceFactory = new JobServiceFactory() { public JobService connect() { return waitForService( host.equals("") ? "localhost" : host, username.equals("") ? "guest" : username, password, RECONNECT_INTERVAL); } }; CourtesyMonitor courtesyMonitor; if (!courtesyCommand.equals("")) { logger.info("Initializing courtesy monitor"); if (courtesyPollingInterval == 0) { courtesyPollingInterval = DEFAULT_COURTESY_POLLING_INTERVAL; } ExecCourtesyMonitor exec = new ExecCourtesyMonitor(courtesyCommand, courtesyWorkingDirectory); exec.startPolling(courtesyPollingInterval, TimeUnit.SECONDS); courtesyMonitor = exec; } else { courtesyMonitor = new UnconditionalCourtesyMonitor(); } ThreadFactory threadFactory = new BackgroundThreadFactory(); ProgressStateFactory monitorFactory = new ProgressStateFactory(); worker = new ThreadServiceWorker(serviceFactory, threadFactory, monitorFactory, courtesyMonitor); worker.setMaxWorkers(numberOfCpus); taskProgressStates = monitorFactory.getProgressStates(); if (!internal) { logger.info("Preparing data source"); EmbeddedDataSource ds = null; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); ds = new EmbeddedDataSource(); ds.setConnectionAttributes("create=true"); ds.setDatabaseName("classes"); worker.setDataSource(ds); } catch (ClassNotFoundException e) { logger.error("Could not locate database driver.", e); } catch (SQLException e) { logger.error("Error occurred while initializing data source.", e); } } workerThread = new Thread(worker); workerThread.start(); }
[ "@", "CommandArgument", "public", "void", "start", "(", "@", "OptionArgument", "(", "\"ncpus\"", ")", "int", "numberOfCpus", ",", "@", "OptionArgument", "(", "\"host\"", ")", "final", "String", "host", ",", "@", "OptionArgument", "(", "\"username\"", ")", "final", "String", "username", ",", "@", "OptionArgument", "(", "\"password\"", ")", "final", "String", "password", ",", "@", "OptionArgument", "(", "value", "=", "\"nodb\"", ",", "shortKey", "=", "'", "'", ")", "final", "boolean", "internal", ",", "@", "OptionArgument", "(", "\"courtesy\"", ")", "final", "String", "courtesyCommand", ",", "@", "OptionArgument", "(", "value", "=", "\"courtesyWorkingDirectory\"", ",", "shortKey", "=", "'", "'", ")", "File", "courtesyWorkingDirectory", ",", "@", "OptionArgument", "(", "value", "=", "\"courtesyPollingInterval\"", ",", "shortKey", "=", "'", "'", ")", "long", "courtesyPollingInterval", ")", "{", "int", "availableCpus", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", ";", "if", "(", "numberOfCpus", "<=", "0", "||", "numberOfCpus", ">", "availableCpus", ")", "{", "numberOfCpus", "=", "availableCpus", ";", "}", "System", ".", "out", ".", "println", "(", "\"Starting worker with \"", "+", "Integer", ".", "toString", "(", "numberOfCpus", ")", "+", "\" cpus\"", ")", ";", "if", "(", "worker", "!=", "null", ")", "{", "logger", ".", "info", "(", "\"Shutting down worker\"", ")", ";", "worker", ".", "shutdown", "(", ")", ";", "try", "{", "workerThread", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "logger", ".", "info", "(", "\"Starting worker\"", ")", ";", "JobServiceFactory", "serviceFactory", "=", "new", "JobServiceFactory", "(", ")", "{", "public", "JobService", "connect", "(", ")", "{", "return", "waitForService", "(", "host", ".", "equals", "(", "\"\"", ")", "?", "\"localhost\"", ":", "host", ",", "username", ".", "equals", "(", "\"\"", ")", "?", "\"guest\"", ":", "username", ",", "password", ",", "RECONNECT_INTERVAL", ")", ";", "}", "}", ";", "CourtesyMonitor", "courtesyMonitor", ";", "if", "(", "!", "courtesyCommand", ".", "equals", "(", "\"\"", ")", ")", "{", "logger", ".", "info", "(", "\"Initializing courtesy monitor\"", ")", ";", "if", "(", "courtesyPollingInterval", "==", "0", ")", "{", "courtesyPollingInterval", "=", "DEFAULT_COURTESY_POLLING_INTERVAL", ";", "}", "ExecCourtesyMonitor", "exec", "=", "new", "ExecCourtesyMonitor", "(", "courtesyCommand", ",", "courtesyWorkingDirectory", ")", ";", "exec", ".", "startPolling", "(", "courtesyPollingInterval", ",", "TimeUnit", ".", "SECONDS", ")", ";", "courtesyMonitor", "=", "exec", ";", "}", "else", "{", "courtesyMonitor", "=", "new", "UnconditionalCourtesyMonitor", "(", ")", ";", "}", "ThreadFactory", "threadFactory", "=", "new", "BackgroundThreadFactory", "(", ")", ";", "ProgressStateFactory", "monitorFactory", "=", "new", "ProgressStateFactory", "(", ")", ";", "worker", "=", "new", "ThreadServiceWorker", "(", "serviceFactory", ",", "threadFactory", ",", "monitorFactory", ",", "courtesyMonitor", ")", ";", "worker", ".", "setMaxWorkers", "(", "numberOfCpus", ")", ";", "taskProgressStates", "=", "monitorFactory", ".", "getProgressStates", "(", ")", ";", "if", "(", "!", "internal", ")", "{", "logger", ".", "info", "(", "\"Preparing data source\"", ")", ";", "EmbeddedDataSource", "ds", "=", "null", ";", "try", "{", "Class", ".", "forName", "(", "\"org.apache.derby.jdbc.EmbeddedDriver\"", ")", ";", "ds", "=", "new", "EmbeddedDataSource", "(", ")", ";", "ds", ".", "setConnectionAttributes", "(", "\"create=true\"", ")", ";", "ds", ".", "setDatabaseName", "(", "\"classes\"", ")", ";", "worker", ".", "setDataSource", "(", "ds", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "logger", ".", "error", "(", "\"Could not locate database driver.\"", ",", "e", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "logger", ".", "error", "(", "\"Error occurred while initializing data source.\"", ",", "e", ")", ";", "}", "}", "workerThread", "=", "new", "Thread", "(", "worker", ")", ";", "workerThread", ".", "start", "(", ")", ";", "}" ]
Starts the worker process. @param numberOfCpus The number of worker threads to spawn. @param host The name of the host to connect to. @param username The user name to log in with. @param password The password to log in with. @param internal If set, class definitions downloaded from the server will be cached in memory only. Otherwise, class definitions will be persisted to a database. @param courtesyCommand an optional shell command to be invoked periodically to query whether to continue processing worker tasks. If the shell script returns a non-zero exit code, worker tasks will be suspended. Worker tasks will resume when the shell script returns an exit code of zero. @param courtesyWorkingDirectory the working directory in which to run the {@code courtesyCommand} shell script @param courtesyPollingInterval the number of seconds between invocations of the {@code courtesyCommand} shell script
[ "Starts", "the", "worker", "process", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-console/src/main/java/ca/eandb/jdcp/console/WorkerState.java#L112-L189
149,905
bwkimmel/jdcp
jdcp-console/src/main/java/ca/eandb/jdcp/console/WorkerState.java
WorkerState.stop
@CommandArgument public void stop() { System.out.println("Stopping worker"); worker.shutdown(); workerThread.interrupt(); try { workerThread.join(); } catch (InterruptedException e) { logger.warn("Joining to worker thread interrupted", e); } worker = null; workerThread = null; taskProgressStates = null; }
java
@CommandArgument public void stop() { System.out.println("Stopping worker"); worker.shutdown(); workerThread.interrupt(); try { workerThread.join(); } catch (InterruptedException e) { logger.warn("Joining to worker thread interrupted", e); } worker = null; workerThread = null; taskProgressStates = null; }
[ "@", "CommandArgument", "public", "void", "stop", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"Stopping worker\"", ")", ";", "worker", ".", "shutdown", "(", ")", ";", "workerThread", ".", "interrupt", "(", ")", ";", "try", "{", "workerThread", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "logger", ".", "warn", "(", "\"Joining to worker thread interrupted\"", ",", "e", ")", ";", "}", "worker", "=", "null", ";", "workerThread", "=", "null", ";", "taskProgressStates", "=", "null", ";", "}" ]
Stops the worker process.
[ "Stops", "the", "worker", "process", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-console/src/main/java/ca/eandb/jdcp/console/WorkerState.java#L254-L267
149,906
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/filter/Filter.java
Filter.toJson
public ObjectNode toJson() { ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); ObjectNode attributeNode = mapper.createObjectNode(); node.put(attribute.getCode(), attributeNode); attributeNode.put("op", operation.getOp()); return node; }
java
public ObjectNode toJson() { ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); ObjectNode attributeNode = mapper.createObjectNode(); node.put(attribute.getCode(), attributeNode); attributeNode.put("op", operation.getOp()); return node; }
[ "public", "ObjectNode", "toJson", "(", ")", "{", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "ObjectNode", "node", "=", "mapper", ".", "createObjectNode", "(", ")", ";", "ObjectNode", "attributeNode", "=", "mapper", ".", "createObjectNode", "(", ")", ";", "node", ".", "put", "(", "attribute", ".", "getCode", "(", ")", ",", "attributeNode", ")", ";", "attributeNode", ".", "put", "(", "\"op\"", ",", "operation", ".", "getOp", "(", ")", ")", ";", "return", "node", ";", "}" ]
Returns a JSON representation of this filter to send to the server. Used by the SDK internally. @return a JSON representation of this filter
[ "Returns", "a", "JSON", "representation", "of", "this", "filter", "to", "send", "to", "the", "server", ".", "Used", "by", "the", "SDK", "internally", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/filter/Filter.java#L61-L70
149,907
mlhartme/mork
src/main/java/net/oneandone/mork/regexpr/Sequence.java
Sequence.createKeyword
public static RegExpr createKeyword(String str) { int i; RegExpr[] chars; if (str.length() == 1) { return new Range(str.charAt(0)); } else { chars = new RegExpr[str.length()]; for (i = 0; i < chars.length; i++) { chars[i] = new Range(str.charAt(i)); } return new Sequence(chars); } }
java
public static RegExpr createKeyword(String str) { int i; RegExpr[] chars; if (str.length() == 1) { return new Range(str.charAt(0)); } else { chars = new RegExpr[str.length()]; for (i = 0; i < chars.length; i++) { chars[i] = new Range(str.charAt(i)); } return new Sequence(chars); } }
[ "public", "static", "RegExpr", "createKeyword", "(", "String", "str", ")", "{", "int", "i", ";", "RegExpr", "[", "]", "chars", ";", "if", "(", "str", ".", "length", "(", ")", "==", "1", ")", "{", "return", "new", "Range", "(", "str", ".", "charAt", "(", "0", ")", ")", ";", "}", "else", "{", "chars", "=", "new", "RegExpr", "[", "str", ".", "length", "(", ")", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "chars", "[", "i", "]", "=", "new", "Range", "(", "str", ".", "charAt", "(", "i", ")", ")", ";", "}", "return", "new", "Sequence", "(", "chars", ")", ";", "}", "}" ]
returns a Range for strings of length 1
[ "returns", "a", "Range", "for", "strings", "of", "length", "1" ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/regexpr/Sequence.java#L42-L55
149,908
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/GenericCompiler.java
GenericCompiler.findField
private Function findField(String name) { Selection slkt; Function f; if (name.indexOf('.') == -1) { name = type.getName() + "." + name; } slkt = Method.forName(name); if (slkt.size() == 0) { f = Field.forName(name); if (f != null) { slkt = slkt.add(new Selection(f)); } } slkt = slkt.restrictArgumentCount(1); slkt = slkt.restrictArgumentType(0, type); switch (slkt.size()) { case 0: throw new RuntimeException("no such field: " + name); case 1: return slkt.getFunction(); default: throw new RuntimeException("ambiguous field: " + name); } }
java
private Function findField(String name) { Selection slkt; Function f; if (name.indexOf('.') == -1) { name = type.getName() + "." + name; } slkt = Method.forName(name); if (slkt.size() == 0) { f = Field.forName(name); if (f != null) { slkt = slkt.add(new Selection(f)); } } slkt = slkt.restrictArgumentCount(1); slkt = slkt.restrictArgumentType(0, type); switch (slkt.size()) { case 0: throw new RuntimeException("no such field: " + name); case 1: return slkt.getFunction(); default: throw new RuntimeException("ambiguous field: " + name); } }
[ "private", "Function", "findField", "(", "String", "name", ")", "{", "Selection", "slkt", ";", "Function", "f", ";", "if", "(", "name", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "name", "=", "type", ".", "getName", "(", ")", "+", "\".\"", "+", "name", ";", "}", "slkt", "=", "Method", ".", "forName", "(", "name", ")", ";", "if", "(", "slkt", ".", "size", "(", ")", "==", "0", ")", "{", "f", "=", "Field", ".", "forName", "(", "name", ")", ";", "if", "(", "f", "!=", "null", ")", "{", "slkt", "=", "slkt", ".", "add", "(", "new", "Selection", "(", "f", ")", ")", ";", "}", "}", "slkt", "=", "slkt", ".", "restrictArgumentCount", "(", "1", ")", ";", "slkt", "=", "slkt", ".", "restrictArgumentType", "(", "0", ",", "type", ")", ";", "switch", "(", "slkt", ".", "size", "(", ")", ")", "{", "case", "0", ":", "throw", "new", "RuntimeException", "(", "\"no such field: \"", "+", "name", ")", ";", "case", "1", ":", "return", "slkt", ".", "getFunction", "(", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"ambiguous field: \"", "+", "name", ")", ";", "}", "}" ]
helper method for constructor
[ "helper", "method", "for", "constructor" ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/GenericCompiler.java#L122-L146
149,909
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/GenericCompiler.java
GenericCompiler.findConstr
private java.lang.reflect.Method findConstr(String name) { Selection slkt; int i; slkt = Method.forName(name); slkt = slkt.restrictArgumentCount(fields.length); for (i = 0; i < fields.length; i++) { slkt.restrictArgumentType(i, fields[i].getReturnType()); } switch (slkt.size()) { case 0: throw new RuntimeException("no such constructor: " + name); case 1: return ((Method) slkt.getFunction()).getRaw(); default: throw new RuntimeException("constructor ambiguous: " + name); } }
java
private java.lang.reflect.Method findConstr(String name) { Selection slkt; int i; slkt = Method.forName(name); slkt = slkt.restrictArgumentCount(fields.length); for (i = 0; i < fields.length; i++) { slkt.restrictArgumentType(i, fields[i].getReturnType()); } switch (slkt.size()) { case 0: throw new RuntimeException("no such constructor: " + name); case 1: return ((Method) slkt.getFunction()).getRaw(); default: throw new RuntimeException("constructor ambiguous: " + name); } }
[ "private", "java", ".", "lang", ".", "reflect", ".", "Method", "findConstr", "(", "String", "name", ")", "{", "Selection", "slkt", ";", "int", "i", ";", "slkt", "=", "Method", ".", "forName", "(", "name", ")", ";", "slkt", "=", "slkt", ".", "restrictArgumentCount", "(", "fields", ".", "length", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "slkt", ".", "restrictArgumentType", "(", "i", ",", "fields", "[", "i", "]", ".", "getReturnType", "(", ")", ")", ";", "}", "switch", "(", "slkt", ".", "size", "(", ")", ")", "{", "case", "0", ":", "throw", "new", "RuntimeException", "(", "\"no such constructor: \"", "+", "name", ")", ";", "case", "1", ":", "return", "(", "(", "Method", ")", "slkt", ".", "getFunction", "(", ")", ")", ".", "getRaw", "(", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"constructor ambiguous: \"", "+", "name", ")", ";", "}", "}" ]
Helper method for the constructor.
[ "Helper", "method", "for", "the", "constructor", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/GenericCompiler.java#L149-L166
149,910
mlhartme/mork
src/main/java/net/oneandone/mork/scanner/Buffer.java
Buffer.resetEndOfs
public void resetEndOfs(int ofs) { if (endPageIdx == 0) { // because a precondition is that ofs is left of the // end end = ofs; } else { endPageIdx = ofs / pageSize; end = ofs % pageSize; if (end == 0 && pages.getLastNo() == endPageIdx) { // this happens if getOfs() was called after the last character of a page was read end += pageSize; endPageIdx--; } endPage = pages.get(endPageIdx); endFilled = pages.getFilled(endPageIdx); } }
java
public void resetEndOfs(int ofs) { if (endPageIdx == 0) { // because a precondition is that ofs is left of the // end end = ofs; } else { endPageIdx = ofs / pageSize; end = ofs % pageSize; if (end == 0 && pages.getLastNo() == endPageIdx) { // this happens if getOfs() was called after the last character of a page was read end += pageSize; endPageIdx--; } endPage = pages.get(endPageIdx); endFilled = pages.getFilled(endPageIdx); } }
[ "public", "void", "resetEndOfs", "(", "int", "ofs", ")", "{", "if", "(", "endPageIdx", "==", "0", ")", "{", "// because a precondition is that ofs is left of the", "// end", "end", "=", "ofs", ";", "}", "else", "{", "endPageIdx", "=", "ofs", "/", "pageSize", ";", "end", "=", "ofs", "%", "pageSize", ";", "if", "(", "end", "==", "0", "&&", "pages", ".", "getLastNo", "(", ")", "==", "endPageIdx", ")", "{", "// this happens if getOfs() was called after the last character of a page was read", "end", "+=", "pageSize", ";", "endPageIdx", "--", ";", "}", "endPage", "=", "pages", ".", "get", "(", "endPageIdx", ")", ";", "endFilled", "=", "pages", ".", "getFilled", "(", "endPageIdx", ")", ";", "}", "}" ]
Sets the current end ofs by to the specified value @param ofs &lt; getEndOfs()
[ "Sets", "the", "current", "end", "ofs", "by", "to", "the", "specified", "value" ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/scanner/Buffer.java#L119-L135
149,911
mlhartme/mork
src/main/java/net/oneandone/mork/scanner/Buffer.java
Buffer.read
public int read() throws IOException { if (end == endFilled) { switch (pages.read(endPageIdx, endFilled)) { case -1: eof = true; return Scanner.EOF; case 0: endFilled = pages.getFilled(endPageIdx); break; case 1: endPageIdx++; end = 0; endPage = pages.get(endPageIdx); endFilled = pages.getFilled(endPageIdx); break; default: throw new RuntimeException(); } } return endPage[end++]; }
java
public int read() throws IOException { if (end == endFilled) { switch (pages.read(endPageIdx, endFilled)) { case -1: eof = true; return Scanner.EOF; case 0: endFilled = pages.getFilled(endPageIdx); break; case 1: endPageIdx++; end = 0; endPage = pages.get(endPageIdx); endFilled = pages.getFilled(endPageIdx); break; default: throw new RuntimeException(); } } return endPage[end++]; }
[ "public", "int", "read", "(", ")", "throws", "IOException", "{", "if", "(", "end", "==", "endFilled", ")", "{", "switch", "(", "pages", ".", "read", "(", "endPageIdx", ",", "endFilled", ")", ")", "{", "case", "-", "1", ":", "eof", "=", "true", ";", "return", "Scanner", ".", "EOF", ";", "case", "0", ":", "endFilled", "=", "pages", ".", "getFilled", "(", "endPageIdx", ")", ";", "break", ";", "case", "1", ":", "endPageIdx", "++", ";", "end", "=", "0", ";", "endPage", "=", "pages", ".", "get", "(", "endPageIdx", ")", ";", "endFilled", "=", "pages", ".", "getFilled", "(", "endPageIdx", ")", ";", "break", ";", "default", ":", "throw", "new", "RuntimeException", "(", ")", ";", "}", "}", "return", "endPage", "[", "end", "++", "]", ";", "}" ]
Advances the end and returns the character at this positio. @return character or Scanner.EOF
[ "Advances", "the", "end", "and", "returns", "the", "character", "at", "this", "positio", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/scanner/Buffer.java#L149-L169
149,912
mlhartme/mork
src/main/java/net/oneandone/mork/scanner/Buffer.java
Buffer.eat
public void eat() { int i; if (endPageIdx == 0) { position.update(endPage, start, end); start = end; } else { position.update(pages.get(0), start, pageSize); for (i = 1; i < endPageIdx; i++) { position.update(pages.get(i), 0, pageSize); } pages.shrink(endPageIdx); endPageIdx = 0; endPage = pages.get(0); start = end; position.update(endPage, 0, start); } }
java
public void eat() { int i; if (endPageIdx == 0) { position.update(endPage, start, end); start = end; } else { position.update(pages.get(0), start, pageSize); for (i = 1; i < endPageIdx; i++) { position.update(pages.get(i), 0, pageSize); } pages.shrink(endPageIdx); endPageIdx = 0; endPage = pages.get(0); start = end; position.update(endPage, 0, start); } }
[ "public", "void", "eat", "(", ")", "{", "int", "i", ";", "if", "(", "endPageIdx", "==", "0", ")", "{", "position", ".", "update", "(", "endPage", ",", "start", ",", "end", ")", ";", "start", "=", "end", ";", "}", "else", "{", "position", ".", "update", "(", "pages", ".", "get", "(", "0", ")", ",", "start", ",", "pageSize", ")", ";", "for", "(", "i", "=", "1", ";", "i", "<", "endPageIdx", ";", "i", "++", ")", "{", "position", ".", "update", "(", "pages", ".", "get", "(", "i", ")", ",", "0", ",", "pageSize", ")", ";", "}", "pages", ".", "shrink", "(", "endPageIdx", ")", ";", "endPageIdx", "=", "0", ";", "endPage", "=", "pages", ".", "get", "(", "0", ")", ";", "start", "=", "end", ";", "position", ".", "update", "(", "endPage", ",", "0", ",", "start", ")", ";", "}", "}" ]
Move start forward to the current position.
[ "Move", "start", "forward", "to", "the", "current", "position", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/scanner/Buffer.java#L176-L193
149,913
mlhartme/mork
src/main/java/net/oneandone/mork/scanner/Buffer.java
Buffer.createString
public String createString() { int i; int count; if (endPageIdx == 0) { // speedup the most frequent situation return new String(endPage, start, end - start); } else { char[] buffer; buffer = new char[endPageIdx * pageSize + end - start]; count = pageSize - start; System.arraycopy(pages.get(0), start, buffer, 0, count); for (i = 1; i < endPageIdx; i++) { System.arraycopy(pages.get(i), 0, buffer, count, pageSize); count += pageSize; } System.arraycopy(pages.get(endPageIdx), 0, buffer, count, end); return new String(buffer); } }
java
public String createString() { int i; int count; if (endPageIdx == 0) { // speedup the most frequent situation return new String(endPage, start, end - start); } else { char[] buffer; buffer = new char[endPageIdx * pageSize + end - start]; count = pageSize - start; System.arraycopy(pages.get(0), start, buffer, 0, count); for (i = 1; i < endPageIdx; i++) { System.arraycopy(pages.get(i), 0, buffer, count, pageSize); count += pageSize; } System.arraycopy(pages.get(endPageIdx), 0, buffer, count, end); return new String(buffer); } }
[ "public", "String", "createString", "(", ")", "{", "int", "i", ";", "int", "count", ";", "if", "(", "endPageIdx", "==", "0", ")", "{", "// speedup the most frequent situation", "return", "new", "String", "(", "endPage", ",", "start", ",", "end", "-", "start", ")", ";", "}", "else", "{", "char", "[", "]", "buffer", ";", "buffer", "=", "new", "char", "[", "endPageIdx", "*", "pageSize", "+", "end", "-", "start", "]", ";", "count", "=", "pageSize", "-", "start", ";", "System", ".", "arraycopy", "(", "pages", ".", "get", "(", "0", ")", ",", "start", ",", "buffer", ",", "0", ",", "count", ")", ";", "for", "(", "i", "=", "1", ";", "i", "<", "endPageIdx", ";", "i", "++", ")", "{", "System", ".", "arraycopy", "(", "pages", ".", "get", "(", "i", ")", ",", "0", ",", "buffer", ",", "count", ",", "pageSize", ")", ";", "count", "+=", "pageSize", ";", "}", "System", ".", "arraycopy", "(", "pages", ".", "get", "(", "endPageIdx", ")", ",", "0", ",", "buffer", ",", "count", ",", "end", ")", ";", "return", "new", "String", "(", "buffer", ")", ";", "}", "}" ]
Returns the string between start and the current position.
[ "Returns", "the", "string", "between", "start", "and", "the", "current", "position", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/scanner/Buffer.java#L198-L218
149,914
eurekaclinical/javautil
src/main/java/org/arp/javautil/io/IOUtil.java
IOUtil.readResourceAsLines
public static List<String> readResourceAsLines( Class<?> classObj, String resourceName) throws IOException { InputStream in = getResourceAsStream(resourceName, classObj); try (BufferedReader buffer = new BufferedReader(new InputStreamReader(in))) { List<String> lines = new ArrayList<>(); String line; while ((line = buffer.readLine()) != null) { lines.add(line); } return lines; } }
java
public static List<String> readResourceAsLines( Class<?> classObj, String resourceName) throws IOException { InputStream in = getResourceAsStream(resourceName, classObj); try (BufferedReader buffer = new BufferedReader(new InputStreamReader(in))) { List<String> lines = new ArrayList<>(); String line; while ((line = buffer.readLine()) != null) { lines.add(line); } return lines; } }
[ "public", "static", "List", "<", "String", ">", "readResourceAsLines", "(", "Class", "<", "?", ">", "classObj", ",", "String", "resourceName", ")", "throws", "IOException", "{", "InputStream", "in", "=", "getResourceAsStream", "(", "resourceName", ",", "classObj", ")", ";", "try", "(", "BufferedReader", "buffer", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "in", ")", ")", ")", "{", "List", "<", "String", ">", "lines", "=", "new", "ArrayList", "<>", "(", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "buffer", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "lines", ".", "add", "(", "line", ")", ";", "}", "return", "lines", ";", "}", "}" ]
Reads everything from a textual resource as lines using the default character set. @param classObj the <code>Class</code> from which <code>Class.getResourceAsStream</code> is invoked. If <code>null</code>, will use <code>IOUtil.class</code>. @param resourceName a resource name <code>String</code>. @return a <code>String</code>, or <code>null</code> if <code>resourceName</code> is <code>null</code>. @return a {@link List<String>} containing the lines of the resource. @throws IOException if the resource cannot be found or if there is an error reading from it.
[ "Reads", "everything", "from", "a", "textual", "resource", "as", "lines", "using", "the", "default", "character", "set", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/io/IOUtil.java#L99-L110
149,915
eurekaclinical/javautil
src/main/java/org/arp/javautil/io/IOUtil.java
IOUtil.readPropertiesFromResource
public static void readPropertiesFromResource(Properties properties, Class<?> classObj, String resourceName) throws IOException { if (classObj == null) { throw new IllegalArgumentException("classObj cannot be null"); } if (resourceName != null) { InputStream inputStream = classObj.getResourceAsStream(resourceName); if (inputStream != null) { try { properties.load(inputStream); } finally { inputStream.close(); } } else { throw new IOException(resourceName + " not found."); } } }
java
public static void readPropertiesFromResource(Properties properties, Class<?> classObj, String resourceName) throws IOException { if (classObj == null) { throw new IllegalArgumentException("classObj cannot be null"); } if (resourceName != null) { InputStream inputStream = classObj.getResourceAsStream(resourceName); if (inputStream != null) { try { properties.load(inputStream); } finally { inputStream.close(); } } else { throw new IOException(resourceName + " not found."); } } }
[ "public", "static", "void", "readPropertiesFromResource", "(", "Properties", "properties", ",", "Class", "<", "?", ">", "classObj", ",", "String", "resourceName", ")", "throws", "IOException", "{", "if", "(", "classObj", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"classObj cannot be null\"", ")", ";", "}", "if", "(", "resourceName", "!=", "null", ")", "{", "InputStream", "inputStream", "=", "classObj", ".", "getResourceAsStream", "(", "resourceName", ")", ";", "if", "(", "inputStream", "!=", "null", ")", "{", "try", "{", "properties", ".", "load", "(", "inputStream", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "else", "{", "throw", "new", "IOException", "(", "resourceName", "+", "\" not found.\"", ")", ";", "}", "}", "}" ]
Loads properties from the given resource into the given properties object. @param properties the {@link Properties}, using the given class' <code>getResourceAsStream</code> method. @param classObj the {@link Class} whose <code>getResourceAsStream</code> method is called, cannot be <code>null</code>. @param resourceName a resource {@link String}, visible * * from <code>classObj</code>'s class loader. If <code>null</code>, this method does nothing. @throws IOException if an error occurred reading the resource.
[ "Loads", "properties", "from", "the", "given", "resource", "into", "the", "given", "properties", "object", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/io/IOUtil.java#L125-L142
149,916
eurekaclinical/javautil
src/main/java/org/arp/javautil/io/IOUtil.java
IOUtil.resourceToFile
public static File resourceToFile(String resourceName, String filePrefix, String fileSuffix) throws IOException { BufferedReader reader = new BufferedReader( new InputStreamReader(getResourceAsStream(resourceName))); File outFile = File.createTempFile(filePrefix, fileSuffix); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outFile))); int c; while ((c = reader.read()) != -1) { writer.write(c); } reader.close(); writer.close(); outFile.deleteOnExit(); return outFile; }
java
public static File resourceToFile(String resourceName, String filePrefix, String fileSuffix) throws IOException { BufferedReader reader = new BufferedReader( new InputStreamReader(getResourceAsStream(resourceName))); File outFile = File.createTempFile(filePrefix, fileSuffix); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outFile))); int c; while ((c = reader.read()) != -1) { writer.write(c); } reader.close(); writer.close(); outFile.deleteOnExit(); return outFile; }
[ "public", "static", "File", "resourceToFile", "(", "String", "resourceName", ",", "String", "filePrefix", ",", "String", "fileSuffix", ")", "throws", "IOException", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "getResourceAsStream", "(", "resourceName", ")", ")", ")", ";", "File", "outFile", "=", "File", ".", "createTempFile", "(", "filePrefix", ",", "fileSuffix", ")", ";", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "(", "outFile", ")", ")", ")", ";", "int", "c", ";", "while", "(", "(", "c", "=", "reader", ".", "read", "(", ")", ")", "!=", "-", "1", ")", "{", "writer", ".", "write", "(", "c", ")", ";", "}", "reader", ".", "close", "(", ")", ";", "writer", ".", "close", "(", ")", ";", "outFile", ".", "deleteOnExit", "(", ")", ";", "return", "outFile", ";", "}" ]
Converts a resource into a temporary file that can be read by objects that look up files by name. Returns the file that was created. The file will be deleted when the program exits. @param resourceName the resource to convert. Cannot be <code>null</code>. @param filePrefix the prefix of the temporary file. Cannot be <code>null</code>. @param fileSuffix the suffix of the temporary file. @return a temporary {@link File}. @throws IOException if an error occurs while writing the contents of the resource to the temporary file.
[ "Converts", "a", "resource", "into", "a", "temporary", "file", "that", "can", "be", "read", "by", "objects", "that", "look", "up", "files", "by", "name", ".", "Returns", "the", "file", "that", "was", "created", ".", "The", "file", "will", "be", "deleted", "when", "the", "program", "exits", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/io/IOUtil.java#L252-L269
149,917
almondtools/picklock
src/main/java/com/almondtools/picklock/ObjectSnoop.java
ObjectSnoop.isUnlockable
public List<Method> isUnlockable(Class<?> interfaceClazz) { List<Method> conflicts = new LinkedList<Method>(); for (Method method : interfaceClazz.getDeclaredMethods()) { try { findInvocationHandler(method); } catch (NoSuchMethodException e) { conflicts.add(method); } } return conflicts; }
java
public List<Method> isUnlockable(Class<?> interfaceClazz) { List<Method> conflicts = new LinkedList<Method>(); for (Method method : interfaceClazz.getDeclaredMethods()) { try { findInvocationHandler(method); } catch (NoSuchMethodException e) { conflicts.add(method); } } return conflicts; }
[ "public", "List", "<", "Method", ">", "isUnlockable", "(", "Class", "<", "?", ">", "interfaceClazz", ")", "{", "List", "<", "Method", ">", "conflicts", "=", "new", "LinkedList", "<", "Method", ">", "(", ")", ";", "for", "(", "Method", "method", ":", "interfaceClazz", ".", "getDeclaredMethods", "(", ")", ")", "{", "try", "{", "findInvocationHandler", "(", "method", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "conflicts", ".", "add", "(", "method", ")", ";", "}", "}", "return", "conflicts", ";", "}" ]
collects all methods of the given interface conflicting with the wrapped object @param interfaceClazz the interface to check on conflicts @return a list of methods conflicting
[ "collects", "all", "methods", "of", "the", "given", "interface", "conflicting", "with", "the", "wrapped", "object" ]
8ec05d58bcd1a893d8d5fe67d2f170183c80012f
https://github.com/almondtools/picklock/blob/8ec05d58bcd1a893d8d5fe67d2f170183c80012f/src/main/java/com/almondtools/picklock/ObjectSnoop.java#L29-L39
149,918
generators-io-projects/generators
generators-core/src/main/java/io/generators/core/GeneratorIterable.java
GeneratorIterable.iterator
@Override public Iterator<T> iterator() { return new Iterator<T>() { private int cursor = 0; @Override public boolean hasNext() { return size == INFINITE_SIZE || cursor < size; } @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } cursor++; return generator.next(); } @Override public void remove() { throw new UnsupportedOperationException("remove() operation is not supported"); } }; }
java
@Override public Iterator<T> iterator() { return new Iterator<T>() { private int cursor = 0; @Override public boolean hasNext() { return size == INFINITE_SIZE || cursor < size; } @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } cursor++; return generator.next(); } @Override public void remove() { throw new UnsupportedOperationException("remove() operation is not supported"); } }; }
[ "@", "Override", "public", "Iterator", "<", "T", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "T", ">", "(", ")", "{", "private", "int", "cursor", "=", "0", ";", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "return", "size", "==", "INFINITE_SIZE", "||", "cursor", "<", "size", ";", "}", "@", "Override", "public", "T", "next", "(", ")", "{", "if", "(", "!", "hasNext", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", ")", ";", "}", "cursor", "++", ";", "return", "generator", ".", "next", "(", ")", ";", "}", "@", "Override", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"remove() operation is not supported\"", ")", ";", "}", "}", ";", "}" ]
Provides iterator over this iterable @return iterator over this iterable
[ "Provides", "iterator", "over", "this", "iterable" ]
bee273970e638b4ed144337c442b795c816d6d61
https://github.com/generators-io-projects/generators/blob/bee273970e638b4ed144337c442b795c816d6d61/generators-core/src/main/java/io/generators/core/GeneratorIterable.java#L53-L77
149,919
icoloma/simpleds
src/main/java/org/simpleds/cache/Level1Cache.java
Level1Cache.get
@SuppressWarnings("unchecked") public <T> Map<Serializable, T> get(Collection<? extends Serializable> keys) { Map<Serializable, T> result = Maps.newHashMapWithExpectedSize(keys.size()); for (Serializable key : keys) { T value = (T) contents.getIfPresent(key); if (value != null) { result.put(key, value); } } if (log.isDebugEnabled() && !result.isEmpty()) { log.debug("Level 1 cache multiple hit: {}", result.keySet()); } return result; }
java
@SuppressWarnings("unchecked") public <T> Map<Serializable, T> get(Collection<? extends Serializable> keys) { Map<Serializable, T> result = Maps.newHashMapWithExpectedSize(keys.size()); for (Serializable key : keys) { T value = (T) contents.getIfPresent(key); if (value != null) { result.put(key, value); } } if (log.isDebugEnabled() && !result.isEmpty()) { log.debug("Level 1 cache multiple hit: {}", result.keySet()); } return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "Map", "<", "Serializable", ",", "T", ">", "get", "(", "Collection", "<", "?", "extends", "Serializable", ">", "keys", ")", "{", "Map", "<", "Serializable", ",", "T", ">", "result", "=", "Maps", ".", "newHashMapWithExpectedSize", "(", "keys", ".", "size", "(", ")", ")", ";", "for", "(", "Serializable", "key", ":", "keys", ")", "{", "T", "value", "=", "(", "T", ")", "contents", ".", "getIfPresent", "(", "key", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "result", ".", "put", "(", "key", ",", "value", ")", ";", "}", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", "&&", "!", "result", ".", "isEmpty", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Level 1 cache multiple hit: {}\"", ",", "result", ".", "keySet", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Return the list of values from cache. Only entries with non-null value will be returned
[ "Return", "the", "list", "of", "values", "from", "cache", ".", "Only", "entries", "with", "non", "-", "null", "value", "will", "be", "returned" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/cache/Level1Cache.java#L100-L113
149,920
mlhartme/mork
examples/command/src/main/java/command/Console.java
Console.createRunner
private static Thread createRunner( final String cmd, final JTextArea dest, final JDialog dialog, final JButton okButton) { return new Thread() { @Override public void run() { Process p; StringBuffer exit; Thread log1; Thread log2; exit = new StringBuffer(); try { try { p = Runtime.getRuntime().exec(cmd); } catch (IOException e) { dest.append("\nexecution failed: " + e.getMessage()); return; } log1 = createLogger(p.getInputStream(), dest); log2 = createLogger(p.getErrorStream(), dest); log1.start(); log2.start(); System.out.println("waiting"); try { log1.join(); log2.join(); // join the logger threads before waiting for // the process - otherwise the exit code can be // printed before the command output exit.append("" + p.waitFor()); } catch (InterruptedException e) { exit.append("interrupted"); } } finally { dest.append("\nfinished, exit= " + exit.toString()); okButton.setEnabled(true); System.out.println("launcher done"); } } }; }
java
private static Thread createRunner( final String cmd, final JTextArea dest, final JDialog dialog, final JButton okButton) { return new Thread() { @Override public void run() { Process p; StringBuffer exit; Thread log1; Thread log2; exit = new StringBuffer(); try { try { p = Runtime.getRuntime().exec(cmd); } catch (IOException e) { dest.append("\nexecution failed: " + e.getMessage()); return; } log1 = createLogger(p.getInputStream(), dest); log2 = createLogger(p.getErrorStream(), dest); log1.start(); log2.start(); System.out.println("waiting"); try { log1.join(); log2.join(); // join the logger threads before waiting for // the process - otherwise the exit code can be // printed before the command output exit.append("" + p.waitFor()); } catch (InterruptedException e) { exit.append("interrupted"); } } finally { dest.append("\nfinished, exit= " + exit.toString()); okButton.setEnabled(true); System.out.println("launcher done"); } } }; }
[ "private", "static", "Thread", "createRunner", "(", "final", "String", "cmd", ",", "final", "JTextArea", "dest", ",", "final", "JDialog", "dialog", ",", "final", "JButton", "okButton", ")", "{", "return", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "Process", "p", ";", "StringBuffer", "exit", ";", "Thread", "log1", ";", "Thread", "log2", ";", "exit", "=", "new", "StringBuffer", "(", ")", ";", "try", "{", "try", "{", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "cmd", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "dest", ".", "append", "(", "\"\\nexecution failed: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "return", ";", "}", "log1", "=", "createLogger", "(", "p", ".", "getInputStream", "(", ")", ",", "dest", ")", ";", "log2", "=", "createLogger", "(", "p", ".", "getErrorStream", "(", ")", ",", "dest", ")", ";", "log1", ".", "start", "(", ")", ";", "log2", ".", "start", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"waiting\"", ")", ";", "try", "{", "log1", ".", "join", "(", ")", ";", "log2", ".", "join", "(", ")", ";", "// join the logger threads before waiting for", "// the process - otherwise the exit code can be", "// printed before the command output", "exit", ".", "append", "(", "\"\"", "+", "p", ".", "waitFor", "(", ")", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "exit", ".", "append", "(", "\"interrupted\"", ")", ";", "}", "}", "finally", "{", "dest", ".", "append", "(", "\"\\nfinished, exit= \"", "+", "exit", ".", "toString", "(", ")", ")", ";", "okButton", ".", "setEnabled", "(", "true", ")", ";", "System", ".", "out", ".", "println", "(", "\"launcher done\"", ")", ";", "}", "}", "}", ";", "}" ]
Create a new thread to execute the specified command. Enables the specified button when done.
[ "Create", "a", "new", "thread", "to", "execute", "the", "specified", "command", ".", "Enables", "the", "specified", "button", "when", "done", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/examples/command/src/main/java/command/Console.java#L70-L111
149,921
Metrink/croquet
croquet-core/src/main/java/com/metrink/croquet/PidManager.java
PidManager.dropPidFile
private boolean dropPidFile() { LOG.trace("Entering dropPidFile()"); // we cannot create pid files on Windows if (System.getProperty("os.name").startsWith("Windows")) { LOG.info("Pid file creation is unsupported on Windows... skipping"); return true; } try { final String[] cmd = {"bash", "-o", "noclobber", "-c", "echo $PPID > " + pidFilename}; final Process p = Runtime.getRuntime().exec(cmd); if (p.waitFor() != 0) { LOG.error("Unable to drop PID file"); return false; } } catch (final InterruptedException | IOException e) { LOG.error("Unable to drop PID file: " + e.getMessage()); return false; } // This must be called after we've successfully dropped the PID file. Otherwise, it might clean-up another // instances PID file. Keep in mind this doesn't account for kill -9 or a hard lockup. The start-up script // should provide some additional logic to clean-up stale pid files. new File(pidFilename).deleteOnExit(); LOG.debug("Dropped PID file"); LOG.trace("Exiting dropPIDFile()"); return true; }
java
private boolean dropPidFile() { LOG.trace("Entering dropPidFile()"); // we cannot create pid files on Windows if (System.getProperty("os.name").startsWith("Windows")) { LOG.info("Pid file creation is unsupported on Windows... skipping"); return true; } try { final String[] cmd = {"bash", "-o", "noclobber", "-c", "echo $PPID > " + pidFilename}; final Process p = Runtime.getRuntime().exec(cmd); if (p.waitFor() != 0) { LOG.error("Unable to drop PID file"); return false; } } catch (final InterruptedException | IOException e) { LOG.error("Unable to drop PID file: " + e.getMessage()); return false; } // This must be called after we've successfully dropped the PID file. Otherwise, it might clean-up another // instances PID file. Keep in mind this doesn't account for kill -9 or a hard lockup. The start-up script // should provide some additional logic to clean-up stale pid files. new File(pidFilename).deleteOnExit(); LOG.debug("Dropped PID file"); LOG.trace("Exiting dropPIDFile()"); return true; }
[ "private", "boolean", "dropPidFile", "(", ")", "{", "LOG", ".", "trace", "(", "\"Entering dropPidFile()\"", ")", ";", "// we cannot create pid files on Windows", "if", "(", "System", ".", "getProperty", "(", "\"os.name\"", ")", ".", "startsWith", "(", "\"Windows\"", ")", ")", "{", "LOG", ".", "info", "(", "\"Pid file creation is unsupported on Windows... skipping\"", ")", ";", "return", "true", ";", "}", "try", "{", "final", "String", "[", "]", "cmd", "=", "{", "\"bash\"", ",", "\"-o\"", ",", "\"noclobber\"", ",", "\"-c\"", ",", "\"echo $PPID > \"", "+", "pidFilename", "}", ";", "final", "Process", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "cmd", ")", ";", "if", "(", "p", ".", "waitFor", "(", ")", "!=", "0", ")", "{", "LOG", ".", "error", "(", "\"Unable to drop PID file\"", ")", ";", "return", "false", ";", "}", "}", "catch", "(", "final", "InterruptedException", "|", "IOException", "e", ")", "{", "LOG", ".", "error", "(", "\"Unable to drop PID file: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "return", "false", ";", "}", "// This must be called after we've successfully dropped the PID file. Otherwise, it might clean-up another", "// instances PID file. Keep in mind this doesn't account for kill -9 or a hard lockup. The start-up script", "// should provide some additional logic to clean-up stale pid files.", "new", "File", "(", "pidFilename", ")", ".", "deleteOnExit", "(", ")", ";", "LOG", ".", "debug", "(", "\"Dropped PID file\"", ")", ";", "LOG", ".", "trace", "(", "\"Exiting dropPIDFile()\"", ")", ";", "return", "true", ";", "}" ]
Create a file with the current process id in it. This is a no-op on Windows. Prior copies of the file must be removed prior to launch. @return true if the pid file was successfully created
[ "Create", "a", "file", "with", "the", "current", "process", "id", "in", "it", ".", "This", "is", "a", "no", "-", "op", "on", "Windows", ".", "Prior", "copies", "of", "the", "file", "must", "be", "removed", "prior", "to", "launch", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/PidManager.java#L52-L82
149,922
craterdog/java-general-utilities
src/main/java/craterdog/utils/Base64Utils.java
Base64Utils.encode
public static String encode(byte[] bytes, String indentation) { int length = bytes.length; if (length == 0) return ""; // empty byte array String encoded = Base64.encodeBase64String(bytes).replaceAll("\\s", ""); // remove all white space StringBuilder result = new StringBuilder(); if (indentation != null) result.append(indentation); result.append(encoded.charAt(0)); for (int c = 1; c < encoded.length(); c++) { if (c % 80 == 0) { // format to indented 80 character blocks result.append("\n"); if (indentation != null) result.append(indentation); } result.append(encoded.charAt(c)); } return result.toString(); }
java
public static String encode(byte[] bytes, String indentation) { int length = bytes.length; if (length == 0) return ""; // empty byte array String encoded = Base64.encodeBase64String(bytes).replaceAll("\\s", ""); // remove all white space StringBuilder result = new StringBuilder(); if (indentation != null) result.append(indentation); result.append(encoded.charAt(0)); for (int c = 1; c < encoded.length(); c++) { if (c % 80 == 0) { // format to indented 80 character blocks result.append("\n"); if (indentation != null) result.append(indentation); } result.append(encoded.charAt(c)); } return result.toString(); }
[ "public", "static", "String", "encode", "(", "byte", "[", "]", "bytes", ",", "String", "indentation", ")", "{", "int", "length", "=", "bytes", ".", "length", ";", "if", "(", "length", "==", "0", ")", "return", "\"\"", ";", "// empty byte array", "String", "encoded", "=", "Base64", ".", "encodeBase64String", "(", "bytes", ")", ".", "replaceAll", "(", "\"\\\\s\"", ",", "\"\"", ")", ";", "// remove all white space", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "indentation", "!=", "null", ")", "result", ".", "append", "(", "indentation", ")", ";", "result", ".", "append", "(", "encoded", ".", "charAt", "(", "0", ")", ")", ";", "for", "(", "int", "c", "=", "1", ";", "c", "<", "encoded", ".", "length", "(", ")", ";", "c", "++", ")", "{", "if", "(", "c", "%", "80", "==", "0", ")", "{", "// format to indented 80 character blocks", "result", ".", "append", "(", "\"\\n\"", ")", ";", "if", "(", "indentation", "!=", "null", ")", "result", ".", "append", "(", "indentation", ")", ";", "}", "result", ".", "append", "(", "encoded", ".", "charAt", "(", "c", ")", ")", ";", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
This function encodes a byte array using base 64 with a specific indentation of new lines. @param bytes The byte array to be encoded. @param indentation The indentation string to be inserted before each new line. @return The base 64 encoded string.
[ "This", "function", "encodes", "a", "byte", "array", "using", "base", "64", "with", "a", "specific", "indentation", "of", "new", "lines", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/Base64Utils.java#L42-L58
149,923
almondtools/picklock
src/main/java/com/almondtools/picklock/ObjectAccess.java
ObjectAccess.features
@SuppressWarnings("unchecked") public <T> T features(Class<T> interfaceClass) { try { List<Class<?>> todo = new ArrayList<Class<?>>(); Set<Class<?>> done = new HashSet<Class<?>>(); todo.add(interfaceClass); while (!todo.isEmpty()) { Class<?> currentClass = todo.remove(0); done.add(currentClass); for (Method method : currentClass.getDeclaredMethods()) { if (!methods.containsKey(method)) { methods.put(method, findInvocationHandler(method)); } for (Class<?> superInterfaceClazz : currentClass.getInterfaces()) { if (!done.contains(superInterfaceClazz)) { todo.add(superInterfaceClazz); } } } } return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, this); } catch (NoSuchMethodException e) { throw new PicklockException("cannot resolve method/property " + e.getMessage() + " on " + object.getClass()); } }
java
@SuppressWarnings("unchecked") public <T> T features(Class<T> interfaceClass) { try { List<Class<?>> todo = new ArrayList<Class<?>>(); Set<Class<?>> done = new HashSet<Class<?>>(); todo.add(interfaceClass); while (!todo.isEmpty()) { Class<?> currentClass = todo.remove(0); done.add(currentClass); for (Method method : currentClass.getDeclaredMethods()) { if (!methods.containsKey(method)) { methods.put(method, findInvocationHandler(method)); } for (Class<?> superInterfaceClazz : currentClass.getInterfaces()) { if (!done.contains(superInterfaceClazz)) { todo.add(superInterfaceClazz); } } } } return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, this); } catch (NoSuchMethodException e) { throw new PicklockException("cannot resolve method/property " + e.getMessage() + " on " + object.getClass()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "features", "(", "Class", "<", "T", ">", "interfaceClass", ")", "{", "try", "{", "List", "<", "Class", "<", "?", ">", ">", "todo", "=", "new", "ArrayList", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "Set", "<", "Class", "<", "?", ">", ">", "done", "=", "new", "HashSet", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "todo", ".", "add", "(", "interfaceClass", ")", ";", "while", "(", "!", "todo", ".", "isEmpty", "(", ")", ")", "{", "Class", "<", "?", ">", "currentClass", "=", "todo", ".", "remove", "(", "0", ")", ";", "done", ".", "add", "(", "currentClass", ")", ";", "for", "(", "Method", "method", ":", "currentClass", ".", "getDeclaredMethods", "(", ")", ")", "{", "if", "(", "!", "methods", ".", "containsKey", "(", "method", ")", ")", "{", "methods", ".", "put", "(", "method", ",", "findInvocationHandler", "(", "method", ")", ")", ";", "}", "for", "(", "Class", "<", "?", ">", "superInterfaceClazz", ":", "currentClass", ".", "getInterfaces", "(", ")", ")", "{", "if", "(", "!", "done", ".", "contains", "(", "superInterfaceClazz", ")", ")", "{", "todo", ".", "add", "(", "superInterfaceClazz", ")", ";", "}", "}", "}", "}", "return", "(", "T", ")", "Proxy", ".", "newProxyInstance", "(", "interfaceClass", ".", "getClassLoader", "(", ")", ",", "new", "Class", "[", "]", "{", "interfaceClass", "}", ",", "this", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "PicklockException", "(", "\"cannot resolve method/property \"", "+", "e", ".", "getMessage", "(", ")", "+", "\" on \"", "+", "object", ".", "getClass", "(", ")", ")", ";", "}", "}" ]
maps the given interface to the wrapped object @param interfaceClass the given interface class (defining the type of the result) @return an object of the type of interfaceClass (mapped to the members of the wrapped object) @throws NoSuchMethodException if a method of the interface class could not be mapped according to the upper rules
[ "maps", "the", "given", "interface", "to", "the", "wrapped", "object" ]
8ec05d58bcd1a893d8d5fe67d2f170183c80012f
https://github.com/almondtools/picklock/blob/8ec05d58bcd1a893d8d5fe67d2f170183c80012f/src/main/java/com/almondtools/picklock/ObjectAccess.java#L117-L141
149,924
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassUtils.java
ClassUtils.flatten
public static String flatten(List lines, String sep) { return flatten(lines.toArray(new Object[lines.size()]), sep); }
java
public static String flatten(List lines, String sep) { return flatten(lines.toArray(new Object[lines.size()]), sep); }
[ "public", "static", "String", "flatten", "(", "List", "lines", ",", "String", "sep", ")", "{", "return", "flatten", "(", "lines", ".", "toArray", "(", "new", "Object", "[", "lines", ".", "size", "(", ")", "]", ")", ",", "sep", ")", ";", "}" ]
Flattens the list into a single, long string. The separator string gets added between the objects, but not after the last one. @param lines the lines to flatten @param sep the separator @return the generated string
[ "Flattens", "the", "list", "into", "a", "single", "long", "string", ".", "The", "separator", "string", "gets", "added", "between", "the", "objects", "but", "not", "after", "the", "last", "one", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassUtils.java#L148-L150
149,925
craterdog/java-general-utilities
src/main/java/craterdog/utils/Base16Utils.java
Base16Utils.encode
static public String encode(byte[] bytes, String indentation) { StringBuilder result = new StringBuilder(); int length = bytes.length; if (length == 0) return ""; // empty byte array if (indentation != null) result.append(indentation); encodeByte(bytes, 0, result); for (int i = 1; i < length; i++) { if (i % 40 == 0) { // format to indented 80 character blocks result.append("\n"); if (indentation != null) result.append(indentation); } encodeByte(bytes, i, result); } return result.toString(); }
java
static public String encode(byte[] bytes, String indentation) { StringBuilder result = new StringBuilder(); int length = bytes.length; if (length == 0) return ""; // empty byte array if (indentation != null) result.append(indentation); encodeByte(bytes, 0, result); for (int i = 1; i < length; i++) { if (i % 40 == 0) { // format to indented 80 character blocks result.append("\n"); if (indentation != null) result.append(indentation); } encodeByte(bytes, i, result); } return result.toString(); }
[ "static", "public", "String", "encode", "(", "byte", "[", "]", "bytes", ",", "String", "indentation", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "int", "length", "=", "bytes", ".", "length", ";", "if", "(", "length", "==", "0", ")", "return", "\"\"", ";", "// empty byte array", "if", "(", "indentation", "!=", "null", ")", "result", ".", "append", "(", "indentation", ")", ";", "encodeByte", "(", "bytes", ",", "0", ",", "result", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "i", "%", "40", "==", "0", ")", "{", "// format to indented 80 character blocks", "result", ".", "append", "(", "\"\\n\"", ")", ";", "if", "(", "indentation", "!=", "null", ")", "result", ".", "append", "(", "indentation", ")", ";", "}", "encodeByte", "(", "bytes", ",", "i", ",", "result", ")", ";", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
This function encodes a byte array using base 16 with a specific indentation of new lines. @param bytes The byte array to be encoded. @param indentation The indentation string to be inserted before each new line. @return The base 16 encoded string.
[ "This", "function", "encodes", "a", "byte", "array", "using", "base", "16", "with", "a", "specific", "indentation", "of", "new", "lines", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/Base16Utils.java#L39-L54
149,926
craterdog/java-general-utilities
src/main/java/craterdog/utils/Base16Utils.java
Base16Utils.decode
static public byte[] decode(String base16) { String string = base16.replaceAll("\\s", ""); // remove all white space int length = string.length(); byte[] bytes = new byte[(int) Math.ceil(length / 2.0)]; for (int i = 0; i < bytes.length; i++) { decodeByte(string, i, bytes); } return bytes; }
java
static public byte[] decode(String base16) { String string = base16.replaceAll("\\s", ""); // remove all white space int length = string.length(); byte[] bytes = new byte[(int) Math.ceil(length / 2.0)]; for (int i = 0; i < bytes.length; i++) { decodeByte(string, i, bytes); } return bytes; }
[ "static", "public", "byte", "[", "]", "decode", "(", "String", "base16", ")", "{", "String", "string", "=", "base16", ".", "replaceAll", "(", "\"\\\\s\"", ",", "\"\"", ")", ";", "// remove all white space", "int", "length", "=", "string", ".", "length", "(", ")", ";", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "(", "int", ")", "Math", ".", "ceil", "(", "length", "/", "2.0", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bytes", ".", "length", ";", "i", "++", ")", "{", "decodeByte", "(", "string", ",", "i", ",", "bytes", ")", ";", "}", "return", "bytes", ";", "}" ]
This function decodes a base 16 string into its corresponding byte array. @param base16 The base 16 encoded string. @return The corresponding byte array.
[ "This", "function", "decodes", "a", "base", "16", "string", "into", "its", "corresponding", "byte", "array", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/Base16Utils.java#L63-L71
149,927
bwkimmel/jdcp
jdcp-console/src/main/java/ca/eandb/jdcp/client/ClientMain.java
ClientMain.main
public static void main(String[] args) { ArgumentProcessor<Configuration> argProcessor = new ArgumentProcessor<Configuration>(""); argProcessor.addOption("verbose", 'V', new BooleanFieldOption<Configuration>("verbose")); argProcessor.addOption("host", 'h', new StringFieldOption<Configuration>("host")); argProcessor.addOption("username", 'u', new StringFieldOption<Configuration>("username")); argProcessor.addOption("password", 'p', new StringFieldOption<Configuration>("password")); argProcessor.addCommand("verify", new VerifyCommand()); argProcessor.addCommand("sync", new SynchronizeCommand()); argProcessor.addCommand("idle", new SetIdleTimeCommand()); argProcessor.addCommand("script", new ScriptCommand()); argProcessor.addCommand("connect", new ConnectCommand()); argProcessor.setDefaultCommand(UnrecognizedCommand.getInstance()); argProcessor.process(args, new Configuration()); }
java
public static void main(String[] args) { ArgumentProcessor<Configuration> argProcessor = new ArgumentProcessor<Configuration>(""); argProcessor.addOption("verbose", 'V', new BooleanFieldOption<Configuration>("verbose")); argProcessor.addOption("host", 'h', new StringFieldOption<Configuration>("host")); argProcessor.addOption("username", 'u', new StringFieldOption<Configuration>("username")); argProcessor.addOption("password", 'p', new StringFieldOption<Configuration>("password")); argProcessor.addCommand("verify", new VerifyCommand()); argProcessor.addCommand("sync", new SynchronizeCommand()); argProcessor.addCommand("idle", new SetIdleTimeCommand()); argProcessor.addCommand("script", new ScriptCommand()); argProcessor.addCommand("connect", new ConnectCommand()); argProcessor.setDefaultCommand(UnrecognizedCommand.getInstance()); argProcessor.process(args, new Configuration()); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "ArgumentProcessor", "<", "Configuration", ">", "argProcessor", "=", "new", "ArgumentProcessor", "<", "Configuration", ">", "(", "\"\"", ")", ";", "argProcessor", ".", "addOption", "(", "\"verbose\"", ",", "'", "'", ",", "new", "BooleanFieldOption", "<", "Configuration", ">", "(", "\"verbose\"", ")", ")", ";", "argProcessor", ".", "addOption", "(", "\"host\"", ",", "'", "'", ",", "new", "StringFieldOption", "<", "Configuration", ">", "(", "\"host\"", ")", ")", ";", "argProcessor", ".", "addOption", "(", "\"username\"", ",", "'", "'", ",", "new", "StringFieldOption", "<", "Configuration", ">", "(", "\"username\"", ")", ")", ";", "argProcessor", ".", "addOption", "(", "\"password\"", ",", "'", "'", ",", "new", "StringFieldOption", "<", "Configuration", ">", "(", "\"password\"", ")", ")", ";", "argProcessor", ".", "addCommand", "(", "\"verify\"", ",", "new", "VerifyCommand", "(", ")", ")", ";", "argProcessor", ".", "addCommand", "(", "\"sync\"", ",", "new", "SynchronizeCommand", "(", ")", ")", ";", "argProcessor", ".", "addCommand", "(", "\"idle\"", ",", "new", "SetIdleTimeCommand", "(", ")", ")", ";", "argProcessor", ".", "addCommand", "(", "\"script\"", ",", "new", "ScriptCommand", "(", ")", ")", ";", "argProcessor", ".", "addCommand", "(", "\"connect\"", ",", "new", "ConnectCommand", "(", ")", ")", ";", "argProcessor", ".", "setDefaultCommand", "(", "UnrecognizedCommand", ".", "getInstance", "(", ")", ")", ";", "argProcessor", ".", "process", "(", "args", ",", "new", "Configuration", "(", ")", ")", ";", "}" ]
Application entry point. @param args Command line arguments.
[ "Application", "entry", "point", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-console/src/main/java/ca/eandb/jdcp/client/ClientMain.java#L45-L64
149,928
trustathsh/ifmapj
src/main/java/util/CanonicalXML.java
CanonicalXML.toCanonicalXml2
public String toCanonicalXml2(XMLReader parser, InputSource inputSource, boolean stripSpace) throws Exception { mStrip = stripSpace; mOut = new StringWriter(); parser.setContentHandler(this); parser.setErrorHandler(this); parser.parse(inputSource); return mOut.toString(); }
java
public String toCanonicalXml2(XMLReader parser, InputSource inputSource, boolean stripSpace) throws Exception { mStrip = stripSpace; mOut = new StringWriter(); parser.setContentHandler(this); parser.setErrorHandler(this); parser.parse(inputSource); return mOut.toString(); }
[ "public", "String", "toCanonicalXml2", "(", "XMLReader", "parser", ",", "InputSource", "inputSource", ",", "boolean", "stripSpace", ")", "throws", "Exception", "{", "mStrip", "=", "stripSpace", ";", "mOut", "=", "new", "StringWriter", "(", ")", ";", "parser", ".", "setContentHandler", "(", "this", ")", ";", "parser", ".", "setErrorHandler", "(", "this", ")", ";", "parser", ".", "parse", "(", "inputSource", ")", ";", "return", "mOut", ".", "toString", "(", ")", ";", "}" ]
Create canonical XML silently, throwing exceptions rather than displaying messages @param parser @param inputSource @param stripSpace @return @throws Exception
[ "Create", "canonical", "XML", "silently", "throwing", "exceptions", "rather", "than", "displaying", "messages" ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/util/CanonicalXML.java#L132-L139
149,929
trustathsh/ifmapj
src/main/java/util/CanonicalXML.java
CanonicalXML.toCanonicalXml3
public String toCanonicalXml3(TransformerFactory factory, XMLReader resultParser, String inxml, boolean stripSpace) throws Exception { mStrip = stripSpace; mOut = new StringWriter(); Transformer t = factory.newTransformer(); SAXSource ss = new SAXSource(resultParser, new InputSource(new StringReader(inxml))); ss.setSystemId("http://localhost/string-input"); t.setOutputProperty(OutputKeys.METHOD, "xml"); t.setOutputProperty(OutputKeys.INDENT, "no"); t.transform(ss, new SAXResult(this)); return mOut.toString(); }
java
public String toCanonicalXml3(TransformerFactory factory, XMLReader resultParser, String inxml, boolean stripSpace) throws Exception { mStrip = stripSpace; mOut = new StringWriter(); Transformer t = factory.newTransformer(); SAXSource ss = new SAXSource(resultParser, new InputSource(new StringReader(inxml))); ss.setSystemId("http://localhost/string-input"); t.setOutputProperty(OutputKeys.METHOD, "xml"); t.setOutputProperty(OutputKeys.INDENT, "no"); t.transform(ss, new SAXResult(this)); return mOut.toString(); }
[ "public", "String", "toCanonicalXml3", "(", "TransformerFactory", "factory", ",", "XMLReader", "resultParser", ",", "String", "inxml", ",", "boolean", "stripSpace", ")", "throws", "Exception", "{", "mStrip", "=", "stripSpace", ";", "mOut", "=", "new", "StringWriter", "(", ")", ";", "Transformer", "t", "=", "factory", ".", "newTransformer", "(", ")", ";", "SAXSource", "ss", "=", "new", "SAXSource", "(", "resultParser", ",", "new", "InputSource", "(", "new", "StringReader", "(", "inxml", ")", ")", ")", ";", "ss", ".", "setSystemId", "(", "\"http://localhost/string-input\"", ")", ";", "t", ".", "setOutputProperty", "(", "OutputKeys", ".", "METHOD", ",", "\"xml\"", ")", ";", "t", ".", "setOutputProperty", "(", "OutputKeys", ".", "INDENT", ",", "\"no\"", ")", ";", "t", ".", "transform", "(", "ss", ",", "new", "SAXResult", "(", "this", ")", ")", ";", "return", "mOut", ".", "toString", "(", ")", ";", "}" ]
Create canonical XML silently, throwing exceptions rather than displaying messages. This version of the method uses the Saxon identityTransformer rather than parsing directly, because for some reason we seem to be able to get XML 1.1 to work this way.
[ "Create", "canonical", "XML", "silently", "throwing", "exceptions", "rather", "than", "displaying", "messages", ".", "This", "version", "of", "the", "method", "uses", "the", "Saxon", "identityTransformer", "rather", "than", "parsing", "directly", "because", "for", "some", "reason", "we", "seem", "to", "be", "able", "to", "get", "XML", "1", ".", "1", "to", "work", "this", "way", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/util/CanonicalXML.java#L147-L158
149,930
dhemery/hartley
src/main/java/com/dhemery/polling/events/ConditionDissatisfied.java
ConditionDissatisfied.reason
public String reason() { Description description = new StringDescription(); condition.describeDissatisfactionTo(description); return description.toString(); }
java
public String reason() { Description description = new StringDescription(); condition.describeDissatisfactionTo(description); return description.toString(); }
[ "public", "String", "reason", "(", ")", "{", "Description", "description", "=", "new", "StringDescription", "(", ")", ";", "condition", ".", "describeDissatisfactionTo", "(", "description", ")", ";", "return", "description", ".", "toString", "(", ")", ";", "}" ]
The reason the condition was dissatisfied.
[ "The", "reason", "the", "condition", "was", "dissatisfied", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/polling/events/ConditionDissatisfied.java#L34-L38
149,931
SourcePond/fileobserver
fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/directory/Directory.java
Directory.streamDirectoryAndForceInform
private void streamDirectoryAndForceInform(final EventDispatcher pDispatcher) { try (final DirectoryStream<Path> stream = newDirectoryStream(getPath(), Files::isRegularFile)) { stream.forEach(p -> createKeys(p).forEach(k -> pDispatcher.modified(k, p, emptyList()))); } catch (final IOException e) { LOG.warn("Exception occurred while trying to inform single listeners!", e); } }
java
private void streamDirectoryAndForceInform(final EventDispatcher pDispatcher) { try (final DirectoryStream<Path> stream = newDirectoryStream(getPath(), Files::isRegularFile)) { stream.forEach(p -> createKeys(p).forEach(k -> pDispatcher.modified(k, p, emptyList()))); } catch (final IOException e) { LOG.warn("Exception occurred while trying to inform single listeners!", e); } }
[ "private", "void", "streamDirectoryAndForceInform", "(", "final", "EventDispatcher", "pDispatcher", ")", "{", "try", "(", "final", "DirectoryStream", "<", "Path", ">", "stream", "=", "newDirectoryStream", "(", "getPath", "(", ")", ",", "Files", "::", "isRegularFile", ")", ")", "{", "stream", ".", "forEach", "(", "p", "->", "createKeys", "(", "p", ")", ".", "forEach", "(", "k", "->", "pDispatcher", ".", "modified", "(", "k", ",", "p", ",", "emptyList", "(", ")", ")", ")", ")", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Exception occurred while trying to inform single listeners!\"", ",", "e", ")", ";", "}", "}" ]
Iterates over all files contained by this directory and informs for each entry the currently focused listener. Only direct children will be considered, sub-directories and non-regular files will be ignored.
[ "Iterates", "over", "all", "files", "contained", "by", "this", "directory", "and", "informs", "for", "each", "entry", "the", "currently", "focused", "listener", ".", "Only", "direct", "children", "will", "be", "considered", "sub", "-", "directories", "and", "non", "-", "regular", "files", "will", "be", "ignored", "." ]
dfb3055ed35759a47f52f6cfdea49879c415fd6b
https://github.com/SourcePond/fileobserver/blob/dfb3055ed35759a47f52f6cfdea49879c415fd6b/fileobserver-impl/src/main/java/ch/sourcepond/io/fileobserver/impl/directory/Directory.java#L59-L67
149,932
eurekaclinical/javautil
src/main/java/org/arp/javautil/collections/Iterators.java
Iterators.equal
public static boolean equal(Iterator itr1, Iterator itr2) { if (itr1 == null || itr2 == null) { return false; } else { while (itr1.hasNext() && itr2.hasNext()) { Object i = itr1.next(); Object i2 = itr2.next(); if ((i == null && i2 != null) || !(i.equals(i2))) { return false; } } if (itr1.hasNext() || itr2.hasNext()) { return false; } return true; } }
java
public static boolean equal(Iterator itr1, Iterator itr2) { if (itr1 == null || itr2 == null) { return false; } else { while (itr1.hasNext() && itr2.hasNext()) { Object i = itr1.next(); Object i2 = itr2.next(); if ((i == null && i2 != null) || !(i.equals(i2))) { return false; } } if (itr1.hasNext() || itr2.hasNext()) { return false; } return true; } }
[ "public", "static", "boolean", "equal", "(", "Iterator", "itr1", ",", "Iterator", "itr2", ")", "{", "if", "(", "itr1", "==", "null", "||", "itr2", "==", "null", ")", "{", "return", "false", ";", "}", "else", "{", "while", "(", "itr1", ".", "hasNext", "(", ")", "&&", "itr2", ".", "hasNext", "(", ")", ")", "{", "Object", "i", "=", "itr1", ".", "next", "(", ")", ";", "Object", "i2", "=", "itr2", ".", "next", "(", ")", ";", "if", "(", "(", "i", "==", "null", "&&", "i2", "!=", "null", ")", "||", "!", "(", "i", ".", "equals", "(", "i2", ")", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "itr1", ".", "hasNext", "(", ")", "||", "itr2", ".", "hasNext", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
Tests two iterators for equality, meaning that they have the same elements enumerated in the same order. @param itr1 an <code>Iterator</code>. @param itr2 an <code>Iterator</code>. @return <code>true</code> if the two iterators are not <code>null</code> and equal, <code>false</code> otherwise.
[ "Tests", "two", "iterators", "for", "equality", "meaning", "that", "they", "have", "the", "same", "elements", "enumerated", "in", "the", "same", "order", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/collections/Iterators.java#L43-L59
149,933
eurekaclinical/javautil
src/main/java/org/arp/javautil/collections/Iterators.java
Iterators.asList
public static <T> List<T> asList(Iterator<T> itr) { List<T> l = new ArrayList<>(); if (itr != null) { while (itr.hasNext()) { l.add(itr.next()); } } return l; }
java
public static <T> List<T> asList(Iterator<T> itr) { List<T> l = new ArrayList<>(); if (itr != null) { while (itr.hasNext()) { l.add(itr.next()); } } return l; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "asList", "(", "Iterator", "<", "T", ">", "itr", ")", "{", "List", "<", "T", ">", "l", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "itr", "!=", "null", ")", "{", "while", "(", "itr", ".", "hasNext", "(", ")", ")", "{", "l", ".", "add", "(", "itr", ".", "next", "(", ")", ")", ";", "}", "}", "return", "l", ";", "}" ]
Returns an iterator as a list. @param itr an <code>Iterator</code>. @return a <code>List</code>.
[ "Returns", "an", "iterator", "as", "a", "list", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/collections/Iterators.java#L68-L76
149,934
Terradue/jcatalogue-client
apis/src/main/java/com/terradue/jcatalogue/lang/Objects.java
Objects.hash
public static int hash( int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object...objs ) { int result = initialNonZeroOddNumber; for ( Object obj : objs ) { result = multiplierNonZeroOddNumber * result + ( obj != null ? obj.hashCode() : 0 ); } return result; }
java
public static int hash( int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object...objs ) { int result = initialNonZeroOddNumber; for ( Object obj : objs ) { result = multiplierNonZeroOddNumber * result + ( obj != null ? obj.hashCode() : 0 ); } return result; }
[ "public", "static", "int", "hash", "(", "int", "initialNonZeroOddNumber", ",", "int", "multiplierNonZeroOddNumber", ",", "Object", "...", "objs", ")", "{", "int", "result", "=", "initialNonZeroOddNumber", ";", "for", "(", "Object", "obj", ":", "objs", ")", "{", "result", "=", "multiplierNonZeroOddNumber", "*", "result", "+", "(", "obj", "!=", "null", "?", "obj", ".", "hashCode", "(", ")", ":", "0", ")", ";", "}", "return", "result", ";", "}" ]
Computes a hashCode given the input objects. @param initialNonZeroOddNumber a non-zero, odd number used as the initial value. @param multiplierNonZeroOddNumber a non-zero, odd number used as the multiplier. @param objs the objects to compute hash code. @return the computed hashCode.
[ "Computes", "a", "hashCode", "given", "the", "input", "objects", "." ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/apis/src/main/java/com/terradue/jcatalogue/lang/Objects.java#L42-L50
149,935
dhemery/hartley
src/main/java/com/dhemery/osx/AppleScriptBuilder.java
AppleScriptBuilder.withLines
public AppleScriptBuilder withLines(List<String> lines) { for (String line : lines) { withLine(line); } return this; }
java
public AppleScriptBuilder withLines(List<String> lines) { for (String line : lines) { withLine(line); } return this; }
[ "public", "AppleScriptBuilder", "withLines", "(", "List", "<", "String", ">", "lines", ")", "{", "for", "(", "String", "line", ":", "lines", ")", "{", "withLine", "(", "line", ")", ";", "}", "return", "this", ";", "}" ]
Append lines to the script. @param lines the lines to append @return this script command builder
[ "Append", "lines", "to", "the", "script", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/osx/AppleScriptBuilder.java#L42-L47
149,936
icoloma/simpleds
src/main/java/org/simpleds/metadata/PersistenceMetadataRepository.java
PersistenceMetadataRepository.add
public ClassMetadata add(Class<?> clazz) { ClassMetadata metadata = classMetadataFactory.createMetadata(clazz); log.debug("Adding persistent class " + metadata.getKind()); metadata.validate(); if (metadataByKind.get(metadata.getKind()) != null) { throw new DuplicateException("Two entities found with kind='" + metadata.getKind() + "': " + metadata.getPersistentClass().getName() + " and " + metadataByKind.get(metadata.getKind()).getPersistentClass().getName()); } metadataByClass.put(metadata.getPersistentClass(), metadata); metadataByKind.put(metadata.getKind(), metadata); return metadata; }
java
public ClassMetadata add(Class<?> clazz) { ClassMetadata metadata = classMetadataFactory.createMetadata(clazz); log.debug("Adding persistent class " + metadata.getKind()); metadata.validate(); if (metadataByKind.get(metadata.getKind()) != null) { throw new DuplicateException("Two entities found with kind='" + metadata.getKind() + "': " + metadata.getPersistentClass().getName() + " and " + metadataByKind.get(metadata.getKind()).getPersistentClass().getName()); } metadataByClass.put(metadata.getPersistentClass(), metadata); metadataByKind.put(metadata.getKind(), metadata); return metadata; }
[ "public", "ClassMetadata", "add", "(", "Class", "<", "?", ">", "clazz", ")", "{", "ClassMetadata", "metadata", "=", "classMetadataFactory", ".", "createMetadata", "(", "clazz", ")", ";", "log", ".", "debug", "(", "\"Adding persistent class \"", "+", "metadata", ".", "getKind", "(", ")", ")", ";", "metadata", ".", "validate", "(", ")", ";", "if", "(", "metadataByKind", ".", "get", "(", "metadata", ".", "getKind", "(", ")", ")", "!=", "null", ")", "{", "throw", "new", "DuplicateException", "(", "\"Two entities found with kind='\"", "+", "metadata", ".", "getKind", "(", ")", "+", "\"': \"", "+", "metadata", ".", "getPersistentClass", "(", ")", ".", "getName", "(", ")", "+", "\" and \"", "+", "metadataByKind", ".", "get", "(", "metadata", ".", "getKind", "(", ")", ")", ".", "getPersistentClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "metadataByClass", ".", "put", "(", "metadata", ".", "getPersistentClass", "(", ")", ",", "metadata", ")", ";", "metadataByKind", ".", "put", "(", "metadata", ".", "getKind", "(", ")", ",", "metadata", ")", ";", "return", "metadata", ";", "}" ]
Adds a persistent class to the repository @return the ClassMetadata instance created for this persistent class
[ "Adds", "a", "persistent", "class", "to", "the", "repository" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/PersistenceMetadataRepository.java#L35-L45
149,937
icoloma/simpleds
src/main/java/org/simpleds/metadata/PersistenceMetadataRepository.java
PersistenceMetadataRepository.remove
public void remove(Class<?> clazz) { ClassMetadata metadata = get(clazz); metadataByClass.remove(clazz); metadataByKind.remove(metadata.getKind()); }
java
public void remove(Class<?> clazz) { ClassMetadata metadata = get(clazz); metadataByClass.remove(clazz); metadataByKind.remove(metadata.getKind()); }
[ "public", "void", "remove", "(", "Class", "<", "?", ">", "clazz", ")", "{", "ClassMetadata", "metadata", "=", "get", "(", "clazz", ")", ";", "metadataByClass", ".", "remove", "(", "clazz", ")", ";", "metadataByKind", ".", "remove", "(", "metadata", ".", "getKind", "(", ")", ")", ";", "}" ]
Removes a persistent class from the repository @param clazz the persistent class to remove @throws IllegalArgumentException if the class is not present in the repository
[ "Removes", "a", "persistent", "class", "from", "the", "repository" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/PersistenceMetadataRepository.java#L52-L56
149,938
mlhartme/mork
src/main/java/net/oneandone/mork/classfile/Jsr.java
Jsr.addRetSuccessors
public static void addRetSuccessors(List<Jsr> jsrs, int idx, IntCollection result) { int i, max; max = jsrs.size(); for (i = 0; i < max; i++) { ((Jsr) jsrs.get(i)).addRetSuccessors(idx, result); } }
java
public static void addRetSuccessors(List<Jsr> jsrs, int idx, IntCollection result) { int i, max; max = jsrs.size(); for (i = 0; i < max; i++) { ((Jsr) jsrs.get(i)).addRetSuccessors(idx, result); } }
[ "public", "static", "void", "addRetSuccessors", "(", "List", "<", "Jsr", ">", "jsrs", ",", "int", "idx", ",", "IntCollection", "result", ")", "{", "int", "i", ",", "max", ";", "max", "=", "jsrs", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "max", ";", "i", "++", ")", "{", "(", "(", "Jsr", ")", "jsrs", ".", "get", "(", "i", ")", ")", ".", "addRetSuccessors", "(", "idx", ",", "result", ")", ";", "}", "}" ]
idx index of ret
[ "idx", "index", "of", "ret" ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/classfile/Jsr.java#L144-L151
149,939
eurekaclinical/javautil
src/main/java/org/arp/javautil/junit/JUnitUtil.java
JUnitUtil.serializeAndDeserialize
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); try { out.writeObject(o); } finally { out.close(); } ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream( bytes.toByteArray())); try { Object result = in.readObject(); return result; } finally { in.close(); } }
java
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); try { out.writeObject(o); } finally { out.close(); } ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream( bytes.toByteArray())); try { Object result = in.readObject(); return result; } finally { in.close(); } }
[ "public", "static", "Object", "serializeAndDeserialize", "(", "Object", "o", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "ByteArrayOutputStream", "bytes", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "out", "=", "new", "ObjectOutputStream", "(", "bytes", ")", ";", "try", "{", "out", ".", "writeObject", "(", "o", ")", ";", "}", "finally", "{", "out", ".", "close", "(", ")", ";", "}", "ObjectInputStream", "in", "=", "new", "ObjectInputStream", "(", "new", "ByteArrayInputStream", "(", "bytes", ".", "toByteArray", "(", ")", ")", ")", ";", "try", "{", "Object", "result", "=", "in", ".", "readObject", "(", ")", ";", "return", "result", ";", "}", "finally", "{", "in", ".", "close", "(", ")", ";", "}", "}" ]
Serializes and deserializes the given object. @param o an <code>Object</code>. @return an <code>Object</code>. @throws IOException @throws ClassNotFoundException
[ "Serializes", "and", "deserializes", "the", "given", "object", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/junit/JUnitUtil.java#L51-L69
149,940
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addEq
public <Y extends Comparable<? super Y>> RestrictionsContainer addEq(String property, Y value) { // Ajout de la restriction restrictions.add(new Eq<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addEq(String property, Y value) { // Ajout de la restriction restrictions.add(new Eq<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addEq", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Eq", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction Eq @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "Eq" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L89-L96
149,941
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addNotEq
public <Y extends Comparable<? super Y>> RestrictionsContainer addNotEq(String property, Y value) { // Ajout de la restriction restrictions.add(new NotEq<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addNotEq(String property, Y value) { // Ajout de la restriction restrictions.add(new NotEq<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addNotEq", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "NotEq", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction NotEq @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "NotEq" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L105-L112
149,942
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addGe
public <Y extends Comparable<? super Y>> RestrictionsContainer addGe(String property, Y value) { // Ajout de la restriction restrictions.add(new Ge<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addGe(String property, Y value) { // Ajout de la restriction restrictions.add(new Ge<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addGe", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Ge", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction GE @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "GE" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L121-L128
149,943
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addGt
public <Y extends Comparable<? super Y>> RestrictionsContainer addGt(String property, Y value) { // Ajout de la restriction restrictions.add(new Gt<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addGt(String property, Y value) { // Ajout de la restriction restrictions.add(new Gt<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addGt", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Gt", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction GT @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "GT" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L137-L144
149,944
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addLt
public <Y extends Comparable<? super Y>> RestrictionsContainer addLt(String property, Y value) { // Ajout de la restriction restrictions.add(new Lt<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addLt(String property, Y value) { // Ajout de la restriction restrictions.add(new Lt<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addLt", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Lt", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction Lt @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "Lt" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L153-L160
149,945
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addLike
public RestrictionsContainer addLike(String property, String value) { // Ajout de la restriction restrictions.add(new Like(property, value)); // On retourne le conteneur return this; }
java
public RestrictionsContainer addLike(String property, String value) { // Ajout de la restriction restrictions.add(new Like(property, value)); // On retourne le conteneur return this; }
[ "public", "RestrictionsContainer", "addLike", "(", "String", "property", ",", "String", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Like", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction Like @param property Nom de la Propriete @param value Valeur de la propriete @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "Like" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L168-L175
149,946
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addNotLike
public RestrictionsContainer addNotLike(String property, String value) { // Ajout de la restriction restrictions.add(new NotLike(property, value)); // On retourne le conteneur return this; }
java
public RestrictionsContainer addNotLike(String property, String value) { // Ajout de la restriction restrictions.add(new NotLike(property, value)); // On retourne le conteneur return this; }
[ "public", "RestrictionsContainer", "addNotLike", "(", "String", "property", ",", "String", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "NotLike", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction NotLike @param property Nom de la Propriete @param value Valeur de la propriete @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "NotLike" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L183-L190
149,947
leadware/jpersistence-tools
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
RestrictionsContainer.addLe
public <Y extends Comparable<? super Y>> RestrictionsContainer addLe(String property, Y value) { // Ajout de la restriction restrictions.add(new Le<Y>(property, value)); // On retourne le conteneur return this; }
java
public <Y extends Comparable<? super Y>> RestrictionsContainer addLe(String property, Y value) { // Ajout de la restriction restrictions.add(new Le<Y>(property, value)); // On retourne le conteneur return this; }
[ "public", "<", "Y", "extends", "Comparable", "<", "?", "super", "Y", ">", ">", "RestrictionsContainer", "addLe", "(", "String", "property", ",", "Y", "value", ")", "{", "// Ajout de la restriction\r", "restrictions", ".", "add", "(", "new", "Le", "<", "Y", ">", "(", "property", ",", "value", ")", ")", ";", "// On retourne le conteneur\r", "return", "this", ";", "}" ]
Methode d'ajout de la restriction Le @param property Nom de la Propriete @param value Valeur de la propriete @param <Y> Type de valeur @return Conteneur
[ "Methode", "d", "ajout", "de", "la", "restriction", "Le" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L199-L206
149,948
seedstack/jms-addon
src/it/java/org/seedstack/jms/JmsPollingIT.java
JmsPollingIT.message_polling_is_working
@Test public void message_polling_is_working() throws JMSException { testSender4.send("HELLO"); try { count.await(5, TimeUnit.SECONDS); Assertions.assertThat(text).isEqualTo("HELLO"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
java
@Test public void message_polling_is_working() throws JMSException { testSender4.send("HELLO"); try { count.await(5, TimeUnit.SECONDS); Assertions.assertThat(text).isEqualTo("HELLO"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
[ "@", "Test", "public", "void", "message_polling_is_working", "(", ")", "throws", "JMSException", "{", "testSender4", ".", "send", "(", "\"HELLO\"", ")", ";", "try", "{", "count", ".", "await", "(", "5", ",", "TimeUnit", ".", "SECONDS", ")", ";", "Assertions", ".", "assertThat", "(", "text", ")", ".", "isEqualTo", "(", "\"HELLO\"", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "fail", "(", "\"Thread interrupted\"", ")", ";", "}", "}" ]
TestSender4 and TestMessageListener4.
[ "TestSender4", "and", "TestMessageListener4", "." ]
d6014811daaac29f591b32bfd2358500fb25d804
https://github.com/seedstack/jms-addon/blob/d6014811daaac29f591b32bfd2358500fb25d804/src/it/java/org/seedstack/jms/JmsPollingIT.java#L34-L45
149,949
mlhartme/mork
src/main/java/net/oneandone/mork/semantics/Partition.java
Partition.getDisconnected
public static List getDisconnected( Collection leftCollection, Graph relation, Collection rightCollection) { List disconnected; Iterator iter; Object left; EdgeIterator relationIter; disconnected = new ArrayList(); iter = leftCollection.iterator(); while (iter.hasNext()) { left = iter.next(); relationIter = relation.edges(); while (relationIter.step()) { if (relationIter.left() == left) { if (!rightCollection.contains(relationIter.right())) { relationIter = null; break; } } } if (relationIter != null) { disconnected.add(left); } } return disconnected; }
java
public static List getDisconnected( Collection leftCollection, Graph relation, Collection rightCollection) { List disconnected; Iterator iter; Object left; EdgeIterator relationIter; disconnected = new ArrayList(); iter = leftCollection.iterator(); while (iter.hasNext()) { left = iter.next(); relationIter = relation.edges(); while (relationIter.step()) { if (relationIter.left() == left) { if (!rightCollection.contains(relationIter.right())) { relationIter = null; break; } } } if (relationIter != null) { disconnected.add(left); } } return disconnected; }
[ "public", "static", "List", "getDisconnected", "(", "Collection", "leftCollection", ",", "Graph", "relation", ",", "Collection", "rightCollection", ")", "{", "List", "disconnected", ";", "Iterator", "iter", ";", "Object", "left", ";", "EdgeIterator", "relationIter", ";", "disconnected", "=", "new", "ArrayList", "(", ")", ";", "iter", "=", "leftCollection", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "left", "=", "iter", ".", "next", "(", ")", ";", "relationIter", "=", "relation", ".", "edges", "(", ")", ";", "while", "(", "relationIter", ".", "step", "(", ")", ")", "{", "if", "(", "relationIter", ".", "left", "(", ")", "==", "left", ")", "{", "if", "(", "!", "rightCollection", ".", "contains", "(", "relationIter", ".", "right", "(", ")", ")", ")", "{", "relationIter", "=", "null", ";", "break", ";", "}", "}", "}", "if", "(", "relationIter", "!=", "null", ")", "{", "disconnected", ".", "add", "(", "left", ")", ";", "}", "}", "return", "disconnected", ";", "}" ]
Returns all objects from leftCollection whole images are a disjoin from rightCollection, none of the resulting objects has an image in rightCollection. Compares objects using ==. Note that lefts with no image show up in the result.
[ "Returns", "all", "objects", "from", "leftCollection", "whole", "images", "are", "a", "disjoin", "from", "rightCollection", "none", "of", "the", "resulting", "objects", "has", "an", "image", "in", "rightCollection", ".", "Compares", "objects", "using", "==", ".", "Note", "that", "lefts", "with", "no", "image", "show", "up", "in", "the", "result", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/semantics/Partition.java#L83-L109
149,950
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/extendedIdentifiers/IcsIdentifiers.java
IcsIdentifiers.createOverlayManagerGroup
public static Identity createOverlayManagerGroup(String name) { return ExtendedIdentifiers.createExtendedIdentifier(IfmapStrings.ICS_METADATA_NS_URI, IfmapStrings.ICS_METADATA_PREFIX, "overlay-manager-group", name); }
java
public static Identity createOverlayManagerGroup(String name) { return ExtendedIdentifiers.createExtendedIdentifier(IfmapStrings.ICS_METADATA_NS_URI, IfmapStrings.ICS_METADATA_PREFIX, "overlay-manager-group", name); }
[ "public", "static", "Identity", "createOverlayManagerGroup", "(", "String", "name", ")", "{", "return", "ExtendedIdentifiers", ".", "createExtendedIdentifier", "(", "IfmapStrings", ".", "ICS_METADATA_NS_URI", ",", "IfmapStrings", ".", "ICS_METADATA_PREFIX", ",", "\"overlay-manager-group\"", ",", "name", ")", ";", "}" ]
Create a overlay-manager-group identifier, that is an extended identity identifier. @param name name of a particular Overlay Manager group @return the new {@link Identity} instance
[ "Create", "a", "overlay", "-", "manager", "-", "group", "identifier", "that", "is", "an", "extended", "identity", "identifier", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/extendedIdentifiers/IcsIdentifiers.java#L73-L76
149,951
mlhartme/mork
src/main/java/net/oneandone/mork/mapping/RelatedArgument.java
RelatedArgument.sort
public static List<List<Argument>> sort(List<Argument> args) { int i; int max; List<List<Argument>> result; List<RelatedArgument> remaining; // List of RelatedArguments List<RelatedArgument> heads; // List of RelatedArguments result = new ArrayList<List<Argument>>(); remaining = createRelatedArgs(args); while (true) { max = remaining.size(); if (max == 0) { return result; } heads = new ArrayList<RelatedArgument>(); for (i = 0; i < max; i++) { addHead(heads, remaining.get(i)); } remaining.clear(); result.add(separate(heads, remaining)); } }
java
public static List<List<Argument>> sort(List<Argument> args) { int i; int max; List<List<Argument>> result; List<RelatedArgument> remaining; // List of RelatedArguments List<RelatedArgument> heads; // List of RelatedArguments result = new ArrayList<List<Argument>>(); remaining = createRelatedArgs(args); while (true) { max = remaining.size(); if (max == 0) { return result; } heads = new ArrayList<RelatedArgument>(); for (i = 0; i < max; i++) { addHead(heads, remaining.get(i)); } remaining.clear(); result.add(separate(heads, remaining)); } }
[ "public", "static", "List", "<", "List", "<", "Argument", ">", ">", "sort", "(", "List", "<", "Argument", ">", "args", ")", "{", "int", "i", ";", "int", "max", ";", "List", "<", "List", "<", "Argument", ">", ">", "result", ";", "List", "<", "RelatedArgument", ">", "remaining", ";", "// List of RelatedArguments", "List", "<", "RelatedArgument", ">", "heads", ";", "// List of RelatedArguments", "result", "=", "new", "ArrayList", "<", "List", "<", "Argument", ">", ">", "(", ")", ";", "remaining", "=", "createRelatedArgs", "(", "args", ")", ";", "while", "(", "true", ")", "{", "max", "=", "remaining", ".", "size", "(", ")", ";", "if", "(", "max", "==", "0", ")", "{", "return", "result", ";", "}", "heads", "=", "new", "ArrayList", "<", "RelatedArgument", ">", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "max", ";", "i", "++", ")", "{", "addHead", "(", "heads", ",", "remaining", ".", "get", "(", "i", ")", ")", ";", "}", "remaining", ".", "clear", "(", ")", ";", "result", ".", "add", "(", "separate", "(", "heads", ",", "remaining", ")", ")", ";", "}", "}" ]
Returns the sorted list of lists of arguments. @param args normal argument, not related arguments
[ "Returns", "the", "sorted", "list", "of", "lists", "of", "arguments", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/mapping/RelatedArgument.java#L32-L53
149,952
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.setEnvelopeFrom
public void setEnvelopeFrom(String address) throws AddressException { if(StringUtils.isEmpty(address)) { this.envelopeFrom = address; } else { InternetAddress tmp = toInternetAddress(address, null); this.envelopeFrom = tmp.getAddress(); } }
java
public void setEnvelopeFrom(String address) throws AddressException { if(StringUtils.isEmpty(address)) { this.envelopeFrom = address; } else { InternetAddress tmp = toInternetAddress(address, null); this.envelopeFrom = tmp.getAddress(); } }
[ "public", "void", "setEnvelopeFrom", "(", "String", "address", ")", "throws", "AddressException", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "address", ")", ")", "{", "this", ".", "envelopeFrom", "=", "address", ";", "}", "else", "{", "InternetAddress", "tmp", "=", "toInternetAddress", "(", "address", ",", "null", ")", ";", "this", ".", "envelopeFrom", "=", "tmp", ".", "getAddress", "(", ")", ";", "}", "}" ]
set the SMTP Envelope address of the email @param address a valid email address @throws AddressException in case of an invalid email address
[ "set", "the", "SMTP", "Envelope", "address", "of", "the", "email" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L55-L62
149,953
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.setFrom
public void setFrom(String address, String personal) throws AddressException { from = toInternetAddress(address, personal); }
java
public void setFrom(String address, String personal) throws AddressException { from = toInternetAddress(address, personal); }
[ "public", "void", "setFrom", "(", "String", "address", ",", "String", "personal", ")", "throws", "AddressException", "{", "from", "=", "toInternetAddress", "(", "address", ",", "personal", ")", ";", "}" ]
set the From address of the email @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address
[ "set", "the", "From", "address", "of", "the", "email" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L71-L73
149,954
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.setReplyTo
public void setReplyTo(String address, String personal) throws AddressException { replyTo = toInternetAddress(address, personal); }
java
public void setReplyTo(String address, String personal) throws AddressException { replyTo = toInternetAddress(address, personal); }
[ "public", "void", "setReplyTo", "(", "String", "address", ",", "String", "personal", ")", "throws", "AddressException", "{", "replyTo", "=", "toInternetAddress", "(", "address", ",", "personal", ")", ";", "}" ]
sets the reply to address @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address
[ "sets", "the", "reply", "to", "address" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L82-L84
149,955
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.addCc
public void addCc(String address, String personal) throws AddressException { if(cc == null) { cc = new ArrayList<>(); } cc.add( toInternetAddress(address, personal) ); }
java
public void addCc(String address, String personal) throws AddressException { if(cc == null) { cc = new ArrayList<>(); } cc.add( toInternetAddress(address, personal) ); }
[ "public", "void", "addCc", "(", "String", "address", ",", "String", "personal", ")", "throws", "AddressException", "{", "if", "(", "cc", "==", "null", ")", "{", "cc", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "cc", ".", "add", "(", "toInternetAddress", "(", "address", ",", "personal", ")", ")", ";", "}" ]
adds a CC recipient @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address
[ "adds", "a", "CC", "recipient" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L107-L112
149,956
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.addBcc
public void addBcc(String address, String personal) throws AddressException { if(bcc == null) { bcc = new ArrayList<>(); } bcc.add( toInternetAddress(address, personal) ); }
java
public void addBcc(String address, String personal) throws AddressException { if(bcc == null) { bcc = new ArrayList<>(); } bcc.add( toInternetAddress(address, personal) ); }
[ "public", "void", "addBcc", "(", "String", "address", ",", "String", "personal", ")", "throws", "AddressException", "{", "if", "(", "bcc", "==", "null", ")", "{", "bcc", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "bcc", ".", "add", "(", "toInternetAddress", "(", "address", ",", "personal", ")", ")", ";", "}" ]
adds a BCC recipient @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address
[ "adds", "a", "BCC", "recipient" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L121-L126
149,957
Terradue/jcatalogue-client
apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java
Proxy.setType
public Proxy setType( String type ) { if ( this.type.equals( type ) || ( type == null && this.type.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
java
public Proxy setType( String type ) { if ( this.type.equals( type ) || ( type == null && this.type.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
[ "public", "Proxy", "setType", "(", "String", "type", ")", "{", "if", "(", "this", ".", "type", ".", "equals", "(", "type", ")", "||", "(", "type", "==", "null", "&&", "this", ".", "type", ".", "length", "(", ")", "<=", "0", ")", ")", "{", "return", "this", ";", "}", "return", "new", "Proxy", "(", "type", ",", "host", ",", "port", ",", "auth", ")", ";", "}" ]
Sets the type of the proxy. @param type The type of the proxy, e.g. "http", may be {@code null}. @return The new proxy, never {@code null}.
[ "Sets", "the", "type", "of", "the", "proxy", "." ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java#L79-L86
149,958
Terradue/jcatalogue-client
apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java
Proxy.setHost
public Proxy setHost( String host ) { if ( this.host.equals( host ) || ( host == null && this.host.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
java
public Proxy setHost( String host ) { if ( this.host.equals( host ) || ( host == null && this.host.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
[ "public", "Proxy", "setHost", "(", "String", "host", ")", "{", "if", "(", "this", ".", "host", ".", "equals", "(", "host", ")", "||", "(", "host", "==", "null", "&&", "this", ".", "host", ".", "length", "(", ")", "<=", "0", ")", ")", "{", "return", "this", ";", "}", "return", "new", "Proxy", "(", "type", ",", "host", ",", "port", ",", "auth", ")", ";", "}" ]
Sets the host of the proxy. @param host The host of the proxy, may be {@code null}. @return The new proxy, never {@code null}.
[ "Sets", "the", "host", "of", "the", "proxy", "." ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java#L104-L111
149,959
Terradue/jcatalogue-client
apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java
Proxy.setPort
public Proxy setPort( int port ) { if ( this.port == port ) { return this; } return new Proxy( type, host, port, auth ); }
java
public Proxy setPort( int port ) { if ( this.port == port ) { return this; } return new Proxy( type, host, port, auth ); }
[ "public", "Proxy", "setPort", "(", "int", "port", ")", "{", "if", "(", "this", ".", "port", "==", "port", ")", "{", "return", "this", ";", "}", "return", "new", "Proxy", "(", "type", ",", "host", ",", "port", ",", "auth", ")", ";", "}" ]
Sets the port number for the proxy. @param port The port number for the proxy. @return The new proxy, never {@code null}.
[ "Sets", "the", "port", "number", "for", "the", "proxy", "." ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java#L129-L136
149,960
Terradue/jcatalogue-client
apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java
Proxy.setAuthentication
public Proxy setAuthentication( Authentication auth ) { if ( eq( this.auth, auth ) ) { return this; } return new Proxy( type, host, port, auth ); }
java
public Proxy setAuthentication( Authentication auth ) { if ( eq( this.auth, auth ) ) { return this; } return new Proxy( type, host, port, auth ); }
[ "public", "Proxy", "setAuthentication", "(", "Authentication", "auth", ")", "{", "if", "(", "eq", "(", "this", ".", "auth", ",", "auth", ")", ")", "{", "return", "this", ";", "}", "return", "new", "Proxy", "(", "type", ",", "host", ",", "port", ",", "auth", ")", ";", "}" ]
Sets the authentication to use for the proxy connection. @param auth The authentication to use, may be {@code null}. @return The new proxy, never {@code null}.
[ "Sets", "the", "authentication", "to", "use", "for", "the", "proxy", "connection", "." ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/apis/src/main/java/com/terradue/jcatalogue/repository/Proxy.java#L154-L161
149,961
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/dataset/data/DataRow.java
DataRow.get
public String get(String columnCode) throws UnknownColumnException { for (DataColumn column : columns) { if (columnCode.equals(column.getCode())) { return content.get(column); } } throw new UnknownColumnException(columnCode); }
java
public String get(String columnCode) throws UnknownColumnException { for (DataColumn column : columns) { if (columnCode.equals(column.getCode())) { return content.get(column); } } throw new UnknownColumnException(columnCode); }
[ "public", "String", "get", "(", "String", "columnCode", ")", "throws", "UnknownColumnException", "{", "for", "(", "DataColumn", "column", ":", "columns", ")", "{", "if", "(", "columnCode", ".", "equals", "(", "column", ".", "getCode", "(", ")", ")", ")", "{", "return", "content", ".", "get", "(", "column", ")", ";", "}", "}", "throw", "new", "UnknownColumnException", "(", "columnCode", ")", ";", "}" ]
Returns this row's content for the given column. @param columnCode the column to read @return this row's content for the given column @throws UnknownColumnException if the column doesn't exist
[ "Returns", "this", "row", "s", "content", "for", "the", "given", "column", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/dataset/data/DataRow.java#L57-L64
149,962
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/dataset/data/DataRow.java
DataRow.set
public DataRow set(String columnCode, String value) throws UnknownColumnException { for (DataColumn column : columns) { if (columnCode.equals(column.getCode())) { content.put(column, value); return this; } } throw new UnknownColumnException(columnCode); }
java
public DataRow set(String columnCode, String value) throws UnknownColumnException { for (DataColumn column : columns) { if (columnCode.equals(column.getCode())) { content.put(column, value); return this; } } throw new UnknownColumnException(columnCode); }
[ "public", "DataRow", "set", "(", "String", "columnCode", ",", "String", "value", ")", "throws", "UnknownColumnException", "{", "for", "(", "DataColumn", "column", ":", "columns", ")", "{", "if", "(", "columnCode", ".", "equals", "(", "column", ".", "getCode", "(", ")", ")", ")", "{", "content", ".", "put", "(", "column", ",", "value", ")", ";", "return", "this", ";", "}", "}", "throw", "new", "UnknownColumnException", "(", "columnCode", ")", ";", "}" ]
Sets this row's content for the given column. @param columnCode the column to set @param value the value to enter @return this row, to allow chaining @throws UnknownColumnException if the column doesn't exist
[ "Sets", "this", "row", "s", "content", "for", "the", "given", "column", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/dataset/data/DataRow.java#L88-L96
149,963
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/dataset/data/DataRow.java
DataRow.setAll
public DataRow setAll(int offset, String... values) throws TooManyColumnsException { if (offset + values.length > columns.size()) { throw new TooManyColumnsException(columns.size(), offset + values.length); } for (int i = 0; i + offset < columns.size() && i < values.length; i++) { content.put(columns.get(i), values[i - offset]); } return this; }
java
public DataRow setAll(int offset, String... values) throws TooManyColumnsException { if (offset + values.length > columns.size()) { throw new TooManyColumnsException(columns.size(), offset + values.length); } for (int i = 0; i + offset < columns.size() && i < values.length; i++) { content.put(columns.get(i), values[i - offset]); } return this; }
[ "public", "DataRow", "setAll", "(", "int", "offset", ",", "String", "...", "values", ")", "throws", "TooManyColumnsException", "{", "if", "(", "offset", "+", "values", ".", "length", ">", "columns", ".", "size", "(", ")", ")", "{", "throw", "new", "TooManyColumnsException", "(", "columns", ".", "size", "(", ")", ",", "offset", "+", "values", ".", "length", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "+", "offset", "<", "columns", ".", "size", "(", ")", "&&", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "content", ".", "put", "(", "columns", ".", "get", "(", "i", ")", ",", "values", "[", "i", "-", "offset", "]", ")", ";", "}", "return", "this", ";", "}" ]
Sets multiple columns of this row, starting from the given offset. @param offset represents offset @param values the column values to set @return this row, to allow chaining @throws TooManyColumnsException if more values are given than columns are available after the offset
[ "Sets", "multiple", "columns", "of", "this", "row", "starting", "from", "the", "given", "offset", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/dataset/data/DataRow.java#L119-L127
149,964
mlhartme/mork
src/main/java/net/oneandone/mork/mapping/ToArray.java
ToArray.readObject
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, NoSuchMethodException { componentType = ClassRef.read(in); }
java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, NoSuchMethodException { componentType = ClassRef.read(in); }
[ "private", "void", "readObject", "(", "ObjectInputStream", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", ",", "NoSuchMethodException", "{", "componentType", "=", "ClassRef", ".", "read", "(", "in", ")", ";", "}" ]
Reads this Constructor. @param in source to read from
[ "Reads", "this", "Constructor", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/mapping/ToArray.java#L111-L114
149,965
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/channel/CommunicationHandlerFactory.java
CommunicationHandlerFactory.newHandlerPreference
private static CommunicationHandler newHandlerPreference(String handlerProp, String url, String user, String pass, SSLSocketFactory sslSocketFactory, HostnameVerifier verifier, int initialConnectionTimeout) throws InitializationException { if (handlerProp == null) { throw new NullPointerException(); } if (handlerProp.equals("java")) { return new JavaCommunicationHandler(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout); } else if (handlerProp.equals("apache")) { try { return new ApacheCoreCommunicationHandler(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout); } catch (NoClassDefFoundError e) { throw new InitializationException("Could not initialize ApacheCommunicationHandler"); } } else { throw new InitializationException("Invalid " + HANDLER_PROPERTY + " value"); } }
java
private static CommunicationHandler newHandlerPreference(String handlerProp, String url, String user, String pass, SSLSocketFactory sslSocketFactory, HostnameVerifier verifier, int initialConnectionTimeout) throws InitializationException { if (handlerProp == null) { throw new NullPointerException(); } if (handlerProp.equals("java")) { return new JavaCommunicationHandler(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout); } else if (handlerProp.equals("apache")) { try { return new ApacheCoreCommunicationHandler(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout); } catch (NoClassDefFoundError e) { throw new InitializationException("Could not initialize ApacheCommunicationHandler"); } } else { throw new InitializationException("Invalid " + HANDLER_PROPERTY + " value"); } }
[ "private", "static", "CommunicationHandler", "newHandlerPreference", "(", "String", "handlerProp", ",", "String", "url", ",", "String", "user", ",", "String", "pass", ",", "SSLSocketFactory", "sslSocketFactory", ",", "HostnameVerifier", "verifier", ",", "int", "initialConnectionTimeout", ")", "throws", "InitializationException", "{", "if", "(", "handlerProp", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "handlerProp", ".", "equals", "(", "\"java\"", ")", ")", "{", "return", "new", "JavaCommunicationHandler", "(", "url", ",", "user", ",", "pass", ",", "sslSocketFactory", ",", "verifier", ",", "initialConnectionTimeout", ")", ";", "}", "else", "if", "(", "handlerProp", ".", "equals", "(", "\"apache\"", ")", ")", "{", "try", "{", "return", "new", "ApacheCoreCommunicationHandler", "(", "url", ",", "user", ",", "pass", ",", "sslSocketFactory", ",", "verifier", ",", "initialConnectionTimeout", ")", ";", "}", "catch", "(", "NoClassDefFoundError", "e", ")", "{", "throw", "new", "InitializationException", "(", "\"Could not initialize ApacheCommunicationHandler\"", ")", ";", "}", "}", "else", "{", "throw", "new", "InitializationException", "(", "\"Invalid \"", "+", "HANDLER_PROPERTY", "+", "\" value\"", ")", ";", "}", "}" ]
Helper to return the handler which is indicated by handlerProp @param handlerProp @param url @param user @param pass @param sslSocketFactory @param verifier @param initialConnectionTimeout the initial connection timeout in milliseconds @return @throws InitializationException
[ "Helper", "to", "return", "the", "handler", "which", "is", "indicated", "by", "handlerProp" ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/channel/CommunicationHandlerFactory.java#L122-L143
149,966
Metrink/croquet
croquet-core/src/main/java/com/metrink/croquet/logging/CroquetLoggingFactory.java
CroquetLoggingFactory.configureLogging
public void configureLogging(final LoggingSettings loggingSettings) { final Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); final LoggerContext context = root.getLoggerContext(); // Reset prior configuration context.reset(); // Propagate level changes to java.util.logging final LevelChangePropagator propagator = new LevelChangePropagator(); propagator.setContext(context); propagator.setResetJUL(true); // Set base threshold for all other loggers. root.setLevel(loggingSettings.getLevel()); // Loop through explicitly configured loggers and set the levels for (final Map.Entry<String, Level> entry : loggingSettings.getLoggers().entrySet()) { ((Logger)LoggerFactory.getLogger(entry.getKey())).setLevel(entry.getValue()); } if (loggingSettings.getLogFile().isEnabled()) { root.addAppender(getFileAppender(loggingSettings.getLogFile(), context)); } if (loggingSettings.getConsole().isEnabled()) { root.addAppender(getConsoleAppender(loggingSettings.getConsole(), context)); } }
java
public void configureLogging(final LoggingSettings loggingSettings) { final Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); final LoggerContext context = root.getLoggerContext(); // Reset prior configuration context.reset(); // Propagate level changes to java.util.logging final LevelChangePropagator propagator = new LevelChangePropagator(); propagator.setContext(context); propagator.setResetJUL(true); // Set base threshold for all other loggers. root.setLevel(loggingSettings.getLevel()); // Loop through explicitly configured loggers and set the levels for (final Map.Entry<String, Level> entry : loggingSettings.getLoggers().entrySet()) { ((Logger)LoggerFactory.getLogger(entry.getKey())).setLevel(entry.getValue()); } if (loggingSettings.getLogFile().isEnabled()) { root.addAppender(getFileAppender(loggingSettings.getLogFile(), context)); } if (loggingSettings.getConsole().isEnabled()) { root.addAppender(getConsoleAppender(loggingSettings.getConsole(), context)); } }
[ "public", "void", "configureLogging", "(", "final", "LoggingSettings", "loggingSettings", ")", "{", "final", "Logger", "root", "=", "(", "Logger", ")", "LoggerFactory", ".", "getLogger", "(", "org", ".", "slf4j", ".", "Logger", ".", "ROOT_LOGGER_NAME", ")", ";", "final", "LoggerContext", "context", "=", "root", ".", "getLoggerContext", "(", ")", ";", "// Reset prior configuration", "context", ".", "reset", "(", ")", ";", "// Propagate level changes to java.util.logging", "final", "LevelChangePropagator", "propagator", "=", "new", "LevelChangePropagator", "(", ")", ";", "propagator", ".", "setContext", "(", "context", ")", ";", "propagator", ".", "setResetJUL", "(", "true", ")", ";", "// Set base threshold for all other loggers.", "root", ".", "setLevel", "(", "loggingSettings", ".", "getLevel", "(", ")", ")", ";", "// Loop through explicitly configured loggers and set the levels", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "Level", ">", "entry", ":", "loggingSettings", ".", "getLoggers", "(", ")", ".", "entrySet", "(", ")", ")", "{", "(", "(", "Logger", ")", "LoggerFactory", ".", "getLogger", "(", "entry", ".", "getKey", "(", ")", ")", ")", ".", "setLevel", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "if", "(", "loggingSettings", ".", "getLogFile", "(", ")", ".", "isEnabled", "(", ")", ")", "{", "root", ".", "addAppender", "(", "getFileAppender", "(", "loggingSettings", ".", "getLogFile", "(", ")", ",", "context", ")", ")", ";", "}", "if", "(", "loggingSettings", ".", "getConsole", "(", ")", ".", "isEnabled", "(", ")", ")", "{", "root", ".", "addAppender", "(", "getConsoleAppender", "(", "loggingSettings", ".", "getConsole", "(", ")", ",", "context", ")", ")", ";", "}", "}" ]
Configure logging. @param loggingSettings the logging settings
[ "Configure", "logging", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/logging/CroquetLoggingFactory.java#L35-L63
149,967
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.initialize
public void initialize() { Enumeration enm; String superclass; String[] packages; try { m_CacheNames = new HashMap<>(); m_ListNames = new HashMap<>(); m_CacheClasses = new HashMap<>(); m_ListClasses = new HashMap<>(); enm = m_Packages.propertyNames(); while (enm.hasMoreElements()) { superclass = (String) enm.nextElement(); packages = m_Packages.getProperty(superclass).replaceAll(" ", "").split(","); addHierarchy(superclass, packages); } } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to determine packages/classes:", e); m_Packages = new Properties(); } }
java
public void initialize() { Enumeration enm; String superclass; String[] packages; try { m_CacheNames = new HashMap<>(); m_ListNames = new HashMap<>(); m_CacheClasses = new HashMap<>(); m_ListClasses = new HashMap<>(); enm = m_Packages.propertyNames(); while (enm.hasMoreElements()) { superclass = (String) enm.nextElement(); packages = m_Packages.getProperty(superclass).replaceAll(" ", "").split(","); addHierarchy(superclass, packages); } } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to determine packages/classes:", e); m_Packages = new Properties(); } }
[ "public", "void", "initialize", "(", ")", "{", "Enumeration", "enm", ";", "String", "superclass", ";", "String", "[", "]", "packages", ";", "try", "{", "m_CacheNames", "=", "new", "HashMap", "<>", "(", ")", ";", "m_ListNames", "=", "new", "HashMap", "<>", "(", ")", ";", "m_CacheClasses", "=", "new", "HashMap", "<>", "(", ")", ";", "m_ListClasses", "=", "new", "HashMap", "<>", "(", ")", ";", "enm", "=", "m_Packages", ".", "propertyNames", "(", ")", ";", "while", "(", "enm", ".", "hasMoreElements", "(", ")", ")", "{", "superclass", "=", "(", "String", ")", "enm", ".", "nextElement", "(", ")", ";", "packages", "=", "m_Packages", ".", "getProperty", "(", "superclass", ")", ".", "replaceAll", "(", "\" \"", ",", "\"\"", ")", ".", "split", "(", "\",\"", ")", ";", "addHierarchy", "(", "superclass", ",", "packages", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "getLogger", "(", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Failed to determine packages/classes:\"", ",", "e", ")", ";", "m_Packages", "=", "new", "Properties", "(", ")", ";", "}", "}" ]
loads the props file and interpretes it.
[ "loads", "the", "props", "file", "and", "interpretes", "it", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L350-L372
149,968
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getClassnames
public String[] getClassnames(Class superclass) { List<String> list; list = m_ListNames.get(superclass.getName()); if (list == null) return new String[0]; else return list.toArray(new String[list.size()]); }
java
public String[] getClassnames(Class superclass) { List<String> list; list = m_ListNames.get(superclass.getName()); if (list == null) return new String[0]; else return list.toArray(new String[list.size()]); }
[ "public", "String", "[", "]", "getClassnames", "(", "Class", "superclass", ")", "{", "List", "<", "String", ">", "list", ";", "list", "=", "m_ListNames", ".", "get", "(", "superclass", ".", "getName", "(", ")", ")", ";", "if", "(", "list", "==", "null", ")", "return", "new", "String", "[", "0", "]", ";", "else", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns all the classnames that were found for this superclass. @param superclass the superclass to return the derived classes for @return the classnames of the derived classes
[ "Returns", "all", "the", "classnames", "that", "were", "found", "for", "this", "superclass", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L380-L388
149,969
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getClasses
public Class[] getClasses(String superclass) { List<Class> list; list = m_ListClasses.get(superclass); if (list == null) return new Class[0]; else return list.toArray(new Class[list.size()]); }
java
public Class[] getClasses(String superclass) { List<Class> list; list = m_ListClasses.get(superclass); if (list == null) return new Class[0]; else return list.toArray(new Class[list.size()]); }
[ "public", "Class", "[", "]", "getClasses", "(", "String", "superclass", ")", "{", "List", "<", "Class", ">", "list", ";", "list", "=", "m_ListClasses", ".", "get", "(", "superclass", ")", ";", "if", "(", "list", "==", "null", ")", "return", "new", "Class", "[", "0", "]", ";", "else", "return", "list", ".", "toArray", "(", "new", "Class", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns all the classes that were found for this superclass. @param superclass the superclass to return the derived classes for @return the classes of the derived classes
[ "Returns", "all", "the", "classes", "that", "were", "found", "for", "this", "superclass", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L406-L414
149,970
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getSuperclasses
public String[] getSuperclasses(String cls) { List<String> result; result = new ArrayList<>(); for (String superclass: m_CacheNames.keySet()) { if (m_CacheNames.get(superclass).contains(cls)) result.add(superclass); } if (result.size() > 1) Collections.sort(result); return result.toArray(new String[result.size()]); }
java
public String[] getSuperclasses(String cls) { List<String> result; result = new ArrayList<>(); for (String superclass: m_CacheNames.keySet()) { if (m_CacheNames.get(superclass).contains(cls)) result.add(superclass); } if (result.size() > 1) Collections.sort(result); return result.toArray(new String[result.size()]); }
[ "public", "String", "[", "]", "getSuperclasses", "(", "String", "cls", ")", "{", "List", "<", "String", ">", "result", ";", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "superclass", ":", "m_CacheNames", ".", "keySet", "(", ")", ")", "{", "if", "(", "m_CacheNames", ".", "get", "(", "superclass", ")", ".", "contains", "(", "cls", ")", ")", "result", ".", "add", "(", "superclass", ")", ";", "}", "if", "(", "result", ".", "size", "(", ")", ">", "1", ")", "Collections", ".", "sort", "(", "result", ")", ";", "return", "result", ".", "toArray", "(", "new", "String", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns the superclasses that the specified classes was listed under. @param cls the class to look up its superclasses @return the superclass(es)
[ "Returns", "the", "superclasses", "that", "the", "specified", "classes", "was", "listed", "under", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L432-L446
149,971
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getSuperclasses
public String[] getSuperclasses() { List<String> result; result = new ArrayList<>(m_CacheNames.keySet()); Collections.sort(result); return result.toArray(new String[result.size()]); }
java
public String[] getSuperclasses() { List<String> result; result = new ArrayList<>(m_CacheNames.keySet()); Collections.sort(result); return result.toArray(new String[result.size()]); }
[ "public", "String", "[", "]", "getSuperclasses", "(", ")", "{", "List", "<", "String", ">", "result", ";", "result", "=", "new", "ArrayList", "<>", "(", "m_CacheNames", ".", "keySet", "(", ")", ")", ";", "Collections", ".", "sort", "(", "result", ")", ";", "return", "result", ".", "toArray", "(", "new", "String", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns the all superclasses that define class hierarchies. @return the superclasses
[ "Returns", "the", "all", "superclasses", "that", "define", "class", "hierarchies", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L453-L460
149,972
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getPackages
public String[] getPackages(String superclass) { String packages; packages = m_Packages.getProperty(superclass); if ((packages == null) || (packages.length() == 0)) return new String[0]; else return packages.split(","); }
java
public String[] getPackages(String superclass) { String packages; packages = m_Packages.getProperty(superclass); if ((packages == null) || (packages.length() == 0)) return new String[0]; else return packages.split(","); }
[ "public", "String", "[", "]", "getPackages", "(", "String", "superclass", ")", "{", "String", "packages", ";", "packages", "=", "m_Packages", ".", "getProperty", "(", "superclass", ")", ";", "if", "(", "(", "packages", "==", "null", ")", "||", "(", "packages", ".", "length", "(", ")", "==", "0", ")", ")", "return", "new", "String", "[", "0", "]", ";", "else", "return", "packages", ".", "split", "(", "\",\"", ")", ";", "}" ]
Returns all the packages that were found for this superclass. @param superclass the superclass to return the packages for @return the packages
[ "Returns", "all", "the", "packages", "that", "were", "found", "for", "this", "superclass", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L478-L486
149,973
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.getSingleton
public static synchronized ClassLister getSingleton(ClassTraversal traversal) { Class<? extends ClassTraversal> cls; cls = (traversal == null) ? null : traversal.getClass(); if (m_Singleton == null) m_Singleton = new HashMap<>(); if (!m_Singleton.containsKey(cls)) m_Singleton.put(cls, new ClassLister(traversal)); return m_Singleton.get(cls); }
java
public static synchronized ClassLister getSingleton(ClassTraversal traversal) { Class<? extends ClassTraversal> cls; cls = (traversal == null) ? null : traversal.getClass(); if (m_Singleton == null) m_Singleton = new HashMap<>(); if (!m_Singleton.containsKey(cls)) m_Singleton.put(cls, new ClassLister(traversal)); return m_Singleton.get(cls); }
[ "public", "static", "synchronized", "ClassLister", "getSingleton", "(", "ClassTraversal", "traversal", ")", "{", "Class", "<", "?", "extends", "ClassTraversal", ">", "cls", ";", "cls", "=", "(", "traversal", "==", "null", ")", "?", "null", ":", "traversal", ".", "getClass", "(", ")", ";", "if", "(", "m_Singleton", "==", "null", ")", "m_Singleton", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "!", "m_Singleton", ".", "containsKey", "(", "cls", ")", ")", "m_Singleton", ".", "put", "(", "cls", ",", "new", "ClassLister", "(", "traversal", ")", ")", ";", "return", "m_Singleton", ".", "get", "(", "cls", ")", ";", "}" ]
Returns the singleton instance of the class lister. @param traversal the class traversal to use, can be null for default one @return the singleton
[ "Returns", "the", "singleton", "instance", "of", "the", "class", "lister", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L535-L545
149,974
Waikato/jclasslocator
src/main/java/nz/ac/waikato/cms/locator/ClassLister.java
ClassLister.load
public static Properties load(String props, Properties defProps) { Properties result; InputStream is; result = new Properties(defProps); is = null; try { is = ClassLoader.getSystemResourceAsStream(props); result.load(is); } catch (Exception e) { result = defProps; } finally { try { if (is != null) is.close(); } catch (Exception e) { // ignored } } return result; }
java
public static Properties load(String props, Properties defProps) { Properties result; InputStream is; result = new Properties(defProps); is = null; try { is = ClassLoader.getSystemResourceAsStream(props); result.load(is); } catch (Exception e) { result = defProps; } finally { try { if (is != null) is.close(); } catch (Exception e) { // ignored } } return result; }
[ "public", "static", "Properties", "load", "(", "String", "props", ",", "Properties", "defProps", ")", "{", "Properties", "result", ";", "InputStream", "is", ";", "result", "=", "new", "Properties", "(", "defProps", ")", ";", "is", "=", "null", ";", "try", "{", "is", "=", "ClassLoader", ".", "getSystemResourceAsStream", "(", "props", ")", ";", "result", ".", "load", "(", "is", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "result", "=", "defProps", ";", "}", "finally", "{", "try", "{", "if", "(", "is", "!=", "null", ")", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// ignored", "}", "}", "return", "result", ";", "}" ]
Loads the properties from the classpath. @param props the path, e.g., "nz/ac/waikato/cms/locator/ClassLister.props" @return the properties, the default ones if failed to load
[ "Loads", "the", "properties", "from", "the", "classpath", "." ]
c899072fff607a56ee7f8c2d01fbeb15157ad144
https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLister.java#L563-L587
149,975
gildur/jshint4j
src/main/java/pl/gildur/jshint4j/JsHint.java
JsHint.lint
public List<Error> lint(String source, String options) { if (source == null) { throw new NullPointerException("Source must not be null."); } Context cx = Context.enter(); try { Scriptable scope = cx.initStandardObjects(); evaluateJSHint(cx, scope); return lint(cx, scope, source, options); } finally { Context.exit(); } }
java
public List<Error> lint(String source, String options) { if (source == null) { throw new NullPointerException("Source must not be null."); } Context cx = Context.enter(); try { Scriptable scope = cx.initStandardObjects(); evaluateJSHint(cx, scope); return lint(cx, scope, source, options); } finally { Context.exit(); } }
[ "public", "List", "<", "Error", ">", "lint", "(", "String", "source", ",", "String", "options", ")", "{", "if", "(", "source", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Source must not be null.\"", ")", ";", "}", "Context", "cx", "=", "Context", ".", "enter", "(", ")", ";", "try", "{", "Scriptable", "scope", "=", "cx", ".", "initStandardObjects", "(", ")", ";", "evaluateJSHint", "(", "cx", ",", "scope", ")", ";", "return", "lint", "(", "cx", ",", "scope", ",", "source", ",", "options", ")", ";", "}", "finally", "{", "Context", ".", "exit", "(", ")", ";", "}", "}" ]
Runs JSHint on given JavaScript source code. @param source JavaScript source code @param options JSHint options @return JSHint errors
[ "Runs", "JSHint", "on", "given", "JavaScript", "source", "code", "." ]
b6f9e2fb00e248a4194f38a2df07eb34d55177f7
https://github.com/gildur/jshint4j/blob/b6f9e2fb00e248a4194f38a2df07eb34d55177f7/src/main/java/pl/gildur/jshint4j/JsHint.java#L26-L39
149,976
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/entity/NamedEntityAlchemyEntity.java
NamedEntityAlchemyEntity.addQuotation
public void addQuotation(final QuotationAlchemyEntity quotation) { if(quotation != null && !quotations.contains(quotation)) { quotations.add(quotation); } }
java
public void addQuotation(final QuotationAlchemyEntity quotation) { if(quotation != null && !quotations.contains(quotation)) { quotations.add(quotation); } }
[ "public", "void", "addQuotation", "(", "final", "QuotationAlchemyEntity", "quotation", ")", "{", "if", "(", "quotation", "!=", "null", "&&", "!", "quotations", ".", "contains", "(", "quotation", ")", ")", "{", "quotations", ".", "add", "(", "quotation", ")", ";", "}", "}" ]
Set extracted quotations for the detected entity. @param quotation extracted quotations for the detected entity
[ "Set", "extracted", "quotations", "for", "the", "detected", "entity", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/entity/NamedEntityAlchemyEntity.java#L343-L347
149,977
ahome-it/ahome-tooling-nativetools
src/main/java/com/ait/tooling/nativetools/client/collection/NFastArrayList.java
NFastArrayList.get
public final M get(final int index) { if ((index >= 0) && (index < size())) { return m_jso.get(index); } return null; }
java
public final M get(final int index) { if ((index >= 0) && (index < size())) { return m_jso.get(index); } return null; }
[ "public", "final", "M", "get", "(", "final", "int", "index", ")", "{", "if", "(", "(", "index", ">=", "0", ")", "&&", "(", "index", "<", "size", "(", ")", ")", ")", "{", "return", "m_jso", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}" ]
Return the primitive found at the specified index. @param index @return
[ "Return", "the", "primitive", "found", "at", "the", "specified", "index", "." ]
0618b7c9998c09b0dcce74667478d5e767dad2e8
https://github.com/ahome-it/ahome-tooling-nativetools/blob/0618b7c9998c09b0dcce74667478d5e767dad2e8/src/main/java/com/ait/tooling/nativetools/client/collection/NFastArrayList.java#L85-L92
149,978
ahome-it/ahome-tooling-nativetools
src/main/java/com/ait/tooling/nativetools/client/collection/NFastArrayList.java
NFastArrayList.set
public final NFastArrayList<M> set(final int i, final M value) { m_jso.set(i, value); return this; }
java
public final NFastArrayList<M> set(final int i, final M value) { m_jso.set(i, value); return this; }
[ "public", "final", "NFastArrayList", "<", "M", ">", "set", "(", "final", "int", "i", ",", "final", "M", "value", ")", "{", "m_jso", ".", "set", "(", "i", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add a value to the List @param value
[ "Add", "a", "value", "to", "the", "List" ]
0618b7c9998c09b0dcce74667478d5e767dad2e8
https://github.com/ahome-it/ahome-tooling-nativetools/blob/0618b7c9998c09b0dcce74667478d5e767dad2e8/src/main/java/com/ait/tooling/nativetools/client/collection/NFastArrayList.java#L109-L114
149,979
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/intervals/AbsoluteInterval.java
AbsoluteInterval.getStart
public Calendar getStart() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(start); return cal; }
java
public Calendar getStart() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(start); return cal; }
[ "public", "Calendar", "getStart", "(", ")", "{", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "start", ")", ";", "return", "cal", ";", "}" ]
Returns the start of the interval. This is the whole date that was specified during instantiation, even if it's too detailed for the given interval unit. @return the start of the interval
[ "Returns", "the", "start", "of", "the", "interval", ".", "This", "is", "the", "whole", "date", "that", "was", "specified", "during", "instantiation", "even", "if", "it", "s", "too", "detailed", "for", "the", "given", "interval", "unit", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/intervals/AbsoluteInterval.java#L61-L65
149,980
BellaDati/belladati-sdk-api
src/main/java/com/belladati/sdk/intervals/AbsoluteInterval.java
AbsoluteInterval.getEnd
public Calendar getEnd() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(end); return cal; }
java
public Calendar getEnd() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(end); return cal; }
[ "public", "Calendar", "getEnd", "(", ")", "{", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "end", ")", ";", "return", "cal", ";", "}" ]
Returns the end of the interval. This is the whole date that was specified during instantiation, even if it's too detailed for the given interval unit. @return the start of the interval
[ "Returns", "the", "end", "of", "the", "interval", ".", "This", "is", "the", "whole", "date", "that", "was", "specified", "during", "instantiation", "even", "if", "it", "s", "too", "detailed", "for", "the", "given", "interval", "unit", "." ]
ec45a42048d8255838ad0200aa6784a8e8a121c1
https://github.com/BellaDati/belladati-sdk-api/blob/ec45a42048d8255838ad0200aa6784a8e8a121c1/src/main/java/com/belladati/sdk/intervals/AbsoluteInterval.java#L74-L78
149,981
Metrink/croquet
croquet-examples/src/main/java/com/metrink/croquet/examples/crm/Main.java
Main.main
public static void main(final String[] args) { // create the croquet object through the builder final CroquetWicket<CrmSettings> croquet = configureBuilder(CrmSettings.class, args).build(); // get the custom settings for the application // if custom settings aren't needed for Guice modules, then you // don't need this method as settings are bound by Croquet final CrmSettings settings = croquet.getSettings(); // add in our Guice module croquet.addGuiceModule(new CrmModule(settings)); // add in a managed module croquet.addManagedModule(EmailModule.class); // run the Crouet application croquet.run(); // after this, a thread(s) will be running in the background // you can stop the application via SIGTERM }
java
public static void main(final String[] args) { // create the croquet object through the builder final CroquetWicket<CrmSettings> croquet = configureBuilder(CrmSettings.class, args).build(); // get the custom settings for the application // if custom settings aren't needed for Guice modules, then you // don't need this method as settings are bound by Croquet final CrmSettings settings = croquet.getSettings(); // add in our Guice module croquet.addGuiceModule(new CrmModule(settings)); // add in a managed module croquet.addManagedModule(EmailModule.class); // run the Crouet application croquet.run(); // after this, a thread(s) will be running in the background // you can stop the application via SIGTERM }
[ "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "// create the croquet object through the builder", "final", "CroquetWicket", "<", "CrmSettings", ">", "croquet", "=", "configureBuilder", "(", "CrmSettings", ".", "class", ",", "args", ")", ".", "build", "(", ")", ";", "// get the custom settings for the application", "// if custom settings aren't needed for Guice modules, then you", "// don't need this method as settings are bound by Croquet", "final", "CrmSettings", "settings", "=", "croquet", ".", "getSettings", "(", ")", ";", "// add in our Guice module", "croquet", ".", "addGuiceModule", "(", "new", "CrmModule", "(", "settings", ")", ")", ";", "// add in a managed module", "croquet", ".", "addManagedModule", "(", "EmailModule", ".", "class", ")", ";", "// run the Crouet application", "croquet", ".", "run", "(", ")", ";", "// after this, a thread(s) will be running in the background", "// you can stop the application via SIGTERM", "}" ]
The main method of this application. @param args the command line arguments.
[ "The", "main", "method", "of", "this", "application", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-examples/src/main/java/com/metrink/croquet/examples/crm/Main.java#L32-L52
149,982
dhemery/hartley
src/main/java/com/dhemery/os/PublishingProcess.java
PublishingProcess.output
@Override public String output() { String output = process.output(); publisher.publish(new Returned(command, output)); return output; }
java
@Override public String output() { String output = process.output(); publisher.publish(new Returned(command, output)); return output; }
[ "@", "Override", "public", "String", "output", "(", ")", "{", "String", "output", "=", "process", ".", "output", "(", ")", ";", "publisher", ".", "publish", "(", "new", "Returned", "(", "command", ",", "output", ")", ")", ";", "return", "output", ";", "}" ]
Publish and return the output from the underlying process.
[ "Publish", "and", "return", "the", "output", "from", "the", "underlying", "process", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/os/PublishingProcess.java#L33-L38
149,983
bwkimmel/jdcp
jdcp-worker/src/main/java/ca/eandb/jdcp/worker/ThreadServiceWorker.java
ThreadServiceWorker.getWorker
private Worker getWorker() throws InterruptedException { while (!courtesyMonitor.allowTasksToRun()) { courtesyMonitor.waitFor(); } while (numWorkers > maxWorkers) { workerQueue.take(); numWorkers--; } return workerQueue.take(); }
java
private Worker getWorker() throws InterruptedException { while (!courtesyMonitor.allowTasksToRun()) { courtesyMonitor.waitFor(); } while (numWorkers > maxWorkers) { workerQueue.take(); numWorkers--; } return workerQueue.take(); }
[ "private", "Worker", "getWorker", "(", ")", "throws", "InterruptedException", "{", "while", "(", "!", "courtesyMonitor", ".", "allowTasksToRun", "(", ")", ")", "{", "courtesyMonitor", ".", "waitFor", "(", ")", ";", "}", "while", "(", "numWorkers", ">", "maxWorkers", ")", "{", "workerQueue", ".", "take", "(", ")", ";", "numWorkers", "--", ";", "}", "return", "workerQueue", ".", "take", "(", ")", ";", "}" ]
Gets the next worker available to process a task. @return The next available worker. @throws InterruptedException If the thread is interrupted while waiting for an available worker.
[ "Gets", "the", "next", "worker", "available", "to", "process", "a", "task", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker/src/main/java/ca/eandb/jdcp/worker/ThreadServiceWorker.java#L248-L257
149,984
leadware/jpersistence-tools
jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/utils/ExpressionModel.java
ExpressionModel.addParameter
public void addParameter(String parameterName, String parameterExpression) { // Si le nom du parametre est null if(parameterName == null || parameterName.trim().length() == 0) return; // Si l'expression est vide if(parameterExpression == null || parameterExpression.trim().length() == 0) return; // On ajoute le Parametre this.parameters.put(parameterName, parameterExpression); }
java
public void addParameter(String parameterName, String parameterExpression) { // Si le nom du parametre est null if(parameterName == null || parameterName.trim().length() == 0) return; // Si l'expression est vide if(parameterExpression == null || parameterExpression.trim().length() == 0) return; // On ajoute le Parametre this.parameters.put(parameterName, parameterExpression); }
[ "public", "void", "addParameter", "(", "String", "parameterName", ",", "String", "parameterExpression", ")", "{", "// Si le nom du parametre est null\r", "if", "(", "parameterName", "==", "null", "||", "parameterName", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "return", ";", "// Si l'expression est vide\r", "if", "(", "parameterExpression", "==", "null", "||", "parameterExpression", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "return", ";", "// On ajoute le Parametre\r", "this", ".", "parameters", ".", "put", "(", "parameterName", ",", "parameterExpression", ")", ";", "}" ]
Methode d'ajout d'un Parametre @param parameterName Nom du parametre @param parameterExpression Expression du parametre
[ "Methode", "d", "ajout", "d", "un", "Parametre" ]
4c15372993584579d7dbb9b23dd4c0c0fdc9e789
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/utils/ExpressionModel.java#L112-L122
149,985
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadataFactory.java
ClassMetadataFactory.isCandidate
private boolean isCandidate(Field field) { return !Modifier.isStatic(field.getModifiers()) && field.getAnnotation(Transient.class) == null; }
java
private boolean isCandidate(Field field) { return !Modifier.isStatic(field.getModifiers()) && field.getAnnotation(Transient.class) == null; }
[ "private", "boolean", "isCandidate", "(", "Field", "field", ")", "{", "return", "!", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", "&&", "field", ".", "getAnnotation", "(", "Transient", ".", "class", ")", "==", "null", ";", "}" ]
Return true if the field is static or marked as transient
[ "Return", "true", "if", "the", "field", "is", "static", "or", "marked", "as", "transient" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadataFactory.java#L173-L175
149,986
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadataFactory.java
ClassMetadataFactory.isCandidate
private boolean isCandidate(PropertyDescriptor property) { if ("class".equals(property.getName()) || property.getReadMethod() == null || Modifier.isStatic(property.getReadMethod().getModifiers())) { return false; } Field field = getDeclaredField(property); if (field == null && property.getWriteMethod() == null) { log.debug("Property " + property.getName() + " has no setter method or private attribute. Skipping."); return false; } return property.getReadMethod().getAnnotation(Transient.class) == null && (field == null || field.getAnnotation(Transient.class) == null); }
java
private boolean isCandidate(PropertyDescriptor property) { if ("class".equals(property.getName()) || property.getReadMethod() == null || Modifier.isStatic(property.getReadMethod().getModifiers())) { return false; } Field field = getDeclaredField(property); if (field == null && property.getWriteMethod() == null) { log.debug("Property " + property.getName() + " has no setter method or private attribute. Skipping."); return false; } return property.getReadMethod().getAnnotation(Transient.class) == null && (field == null || field.getAnnotation(Transient.class) == null); }
[ "private", "boolean", "isCandidate", "(", "PropertyDescriptor", "property", ")", "{", "if", "(", "\"class\"", ".", "equals", "(", "property", ".", "getName", "(", ")", ")", "||", "property", ".", "getReadMethod", "(", ")", "==", "null", "||", "Modifier", ".", "isStatic", "(", "property", ".", "getReadMethod", "(", ")", ".", "getModifiers", "(", ")", ")", ")", "{", "return", "false", ";", "}", "Field", "field", "=", "getDeclaredField", "(", "property", ")", ";", "if", "(", "field", "==", "null", "&&", "property", ".", "getWriteMethod", "(", ")", "==", "null", ")", "{", "log", ".", "debug", "(", "\"Property \"", "+", "property", ".", "getName", "(", ")", "+", "\" has no setter method or private attribute. Skipping.\"", ")", ";", "return", "false", ";", "}", "return", "property", ".", "getReadMethod", "(", ")", ".", "getAnnotation", "(", "Transient", ".", "class", ")", "==", "null", "&&", "(", "field", "==", "null", "||", "field", ".", "getAnnotation", "(", "Transient", ".", "class", ")", "==", "null", ")", ";", "}" ]
Return true if the field is private or marked as transient
[ "Return", "true", "if", "the", "field", "is", "private", "or", "marked", "as", "transient" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadataFactory.java#L188-L198
149,987
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/MainWindow.java
MainWindow.startWorker
private void startWorker() { JobServiceFactory serviceFactory = new JobServiceFactory() { private boolean first = true; public JobService connect() { SwingUtilities.invokeLater(new Runnable() { public void run() { setStatus("Connecting..."); } }); JobService service = first ? MainWindow.this.connect() : reconnect(); if (service == null) { setVisible(false); throw new RuntimeException("Unable to connect"); } SwingUtilities.invokeLater(new Runnable() { public void run() { setStatus("Connected"); } }); first = false; return service; } // // public JobService connect() { // try { // SwingUtilities.invokeAndWait(task); // } catch (Exception e) { // logger.warn("Exception thrown trying to reconnect", e); // throw new RuntimeException(e); // } // if (task.service == null) { // throw new RuntimeException("No service."); // } // return task.service; // } }; int availableCpus = Runtime.getRuntime().availableProcessors(); if (options.numberOfCpus < 0) { options.numberOfCpus = pref.getInt("maxCpus", 0); } if (options.numberOfCpus <= 0 || options.numberOfCpus > availableCpus) { options.numberOfCpus = availableCpus; } if (worker != null) { setStatus("Shutting down worker..."); worker.shutdown(); try { workerThread.join(); } catch (InterruptedException e) { } progressPanel.clear(); } setStatus("Starting worker..."); CourtesyMonitor courtesyMonitor = (powerMonitor != null) ? powerMonitor : new UnconditionalCourtesyMonitor(); ThreadFactory threadFactory = new BackgroundThreadFactory(); worker = new ThreadServiceWorker(serviceFactory, threadFactory, getProgressPanel(), courtesyMonitor); worker.setMaxWorkers(options.numberOfCpus); boolean cacheClassDefinitions = pref.getBoolean("cacheClassDefinitions", true); if (cacheClassDefinitions) { setStatus("Preparing data source..."); EmbeddedDataSource ds = null; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); ds = new EmbeddedDataSource(); ds.setConnectionAttributes("create=true"); ds.setDatabaseName("classes"); worker.setDataSource(ds); } catch (ClassNotFoundException e) { logger.error("Could not locate database driver.", e); } catch (SQLException e) { logger.error("Error occurred while initializing data source.", e); } } onPreferencesChanged(); workerThread = new Thread(worker); workerThread.start(); }
java
private void startWorker() { JobServiceFactory serviceFactory = new JobServiceFactory() { private boolean first = true; public JobService connect() { SwingUtilities.invokeLater(new Runnable() { public void run() { setStatus("Connecting..."); } }); JobService service = first ? MainWindow.this.connect() : reconnect(); if (service == null) { setVisible(false); throw new RuntimeException("Unable to connect"); } SwingUtilities.invokeLater(new Runnable() { public void run() { setStatus("Connected"); } }); first = false; return service; } // // public JobService connect() { // try { // SwingUtilities.invokeAndWait(task); // } catch (Exception e) { // logger.warn("Exception thrown trying to reconnect", e); // throw new RuntimeException(e); // } // if (task.service == null) { // throw new RuntimeException("No service."); // } // return task.service; // } }; int availableCpus = Runtime.getRuntime().availableProcessors(); if (options.numberOfCpus < 0) { options.numberOfCpus = pref.getInt("maxCpus", 0); } if (options.numberOfCpus <= 0 || options.numberOfCpus > availableCpus) { options.numberOfCpus = availableCpus; } if (worker != null) { setStatus("Shutting down worker..."); worker.shutdown(); try { workerThread.join(); } catch (InterruptedException e) { } progressPanel.clear(); } setStatus("Starting worker..."); CourtesyMonitor courtesyMonitor = (powerMonitor != null) ? powerMonitor : new UnconditionalCourtesyMonitor(); ThreadFactory threadFactory = new BackgroundThreadFactory(); worker = new ThreadServiceWorker(serviceFactory, threadFactory, getProgressPanel(), courtesyMonitor); worker.setMaxWorkers(options.numberOfCpus); boolean cacheClassDefinitions = pref.getBoolean("cacheClassDefinitions", true); if (cacheClassDefinitions) { setStatus("Preparing data source..."); EmbeddedDataSource ds = null; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); ds = new EmbeddedDataSource(); ds.setConnectionAttributes("create=true"); ds.setDatabaseName("classes"); worker.setDataSource(ds); } catch (ClassNotFoundException e) { logger.error("Could not locate database driver.", e); } catch (SQLException e) { logger.error("Error occurred while initializing data source.", e); } } onPreferencesChanged(); workerThread = new Thread(worker); workerThread.start(); }
[ "private", "void", "startWorker", "(", ")", "{", "JobServiceFactory", "serviceFactory", "=", "new", "JobServiceFactory", "(", ")", "{", "private", "boolean", "first", "=", "true", ";", "public", "JobService", "connect", "(", ")", "{", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "setStatus", "(", "\"Connecting...\"", ")", ";", "}", "}", ")", ";", "JobService", "service", "=", "first", "?", "MainWindow", ".", "this", ".", "connect", "(", ")", ":", "reconnect", "(", ")", ";", "if", "(", "service", "==", "null", ")", "{", "setVisible", "(", "false", ")", ";", "throw", "new", "RuntimeException", "(", "\"Unable to connect\"", ")", ";", "}", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "setStatus", "(", "\"Connected\"", ")", ";", "}", "}", ")", ";", "first", "=", "false", ";", "return", "service", ";", "}", "//", "// public JobService connect() {", "// try {", "// SwingUtilities.invokeAndWait(task);", "// } catch (Exception e) {", "// logger.warn(\"Exception thrown trying to reconnect\", e);", "// throw new RuntimeException(e);", "// }", "// if (task.service == null) {", "// throw new RuntimeException(\"No service.\");", "// }", "// return task.service;", "// }", "}", ";", "int", "availableCpus", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", ";", "if", "(", "options", ".", "numberOfCpus", "<", "0", ")", "{", "options", ".", "numberOfCpus", "=", "pref", ".", "getInt", "(", "\"maxCpus\"", ",", "0", ")", ";", "}", "if", "(", "options", ".", "numberOfCpus", "<=", "0", "||", "options", ".", "numberOfCpus", ">", "availableCpus", ")", "{", "options", ".", "numberOfCpus", "=", "availableCpus", ";", "}", "if", "(", "worker", "!=", "null", ")", "{", "setStatus", "(", "\"Shutting down worker...\"", ")", ";", "worker", ".", "shutdown", "(", ")", ";", "try", "{", "workerThread", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "progressPanel", ".", "clear", "(", ")", ";", "}", "setStatus", "(", "\"Starting worker...\"", ")", ";", "CourtesyMonitor", "courtesyMonitor", "=", "(", "powerMonitor", "!=", "null", ")", "?", "powerMonitor", ":", "new", "UnconditionalCourtesyMonitor", "(", ")", ";", "ThreadFactory", "threadFactory", "=", "new", "BackgroundThreadFactory", "(", ")", ";", "worker", "=", "new", "ThreadServiceWorker", "(", "serviceFactory", ",", "threadFactory", ",", "getProgressPanel", "(", ")", ",", "courtesyMonitor", ")", ";", "worker", ".", "setMaxWorkers", "(", "options", ".", "numberOfCpus", ")", ";", "boolean", "cacheClassDefinitions", "=", "pref", ".", "getBoolean", "(", "\"cacheClassDefinitions\"", ",", "true", ")", ";", "if", "(", "cacheClassDefinitions", ")", "{", "setStatus", "(", "\"Preparing data source...\"", ")", ";", "EmbeddedDataSource", "ds", "=", "null", ";", "try", "{", "Class", ".", "forName", "(", "\"org.apache.derby.jdbc.EmbeddedDriver\"", ")", ";", "ds", "=", "new", "EmbeddedDataSource", "(", ")", ";", "ds", ".", "setConnectionAttributes", "(", "\"create=true\"", ")", ";", "ds", ".", "setDatabaseName", "(", "\"classes\"", ")", ";", "worker", ".", "setDataSource", "(", "ds", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "logger", ".", "error", "(", "\"Could not locate database driver.\"", ",", "e", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "logger", ".", "error", "(", "\"Error occurred while initializing data source.\"", ",", "e", ")", ";", "}", "}", "onPreferencesChanged", "(", ")", ";", "workerThread", "=", "new", "Thread", "(", "worker", ")", ";", "workerThread", ".", "start", "(", ")", ";", "}" ]
Start the worker thread.
[ "Start", "the", "worker", "thread", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/MainWindow.java#L486-L576
149,988
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/entity/KeywordAlchemyEntity.java
KeywordAlchemyEntity.setKeyword
public void setKeyword(String keyword) { if(keyword != null) { keyword = keyword.trim(); } this.keyword = keyword; }
java
public void setKeyword(String keyword) { if(keyword != null) { keyword = keyword.trim(); } this.keyword = keyword; }
[ "public", "void", "setKeyword", "(", "String", "keyword", ")", "{", "if", "(", "keyword", "!=", "null", ")", "{", "keyword", "=", "keyword", ".", "trim", "(", ")", ";", "}", "this", ".", "keyword", "=", "keyword", ";", "}" ]
Set the detected keyword text. @param keyword detected keyword text
[ "Set", "the", "detected", "keyword", "text", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/entity/KeywordAlchemyEntity.java#L48-L53
149,989
icoloma/simpleds
src/main/java/org/simpleds/util/GenericCollectionTypeResolver.java
GenericCollectionTypeResolver.extractTypeFromParameterizedType
private static Class<?> extractTypeFromParameterizedType(MethodParameter methodParam, ParameterizedType ptype, Class<?> source, int typeIndex, int nestingLevel, int currentLevel) { if (!(ptype.getRawType() instanceof Class)) { return null; } Class rawType = (Class) ptype.getRawType(); Type[] paramTypes = ptype.getActualTypeArguments(); if (nestingLevel - currentLevel > 0) { int nextLevel = currentLevel + 1; Integer currentTypeIndex = (methodParam != null ? methodParam.getTypeIndexForLevel(nextLevel) : null); // Default is last parameter type: Collection element or Map value. int indexToUse = (currentTypeIndex != null ? currentTypeIndex : paramTypes.length - 1); Type paramType = paramTypes[indexToUse]; return extractType(methodParam, paramType, source, typeIndex, nestingLevel, nextLevel); } if (source != null && !source.isAssignableFrom(rawType)) { return null; } Class fromSuperclassOrInterface = extractTypeFromClass(methodParam, rawType, source, typeIndex, nestingLevel, currentLevel); if (fromSuperclassOrInterface != null) { return fromSuperclassOrInterface; } if (paramTypes == null || typeIndex >= paramTypes.length) { return null; } Type paramType = paramTypes[typeIndex]; if (paramType instanceof TypeVariable && methodParam != null && methodParam.typeVariableMap != null) { Type mappedType = methodParam.typeVariableMap.get(paramType); if (mappedType != null) { paramType = mappedType; } } if (paramType instanceof WildcardType) { WildcardType wildcardType = (WildcardType) paramType; Type[] upperBounds = wildcardType.getUpperBounds(); if (upperBounds != null && upperBounds.length > 0 && !Object.class.equals(upperBounds[0])) { paramType = upperBounds[0]; } else { Type[] lowerBounds = wildcardType.getLowerBounds(); if (lowerBounds != null && lowerBounds.length > 0 && !Object.class.equals(lowerBounds[0])) { paramType = lowerBounds[0]; } } } if (paramType instanceof ParameterizedType) { paramType = ((ParameterizedType) paramType).getRawType(); } if (paramType instanceof GenericArrayType) { // A generic array type... Let's turn it into a straight array type if possible. Type compType = ((GenericArrayType) paramType).getGenericComponentType(); if (compType instanceof Class) { return Array.newInstance((Class) compType, 0).getClass(); } } else if (paramType instanceof Class) { // We finally got a straight Class... return (Class) paramType; } return null; }
java
private static Class<?> extractTypeFromParameterizedType(MethodParameter methodParam, ParameterizedType ptype, Class<?> source, int typeIndex, int nestingLevel, int currentLevel) { if (!(ptype.getRawType() instanceof Class)) { return null; } Class rawType = (Class) ptype.getRawType(); Type[] paramTypes = ptype.getActualTypeArguments(); if (nestingLevel - currentLevel > 0) { int nextLevel = currentLevel + 1; Integer currentTypeIndex = (methodParam != null ? methodParam.getTypeIndexForLevel(nextLevel) : null); // Default is last parameter type: Collection element or Map value. int indexToUse = (currentTypeIndex != null ? currentTypeIndex : paramTypes.length - 1); Type paramType = paramTypes[indexToUse]; return extractType(methodParam, paramType, source, typeIndex, nestingLevel, nextLevel); } if (source != null && !source.isAssignableFrom(rawType)) { return null; } Class fromSuperclassOrInterface = extractTypeFromClass(methodParam, rawType, source, typeIndex, nestingLevel, currentLevel); if (fromSuperclassOrInterface != null) { return fromSuperclassOrInterface; } if (paramTypes == null || typeIndex >= paramTypes.length) { return null; } Type paramType = paramTypes[typeIndex]; if (paramType instanceof TypeVariable && methodParam != null && methodParam.typeVariableMap != null) { Type mappedType = methodParam.typeVariableMap.get(paramType); if (mappedType != null) { paramType = mappedType; } } if (paramType instanceof WildcardType) { WildcardType wildcardType = (WildcardType) paramType; Type[] upperBounds = wildcardType.getUpperBounds(); if (upperBounds != null && upperBounds.length > 0 && !Object.class.equals(upperBounds[0])) { paramType = upperBounds[0]; } else { Type[] lowerBounds = wildcardType.getLowerBounds(); if (lowerBounds != null && lowerBounds.length > 0 && !Object.class.equals(lowerBounds[0])) { paramType = lowerBounds[0]; } } } if (paramType instanceof ParameterizedType) { paramType = ((ParameterizedType) paramType).getRawType(); } if (paramType instanceof GenericArrayType) { // A generic array type... Let's turn it into a straight array type if possible. Type compType = ((GenericArrayType) paramType).getGenericComponentType(); if (compType instanceof Class) { return Array.newInstance((Class) compType, 0).getClass(); } } else if (paramType instanceof Class) { // We finally got a straight Class... return (Class) paramType; } return null; }
[ "private", "static", "Class", "<", "?", ">", "extractTypeFromParameterizedType", "(", "MethodParameter", "methodParam", ",", "ParameterizedType", "ptype", ",", "Class", "<", "?", ">", "source", ",", "int", "typeIndex", ",", "int", "nestingLevel", ",", "int", "currentLevel", ")", "{", "if", "(", "!", "(", "ptype", ".", "getRawType", "(", ")", "instanceof", "Class", ")", ")", "{", "return", "null", ";", "}", "Class", "rawType", "=", "(", "Class", ")", "ptype", ".", "getRawType", "(", ")", ";", "Type", "[", "]", "paramTypes", "=", "ptype", ".", "getActualTypeArguments", "(", ")", ";", "if", "(", "nestingLevel", "-", "currentLevel", ">", "0", ")", "{", "int", "nextLevel", "=", "currentLevel", "+", "1", ";", "Integer", "currentTypeIndex", "=", "(", "methodParam", "!=", "null", "?", "methodParam", ".", "getTypeIndexForLevel", "(", "nextLevel", ")", ":", "null", ")", ";", "// Default is last parameter type: Collection element or Map value.", "int", "indexToUse", "=", "(", "currentTypeIndex", "!=", "null", "?", "currentTypeIndex", ":", "paramTypes", ".", "length", "-", "1", ")", ";", "Type", "paramType", "=", "paramTypes", "[", "indexToUse", "]", ";", "return", "extractType", "(", "methodParam", ",", "paramType", ",", "source", ",", "typeIndex", ",", "nestingLevel", ",", "nextLevel", ")", ";", "}", "if", "(", "source", "!=", "null", "&&", "!", "source", ".", "isAssignableFrom", "(", "rawType", ")", ")", "{", "return", "null", ";", "}", "Class", "fromSuperclassOrInterface", "=", "extractTypeFromClass", "(", "methodParam", ",", "rawType", ",", "source", ",", "typeIndex", ",", "nestingLevel", ",", "currentLevel", ")", ";", "if", "(", "fromSuperclassOrInterface", "!=", "null", ")", "{", "return", "fromSuperclassOrInterface", ";", "}", "if", "(", "paramTypes", "==", "null", "||", "typeIndex", ">=", "paramTypes", ".", "length", ")", "{", "return", "null", ";", "}", "Type", "paramType", "=", "paramTypes", "[", "typeIndex", "]", ";", "if", "(", "paramType", "instanceof", "TypeVariable", "&&", "methodParam", "!=", "null", "&&", "methodParam", ".", "typeVariableMap", "!=", "null", ")", "{", "Type", "mappedType", "=", "methodParam", ".", "typeVariableMap", ".", "get", "(", "paramType", ")", ";", "if", "(", "mappedType", "!=", "null", ")", "{", "paramType", "=", "mappedType", ";", "}", "}", "if", "(", "paramType", "instanceof", "WildcardType", ")", "{", "WildcardType", "wildcardType", "=", "(", "WildcardType", ")", "paramType", ";", "Type", "[", "]", "upperBounds", "=", "wildcardType", ".", "getUpperBounds", "(", ")", ";", "if", "(", "upperBounds", "!=", "null", "&&", "upperBounds", ".", "length", ">", "0", "&&", "!", "Object", ".", "class", ".", "equals", "(", "upperBounds", "[", "0", "]", ")", ")", "{", "paramType", "=", "upperBounds", "[", "0", "]", ";", "}", "else", "{", "Type", "[", "]", "lowerBounds", "=", "wildcardType", ".", "getLowerBounds", "(", ")", ";", "if", "(", "lowerBounds", "!=", "null", "&&", "lowerBounds", ".", "length", ">", "0", "&&", "!", "Object", ".", "class", ".", "equals", "(", "lowerBounds", "[", "0", "]", ")", ")", "{", "paramType", "=", "lowerBounds", "[", "0", "]", ";", "}", "}", "}", "if", "(", "paramType", "instanceof", "ParameterizedType", ")", "{", "paramType", "=", "(", "(", "ParameterizedType", ")", "paramType", ")", ".", "getRawType", "(", ")", ";", "}", "if", "(", "paramType", "instanceof", "GenericArrayType", ")", "{", "// A generic array type... Let's turn it into a straight array type if possible.", "Type", "compType", "=", "(", "(", "GenericArrayType", ")", "paramType", ")", ".", "getGenericComponentType", "(", ")", ";", "if", "(", "compType", "instanceof", "Class", ")", "{", "return", "Array", ".", "newInstance", "(", "(", "Class", ")", "compType", ",", "0", ")", ".", "getClass", "(", ")", ";", "}", "}", "else", "if", "(", "paramType", "instanceof", "Class", ")", "{", "// We finally got a straight Class...", "return", "(", "Class", ")", "paramType", ";", "}", "return", "null", ";", "}" ]
Extract the generic type from the given ParameterizedType object. @param methodParam the method parameter specification @param ptype the ParameterizedType to check @param source the expected raw source type (can be <code>null</code>) @param typeIndex the index of the actual type argument @param nestingLevel the nesting level of the target type @param currentLevel the current nested level @return the generic type as Class, or <code>null</code> if none
[ "Extract", "the", "generic", "type", "from", "the", "given", "ParameterizedType", "object", "." ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/util/GenericCollectionTypeResolver.java#L291-L353
149,990
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/service/EmailTemplateRendererService.java
EmailTemplateRendererService.render
public String render(String templateName, EmailModel emailModel, Map<String, Object> model, Locale locale) { if (logger.isDebugEnabled()) { logger.debug("Rendering template [{}] for recipient [{}]", templateName, emailModel.getTo()); } final IEngineConfiguration engineConfiguration = templateEngineFactory.getTemplateEngine().getConfiguration(); final ExpressionContext context = new ExpressionContext(engineConfiguration, locale); context.setVariable(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, new ThymeleafEvaluationContext(applicationContext, null)); context.setVariables(model); context.setVariable(THYMELEAF_EMAIL_MODEL_NAME, emailModel); return templateEngineFactory.getTemplateEngine().process(templateName, context); }
java
public String render(String templateName, EmailModel emailModel, Map<String, Object> model, Locale locale) { if (logger.isDebugEnabled()) { logger.debug("Rendering template [{}] for recipient [{}]", templateName, emailModel.getTo()); } final IEngineConfiguration engineConfiguration = templateEngineFactory.getTemplateEngine().getConfiguration(); final ExpressionContext context = new ExpressionContext(engineConfiguration, locale); context.setVariable(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, new ThymeleafEvaluationContext(applicationContext, null)); context.setVariables(model); context.setVariable(THYMELEAF_EMAIL_MODEL_NAME, emailModel); return templateEngineFactory.getTemplateEngine().process(templateName, context); }
[ "public", "String", "render", "(", "String", "templateName", ",", "EmailModel", "emailModel", ",", "Map", "<", "String", ",", "Object", ">", "model", ",", "Locale", "locale", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Rendering template [{}] for recipient [{}]\"", ",", "templateName", ",", "emailModel", ".", "getTo", "(", ")", ")", ";", "}", "final", "IEngineConfiguration", "engineConfiguration", "=", "templateEngineFactory", ".", "getTemplateEngine", "(", ")", ".", "getConfiguration", "(", ")", ";", "final", "ExpressionContext", "context", "=", "new", "ExpressionContext", "(", "engineConfiguration", ",", "locale", ")", ";", "context", ".", "setVariable", "(", "ThymeleafEvaluationContext", ".", "THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME", ",", "new", "ThymeleafEvaluationContext", "(", "applicationContext", ",", "null", ")", ")", ";", "context", ".", "setVariables", "(", "model", ")", ";", "context", ".", "setVariable", "(", "THYMELEAF_EMAIL_MODEL_NAME", ",", "emailModel", ")", ";", "return", "templateEngineFactory", ".", "getTemplateEngine", "(", ")", ".", "process", "(", "templateName", ",", "context", ")", ";", "}" ]
renders a template and returns its output @param templateName the templateName to be resolved by Thymeleafs templateResolver @param emailModel the emailModel @param model additional model @param locale the locale @return rendered output
[ "renders", "a", "template", "and", "returns", "its", "output" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/service/EmailTemplateRendererService.java#L53-L68
149,991
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/service/EmailTemplateRendererService.java
EmailTemplateRendererService.htmlToText
public String htmlToText(String html) { final Source source = new Source(html); return source.getRenderer().toString(); }
java
public String htmlToText(String html) { final Source source = new Source(html); return source.getRenderer().toString(); }
[ "public", "String", "htmlToText", "(", "String", "html", ")", "{", "final", "Source", "source", "=", "new", "Source", "(", "html", ")", ";", "return", "source", ".", "getRenderer", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Converts HTML to plain text using Jericho HTML parser @see <a href="http://jericho.htmlparser.net">http://jericho.htmlparser.net</a> @param html valid html Content @return a plain text representation of the HTML content (line breaks, list items, tables, etc. converted)
[ "Converts", "HTML", "to", "plain", "text", "using", "Jericho", "HTML", "parser" ]
a55d9ef1a2173917cb5f870854bc24e5aaebd182
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/service/EmailTemplateRendererService.java#L77-L80
149,992
icoloma/simpleds
src/main/java/org/simpleds/SimpleQuery.java
SimpleQuery.asList
public <T> List<T> asList() { String cacheKey = null; // is the result of the query cached? if (isCacheable() && transaction == null) { cacheKey = getCacheKey(); List<Key> keys = getCacheManager().get(cacheNamespace, cacheKey); if (keys != null) { if (isKeysOnly()) { return (List) keys; } else { final Map<Key, T> values = entityManager.get(keys); return Lists.transform(keys, new Function<Key, T>() { @Override public T apply(Key key) { return values.get(key); } }); } } } // execute the query List<T> result = Lists.newArrayList((Iterable<T>) asIterable()); if (isCacheable()) { Collection<Key> keys = isKeysOnly()? result : Collections2.transform(result, new EntityToKeyFunction(classMetadata.getPersistentClass())); populateCache(cacheKey, Lists.newArrayList(keys)); } return result; }
java
public <T> List<T> asList() { String cacheKey = null; // is the result of the query cached? if (isCacheable() && transaction == null) { cacheKey = getCacheKey(); List<Key> keys = getCacheManager().get(cacheNamespace, cacheKey); if (keys != null) { if (isKeysOnly()) { return (List) keys; } else { final Map<Key, T> values = entityManager.get(keys); return Lists.transform(keys, new Function<Key, T>() { @Override public T apply(Key key) { return values.get(key); } }); } } } // execute the query List<T> result = Lists.newArrayList((Iterable<T>) asIterable()); if (isCacheable()) { Collection<Key> keys = isKeysOnly()? result : Collections2.transform(result, new EntityToKeyFunction(classMetadata.getPersistentClass())); populateCache(cacheKey, Lists.newArrayList(keys)); } return result; }
[ "public", "<", "T", ">", "List", "<", "T", ">", "asList", "(", ")", "{", "String", "cacheKey", "=", "null", ";", "// is the result of the query cached?", "if", "(", "isCacheable", "(", ")", "&&", "transaction", "==", "null", ")", "{", "cacheKey", "=", "getCacheKey", "(", ")", ";", "List", "<", "Key", ">", "keys", "=", "getCacheManager", "(", ")", ".", "get", "(", "cacheNamespace", ",", "cacheKey", ")", ";", "if", "(", "keys", "!=", "null", ")", "{", "if", "(", "isKeysOnly", "(", ")", ")", "{", "return", "(", "List", ")", "keys", ";", "}", "else", "{", "final", "Map", "<", "Key", ",", "T", ">", "values", "=", "entityManager", ".", "get", "(", "keys", ")", ";", "return", "Lists", ".", "transform", "(", "keys", ",", "new", "Function", "<", "Key", ",", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "apply", "(", "Key", "key", ")", "{", "return", "values", ".", "get", "(", "key", ")", ";", "}", "}", ")", ";", "}", "}", "}", "// execute the query", "List", "<", "T", ">", "result", "=", "Lists", ".", "newArrayList", "(", "(", "Iterable", "<", "T", ">", ")", "asIterable", "(", ")", ")", ";", "if", "(", "isCacheable", "(", ")", ")", "{", "Collection", "<", "Key", ">", "keys", "=", "isKeysOnly", "(", ")", "?", "result", ":", "Collections2", ".", "transform", "(", "result", ",", "new", "EntityToKeyFunction", "(", "classMetadata", ".", "getPersistentClass", "(", ")", ")", ")", ";", "populateCache", "(", "cacheKey", ",", "Lists", ".", "newArrayList", "(", "keys", ")", ")", ";", "}", "return", "result", ";", "}" ]
Execute the provided query and returns the result as a List of java objects @return the list of resulting java entities
[ "Execute", "the", "provided", "query", "and", "returns", "the", "result", "as", "a", "List", "of", "java", "objects" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/SimpleQuery.java#L379-L410
149,993
icoloma/simpleds
src/main/java/org/simpleds/SimpleQuery.java
SimpleQuery.asCursorList
public <T> CursorList<T> asCursorList(int size) { CursorList<T> result = CursorList.create(this, size); return result; }
java
public <T> CursorList<T> asCursorList(int size) { CursorList<T> result = CursorList.create(this, size); return result; }
[ "public", "<", "T", ">", "CursorList", "<", "T", ">", "asCursorList", "(", "int", "size", ")", "{", "CursorList", "<", "T", ">", "result", "=", "CursorList", ".", "create", "(", "this", ",", "size", ")", ";", "return", "result", ";", "}" ]
Execute the query and return a CursorList @return the CursorList according to the provided startCursor and limit values
[ "Execute", "the", "query", "and", "return", "a", "CursorList" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/SimpleQuery.java#L425-L428
149,994
icoloma/simpleds
src/main/java/org/simpleds/SimpleQuery.java
SimpleQuery.asSingleResult
public <T> T asSingleResult() { T javaObject = null; String cacheKey = getCacheKey(); if (isCacheable() && transaction == null) { Collection<Key> keys = getCacheManager().get(cacheNamespace, cacheKey); if (keys != null && keys.size() > 0) { Key key = keys.iterator().next(); try { javaObject = (T) entityManager.get(key); } catch (EntityNotFoundException e) { throw new InconsistentCacheException("Entity Key " + key + " found in the cache but not in the Datastore"); } } } if (javaObject == null) { Entity entity = getDatastoreService().prepare(query).asSingleEntity(); if (entity == null) { throw new org.simpleds.exception.EntityNotFoundException("No " + getKind() + " found with " + getFilterPredicates()); } javaObject = (T) entityManager.datastoreToJava(entity); if (isCacheable()) { populateCache(cacheKey, ImmutableList.of(entity.getKey())); } } return javaObject; }
java
public <T> T asSingleResult() { T javaObject = null; String cacheKey = getCacheKey(); if (isCacheable() && transaction == null) { Collection<Key> keys = getCacheManager().get(cacheNamespace, cacheKey); if (keys != null && keys.size() > 0) { Key key = keys.iterator().next(); try { javaObject = (T) entityManager.get(key); } catch (EntityNotFoundException e) { throw new InconsistentCacheException("Entity Key " + key + " found in the cache but not in the Datastore"); } } } if (javaObject == null) { Entity entity = getDatastoreService().prepare(query).asSingleEntity(); if (entity == null) { throw new org.simpleds.exception.EntityNotFoundException("No " + getKind() + " found with " + getFilterPredicates()); } javaObject = (T) entityManager.datastoreToJava(entity); if (isCacheable()) { populateCache(cacheKey, ImmutableList.of(entity.getKey())); } } return javaObject; }
[ "public", "<", "T", ">", "T", "asSingleResult", "(", ")", "{", "T", "javaObject", "=", "null", ";", "String", "cacheKey", "=", "getCacheKey", "(", ")", ";", "if", "(", "isCacheable", "(", ")", "&&", "transaction", "==", "null", ")", "{", "Collection", "<", "Key", ">", "keys", "=", "getCacheManager", "(", ")", ".", "get", "(", "cacheNamespace", ",", "cacheKey", ")", ";", "if", "(", "keys", "!=", "null", "&&", "keys", ".", "size", "(", ")", ">", "0", ")", "{", "Key", "key", "=", "keys", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "try", "{", "javaObject", "=", "(", "T", ")", "entityManager", ".", "get", "(", "key", ")", ";", "}", "catch", "(", "EntityNotFoundException", "e", ")", "{", "throw", "new", "InconsistentCacheException", "(", "\"Entity Key \"", "+", "key", "+", "\" found in the cache but not in the Datastore\"", ")", ";", "}", "}", "}", "if", "(", "javaObject", "==", "null", ")", "{", "Entity", "entity", "=", "getDatastoreService", "(", ")", ".", "prepare", "(", "query", ")", ".", "asSingleEntity", "(", ")", ";", "if", "(", "entity", "==", "null", ")", "{", "throw", "new", "org", ".", "simpleds", ".", "exception", ".", "EntityNotFoundException", "(", "\"No \"", "+", "getKind", "(", ")", "+", "\" found with \"", "+", "getFilterPredicates", "(", ")", ")", ";", "}", "javaObject", "=", "(", "T", ")", "entityManager", ".", "datastoreToJava", "(", "entity", ")", ";", "if", "(", "isCacheable", "(", ")", ")", "{", "populateCache", "(", "cacheKey", ",", "ImmutableList", ".", "of", "(", "entity", ".", "getKey", "(", ")", ")", ")", ";", "}", "}", "return", "javaObject", ";", "}" ]
Execute the query and return a single result @return the first result of the query @throws EntityNotFoundException if the query did not return any result
[ "Execute", "the", "query", "and", "return", "a", "single", "result" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/SimpleQuery.java#L435-L461
149,995
icoloma/simpleds
src/main/java/org/simpleds/SimpleQuery.java
SimpleQuery.count
public int count() { Integer result = null; if (result == null) { SimpleQuery q = this.isKeysOnly()? this : this.clone().keysOnly(); result = getDatastoreService().prepare(q.getQuery()).countEntities(fetchOptions); } return result; }
java
public int count() { Integer result = null; if (result == null) { SimpleQuery q = this.isKeysOnly()? this : this.clone().keysOnly(); result = getDatastoreService().prepare(q.getQuery()).countEntities(fetchOptions); } return result; }
[ "public", "int", "count", "(", ")", "{", "Integer", "result", "=", "null", ";", "if", "(", "result", "==", "null", ")", "{", "SimpleQuery", "q", "=", "this", ".", "isKeysOnly", "(", ")", "?", "this", ":", "this", ".", "clone", "(", ")", ".", "keysOnly", "(", ")", ";", "result", "=", "getDatastoreService", "(", ")", ".", "prepare", "(", "q", ".", "getQuery", "(", ")", ")", ".", "countEntities", "(", "fetchOptions", ")", ";", "}", "return", "result", ";", "}" ]
Counts the number of instances returned from this query. This method will only retrieve the matching keys, not the entities themselves.
[ "Counts", "the", "number", "of", "instances", "returned", "from", "this", "query", ".", "This", "method", "will", "only", "retrieve", "the", "matching", "keys", "not", "the", "entities", "themselves", "." ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/SimpleQuery.java#L477-L484
149,996
icoloma/simpleds
src/main/java/org/simpleds/SimpleQuery.java
SimpleQuery.addCommonCacheKeyParts
private void addCommonCacheKeyParts(StringBuilder builder) { builder.append("kind=").append(getKind()); List<FilterPredicate> predicates = query.getFilterPredicates(); if (predicates.size() > 0) { builder.append(",pred=").append(predicates); } }
java
private void addCommonCacheKeyParts(StringBuilder builder) { builder.append("kind=").append(getKind()); List<FilterPredicate> predicates = query.getFilterPredicates(); if (predicates.size() > 0) { builder.append(",pred=").append(predicates); } }
[ "private", "void", "addCommonCacheKeyParts", "(", "StringBuilder", "builder", ")", "{", "builder", ".", "append", "(", "\"kind=\"", ")", ".", "append", "(", "getKind", "(", ")", ")", ";", "List", "<", "FilterPredicate", ">", "predicates", "=", "query", ".", "getFilterPredicates", "(", ")", ";", "if", "(", "predicates", ".", "size", "(", ")", ">", "0", ")", "{", "builder", ".", "append", "(", "\",pred=\"", ")", ".", "append", "(", "predicates", ")", ";", "}", "}" ]
Add cache key parts that are common to query data and query count. @param builder
[ "Add", "cache", "key", "parts", "that", "are", "common", "to", "query", "data", "and", "query", "count", "." ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/SimpleQuery.java#L559-L565
149,997
io7m/jcanephora
com.io7m.jcanephora.jogl/src/main/java/com/io7m/jcanephora/jogl/JOGLTypeConversions.java
JOGLTypeConversions.polygonModeFromGL
public static JCGLPolygonMode polygonModeFromGL( final int g) { switch (g) { case GL2GL3.GL_FILL: return JCGLPolygonMode.POLYGON_FILL; case GL2GL3.GL_LINE: return JCGLPolygonMode.POLYGON_LINES; case GL2GL3.GL_POINT: return JCGLPolygonMode.POLYGON_POINTS; default: throw new UnreachableCodeException(); } }
java
public static JCGLPolygonMode polygonModeFromGL( final int g) { switch (g) { case GL2GL3.GL_FILL: return JCGLPolygonMode.POLYGON_FILL; case GL2GL3.GL_LINE: return JCGLPolygonMode.POLYGON_LINES; case GL2GL3.GL_POINT: return JCGLPolygonMode.POLYGON_POINTS; default: throw new UnreachableCodeException(); } }
[ "public", "static", "JCGLPolygonMode", "polygonModeFromGL", "(", "final", "int", "g", ")", "{", "switch", "(", "g", ")", "{", "case", "GL2GL3", ".", "GL_FILL", ":", "return", "JCGLPolygonMode", ".", "POLYGON_FILL", ";", "case", "GL2GL3", ".", "GL_LINE", ":", "return", "JCGLPolygonMode", ".", "POLYGON_LINES", ";", "case", "GL2GL3", ".", "GL_POINT", ":", "return", "JCGLPolygonMode", ".", "POLYGON_POINTS", ";", "default", ":", "throw", "new", "UnreachableCodeException", "(", ")", ";", "}", "}" ]
Convert polygon modes from GL constants. @param g The GL constant. @return The value.
[ "Convert", "polygon", "modes", "from", "GL", "constants", "." ]
0004c1744b7f0969841d04cd4fa693f402b10980
https://github.com/io7m/jcanephora/blob/0004c1744b7f0969841d04cd4fa693f402b10980/com.io7m.jcanephora.jogl/src/main/java/com/io7m/jcanephora/jogl/JOGLTypeConversions.java#L168-L181
149,998
vikingbrain/thedavidbox-client4j
src/main/java/com/vikingbrain/nmt/client/modules/impl/ModuleMetadataDatabaseImpl.java
ModuleMetadataDatabaseImpl.getDatabase
private MetadataDatabase getDatabase(String deviceUrl) throws TheDavidBoxClientException{ ResponseCheckDatabase responseCheckDatabase = buildCheckDatabaseOperation(deviceUrl).execute(); String databasePath = responseCheckDatabase.getDatabasePath(); MetadataDatabase database = new MetadataDatabase(deviceUrl, databasePath); return database; }
java
private MetadataDatabase getDatabase(String deviceUrl) throws TheDavidBoxClientException{ ResponseCheckDatabase responseCheckDatabase = buildCheckDatabaseOperation(deviceUrl).execute(); String databasePath = responseCheckDatabase.getDatabasePath(); MetadataDatabase database = new MetadataDatabase(deviceUrl, databasePath); return database; }
[ "private", "MetadataDatabase", "getDatabase", "(", "String", "deviceUrl", ")", "throws", "TheDavidBoxClientException", "{", "ResponseCheckDatabase", "responseCheckDatabase", "=", "buildCheckDatabaseOperation", "(", "deviceUrl", ")", ".", "execute", "(", ")", ";", "String", "databasePath", "=", "responseCheckDatabase", ".", "getDatabasePath", "(", ")", ";", "MetadataDatabase", "database", "=", "new", "MetadataDatabase", "(", "deviceUrl", ",", "databasePath", ")", ";", "return", "database", ";", "}" ]
Get a possible database from a device url. @param deviceUrl the device url @return the metadata database @throws TheDavidBoxClientException exception in the client
[ "Get", "a", "possible", "database", "from", "a", "device", "url", "." ]
b2375a59b30fc3bd5dae34316bda68e01d006535
https://github.com/vikingbrain/thedavidbox-client4j/blob/b2375a59b30fc3bd5dae34316bda68e01d006535/src/main/java/com/vikingbrain/nmt/client/modules/impl/ModuleMetadataDatabaseImpl.java#L100-L106
149,999
vikingbrain/thedavidbox-client4j
src/main/java/com/vikingbrain/nmt/controller/impl/RemoteHttpServiceImpl.java
RemoteHttpServiceImpl.encodeHttpParameter
private String encodeHttpParameter(String str){ //It translates the empty space String encoded = str.replaceAll(" ", "%20"); //It translates the & symbol encoded = encoded.replaceAll("&", "%26"); // encoded = encoded.replaceAll("$", "%24"); // encoded = encoded.replaceAll("`", "%60"); // encoded = encoded.replaceAll(":", "%3A"); // encoded = encoded.replaceAll("<", "%3C"); // encoded = encoded.replaceAll(">", "%3E"); // encoded = encoded.replaceAll("[", "%5B"); // encoded = encoded.replaceAll("]", "%5D"); // encoded = encoded.replaceAll("{", "%7B"); // encoded = encoded.replaceAll("}", "%7D"); return encoded; }
java
private String encodeHttpParameter(String str){ //It translates the empty space String encoded = str.replaceAll(" ", "%20"); //It translates the & symbol encoded = encoded.replaceAll("&", "%26"); // encoded = encoded.replaceAll("$", "%24"); // encoded = encoded.replaceAll("`", "%60"); // encoded = encoded.replaceAll(":", "%3A"); // encoded = encoded.replaceAll("<", "%3C"); // encoded = encoded.replaceAll(">", "%3E"); // encoded = encoded.replaceAll("[", "%5B"); // encoded = encoded.replaceAll("]", "%5D"); // encoded = encoded.replaceAll("{", "%7B"); // encoded = encoded.replaceAll("}", "%7D"); return encoded; }
[ "private", "String", "encodeHttpParameter", "(", "String", "str", ")", "{", "//It translates the empty space", "String", "encoded", "=", "str", ".", "replaceAll", "(", "\" \"", ",", "\"%20\"", ")", ";", "//It translates the & symbol\t\t\t\t", "encoded", "=", "encoded", ".", "replaceAll", "(", "\"&\"", ",", "\"%26\"", ")", ";", "//\t\tencoded = encoded.replaceAll(\"$\", \"%24\");", "//\t\tencoded = encoded.replaceAll(\"`\", \"%60\");", "//\t\tencoded = encoded.replaceAll(\":\", \"%3A\");", "//\t\tencoded = encoded.replaceAll(\"<\", \"%3C\");", "//\t\tencoded = encoded.replaceAll(\">\", \"%3E\");", "//\t\tencoded = encoded.replaceAll(\"[\", \"%5B\");", "//\t\tencoded = encoded.replaceAll(\"]\", \"%5D\");", "//\t\tencoded = encoded.replaceAll(\"{\", \"%7B\");", "//\t\tencoded = encoded.replaceAll(\"}\", \"%7D\");", "return", "encoded", ";", "}" ]
It encodes special symbols in their valid representations for http requests. @param str the text to encode @return the text encoded for http
[ "It", "encodes", "special", "symbols", "in", "their", "valid", "representations", "for", "http", "requests", "." ]
b2375a59b30fc3bd5dae34316bda68e01d006535
https://github.com/vikingbrain/thedavidbox-client4j/blob/b2375a59b30fc3bd5dae34316bda68e01d006535/src/main/java/com/vikingbrain/nmt/controller/impl/RemoteHttpServiceImpl.java#L62-L80