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
145,400
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.zipDir
public static void zipDir(final File srcDir, final FileFilter filter, final String destPath, final File destFile) throws IOException { Utils4J.checkNotNull("srcDir", srcDir); Utils4J.checkValidDir(srcDir); Utils4J.checkNotNull("destFile", destFile); try (final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destFile)))) { zipDir(srcDir, filter, destPath, out); } }
java
public static void zipDir(final File srcDir, final FileFilter filter, final String destPath, final File destFile) throws IOException { Utils4J.checkNotNull("srcDir", srcDir); Utils4J.checkValidDir(srcDir); Utils4J.checkNotNull("destFile", destFile); try (final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destFile)))) { zipDir(srcDir, filter, destPath, out); } }
[ "public", "static", "void", "zipDir", "(", "final", "File", "srcDir", ",", "final", "FileFilter", "filter", ",", "final", "String", "destPath", ",", "final", "File", "destFile", ")", "throws", "IOException", "{", "Utils4J", ".", "checkNotNull", "(", "\"srcDir\"", ",", "srcDir", ")", ";", "Utils4J", ".", "checkValidDir", "(", "srcDir", ")", ";", "Utils4J", ".", "checkNotNull", "(", "\"destFile\"", ",", "destFile", ")", ";", "try", "(", "final", "ZipOutputStream", "out", "=", "new", "ZipOutputStream", "(", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "destFile", ")", ")", ")", ")", "{", "zipDir", "(", "srcDir", ",", "filter", ",", "destPath", ",", "out", ")", ";", "}", "}" ]
Creates a ZIP file and adds all files in a directory and all it's sub directories to the archive. Only entries are added that comply to the file filter. @param srcDir Directory to add - Cannot be <code>null</code> and must be a valid directory. @param filter Filter or <code>null</code> for all files/directories. @param destPath Path to use for the ZIP archive - May be <code>null</code> or an empyt string. @param destFile Target ZIP file - Cannot be <code>null</code>. @throws IOException Error writing to the output stream.
[ "Creates", "a", "ZIP", "file", "and", "adds", "all", "files", "in", "a", "directory", "and", "all", "it", "s", "sub", "directories", "to", "the", "archive", ".", "Only", "entries", "are", "added", "that", "comply", "to", "the", "file", "filter", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1379-L1389
145,401
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.zipDir
public static void zipDir(final File srcDir, final String destPath, final File destFile) throws IOException { zipDir(srcDir, null, destPath, destFile); }
java
public static void zipDir(final File srcDir, final String destPath, final File destFile) throws IOException { zipDir(srcDir, null, destPath, destFile); }
[ "public", "static", "void", "zipDir", "(", "final", "File", "srcDir", ",", "final", "String", "destPath", ",", "final", "File", "destFile", ")", "throws", "IOException", "{", "zipDir", "(", "srcDir", ",", "null", ",", "destPath", ",", "destFile", ")", ";", "}" ]
Creates a ZIP file and adds all files in a directory and all it's sub directories to the archive. @param srcDir Directory to add - Cannot be <code>null</code> and must be a valid directory. @param destPath Path to use for the ZIP archive - May be <code>null</code> or an empyt string. @param destFile Target ZIP file - Cannot be <code>null</code>. @throws IOException Error writing to the output stream.
[ "Creates", "a", "ZIP", "file", "and", "adds", "all", "files", "in", "a", "directory", "and", "all", "it", "s", "sub", "directories", "to", "the", "archive", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1404-L1408
145,402
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.readAsString
public static String readAsString(final URL url, final String encoding, final int bufSize) { try (final Reader reader = new InputStreamReader(url.openStream(), encoding)) { final StringBuilder sb = new StringBuilder(); final char[] cbuf = new char[bufSize]; int count; while ((count = reader.read(cbuf)) > -1) { sb.append(String.valueOf(cbuf, 0, count)); } return sb.toString(); } catch (final IOException ex) { throw new RuntimeException(ex); } }
java
public static String readAsString(final URL url, final String encoding, final int bufSize) { try (final Reader reader = new InputStreamReader(url.openStream(), encoding)) { final StringBuilder sb = new StringBuilder(); final char[] cbuf = new char[bufSize]; int count; while ((count = reader.read(cbuf)) > -1) { sb.append(String.valueOf(cbuf, 0, count)); } return sb.toString(); } catch (final IOException ex) { throw new RuntimeException(ex); } }
[ "public", "static", "String", "readAsString", "(", "final", "URL", "url", ",", "final", "String", "encoding", ",", "final", "int", "bufSize", ")", "{", "try", "(", "final", "Reader", "reader", "=", "new", "InputStreamReader", "(", "url", ".", "openStream", "(", ")", ",", "encoding", ")", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "final", "char", "[", "]", "cbuf", "=", "new", "char", "[", "bufSize", "]", ";", "int", "count", ";", "while", "(", "(", "count", "=", "reader", ".", "read", "(", "cbuf", ")", ")", ">", "-", "1", ")", "{", "sb", ".", "append", "(", "String", ".", "valueOf", "(", "cbuf", ",", "0", ",", "count", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}" ]
Reads a given URL and returns the content as String. @param url URL to read. @param encoding Encoding (like 'utf-8'). @param bufSize Size of the buffer to use. @return File content as String.
[ "Reads", "a", "given", "URL", "and", "returns", "the", "content", "as", "String", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1469-L1481
145,403
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.replaceCrLfTab
public static String replaceCrLfTab(final String str) { if (str == null) { return null; } final int len = str.length(); final StringBuilder sb = new StringBuilder(); int i = 0; while (i < len) { final char ch = str.charAt(i++); if (ch == '\\') { if (i < len) { final char next = str.charAt(i); final Character replacement = SPECIAL_CHAR_REPLACEMENT_MAP.get(next); if (replacement != null) { sb.append(replacement); i++; } else { sb.append(ch); } } else { sb.append(ch); } } else { sb.append(ch); } } return sb.toString(); }
java
public static String replaceCrLfTab(final String str) { if (str == null) { return null; } final int len = str.length(); final StringBuilder sb = new StringBuilder(); int i = 0; while (i < len) { final char ch = str.charAt(i++); if (ch == '\\') { if (i < len) { final char next = str.charAt(i); final Character replacement = SPECIAL_CHAR_REPLACEMENT_MAP.get(next); if (replacement != null) { sb.append(replacement); i++; } else { sb.append(ch); } } else { sb.append(ch); } } else { sb.append(ch); } } return sb.toString(); }
[ "public", "static", "String", "replaceCrLfTab", "(", "final", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "final", "int", "len", "=", "str", ".", "length", "(", ")", ";", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "i", "=", "0", ";", "while", "(", "i", "<", "len", ")", "{", "final", "char", "ch", "=", "str", ".", "charAt", "(", "i", "++", ")", ";", "if", "(", "ch", "==", "'", "'", ")", "{", "if", "(", "i", "<", "len", ")", "{", "final", "char", "next", "=", "str", ".", "charAt", "(", "i", ")", ";", "final", "Character", "replacement", "=", "SPECIAL_CHAR_REPLACEMENT_MAP", ".", "get", "(", "next", ")", ";", "if", "(", "replacement", "!=", "null", ")", "{", "sb", ".", "append", "(", "replacement", ")", ";", "i", "++", ";", "}", "else", "{", "sb", ".", "append", "(", "ch", ")", ";", "}", "}", "else", "{", "sb", ".", "append", "(", "ch", ")", ";", "}", "}", "else", "{", "sb", ".", "append", "(", "ch", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Replaces the strings "\r", "\n" and "\t" with "carriage return", "new line" and "tab" character. @param str String to replace or <code>null</code>. @return Replaced string or <code>null</code>.
[ "Replaces", "the", "strings", "\\", "r", "\\", "n", "and", "\\", "t", "with", "carriage", "return", "new", "line", "and", "tab", "character", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1513-L1540
145,404
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.expectedCause
public static boolean expectedCause(final Exception actualException, final Collection<Class<? extends Exception>> expectedExceptions) { checkNotNull("actualException", actualException); if (expectedExceptions == null || expectedExceptions.size() == 0) { // All exceptions are expected return true; } final Throwable cause = actualException.getCause(); if (!(cause instanceof Exception)) { // We're only interested in exceptions return false; } return expectedException((Exception) cause, expectedExceptions); }
java
public static boolean expectedCause(final Exception actualException, final Collection<Class<? extends Exception>> expectedExceptions) { checkNotNull("actualException", actualException); if (expectedExceptions == null || expectedExceptions.size() == 0) { // All exceptions are expected return true; } final Throwable cause = actualException.getCause(); if (!(cause instanceof Exception)) { // We're only interested in exceptions return false; } return expectedException((Exception) cause, expectedExceptions); }
[ "public", "static", "boolean", "expectedCause", "(", "final", "Exception", "actualException", ",", "final", "Collection", "<", "Class", "<", "?", "extends", "Exception", ">", ">", "expectedExceptions", ")", "{", "checkNotNull", "(", "\"actualException\"", ",", "actualException", ")", ";", "if", "(", "expectedExceptions", "==", "null", "||", "expectedExceptions", ".", "size", "(", ")", "==", "0", ")", "{", "// All exceptions are expected\r", "return", "true", ";", "}", "final", "Throwable", "cause", "=", "actualException", ".", "getCause", "(", ")", ";", "if", "(", "!", "(", "cause", "instanceof", "Exception", ")", ")", "{", "// We're only interested in exceptions\r", "return", "false", ";", "}", "return", "expectedException", "(", "(", "Exception", ")", "cause", ",", "expectedExceptions", ")", ";", "}" ]
Verifies if the cause of an exception is of a given type. @param actualException Actual exception that was caused by something else - Cannot be <code>null</code>. @param expectedExceptions Expected exceptions - May be <code>null</code> if any cause is expected. @return TRUE if the actual exception is one of the expected exceptions.
[ "Verifies", "if", "the", "cause", "of", "an", "exception", "is", "of", "a", "given", "type", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1568-L1585
145,405
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.expectedException
public static boolean expectedException(final Exception actualException, final Collection<Class<? extends Exception>> expectedExceptions) { checkNotNull("actualException", actualException); if (expectedExceptions == null || expectedExceptions.size() == 0) { // All exceptions are expected return true; } for (final Class<? extends Exception> expectedException : expectedExceptions) { if (expectedException.isAssignableFrom(actualException.getClass())) { return true; } } return false; }
java
public static boolean expectedException(final Exception actualException, final Collection<Class<? extends Exception>> expectedExceptions) { checkNotNull("actualException", actualException); if (expectedExceptions == null || expectedExceptions.size() == 0) { // All exceptions are expected return true; } for (final Class<? extends Exception> expectedException : expectedExceptions) { if (expectedException.isAssignableFrom(actualException.getClass())) { return true; } } return false; }
[ "public", "static", "boolean", "expectedException", "(", "final", "Exception", "actualException", ",", "final", "Collection", "<", "Class", "<", "?", "extends", "Exception", ">", ">", "expectedExceptions", ")", "{", "checkNotNull", "(", "\"actualException\"", ",", "actualException", ")", ";", "if", "(", "expectedExceptions", "==", "null", "||", "expectedExceptions", ".", "size", "(", ")", "==", "0", ")", "{", "// All exceptions are expected\r", "return", "true", ";", "}", "for", "(", "final", "Class", "<", "?", "extends", "Exception", ">", "expectedException", ":", "expectedExceptions", ")", "{", "if", "(", "expectedException", ".", "isAssignableFrom", "(", "actualException", ".", "getClass", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Verifies if an exception is of a given type. @param actualException Actual exception - Cannot be <code>null</code>. @param expectedExceptions Expected exceptions - May be <code>null</code> if any exception is expected. @return TRUE if the actual exception is one of the expected exceptions.
[ "Verifies", "if", "an", "exception", "is", "of", "a", "given", "type", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1597-L1615
145,406
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.jreFile
public static boolean jreFile(final File file) { final String javaHome = System.getProperty("java.home"); try { return file.getCanonicalPath().startsWith(javaHome) && file.isFile(); } catch (final IOException ex) { throw new RuntimeException("Error reading canonical path for: " + file, ex); } }
java
public static boolean jreFile(final File file) { final String javaHome = System.getProperty("java.home"); try { return file.getCanonicalPath().startsWith(javaHome) && file.isFile(); } catch (final IOException ex) { throw new RuntimeException("Error reading canonical path for: " + file, ex); } }
[ "public", "static", "boolean", "jreFile", "(", "final", "File", "file", ")", "{", "final", "String", "javaHome", "=", "System", ".", "getProperty", "(", "\"java.home\"", ")", ";", "try", "{", "return", "file", ".", "getCanonicalPath", "(", ")", ".", "startsWith", "(", "javaHome", ")", "&&", "file", ".", "isFile", "(", ")", ";", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error reading canonical path for: \"", "+", "file", ",", "ex", ")", ";", "}", "}" ]
Determines if the file is a file from the Java runtime and exists. @param file File to test. @return TRUE if the file is in the 'java.home' directory.
[ "Determines", "if", "the", "file", "is", "a", "file", "from", "the", "Java", "runtime", "and", "exists", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1625-L1632
145,407
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.classpathFiles
public static List<File> classpathFiles(final Predicate<File> predicate) { return pathsFiles(System.getProperty("java.class.path"), predicate); }
java
public static List<File> classpathFiles(final Predicate<File> predicate) { return pathsFiles(System.getProperty("java.class.path"), predicate); }
[ "public", "static", "List", "<", "File", ">", "classpathFiles", "(", "final", "Predicate", "<", "File", ">", "predicate", ")", "{", "return", "pathsFiles", "(", "System", ".", "getProperty", "(", "\"java.class.path\"", ")", ",", "predicate", ")", ";", "}" ]
Returns a list of files from the classpath. @param predicate Condition that returns files from the classpath. @return List of files in the classpath (from property "java.class.path").
[ "Returns", "a", "list", "of", "files", "from", "the", "classpath", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1690-L1693
145,408
fuinorg/utils4j
src/main/java/org/fuin/utils4j/Utils4J.java
Utils4J.pathsFiles
public static List<File> pathsFiles(final String paths, final Predicate<File> predicate) { final List<File> files = new ArrayList<File>(); for (final String filePathAndName : paths.split(File.pathSeparator)) { final File file = new File(filePathAndName); if (file.isDirectory()) { try (final Stream<Path> stream = Files.walk(file.toPath(), Integer.MAX_VALUE)) { stream.map(f -> f.toFile()).filter(predicate).forEach(files::add); } catch (final IOException ex) { throw new RuntimeException("Error walking path: " + file, ex); } } else { if (predicate.test(file)) { files.add(file); } } } return files; }
java
public static List<File> pathsFiles(final String paths, final Predicate<File> predicate) { final List<File> files = new ArrayList<File>(); for (final String filePathAndName : paths.split(File.pathSeparator)) { final File file = new File(filePathAndName); if (file.isDirectory()) { try (final Stream<Path> stream = Files.walk(file.toPath(), Integer.MAX_VALUE)) { stream.map(f -> f.toFile()).filter(predicate).forEach(files::add); } catch (final IOException ex) { throw new RuntimeException("Error walking path: " + file, ex); } } else { if (predicate.test(file)) { files.add(file); } } } return files; }
[ "public", "static", "List", "<", "File", ">", "pathsFiles", "(", "final", "String", "paths", ",", "final", "Predicate", "<", "File", ">", "predicate", ")", "{", "final", "List", "<", "File", ">", "files", "=", "new", "ArrayList", "<", "File", ">", "(", ")", ";", "for", "(", "final", "String", "filePathAndName", ":", "paths", ".", "split", "(", "File", ".", "pathSeparator", ")", ")", "{", "final", "File", "file", "=", "new", "File", "(", "filePathAndName", ")", ";", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "try", "(", "final", "Stream", "<", "Path", ">", "stream", "=", "Files", ".", "walk", "(", "file", ".", "toPath", "(", ")", ",", "Integer", ".", "MAX_VALUE", ")", ")", "{", "stream", ".", "map", "(", "f", "->", "f", ".", "toFile", "(", ")", ")", ".", "filter", "(", "predicate", ")", ".", "forEach", "(", "files", "::", "add", ")", ";", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error walking path: \"", "+", "file", ",", "ex", ")", ";", "}", "}", "else", "{", "if", "(", "predicate", ".", "test", "(", "file", ")", ")", "{", "files", ".", "add", "(", "file", ")", ";", "}", "}", "}", "return", "files", ";", "}" ]
Returns a list of files from all given paths. @param paths Paths to search (Paths separated by {@link File#pathSeparator}. @param predicate Condition for files to return. @return List of files in the given paths.
[ "Returns", "a", "list", "of", "files", "from", "all", "given", "paths", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L1705-L1722
145,409
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java
HTMLUtilities.inlineSvgNodes
private static void inlineSvgNodes(final Document doc, final String basePath) { try { // handle null inputs if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> nodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "object"); for (final Node node : nodes) { final NamedNodeMap attributes = node.getAttributes(); final Node typeAttribute = attributes.getNamedItem("type"); final Node dataAttribute = attributes.getNamedItem("data"); if (typeAttribute != null && typeAttribute.getTextContent().equals("image/svg+xml") && dataAttribute != null) { final String data = dataAttribute.getTextContent(); final File dataFile = new File(fixedBasePath + "/" + data); if (dataFile.exists()) { final String fileString = FileUtilities.readFileContents(dataFile); final Document svgDoc = XMLUtilities.convertStringToDocument(fileString); if (svgDoc != null) { final Element svgDocElement = svgDoc.getDocumentElement(); if (svgDocElement != null && svgDocElement.getNodeName().equals("svg")) { final Node parent = node.getParentNode(); if (parent != null) { final Node importedNode = doc.importNode(svgDocElement, true); parent.replaceChild(importedNode, node); } } } } } } } catch (final Exception ex) { LOG.error("Unable to convert external SVG image to DOM Document", ex); } }
java
private static void inlineSvgNodes(final Document doc, final String basePath) { try { // handle null inputs if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> nodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "object"); for (final Node node : nodes) { final NamedNodeMap attributes = node.getAttributes(); final Node typeAttribute = attributes.getNamedItem("type"); final Node dataAttribute = attributes.getNamedItem("data"); if (typeAttribute != null && typeAttribute.getTextContent().equals("image/svg+xml") && dataAttribute != null) { final String data = dataAttribute.getTextContent(); final File dataFile = new File(fixedBasePath + "/" + data); if (dataFile.exists()) { final String fileString = FileUtilities.readFileContents(dataFile); final Document svgDoc = XMLUtilities.convertStringToDocument(fileString); if (svgDoc != null) { final Element svgDocElement = svgDoc.getDocumentElement(); if (svgDocElement != null && svgDocElement.getNodeName().equals("svg")) { final Node parent = node.getParentNode(); if (parent != null) { final Node importedNode = doc.importNode(svgDocElement, true); parent.replaceChild(importedNode, node); } } } } } } } catch (final Exception ex) { LOG.error("Unable to convert external SVG image to DOM Document", ex); } }
[ "private", "static", "void", "inlineSvgNodes", "(", "final", "Document", "doc", ",", "final", "String", "basePath", ")", "{", "try", "{", "// handle null inputs", "if", "(", "doc", "==", "null", ")", "return", ";", "final", "String", "fixedBasePath", "=", "basePath", "==", "null", "?", "\"\"", ":", "basePath", ";", "final", "List", "<", "Node", ">", "nodes", "=", "XMLUtilities", ".", "getChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"object\"", ")", ";", "for", "(", "final", "Node", "node", ":", "nodes", ")", "{", "final", "NamedNodeMap", "attributes", "=", "node", ".", "getAttributes", "(", ")", ";", "final", "Node", "typeAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"type\"", ")", ";", "final", "Node", "dataAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"data\"", ")", ";", "if", "(", "typeAttribute", "!=", "null", "&&", "typeAttribute", ".", "getTextContent", "(", ")", ".", "equals", "(", "\"image/svg+xml\"", ")", "&&", "dataAttribute", "!=", "null", ")", "{", "final", "String", "data", "=", "dataAttribute", ".", "getTextContent", "(", ")", ";", "final", "File", "dataFile", "=", "new", "File", "(", "fixedBasePath", "+", "\"/\"", "+", "data", ")", ";", "if", "(", "dataFile", ".", "exists", "(", ")", ")", "{", "final", "String", "fileString", "=", "FileUtilities", ".", "readFileContents", "(", "dataFile", ")", ";", "final", "Document", "svgDoc", "=", "XMLUtilities", ".", "convertStringToDocument", "(", "fileString", ")", ";", "if", "(", "svgDoc", "!=", "null", ")", "{", "final", "Element", "svgDocElement", "=", "svgDoc", ".", "getDocumentElement", "(", ")", ";", "if", "(", "svgDocElement", "!=", "null", "&&", "svgDocElement", ".", "getNodeName", "(", ")", ".", "equals", "(", "\"svg\"", ")", ")", "{", "final", "Node", "parent", "=", "node", ".", "getParentNode", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "final", "Node", "importedNode", "=", "doc", ".", "importNode", "(", "svgDocElement", ",", "true", ")", ";", "parent", ".", "replaceChild", "(", "importedNode", ",", "node", ")", ";", "}", "}", "}", "}", "}", "}", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "LOG", ".", "error", "(", "\"Unable to convert external SVG image to DOM Document\"", ",", "ex", ")", ";", "}", "}" ]
Finds any reference to an external SVG image and replaces the node with the SVG inline data. @param doc The document that holds the XHTML @param basePath The base path where the SVG images can be found
[ "Finds", "any", "reference", "to", "an", "external", "SVG", "image", "and", "replaces", "the", "node", "with", "the", "SVG", "inline", "data", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java#L87-L124
145,410
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java
HTMLUtilities.inlineCssNodes
private static void inlineCssNodes(final Document doc, final String basePath) { if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> nodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "link"); for (final Node node : nodes) { final NamedNodeMap attributes = node.getAttributes(); final Node relAttribute = attributes.getNamedItem("rel"); final Node hrefAttribute = attributes.getNamedItem("href"); final Node mediaAttribute = attributes.getNamedItem("media"); if (relAttribute != null && relAttribute.getTextContent().equals("stylesheet") && hrefAttribute != null) { final String href = hrefAttribute.getTextContent(); final File hrefFile = new File(fixedBasePath + "/" + href); if (hrefFile.exists()) { // find the base path for any import statements that // might be in the css file String cssBasePath = ""; int end = href.lastIndexOf("/"); if (end == -1) end = href.lastIndexOf("\\"); if (end != -1) cssBasePath = href.substring(0, end); final String fileString = inlineCssImports(FileUtilities.readFileContents(hrefFile), basePath + "/" + cssBasePath); final Node parent = node.getParentNode(); if (parent != null) { final Element newNode = doc.createElement("style"); newNode.setAttribute("type", "text/css"); if (mediaAttribute != null) newNode.setAttribute("media", mediaAttribute.getTextContent()); newNode.setTextContent(fileString); parent.replaceChild(newNode, node); } } } } }
java
private static void inlineCssNodes(final Document doc, final String basePath) { if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> nodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "link"); for (final Node node : nodes) { final NamedNodeMap attributes = node.getAttributes(); final Node relAttribute = attributes.getNamedItem("rel"); final Node hrefAttribute = attributes.getNamedItem("href"); final Node mediaAttribute = attributes.getNamedItem("media"); if (relAttribute != null && relAttribute.getTextContent().equals("stylesheet") && hrefAttribute != null) { final String href = hrefAttribute.getTextContent(); final File hrefFile = new File(fixedBasePath + "/" + href); if (hrefFile.exists()) { // find the base path for any import statements that // might be in the css file String cssBasePath = ""; int end = href.lastIndexOf("/"); if (end == -1) end = href.lastIndexOf("\\"); if (end != -1) cssBasePath = href.substring(0, end); final String fileString = inlineCssImports(FileUtilities.readFileContents(hrefFile), basePath + "/" + cssBasePath); final Node parent = node.getParentNode(); if (parent != null) { final Element newNode = doc.createElement("style"); newNode.setAttribute("type", "text/css"); if (mediaAttribute != null) newNode.setAttribute("media", mediaAttribute.getTextContent()); newNode.setTextContent(fileString); parent.replaceChild(newNode, node); } } } } }
[ "private", "static", "void", "inlineCssNodes", "(", "final", "Document", "doc", ",", "final", "String", "basePath", ")", "{", "if", "(", "doc", "==", "null", ")", "return", ";", "final", "String", "fixedBasePath", "=", "basePath", "==", "null", "?", "\"\"", ":", "basePath", ";", "final", "List", "<", "Node", ">", "nodes", "=", "XMLUtilities", ".", "getChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"link\"", ")", ";", "for", "(", "final", "Node", "node", ":", "nodes", ")", "{", "final", "NamedNodeMap", "attributes", "=", "node", ".", "getAttributes", "(", ")", ";", "final", "Node", "relAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"rel\"", ")", ";", "final", "Node", "hrefAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"href\"", ")", ";", "final", "Node", "mediaAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"media\"", ")", ";", "if", "(", "relAttribute", "!=", "null", "&&", "relAttribute", ".", "getTextContent", "(", ")", ".", "equals", "(", "\"stylesheet\"", ")", "&&", "hrefAttribute", "!=", "null", ")", "{", "final", "String", "href", "=", "hrefAttribute", ".", "getTextContent", "(", ")", ";", "final", "File", "hrefFile", "=", "new", "File", "(", "fixedBasePath", "+", "\"/\"", "+", "href", ")", ";", "if", "(", "hrefFile", ".", "exists", "(", ")", ")", "{", "// find the base path for any import statements that", "// might be in the css file", "String", "cssBasePath", "=", "\"\"", ";", "int", "end", "=", "href", ".", "lastIndexOf", "(", "\"/\"", ")", ";", "if", "(", "end", "==", "-", "1", ")", "end", "=", "href", ".", "lastIndexOf", "(", "\"\\\\\"", ")", ";", "if", "(", "end", "!=", "-", "1", ")", "cssBasePath", "=", "href", ".", "substring", "(", "0", ",", "end", ")", ";", "final", "String", "fileString", "=", "inlineCssImports", "(", "FileUtilities", ".", "readFileContents", "(", "hrefFile", ")", ",", "basePath", "+", "\"/\"", "+", "cssBasePath", ")", ";", "final", "Node", "parent", "=", "node", ".", "getParentNode", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "final", "Element", "newNode", "=", "doc", ".", "createElement", "(", "\"style\"", ")", ";", "newNode", ".", "setAttribute", "(", "\"type\"", ",", "\"text/css\"", ")", ";", "if", "(", "mediaAttribute", "!=", "null", ")", "newNode", ".", "setAttribute", "(", "\"media\"", ",", "mediaAttribute", ".", "getTextContent", "(", ")", ")", ";", "newNode", ".", "setTextContent", "(", "fileString", ")", ";", "parent", ".", "replaceChild", "(", "newNode", ",", "node", ")", ";", "}", "}", "}", "}", "}" ]
Finds any reference to an external CSS scripts and replaces the node with inline CSS data. @param doc The document that holds the XHTML @param basePath The base path where the CSS scripts can be found
[ "Finds", "any", "reference", "to", "an", "external", "CSS", "scripts", "and", "replaces", "the", "node", "with", "inline", "CSS", "data", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java#L133-L173
145,411
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java
HTMLUtilities.inlineCssImports
private static String inlineCssImports(final String css, final String basePath) { String retValue = css; int start; while ((start = retValue.indexOf(CSS_IMPORT_START)) != -1) { int end = retValue.indexOf(CSS_IMPORT_END, start); if (end != -1) { final String filePath = retValue.substring(start + CSS_IMPORT_START.length(), end); final String fileData = FileUtilities.readFileContents(new File(basePath + "/" + filePath)); retValue = retValue.replace(CSS_IMPORT_START + filePath + CSS_IMPORT_END, fileData); } } return retValue; }
java
private static String inlineCssImports(final String css, final String basePath) { String retValue = css; int start; while ((start = retValue.indexOf(CSS_IMPORT_START)) != -1) { int end = retValue.indexOf(CSS_IMPORT_END, start); if (end != -1) { final String filePath = retValue.substring(start + CSS_IMPORT_START.length(), end); final String fileData = FileUtilities.readFileContents(new File(basePath + "/" + filePath)); retValue = retValue.replace(CSS_IMPORT_START + filePath + CSS_IMPORT_END, fileData); } } return retValue; }
[ "private", "static", "String", "inlineCssImports", "(", "final", "String", "css", ",", "final", "String", "basePath", ")", "{", "String", "retValue", "=", "css", ";", "int", "start", ";", "while", "(", "(", "start", "=", "retValue", ".", "indexOf", "(", "CSS_IMPORT_START", ")", ")", "!=", "-", "1", ")", "{", "int", "end", "=", "retValue", ".", "indexOf", "(", "CSS_IMPORT_END", ",", "start", ")", ";", "if", "(", "end", "!=", "-", "1", ")", "{", "final", "String", "filePath", "=", "retValue", ".", "substring", "(", "start", "+", "CSS_IMPORT_START", ".", "length", "(", ")", ",", "end", ")", ";", "final", "String", "fileData", "=", "FileUtilities", ".", "readFileContents", "(", "new", "File", "(", "basePath", "+", "\"/\"", "+", "filePath", ")", ")", ";", "retValue", "=", "retValue", ".", "replace", "(", "CSS_IMPORT_START", "+", "filePath", "+", "CSS_IMPORT_END", ",", "fileData", ")", ";", "}", "}", "return", "retValue", ";", "}" ]
Finds any reference to an external CSS scripts that themselves have been referenced in a CSS script using an import statement and replaces the node with inline CSS data. @param doc The document that holds the XHTML @param basePath The base path where the CSS scripts can be found
[ "Finds", "any", "reference", "to", "an", "external", "CSS", "scripts", "that", "themselves", "have", "been", "referenced", "in", "a", "CSS", "script", "using", "an", "import", "statement", "and", "replaces", "the", "node", "with", "inline", "CSS", "data", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java#L183-L196
145,412
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java
HTMLUtilities.inlineImgNodes
private static void inlineImgNodes(final Document doc, final String basePath) { // handle null inputs if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> imageNodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "img"); for (final Node node : imageNodes) { final NamedNodeMap attributes = node.getAttributes(); final Node srcAttribute = attributes.getNamedItem("src"); if (srcAttribute != null) { final String src = srcAttribute.getTextContent(); final File srcFile = new File(fixedBasePath + "/" + src); if (srcFile.exists()) { final byte[] srcFileByteArray = FileUtilities.readFileContentsAsByteArray(srcFile); if (srcFileByteArray != null) { // get the file extension of the original image final int extensionStringLocation = src.lastIndexOf("."); // make sure we have an extension if (extensionStringLocation != -1 && extensionStringLocation != src.length() - 1) { final String extension = src.substring(extensionStringLocation + 1); // encode the image final byte[] srcFileEncodedByteArray = Base64.encodeBase64(srcFileByteArray); final String srcFileEncodedString = new String(srcFileEncodedByteArray); final Node parent = node.getParentNode(); if (parent != null) { final Element newImgNode = doc.createElement("img"); newImgNode.setAttribute("src", "data:image/" + extension + ";base64," + srcFileEncodedString); parent.replaceChild(newImgNode, node); } } } } } } }
java
private static void inlineImgNodes(final Document doc, final String basePath) { // handle null inputs if (doc == null) return; final String fixedBasePath = basePath == null ? "" : basePath; final List<Node> imageNodes = XMLUtilities.getChildNodes(doc.getDocumentElement(), "img"); for (final Node node : imageNodes) { final NamedNodeMap attributes = node.getAttributes(); final Node srcAttribute = attributes.getNamedItem("src"); if (srcAttribute != null) { final String src = srcAttribute.getTextContent(); final File srcFile = new File(fixedBasePath + "/" + src); if (srcFile.exists()) { final byte[] srcFileByteArray = FileUtilities.readFileContentsAsByteArray(srcFile); if (srcFileByteArray != null) { // get the file extension of the original image final int extensionStringLocation = src.lastIndexOf("."); // make sure we have an extension if (extensionStringLocation != -1 && extensionStringLocation != src.length() - 1) { final String extension = src.substring(extensionStringLocation + 1); // encode the image final byte[] srcFileEncodedByteArray = Base64.encodeBase64(srcFileByteArray); final String srcFileEncodedString = new String(srcFileEncodedByteArray); final Node parent = node.getParentNode(); if (parent != null) { final Element newImgNode = doc.createElement("img"); newImgNode.setAttribute("src", "data:image/" + extension + ";base64," + srcFileEncodedString); parent.replaceChild(newImgNode, node); } } } } } } }
[ "private", "static", "void", "inlineImgNodes", "(", "final", "Document", "doc", ",", "final", "String", "basePath", ")", "{", "// handle null inputs", "if", "(", "doc", "==", "null", ")", "return", ";", "final", "String", "fixedBasePath", "=", "basePath", "==", "null", "?", "\"\"", ":", "basePath", ";", "final", "List", "<", "Node", ">", "imageNodes", "=", "XMLUtilities", ".", "getChildNodes", "(", "doc", ".", "getDocumentElement", "(", ")", ",", "\"img\"", ")", ";", "for", "(", "final", "Node", "node", ":", "imageNodes", ")", "{", "final", "NamedNodeMap", "attributes", "=", "node", ".", "getAttributes", "(", ")", ";", "final", "Node", "srcAttribute", "=", "attributes", ".", "getNamedItem", "(", "\"src\"", ")", ";", "if", "(", "srcAttribute", "!=", "null", ")", "{", "final", "String", "src", "=", "srcAttribute", ".", "getTextContent", "(", ")", ";", "final", "File", "srcFile", "=", "new", "File", "(", "fixedBasePath", "+", "\"/\"", "+", "src", ")", ";", "if", "(", "srcFile", ".", "exists", "(", ")", ")", "{", "final", "byte", "[", "]", "srcFileByteArray", "=", "FileUtilities", ".", "readFileContentsAsByteArray", "(", "srcFile", ")", ";", "if", "(", "srcFileByteArray", "!=", "null", ")", "{", "// get the file extension of the original image", "final", "int", "extensionStringLocation", "=", "src", ".", "lastIndexOf", "(", "\".\"", ")", ";", "// make sure we have an extension", "if", "(", "extensionStringLocation", "!=", "-", "1", "&&", "extensionStringLocation", "!=", "src", ".", "length", "(", ")", "-", "1", ")", "{", "final", "String", "extension", "=", "src", ".", "substring", "(", "extensionStringLocation", "+", "1", ")", ";", "// encode the image", "final", "byte", "[", "]", "srcFileEncodedByteArray", "=", "Base64", ".", "encodeBase64", "(", "srcFileByteArray", ")", ";", "final", "String", "srcFileEncodedString", "=", "new", "String", "(", "srcFileEncodedByteArray", ")", ";", "final", "Node", "parent", "=", "node", ".", "getParentNode", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "final", "Element", "newImgNode", "=", "doc", ".", "createElement", "(", "\"img\"", ")", ";", "newImgNode", ".", "setAttribute", "(", "\"src\"", ",", "\"data:image/\"", "+", "extension", "+", "\";base64,\"", "+", "srcFileEncodedString", ")", ";", "parent", ".", "replaceChild", "(", "newImgNode", ",", "node", ")", ";", "}", "}", "}", "}", "}", "}", "}" ]
Finds any reference to an external images and replaces them with inline base64 data @param doc The document that holds the XHTML @param basePath The base path where the images can be found
[ "Finds", "any", "reference", "to", "an", "external", "images", "and", "replaces", "them", "with", "inline", "base64", "data" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/HTMLUtilities.java#L205-L244
145,413
rwl/JKLU
src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java
Dklu_kernel.dfs
public static int dfs(int j, int k, int[] Pinv, int[] Llen, int Llen_offset, int[] Lip, int Lip_offset, int[] Stack, int[] Flag, int[] Lpend, int top, double[] LU, double[] Lik, int Lik_offset, int[] plength, int[] Ap_pos) { int i, pos, jnew, head, l_length; /*int[]*/double[] Li; l_length = plength [0] ; head = 0 ; Stack [0] = j ; ASSERT (Flag [j] != k) ; while (head >= 0) { j = Stack [head] ; jnew = Pinv [j] ; ASSERT (jnew >= 0 && jnew < k) ; /* j is pivotal */ if (Flag [j] != k) /* a node is not yet visited */ { /* first time that j has been visited */ Flag [j] = k ; PRINTF ("[ start dfs at %d : new %d\n", j, jnew) ; /* set Ap_pos [head] to one past the last entry in col j to scan */ Ap_pos [head] = (Lpend [jnew] == EMPTY) ? Llen [Llen_offset + jnew] : Lpend [jnew] ; } /* add the adjacent nodes to the recursive stack by iterating through * until finding another non-visited pivotal node */ Li = LU ; int Li_offset = Lip [Lip_offset + jnew] ; for (pos = --Ap_pos [head] ; pos >= 0 ; --pos) { i = (int) Li [Li_offset + pos] ; if (Flag [i] != k) { /* node i is not yet visited */ if (Pinv [i] >= 0) { /* keep track of where we left off in the scan of the * adjacency list of node j so we can restart j where we * left off. */ Ap_pos [head] = pos ; /* node i is pivotal; push it onto the recursive stack * and immediately break so we can recurse on node i. */ Stack [++head] = i ; break ; } else { /* node i is not pivotal (no outgoing edges). */ /* Flag as visited and store directly into L, * and continue with current node j. */ Flag [i] = k ; Lik [Lik_offset + l_length] = i ; l_length++ ; } } } if (pos == -1) { /* if all adjacent nodes of j are already visited, pop j from * recursive stack and push j onto output stack */ head-- ; Stack[--top] = j ; PRINTF (" end dfs at %d ] head : %d\n", j, head) ; } } plength[0] = l_length ; return (top) ; }
java
public static int dfs(int j, int k, int[] Pinv, int[] Llen, int Llen_offset, int[] Lip, int Lip_offset, int[] Stack, int[] Flag, int[] Lpend, int top, double[] LU, double[] Lik, int Lik_offset, int[] plength, int[] Ap_pos) { int i, pos, jnew, head, l_length; /*int[]*/double[] Li; l_length = plength [0] ; head = 0 ; Stack [0] = j ; ASSERT (Flag [j] != k) ; while (head >= 0) { j = Stack [head] ; jnew = Pinv [j] ; ASSERT (jnew >= 0 && jnew < k) ; /* j is pivotal */ if (Flag [j] != k) /* a node is not yet visited */ { /* first time that j has been visited */ Flag [j] = k ; PRINTF ("[ start dfs at %d : new %d\n", j, jnew) ; /* set Ap_pos [head] to one past the last entry in col j to scan */ Ap_pos [head] = (Lpend [jnew] == EMPTY) ? Llen [Llen_offset + jnew] : Lpend [jnew] ; } /* add the adjacent nodes to the recursive stack by iterating through * until finding another non-visited pivotal node */ Li = LU ; int Li_offset = Lip [Lip_offset + jnew] ; for (pos = --Ap_pos [head] ; pos >= 0 ; --pos) { i = (int) Li [Li_offset + pos] ; if (Flag [i] != k) { /* node i is not yet visited */ if (Pinv [i] >= 0) { /* keep track of where we left off in the scan of the * adjacency list of node j so we can restart j where we * left off. */ Ap_pos [head] = pos ; /* node i is pivotal; push it onto the recursive stack * and immediately break so we can recurse on node i. */ Stack [++head] = i ; break ; } else { /* node i is not pivotal (no outgoing edges). */ /* Flag as visited and store directly into L, * and continue with current node j. */ Flag [i] = k ; Lik [Lik_offset + l_length] = i ; l_length++ ; } } } if (pos == -1) { /* if all adjacent nodes of j are already visited, pop j from * recursive stack and push j onto output stack */ head-- ; Stack[--top] = j ; PRINTF (" end dfs at %d ] head : %d\n", j, head) ; } } plength[0] = l_length ; return (top) ; }
[ "public", "static", "int", "dfs", "(", "int", "j", ",", "int", "k", ",", "int", "[", "]", "Pinv", ",", "int", "[", "]", "Llen", ",", "int", "Llen_offset", ",", "int", "[", "]", "Lip", ",", "int", "Lip_offset", ",", "int", "[", "]", "Stack", ",", "int", "[", "]", "Flag", ",", "int", "[", "]", "Lpend", ",", "int", "top", ",", "double", "[", "]", "LU", ",", "double", "[", "]", "Lik", ",", "int", "Lik_offset", ",", "int", "[", "]", "plength", ",", "int", "[", "]", "Ap_pos", ")", "{", "int", "i", ",", "pos", ",", "jnew", ",", "head", ",", "l_length", ";", "/*int[]*/", "double", "[", "]", "Li", ";", "l_length", "=", "plength", "[", "0", "]", ";", "head", "=", "0", ";", "Stack", "[", "0", "]", "=", "j", ";", "ASSERT", "(", "Flag", "[", "j", "]", "!=", "k", ")", ";", "while", "(", "head", ">=", "0", ")", "{", "j", "=", "Stack", "[", "head", "]", ";", "jnew", "=", "Pinv", "[", "j", "]", ";", "ASSERT", "(", "jnew", ">=", "0", "&&", "jnew", "<", "k", ")", ";", "/* j is pivotal */", "if", "(", "Flag", "[", "j", "]", "!=", "k", ")", "/* a node is not yet visited */", "{", "/* first time that j has been visited */", "Flag", "[", "j", "]", "=", "k", ";", "PRINTF", "(", "\"[ start dfs at %d : new %d\\n\"", ",", "j", ",", "jnew", ")", ";", "/* set Ap_pos [head] to one past the last entry in col j to scan */", "Ap_pos", "[", "head", "]", "=", "(", "Lpend", "[", "jnew", "]", "==", "EMPTY", ")", "?", "Llen", "[", "Llen_offset", "+", "jnew", "]", ":", "Lpend", "[", "jnew", "]", ";", "}", "/* add the adjacent nodes to the recursive stack by iterating through\n\t\t\t * until finding another non-visited pivotal node */", "Li", "=", "LU", ";", "int", "Li_offset", "=", "Lip", "[", "Lip_offset", "+", "jnew", "]", ";", "for", "(", "pos", "=", "--", "Ap_pos", "[", "head", "]", ";", "pos", ">=", "0", ";", "--", "pos", ")", "{", "i", "=", "(", "int", ")", "Li", "[", "Li_offset", "+", "pos", "]", ";", "if", "(", "Flag", "[", "i", "]", "!=", "k", ")", "{", "/* node i is not yet visited */", "if", "(", "Pinv", "[", "i", "]", ">=", "0", ")", "{", "/* keep track of where we left off in the scan of the\n\t\t\t\t\t\t * adjacency list of node j so we can restart j where we\n\t\t\t\t\t\t * left off. */", "Ap_pos", "[", "head", "]", "=", "pos", ";", "/* node i is pivotal; push it onto the recursive stack\n\t\t\t\t\t\t * and immediately break so we can recurse on node i. */", "Stack", "[", "++", "head", "]", "=", "i", ";", "break", ";", "}", "else", "{", "/* node i is not pivotal (no outgoing edges). */", "/* Flag as visited and store directly into L,\n\t\t\t\t\t\t * and continue with current node j. */", "Flag", "[", "i", "]", "=", "k", ";", "Lik", "[", "Lik_offset", "+", "l_length", "]", "=", "i", ";", "l_length", "++", ";", "}", "}", "}", "if", "(", "pos", "==", "-", "1", ")", "{", "/* if all adjacent nodes of j are already visited, pop j from\n\t\t\t\t * recursive stack and push j onto output stack */", "head", "--", ";", "Stack", "[", "--", "top", "]", "=", "j", ";", "PRINTF", "(", "\" end dfs at %d ] head : %d\\n\"", ",", "j", ",", "head", ")", ";", "}", "}", "plength", "[", "0", "]", "=", "l_length", ";", "return", "(", "top", ")", ";", "}" ]
Does a depth-first-search, starting at node j. @param j node at which to start the DFS @param k mark value, for the Flag array @param Pinv Pinv[i] = k if row i is kth pivot row, or EMPTY if row i is not yet pivotal. @param Llen size n, Llen[k] = # nonzeros in column k of L @param Lip size n, Lip[k] is position in LU of column k of L @param Stack size n @param Flag Flag[i] == k means i is marked @param Lpend for symmetric pruning @param top top of stack on input @param LU @param Lik Li row index array of the kth column @param plength @param Ap_pos keeps track of position in adj list during DFS @return
[ "Does", "a", "depth", "-", "first", "-", "search", "starting", "at", "node", "j", "." ]
4e5fcdfb479040be72b4642ff1682670142b4892
https://github.com/rwl/JKLU/blob/4e5fcdfb479040be72b4642ff1682670142b4892/src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java#L57-L133
145,414
rwl/JKLU
src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java
Dklu_kernel.lsolve_symbolic
public static int lsolve_symbolic(int n, int k, int[] Ap, int[] Ai, int[] Q, int[] Pinv, int[] Stack, int[] Flag, int[] Lpend, int[] Ap_pos, double[] LU, int lup, int[] Llen, int Llen_offset, int[] Lip, int Lip_offset, int k1, int[] PSinv) { /*int[]*/double[] Lik; int i, p, pend, oldcol, kglobal, top ; int[] l_length; top = n ; l_length = new int[] {0} ; Lik = LU ; int Lik_offset = lup ; /* ---------------------------------------------------------------------- */ /* BTF factorization of A (k1:k2-1, k1:k2-1) */ /* ---------------------------------------------------------------------- */ kglobal = k + k1 ; /* column k of the block is col kglobal of A */ oldcol = Q [kglobal] ; /* Q must be present for BTF case */ pend = Ap [oldcol+1] ; for (p = Ap [oldcol] ; p < pend ; p++) { i = PSinv [Ai [p]] - k1 ; if (i < 0) continue ; /* skip entry outside the block */ /* (i,k) is an entry in the block. start a DFS at node i */ PRINTF ("\n ===== DFS at node %d in b, inew: %d\n", i, Pinv [i]) ; if (Flag [i] != k) { if (Pinv [i] >= 0) { top = dfs (i, k, Pinv, Llen, Llen_offset, Lip, Lip_offset, Stack, Flag, Lpend, top, LU, Lik, Lik_offset, l_length, Ap_pos) ; } else { /* i is not pivotal, and not flagged. Flag and put in L */ Flag [i] = k ; Lik [Lik_offset + l_length[0]] = i ; l_length[0]++; } } } /* If Llen [k] is zero, the matrix is structurally singular */ Llen [Llen_offset + k] = l_length[0] ; return (top) ; }
java
public static int lsolve_symbolic(int n, int k, int[] Ap, int[] Ai, int[] Q, int[] Pinv, int[] Stack, int[] Flag, int[] Lpend, int[] Ap_pos, double[] LU, int lup, int[] Llen, int Llen_offset, int[] Lip, int Lip_offset, int k1, int[] PSinv) { /*int[]*/double[] Lik; int i, p, pend, oldcol, kglobal, top ; int[] l_length; top = n ; l_length = new int[] {0} ; Lik = LU ; int Lik_offset = lup ; /* ---------------------------------------------------------------------- */ /* BTF factorization of A (k1:k2-1, k1:k2-1) */ /* ---------------------------------------------------------------------- */ kglobal = k + k1 ; /* column k of the block is col kglobal of A */ oldcol = Q [kglobal] ; /* Q must be present for BTF case */ pend = Ap [oldcol+1] ; for (p = Ap [oldcol] ; p < pend ; p++) { i = PSinv [Ai [p]] - k1 ; if (i < 0) continue ; /* skip entry outside the block */ /* (i,k) is an entry in the block. start a DFS at node i */ PRINTF ("\n ===== DFS at node %d in b, inew: %d\n", i, Pinv [i]) ; if (Flag [i] != k) { if (Pinv [i] >= 0) { top = dfs (i, k, Pinv, Llen, Llen_offset, Lip, Lip_offset, Stack, Flag, Lpend, top, LU, Lik, Lik_offset, l_length, Ap_pos) ; } else { /* i is not pivotal, and not flagged. Flag and put in L */ Flag [i] = k ; Lik [Lik_offset + l_length[0]] = i ; l_length[0]++; } } } /* If Llen [k] is zero, the matrix is structurally singular */ Llen [Llen_offset + k] = l_length[0] ; return (top) ; }
[ "public", "static", "int", "lsolve_symbolic", "(", "int", "n", ",", "int", "k", ",", "int", "[", "]", "Ap", ",", "int", "[", "]", "Ai", ",", "int", "[", "]", "Q", ",", "int", "[", "]", "Pinv", ",", "int", "[", "]", "Stack", ",", "int", "[", "]", "Flag", ",", "int", "[", "]", "Lpend", ",", "int", "[", "]", "Ap_pos", ",", "double", "[", "]", "LU", ",", "int", "lup", ",", "int", "[", "]", "Llen", ",", "int", "Llen_offset", ",", "int", "[", "]", "Lip", ",", "int", "Lip_offset", ",", "int", "k1", ",", "int", "[", "]", "PSinv", ")", "{", "/*int[]*/", "double", "[", "]", "Lik", ";", "int", "i", ",", "p", ",", "pend", ",", "oldcol", ",", "kglobal", ",", "top", ";", "int", "[", "]", "l_length", ";", "top", "=", "n", ";", "l_length", "=", "new", "int", "[", "]", "{", "0", "}", ";", "Lik", "=", "LU", ";", "int", "Lik_offset", "=", "lup", ";", "/* ---------------------------------------------------------------------- */", "/* BTF factorization of A (k1:k2-1, k1:k2-1) */", "/* ---------------------------------------------------------------------- */", "kglobal", "=", "k", "+", "k1", ";", "/* column k of the block is col kglobal of A */", "oldcol", "=", "Q", "[", "kglobal", "]", ";", "/* Q must be present for BTF case */", "pend", "=", "Ap", "[", "oldcol", "+", "1", "]", ";", "for", "(", "p", "=", "Ap", "[", "oldcol", "]", ";", "p", "<", "pend", ";", "p", "++", ")", "{", "i", "=", "PSinv", "[", "Ai", "[", "p", "]", "]", "-", "k1", ";", "if", "(", "i", "<", "0", ")", "continue", ";", "/* skip entry outside the block */", "/* (i,k) is an entry in the block. start a DFS at node i */", "PRINTF", "(", "\"\\n ===== DFS at node %d in b, inew: %d\\n\"", ",", "i", ",", "Pinv", "[", "i", "]", ")", ";", "if", "(", "Flag", "[", "i", "]", "!=", "k", ")", "{", "if", "(", "Pinv", "[", "i", "]", ">=", "0", ")", "{", "top", "=", "dfs", "(", "i", ",", "k", ",", "Pinv", ",", "Llen", ",", "Llen_offset", ",", "Lip", ",", "Lip_offset", ",", "Stack", ",", "Flag", ",", "Lpend", ",", "top", ",", "LU", ",", "Lik", ",", "Lik_offset", ",", "l_length", ",", "Ap_pos", ")", ";", "}", "else", "{", "/* i is not pivotal, and not flagged. Flag and put in L */", "Flag", "[", "i", "]", "=", "k", ";", "Lik", "[", "Lik_offset", "+", "l_length", "[", "0", "]", "]", "=", "i", ";", "l_length", "[", "0", "]", "++", ";", "}", "}", "}", "/* If Llen [k] is zero, the matrix is structurally singular */", "Llen", "[", "Llen_offset", "+", "k", "]", "=", "l_length", "[", "0", "]", ";", "return", "(", "top", ")", ";", "}" ]
Finds the pattern of x, for the solution of Lx=b. @param n L is n-by-n, where n >= 0 @param k also used as the mark value, for the Flag array @param Ap @param Ai @param Q @param Pinv Pinv[i] = k if i is kth pivot row, or EMPTY if row i is not yet pivotal. @param Stack size n @param Flag size n. Initially, all of Flag[0..n-1] < k. After lsolve_symbolicis done, Flag[i] == k if i is in the pattern of the output, and Flag[0..n-1] <= k. @param Lpend for symmetric pruning @param Ap_pos workspace used in dfs @param LU LU factors (pattern and values) @param lup pointer to free space in LU @param Llen size n, Llen[k] = # nonzeros in column k of L @param Lip size n, Lip[k] is position in LU of column k of L @param k1 the block of A is from k1 to k2-1 @param PSinv inverse of P from symbolic factorization @return
[ "Finds", "the", "pattern", "of", "x", "for", "the", "solution", "of", "Lx", "=", "b", "." ]
4e5fcdfb479040be72b4642ff1682670142b4892
https://github.com/rwl/JKLU/blob/4e5fcdfb479040be72b4642ff1682670142b4892/src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java#L159-L208
145,415
rwl/JKLU
src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java
Dklu_kernel.construct_column
public static void construct_column(int k, int[] Ap, int[] Ai, double[] Ax, int[] Q, double[] X, int k1, int[] PSinv, double[] Rs, int scale, int[] Offp, int[] Offi, double[] Offx) { double aik ; int i, p, pend, oldcol, kglobal, poff, oldrow ; /* ---------------------------------------------------------------------- */ /* Scale and scatter the column into X. */ /* ---------------------------------------------------------------------- */ kglobal = k + k1 ; /* column k of the block is col kglobal of A */ poff = Offp [kglobal] ; /* start of off-diagonal column */ oldcol = Q [kglobal] ; pend = Ap [oldcol+1] ; if (scale <= 0) { /* no scaling */ for (p = Ap [oldcol] ; p < pend ; p++) { oldrow = Ai [p] ; i = PSinv [oldrow] - k1 ; aik = Ax [p] ; if (i < 0) { /* this is an entry in the off-diagonal part */ Offi [poff] = oldrow ; Offx [poff] = aik ; poff++ ; } else { /* (i,k) is an entry in the block. scatter into X */ X [i] = aik ; } } } else { /* row scaling */ for (p = Ap [oldcol] ; p < pend ; p++) { oldrow = Ai [p] ; i = PSinv [oldrow] - k1 ; aik = Ax [p] ; aik = SCALE_DIV (aik, Rs [oldrow]) ; if (i < 0) { /* this is an entry in the off-diagonal part */ Offi [poff] = oldrow ; Offx [poff] = aik ; poff++ ; } else { /* (i,k) is an entry in the block. scatter into X */ X [i] = aik ; } } } Offp [kglobal+1] = poff ; /* start of the next col of off-diag part */ }
java
public static void construct_column(int k, int[] Ap, int[] Ai, double[] Ax, int[] Q, double[] X, int k1, int[] PSinv, double[] Rs, int scale, int[] Offp, int[] Offi, double[] Offx) { double aik ; int i, p, pend, oldcol, kglobal, poff, oldrow ; /* ---------------------------------------------------------------------- */ /* Scale and scatter the column into X. */ /* ---------------------------------------------------------------------- */ kglobal = k + k1 ; /* column k of the block is col kglobal of A */ poff = Offp [kglobal] ; /* start of off-diagonal column */ oldcol = Q [kglobal] ; pend = Ap [oldcol+1] ; if (scale <= 0) { /* no scaling */ for (p = Ap [oldcol] ; p < pend ; p++) { oldrow = Ai [p] ; i = PSinv [oldrow] - k1 ; aik = Ax [p] ; if (i < 0) { /* this is an entry in the off-diagonal part */ Offi [poff] = oldrow ; Offx [poff] = aik ; poff++ ; } else { /* (i,k) is an entry in the block. scatter into X */ X [i] = aik ; } } } else { /* row scaling */ for (p = Ap [oldcol] ; p < pend ; p++) { oldrow = Ai [p] ; i = PSinv [oldrow] - k1 ; aik = Ax [p] ; aik = SCALE_DIV (aik, Rs [oldrow]) ; if (i < 0) { /* this is an entry in the off-diagonal part */ Offi [poff] = oldrow ; Offx [poff] = aik ; poff++ ; } else { /* (i,k) is an entry in the block. scatter into X */ X [i] = aik ; } } } Offp [kglobal+1] = poff ; /* start of the next col of off-diag part */ }
[ "public", "static", "void", "construct_column", "(", "int", "k", ",", "int", "[", "]", "Ap", ",", "int", "[", "]", "Ai", ",", "double", "[", "]", "Ax", ",", "int", "[", "]", "Q", ",", "double", "[", "]", "X", ",", "int", "k1", ",", "int", "[", "]", "PSinv", ",", "double", "[", "]", "Rs", ",", "int", "scale", ",", "int", "[", "]", "Offp", ",", "int", "[", "]", "Offi", ",", "double", "[", "]", "Offx", ")", "{", "double", "aik", ";", "int", "i", ",", "p", ",", "pend", ",", "oldcol", ",", "kglobal", ",", "poff", ",", "oldrow", ";", "/* ---------------------------------------------------------------------- */", "/* Scale and scatter the column into X. */", "/* ---------------------------------------------------------------------- */", "kglobal", "=", "k", "+", "k1", ";", "/* column k of the block is col kglobal of A */", "poff", "=", "Offp", "[", "kglobal", "]", ";", "/* start of off-diagonal column */", "oldcol", "=", "Q", "[", "kglobal", "]", ";", "pend", "=", "Ap", "[", "oldcol", "+", "1", "]", ";", "if", "(", "scale", "<=", "0", ")", "{", "/* no scaling */", "for", "(", "p", "=", "Ap", "[", "oldcol", "]", ";", "p", "<", "pend", ";", "p", "++", ")", "{", "oldrow", "=", "Ai", "[", "p", "]", ";", "i", "=", "PSinv", "[", "oldrow", "]", "-", "k1", ";", "aik", "=", "Ax", "[", "p", "]", ";", "if", "(", "i", "<", "0", ")", "{", "/* this is an entry in the off-diagonal part */", "Offi", "[", "poff", "]", "=", "oldrow", ";", "Offx", "[", "poff", "]", "=", "aik", ";", "poff", "++", ";", "}", "else", "{", "/* (i,k) is an entry in the block. scatter into X */", "X", "[", "i", "]", "=", "aik", ";", "}", "}", "}", "else", "{", "/* row scaling */", "for", "(", "p", "=", "Ap", "[", "oldcol", "]", ";", "p", "<", "pend", ";", "p", "++", ")", "{", "oldrow", "=", "Ai", "[", "p", "]", ";", "i", "=", "PSinv", "[", "oldrow", "]", "-", "k1", ";", "aik", "=", "Ax", "[", "p", "]", ";", "aik", "=", "SCALE_DIV", "(", "aik", ",", "Rs", "[", "oldrow", "]", ")", ";", "if", "(", "i", "<", "0", ")", "{", "/* this is an entry in the off-diagonal part */", "Offi", "[", "poff", "]", "=", "oldrow", ";", "Offx", "[", "poff", "]", "=", "aik", ";", "poff", "++", ";", "}", "else", "{", "/* (i,k) is an entry in the block. scatter into X */", "X", "[", "i", "]", "=", "aik", ";", "}", "}", "}", "Offp", "[", "kglobal", "+", "1", "]", "=", "poff", ";", "/* start of the next col of off-diag part */", "}" ]
Construct the kth column of A, and the off-diagonal part, if requested. Scatter the numerical values into the workspace X, and construct the corresponding column of the off-diagonal matrix. @param k the column of A (or the column of the block) to get @param Ap @param Ai @param Ax @param Q column pre-ordering @param X @param k1 the block of A is from k1 to k2-1 @param PSinv inverse of P from symbolic factorization @param Rs scale factors for A @param scale 0: no scaling, nonzero: scale the rows with Rs @param Offp off-diagonal matrix (modified by this routine) @param Offi @param Offx
[ "Construct", "the", "kth", "column", "of", "A", "and", "the", "off", "-", "diagonal", "part", "if", "requested", ".", "Scatter", "the", "numerical", "values", "into", "the", "workspace", "X", "and", "construct", "the", "corresponding", "column", "of", "the", "off", "-", "diagonal", "matrix", "." ]
4e5fcdfb479040be72b4642ff1682670142b4892
https://github.com/rwl/JKLU/blob/4e5fcdfb479040be72b4642ff1682670142b4892/src/main/java/edu/ufl/cise/klu/tdouble/Dklu_kernel.java#L229-L292
145,416
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java
FileUtilities.getFileExtension
public static String getFileExtension(final String fileName) { if (fileName == null) return null; final int lastPeriodIndex = fileName.lastIndexOf("."); // make sure there is an extension, and that the filename doesn't end with a period if (lastPeriodIndex != -1 && lastPeriodIndex < fileName.length() - 1) { final String extension = fileName.substring(lastPeriodIndex + 1); return extension; } return null; }
java
public static String getFileExtension(final String fileName) { if (fileName == null) return null; final int lastPeriodIndex = fileName.lastIndexOf("."); // make sure there is an extension, and that the filename doesn't end with a period if (lastPeriodIndex != -1 && lastPeriodIndex < fileName.length() - 1) { final String extension = fileName.substring(lastPeriodIndex + 1); return extension; } return null; }
[ "public", "static", "String", "getFileExtension", "(", "final", "String", "fileName", ")", "{", "if", "(", "fileName", "==", "null", ")", "return", "null", ";", "final", "int", "lastPeriodIndex", "=", "fileName", ".", "lastIndexOf", "(", "\".\"", ")", ";", "// make sure there is an extension, and that the filename doesn't end with a period\r", "if", "(", "lastPeriodIndex", "!=", "-", "1", "&&", "lastPeriodIndex", "<", "fileName", ".", "length", "(", ")", "-", "1", ")", "{", "final", "String", "extension", "=", "fileName", ".", "substring", "(", "lastPeriodIndex", "+", "1", ")", ";", "return", "extension", ";", "}", "return", "null", ";", "}" ]
Gets the extension for a file. @param fileName The name of the file. eg Image.jpg @return The filename extension for the file if it has one, otherwise null.
[ "Gets", "the", "extension", "for", "a", "file", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java#L117-L128
145,417
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java
FileUtilities.openFile
public static void openFile(final File file) throws IOException { // Check that the file is a file if (!file.isFile()) throw new IOException("Passed file is not a file."); // Check that the Desktop API is supported if (!Desktop.isDesktopSupported()) { throw new IllegalStateException("Desktop is not supported"); } final Desktop desktop = Desktop.getDesktop(); // Check that the open functionality is supported if (!desktop.isSupported(Desktop.Action.OPEN)) { throw new IllegalStateException("Desktop doesn't support the open action"); } // Open the file desktop.open(file); }
java
public static void openFile(final File file) throws IOException { // Check that the file is a file if (!file.isFile()) throw new IOException("Passed file is not a file."); // Check that the Desktop API is supported if (!Desktop.isDesktopSupported()) { throw new IllegalStateException("Desktop is not supported"); } final Desktop desktop = Desktop.getDesktop(); // Check that the open functionality is supported if (!desktop.isSupported(Desktop.Action.OPEN)) { throw new IllegalStateException("Desktop doesn't support the open action"); } // Open the file desktop.open(file); }
[ "public", "static", "void", "openFile", "(", "final", "File", "file", ")", "throws", "IOException", "{", "// Check that the file is a file\r", "if", "(", "!", "file", ".", "isFile", "(", ")", ")", "throw", "new", "IOException", "(", "\"Passed file is not a file.\"", ")", ";", "// Check that the Desktop API is supported\r", "if", "(", "!", "Desktop", ".", "isDesktopSupported", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Desktop is not supported\"", ")", ";", "}", "final", "Desktop", "desktop", "=", "Desktop", ".", "getDesktop", "(", ")", ";", "// Check that the open functionality is supported\r", "if", "(", "!", "desktop", ".", "isSupported", "(", "Desktop", ".", "Action", ".", "OPEN", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Desktop doesn't support the open action\"", ")", ";", "}", "// Open the file\r", "desktop", ".", "open", "(", "file", ")", ";", "}" ]
Opens a file using the OS default program for the file type, using the Java Desktop API. @param file The file to be opened. @throws IOException Thrown if there is an issue opening the file. @throws IllegalStateException Thrown if the Desktop API isn't supported.
[ "Opens", "a", "file", "using", "the", "OS", "default", "program", "for", "the", "file", "type", "using", "the", "Java", "Desktop", "API", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java#L223-L241
145,418
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java
FileUtilities.saveFile
public static void saveFile(final File file, final String contents, final String encoding) throws IOException { saveFile(file, contents.getBytes(encoding)); }
java
public static void saveFile(final File file, final String contents, final String encoding) throws IOException { saveFile(file, contents.getBytes(encoding)); }
[ "public", "static", "void", "saveFile", "(", "final", "File", "file", ",", "final", "String", "contents", ",", "final", "String", "encoding", ")", "throws", "IOException", "{", "saveFile", "(", "file", ",", "contents", ".", "getBytes", "(", "encoding", ")", ")", ";", "}" ]
Save the data, represented as a String to a file @param file The location/name of the file to be saved. @param contents The data that is to be written to the file. @throws IOException
[ "Save", "the", "data", "represented", "as", "a", "String", "to", "a", "file" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java#L250-L252
145,419
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java
FileUtilities.saveFile
public static void saveFile(final File file, byte[] fileContents) throws IOException { if (file.isDirectory()) { throw new IOException("Unable to save file contents as a directory."); } final FileOutputStream fos = new FileOutputStream(file); fos.write(fileContents); fos.flush(); fos.close(); }
java
public static void saveFile(final File file, byte[] fileContents) throws IOException { if (file.isDirectory()) { throw new IOException("Unable to save file contents as a directory."); } final FileOutputStream fos = new FileOutputStream(file); fos.write(fileContents); fos.flush(); fos.close(); }
[ "public", "static", "void", "saveFile", "(", "final", "File", "file", ",", "byte", "[", "]", "fileContents", ")", "throws", "IOException", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"Unable to save file contents as a directory.\"", ")", ";", "}", "final", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "file", ")", ";", "fos", ".", "write", "(", "fileContents", ")", ";", "fos", ".", "flush", "(", ")", ";", "fos", ".", "close", "(", ")", ";", "}" ]
Save the data, represented as a byte array to a file @param file The location/name of the file to be saved. @param fileContents The data that is to be written to the file. @throws IOException
[ "Save", "the", "data", "represented", "as", "a", "byte", "array", "to", "a", "file" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/FileUtilities.java#L261-L270
145,420
rwl/JKLU
src/main/java/edu/ufl/cise/klu/tdouble/Dklu_defaults.java
Dklu_defaults.klu_defaults
public static int klu_defaults(KLU_common Common) { if (Common == null) { return (FALSE) ; } /* parameters */ Common.tol = 0.001 ; /* pivot tolerance for diagonal */ Common.memgrow = 1.2 ; /* realloc size ratio increase for LU factors */ Common.initmem_amd = 1.2 ; /* init. mem with AMD: c*nnz(L) + n */ Common.initmem = 10 ; /* init. mem otherwise: c*nnz(A) + n */ Common.btf = TRUE ; /* use BTF pre-ordering, or not */ Common.maxwork = 0 ; /* no limit to work done by btf_order */ Common.ordering = 0 ; /* 0: AMD, 1: COLAMD, 2: user-provided P and Q, * 3: user-provided function */ Common.scale = 2 ; /* scale: -1: none, and do not check for errors * in the input matrix in KLU_refactor. * 0: none, but check for errors, * 1: sum, 2: max */ Common.halt_if_singular = TRUE ; /* quick halt if matrix is singular */ /* memory management routines */ //Common.malloc_memory = malloc ; //Common.calloc_memory = calloc ; //Common.free_memory = free ; //Common.realloc_memory = realloc ; /* user ordering function and optional argument */ Common.user_order = null ; Common.user_data = null ; /* statistics */ Common.status = KLU_OK ; Common.nrealloc = 0 ; Common.structural_rank = EMPTY ; Common.numerical_rank = EMPTY ; Common.noffdiag = EMPTY ; Common.flops = EMPTY ; Common.rcond = EMPTY ; Common.condest = EMPTY ; Common.rgrowth = EMPTY ; Common.work = 0 ; /* work done by btf_order */ Common.memusage = 0 ; Common.mempeak = 0 ; return (TRUE) ; }
java
public static int klu_defaults(KLU_common Common) { if (Common == null) { return (FALSE) ; } /* parameters */ Common.tol = 0.001 ; /* pivot tolerance for diagonal */ Common.memgrow = 1.2 ; /* realloc size ratio increase for LU factors */ Common.initmem_amd = 1.2 ; /* init. mem with AMD: c*nnz(L) + n */ Common.initmem = 10 ; /* init. mem otherwise: c*nnz(A) + n */ Common.btf = TRUE ; /* use BTF pre-ordering, or not */ Common.maxwork = 0 ; /* no limit to work done by btf_order */ Common.ordering = 0 ; /* 0: AMD, 1: COLAMD, 2: user-provided P and Q, * 3: user-provided function */ Common.scale = 2 ; /* scale: -1: none, and do not check for errors * in the input matrix in KLU_refactor. * 0: none, but check for errors, * 1: sum, 2: max */ Common.halt_if_singular = TRUE ; /* quick halt if matrix is singular */ /* memory management routines */ //Common.malloc_memory = malloc ; //Common.calloc_memory = calloc ; //Common.free_memory = free ; //Common.realloc_memory = realloc ; /* user ordering function and optional argument */ Common.user_order = null ; Common.user_data = null ; /* statistics */ Common.status = KLU_OK ; Common.nrealloc = 0 ; Common.structural_rank = EMPTY ; Common.numerical_rank = EMPTY ; Common.noffdiag = EMPTY ; Common.flops = EMPTY ; Common.rcond = EMPTY ; Common.condest = EMPTY ; Common.rgrowth = EMPTY ; Common.work = 0 ; /* work done by btf_order */ Common.memusage = 0 ; Common.mempeak = 0 ; return (TRUE) ; }
[ "public", "static", "int", "klu_defaults", "(", "KLU_common", "Common", ")", "{", "if", "(", "Common", "==", "null", ")", "{", "return", "(", "FALSE", ")", ";", "}", "/* parameters */", "Common", ".", "tol", "=", "0.001", ";", "/* pivot tolerance for diagonal */", "Common", ".", "memgrow", "=", "1.2", ";", "/* realloc size ratio increase for LU factors */", "Common", ".", "initmem_amd", "=", "1.2", ";", "/* init. mem with AMD: c*nnz(L) + n */", "Common", ".", "initmem", "=", "10", ";", "/* init. mem otherwise: c*nnz(A) + n */", "Common", ".", "btf", "=", "TRUE", ";", "/* use BTF pre-ordering, or not */", "Common", ".", "maxwork", "=", "0", ";", "/* no limit to work done by btf_order */", "Common", ".", "ordering", "=", "0", ";", "/* 0: AMD, 1: COLAMD, 2: user-provided P and Q,\n\t\t * 3: user-provided function */", "Common", ".", "scale", "=", "2", ";", "/* scale: -1: none, and do not check for errors\n\t\t * in the input matrix in KLU_refactor.\n\t\t * 0: none, but check for errors,\n\t\t * 1: sum, 2: max */", "Common", ".", "halt_if_singular", "=", "TRUE", ";", "/* quick halt if matrix is singular */", "/* memory management routines */", "//Common.malloc_memory = malloc ;", "//Common.calloc_memory = calloc ;", "//Common.free_memory = free ;", "//Common.realloc_memory = realloc ;", "/* user ordering function and optional argument */", "Common", ".", "user_order", "=", "null", ";", "Common", ".", "user_data", "=", "null", ";", "/* statistics */", "Common", ".", "status", "=", "KLU_OK", ";", "Common", ".", "nrealloc", "=", "0", ";", "Common", ".", "structural_rank", "=", "EMPTY", ";", "Common", ".", "numerical_rank", "=", "EMPTY", ";", "Common", ".", "noffdiag", "=", "EMPTY", ";", "Common", ".", "flops", "=", "EMPTY", ";", "Common", ".", "rcond", "=", "EMPTY", ";", "Common", ".", "condest", "=", "EMPTY", ";", "Common", ".", "rgrowth", "=", "EMPTY", ";", "Common", ".", "work", "=", "0", ";", "/* work done by btf_order */", "Common", ".", "memusage", "=", "0", ";", "Common", ".", "mempeak", "=", "0", ";", "return", "(", "TRUE", ")", ";", "}" ]
Sets default parameters for KLU. @param Common @return
[ "Sets", "default", "parameters", "for", "KLU", "." ]
4e5fcdfb479040be72b4642ff1682670142b4892
https://github.com/rwl/JKLU/blob/4e5fcdfb479040be72b4642ff1682670142b4892/src/main/java/edu/ufl/cise/klu/tdouble/Dklu_defaults.java#L38-L86
145,421
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/ParserConfig.java
ParserConfig.getParser
@SuppressWarnings("unchecked") @NotNull public final Parser<Object> getParser() { if (parser != null) { return parser; } LOG.info("Creating parser: {}", className); if (className == null) { throw new IllegalStateException("Class name was not set: " + getName()); } if (context == null) { throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className); } final Object obj = Utils4J.createInstance(className, context.getClassLoader()); if (!(obj instanceof Parser<?>)) { throw new IllegalStateException("Expected class to be of type '" + Parser.class.getName() + "', but was: " + className); } parser = (Parser<Object>) obj; parser.initialize(context, this); return parser; }
java
@SuppressWarnings("unchecked") @NotNull public final Parser<Object> getParser() { if (parser != null) { return parser; } LOG.info("Creating parser: {}", className); if (className == null) { throw new IllegalStateException("Class name was not set: " + getName()); } if (context == null) { throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className); } final Object obj = Utils4J.createInstance(className, context.getClassLoader()); if (!(obj instanceof Parser<?>)) { throw new IllegalStateException("Expected class to be of type '" + Parser.class.getName() + "', but was: " + className); } parser = (Parser<Object>) obj; parser.initialize(context, this); return parser; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "NotNull", "public", "final", "Parser", "<", "Object", ">", "getParser", "(", ")", "{", "if", "(", "parser", "!=", "null", ")", "{", "return", "parser", ";", "}", "LOG", ".", "info", "(", "\"Creating parser: {}\"", ",", "className", ")", ";", "if", "(", "className", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Class name was not set: \"", "+", "getName", "(", ")", ")", ";", "}", "if", "(", "context", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Context class loader was not set: \"", "+", "getName", "(", ")", "+", "\" / \"", "+", "className", ")", ";", "}", "final", "Object", "obj", "=", "Utils4J", ".", "createInstance", "(", "className", ",", "context", ".", "getClassLoader", "(", ")", ")", ";", "if", "(", "!", "(", "obj", "instanceof", "Parser", "<", "?", ">", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Expected class to be of type '\"", "+", "Parser", ".", "class", ".", "getName", "(", ")", "+", "\"', but was: \"", "+", "className", ")", ";", "}", "parser", "=", "(", "Parser", "<", "Object", ">", ")", "obj", ";", "parser", ".", "initialize", "(", "context", ",", "this", ")", ";", "return", "parser", ";", "}" ]
Returns an existing parser instance or creates a new one if it's the first call to this method. @return Parser of type {@link #className}.
[ "Returns", "an", "existing", "parser", "instance", "or", "creates", "a", "new", "one", "if", "it", "s", "the", "first", "call", "to", "this", "method", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/ParserConfig.java#L148-L168
145,422
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/factory/ImplementedMethod.java
ImplementedMethod.addInterface
public final void addInterface(final Class<?> intf) { if (intf == null) { throw new IllegalArgumentException("The argument 'intf' cannot be null!"); } if (!intf.isInterface()) { throw new IllegalArgumentException("The argument 'intf' [" + intf.getName() + "] is not an interface!"); } interfaces.add(intf); }
java
public final void addInterface(final Class<?> intf) { if (intf == null) { throw new IllegalArgumentException("The argument 'intf' cannot be null!"); } if (!intf.isInterface()) { throw new IllegalArgumentException("The argument 'intf' [" + intf.getName() + "] is not an interface!"); } interfaces.add(intf); }
[ "public", "final", "void", "addInterface", "(", "final", "Class", "<", "?", ">", "intf", ")", "{", "if", "(", "intf", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'intf' cannot be null!\"", ")", ";", "}", "if", "(", "!", "intf", ".", "isInterface", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'intf' [\"", "+", "intf", ".", "getName", "(", ")", "+", "\"] is not an interface!\"", ")", ";", "}", "interfaces", ".", "add", "(", "intf", ")", ";", "}" ]
Adds a new interface that has this method. @param intf Interface to add - Cannot be <code>null</code> and must be an interface.
[ "Adds", "a", "new", "interface", "that", "has", "this", "method", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/factory/ImplementedMethod.java#L67-L76
145,423
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/maven/CeylonInstallJar.java
CeylonInstallJar.gavExists
private boolean gavExists() { return groupId != null && !"".equals(groupId) && artifactId != null && !"".equals(artifactId) && version != null && !"".equals(version); }
java
private boolean gavExists() { return groupId != null && !"".equals(groupId) && artifactId != null && !"".equals(artifactId) && version != null && !"".equals(version); }
[ "private", "boolean", "gavExists", "(", ")", "{", "return", "groupId", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "groupId", ")", "&&", "artifactId", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "artifactId", ")", "&&", "version", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "version", ")", ";", "}" ]
Determines if the GAV coordinates are specified. @return True if all three exist, false otherwise
[ "Determines", "if", "the", "GAV", "coordinates", "are", "specified", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonInstallJar.java#L221-L225
145,424
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/maven/CeylonInstallJar.java
CeylonInstallJar.installJar
private void installJar(final File installableFile) throws MojoExecutionException { try { Artifact artifact = new DefaultArtifact(groupId, artifactId, version, null, "jar", null, new DefaultArtifactHandler("jar")); install(installableFile, artifact, localRepository); File artifactFile = new File(localRepository.getBasedir(), localRepository.pathOf(artifact)); installAdditional(artifactFile, ".sha1", CeylonUtil.calculateChecksum(artifactFile), false); if (model != null) { String deps = calculateDependencies(new MavenProject(model)); if (!"".equals(deps)) { installAdditional(artifactFile, "module.properties", deps, false); installAdditional(artifactFile, ".module", deps, true); } } } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
java
private void installJar(final File installableFile) throws MojoExecutionException { try { Artifact artifact = new DefaultArtifact(groupId, artifactId, version, null, "jar", null, new DefaultArtifactHandler("jar")); install(installableFile, artifact, localRepository); File artifactFile = new File(localRepository.getBasedir(), localRepository.pathOf(artifact)); installAdditional(artifactFile, ".sha1", CeylonUtil.calculateChecksum(artifactFile), false); if (model != null) { String deps = calculateDependencies(new MavenProject(model)); if (!"".equals(deps)) { installAdditional(artifactFile, "module.properties", deps, false); installAdditional(artifactFile, ".module", deps, true); } } } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
[ "private", "void", "installJar", "(", "final", "File", "installableFile", ")", "throws", "MojoExecutionException", "{", "try", "{", "Artifact", "artifact", "=", "new", "DefaultArtifact", "(", "groupId", ",", "artifactId", ",", "version", ",", "null", ",", "\"jar\"", ",", "null", ",", "new", "DefaultArtifactHandler", "(", "\"jar\"", ")", ")", ";", "install", "(", "installableFile", ",", "artifact", ",", "localRepository", ")", ";", "File", "artifactFile", "=", "new", "File", "(", "localRepository", ".", "getBasedir", "(", ")", ",", "localRepository", ".", "pathOf", "(", "artifact", ")", ")", ";", "installAdditional", "(", "artifactFile", ",", "\".sha1\"", ",", "CeylonUtil", ".", "calculateChecksum", "(", "artifactFile", ")", ",", "false", ")", ";", "if", "(", "model", "!=", "null", ")", "{", "String", "deps", "=", "calculateDependencies", "(", "new", "MavenProject", "(", "model", ")", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "deps", ")", ")", "{", "installAdditional", "(", "artifactFile", ",", "\"module.properties\"", ",", "deps", ",", "false", ")", ";", "installAdditional", "(", "artifactFile", ",", "\".module\"", ",", "deps", ",", "true", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Does the actual installation of the jar file. @param installableFile The file to install @throws MojoExecutionException In case of an error
[ "Does", "the", "actual", "installation", "of", "the", "jar", "file", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonInstallJar.java#L232-L258
145,425
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/maven/CeylonInstallJar.java
CeylonInstallJar.processModel
private void processModel(final Model readModel) { this.model = readModel; Parent parent = readModel.getParent(); if (this.groupId == null) { this.groupId = readModel.getGroupId(); if (this.groupId == null && parent != null) { this.groupId = parent.getGroupId(); } } if (this.artifactId == null) { this.artifactId = readModel.getArtifactId(); } if (this.version == null) { this.version = readModel.getVersion(); if (this.version == null && parent != null) { this.version = parent.getVersion(); } } if (this.packaging == null) { this.packaging = readModel.getPackaging(); } }
java
private void processModel(final Model readModel) { this.model = readModel; Parent parent = readModel.getParent(); if (this.groupId == null) { this.groupId = readModel.getGroupId(); if (this.groupId == null && parent != null) { this.groupId = parent.getGroupId(); } } if (this.artifactId == null) { this.artifactId = readModel.getArtifactId(); } if (this.version == null) { this.version = readModel.getVersion(); if (this.version == null && parent != null) { this.version = parent.getVersion(); } } if (this.packaging == null) { this.packaging = readModel.getPackaging(); } }
[ "private", "void", "processModel", "(", "final", "Model", "readModel", ")", "{", "this", ".", "model", "=", "readModel", ";", "Parent", "parent", "=", "readModel", ".", "getParent", "(", ")", ";", "if", "(", "this", ".", "groupId", "==", "null", ")", "{", "this", ".", "groupId", "=", "readModel", ".", "getGroupId", "(", ")", ";", "if", "(", "this", ".", "groupId", "==", "null", "&&", "parent", "!=", "null", ")", "{", "this", ".", "groupId", "=", "parent", ".", "getGroupId", "(", ")", ";", "}", "}", "if", "(", "this", ".", "artifactId", "==", "null", ")", "{", "this", ".", "artifactId", "=", "readModel", ".", "getArtifactId", "(", ")", ";", "}", "if", "(", "this", ".", "version", "==", "null", ")", "{", "this", ".", "version", "=", "readModel", ".", "getVersion", "(", ")", ";", "if", "(", "this", ".", "version", "==", "null", "&&", "parent", "!=", "null", ")", "{", "this", ".", "version", "=", "parent", ".", "getVersion", "(", ")", ";", "}", "}", "if", "(", "this", ".", "packaging", "==", "null", ")", "{", "this", ".", "packaging", "=", "readModel", ".", "getPackaging", "(", ")", ";", "}", "}" ]
Populates missing mojo parameters from the specified POM. @param readModel The POM to extract missing artifact coordinates from, must not be <code>null</code>.
[ "Populates", "missing", "mojo", "parameters", "from", "the", "specified", "POM", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonInstallJar.java#L266-L289
145,426
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/maven/CeylonInstallJar.java
CeylonInstallJar.readModel
private Model readModel(final InputStream pomStream) throws MojoExecutionException { Reader reader = null; try { reader = ReaderFactory.newXmlReader(pomStream); return new MavenXpp3Reader().read(reader); } catch (FileNotFoundException e) { throw new MojoExecutionException("File not found " + pomFile, e); } catch (IOException e) { throw new MojoExecutionException("Error reading POM " + pomFile, e); } catch (XmlPullParserException e) { throw new MojoExecutionException("Error parsing POM " + pomFile, e); } finally { IOUtil.close(reader); } }
java
private Model readModel(final InputStream pomStream) throws MojoExecutionException { Reader reader = null; try { reader = ReaderFactory.newXmlReader(pomStream); return new MavenXpp3Reader().read(reader); } catch (FileNotFoundException e) { throw new MojoExecutionException("File not found " + pomFile, e); } catch (IOException e) { throw new MojoExecutionException("Error reading POM " + pomFile, e); } catch (XmlPullParserException e) { throw new MojoExecutionException("Error parsing POM " + pomFile, e); } finally { IOUtil.close(reader); } }
[ "private", "Model", "readModel", "(", "final", "InputStream", "pomStream", ")", "throws", "MojoExecutionException", "{", "Reader", "reader", "=", "null", ";", "try", "{", "reader", "=", "ReaderFactory", ".", "newXmlReader", "(", "pomStream", ")", ";", "return", "new", "MavenXpp3Reader", "(", ")", ".", "read", "(", "reader", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"File not found \"", "+", "pomFile", ",", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Error reading POM \"", "+", "pomFile", ",", "e", ")", ";", "}", "catch", "(", "XmlPullParserException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Error parsing POM \"", "+", "pomFile", ",", "e", ")", ";", "}", "finally", "{", "IOUtil", ".", "close", "(", "reader", ")", ";", "}", "}" ]
Parses a POM. @param pomStream The path of the POM file to parse, must not be <code>null</code>. @return The model from the POM file, never <code>null</code>. @throws MojoExecutionException If the POM could not be parsed.
[ "Parses", "a", "POM", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonInstallJar.java#L298-L312
145,427
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java
CircularSeekBar.initAttributes
protected void initAttributes(TypedArray attrArray) { mCircleXRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_x_radius, DEFAULT_CIRCLE_X_RADIUS * DPTOPX_SCALE); mCircleYRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_y_radius, DEFAULT_CIRCLE_Y_RADIUS * DPTOPX_SCALE); mPointerRadius = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_radius, DEFAULT_POINTER_RADIUS * DPTOPX_SCALE); mPointerHaloWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_width, DEFAULT_POINTER_HALO_WIDTH * DPTOPX_SCALE); mPointerHaloBorderWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_border_width, DEFAULT_POINTER_HALO_BORDER_WIDTH * DPTOPX_SCALE); mCircleStrokeWidth = attrArray.getDimension(R.styleable.CircularSeekBar_circle_stroke_width, DEFAULT_CIRCLE_STROKE_WIDTH * DPTOPX_SCALE); mPointerColor = attrArray.getColor(R.styleable.CircularSeekBar_pointer_color, DEFAULT_POINTER_COLOR); mPointerHaloColor = attrArray.getColor(R.styleable.CircularSeekBar_pointer_halo_color, DEFAULT_POINTER_HALO_COLOR); mPointerHaloColorOnTouch = attrArray.getColor(R.styleable.CircularSeekBar_pointer_halo_color_ontouch, DEFAULT_POINTER_HALO_COLOR_ONTOUCH); mCircleColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_color, DEFAULT_CIRCLE_COLOR); mCircleProgressColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_progress_color, DEFAULT_CIRCLE_PROGRESS_COLOR); mCircleFillColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_fill, DEFAULT_CIRCLE_FILL_COLOR); mPointerAlpha = Color.alpha(mPointerHaloColor); mPointerAlphaOnTouch = attrArray.getInt(R.styleable.CircularSeekBar_pointer_alpha_ontouch, DEFAULT_POINTER_ALPHA_ONTOUCH); if (mPointerAlphaOnTouch > 255 || mPointerAlphaOnTouch < 0) { mPointerAlphaOnTouch = DEFAULT_POINTER_ALPHA_ONTOUCH; } mMax = attrArray.getInt(R.styleable.CircularSeekBar_maxValue, DEFAULT_MAX); mProgress = attrArray.getInt(R.styleable.CircularSeekBar_progressValue, DEFAULT_PROGRESS); mCustomRadii = attrArray.getBoolean(R.styleable.CircularSeekBar_use_custom_radii, DEFAULT_USE_CUSTOM_RADII); mMaintainEqualCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_maintain_equal_circle, DEFAULT_MAINTAIN_EQUAL_CIRCLE); mMoveOutsideCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_move_outside_circle, DEFAULT_MOVE_OUTSIDE_CIRCLE); lockEnabled = attrArray.getBoolean(R.styleable.CircularSeekBar_lock_enabled, DEFAULT_LOCK_ENABLED); // Modulo 360 right now to avoid constant conversion mStartAngle = ((360f + (attrArray.getFloat((R.styleable.CircularSeekBar_start_angle), DEFAULT_START_ANGLE) % 360f)) % 360f); mEndAngle = ((360f + (attrArray.getFloat((R.styleable.CircularSeekBar_end_angle), DEFAULT_END_ANGLE) % 360f)) % 360f); if (mStartAngle == mEndAngle) { //mStartAngle = mStartAngle + 1f; mEndAngle = mEndAngle - .1f; } }
java
protected void initAttributes(TypedArray attrArray) { mCircleXRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_x_radius, DEFAULT_CIRCLE_X_RADIUS * DPTOPX_SCALE); mCircleYRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_y_radius, DEFAULT_CIRCLE_Y_RADIUS * DPTOPX_SCALE); mPointerRadius = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_radius, DEFAULT_POINTER_RADIUS * DPTOPX_SCALE); mPointerHaloWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_width, DEFAULT_POINTER_HALO_WIDTH * DPTOPX_SCALE); mPointerHaloBorderWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_border_width, DEFAULT_POINTER_HALO_BORDER_WIDTH * DPTOPX_SCALE); mCircleStrokeWidth = attrArray.getDimension(R.styleable.CircularSeekBar_circle_stroke_width, DEFAULT_CIRCLE_STROKE_WIDTH * DPTOPX_SCALE); mPointerColor = attrArray.getColor(R.styleable.CircularSeekBar_pointer_color, DEFAULT_POINTER_COLOR); mPointerHaloColor = attrArray.getColor(R.styleable.CircularSeekBar_pointer_halo_color, DEFAULT_POINTER_HALO_COLOR); mPointerHaloColorOnTouch = attrArray.getColor(R.styleable.CircularSeekBar_pointer_halo_color_ontouch, DEFAULT_POINTER_HALO_COLOR_ONTOUCH); mCircleColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_color, DEFAULT_CIRCLE_COLOR); mCircleProgressColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_progress_color, DEFAULT_CIRCLE_PROGRESS_COLOR); mCircleFillColor = attrArray.getColor(R.styleable.CircularSeekBar_circle_fill, DEFAULT_CIRCLE_FILL_COLOR); mPointerAlpha = Color.alpha(mPointerHaloColor); mPointerAlphaOnTouch = attrArray.getInt(R.styleable.CircularSeekBar_pointer_alpha_ontouch, DEFAULT_POINTER_ALPHA_ONTOUCH); if (mPointerAlphaOnTouch > 255 || mPointerAlphaOnTouch < 0) { mPointerAlphaOnTouch = DEFAULT_POINTER_ALPHA_ONTOUCH; } mMax = attrArray.getInt(R.styleable.CircularSeekBar_maxValue, DEFAULT_MAX); mProgress = attrArray.getInt(R.styleable.CircularSeekBar_progressValue, DEFAULT_PROGRESS); mCustomRadii = attrArray.getBoolean(R.styleable.CircularSeekBar_use_custom_radii, DEFAULT_USE_CUSTOM_RADII); mMaintainEqualCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_maintain_equal_circle, DEFAULT_MAINTAIN_EQUAL_CIRCLE); mMoveOutsideCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_move_outside_circle, DEFAULT_MOVE_OUTSIDE_CIRCLE); lockEnabled = attrArray.getBoolean(R.styleable.CircularSeekBar_lock_enabled, DEFAULT_LOCK_ENABLED); // Modulo 360 right now to avoid constant conversion mStartAngle = ((360f + (attrArray.getFloat((R.styleable.CircularSeekBar_start_angle), DEFAULT_START_ANGLE) % 360f)) % 360f); mEndAngle = ((360f + (attrArray.getFloat((R.styleable.CircularSeekBar_end_angle), DEFAULT_END_ANGLE) % 360f)) % 360f); if (mStartAngle == mEndAngle) { //mStartAngle = mStartAngle + 1f; mEndAngle = mEndAngle - .1f; } }
[ "protected", "void", "initAttributes", "(", "TypedArray", "attrArray", ")", "{", "mCircleXRadius", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_x_radius", ",", "DEFAULT_CIRCLE_X_RADIUS", "*", "DPTOPX_SCALE", ")", ";", "mCircleYRadius", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_y_radius", ",", "DEFAULT_CIRCLE_Y_RADIUS", "*", "DPTOPX_SCALE", ")", ";", "mPointerRadius", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_radius", ",", "DEFAULT_POINTER_RADIUS", "*", "DPTOPX_SCALE", ")", ";", "mPointerHaloWidth", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_halo_width", ",", "DEFAULT_POINTER_HALO_WIDTH", "*", "DPTOPX_SCALE", ")", ";", "mPointerHaloBorderWidth", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_halo_border_width", ",", "DEFAULT_POINTER_HALO_BORDER_WIDTH", "*", "DPTOPX_SCALE", ")", ";", "mCircleStrokeWidth", "=", "attrArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_stroke_width", ",", "DEFAULT_CIRCLE_STROKE_WIDTH", "*", "DPTOPX_SCALE", ")", ";", "mPointerColor", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_color", ",", "DEFAULT_POINTER_COLOR", ")", ";", "mPointerHaloColor", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_halo_color", ",", "DEFAULT_POINTER_HALO_COLOR", ")", ";", "mPointerHaloColorOnTouch", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_halo_color_ontouch", ",", "DEFAULT_POINTER_HALO_COLOR_ONTOUCH", ")", ";", "mCircleColor", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_color", ",", "DEFAULT_CIRCLE_COLOR", ")", ";", "mCircleProgressColor", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_progress_color", ",", "DEFAULT_CIRCLE_PROGRESS_COLOR", ")", ";", "mCircleFillColor", "=", "attrArray", ".", "getColor", "(", "R", ".", "styleable", ".", "CircularSeekBar_circle_fill", ",", "DEFAULT_CIRCLE_FILL_COLOR", ")", ";", "mPointerAlpha", "=", "Color", ".", "alpha", "(", "mPointerHaloColor", ")", ";", "mPointerAlphaOnTouch", "=", "attrArray", ".", "getInt", "(", "R", ".", "styleable", ".", "CircularSeekBar_pointer_alpha_ontouch", ",", "DEFAULT_POINTER_ALPHA_ONTOUCH", ")", ";", "if", "(", "mPointerAlphaOnTouch", ">", "255", "||", "mPointerAlphaOnTouch", "<", "0", ")", "{", "mPointerAlphaOnTouch", "=", "DEFAULT_POINTER_ALPHA_ONTOUCH", ";", "}", "mMax", "=", "attrArray", ".", "getInt", "(", "R", ".", "styleable", ".", "CircularSeekBar_maxValue", ",", "DEFAULT_MAX", ")", ";", "mProgress", "=", "attrArray", ".", "getInt", "(", "R", ".", "styleable", ".", "CircularSeekBar_progressValue", ",", "DEFAULT_PROGRESS", ")", ";", "mCustomRadii", "=", "attrArray", ".", "getBoolean", "(", "R", ".", "styleable", ".", "CircularSeekBar_use_custom_radii", ",", "DEFAULT_USE_CUSTOM_RADII", ")", ";", "mMaintainEqualCircle", "=", "attrArray", ".", "getBoolean", "(", "R", ".", "styleable", ".", "CircularSeekBar_maintain_equal_circle", ",", "DEFAULT_MAINTAIN_EQUAL_CIRCLE", ")", ";", "mMoveOutsideCircle", "=", "attrArray", ".", "getBoolean", "(", "R", ".", "styleable", ".", "CircularSeekBar_move_outside_circle", ",", "DEFAULT_MOVE_OUTSIDE_CIRCLE", ")", ";", "lockEnabled", "=", "attrArray", ".", "getBoolean", "(", "R", ".", "styleable", ".", "CircularSeekBar_lock_enabled", ",", "DEFAULT_LOCK_ENABLED", ")", ";", "// Modulo 360 right now to avoid constant conversion", "mStartAngle", "=", "(", "(", "360f", "+", "(", "attrArray", ".", "getFloat", "(", "(", "R", ".", "styleable", ".", "CircularSeekBar_start_angle", ")", ",", "DEFAULT_START_ANGLE", ")", "%", "360f", ")", ")", "%", "360f", ")", ";", "mEndAngle", "=", "(", "(", "360f", "+", "(", "attrArray", ".", "getFloat", "(", "(", "R", ".", "styleable", ".", "CircularSeekBar_end_angle", ")", ",", "DEFAULT_END_ANGLE", ")", "%", "360f", ")", ")", "%", "360f", ")", ";", "if", "(", "mStartAngle", "==", "mEndAngle", ")", "{", "//mStartAngle = mStartAngle + 1f;", "mEndAngle", "=", "mEndAngle", "-", ".1f", ";", "}", "}" ]
Initialize the CircularSeekBar with the attributes from the XML style. Uses the defaults defined at the top of this file when an attribute is not specified by the user. @param attrArray TypedArray containing the attributes.
[ "Initialize", "the", "CircularSeekBar", "with", "the", "attributes", "from", "the", "XML", "style", ".", "Uses", "the", "defaults", "defined", "at", "the", "top", "of", "this", "file", "when", "an", "attribute", "is", "not", "specified", "by", "the", "user", "." ]
b122f6dcab7cec60c8e5455e0c31613d08bec6ad
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java#L349-L386
145,428
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java
CircularSeekBar.setProgress
public void setProgress(int progress) { if (mProgress != progress) { mProgress = progress; if (mOnCircularSeekBarChangeListener != null) { mOnCircularSeekBarChangeListener.onProgressChanged(this, progress, false); } recalculateAll(); invalidate(); } }
java
public void setProgress(int progress) { if (mProgress != progress) { mProgress = progress; if (mOnCircularSeekBarChangeListener != null) { mOnCircularSeekBarChangeListener.onProgressChanged(this, progress, false); } recalculateAll(); invalidate(); } }
[ "public", "void", "setProgress", "(", "int", "progress", ")", "{", "if", "(", "mProgress", "!=", "progress", ")", "{", "mProgress", "=", "progress", ";", "if", "(", "mOnCircularSeekBarChangeListener", "!=", "null", ")", "{", "mOnCircularSeekBarChangeListener", ".", "onProgressChanged", "(", "this", ",", "progress", ",", "false", ")", ";", "}", "recalculateAll", "(", ")", ";", "invalidate", "(", ")", ";", "}", "}" ]
Set the progress of the CircularSeekBar. If the progress is the same, then any listener will not receive a onProgressChanged event. @param progress The progress to set the CircularSeekBar to.
[ "Set", "the", "progress", "of", "the", "CircularSeekBar", ".", "If", "the", "progress", "is", "the", "same", "then", "any", "listener", "will", "not", "receive", "a", "onProgressChanged", "event", "." ]
b122f6dcab7cec60c8e5455e0c31613d08bec6ad
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java#L531-L541
145,429
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java
CircularSeekBar.setPointerAlpha
public void setPointerAlpha(int alpha) { if (alpha >= 0 && alpha <= 255) { mPointerAlpha = alpha; mPointerHaloPaint.setAlpha(mPointerAlpha); invalidate(); } }
java
public void setPointerAlpha(int alpha) { if (alpha >= 0 && alpha <= 255) { mPointerAlpha = alpha; mPointerHaloPaint.setAlpha(mPointerAlpha); invalidate(); } }
[ "public", "void", "setPointerAlpha", "(", "int", "alpha", ")", "{", "if", "(", "alpha", ">=", "0", "&&", "alpha", "<=", "255", ")", "{", "mPointerAlpha", "=", "alpha", ";", "mPointerHaloPaint", ".", "setAlpha", "(", "mPointerAlpha", ")", ";", "invalidate", "(", ")", ";", "}", "}" ]
Sets the pointer alpha. @param alpha the alpha of the pointer
[ "Sets", "the", "pointer", "alpha", "." ]
b122f6dcab7cec60c8e5455e0c31613d08bec6ad
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java#L973-L979
145,430
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java
CircularSeekBar.setMax
public void setMax(int max) { if (!(max <= 0)) { // Check to make sure it's greater than zero if (max <= mProgress) { mProgress = 0; // If the new max is less than current progress, set progress to zero if (mOnCircularSeekBarChangeListener != null) { mOnCircularSeekBarChangeListener.onProgressChanged(this, mProgress, false); } } mMax = max; recalculateAll(); invalidate(); } }
java
public void setMax(int max) { if (!(max <= 0)) { // Check to make sure it's greater than zero if (max <= mProgress) { mProgress = 0; // If the new max is less than current progress, set progress to zero if (mOnCircularSeekBarChangeListener != null) { mOnCircularSeekBarChangeListener.onProgressChanged(this, mProgress, false); } } mMax = max; recalculateAll(); invalidate(); } }
[ "public", "void", "setMax", "(", "int", "max", ")", "{", "if", "(", "!", "(", "max", "<=", "0", ")", ")", "{", "// Check to make sure it's greater than zero", "if", "(", "max", "<=", "mProgress", ")", "{", "mProgress", "=", "0", ";", "// If the new max is less than current progress, set progress to zero", "if", "(", "mOnCircularSeekBarChangeListener", "!=", "null", ")", "{", "mOnCircularSeekBarChangeListener", ".", "onProgressChanged", "(", "this", ",", "mProgress", ",", "false", ")", ";", "}", "}", "mMax", "=", "max", ";", "recalculateAll", "(", ")", ";", "invalidate", "(", ")", ";", "}", "}" ]
Set the max of the CircularSeekBar. If the new max is less than the current progress, then the progress will be set to zero. If the progress is changed as a result, then any listener will receive a onProgressChanged event. @param max The new max for the CircularSeekBar.
[ "Set", "the", "max", "of", "the", "CircularSeekBar", ".", "If", "the", "new", "max", "is", "less", "than", "the", "current", "progress", "then", "the", "progress", "will", "be", "set", "to", "zero", ".", "If", "the", "progress", "is", "changed", "as", "a", "result", "then", "any", "listener", "will", "receive", "a", "onProgressChanged", "event", "." ]
b122f6dcab7cec60c8e5455e0c31613d08bec6ad
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/view/CircularSeekBar.java#L1037-L1050
145,431
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.collectLinks
public List<Link> collectLinks(String rel) { return collectResources(Link.class, HalResourceType.LINKS, rel); }
java
public List<Link> collectLinks(String rel) { return collectResources(Link.class, HalResourceType.LINKS, rel); }
[ "public", "List", "<", "Link", ">", "collectLinks", "(", "String", "rel", ")", "{", "return", "collectResources", "(", "Link", ".", "class", ",", "HalResourceType", ".", "LINKS", ",", "rel", ")", ";", "}" ]
recursively collects links within this resource and all embedded resources @param rel the relation your interested in @return a list of all links
[ "recursively", "collects", "links", "within", "this", "resource", "and", "all", "embedded", "resources" ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L218-L220
145,432
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.collectEmbedded
public List<HalResource> collectEmbedded(String rel) { return collectResources(HalResource.class, HalResourceType.EMBEDDED, rel); }
java
public List<HalResource> collectEmbedded(String rel) { return collectResources(HalResource.class, HalResourceType.EMBEDDED, rel); }
[ "public", "List", "<", "HalResource", ">", "collectEmbedded", "(", "String", "rel", ")", "{", "return", "collectResources", "(", "HalResource", ".", "class", ",", "HalResourceType", ".", "EMBEDDED", ",", "rel", ")", ";", "}" ]
recursively collects embedded resources of a specific rel @param rel the relation your interested in @return a list of all embedded resources
[ "recursively", "collects", "embedded", "resources", "of", "a", "specific", "rel" ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L251-L253
145,433
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.setEmbedded
public HalResource setEmbedded(String relation, HalResource resource) { if (resource == null) { return this; } return addResources(HalResourceType.EMBEDDED, relation, false, new HalResource[] { resource }); }
java
public HalResource setEmbedded(String relation, HalResource resource) { if (resource == null) { return this; } return addResources(HalResourceType.EMBEDDED, relation, false, new HalResource[] { resource }); }
[ "public", "HalResource", "setEmbedded", "(", "String", "relation", ",", "HalResource", "resource", ")", "{", "if", "(", "resource", "==", "null", ")", "{", "return", "this", ";", "}", "return", "addResources", "(", "HalResourceType", ".", "EMBEDDED", ",", "relation", ",", "false", ",", "new", "HalResource", "[", "]", "{", "resource", "}", ")", ";", "}" ]
Embed resource for the given relation. Overwrites existing one. @param relation Embedded resource relation @param resource Resource to embed @return HAL resource
[ "Embed", "resource", "for", "the", "given", "relation", ".", "Overwrites", "existing", "one", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L337-L344
145,434
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.removeLink
public HalResource removeLink(String relation, int index) { return removeResource(HalResourceType.LINKS, relation, index); }
java
public HalResource removeLink(String relation, int index) { return removeResource(HalResourceType.LINKS, relation, index); }
[ "public", "HalResource", "removeLink", "(", "String", "relation", ",", "int", "index", ")", "{", "return", "removeResource", "(", "HalResourceType", ".", "LINKS", ",", "relation", ",", "index", ")", ";", "}" ]
Removes one link for the given relation and index. @param relation Link relation @param index Array index @return HAL resource
[ "Removes", "one", "link", "for", "the", "given", "relation", "and", "index", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L440-L442
145,435
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.removeLinkWithHref
public HalResource removeLinkWithHref(String relation, String href) { List<Link> links = getLinks(relation); for (int i = 0; i < links.size(); i++) { if (href.equals(links.get(i).getHref())) { return removeLink(relation, i); } } return this; }
java
public HalResource removeLinkWithHref(String relation, String href) { List<Link> links = getLinks(relation); for (int i = 0; i < links.size(); i++) { if (href.equals(links.get(i).getHref())) { return removeLink(relation, i); } } return this; }
[ "public", "HalResource", "removeLinkWithHref", "(", "String", "relation", ",", "String", "href", ")", "{", "List", "<", "Link", ">", "links", "=", "getLinks", "(", "relation", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "links", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "href", ".", "equals", "(", "links", ".", "get", "(", "i", ")", ".", "getHref", "(", ")", ")", ")", "{", "return", "removeLink", "(", "relation", ",", "i", ")", ";", "}", "}", "return", "this", ";", "}" ]
Remove the link with the given relation and href @param relation Link relation @param href to identify the link to remove @return this HAL resource
[ "Remove", "the", "link", "with", "the", "given", "relation", "and", "href" ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L451-L461
145,436
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.removeEmbedded
public HalResource removeEmbedded(String relation, int index) { return removeResource(HalResourceType.EMBEDDED, relation, index); }
java
public HalResource removeEmbedded(String relation, int index) { return removeResource(HalResourceType.EMBEDDED, relation, index); }
[ "public", "HalResource", "removeEmbedded", "(", "String", "relation", ",", "int", "index", ")", "{", "return", "removeResource", "(", "HalResourceType", ".", "EMBEDDED", ",", "relation", ",", "index", ")", ";", "}" ]
Removes one embedded resource for the given relation and index. @param relation Embedded resource relation @param index Array index @return HAL resource
[ "Removes", "one", "embedded", "resource", "for", "the", "given", "relation", "and", "index", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L469-L471
145,437
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.renameEmbedded
public HalResource renameEmbedded(String relToRename, String newRel) { List<HalResource> resources = getEmbedded(relToRename); return removeEmbedded(relToRename).addEmbedded(newRel, resources); }
java
public HalResource renameEmbedded(String relToRename, String newRel) { List<HalResource> resources = getEmbedded(relToRename); return removeEmbedded(relToRename).addEmbedded(newRel, resources); }
[ "public", "HalResource", "renameEmbedded", "(", "String", "relToRename", ",", "String", "newRel", ")", "{", "List", "<", "HalResource", ">", "resources", "=", "getEmbedded", "(", "relToRename", ")", ";", "return", "removeEmbedded", "(", "relToRename", ")", ".", "addEmbedded", "(", "newRel", ",", "resources", ")", ";", "}" ]
Changes the rel of embedded resources @param relToRename the rel that you want to change @param newRel the new rel for all embedded items @return HAL resource
[ "Changes", "the", "rel", "of", "embedded", "resources" ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L508-L511
145,438
wcm-io-caravan/caravan-hal
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
HalResource.addState
public HalResource addState(ObjectNode state) { state.fields().forEachRemaining(entry -> model.set(entry.getKey(), entry.getValue())); return this; }
java
public HalResource addState(ObjectNode state) { state.fields().forEachRemaining(entry -> model.set(entry.getKey(), entry.getValue())); return this; }
[ "public", "HalResource", "addState", "(", "ObjectNode", "state", ")", "{", "state", ".", "fields", "(", ")", ".", "forEachRemaining", "(", "entry", "->", "model", ".", "set", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ")", ";", "return", "this", ";", "}" ]
Adds state to the resource. @param state Resource state @return HAL resource
[ "Adds", "state", "to", "the", "resource", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L523-L526
145,439
wcm-io-caravan/caravan-hal
docs/src/main/java/io/wcm/caravan/hal/docs/impl/reader/ServiceModelReader.java
ServiceModelReader.read
public static Service read(Bundle bundle) { String resourcePath = DOCS_CLASSPATH_PREFIX + "/" + SERVICE_DOC_FILE; URL bundleResource = bundle.getResource(resourcePath); if (bundleResource == null) { return null; } try (InputStream is = bundleResource.openStream()) { return new ServiceJson().read(is); } catch (Throwable ex) { log.error("Unable to parse JSON file " + resourcePath + " from bundle " + bundle.getSymbolicName()); return null; } }
java
public static Service read(Bundle bundle) { String resourcePath = DOCS_CLASSPATH_PREFIX + "/" + SERVICE_DOC_FILE; URL bundleResource = bundle.getResource(resourcePath); if (bundleResource == null) { return null; } try (InputStream is = bundleResource.openStream()) { return new ServiceJson().read(is); } catch (Throwable ex) { log.error("Unable to parse JSON file " + resourcePath + " from bundle " + bundle.getSymbolicName()); return null; } }
[ "public", "static", "Service", "read", "(", "Bundle", "bundle", ")", "{", "String", "resourcePath", "=", "DOCS_CLASSPATH_PREFIX", "+", "\"/\"", "+", "SERVICE_DOC_FILE", ";", "URL", "bundleResource", "=", "bundle", ".", "getResource", "(", "resourcePath", ")", ";", "if", "(", "bundleResource", "==", "null", ")", "{", "return", "null", ";", "}", "try", "(", "InputStream", "is", "=", "bundleResource", ".", "openStream", "(", ")", ")", "{", "return", "new", "ServiceJson", "(", ")", ".", "read", "(", "is", ")", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "log", ".", "error", "(", "\"Unable to parse JSON file \"", "+", "resourcePath", "+", "\" from bundle \"", "+", "bundle", ".", "getSymbolicName", "(", ")", ")", ";", "return", "null", ";", "}", "}" ]
Reads service model from bundle classpath. @param bundle Bundle @return Service model or null if not found or not parseable.
[ "Reads", "service", "model", "from", "bundle", "classpath", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs/src/main/java/io/wcm/caravan/hal/docs/impl/reader/ServiceModelReader.java#L57-L70
145,440
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/datetimepicker/SlidingTabLayout.java
SlidingTabLayout.setTabText
public void setTabText(int index, String text) { TextView tv = (TextView) mTabTitleViews.get(index); if (tv != null) { tv.setText(text); } }
java
public void setTabText(int index, String text) { TextView tv = (TextView) mTabTitleViews.get(index); if (tv != null) { tv.setText(text); } }
[ "public", "void", "setTabText", "(", "int", "index", ",", "String", "text", ")", "{", "TextView", "tv", "=", "(", "TextView", ")", "mTabTitleViews", ".", "get", "(", "index", ")", ";", "if", "(", "tv", "!=", "null", ")", "{", "tv", ".", "setText", "(", "text", ")", ";", "}", "}" ]
Set the text on the specified tab's TextView. @param index the index of the tab whose TextView you want to update @param text the text to display on the specified tab's TextView
[ "Set", "the", "text", "on", "the", "specified", "tab", "s", "TextView", "." ]
b122f6dcab7cec60c8e5455e0c31613d08bec6ad
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/datetimepicker/SlidingTabLayout.java#L247-L253
145,441
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/Generators.java
Generators.addGenerator
public final void addGenerator(@NotNull final GeneratorConfig generator) { Contract.requireArgNotNull("generator", generator); if (list == null) { list = new ArrayList<>(); } list.add(generator); }
java
public final void addGenerator(@NotNull final GeneratorConfig generator) { Contract.requireArgNotNull("generator", generator); if (list == null) { list = new ArrayList<>(); } list.add(generator); }
[ "public", "final", "void", "addGenerator", "(", "@", "NotNull", "final", "GeneratorConfig", "generator", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"generator\"", ",", "generator", ")", ";", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "list", ".", "add", "(", "generator", ")", ";", "}" ]
Adds a generator to the list. If the list does not exist it's created. @param generator Generator to add.
[ "Adds", "a", "generator", "to", "the", "list", ".", "If", "the", "list", "does", "not", "exist", "it", "s", "created", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/Generators.java#L99-L105
145,442
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/Generators.java
Generators.findByName
@Nullable public final GeneratorConfig findByName(@NotEmpty final String generatorName) throws GeneratorNotFoundException { Contract.requireArgNotEmpty("generatorName", generatorName); final int idx = list.indexOf(new GeneratorConfig(generatorName, "dummy", "dummy")); if (idx < 0) { throw new GeneratorNotFoundException(generatorName); } return list.get(idx); }
java
@Nullable public final GeneratorConfig findByName(@NotEmpty final String generatorName) throws GeneratorNotFoundException { Contract.requireArgNotEmpty("generatorName", generatorName); final int idx = list.indexOf(new GeneratorConfig(generatorName, "dummy", "dummy")); if (idx < 0) { throw new GeneratorNotFoundException(generatorName); } return list.get(idx); }
[ "@", "Nullable", "public", "final", "GeneratorConfig", "findByName", "(", "@", "NotEmpty", "final", "String", "generatorName", ")", "throws", "GeneratorNotFoundException", "{", "Contract", ".", "requireArgNotEmpty", "(", "\"generatorName\"", ",", "generatorName", ")", ";", "final", "int", "idx", "=", "list", ".", "indexOf", "(", "new", "GeneratorConfig", "(", "generatorName", ",", "\"dummy\"", ",", "\"dummy\"", ")", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "throw", "new", "GeneratorNotFoundException", "(", "generatorName", ")", ";", "}", "return", "list", ".", "get", "(", "idx", ")", ";", "}" ]
Returns a generator by it's name. @param generatorName Name to find. @return The generator. @throws GeneratorNotFoundException No generator with the given name was found.
[ "Returns", "a", "generator", "by", "it", "s", "name", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/Generators.java#L142-L150
145,443
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgClassPool.java
SgClassPool.get
public final SgClass get(final String className) { if (className == null) { throw new IllegalArgumentException("The argument 'className' cannot be null!"); } return cache.get(className); }
java
public final SgClass get(final String className) { if (className == null) { throw new IllegalArgumentException("The argument 'className' cannot be null!"); } return cache.get(className); }
[ "public", "final", "SgClass", "get", "(", "final", "String", "className", ")", "{", "if", "(", "className", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'className' cannot be null!\"", ")", ";", "}", "return", "cache", ".", "get", "(", "className", ")", ";", "}" ]
Returns a class from the internal cache. @param className Class to find - Cannot be null. @return Class or null if it's not found.
[ "Returns", "a", "class", "from", "the", "internal", "cache", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgClassPool.java#L55-L60
145,444
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgClassPool.java
SgClassPool.put
public final void put(final SgClass clasz) { if (clasz == null) { throw new IllegalArgumentException("The argument 'clasz' cannot be null!"); } cache.put(clasz.getName(), clasz); }
java
public final void put(final SgClass clasz) { if (clasz == null) { throw new IllegalArgumentException("The argument 'clasz' cannot be null!"); } cache.put(clasz.getName(), clasz); }
[ "public", "final", "void", "put", "(", "final", "SgClass", "clasz", ")", "{", "if", "(", "clasz", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'clasz' cannot be null!\"", ")", ";", "}", "cache", ".", "put", "(", "clasz", ".", "getName", "(", ")", ",", "clasz", ")", ";", "}" ]
Adds a class to the internal cache. @param clasz Class to add - Cannot be null.
[ "Adds", "a", "class", "to", "the", "internal", "cache", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgClassPool.java#L68-L73
145,445
UweTrottmann/getglue-java
src/main/java/com/uwetrottmann/getglue/Utils.java
Utils.createOkHttpClient
public static OkHttpClient createOkHttpClient() { OkHttpClient okHttpClient = new OkHttpClient(); // set timeouts okHttpClient.setConnectTimeout(15 * 1000, TimeUnit.MILLISECONDS); okHttpClient.setReadTimeout(20 * 1000, TimeUnit.MILLISECONDS); return okHttpClient; }
java
public static OkHttpClient createOkHttpClient() { OkHttpClient okHttpClient = new OkHttpClient(); // set timeouts okHttpClient.setConnectTimeout(15 * 1000, TimeUnit.MILLISECONDS); okHttpClient.setReadTimeout(20 * 1000, TimeUnit.MILLISECONDS); return okHttpClient; }
[ "public", "static", "OkHttpClient", "createOkHttpClient", "(", ")", "{", "OkHttpClient", "okHttpClient", "=", "new", "OkHttpClient", "(", ")", ";", "// set timeouts", "okHttpClient", ".", "setConnectTimeout", "(", "15", "*", "1000", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "okHttpClient", ".", "setReadTimeout", "(", "20", "*", "1000", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "return", "okHttpClient", ";", "}" ]
Create an OkHttpClient with sensible timeouts for mobile connections.
[ "Create", "an", "OkHttpClient", "with", "sensible", "timeouts", "for", "mobile", "connections", "." ]
9d79c150124f7e71c88568510df5f4f7ccd75d25
https://github.com/UweTrottmann/getglue-java/blob/9d79c150124f7e71c88568510df5f4f7ccd75d25/src/main/java/com/uwetrottmann/getglue/Utils.java#L28-L36
145,446
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
DownloadProperties.forGalaxyDist
@Deprecated public static DownloadProperties forGalaxyDist(final File destination, String revision) { return new DownloadProperties(GALAXY_DIST_REPOSITORY_URL, BRANCH_STABLE, revision, destination); }
java
@Deprecated public static DownloadProperties forGalaxyDist(final File destination, String revision) { return new DownloadProperties(GALAXY_DIST_REPOSITORY_URL, BRANCH_STABLE, revision, destination); }
[ "@", "Deprecated", "public", "static", "DownloadProperties", "forGalaxyDist", "(", "final", "File", "destination", ",", "String", "revision", ")", "{", "return", "new", "DownloadProperties", "(", "GALAXY_DIST_REPOSITORY_URL", ",", "BRANCH_STABLE", ",", "revision", ",", "destination", ")", ";", "}" ]
Builds a new DownloadProperties for downloading Galaxy from galaxy-dist. @param destination The destination directory to store Galaxy, null if a directory should be chosen by default. @param revision The revision to use for Galaxy. @return A new DownloadProperties for downloading Galaxy from galaxy-dist.
[ "Builds", "a", "new", "DownloadProperties", "for", "downloading", "Galaxy", "from", "galaxy", "-", "dist", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L326-L329
145,447
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
DownloadProperties.forGalaxyCentral
@Deprecated public static DownloadProperties forGalaxyCentral(final File destination, String revision) { return new DownloadProperties(GALAXY_CENTRAL_REPOSITORY_URL, BRANCH_DEFAULT, revision, destination); }
java
@Deprecated public static DownloadProperties forGalaxyCentral(final File destination, String revision) { return new DownloadProperties(GALAXY_CENTRAL_REPOSITORY_URL, BRANCH_DEFAULT, revision, destination); }
[ "@", "Deprecated", "public", "static", "DownloadProperties", "forGalaxyCentral", "(", "final", "File", "destination", ",", "String", "revision", ")", "{", "return", "new", "DownloadProperties", "(", "GALAXY_CENTRAL_REPOSITORY_URL", ",", "BRANCH_DEFAULT", ",", "revision", ",", "destination", ")", ";", "}" ]
Builds a new DownloadProperties for downloading Galaxy from galaxy-central. @param destination The destination directory to store Galaxy, null if a directory should be chosen by default. @param revision The revision to use for Galaxy. @return A new DownloadProperties for downloading Galaxy from galaxy-central.
[ "Builds", "a", "new", "DownloadProperties", "for", "downloading", "Galaxy", "from", "galaxy", "-", "central", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L349-L352
145,448
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
DownloadProperties.forStableAtRevision
@Deprecated public static DownloadProperties forStableAtRevision(final File destination, String revision) { return new DownloadProperties(GALAXY_CENTRAL_REPOSITORY_URL, BRANCH_STABLE, revision, destination); }
java
@Deprecated public static DownloadProperties forStableAtRevision(final File destination, String revision) { return new DownloadProperties(GALAXY_CENTRAL_REPOSITORY_URL, BRANCH_STABLE, revision, destination); }
[ "@", "Deprecated", "public", "static", "DownloadProperties", "forStableAtRevision", "(", "final", "File", "destination", ",", "String", "revision", ")", "{", "return", "new", "DownloadProperties", "(", "GALAXY_CENTRAL_REPOSITORY_URL", ",", "BRANCH_STABLE", ",", "revision", ",", "destination", ")", ";", "}" ]
Builds a new DownloadProperties for downloading Galaxy at the given revision. @param destination The destination directory to store Galaxy, null if a directory should be chosen by default. @return A new DownloadProperties for downloading Galaxy at the given revision.
[ "Builds", "a", "new", "DownloadProperties", "for", "downloading", "Galaxy", "at", "the", "given", "revision", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L371-L374
145,449
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
DownloadProperties.forRelease
public static DownloadProperties forRelease(final String release, final File destination) { return new DownloadProperties(new WgetGithubDownloader(release), destination); }
java
public static DownloadProperties forRelease(final String release, final File destination) { return new DownloadProperties(new WgetGithubDownloader(release), destination); }
[ "public", "static", "DownloadProperties", "forRelease", "(", "final", "String", "release", ",", "final", "File", "destination", ")", "{", "return", "new", "DownloadProperties", "(", "new", "WgetGithubDownloader", "(", "release", ")", ",", "destination", ")", ";", "}" ]
Builds a new DownloadProperties for downloading a specific Galaxy release. @param release The release to pull from GitHub (eg. "v17.01") @param destination The destination directory to store Galaxy, null if a directory should be chosen by default. @return A new DownloadProperties for downloading a specific Galaxy release.
[ "Builds", "a", "new", "DownloadProperties", "for", "downloading", "a", "specific", "Galaxy", "release", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L403-L405
145,450
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
DownloadProperties.download
void download() { final String path = location.getAbsolutePath(); logger.info("About to download Galaxy from " + downloader.toString() + " to " + path); this.downloader.downloadTo(location, cache); logger.info("Finished downloading Galaxy to " + path); }
java
void download() { final String path = location.getAbsolutePath(); logger.info("About to download Galaxy from " + downloader.toString() + " to " + path); this.downloader.downloadTo(location, cache); logger.info("Finished downloading Galaxy to " + path); }
[ "void", "download", "(", ")", "{", "final", "String", "path", "=", "location", ".", "getAbsolutePath", "(", ")", ";", "logger", ".", "info", "(", "\"About to download Galaxy from \"", "+", "downloader", ".", "toString", "(", ")", "+", "\" to \"", "+", "path", ")", ";", "this", ".", "downloader", ".", "downloadTo", "(", "location", ",", "cache", ")", ";", "logger", ".", "info", "(", "\"Finished downloading Galaxy to \"", "+", "path", ")", ";", "}" ]
Performs the download of Galaxy.
[ "Performs", "the", "download", "of", "Galaxy", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L410-L417
145,451
geomajas/geomajas-project-hammer-gwt
hammer-gwt/src/main/java/org/geomajas/hammergwt/client/event/NativeHammerEvent.java
NativeHammerEvent.getRelativeX
public final int getRelativeX() { NativeEvent e = getNativeEvent(); Element target = getTarget(); return e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft(); }
java
public final int getRelativeX() { NativeEvent e = getNativeEvent(); Element target = getTarget(); return e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft(); }
[ "public", "final", "int", "getRelativeX", "(", ")", "{", "NativeEvent", "e", "=", "getNativeEvent", "(", ")", ";", "Element", "target", "=", "getTarget", "(", ")", ";", "return", "e", ".", "getClientX", "(", ")", "-", "target", ".", "getAbsoluteLeft", "(", ")", "+", "target", ".", "getScrollLeft", "(", ")", "+", "target", ".", "getOwnerDocument", "(", ")", ".", "getScrollLeft", "(", ")", ";", "}" ]
Get relative x position on the page. @return x position in pixels
[ "Get", "relative", "x", "position", "on", "the", "page", "." ]
bc764171bed55e5a9eced72f0078ec22b8105b62
https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt/src/main/java/org/geomajas/hammergwt/client/event/NativeHammerEvent.java#L262-L268
145,452
geomajas/geomajas-project-hammer-gwt
hammer-gwt/src/main/java/org/geomajas/hammergwt/client/event/NativeHammerEvent.java
NativeHammerEvent.getRelativeY
public final int getRelativeY() { NativeEvent e = getNativeEvent(); Element target = getTarget(); return e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument().getScrollTop(); }
java
public final int getRelativeY() { NativeEvent e = getNativeEvent(); Element target = getTarget(); return e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument().getScrollTop(); }
[ "public", "final", "int", "getRelativeY", "(", ")", "{", "NativeEvent", "e", "=", "getNativeEvent", "(", ")", ";", "Element", "target", "=", "getTarget", "(", ")", ";", "return", "e", ".", "getClientY", "(", ")", "-", "target", ".", "getAbsoluteTop", "(", ")", "+", "target", ".", "getScrollTop", "(", ")", "+", "target", ".", "getOwnerDocument", "(", ")", ".", "getScrollTop", "(", ")", ";", "}" ]
Get relative y position on the page. @return x position in pixels
[ "Get", "relative", "y", "position", "on", "the", "page", "." ]
bc764171bed55e5a9eced72f0078ec22b8105b62
https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt/src/main/java/org/geomajas/hammergwt/client/event/NativeHammerEvent.java#L274-L280
145,453
dbracewell/mango
src/main/java/com/davidbracewell/conversion/CollectionConverter.java
CollectionConverter.COLLECTION
public static Function<Object, Collection<?>> COLLECTION(final Class<? extends Collection> collectionType) { return as(new CollectionConverterImpl<>(collectionType, null)); }
java
public static Function<Object, Collection<?>> COLLECTION(final Class<? extends Collection> collectionType) { return as(new CollectionConverterImpl<>(collectionType, null)); }
[ "public", "static", "Function", "<", "Object", ",", "Collection", "<", "?", ">", ">", "COLLECTION", "(", "final", "Class", "<", "?", "extends", "Collection", ">", "collectionType", ")", "{", "return", "as", "(", "new", "CollectionConverterImpl", "<>", "(", "collectionType", ",", "null", ")", ")", ";", "}" ]
Converts an object to a collection @param collectionType the collection type @return the conversion function
[ "Converts", "an", "object", "to", "a", "collection" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/CollectionConverter.java#L87-L89
145,454
dbracewell/mango
src/main/java/com/davidbracewell/conversion/CollectionConverter.java
CollectionConverter.COLLECTION
public static <T> Function<Object, Collection<T>> COLLECTION(final Class<? extends Collection> collectionType, final Class<T> componentType) { return new CollectionConverterImpl<>(collectionType, componentType); }
java
public static <T> Function<Object, Collection<T>> COLLECTION(final Class<? extends Collection> collectionType, final Class<T> componentType) { return new CollectionConverterImpl<>(collectionType, componentType); }
[ "public", "static", "<", "T", ">", "Function", "<", "Object", ",", "Collection", "<", "T", ">", ">", "COLLECTION", "(", "final", "Class", "<", "?", "extends", "Collection", ">", "collectionType", ",", "final", "Class", "<", "T", ">", "componentType", ")", "{", "return", "new", "CollectionConverterImpl", "<>", "(", "collectionType", ",", "componentType", ")", ";", "}" ]
Converts an object to a collection and converts the components as well. @param <T> the component type parameter @param collectionType the collection type @param componentType the component type @return the conversion function
[ "Converts", "an", "object", "to", "a", "collection", "and", "converts", "the", "components", "as", "well", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/CollectionConverter.java#L99-L101
145,455
poolik/classfinder
src/main/java/com/poolik/classfinder/info/ClassInfo.java
ClassInfo.setClassFields
private void setClassFields(String name, String superClassName, String[] interfaces, int asmAccessMask, File location) { this.className = translateInternalClassName(name); this.locationFound = location; if ((superClassName != null) && (!superClassName.equals("java/lang/Object"))) { this.superClassName = translateInternalClassName(superClassName); } if (interfaces != null) { this.implementedInterfaces = new String[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { this.implementedInterfaces[i] = translateInternalClassName(interfaces[i]); } } modifier = convertAccessMaskToModifierMask(asmAccessMask); }
java
private void setClassFields(String name, String superClassName, String[] interfaces, int asmAccessMask, File location) { this.className = translateInternalClassName(name); this.locationFound = location; if ((superClassName != null) && (!superClassName.equals("java/lang/Object"))) { this.superClassName = translateInternalClassName(superClassName); } if (interfaces != null) { this.implementedInterfaces = new String[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { this.implementedInterfaces[i] = translateInternalClassName(interfaces[i]); } } modifier = convertAccessMaskToModifierMask(asmAccessMask); }
[ "private", "void", "setClassFields", "(", "String", "name", ",", "String", "superClassName", ",", "String", "[", "]", "interfaces", ",", "int", "asmAccessMask", ",", "File", "location", ")", "{", "this", ".", "className", "=", "translateInternalClassName", "(", "name", ")", ";", "this", ".", "locationFound", "=", "location", ";", "if", "(", "(", "superClassName", "!=", "null", ")", "&&", "(", "!", "superClassName", ".", "equals", "(", "\"java/lang/Object\"", ")", ")", ")", "{", "this", ".", "superClassName", "=", "translateInternalClassName", "(", "superClassName", ")", ";", "}", "if", "(", "interfaces", "!=", "null", ")", "{", "this", ".", "implementedInterfaces", "=", "new", "String", "[", "interfaces", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interfaces", ".", "length", ";", "i", "++", ")", "{", "this", ".", "implementedInterfaces", "[", "i", "]", "=", "translateInternalClassName", "(", "interfaces", "[", "i", "]", ")", ";", "}", "}", "modifier", "=", "convertAccessMaskToModifierMask", "(", "asmAccessMask", ")", ";", "}" ]
Set the fields in this object. @param name the class name @param superClassName the parent class name, or null @param interfaces the names of interfaces the class implements, or null @param asmAccessMask ASM API's access mask for the class @param location File (jar, zip) or directory where class was found
[ "Set", "the", "fields", "in", "this", "object", "." ]
0544f1c702f4fe6cb4a33db2a85c48b1d93f168f
https://github.com/poolik/classfinder/blob/0544f1c702f4fe6cb4a33db2a85c48b1d93f168f/src/main/java/com/poolik/classfinder/info/ClassInfo.java#L266-L288
145,456
poolik/classfinder
src/main/java/com/poolik/classfinder/info/ClassInfo.java
ClassInfo.convertAccessMaskToModifierMask
private int convertAccessMaskToModifierMask(int asmAccessMask) { int modifier = 0; // Convert the ASM access info into Reflection API modifiers. if ((asmAccessMask & Opcodes.ACC_FINAL) != 0) modifier |= Modifier.FINAL; if ((asmAccessMask & Opcodes.ACC_NATIVE) != 0) modifier |= Modifier.NATIVE; if ((asmAccessMask & Opcodes.ACC_INTERFACE) != 0) modifier |= Modifier.INTERFACE; if ((asmAccessMask & Opcodes.ACC_ABSTRACT) != 0) modifier |= Modifier.ABSTRACT; if ((asmAccessMask & Opcodes.ACC_PRIVATE) != 0) modifier |= Modifier.PRIVATE; if ((asmAccessMask & Opcodes.ACC_PROTECTED) != 0) modifier |= Modifier.PROTECTED; if ((asmAccessMask & Opcodes.ACC_PUBLIC) != 0) modifier |= Modifier.PUBLIC; if ((asmAccessMask & Opcodes.ACC_STATIC) != 0) modifier |= Modifier.STATIC; if ((asmAccessMask & Opcodes.ACC_STRICT) != 0) modifier |= Modifier.STRICT; if ((asmAccessMask & Opcodes.ACC_SYNCHRONIZED) != 0) modifier |= Modifier.SYNCHRONIZED; if ((asmAccessMask & Opcodes.ACC_TRANSIENT) != 0) modifier |= Modifier.TRANSIENT; if ((asmAccessMask & Opcodes.ACC_VOLATILE) != 0) modifier |= Modifier.VOLATILE; return modifier; }
java
private int convertAccessMaskToModifierMask(int asmAccessMask) { int modifier = 0; // Convert the ASM access info into Reflection API modifiers. if ((asmAccessMask & Opcodes.ACC_FINAL) != 0) modifier |= Modifier.FINAL; if ((asmAccessMask & Opcodes.ACC_NATIVE) != 0) modifier |= Modifier.NATIVE; if ((asmAccessMask & Opcodes.ACC_INTERFACE) != 0) modifier |= Modifier.INTERFACE; if ((asmAccessMask & Opcodes.ACC_ABSTRACT) != 0) modifier |= Modifier.ABSTRACT; if ((asmAccessMask & Opcodes.ACC_PRIVATE) != 0) modifier |= Modifier.PRIVATE; if ((asmAccessMask & Opcodes.ACC_PROTECTED) != 0) modifier |= Modifier.PROTECTED; if ((asmAccessMask & Opcodes.ACC_PUBLIC) != 0) modifier |= Modifier.PUBLIC; if ((asmAccessMask & Opcodes.ACC_STATIC) != 0) modifier |= Modifier.STATIC; if ((asmAccessMask & Opcodes.ACC_STRICT) != 0) modifier |= Modifier.STRICT; if ((asmAccessMask & Opcodes.ACC_SYNCHRONIZED) != 0) modifier |= Modifier.SYNCHRONIZED; if ((asmAccessMask & Opcodes.ACC_TRANSIENT) != 0) modifier |= Modifier.TRANSIENT; if ((asmAccessMask & Opcodes.ACC_VOLATILE) != 0) modifier |= Modifier.VOLATILE; return modifier; }
[ "private", "int", "convertAccessMaskToModifierMask", "(", "int", "asmAccessMask", ")", "{", "int", "modifier", "=", "0", ";", "// Convert the ASM access info into Reflection API modifiers.", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_FINAL", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "FINAL", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_NATIVE", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "NATIVE", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_INTERFACE", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "INTERFACE", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_ABSTRACT", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "ABSTRACT", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_PRIVATE", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "PRIVATE", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_PROTECTED", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "PROTECTED", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_PUBLIC", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "PUBLIC", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_STATIC", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "STATIC", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_STRICT", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "STRICT", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_SYNCHRONIZED", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "SYNCHRONIZED", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_TRANSIENT", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "TRANSIENT", ";", "if", "(", "(", "asmAccessMask", "&", "Opcodes", ".", "ACC_VOLATILE", ")", "!=", "0", ")", "modifier", "|=", "Modifier", ".", "VOLATILE", ";", "return", "modifier", ";", "}" ]
Convert an ASM access mask to a reflection Modifier mask. @param asmAccessMask the ASM access mask @return the Modifier mask
[ "Convert", "an", "ASM", "access", "mask", "to", "a", "reflection", "Modifier", "mask", "." ]
0544f1c702f4fe6cb4a33db2a85c48b1d93f168f
https://github.com/poolik/classfinder/blob/0544f1c702f4fe6cb4a33db2a85c48b1d93f168f/src/main/java/com/poolik/classfinder/info/ClassInfo.java#L296-L338
145,457
triceo/splitlog
splitlog-core/src/main/java/com/github/triceo/splitlog/expectations/AbstractExpectation.java
AbstractExpectation.call
@Override public Message call() throws InterruptedException { AbstractExpectation.LOGGER.info("Thread blocked waiting for message to pass condition {}.", this.getBlockingCondition()); try { this.latch.await(); this.manager.unsetExpectation(this); AbstractExpectation.LOGGER.info("Condition passed."); if (this.actionFuture != null) { this.waitUntilActionComplete(); } AbstractExpectation.LOGGER.info("Expectation processing passed."); return this.stash; } finally { this.manager.unsetExpectation(this); // in case await() throws this.actionFuture = null; AbstractExpectation.LOGGER.info("Thread unblocked."); } }
java
@Override public Message call() throws InterruptedException { AbstractExpectation.LOGGER.info("Thread blocked waiting for message to pass condition {}.", this.getBlockingCondition()); try { this.latch.await(); this.manager.unsetExpectation(this); AbstractExpectation.LOGGER.info("Condition passed."); if (this.actionFuture != null) { this.waitUntilActionComplete(); } AbstractExpectation.LOGGER.info("Expectation processing passed."); return this.stash; } finally { this.manager.unsetExpectation(this); // in case await() throws this.actionFuture = null; AbstractExpectation.LOGGER.info("Thread unblocked."); } }
[ "@", "Override", "public", "Message", "call", "(", ")", "throws", "InterruptedException", "{", "AbstractExpectation", ".", "LOGGER", ".", "info", "(", "\"Thread blocked waiting for message to pass condition {}.\"", ",", "this", ".", "getBlockingCondition", "(", ")", ")", ";", "try", "{", "this", ".", "latch", ".", "await", "(", ")", ";", "this", ".", "manager", ".", "unsetExpectation", "(", "this", ")", ";", "AbstractExpectation", ".", "LOGGER", ".", "info", "(", "\"Condition passed.\"", ")", ";", "if", "(", "this", ".", "actionFuture", "!=", "null", ")", "{", "this", ".", "waitUntilActionComplete", "(", ")", ";", "}", "AbstractExpectation", ".", "LOGGER", ".", "info", "(", "\"Expectation processing passed.\"", ")", ";", "return", "this", ".", "stash", ";", "}", "finally", "{", "this", ".", "manager", ".", "unsetExpectation", "(", "this", ")", ";", "// in case await() throws", "this", ".", "actionFuture", "=", "null", ";", "AbstractExpectation", ".", "LOGGER", ".", "info", "(", "\"Thread unblocked.\"", ")", ";", "}", "}" ]
Will start the wait for the condition to become true.
[ "Will", "start", "the", "wait", "for", "the", "condition", "to", "become", "true", "." ]
4e1b188e8c814119f5cf7343bbc53917843d68a2
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/expectations/AbstractExpectation.java#L53-L71
145,458
geomajas/geomajas-project-hammer-gwt
hammer-gwt-example/src/main/java/org/geomajas/hammergwt/example/server/RemoteSLF4j.java
RemoteSLF4j.logOnServer
public final String logOnServer(LogRecord lr) { String strongName = getPermutationStrongName(); /*RemoteLoggingServiceUtil.logOnServer( lr, strongName, deobfuscator, loggerNameOverride);*/ logger.error(lr.getMessage()); return null; }
java
public final String logOnServer(LogRecord lr) { String strongName = getPermutationStrongName(); /*RemoteLoggingServiceUtil.logOnServer( lr, strongName, deobfuscator, loggerNameOverride);*/ logger.error(lr.getMessage()); return null; }
[ "public", "final", "String", "logOnServer", "(", "LogRecord", "lr", ")", "{", "String", "strongName", "=", "getPermutationStrongName", "(", ")", ";", "/*RemoteLoggingServiceUtil.logOnServer(\n\t\t\t\tlr, strongName, deobfuscator, loggerNameOverride);*/", "logger", ".", "error", "(", "lr", ".", "getMessage", "(", ")", ")", ";", "return", "null", ";", "}" ]
Logs a Log Record which has been serialized using GWT RPC on the server. @return either an error message, or null if logging is successful.
[ "Logs", "a", "Log", "Record", "which", "has", "been", "serialized", "using", "GWT", "RPC", "on", "the", "server", "." ]
bc764171bed55e5a9eced72f0078ec22b8105b62
https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt-example/src/main/java/org/geomajas/hammergwt/example/server/RemoteSLF4j.java#L41-L49
145,459
geomajas/geomajas-project-hammer-gwt
hammer-gwt-example/src/main/java/org/geomajas/hammergwt/example/server/RemoteSLF4j.java
RemoteSLF4j.setSymbolMapsDirectory
public void setSymbolMapsDirectory(String symbolMapsDir) { if (deobfuscator == null) { deobfuscator = new StackTraceDeobfuscator(symbolMapsDir); } else { deobfuscator.setSymbolMapsDirectory(symbolMapsDir); } }
java
public void setSymbolMapsDirectory(String symbolMapsDir) { if (deobfuscator == null) { deobfuscator = new StackTraceDeobfuscator(symbolMapsDir); } else { deobfuscator.setSymbolMapsDirectory(symbolMapsDir); } }
[ "public", "void", "setSymbolMapsDirectory", "(", "String", "symbolMapsDir", ")", "{", "if", "(", "deobfuscator", "==", "null", ")", "{", "deobfuscator", "=", "new", "StackTraceDeobfuscator", "(", "symbolMapsDir", ")", ";", "}", "else", "{", "deobfuscator", ".", "setSymbolMapsDirectory", "(", "symbolMapsDir", ")", ";", "}", "}" ]
By default, this service does not do any deobfuscation. In order to do server side deobfuscation, you must copy the symbolMaps files to a directory visible to the server and set the directory using this method. @param symbolMapsDir
[ "By", "default", "this", "service", "does", "not", "do", "any", "deobfuscation", ".", "In", "order", "to", "do", "server", "side", "deobfuscation", "you", "must", "copy", "the", "symbolMaps", "files", "to", "a", "directory", "visible", "to", "the", "server", "and", "set", "the", "directory", "using", "this", "method", "." ]
bc764171bed55e5a9eced72f0078ec22b8105b62
https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt-example/src/main/java/org/geomajas/hammergwt/example/server/RemoteSLF4j.java#L67-L73
145,460
josueeduardo/snappy
snappy/src/main/java/io/joshworks/snappy/handler/HandlerUtil.java
HandlerUtil.removePathTemplate
public static String[] removePathTemplate(List<MappedEndpoint> mappedEndpoints) { return mappedEndpoints.stream() .filter(me -> !me.type.equals(MappedEndpoint.Type.STATIC)) .map(me -> { int idx = me.url.indexOf("/{"); return idx >= 0 ? me.url.substring(0, idx) : me.url; }) .distinct().toArray(String[]::new); }
java
public static String[] removePathTemplate(List<MappedEndpoint> mappedEndpoints) { return mappedEndpoints.stream() .filter(me -> !me.type.equals(MappedEndpoint.Type.STATIC)) .map(me -> { int idx = me.url.indexOf("/{"); return idx >= 0 ? me.url.substring(0, idx) : me.url; }) .distinct().toArray(String[]::new); }
[ "public", "static", "String", "[", "]", "removePathTemplate", "(", "List", "<", "MappedEndpoint", ">", "mappedEndpoints", ")", "{", "return", "mappedEndpoints", ".", "stream", "(", ")", ".", "filter", "(", "me", "->", "!", "me", ".", "type", ".", "equals", "(", "MappedEndpoint", ".", "Type", ".", "STATIC", ")", ")", ".", "map", "(", "me", "->", "{", "int", "idx", "=", "me", ".", "url", ".", "indexOf", "(", "\"/{\"", ")", ";", "return", "idx", ">=", "0", "?", "me", ".", "url", ".", "substring", "(", "0", ",", "idx", ")", ":", "me", ".", "url", ";", "}", ")", ".", "distinct", "(", ")", ".", "toArray", "(", "String", "[", "]", "::", "new", ")", ";", "}" ]
best effort to resolve url that may be unique
[ "best", "effort", "to", "resolve", "url", "that", "may", "be", "unique" ]
d95a9e811eda3c24a5e53086369208819884fa49
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/snappy/src/main/java/io/joshworks/snappy/handler/HandlerUtil.java#L233-L242
145,461
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/movement/ShanksAgentMovementCapability.java
ShanksAgentMovementCapability.normalizeDouble3D
private static Double3D normalizeDouble3D(Double3D vector) { double invertedlen = 1.0D / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); if ((invertedlen == (1.0D / 0.0D)) || (invertedlen == (-1.0D / 0.0D)) || (invertedlen == 0.0D) || (invertedlen != invertedlen)) throw new ArithmeticException("Vector length is " + Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z) + ", cannot normalize"); return new Double3D(vector.x * invertedlen, vector.y * invertedlen, vector.z * invertedlen); }
java
private static Double3D normalizeDouble3D(Double3D vector) { double invertedlen = 1.0D / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); if ((invertedlen == (1.0D / 0.0D)) || (invertedlen == (-1.0D / 0.0D)) || (invertedlen == 0.0D) || (invertedlen != invertedlen)) throw new ArithmeticException("Vector length is " + Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z) + ", cannot normalize"); return new Double3D(vector.x * invertedlen, vector.y * invertedlen, vector.z * invertedlen); }
[ "private", "static", "Double3D", "normalizeDouble3D", "(", "Double3D", "vector", ")", "{", "double", "invertedlen", "=", "1.0D", "/", "Math", ".", "sqrt", "(", "vector", ".", "x", "*", "vector", ".", "x", "+", "vector", ".", "y", "*", "vector", ".", "y", "+", "vector", ".", "z", "*", "vector", ".", "z", ")", ";", "if", "(", "(", "invertedlen", "==", "(", "1.0D", "/", "0.0D", ")", ")", "||", "(", "invertedlen", "==", "(", "-", "1.0D", "/", "0.0D", ")", ")", "||", "(", "invertedlen", "==", "0.0D", ")", "||", "(", "invertedlen", "!=", "invertedlen", ")", ")", "throw", "new", "ArithmeticException", "(", "\"Vector length is \"", "+", "Math", ".", "sqrt", "(", "vector", ".", "x", "*", "vector", ".", "x", "+", "vector", ".", "y", "*", "vector", ".", "y", "+", "vector", ".", "z", "*", "vector", ".", "z", ")", "+", "\", cannot normalize\"", ")", ";", "return", "new", "Double3D", "(", "vector", ".", "x", "*", "invertedlen", ",", "vector", ".", "y", "*", "invertedlen", ",", "vector", ".", "z", "*", "invertedlen", ")", ";", "}" ]
Normalize a Double3D object @param vector @return the normalized vector
[ "Normalize", "a", "Double3D", "object" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/movement/ShanksAgentMovementCapability.java#L194-L204
145,462
jmchilton/galaxy-bootstrap
src/main/java/com/github/jmchilton/galaxybootstrap/IoUtils.java
IoUtils.findFreePort
public static int findFreePort() { ServerSocket socket = null; try { socket = new ServerSocket(0); socket.setReuseAddress(true); int port = socket.getLocalPort(); try { socket.close(); } catch(IOException e) { // Ignore IOException on close() } return port; } catch(IOException e) { } finally { if(socket != null) { try { socket.close(); } catch(IOException e) { } } } throw new IllegalStateException("Could not find a free TCP/IP port to start Galaxy on"); }
java
public static int findFreePort() { ServerSocket socket = null; try { socket = new ServerSocket(0); socket.setReuseAddress(true); int port = socket.getLocalPort(); try { socket.close(); } catch(IOException e) { // Ignore IOException on close() } return port; } catch(IOException e) { } finally { if(socket != null) { try { socket.close(); } catch(IOException e) { } } } throw new IllegalStateException("Could not find a free TCP/IP port to start Galaxy on"); }
[ "public", "static", "int", "findFreePort", "(", ")", "{", "ServerSocket", "socket", "=", "null", ";", "try", "{", "socket", "=", "new", "ServerSocket", "(", "0", ")", ";", "socket", ".", "setReuseAddress", "(", "true", ")", ";", "int", "port", "=", "socket", ".", "getLocalPort", "(", ")", ";", "try", "{", "socket", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// Ignore IOException on close()", "}", "return", "port", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "finally", "{", "if", "(", "socket", "!=", "null", ")", "{", "try", "{", "socket", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "throw", "new", "IllegalStateException", "(", "\"Could not find a free TCP/IP port to start Galaxy on\"", ")", ";", "}" ]
Returns a free port number on localhost. Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this). Slightly improved with close() missing in JDT. And throws exception instead of returning -1. https://gist.github.com/vorburger/3429822 @return a free port number on localhost @throws IllegalStateException if unable to find a free port
[ "Returns", "a", "free", "port", "number", "on", "localhost", "." ]
4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/IoUtils.java#L28-L50
145,463
fuinorg/utils4j
src/main/java/org/fuin/utils4j/JandexUtils.java
JandexUtils.indexClassFile
public static boolean indexClassFile(final Indexer indexer, final List<File> knownFiles, final File classFile) { if (knownFiles.contains(classFile)) { return false; } knownFiles.add(classFile); try (final InputStream in = classFile.toURI().toURL().openStream()) { indexer.index(in); } catch (final IOException ex) { throw new RuntimeException("Error indexing file: " + classFile, ex); } return true; }
java
public static boolean indexClassFile(final Indexer indexer, final List<File> knownFiles, final File classFile) { if (knownFiles.contains(classFile)) { return false; } knownFiles.add(classFile); try (final InputStream in = classFile.toURI().toURL().openStream()) { indexer.index(in); } catch (final IOException ex) { throw new RuntimeException("Error indexing file: " + classFile, ex); } return true; }
[ "public", "static", "boolean", "indexClassFile", "(", "final", "Indexer", "indexer", ",", "final", "List", "<", "File", ">", "knownFiles", ",", "final", "File", "classFile", ")", "{", "if", "(", "knownFiles", ".", "contains", "(", "classFile", ")", ")", "{", "return", "false", ";", "}", "knownFiles", ".", "add", "(", "classFile", ")", ";", "try", "(", "final", "InputStream", "in", "=", "classFile", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ".", "openStream", "(", ")", ")", "{", "indexer", ".", "index", "(", "in", ")", ";", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error indexing file: \"", "+", "classFile", ",", "ex", ")", ";", "}", "return", "true", ";", "}" ]
Indexes a single file, except it was already analyzed. @param indexer Indexer to use. @param knownFiles List of files already analyzed. New files will be added within this method. @param classFile Class file to analyze. @return TRUE if the file was indexed or FALSE if it was ignored.
[ "Indexes", "a", "single", "file", "except", "it", "was", "already", "analyzed", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/JandexUtils.java#L55-L69
145,464
fuinorg/utils4j
src/main/java/org/fuin/utils4j/JandexUtils.java
JandexUtils.indexDir
public static void indexDir(final Indexer indexer, final List<File> knownFiles, final File dir) { final List<File> classes = Utils4J.pathsFiles(dir.getPath(), Utils4J::classFile); for (final File file : classes) { indexClassFile(indexer, knownFiles, file); } }
java
public static void indexDir(final Indexer indexer, final List<File> knownFiles, final File dir) { final List<File> classes = Utils4J.pathsFiles(dir.getPath(), Utils4J::classFile); for (final File file : classes) { indexClassFile(indexer, knownFiles, file); } }
[ "public", "static", "void", "indexDir", "(", "final", "Indexer", "indexer", ",", "final", "List", "<", "File", ">", "knownFiles", ",", "final", "File", "dir", ")", "{", "final", "List", "<", "File", ">", "classes", "=", "Utils4J", ".", "pathsFiles", "(", "dir", ".", "getPath", "(", ")", ",", "Utils4J", "::", "classFile", ")", ";", "for", "(", "final", "File", "file", ":", "classes", ")", "{", "indexClassFile", "(", "indexer", ",", "knownFiles", ",", "file", ")", ";", "}", "}" ]
Indexes all classes in a directory or it's sub directories. @param indexer Indexer to use. @param knownFiles List of files already analyzed. New files will be added within this method. @param dir Directory to analyze.
[ "Indexes", "all", "classes", "in", "a", "directory", "or", "it", "s", "sub", "directories", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/JandexUtils.java#L81-L86
145,465
fuinorg/utils4j
src/main/java/org/fuin/utils4j/JandexUtils.java
JandexUtils.indexJar
public static boolean indexJar(final Indexer indexer, final List<File> knownFiles, final File jarFile) { if (knownFiles.contains(jarFile)) { return false; } knownFiles.add(jarFile); try (final JarFile jar = new JarFile(jarFile)) { final Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { try (final InputStream stream = jar.getInputStream(entry)) { indexer.index(stream); } catch (final IOException ex) { throw new RuntimeException("Error indexing " + entry.getName() + " in " + jarFile, ex); } } } } catch (final IOException ex) { throw new RuntimeException("Error indexing " + jarFile, ex); } return true; }
java
public static boolean indexJar(final Indexer indexer, final List<File> knownFiles, final File jarFile) { if (knownFiles.contains(jarFile)) { return false; } knownFiles.add(jarFile); try (final JarFile jar = new JarFile(jarFile)) { final Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { try (final InputStream stream = jar.getInputStream(entry)) { indexer.index(stream); } catch (final IOException ex) { throw new RuntimeException("Error indexing " + entry.getName() + " in " + jarFile, ex); } } } } catch (final IOException ex) { throw new RuntimeException("Error indexing " + jarFile, ex); } return true; }
[ "public", "static", "boolean", "indexJar", "(", "final", "Indexer", "indexer", ",", "final", "List", "<", "File", ">", "knownFiles", ",", "final", "File", "jarFile", ")", "{", "if", "(", "knownFiles", ".", "contains", "(", "jarFile", ")", ")", "{", "return", "false", ";", "}", "knownFiles", ".", "add", "(", "jarFile", ")", ";", "try", "(", "final", "JarFile", "jar", "=", "new", "JarFile", "(", "jarFile", ")", ")", "{", "final", "Enumeration", "<", "JarEntry", ">", "entries", "=", "jar", ".", "entries", "(", ")", ";", "while", "(", "entries", ".", "hasMoreElements", "(", ")", ")", "{", "final", "JarEntry", "entry", "=", "entries", ".", "nextElement", "(", ")", ";", "if", "(", "entry", ".", "getName", "(", ")", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "try", "(", "final", "InputStream", "stream", "=", "jar", ".", "getInputStream", "(", "entry", ")", ")", "{", "indexer", ".", "index", "(", "stream", ")", ";", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error indexing \"", "+", "entry", ".", "getName", "(", ")", "+", "\" in \"", "+", "jarFile", ",", "ex", ")", ";", "}", "}", "}", "}", "catch", "(", "final", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error indexing \"", "+", "jarFile", ",", "ex", ")", ";", "}", "return", "true", ";", "}" ]
Indexes a single JAR, except it was already analyzed. @param indexer Indexer to use. @param knownFiles List of files already analyzed. New files will be added within this method. @param jarFile JAR to analyze. @return TRUE if the JAR was indexed or FALSE if it was ignored.
[ "Indexes", "a", "single", "JAR", "except", "it", "was", "already", "analyzed", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/JandexUtils.java#L100-L125
145,466
Mthwate/DatLib
src/main/java/com/mthwate/datlib/ImageUtils.java
ImageUtils.totalImageDiff
public static long totalImageDiff(BufferedImage img1, BufferedImage img2) { int width = img1.getWidth(); int height = img1.getHeight(); if ((width != img2.getWidth()) || (height != img2.getHeight())) { throw new IllegalArgumentException("Image dimensions do not match"); } long diff = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int rgb1 = img1.getRGB(x, y); int rgb2 = img2.getRGB(x, y); int a1 = ColorUtils.getAlpha(rgb1); int r1 = ColorUtils.getRed(rgb1); int g1 = ColorUtils.getGreen(rgb1); int b1 = ColorUtils.getBlue(rgb1); int a2 = ColorUtils.getAlpha(rgb2); int r2 = ColorUtils.getRed(rgb2); int g2 = ColorUtils.getGreen(rgb2); int b2 = ColorUtils.getBlue(rgb2); diff += Math.abs(a1 - a2); diff += Math.abs(r1 - r2); diff += Math.abs(g1 - g2); diff += Math.abs(b1 - b2); } } return diff; }
java
public static long totalImageDiff(BufferedImage img1, BufferedImage img2) { int width = img1.getWidth(); int height = img1.getHeight(); if ((width != img2.getWidth()) || (height != img2.getHeight())) { throw new IllegalArgumentException("Image dimensions do not match"); } long diff = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int rgb1 = img1.getRGB(x, y); int rgb2 = img2.getRGB(x, y); int a1 = ColorUtils.getAlpha(rgb1); int r1 = ColorUtils.getRed(rgb1); int g1 = ColorUtils.getGreen(rgb1); int b1 = ColorUtils.getBlue(rgb1); int a2 = ColorUtils.getAlpha(rgb2); int r2 = ColorUtils.getRed(rgb2); int g2 = ColorUtils.getGreen(rgb2); int b2 = ColorUtils.getBlue(rgb2); diff += Math.abs(a1 - a2); diff += Math.abs(r1 - r2); diff += Math.abs(g1 - g2); diff += Math.abs(b1 - b2); } } return diff; }
[ "public", "static", "long", "totalImageDiff", "(", "BufferedImage", "img1", ",", "BufferedImage", "img2", ")", "{", "int", "width", "=", "img1", ".", "getWidth", "(", ")", ";", "int", "height", "=", "img1", ".", "getHeight", "(", ")", ";", "if", "(", "(", "width", "!=", "img2", ".", "getWidth", "(", ")", ")", "||", "(", "height", "!=", "img2", ".", "getHeight", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Image dimensions do not match\"", ")", ";", "}", "long", "diff", "=", "0", ";", "for", "(", "int", "x", "=", "0", ";", "x", "<", "width", ";", "x", "++", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "height", ";", "y", "++", ")", "{", "int", "rgb1", "=", "img1", ".", "getRGB", "(", "x", ",", "y", ")", ";", "int", "rgb2", "=", "img2", ".", "getRGB", "(", "x", ",", "y", ")", ";", "int", "a1", "=", "ColorUtils", ".", "getAlpha", "(", "rgb1", ")", ";", "int", "r1", "=", "ColorUtils", ".", "getRed", "(", "rgb1", ")", ";", "int", "g1", "=", "ColorUtils", ".", "getGreen", "(", "rgb1", ")", ";", "int", "b1", "=", "ColorUtils", ".", "getBlue", "(", "rgb1", ")", ";", "int", "a2", "=", "ColorUtils", ".", "getAlpha", "(", "rgb2", ")", ";", "int", "r2", "=", "ColorUtils", ".", "getRed", "(", "rgb2", ")", ";", "int", "g2", "=", "ColorUtils", ".", "getGreen", "(", "rgb2", ")", ";", "int", "b2", "=", "ColorUtils", ".", "getBlue", "(", "rgb2", ")", ";", "diff", "+=", "Math", ".", "abs", "(", "a1", "-", "a2", ")", ";", "diff", "+=", "Math", ".", "abs", "(", "r1", "-", "r2", ")", ";", "diff", "+=", "Math", ".", "abs", "(", "g1", "-", "g2", ")", ";", "diff", "+=", "Math", ".", "abs", "(", "b1", "-", "b2", ")", ";", "}", "}", "return", "diff", ";", "}" ]
The total difference between two images calculated as the sum of the difference in RGB values of each pixel the images MUST be the same dimensions. @since 1.2 @param img1 the first image to be compared @param img2 the second image to be compared @return the difference between the two images
[ "The", "total", "difference", "between", "two", "images", "calculated", "as", "the", "sum", "of", "the", "difference", "in", "RGB", "values", "of", "each", "pixel", "the", "images", "MUST", "be", "the", "same", "dimensions", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/ImageUtils.java#L21-L51
145,467
devcon5io/common
classutils/src/main/java/io/devcon5/classutils/TypeConverter.java
TypeConverter.to
public <T> T to(Class<T> targetType) { if (targetType == String.class) { return (T) value; } try { final String methodName; final Class type; if (targetType.isPrimitive()) { final String typeName = targetType.getSimpleName(); methodName = "parse" + typeName.substring(0, 1).toUpperCase() + typeName.substring(1); type = PRIMITIVE_TO_OBJECT_TYPE_MAP.get(targetType); } else { methodName = "valueOf"; type = targetType; } return (T) type.getMethod(methodName, String.class).invoke(null, value); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Could not convert value '" + value + "' to type " + targetType.getName(), e); } }
java
public <T> T to(Class<T> targetType) { if (targetType == String.class) { return (T) value; } try { final String methodName; final Class type; if (targetType.isPrimitive()) { final String typeName = targetType.getSimpleName(); methodName = "parse" + typeName.substring(0, 1).toUpperCase() + typeName.substring(1); type = PRIMITIVE_TO_OBJECT_TYPE_MAP.get(targetType); } else { methodName = "valueOf"; type = targetType; } return (T) type.getMethod(methodName, String.class).invoke(null, value); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Could not convert value '" + value + "' to type " + targetType.getName(), e); } }
[ "public", "<", "T", ">", "T", "to", "(", "Class", "<", "T", ">", "targetType", ")", "{", "if", "(", "targetType", "==", "String", ".", "class", ")", "{", "return", "(", "T", ")", "value", ";", "}", "try", "{", "final", "String", "methodName", ";", "final", "Class", "type", ";", "if", "(", "targetType", ".", "isPrimitive", "(", ")", ")", "{", "final", "String", "typeName", "=", "targetType", ".", "getSimpleName", "(", ")", ";", "methodName", "=", "\"parse\"", "+", "typeName", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "typeName", ".", "substring", "(", "1", ")", ";", "type", "=", "PRIMITIVE_TO_OBJECT_TYPE_MAP", ".", "get", "(", "targetType", ")", ";", "}", "else", "{", "methodName", "=", "\"valueOf\"", ";", "type", "=", "targetType", ";", "}", "return", "(", "T", ")", "type", ".", "getMethod", "(", "methodName", ",", "String", ".", "class", ")", ".", "invoke", "(", "null", ",", "value", ")", ";", "}", "catch", "(", "NoSuchMethodException", "|", "InvocationTargetException", "|", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not convert value '\"", "+", "value", "+", "\"' to type \"", "+", "targetType", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}" ]
Converts the underlying string value to a primitive value. @param targetType the type into which the string value should be converted. @param <T> the type of the target type @return the converted value.
[ "Converts", "the", "underlying", "string", "value", "to", "a", "primitive", "value", "." ]
363688e0dc904d559682bf796bd6c836b4e0efc7
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/TypeConverter.java#L75-L94
145,468
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/creation/CreationShanksAgentCapability.java
CreationShanksAgentCapability.addNewAgent
public static void addNewAgent(ShanksSimulation sim, ShanksAgent agent) throws ShanksException { sim.registerShanksAgent(agent); if (sim.schedule.getTime() < 0) { sim.schedule.scheduleRepeating(Schedule.EPOCH, 2, agent, 1); } else { sim.schedule.scheduleRepeating(sim.schedule.getTime(), 2, agent, 1); } sim.logger .info("Added a new agent to the simulation: " + agent.getID()); }
java
public static void addNewAgent(ShanksSimulation sim, ShanksAgent agent) throws ShanksException { sim.registerShanksAgent(agent); if (sim.schedule.getTime() < 0) { sim.schedule.scheduleRepeating(Schedule.EPOCH, 2, agent, 1); } else { sim.schedule.scheduleRepeating(sim.schedule.getTime(), 2, agent, 1); } sim.logger .info("Added a new agent to the simulation: " + agent.getID()); }
[ "public", "static", "void", "addNewAgent", "(", "ShanksSimulation", "sim", ",", "ShanksAgent", "agent", ")", "throws", "ShanksException", "{", "sim", ".", "registerShanksAgent", "(", "agent", ")", ";", "if", "(", "sim", ".", "schedule", ".", "getTime", "(", ")", "<", "0", ")", "{", "sim", ".", "schedule", ".", "scheduleRepeating", "(", "Schedule", ".", "EPOCH", ",", "2", ",", "agent", ",", "1", ")", ";", "}", "else", "{", "sim", ".", "schedule", ".", "scheduleRepeating", "(", "sim", ".", "schedule", ".", "getTime", "(", ")", ",", "2", ",", "agent", ",", "1", ")", ";", "}", "sim", ".", "logger", ".", "info", "(", "\"Added a new agent to the simulation: \"", "+", "agent", ".", "getID", "(", ")", ")", ";", "}" ]
Adds an agent to the simulation @param sim - The shanks simulation @param agent - The new agent @throws DuplicatedAgentIDException
[ "Adds", "an", "agent", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/creation/CreationShanksAgentCapability.java#L48-L58
145,469
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/creation/CreationShanksAgentCapability.java
CreationShanksAgentCapability.removeAgent
public static void removeAgent(ShanksSimulation sim, String agentID) throws ShanksException { sim.logger.info("Stoppable not fount. Attempting direct stop..."); sim.unregisterShanksAgent(agentID); sim.logger.info("Agent " + agentID + " stopped."); }
java
public static void removeAgent(ShanksSimulation sim, String agentID) throws ShanksException { sim.logger.info("Stoppable not fount. Attempting direct stop..."); sim.unregisterShanksAgent(agentID); sim.logger.info("Agent " + agentID + " stopped."); }
[ "public", "static", "void", "removeAgent", "(", "ShanksSimulation", "sim", ",", "String", "agentID", ")", "throws", "ShanksException", "{", "sim", ".", "logger", ".", "info", "(", "\"Stoppable not fount. Attempting direct stop...\"", ")", ";", "sim", ".", "unregisterShanksAgent", "(", "agentID", ")", ";", "sim", ".", "logger", ".", "info", "(", "\"Agent \"", "+", "agentID", "+", "\" stopped.\"", ")", ";", "}" ]
"Removes" an agent with the given name from the simulation Be careful: what this actually do is to stop the agent execution. @param sim -The Shanks Simulation @param agentID - The name of the agent to remove @throws ShanksException An UnkownAgentException if the Agent ID is not found on the simulation.
[ "Removes", "an", "agent", "with", "the", "given", "name", "from", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/creation/CreationShanksAgentCapability.java#L73-L78
145,470
theisenp/harbor
src/main/java/com/theisenp/harbor/lcm/Subscriber.java
Subscriber.clear
public synchronized void clear() { peers.clear(); for(Future<?> timeout : timeouts.values()) { timeout.cancel(true); } timeouts.clear(); }
java
public synchronized void clear() { peers.clear(); for(Future<?> timeout : timeouts.values()) { timeout.cancel(true); } timeouts.clear(); }
[ "public", "synchronized", "void", "clear", "(", ")", "{", "peers", ".", "clear", "(", ")", ";", "for", "(", "Future", "<", "?", ">", "timeout", ":", "timeouts", ".", "values", "(", ")", ")", "{", "timeout", ".", "cancel", "(", "true", ")", ";", "}", "timeouts", ".", "clear", "(", ")", ";", "}" ]
Clear all known peers
[ "Clear", "all", "known", "peers" ]
59a6d373a709e10ddf0945475b95394f3f7a8254
https://github.com/theisenp/harbor/blob/59a6d373a709e10ddf0945475b95394f3f7a8254/src/main/java/com/theisenp/harbor/lcm/Subscriber.java#L74-L80
145,471
theisenp/harbor
src/main/java/com/theisenp/harbor/lcm/Subscriber.java
Subscriber.notifyConnected
private void notifyConnected(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onConnected(peer); } }
java
private void notifyConnected(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onConnected(peer); } }
[ "private", "void", "notifyConnected", "(", "Peer", "peer", ")", "{", "for", "(", "Listener", "listener", ":", "new", "HashSet", "<>", "(", "listeners", ")", ")", "{", "listener", ".", "onConnected", "(", "peer", ")", ";", "}", "}" ]
Notifies all registered listeners of the connected peer
[ "Notifies", "all", "registered", "listeners", "of", "the", "connected", "peer" ]
59a6d373a709e10ddf0945475b95394f3f7a8254
https://github.com/theisenp/harbor/blob/59a6d373a709e10ddf0945475b95394f3f7a8254/src/main/java/com/theisenp/harbor/lcm/Subscriber.java#L146-L150
145,472
theisenp/harbor
src/main/java/com/theisenp/harbor/lcm/Subscriber.java
Subscriber.notifyActive
private void notifyActive(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onActive(peer); } }
java
private void notifyActive(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onActive(peer); } }
[ "private", "void", "notifyActive", "(", "Peer", "peer", ")", "{", "for", "(", "Listener", "listener", ":", "new", "HashSet", "<>", "(", "listeners", ")", ")", "{", "listener", ".", "onActive", "(", "peer", ")", ";", "}", "}" ]
Notifies all registered listeners of the active peer
[ "Notifies", "all", "registered", "listeners", "of", "the", "active", "peer" ]
59a6d373a709e10ddf0945475b95394f3f7a8254
https://github.com/theisenp/harbor/blob/59a6d373a709e10ddf0945475b95394f3f7a8254/src/main/java/com/theisenp/harbor/lcm/Subscriber.java#L155-L159
145,473
theisenp/harbor
src/main/java/com/theisenp/harbor/lcm/Subscriber.java
Subscriber.notifyInactive
private void notifyInactive(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onInactive(peer); } }
java
private void notifyInactive(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onInactive(peer); } }
[ "private", "void", "notifyInactive", "(", "Peer", "peer", ")", "{", "for", "(", "Listener", "listener", ":", "new", "HashSet", "<>", "(", "listeners", ")", ")", "{", "listener", ".", "onInactive", "(", "peer", ")", ";", "}", "}" ]
Notifies all registered listeners of the inactive peer
[ "Notifies", "all", "registered", "listeners", "of", "the", "inactive", "peer" ]
59a6d373a709e10ddf0945475b95394f3f7a8254
https://github.com/theisenp/harbor/blob/59a6d373a709e10ddf0945475b95394f3f7a8254/src/main/java/com/theisenp/harbor/lcm/Subscriber.java#L164-L168
145,474
theisenp/harbor
src/main/java/com/theisenp/harbor/lcm/Subscriber.java
Subscriber.notifyDisconnected
private void notifyDisconnected(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onDisconnected(peer); } }
java
private void notifyDisconnected(Peer peer) { for(Listener listener : new HashSet<>(listeners)) { listener.onDisconnected(peer); } }
[ "private", "void", "notifyDisconnected", "(", "Peer", "peer", ")", "{", "for", "(", "Listener", "listener", ":", "new", "HashSet", "<>", "(", "listeners", ")", ")", "{", "listener", ".", "onDisconnected", "(", "peer", ")", ";", "}", "}" ]
Notifies all registered listeners of the disconnected peer
[ "Notifies", "all", "registered", "listeners", "of", "the", "disconnected", "peer" ]
59a6d373a709e10ddf0945475b95394f3f7a8254
https://github.com/theisenp/harbor/blob/59a6d373a709e10ddf0945475b95394f3f7a8254/src/main/java/com/theisenp/harbor/lcm/Subscriber.java#L173-L177
145,475
fuinorg/utils4j
src/main/java/org/fuin/utils4j/filter/TokenFilter.java
TokenFilter.complies
protected final boolean complies(final String value, final String constValue, final String separators) { if (value == null) { return false; } else { final StringTokenizer tok = new StringTokenizer(value, separators); while (tok.hasMoreTokens()) { final String t = tok.nextToken(); if (t.equals(constValue)) { return true; } } return false; } }
java
protected final boolean complies(final String value, final String constValue, final String separators) { if (value == null) { return false; } else { final StringTokenizer tok = new StringTokenizer(value, separators); while (tok.hasMoreTokens()) { final String t = tok.nextToken(); if (t.equals(constValue)) { return true; } } return false; } }
[ "protected", "final", "boolean", "complies", "(", "final", "String", "value", ",", "final", "String", "constValue", ",", "final", "String", "separators", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "false", ";", "}", "else", "{", "final", "StringTokenizer", "tok", "=", "new", "StringTokenizer", "(", "value", ",", "separators", ")", ";", "while", "(", "tok", ".", "hasMoreTokens", "(", ")", ")", "{", "final", "String", "t", "=", "tok", ".", "nextToken", "(", ")", ";", "if", "(", "t", ".", "equals", "(", "constValue", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}" ]
Helper method for subclasses to do the comparation. @param value Object that contains the property. @param constValue Value to compare with. @param separators Separators @return If object property contains the value as one of the tokens TRUE else FALSE.
[ "Helper", "method", "for", "subclasses", "to", "do", "the", "comparation", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/filter/TokenFilter.java#L80-L94
145,476
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgBehavior.java
SgBehavior.getLastArgument
public final SgArgument getLastArgument() { final int size = arguments.size(); if (size == 0) { return null; } return arguments.get(size - 1); }
java
public final SgArgument getLastArgument() { final int size = arguments.size(); if (size == 0) { return null; } return arguments.get(size - 1); }
[ "public", "final", "SgArgument", "getLastArgument", "(", ")", "{", "final", "int", "size", "=", "arguments", ".", "size", "(", ")", ";", "if", "(", "size", "==", "0", ")", "{", "return", "null", ";", "}", "return", "arguments", ".", "get", "(", "size", "-", "1", ")", ";", "}" ]
Returns the last argument of the list. @return Last argument or null if the list is empty.
[ "Returns", "the", "last", "argument", "of", "the", "list", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgBehavior.java#L158-L164
145,477
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgBehavior.java
SgBehavior.addArgument
public final void addArgument(final SgArgument arg) { if (arg == null) { throw new IllegalArgumentException("The argument 'arg' cannot be null!"); } if (arg.getOwner() != this) { throw new IllegalArgumentException("The owner of 'arg' is different from 'this'!"); } if (!arguments.contains(arg)) { arguments.add(arg); } }
java
public final void addArgument(final SgArgument arg) { if (arg == null) { throw new IllegalArgumentException("The argument 'arg' cannot be null!"); } if (arg.getOwner() != this) { throw new IllegalArgumentException("The owner of 'arg' is different from 'this'!"); } if (!arguments.contains(arg)) { arguments.add(arg); } }
[ "public", "final", "void", "addArgument", "(", "final", "SgArgument", "arg", ")", "{", "if", "(", "arg", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'arg' cannot be null!\"", ")", ";", "}", "if", "(", "arg", ".", "getOwner", "(", ")", "!=", "this", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The owner of 'arg' is different from 'this'!\"", ")", ";", "}", "if", "(", "!", "arguments", ".", "contains", "(", "arg", ")", ")", "{", "arguments", ".", "add", "(", "arg", ")", ";", "}", "}" ]
Adds an argument to the list. Does nothing if the argument is already in the list of arguments. You will never need to use this method in your code! An argument is added automatically to the owning behavior when it's constructed! @param arg Argument to add - Non null.
[ "Adds", "an", "argument", "to", "the", "list", ".", "Does", "nothing", "if", "the", "argument", "is", "already", "in", "the", "list", "of", "arguments", ".", "You", "will", "never", "need", "to", "use", "this", "method", "in", "your", "code!", "An", "argument", "is", "added", "automatically", "to", "the", "owning", "behavior", "when", "it", "s", "constructed!" ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgBehavior.java#L175-L185
145,478
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgBehavior.java
SgBehavior.addException
public final void addException(final SgClass clasz) { if (clasz == null) { throw new IllegalArgumentException("The argument 'clasz' cannot be null!"); } // TODO Check if any superclass is of type Exception. if (!exceptions.contains(clasz)) { exceptions.add(clasz); } }
java
public final void addException(final SgClass clasz) { if (clasz == null) { throw new IllegalArgumentException("The argument 'clasz' cannot be null!"); } // TODO Check if any superclass is of type Exception. if (!exceptions.contains(clasz)) { exceptions.add(clasz); } }
[ "public", "final", "void", "addException", "(", "final", "SgClass", "clasz", ")", "{", "if", "(", "clasz", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'clasz' cannot be null!\"", ")", ";", "}", "// TODO Check if any superclass is of type Exception.\r", "if", "(", "!", "exceptions", ".", "contains", "(", "clasz", ")", ")", "{", "exceptions", ".", "add", "(", "clasz", ")", ";", "}", "}" ]
Adds an exception to the list. Does nothing if the class is already in the list of exceptions. @param clasz Exception to add.
[ "Adds", "an", "exception", "to", "the", "list", ".", "Does", "nothing", "if", "the", "class", "is", "already", "in", "the", "list", "of", "exceptions", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgBehavior.java#L203-L211
145,479
dbracewell/mango
src/main/java/com/davidbracewell/concurrent/Broker.java
Broker.run
public boolean run() { ExecutorService executors = Executors.newFixedThreadPool(producers.size() + consumers.size()); runningProducers.set(producers.size()); //create the producers for (Producer<V> producer : producers) { producer.setOwner(this); executors.submit(new ProducerThread(producer)); } //create the consumers for (java.util.function.Consumer<? super V> consumer : consumers) { executors.submit(new ConsumerThread(consumer)); } //give it some more time to process while (runningProducers.get() > 0 || !queue.isEmpty()) { Threads.sleep(10); } executors.shutdown(); try { executors.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { logWarn(e); return false; } return true; }
java
public boolean run() { ExecutorService executors = Executors.newFixedThreadPool(producers.size() + consumers.size()); runningProducers.set(producers.size()); //create the producers for (Producer<V> producer : producers) { producer.setOwner(this); executors.submit(new ProducerThread(producer)); } //create the consumers for (java.util.function.Consumer<? super V> consumer : consumers) { executors.submit(new ConsumerThread(consumer)); } //give it some more time to process while (runningProducers.get() > 0 || !queue.isEmpty()) { Threads.sleep(10); } executors.shutdown(); try { executors.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { logWarn(e); return false; } return true; }
[ "public", "boolean", "run", "(", ")", "{", "ExecutorService", "executors", "=", "Executors", ".", "newFixedThreadPool", "(", "producers", ".", "size", "(", ")", "+", "consumers", ".", "size", "(", ")", ")", ";", "runningProducers", ".", "set", "(", "producers", ".", "size", "(", ")", ")", ";", "//create the producers", "for", "(", "Producer", "<", "V", ">", "producer", ":", "producers", ")", "{", "producer", ".", "setOwner", "(", "this", ")", ";", "executors", ".", "submit", "(", "new", "ProducerThread", "(", "producer", ")", ")", ";", "}", "//create the consumers", "for", "(", "java", ".", "util", ".", "function", ".", "Consumer", "<", "?", "super", "V", ">", "consumer", ":", "consumers", ")", "{", "executors", ".", "submit", "(", "new", "ConsumerThread", "(", "consumer", ")", ")", ";", "}", "//give it some more time to process", "while", "(", "runningProducers", ".", "get", "(", ")", ">", "0", "||", "!", "queue", ".", "isEmpty", "(", ")", ")", "{", "Threads", ".", "sleep", "(", "10", ")", ";", "}", "executors", ".", "shutdown", "(", ")", ";", "try", "{", "executors", ".", "awaitTermination", "(", "Integer", ".", "MAX_VALUE", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "logWarn", "(", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Starts execution of the broker. @return Returns true if the broker completed without interruption, false otherwise
[ "Starts", "execution", "of", "the", "broker", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/concurrent/Broker.java#L71-L99
145,480
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/concurrency/BaseWorkQueue.java
BaseWorkQueue.execute
public void execute(final T runnable) { synchronized (queue) { if (runnable != null && !disabled) { queue.addLast(runnable); queue.notify(); System.out.println("WorkQueue has added runable - WorkQueue size is " + queue.size()); } } }
java
public void execute(final T runnable) { synchronized (queue) { if (runnable != null && !disabled) { queue.addLast(runnable); queue.notify(); System.out.println("WorkQueue has added runable - WorkQueue size is " + queue.size()); } } }
[ "public", "void", "execute", "(", "final", "T", "runnable", ")", "{", "synchronized", "(", "queue", ")", "{", "if", "(", "runnable", "!=", "null", "&&", "!", "disabled", ")", "{", "queue", ".", "addLast", "(", "runnable", ")", ";", "queue", ".", "notify", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"WorkQueue has added runable - WorkQueue size is \"", "+", "queue", ".", "size", "(", ")", ")", ";", "}", "}", "}" ]
Add a Runnable object to the pool to be executed once a thread is available
[ "Add", "a", "Runnable", "object", "to", "the", "pool", "to", "be", "executed", "once", "a", "thread", "is", "available" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/concurrency/BaseWorkQueue.java#L116-L124
145,481
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/concurrency/BaseWorkQueue.java
BaseWorkQueue.runAndWait
public static void runAndWait(final Runnable r) { try { if (r != null) { final Thread thread = new Thread(r); thread.start(); thread.join(); } } catch (final Exception ex) { LOG.debug("Thread has been interrupted and cannot be joined", ex); } }
java
public static void runAndWait(final Runnable r) { try { if (r != null) { final Thread thread = new Thread(r); thread.start(); thread.join(); } } catch (final Exception ex) { LOG.debug("Thread has been interrupted and cannot be joined", ex); } }
[ "public", "static", "void", "runAndWait", "(", "final", "Runnable", "r", ")", "{", "try", "{", "if", "(", "r", "!=", "null", ")", "{", "final", "Thread", "thread", "=", "new", "Thread", "(", "r", ")", ";", "thread", ".", "start", "(", ")", ";", "thread", ".", "join", "(", ")", ";", "}", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "LOG", ".", "debug", "(", "\"Thread has been interrupted and cannot be joined\"", ",", "ex", ")", ";", "}", "}" ]
Provides the boilerplate code for running and waiting on a Runnable.
[ "Provides", "the", "boilerplate", "code", "for", "running", "and", "waiting", "on", "a", "Runnable", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/concurrency/BaseWorkQueue.java#L129-L139
145,482
sangupta/jerry-services
src/main/java/com/sangupta/jerry/lock/service/impl/RedisLockServiceImpl.java
RedisLockServiceImpl.getNewLockValue
protected String getNewLockValue(long timeoutInMillis) { long time = System.currentTimeMillis() + timeoutInMillis + 1l; String lockValue = ApplicationContext.NODE_ID + ":" + time; return lockValue; }
java
protected String getNewLockValue(long timeoutInMillis) { long time = System.currentTimeMillis() + timeoutInMillis + 1l; String lockValue = ApplicationContext.NODE_ID + ":" + time; return lockValue; }
[ "protected", "String", "getNewLockValue", "(", "long", "timeoutInMillis", ")", "{", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "timeoutInMillis", "+", "1l", ";", "String", "lockValue", "=", "ApplicationContext", ".", "NODE_ID", "+", "\":\"", "+", "time", ";", "return", "lockValue", ";", "}" ]
Return the new value for the lock for given timeout. @param timeoutInMillis timeout in milli-seconds @return the new lock value
[ "Return", "the", "new", "value", "for", "the", "lock", "for", "given", "timeout", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/lock/service/impl/RedisLockServiceImpl.java#L153-L157
145,483
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/repo/CeylonModelLocator.java
CeylonModelLocator.locatePom
public File locatePom(final File folder) { if (folder != null && folder.exists() && folder.isDirectory()) { String moduleVersion = folder.getParentFile().getName(); File[] list = folder.listFiles(); File[] four = new File[CeylonUtil.NUM_CEYLON_JAVA_DEP_TYPES]; for (File file : list) { if (file.isFile()) { if ("module.xml".equals(file.getName())) { four[0] = file; } else if (file.getName().endsWith("-" + moduleVersion + ".module")) { four[1] = file; } else if ("module.properties".equals(file.getName())) { four[2] = file; } else if (file.getName().endsWith("-" + moduleVersion + ".car")) { four[3] = file; } } } for (File file : four) { if (file != null) { return file; } } } return new File(folder, "pom.xml"); }
java
public File locatePom(final File folder) { if (folder != null && folder.exists() && folder.isDirectory()) { String moduleVersion = folder.getParentFile().getName(); File[] list = folder.listFiles(); File[] four = new File[CeylonUtil.NUM_CEYLON_JAVA_DEP_TYPES]; for (File file : list) { if (file.isFile()) { if ("module.xml".equals(file.getName())) { four[0] = file; } else if (file.getName().endsWith("-" + moduleVersion + ".module")) { four[1] = file; } else if ("module.properties".equals(file.getName())) { four[2] = file; } else if (file.getName().endsWith("-" + moduleVersion + ".car")) { four[3] = file; } } } for (File file : four) { if (file != null) { return file; } } } return new File(folder, "pom.xml"); }
[ "public", "File", "locatePom", "(", "final", "File", "folder", ")", "{", "if", "(", "folder", "!=", "null", "&&", "folder", ".", "exists", "(", ")", "&&", "folder", ".", "isDirectory", "(", ")", ")", "{", "String", "moduleVersion", "=", "folder", ".", "getParentFile", "(", ")", ".", "getName", "(", ")", ";", "File", "[", "]", "list", "=", "folder", ".", "listFiles", "(", ")", ";", "File", "[", "]", "four", "=", "new", "File", "[", "CeylonUtil", ".", "NUM_CEYLON_JAVA_DEP_TYPES", "]", ";", "for", "(", "File", "file", ":", "list", ")", "{", "if", "(", "file", ".", "isFile", "(", ")", ")", "{", "if", "(", "\"module.xml\"", ".", "equals", "(", "file", ".", "getName", "(", ")", ")", ")", "{", "four", "[", "0", "]", "=", "file", ";", "}", "else", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\"-\"", "+", "moduleVersion", "+", "\".module\"", ")", ")", "{", "four", "[", "1", "]", "=", "file", ";", "}", "else", "if", "(", "\"module.properties\"", ".", "equals", "(", "file", ".", "getName", "(", ")", ")", ")", "{", "four", "[", "2", "]", "=", "file", ";", "}", "else", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\"-\"", "+", "moduleVersion", "+", "\".car\"", ")", ")", "{", "four", "[", "3", "]", "=", "file", ";", "}", "}", "}", "for", "(", "File", "file", ":", "four", ")", "{", "if", "(", "file", "!=", "null", ")", "{", "return", "file", ";", "}", "}", "}", "return", "new", "File", "(", "folder", ",", "\"pom.xml\"", ")", ";", "}" ]
Implementing Maven API to locate the project model. @param folder The folder in which to look @return File The file that represents the POM. It may be a Ceylon properties or .module file
[ "Implementing", "Maven", "API", "to", "locate", "the", "project", "model", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/repo/CeylonModelLocator.java#L24-L52
145,484
flex-oss/flex-fruit
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/JpaRepository.java
JpaRepository.findOneByAttribute
public T findOneByAttribute(String attribute, Object value) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); CriteriaQuery<T> query = cb.createQuery(getEntityClass()); Root<T> from = query.from(getEntityClass()); query.where(cb.equal(from.get(attribute), value)); try { return getEntityManager().createQuery(query).getSingleResult(); } catch (NoResultException e) { return null; } }
java
public T findOneByAttribute(String attribute, Object value) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); CriteriaQuery<T> query = cb.createQuery(getEntityClass()); Root<T> from = query.from(getEntityClass()); query.where(cb.equal(from.get(attribute), value)); try { return getEntityManager().createQuery(query).getSingleResult(); } catch (NoResultException e) { return null; } }
[ "public", "T", "findOneByAttribute", "(", "String", "attribute", ",", "Object", "value", ")", "{", "CriteriaBuilder", "cb", "=", "getEntityManager", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "query", "=", "cb", ".", "createQuery", "(", "getEntityClass", "(", ")", ")", ";", "Root", "<", "T", ">", "from", "=", "query", ".", "from", "(", "getEntityClass", "(", ")", ")", ";", "query", ".", "where", "(", "cb", ".", "equal", "(", "from", ".", "get", "(", "attribute", ")", ",", "value", ")", ")", ";", "try", "{", "return", "getEntityManager", "(", ")", ".", "createQuery", "(", "query", ")", ".", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NoResultException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Finds an entity by a given attribute. Returns null if none was found. @param attribute the attribute to search for @param value the value @return the entity or null if none was found
[ "Finds", "an", "entity", "by", "a", "given", "attribute", ".", "Returns", "null", "if", "none", "was", "found", "." ]
30d7eca5ee796b829f96c9932a95b259ca9738d9
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/JpaRepository.java#L190-L202
145,485
flex-oss/flex-fruit
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/JpaRepository.java
JpaRepository.execute
protected void execute(EntityManagerCommand command) { try { getEntityManagerCommandExecutor().execute(command); } catch (javax.persistence.PersistenceException e) { throw new PersistenceException(e); } }
java
protected void execute(EntityManagerCommand command) { try { getEntityManagerCommandExecutor().execute(command); } catch (javax.persistence.PersistenceException e) { throw new PersistenceException(e); } }
[ "protected", "void", "execute", "(", "EntityManagerCommand", "command", ")", "{", "try", "{", "getEntityManagerCommandExecutor", "(", ")", ".", "execute", "(", "command", ")", ";", "}", "catch", "(", "javax", ".", "persistence", ".", "PersistenceException", "e", ")", "{", "throw", "new", "PersistenceException", "(", "e", ")", ";", "}", "}" ]
Executes the given command using an EntityManagerCommandExecutor. @param command the command to execute
[ "Executes", "the", "given", "command", "using", "an", "EntityManagerCommandExecutor", "." ]
30d7eca5ee796b829f96c9932a95b259ca9738d9
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/JpaRepository.java#L308-L314
145,486
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation3DGUI.java
ShanksSimulation3DGUI.removeTimeChart
public void removeTimeChart(String chartID) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = (Scenario3DPortrayal) this .getSimulation().getScenarioPortrayal(); scenarioPortrayal.removeTimeChart(chartID); }
java
public void removeTimeChart(String chartID) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = (Scenario3DPortrayal) this .getSimulation().getScenarioPortrayal(); scenarioPortrayal.removeTimeChart(chartID); }
[ "public", "void", "removeTimeChart", "(", "String", "chartID", ")", "throws", "ShanksException", "{", "Scenario3DPortrayal", "scenarioPortrayal", "=", "(", "Scenario3DPortrayal", ")", "this", ".", "getSimulation", "(", ")", ".", "getScenarioPortrayal", "(", ")", ";", "scenarioPortrayal", ".", "removeTimeChart", "(", "chartID", ")", ";", "}" ]
Remove a chart to the simulation @param chartID @throws DuplicatedPortrayalIDException @throws ScenarioNotFoundException
[ "Remove", "a", "chart", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation3DGUI.java#L360-L364
145,487
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation3DGUI.java
ShanksSimulation3DGUI.addScatterPlot
public void addScatterPlot(String scatterID, String xAxisLabel, String yAxisLabel) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = (Scenario3DPortrayal) this .getSimulation().getScenarioPortrayal(); scenarioPortrayal.addScatterPlot(scatterID, xAxisLabel, yAxisLabel); }
java
public void addScatterPlot(String scatterID, String xAxisLabel, String yAxisLabel) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = (Scenario3DPortrayal) this .getSimulation().getScenarioPortrayal(); scenarioPortrayal.addScatterPlot(scatterID, xAxisLabel, yAxisLabel); }
[ "public", "void", "addScatterPlot", "(", "String", "scatterID", ",", "String", "xAxisLabel", ",", "String", "yAxisLabel", ")", "throws", "ShanksException", "{", "Scenario3DPortrayal", "scenarioPortrayal", "=", "(", "Scenario3DPortrayal", ")", "this", ".", "getSimulation", "(", ")", ".", "getScenarioPortrayal", "(", ")", ";", "scenarioPortrayal", ".", "addScatterPlot", "(", "scatterID", ",", "xAxisLabel", ",", "yAxisLabel", ")", ";", "}" ]
Add a Scatter Plot to the simulation @param scatterID - The name of the plot @param xAxisLabel - The name of the x axis @param yAxisLabel - The name of the y axis @throws DuplicatedPortrayalIDException @throws ScenarioNotFoundException @throws DuplicatedChartIDException
[ "Add", "a", "Scatter", "Plot", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation3DGUI.java#L379-L384
145,488
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java
CollectionUtilities.getSortOrder
public static <T extends Comparable<? super T>> Integer getSortOrder(final T first, final T second) { if (first == null && second == null) return null; if (first == null && second != null) return -1; if (first != null && second == null) return 1; return first.compareTo(second); }
java
public static <T extends Comparable<? super T>> Integer getSortOrder(final T first, final T second) { if (first == null && second == null) return null; if (first == null && second != null) return -1; if (first != null && second == null) return 1; return first.compareTo(second); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "?", "super", "T", ">", ">", "Integer", "getSortOrder", "(", "final", "T", "first", ",", "final", "T", "second", ")", "{", "if", "(", "first", "==", "null", "&&", "second", "==", "null", ")", "return", "null", ";", "if", "(", "first", "==", "null", "&&", "second", "!=", "null", ")", "return", "-", "1", ";", "if", "(", "first", "!=", "null", "&&", "second", "==", "null", ")", "return", "1", ";", "return", "first", ".", "compareTo", "(", "second", ")", ";", "}" ]
Provides an easy way to compare two possibly null comparable objects @param first The first object to compare @param second The second object to compare @return < 0 if the first object is less than the second object, 0 if they are equal, and > 0 otherwise
[ "Provides", "an", "easy", "way", "to", "compare", "two", "possibly", "null", "comparable", "objects" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java#L163-L171
145,489
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java
CollectionUtilities.isEqual
public static <T> boolean isEqual(final T first, final T second) { /* test to see if they are both null, or both reference the same object */ if (first == second) return true; if (first == null && second != null) return false; return first.equals(second); }
java
public static <T> boolean isEqual(final T first, final T second) { /* test to see if they are both null, or both reference the same object */ if (first == second) return true; if (first == null && second != null) return false; return first.equals(second); }
[ "public", "static", "<", "T", ">", "boolean", "isEqual", "(", "final", "T", "first", ",", "final", "T", "second", ")", "{", "/* test to see if they are both null, or both reference the same object */", "if", "(", "first", "==", "second", ")", "return", "true", ";", "if", "(", "first", "==", "null", "&&", "second", "!=", "null", ")", "return", "false", ";", "return", "first", ".", "equals", "(", "second", ")", ";", "}" ]
Provides an easy way to see if two possibly null objects are equal @param first The first object to test @param second The second to test @return true if both objects are equal, false otherwise
[ "Provides", "an", "easy", "way", "to", "see", "if", "two", "possibly", "null", "objects", "are", "equal" ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java#L180-L187
145,490
pressgang-ccms/PressGangCCMSCommonUtilities
src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java
CollectionUtilities.trimStringArray
public static String[] trimStringArray(final String[] input) { final ArrayList<String> output = new ArrayList<String>(); for (int i = 0; i < input.length; i++) { String s = input[i].trim(); if (!s.equals("")) output.add(s); } return output.toArray(new String[0]); }
java
public static String[] trimStringArray(final String[] input) { final ArrayList<String> output = new ArrayList<String>(); for (int i = 0; i < input.length; i++) { String s = input[i].trim(); if (!s.equals("")) output.add(s); } return output.toArray(new String[0]); }
[ "public", "static", "String", "[", "]", "trimStringArray", "(", "final", "String", "[", "]", "input", ")", "{", "final", "ArrayList", "<", "String", ">", "output", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "input", ".", "length", ";", "i", "++", ")", "{", "String", "s", "=", "input", "[", "i", "]", ".", "trim", "(", ")", ";", "if", "(", "!", "s", ".", "equals", "(", "\"\"", ")", ")", "output", ".", "add", "(", "s", ")", ";", "}", "return", "output", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}" ]
Trims an array of Strings to remove the whitespace. If the string is empty then its removed from the array. @param input The array of strings to be trimmed @return The same array of strings but all elements have been trimmed of whitespace
[ "Trims", "an", "array", "of", "Strings", "to", "remove", "the", "whitespace", ".", "If", "the", "string", "is", "empty", "then", "its", "removed", "from", "the", "array", "." ]
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/CollectionUtilities.java#L202-L209
145,491
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.newWeightsVector
public ConcatVector newWeightsVector(boolean presize) { ConcatVector vector = new ConcatVector(featureToIndex.size()); if (presize) { for (ObjectCursor<String> s : sparseFeatureIndex.keys()) { int size = sparseFeatureIndex.get(s.value).size(); vector.setDenseComponent(ensureFeature(s.value), new double[size]); } } setAlwaysOneFeature(vector, 1); return vector; }
java
public ConcatVector newWeightsVector(boolean presize) { ConcatVector vector = new ConcatVector(featureToIndex.size()); if (presize) { for (ObjectCursor<String> s : sparseFeatureIndex.keys()) { int size = sparseFeatureIndex.get(s.value).size(); vector.setDenseComponent(ensureFeature(s.value), new double[size]); } } setAlwaysOneFeature(vector, 1); return vector; }
[ "public", "ConcatVector", "newWeightsVector", "(", "boolean", "presize", ")", "{", "ConcatVector", "vector", "=", "new", "ConcatVector", "(", "featureToIndex", ".", "size", "(", ")", ")", ";", "if", "(", "presize", ")", "{", "for", "(", "ObjectCursor", "<", "String", ">", "s", ":", "sparseFeatureIndex", ".", "keys", "(", ")", ")", "{", "int", "size", "=", "sparseFeatureIndex", ".", "get", "(", "s", ".", "value", ")", ".", "size", "(", ")", ";", "vector", ".", "setDenseComponent", "(", "ensureFeature", "(", "s", ".", "value", ")", ",", "new", "double", "[", "size", "]", ")", ";", "}", "}", "setAlwaysOneFeature", "(", "vector", ",", "1", ")", ";", "return", "vector", ";", "}" ]
This constructs a fresh vector that is sized correctly to accommodate all the known sparse values for vectors that are possibly sparse. @param presize a flag for whether or not to create all the dense double arrays for our sparse features @return a new, internally correctly sized ConcatVector that will work correctly as weights for features from this namespace;
[ "This", "constructs", "a", "fresh", "vector", "that", "is", "sized", "correctly", "to", "accommodate", "all", "the", "known", "sparse", "values", "for", "vectors", "that", "are", "possibly", "sparse", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L48-L58
145,492
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.ensureFeature
public int ensureFeature(String featureName) { int feature = featureToIndex.getOrDefault(featureName, -1); if (feature == -1) { synchronized (featureToIndex) { feature = featureToIndex.getOrDefault(featureName, -1); if (feature == -1) { feature = featureToIndex.size(); featureToIndex.put(featureName, feature); } } } return feature; }
java
public int ensureFeature(String featureName) { int feature = featureToIndex.getOrDefault(featureName, -1); if (feature == -1) { synchronized (featureToIndex) { feature = featureToIndex.getOrDefault(featureName, -1); if (feature == -1) { feature = featureToIndex.size(); featureToIndex.put(featureName, feature); } } } return feature; }
[ "public", "int", "ensureFeature", "(", "String", "featureName", ")", "{", "int", "feature", "=", "featureToIndex", ".", "getOrDefault", "(", "featureName", ",", "-", "1", ")", ";", "if", "(", "feature", "==", "-", "1", ")", "{", "synchronized", "(", "featureToIndex", ")", "{", "feature", "=", "featureToIndex", ".", "getOrDefault", "(", "featureName", ",", "-", "1", ")", ";", "if", "(", "feature", "==", "-", "1", ")", "{", "feature", "=", "featureToIndex", ".", "size", "(", ")", ";", "featureToIndex", ".", "put", "(", "featureName", ",", "feature", ")", ";", "}", "}", "}", "return", "feature", ";", "}" ]
An optimization, this lets clients inform the ConcatVectorNamespace of how many features to expect, so that we can avoid resizing ConcatVectors. @param featureName the feature to add to our index
[ "An", "optimization", "this", "lets", "clients", "inform", "the", "ConcatVectorNamespace", "of", "how", "many", "features", "to", "expect", "so", "that", "we", "can", "avoid", "resizing", "ConcatVectors", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L65-L77
145,493
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.ensureSparseFeature
public int ensureSparseFeature(String featureName, String index) { ensureFeature(featureName); ObjectIntMap<String> sparseIndex = sparseFeatureIndex.get(featureName); IntObjectMap<String> reverseSparseIndex = reverseSparseFeatureIndex.get(featureName); if (sparseIndex == null || reverseSparseIndex == null) { synchronized (sparseFeatureIndex) { sparseIndex = sparseFeatureIndex.get(featureName); reverseSparseIndex = reverseSparseFeatureIndex.get(featureName); if (sparseIndex == null || reverseSparseIndex == null) { sparseIndex = new ObjectIntHashMap<>(); reverseSparseIndex = new IntObjectHashMap<>(); sparseFeatureIndex.put(featureName, sparseIndex); reverseSparseFeatureIndex.put(featureName, reverseSparseIndex); } } } Integer rtn = sparseIndex.getOrDefault(index, -1); if (rtn == -1) { //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (sparseIndex) { rtn = sparseIndex.getOrDefault(index, -1); if (rtn == -1) { rtn = sparseIndex.size(); reverseSparseIndex.put(rtn, index); sparseIndex.put(index, rtn); } } } return rtn; }
java
public int ensureSparseFeature(String featureName, String index) { ensureFeature(featureName); ObjectIntMap<String> sparseIndex = sparseFeatureIndex.get(featureName); IntObjectMap<String> reverseSparseIndex = reverseSparseFeatureIndex.get(featureName); if (sparseIndex == null || reverseSparseIndex == null) { synchronized (sparseFeatureIndex) { sparseIndex = sparseFeatureIndex.get(featureName); reverseSparseIndex = reverseSparseFeatureIndex.get(featureName); if (sparseIndex == null || reverseSparseIndex == null) { sparseIndex = new ObjectIntHashMap<>(); reverseSparseIndex = new IntObjectHashMap<>(); sparseFeatureIndex.put(featureName, sparseIndex); reverseSparseFeatureIndex.put(featureName, reverseSparseIndex); } } } Integer rtn = sparseIndex.getOrDefault(index, -1); if (rtn == -1) { //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (sparseIndex) { rtn = sparseIndex.getOrDefault(index, -1); if (rtn == -1) { rtn = sparseIndex.size(); reverseSparseIndex.put(rtn, index); sparseIndex.put(index, rtn); } } } return rtn; }
[ "public", "int", "ensureSparseFeature", "(", "String", "featureName", ",", "String", "index", ")", "{", "ensureFeature", "(", "featureName", ")", ";", "ObjectIntMap", "<", "String", ">", "sparseIndex", "=", "sparseFeatureIndex", ".", "get", "(", "featureName", ")", ";", "IntObjectMap", "<", "String", ">", "reverseSparseIndex", "=", "reverseSparseFeatureIndex", ".", "get", "(", "featureName", ")", ";", "if", "(", "sparseIndex", "==", "null", "||", "reverseSparseIndex", "==", "null", ")", "{", "synchronized", "(", "sparseFeatureIndex", ")", "{", "sparseIndex", "=", "sparseFeatureIndex", ".", "get", "(", "featureName", ")", ";", "reverseSparseIndex", "=", "reverseSparseFeatureIndex", ".", "get", "(", "featureName", ")", ";", "if", "(", "sparseIndex", "==", "null", "||", "reverseSparseIndex", "==", "null", ")", "{", "sparseIndex", "=", "new", "ObjectIntHashMap", "<>", "(", ")", ";", "reverseSparseIndex", "=", "new", "IntObjectHashMap", "<>", "(", ")", ";", "sparseFeatureIndex", ".", "put", "(", "featureName", ",", "sparseIndex", ")", ";", "reverseSparseFeatureIndex", ".", "put", "(", "featureName", ",", "reverseSparseIndex", ")", ";", "}", "}", "}", "Integer", "rtn", "=", "sparseIndex", ".", "getOrDefault", "(", "index", ",", "-", "1", ")", ";", "if", "(", "rtn", "==", "-", "1", ")", "{", "//noinspection SynchronizationOnLocalVariableOrMethodParameter", "synchronized", "(", "sparseIndex", ")", "{", "rtn", "=", "sparseIndex", ".", "getOrDefault", "(", "index", ",", "-", "1", ")", ";", "if", "(", "rtn", "==", "-", "1", ")", "{", "rtn", "=", "sparseIndex", ".", "size", "(", ")", ";", "reverseSparseIndex", ".", "put", "(", "rtn", ",", "index", ")", ";", "sparseIndex", ".", "put", "(", "index", ",", "rtn", ")", ";", "}", "}", "}", "return", "rtn", ";", "}" ]
An optimization, this lets clients inform the ConcatVectorNamespace of how many sparse feature components to expect, again so that we can avoid resizing ConcatVectors. @param featureName the feature to use in our index @param index the sparse value to ensure is available
[ "An", "optimization", "this", "lets", "clients", "inform", "the", "ConcatVectorNamespace", "of", "how", "many", "sparse", "feature", "components", "to", "expect", "again", "so", "that", "we", "can", "avoid", "resizing", "ConcatVectors", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L85-L114
145,494
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.setDenseFeature
public void setDenseFeature(ConcatVector vector, String featureName, double[] value) { vector.setDenseComponent(ensureFeature(featureName), value); }
java
public void setDenseFeature(ConcatVector vector, String featureName, double[] value) { vector.setDenseComponent(ensureFeature(featureName), value); }
[ "public", "void", "setDenseFeature", "(", "ConcatVector", "vector", ",", "String", "featureName", ",", "double", "[", "]", "value", ")", "{", "vector", ".", "setDenseComponent", "(", "ensureFeature", "(", "featureName", ")", ",", "value", ")", ";", "}" ]
This adds a dense feature to a vector, setting the appropriate component of the given vector to the passed in value. @param vector the vector @param featureName the feature whose value to set @param value the value we want to set this vector to
[ "This", "adds", "a", "dense", "feature", "to", "a", "vector", "setting", "the", "appropriate", "component", "of", "the", "given", "vector", "to", "the", "passed", "in", "value", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L134-L136
145,495
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.setSparseFeature
public void setSparseFeature(ConcatVector vector, String featureName, String index, double value) { vector.setSparseComponent(ensureFeature(featureName), ensureSparseFeature(featureName, index), value); }
java
public void setSparseFeature(ConcatVector vector, String featureName, String index, double value) { vector.setSparseComponent(ensureFeature(featureName), ensureSparseFeature(featureName, index), value); }
[ "public", "void", "setSparseFeature", "(", "ConcatVector", "vector", ",", "String", "featureName", ",", "String", "index", ",", "double", "value", ")", "{", "vector", ".", "setSparseComponent", "(", "ensureFeature", "(", "featureName", ")", ",", "ensureSparseFeature", "(", "featureName", ",", "index", ")", ",", "value", ")", ";", "}" ]
This adds a sparse feature to a vector, setting the appropriate component of the given vector to the passed in value. @param vector the vector @param featureName the feature whose value to set @param index the index of the one-hot vector to set, as a string, which we will translate into a mapping @param value the value we want to set this one-hot index to
[ "This", "adds", "a", "sparse", "feature", "to", "a", "vector", "setting", "the", "appropriate", "component", "of", "the", "given", "vector", "to", "the", "passed", "in", "value", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L146-L148
145,496
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.debugVector
public void debugVector(ConcatVector vector, BufferedWriter bw) throws IOException { List<String> features = new ArrayList<>(); Map<String, List<Integer>> sortedFeatures = new HashMap<>(); for (ObjectCursor<String> key : featureToIndex.keys()) { features.add(key.value); int i = featureToIndex.getOrDefault(key.value, -1); List<Integer> featureIndices = new ArrayList<>(); if (vector.isComponentSparse(i)) { int[] indices = vector.getSparseIndices(i); for (int j : indices) { featureIndices.add(j); } } else { double[] arr = vector.getDenseComponent(i); for (int j = 0; j < arr.length; j++) { featureIndices.add(j); } } featureIndices.sort((a,b) -> { if (Math.abs(vector.getValueAt(i, a)) < Math.abs(vector.getValueAt(i, b))) { return 1; } else if (Math.abs(vector.getValueAt(i, a)) > Math.abs(vector.getValueAt(i, b))) { return -1; } else { return 0; } }); sortedFeatures.put(key.value, featureIndices); } features.sort((a,b) -> { double bestAValue = sortedFeatures.get(a).size() == 0 ? 0.0 : Math.abs(vector.getValueAt(featureToIndex.getOrDefault(a, -1), sortedFeatures.get(a).get(0))); double bestBValue = sortedFeatures.get(b).size() == 0 ? 0.0 : Math.abs(vector.getValueAt(featureToIndex.getOrDefault(b, -1), sortedFeatures.get(b).get(0))); if (bestAValue < bestBValue) { return 1; } else if (bestAValue > bestBValue) { return -1; } else return 0; }); for (String key : features) { bw.write("FEATURE: \""+key); bw.write("\"\n"); for (int j : sortedFeatures.get(key)) { debugFeatureValue(key, j, vector, bw); } } // Flush the writer bw.flush(); }
java
public void debugVector(ConcatVector vector, BufferedWriter bw) throws IOException { List<String> features = new ArrayList<>(); Map<String, List<Integer>> sortedFeatures = new HashMap<>(); for (ObjectCursor<String> key : featureToIndex.keys()) { features.add(key.value); int i = featureToIndex.getOrDefault(key.value, -1); List<Integer> featureIndices = new ArrayList<>(); if (vector.isComponentSparse(i)) { int[] indices = vector.getSparseIndices(i); for (int j : indices) { featureIndices.add(j); } } else { double[] arr = vector.getDenseComponent(i); for (int j = 0; j < arr.length; j++) { featureIndices.add(j); } } featureIndices.sort((a,b) -> { if (Math.abs(vector.getValueAt(i, a)) < Math.abs(vector.getValueAt(i, b))) { return 1; } else if (Math.abs(vector.getValueAt(i, a)) > Math.abs(vector.getValueAt(i, b))) { return -1; } else { return 0; } }); sortedFeatures.put(key.value, featureIndices); } features.sort((a,b) -> { double bestAValue = sortedFeatures.get(a).size() == 0 ? 0.0 : Math.abs(vector.getValueAt(featureToIndex.getOrDefault(a, -1), sortedFeatures.get(a).get(0))); double bestBValue = sortedFeatures.get(b).size() == 0 ? 0.0 : Math.abs(vector.getValueAt(featureToIndex.getOrDefault(b, -1), sortedFeatures.get(b).get(0))); if (bestAValue < bestBValue) { return 1; } else if (bestAValue > bestBValue) { return -1; } else return 0; }); for (String key : features) { bw.write("FEATURE: \""+key); bw.write("\"\n"); for (int j : sortedFeatures.get(key)) { debugFeatureValue(key, j, vector, bw); } } // Flush the writer bw.flush(); }
[ "public", "void", "debugVector", "(", "ConcatVector", "vector", ",", "BufferedWriter", "bw", ")", "throws", "IOException", "{", "List", "<", "String", ">", "features", "=", "new", "ArrayList", "<>", "(", ")", ";", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "sortedFeatures", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "ObjectCursor", "<", "String", ">", "key", ":", "featureToIndex", ".", "keys", "(", ")", ")", "{", "features", ".", "add", "(", "key", ".", "value", ")", ";", "int", "i", "=", "featureToIndex", ".", "getOrDefault", "(", "key", ".", "value", ",", "-", "1", ")", ";", "List", "<", "Integer", ">", "featureIndices", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "vector", ".", "isComponentSparse", "(", "i", ")", ")", "{", "int", "[", "]", "indices", "=", "vector", ".", "getSparseIndices", "(", "i", ")", ";", "for", "(", "int", "j", ":", "indices", ")", "{", "featureIndices", ".", "add", "(", "j", ")", ";", "}", "}", "else", "{", "double", "[", "]", "arr", "=", "vector", ".", "getDenseComponent", "(", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "arr", ".", "length", ";", "j", "++", ")", "{", "featureIndices", ".", "add", "(", "j", ")", ";", "}", "}", "featureIndices", ".", "sort", "(", "(", "a", ",", "b", ")", "->", "{", "if", "(", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "i", ",", "a", ")", ")", "<", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "i", ",", "b", ")", ")", ")", "{", "return", "1", ";", "}", "else", "if", "(", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "i", ",", "a", ")", ")", ">", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "i", ",", "b", ")", ")", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "0", ";", "}", "}", ")", ";", "sortedFeatures", ".", "put", "(", "key", ".", "value", ",", "featureIndices", ")", ";", "}", "features", ".", "sort", "(", "(", "a", ",", "b", ")", "->", "{", "double", "bestAValue", "=", "sortedFeatures", ".", "get", "(", "a", ")", ".", "size", "(", ")", "==", "0", "?", "0.0", ":", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "featureToIndex", ".", "getOrDefault", "(", "a", ",", "-", "1", ")", ",", "sortedFeatures", ".", "get", "(", "a", ")", ".", "get", "(", "0", ")", ")", ")", ";", "double", "bestBValue", "=", "sortedFeatures", ".", "get", "(", "b", ")", ".", "size", "(", ")", "==", "0", "?", "0.0", ":", "Math", ".", "abs", "(", "vector", ".", "getValueAt", "(", "featureToIndex", ".", "getOrDefault", "(", "b", ",", "-", "1", ")", ",", "sortedFeatures", ".", "get", "(", "b", ")", ".", "get", "(", "0", ")", ")", ")", ";", "if", "(", "bestAValue", "<", "bestBValue", ")", "{", "return", "1", ";", "}", "else", "if", "(", "bestAValue", ">", "bestBValue", ")", "{", "return", "-", "1", ";", "}", "else", "return", "0", ";", "}", ")", ";", "for", "(", "String", "key", ":", "features", ")", "{", "bw", ".", "write", "(", "\"FEATURE: \\\"\"", "+", "key", ")", ";", "bw", ".", "write", "(", "\"\\\"\\n\"", ")", ";", "for", "(", "int", "j", ":", "sortedFeatures", ".", "get", "(", "key", ")", ")", "{", "debugFeatureValue", "(", "key", ",", "j", ",", "vector", ",", "bw", ")", ";", "}", "}", "// Flush the writer", "bw", ".", "flush", "(", ")", ";", "}" ]
This prints out a ConcatVector by mapping to the namespace, to make debugging learning algorithms easier. @param vector the vector to print @param bw the output stream to write to
[ "This", "prints", "out", "a", "ConcatVector", "by", "mapping", "to", "the", "namespace", "to", "make", "debugging", "learning", "algorithms", "easier", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L308-L366
145,497
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java
ConcatVectorNamespace.debugFeatureValue
private void debugFeatureValue(String feature, int index, ConcatVector vector, BufferedWriter bw) throws IOException { bw.write("\t"); if (sparseFeatureIndex.containsKey(feature) && sparseFeatureIndex.get(feature).values().contains(index)) { // we can map this index to an interpretable string, so we do bw.write("SPARSE VALUE \""); bw.write(reverseSparseFeatureIndex.get(feature).get(index)); bw.write("\""); } else { // we can't map this to a useful string, so we default to the number bw.write(Integer.toString(index)); } bw.write(": "); bw.write(Double.toString(vector.getValueAt(featureToIndex.getOrDefault(feature, -1), index))); bw.write("\n"); }
java
private void debugFeatureValue(String feature, int index, ConcatVector vector, BufferedWriter bw) throws IOException { bw.write("\t"); if (sparseFeatureIndex.containsKey(feature) && sparseFeatureIndex.get(feature).values().contains(index)) { // we can map this index to an interpretable string, so we do bw.write("SPARSE VALUE \""); bw.write(reverseSparseFeatureIndex.get(feature).get(index)); bw.write("\""); } else { // we can't map this to a useful string, so we default to the number bw.write(Integer.toString(index)); } bw.write(": "); bw.write(Double.toString(vector.getValueAt(featureToIndex.getOrDefault(feature, -1), index))); bw.write("\n"); }
[ "private", "void", "debugFeatureValue", "(", "String", "feature", ",", "int", "index", ",", "ConcatVector", "vector", ",", "BufferedWriter", "bw", ")", "throws", "IOException", "{", "bw", ".", "write", "(", "\"\\t\"", ")", ";", "if", "(", "sparseFeatureIndex", ".", "containsKey", "(", "feature", ")", "&&", "sparseFeatureIndex", ".", "get", "(", "feature", ")", ".", "values", "(", ")", ".", "contains", "(", "index", ")", ")", "{", "// we can map this index to an interpretable string, so we do", "bw", ".", "write", "(", "\"SPARSE VALUE \\\"\"", ")", ";", "bw", ".", "write", "(", "reverseSparseFeatureIndex", ".", "get", "(", "feature", ")", ".", "get", "(", "index", ")", ")", ";", "bw", ".", "write", "(", "\"\\\"\"", ")", ";", "}", "else", "{", "// we can't map this to a useful string, so we default to the number", "bw", ".", "write", "(", "Integer", ".", "toString", "(", "index", ")", ")", ";", "}", "bw", ".", "write", "(", "\": \"", ")", ";", "bw", ".", "write", "(", "Double", ".", "toString", "(", "vector", ".", "getValueAt", "(", "featureToIndex", ".", "getOrDefault", "(", "feature", ",", "-", "1", ")", ",", "index", ")", ")", ")", ";", "bw", ".", "write", "(", "\"\\n\"", ")", ";", "}" ]
This writes a feature's individual value, using the human readable name if possible, to a StringBuilder
[ "This", "writes", "a", "feature", "s", "individual", "value", "using", "the", "human", "readable", "name", "if", "possible", "to", "a", "StringBuilder" ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L371-L386
145,498
dbracewell/mango
src/main/java/com/davidbracewell/string/CSVFormatter.java
CSVFormatter.format
public String format(Object... array) { if (array == null) { return StringUtils.EMPTY; } if (array.length == 1 && array[0].getClass().isArray()) { return format(Convert.convert(array[0], Iterable.class)); } return format(Arrays.asList(array).iterator()); }
java
public String format(Object... array) { if (array == null) { return StringUtils.EMPTY; } if (array.length == 1 && array[0].getClass().isArray()) { return format(Convert.convert(array[0], Iterable.class)); } return format(Arrays.asList(array).iterator()); }
[ "public", "String", "format", "(", "Object", "...", "array", ")", "{", "if", "(", "array", "==", "null", ")", "{", "return", "StringUtils", ".", "EMPTY", ";", "}", "if", "(", "array", ".", "length", "==", "1", "&&", "array", "[", "0", "]", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "return", "format", "(", "Convert", ".", "convert", "(", "array", "[", "0", "]", ",", "Iterable", ".", "class", ")", ")", ";", "}", "return", "format", "(", "Arrays", ".", "asList", "(", "array", ")", ".", "iterator", "(", ")", ")", ";", "}" ]
Formats the items in an Array. @param array The array to format @return A String representing the single DSV formatted row
[ "Formats", "the", "items", "in", "an", "Array", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/string/CSVFormatter.java#L235-L243
145,499
josueeduardo/snappy
plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/FileUtils.java
FileUtils.sha1Hash
public static String sha1Hash(File file) throws IOException { try { DigestInputStream inputStream = new DigestInputStream( new FileInputStream(file), MessageDigest.getInstance("SHA-1")); try { byte[] buffer = new byte[4098]; while (inputStream.read(buffer) != -1) { // Read the entire stream } return bytesToHex(inputStream.getMessageDigest().digest()); } finally { inputStream.close(); } } catch (NoSuchAlgorithmException ex) { throw new IllegalStateException(ex); } }
java
public static String sha1Hash(File file) throws IOException { try { DigestInputStream inputStream = new DigestInputStream( new FileInputStream(file), MessageDigest.getInstance("SHA-1")); try { byte[] buffer = new byte[4098]; while (inputStream.read(buffer) != -1) { // Read the entire stream } return bytesToHex(inputStream.getMessageDigest().digest()); } finally { inputStream.close(); } } catch (NoSuchAlgorithmException ex) { throw new IllegalStateException(ex); } }
[ "public", "static", "String", "sha1Hash", "(", "File", "file", ")", "throws", "IOException", "{", "try", "{", "DigestInputStream", "inputStream", "=", "new", "DigestInputStream", "(", "new", "FileInputStream", "(", "file", ")", ",", "MessageDigest", ".", "getInstance", "(", "\"SHA-1\"", ")", ")", ";", "try", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "4098", "]", ";", "while", "(", "inputStream", ".", "read", "(", "buffer", ")", "!=", "-", "1", ")", "{", "// Read the entire stream", "}", "return", "bytesToHex", "(", "inputStream", ".", "getMessageDigest", "(", ")", ".", "digest", "(", ")", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "NoSuchAlgorithmException", "ex", ")", "{", "throw", "new", "IllegalStateException", "(", "ex", ")", ";", "}", "}" ]
Generate a SHA.1 Hash for a given file. @param file the file to hash @return the hash value as a String @throws IOException if the file cannot be read
[ "Generate", "a", "SHA", ".", "1", "Hash", "for", "a", "given", "file", "." ]
d95a9e811eda3c24a5e53086369208819884fa49
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/FileUtils.java#L66-L82