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,000
Mthwate/DatLib
src/main/java/com/mthwate/datlib/HashUtils.java
HashUtils.sha256Hex
public static String sha256Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha256Hex(data.getBytes(charset)); }
java
public static String sha256Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha256Hex(data.getBytes(charset)); }
[ "public", "static", "String", "sha256Hex", "(", "String", "data", ",", "Charset", "charset", ")", "throws", "NoSuchAlgorithmException", "{", "return", "sha256Hex", "(", "data", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Hashes a string using the SHA-256 algorithm. Returns a hexadecimal result. @since 1.1 @param data the string to hash @param charset the charset of the string @return the hexadecimal SHA-256 hash of the string @throws NoSuchAlgorithmException the algorithm is not supported by existing providers
[ "Hashes", "a", "string", "using", "the", "SHA", "-", "256", "algorithm", ".", "Returns", "a", "hexadecimal", "result", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L434-L436
145,001
Mthwate/DatLib
src/main/java/com/mthwate/datlib/HashUtils.java
HashUtils.sha384Hash
public static byte[] sha384Hash(String data, Charset charset) throws NoSuchAlgorithmException { return sha384Hash(data.getBytes(charset)); }
java
public static byte[] sha384Hash(String data, Charset charset) throws NoSuchAlgorithmException { return sha384Hash(data.getBytes(charset)); }
[ "public", "static", "byte", "[", "]", "sha384Hash", "(", "String", "data", ",", "Charset", "charset", ")", "throws", "NoSuchAlgorithmException", "{", "return", "sha384Hash", "(", "data", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Hashes a string using the SHA-384 algorithm. @since 1.1 @param data the string to hash @param charset the charset of the string @return the SHA-384 hash of the string @throws NoSuchAlgorithmException the algorithm is not supported by existing providers
[ "Hashes", "a", "string", "using", "the", "SHA", "-", "384", "algorithm", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L471-L473
145,002
Mthwate/DatLib
src/main/java/com/mthwate/datlib/HashUtils.java
HashUtils.sha384Hex
public static String sha384Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha384Hex(data.getBytes(charset)); }
java
public static String sha384Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha384Hex(data.getBytes(charset)); }
[ "public", "static", "String", "sha384Hex", "(", "String", "data", ",", "Charset", "charset", ")", "throws", "NoSuchAlgorithmException", "{", "return", "sha384Hex", "(", "data", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Hashes a string using the SHA-384 algorithm. Returns a hexadecimal result. @since 1.1 @param data the string to hash @param charset the charset of the string @return the hexadecimal SHA-384 hash of the string @throws NoSuchAlgorithmException the algorithm is not supported by existing providers
[ "Hashes", "a", "string", "using", "the", "SHA", "-", "384", "algorithm", ".", "Returns", "a", "hexadecimal", "result", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L508-L510
145,003
Mthwate/DatLib
src/main/java/com/mthwate/datlib/HashUtils.java
HashUtils.sha512Hash
public static byte[] sha512Hash(String data, Charset charset) throws NoSuchAlgorithmException { return sha512Hash(data.getBytes(charset)); }
java
public static byte[] sha512Hash(String data, Charset charset) throws NoSuchAlgorithmException { return sha512Hash(data.getBytes(charset)); }
[ "public", "static", "byte", "[", "]", "sha512Hash", "(", "String", "data", ",", "Charset", "charset", ")", "throws", "NoSuchAlgorithmException", "{", "return", "sha512Hash", "(", "data", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Hashes a string using the SHA-512 algorithm. @since 1.1 @param data the string to hash @param charset the charset of the string @return the SHA-512 hash of the string @throws NoSuchAlgorithmException the algorithm is not supported by existing providers
[ "Hashes", "a", "string", "using", "the", "SHA", "-", "512", "algorithm", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L545-L547
145,004
Mthwate/DatLib
src/main/java/com/mthwate/datlib/HashUtils.java
HashUtils.sha512Hex
public static String sha512Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha512Hex(data.getBytes(charset)); }
java
public static String sha512Hex(String data, Charset charset) throws NoSuchAlgorithmException { return sha512Hex(data.getBytes(charset)); }
[ "public", "static", "String", "sha512Hex", "(", "String", "data", ",", "Charset", "charset", ")", "throws", "NoSuchAlgorithmException", "{", "return", "sha512Hex", "(", "data", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Hashes a string using the SHA-512 algorithm. Returns a hexadecimal result. @since 1.1 @param data the string to hash @param charset the charset of the string @return the hexadecimal SHA-512 hash of the string @throws NoSuchAlgorithmException the algorithm is not supported by existing providers
[ "Hashes", "a", "string", "using", "the", "SHA", "-", "512", "algorithm", ".", "Returns", "a", "hexadecimal", "result", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L582-L584
145,005
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.ceylonRepoPath
public static String ceylonRepoPath(final String groupId, final String artifactId, final String version, final String classifier, final String extension) { StringBuilder path = new StringBuilder(STRING_BUILDER_SIZE); path.append(formatAsDirectory(groupId)).append(PATH_SEPARATOR); path.append(artifactId).append(PATH_SEPARATOR); path.append(version).append(PATH_SEPARATOR); path.append(ceylonModuleName(groupId, artifactId, version, classifier, extension)); return path.toString(); }
java
public static String ceylonRepoPath(final String groupId, final String artifactId, final String version, final String classifier, final String extension) { StringBuilder path = new StringBuilder(STRING_BUILDER_SIZE); path.append(formatAsDirectory(groupId)).append(PATH_SEPARATOR); path.append(artifactId).append(PATH_SEPARATOR); path.append(version).append(PATH_SEPARATOR); path.append(ceylonModuleName(groupId, artifactId, version, classifier, extension)); return path.toString(); }
[ "public", "static", "String", "ceylonRepoPath", "(", "final", "String", "groupId", ",", "final", "String", "artifactId", ",", "final", "String", "version", ",", "final", "String", "classifier", ",", "final", "String", "extension", ")", "{", "StringBuilder", "path", "=", "new", "StringBuilder", "(", "STRING_BUILDER_SIZE", ")", ";", "path", ".", "append", "(", "formatAsDirectory", "(", "groupId", ")", ")", ".", "append", "(", "PATH_SEPARATOR", ")", ";", "path", ".", "append", "(", "artifactId", ")", ".", "append", "(", "PATH_SEPARATOR", ")", ";", "path", ".", "append", "(", "version", ")", ".", "append", "(", "PATH_SEPARATOR", ")", ";", "path", ".", "append", "(", "ceylonModuleName", "(", "groupId", ",", "artifactId", ",", "version", ",", "classifier", ",", "extension", ")", ")", ";", "return", "path", ".", "toString", "(", ")", ";", "}" ]
Determines the relative path of a module atifact within a Ceylon repo. @param groupId Maven group id @param artifactId Maven artifact id @param version Version @param classifier Sources, javadoc etc. @param extension The extension or packaging of the artifact @return String The computed path
[ "Determines", "the", "relative", "path", "of", "a", "module", "atifact", "within", "a", "Ceylon", "repo", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L118-L129
145,006
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.ceylonModuleName
public static String ceylonModuleName(final String groupId, final String artifactId, final String version, final String classifier, final String extension) { if (version == null || "".equals(version) || version.contains("-")) { // TODO fix the '-' based on the new Herd rules throw new IllegalArgumentException(" Null, empty, or '-' is not allowed in version"); } StringBuilder name = new StringBuilder(STRING_BUILDER_SIZE); name.append(ceylonModuleBaseName(groupId, artifactId)) .append(ARTIFACT_SEPARATOR).append(version); if (extension != null) { name.append(GROUP_SEPARATOR).append(extension); } else { name.append(GROUP_SEPARATOR).append("car"); } return name.toString(); }
java
public static String ceylonModuleName(final String groupId, final String artifactId, final String version, final String classifier, final String extension) { if (version == null || "".equals(version) || version.contains("-")) { // TODO fix the '-' based on the new Herd rules throw new IllegalArgumentException(" Null, empty, or '-' is not allowed in version"); } StringBuilder name = new StringBuilder(STRING_BUILDER_SIZE); name.append(ceylonModuleBaseName(groupId, artifactId)) .append(ARTIFACT_SEPARATOR).append(version); if (extension != null) { name.append(GROUP_SEPARATOR).append(extension); } else { name.append(GROUP_SEPARATOR).append("car"); } return name.toString(); }
[ "public", "static", "String", "ceylonModuleName", "(", "final", "String", "groupId", ",", "final", "String", "artifactId", ",", "final", "String", "version", ",", "final", "String", "classifier", ",", "final", "String", "extension", ")", "{", "if", "(", "version", "==", "null", "||", "\"\"", ".", "equals", "(", "version", ")", "||", "version", ".", "contains", "(", "\"-\"", ")", ")", "{", "// TODO fix the '-' based on the new Herd rules\r", "throw", "new", "IllegalArgumentException", "(", "\" Null, empty, or '-' is not allowed in version\"", ")", ";", "}", "StringBuilder", "name", "=", "new", "StringBuilder", "(", "STRING_BUILDER_SIZE", ")", ";", "name", ".", "append", "(", "ceylonModuleBaseName", "(", "groupId", ",", "artifactId", ")", ")", ".", "append", "(", "ARTIFACT_SEPARATOR", ")", ".", "append", "(", "version", ")", ";", "if", "(", "extension", "!=", "null", ")", "{", "name", ".", "append", "(", "GROUP_SEPARATOR", ")", ".", "append", "(", "extension", ")", ";", "}", "else", "{", "name", ".", "append", "(", "GROUP_SEPARATOR", ")", ".", "append", "(", "\"car\"", ")", ";", "}", "return", "name", ".", "toString", "(", ")", ";", "}" ]
Comes up with a Ceylon module name based on Maven coordinates. @param groupId Maven group id @param artifactId Maven artifact id @param version Version @param classifier Sources, javadoc etc. @param extension The extension or packaging of the artifact @return String The module name
[ "Comes", "up", "with", "a", "Ceylon", "module", "name", "based", "on", "Maven", "coordinates", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L141-L161
145,007
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.calculateChecksum
public static String calculateChecksum(final File installedFile) throws MojoExecutionException { int bufsize = CHECKSUM_BUFFER_SIZE; byte[] buffer = new byte[bufsize]; FileInputStream fis = null; BufferedInputStream bis = null; String checksum = null; try { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); fis = new FileInputStream(installedFile); sha1.reset(); int size = fis.read(buffer, 0, bufsize); while (size >= 0) { sha1.update(buffer, 0, size); size = fis.read(buffer, 0, bufsize); } checksum = String.format("%040x", new BigInteger(1, sha1.digest())); } catch (Exception e) { throw new MojoExecutionException("Failed to calculate digest checksum for " + installedFile, e); } finally { IOUtil.close(bis); IOUtil.close(fis); } if (checksum != null) { return checksum; } else { throw new MojoExecutionException("Failed to calculate digest checksum for " + installedFile); } }
java
public static String calculateChecksum(final File installedFile) throws MojoExecutionException { int bufsize = CHECKSUM_BUFFER_SIZE; byte[] buffer = new byte[bufsize]; FileInputStream fis = null; BufferedInputStream bis = null; String checksum = null; try { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); fis = new FileInputStream(installedFile); sha1.reset(); int size = fis.read(buffer, 0, bufsize); while (size >= 0) { sha1.update(buffer, 0, size); size = fis.read(buffer, 0, bufsize); } checksum = String.format("%040x", new BigInteger(1, sha1.digest())); } catch (Exception e) { throw new MojoExecutionException("Failed to calculate digest checksum for " + installedFile, e); } finally { IOUtil.close(bis); IOUtil.close(fis); } if (checksum != null) { return checksum; } else { throw new MojoExecutionException("Failed to calculate digest checksum for " + installedFile); } }
[ "public", "static", "String", "calculateChecksum", "(", "final", "File", "installedFile", ")", "throws", "MojoExecutionException", "{", "int", "bufsize", "=", "CHECKSUM_BUFFER_SIZE", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "bufsize", "]", ";", "FileInputStream", "fis", "=", "null", ";", "BufferedInputStream", "bis", "=", "null", ";", "String", "checksum", "=", "null", ";", "try", "{", "MessageDigest", "sha1", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA-1\"", ")", ";", "fis", "=", "new", "FileInputStream", "(", "installedFile", ")", ";", "sha1", ".", "reset", "(", ")", ";", "int", "size", "=", "fis", ".", "read", "(", "buffer", ",", "0", ",", "bufsize", ")", ";", "while", "(", "size", ">=", "0", ")", "{", "sha1", ".", "update", "(", "buffer", ",", "0", ",", "size", ")", ";", "size", "=", "fis", ".", "read", "(", "buffer", ",", "0", ",", "bufsize", ")", ";", "}", "checksum", "=", "String", ".", "format", "(", "\"%040x\"", ",", "new", "BigInteger", "(", "1", ",", "sha1", ".", "digest", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Failed to calculate digest checksum for \"", "+", "installedFile", ",", "e", ")", ";", "}", "finally", "{", "IOUtil", ".", "close", "(", "bis", ")", ";", "IOUtil", ".", "close", "(", "fis", ")", ";", "}", "if", "(", "checksum", "!=", "null", ")", "{", "return", "checksum", ";", "}", "else", "{", "throw", "new", "MojoExecutionException", "(", "\"Failed to calculate digest checksum for \"", "+", "installedFile", ")", ";", "}", "}" ]
Calculates the SHA1 checksum for a file using a crude method. @param installedFile The installed artifact for which the checksum is being computed @return String The SHA1 checksum @throws MojoExecutionException In case of IO error or checksum calculation error
[ "Calculates", "the", "SHA1", "checksum", "for", "a", "file", "using", "a", "crude", "method", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L184-L214
145,008
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.extractFile
public static void extractFile(final ZipInputStream in, final File outdir, final String name) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(outdir, name))); int count = -1; while ((count = in.read(buffer)) != -1) { out.write(buffer, 0, count); } out.close(); }
java
public static void extractFile(final ZipInputStream in, final File outdir, final String name) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(outdir, name))); int count = -1; while ((count = in.read(buffer)) != -1) { out.write(buffer, 0, count); } out.close(); }
[ "public", "static", "void", "extractFile", "(", "final", "ZipInputStream", "in", ",", "final", "File", "outdir", ",", "final", "String", "name", ")", "throws", "IOException", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "BufferedOutputStream", "out", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "new", "File", "(", "outdir", ",", "name", ")", ")", ")", ";", "int", "count", "=", "-", "1", ";", "while", "(", "(", "count", "=", "in", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "out", ".", "write", "(", "buffer", ",", "0", ",", "count", ")", ";", "}", "out", ".", "close", "(", ")", ";", "}" ]
Extracts a single file from a zip archive. @param in Input zip stream @param outdir Output directory @param name File name @throws IOException In case of IO error
[ "Extracts", "a", "single", "file", "from", "a", "zip", "archive", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L223-L231
145,009
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.mkdirs
public static void mkdirs(final File outdir, final String path) { File d = new File(outdir, path); if (!d.exists()) { d.mkdirs(); } }
java
public static void mkdirs(final File outdir, final String path) { File d = new File(outdir, path); if (!d.exists()) { d.mkdirs(); } }
[ "public", "static", "void", "mkdirs", "(", "final", "File", "outdir", ",", "final", "String", "path", ")", "{", "File", "d", "=", "new", "File", "(", "outdir", ",", "path", ")", ";", "if", "(", "!", "d", ".", "exists", "(", ")", ")", "{", "d", ".", "mkdirs", "(", ")", ";", "}", "}" ]
Creates directories from an existing file to an additional path. @param outdir Existing directory @param path Additional path
[ "Creates", "directories", "from", "an", "existing", "file", "to", "an", "additional", "path", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L238-L243
145,010
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/common/CeylonUtil.java
CeylonUtil.dirpart
public static String dirpart(final String path) { int s = path.lastIndexOf(File.separatorChar); if (s != -1) { return path.substring(0, s); } else { return null; } }
java
public static String dirpart(final String path) { int s = path.lastIndexOf(File.separatorChar); if (s != -1) { return path.substring(0, s); } else { return null; } }
[ "public", "static", "String", "dirpart", "(", "final", "String", "path", ")", "{", "int", "s", "=", "path", ".", "lastIndexOf", "(", "File", ".", "separatorChar", ")", ";", "if", "(", "s", "!=", "-", "1", ")", "{", "return", "path", ".", "substring", "(", "0", ",", "s", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the directory part of path string. @param path Input path @return String The directory part of the path
[ "Returns", "the", "directory", "part", "of", "path", "string", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/CeylonUtil.java#L250-L257
145,011
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/unbbayes/ShanksAgentBayesianReasoningCapability.java
ShanksAgentBayesianReasoningCapability.addSoftEvidences
public static void addSoftEvidences(BayesianReasonerShanksAgent agent, HashMap<String, HashMap<String, Double>> softEvidences) throws ShanksException { ShanksAgentBayesianReasoningCapability.addSoftEvidences( agent.getBayesianNetwork(), softEvidences); }
java
public static void addSoftEvidences(BayesianReasonerShanksAgent agent, HashMap<String, HashMap<String, Double>> softEvidences) throws ShanksException { ShanksAgentBayesianReasoningCapability.addSoftEvidences( agent.getBayesianNetwork(), softEvidences); }
[ "public", "static", "void", "addSoftEvidences", "(", "BayesianReasonerShanksAgent", "agent", ",", "HashMap", "<", "String", ",", "HashMap", "<", "String", ",", "Double", ">", ">", "softEvidences", ")", "throws", "ShanksException", "{", "ShanksAgentBayesianReasoningCapability", ".", "addSoftEvidences", "(", "agent", ".", "getBayesianNetwork", "(", ")", ",", "softEvidences", ")", ";", "}" ]
Add a set of soft-evidences to the Bayesian network to reason with it. @param agent @param softEvidences @throws ShanksException
[ "Add", "a", "set", "of", "soft", "-", "evidences", "to", "the", "Bayesian", "network", "to", "reason", "with", "it", "." ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/unbbayes/ShanksAgentBayesianReasoningCapability.java#L629-L634
145,012
duraspace/fcrepo-cloudsync
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java
StringUtil.normalize
public static String normalize(String val) { if (val == null || val.trim().length() == 0) return null; return val.trim(); }
java
public static String normalize(String val) { if (val == null || val.trim().length() == 0) return null; return val.trim(); }
[ "public", "static", "String", "normalize", "(", "String", "val", ")", "{", "if", "(", "val", "==", "null", "||", "val", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "return", "val", ".", "trim", "(", ")", ";", "}" ]
Normalizes the given string by trimming it if non-null and returning null if null or empty. @param val the string value to normalize. @return the normalized value.
[ "Normalizes", "the", "given", "string", "by", "trimming", "it", "if", "non", "-", "null", "and", "returning", "null", "if", "null", "or", "empty", "." ]
2d90e2c9c84a827f2605607ff40e116c67eff9b9
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java#L14-L17
145,013
duraspace/fcrepo-cloudsync
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java
StringUtil.validate
public static String validate(String name, String value, int maxLen) throws IllegalArgumentException { String normVal = normalize(value); if (normVal == null) { throw new IllegalArgumentException("A value must be specified for" + " '" + name + "'"); } else if (normVal.length() > maxLen) { throw new IllegalArgumentException("The value specified for" + " '" + name + "' was too long. It must not exceed" + " " + maxLen + " characters."); } return normVal; }
java
public static String validate(String name, String value, int maxLen) throws IllegalArgumentException { String normVal = normalize(value); if (normVal == null) { throw new IllegalArgumentException("A value must be specified for" + " '" + name + "'"); } else if (normVal.length() > maxLen) { throw new IllegalArgumentException("The value specified for" + " '" + name + "' was too long. It must not exceed" + " " + maxLen + " characters."); } return normVal; }
[ "public", "static", "String", "validate", "(", "String", "name", ",", "String", "value", ",", "int", "maxLen", ")", "throws", "IllegalArgumentException", "{", "String", "normVal", "=", "normalize", "(", "value", ")", ";", "if", "(", "normVal", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A value must be specified for\"", "+", "\" '\"", "+", "name", "+", "\"'\"", ")", ";", "}", "else", "if", "(", "normVal", ".", "length", "(", ")", ">", "maxLen", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The value specified for\"", "+", "\" '\"", "+", "name", "+", "\"' was too long. It must not exceed\"", "+", "\" \"", "+", "maxLen", "+", "\" characters.\"", ")", ";", "}", "return", "normVal", ";", "}" ]
Checks that the given value's normalized length is in the allowed range. @param name the name of the property being checked, for error reporting. @param value the value. @param maxLen the maximum length allowed. @return the normalized value. @throws IllegalArgumentException if the normalized value is null, zero-length, or exceeds the maximum length specified.
[ "Checks", "that", "the", "given", "value", "s", "normalized", "length", "is", "in", "the", "allowed", "range", "." ]
2d90e2c9c84a827f2605607ff40e116c67eff9b9
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java#L29-L41
145,014
duraspace/fcrepo-cloudsync
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java
StringUtil.validate
public static String validate(String name, String value, String[] validValues) throws IllegalArgumentException { String normVal = validate(name, value, Integer.MAX_VALUE); StringBuilder s = new StringBuilder(); for (int i = 0; i < validValues.length; i++) { if (i > 0) { s.append(", "); } s.append("'"); s.append(validValues[i]); s.append("'"); if (normVal.equals(validValues[i])) return normVal; } throw new IllegalArgumentException("One of the following values must" + " be specified for '" + name + "': [ " + s.toString() + " ]"); }
java
public static String validate(String name, String value, String[] validValues) throws IllegalArgumentException { String normVal = validate(name, value, Integer.MAX_VALUE); StringBuilder s = new StringBuilder(); for (int i = 0; i < validValues.length; i++) { if (i > 0) { s.append(", "); } s.append("'"); s.append(validValues[i]); s.append("'"); if (normVal.equals(validValues[i])) return normVal; } throw new IllegalArgumentException("One of the following values must" + " be specified for '" + name + "': [ " + s.toString() + " ]"); }
[ "public", "static", "String", "validate", "(", "String", "name", ",", "String", "value", ",", "String", "[", "]", "validValues", ")", "throws", "IllegalArgumentException", "{", "String", "normVal", "=", "validate", "(", "name", ",", "value", ",", "Integer", ".", "MAX_VALUE", ")", ";", "StringBuilder", "s", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "validValues", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "s", ".", "append", "(", "\", \"", ")", ";", "}", "s", ".", "append", "(", "\"'\"", ")", ";", "s", ".", "append", "(", "validValues", "[", "i", "]", ")", ";", "s", ".", "append", "(", "\"'\"", ")", ";", "if", "(", "normVal", ".", "equals", "(", "validValues", "[", "i", "]", ")", ")", "return", "normVal", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"One of the following values must\"", "+", "\" be specified for '\"", "+", "name", "+", "\"': [ \"", "+", "s", ".", "toString", "(", ")", "+", "\" ]\"", ")", ";", "}" ]
Checks that the given value's normalized form is one of the allowed values. @param name the name of the property being checked, for error reporting. @param value the value. @param validValues the allowed values. @return the normalized value. @throws IllegalArgumentException if the normalized value is null, zero-length, or not one of the allowed values.
[ "Checks", "that", "the", "given", "value", "s", "normalized", "form", "is", "one", "of", "the", "allowed", "values", "." ]
2d90e2c9c84a827f2605607ff40e116c67eff9b9
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/util/StringUtil.java#L54-L70
145,015
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/NetworkElement.java
NetworkElement.changeProperty
public void changeProperty(String propertyName, Object propertyValue) throws ShanksException { this.properties.put(propertyName, propertyValue); this.checkStatus(); }
java
public void changeProperty(String propertyName, Object propertyValue) throws ShanksException { this.properties.put(propertyName, propertyValue); this.checkStatus(); }
[ "public", "void", "changeProperty", "(", "String", "propertyName", ",", "Object", "propertyValue", ")", "throws", "ShanksException", "{", "this", ".", "properties", ".", "put", "(", "propertyName", ",", "propertyValue", ")", ";", "this", ".", "checkStatus", "(", ")", ";", "}" ]
If the property exists, this method changes it. If not, this method creates it. @param propertyName @param propertyValue @throws UnsupportedNetworkElementFieldException
[ "If", "the", "property", "exists", "this", "method", "changes", "it", ".", "If", "not", "this", "method", "creates", "it", "." ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/NetworkElement.java#L253-L257
145,016
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/NetworkElement.java
NetworkElement.getPossibleStates
public List<String> getPossibleStates() { List<String> copy = new ArrayList<String>(); for (String possibleStatus : states.keySet()) { copy.add(possibleStatus); } return copy; }
java
public List<String> getPossibleStates() { List<String> copy = new ArrayList<String>(); for (String possibleStatus : states.keySet()) { copy.add(possibleStatus); } return copy; }
[ "public", "List", "<", "String", ">", "getPossibleStates", "(", ")", "{", "List", "<", "String", ">", "copy", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "possibleStatus", ":", "states", ".", "keySet", "(", ")", ")", "{", "copy", ".", "add", "(", "possibleStatus", ")", ";", "}", "return", "copy", ";", "}" ]
This method only returns a copy of the list, if you modify the copy, the internal list of PossibleStates will be not modified. To interact with the real list, use "addPossibleStatus" and "removePossibleStatus" methods @return a copy of possibleStates list
[ "This", "method", "only", "returns", "a", "copy", "of", "the", "list", "if", "you", "modify", "the", "copy", "the", "internal", "list", "of", "PossibleStates", "will", "be", "not", "modified", ".", "To", "interact", "with", "the", "real", "list", "use", "addPossibleStatus", "and", "removePossibleStatus", "methods" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/NetworkElement.java#L284-L290
145,017
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java
SrcGen4JConfig.addParser
public final void addParser(@NotNull final ParserConfig parser) { Contract.requireArgNotNull("parser", parser); if (parsers == null) { parsers = new Parsers(); } parsers.addParser(parser); }
java
public final void addParser(@NotNull final ParserConfig parser) { Contract.requireArgNotNull("parser", parser); if (parsers == null) { parsers = new Parsers(); } parsers.addParser(parser); }
[ "public", "final", "void", "addParser", "(", "@", "NotNull", "final", "ParserConfig", "parser", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"parser\"", ",", "parser", ")", ";", "if", "(", "parsers", "==", "null", ")", "{", "parsers", "=", "new", "Parsers", "(", ")", ";", "}", "parsers", ".", "addParser", "(", "parser", ")", ";", "}" ]
Adds a parser to the configuration. If the list of parsers does not exist it will be created. @param parser Parser to add.
[ "Adds", "a", "parser", "to", "the", "configuration", ".", "If", "the", "list", "of", "parsers", "does", "not", "exist", "it", "will", "be", "created", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java#L193-L199
145,018
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java
SrcGen4JConfig.findTargetFolder
public final Folder findTargetFolder(@NotNull final String generatorName, @NotNull final String artifactName) throws ProjectNameNotDefinedException, ArtifactNotFoundException, FolderNameNotDefinedException, GeneratorNotFoundException, ProjectNotFoundException, FolderNotFoundException { Contract.requireArgNotNull("generatorName", generatorName); Contract.requireArgNotNull("artifactName", artifactName); return findTargetFolder(generatorName, artifactName, null); }
java
public final Folder findTargetFolder(@NotNull final String generatorName, @NotNull final String artifactName) throws ProjectNameNotDefinedException, ArtifactNotFoundException, FolderNameNotDefinedException, GeneratorNotFoundException, ProjectNotFoundException, FolderNotFoundException { Contract.requireArgNotNull("generatorName", generatorName); Contract.requireArgNotNull("artifactName", artifactName); return findTargetFolder(generatorName, artifactName, null); }
[ "public", "final", "Folder", "findTargetFolder", "(", "@", "NotNull", "final", "String", "generatorName", ",", "@", "NotNull", "final", "String", "artifactName", ")", "throws", "ProjectNameNotDefinedException", ",", "ArtifactNotFoundException", ",", "FolderNameNotDefinedException", ",", "GeneratorNotFoundException", ",", "ProjectNotFoundException", ",", "FolderNotFoundException", "{", "Contract", ".", "requireArgNotNull", "(", "\"generatorName\"", ",", "generatorName", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"artifactName\"", ",", "artifactName", ")", ";", "return", "findTargetFolder", "(", "generatorName", ",", "artifactName", ",", "null", ")", ";", "}" ]
Returns a target directory for a given combination of generator name and artifact name. @param generatorName Name of the generator. @param artifactName Name of the artifact. @return Target file based on the configuration. @throws GeneratorNotFoundException The given generator name was not found in the configuration. @throws ArtifactNotFoundException The given artifact was not found in the generator. @throws ProjectNameNotDefinedException No project name is bound to the given combination. @throws FolderNameNotDefinedException No folder name is bound to the given combination. @throws ProjectNotFoundException The project name based on the selection is unknown. @throws FolderNotFoundException The folder in the project based on the selection is unknown.
[ "Returns", "a", "target", "directory", "for", "a", "given", "combination", "of", "generator", "name", "and", "artifact", "name", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java#L308-L317
145,019
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java
SrcGen4JConfig.findTargetFolder
public final Folder findTargetFolder(@NotNull final String generatorName, @NotNull final String artifactName, final String targetPath) throws ProjectNameNotDefinedException, ArtifactNotFoundException, FolderNameNotDefinedException, GeneratorNotFoundException, ProjectNotFoundException, FolderNotFoundException { Contract.requireArgNotNull("generatorName", generatorName); Contract.requireArgNotNull("artifactName", artifactName); final GeneratorConfig generator = generators.findByName(generatorName); int idx = generator.getArtifacts().indexOf(new Artifact(artifactName)); if (idx < 0) { throw new ArtifactNotFoundException(generatorName, artifactName); } final Artifact artifact = generator.getArtifacts().get(idx); final String projectName; final String folderName; final String targetPattern; final Target target = artifact.findTargetFor(targetPath); if (target == null) { projectName = artifact.getDefProject(); folderName = artifact.getDefFolder(); targetPattern = null; } else { projectName = target.getDefProject(); folderName = target.getDefFolder(); targetPattern = target.getPattern(); } if (projectName == null) { throw new ProjectNameNotDefinedException(generatorName, artifactName, targetPattern); } if (folderName == null) { throw new FolderNameNotDefinedException(generatorName, artifactName, targetPattern); } idx = projects.indexOf(new Project(projectName, "dummy")); if (idx < 0) { throw new ProjectNotFoundException(generatorName, artifactName, targetPattern, projectName); } final Project project = projects.get(idx); idx = project.getFolders().indexOf(new Folder(folderName, "NotUsed")); if (idx < 0) { throw new FolderNotFoundException(generatorName, artifactName, targetPattern, projectName, folderName); } return project.getFolders().get(idx); }
java
public final Folder findTargetFolder(@NotNull final String generatorName, @NotNull final String artifactName, final String targetPath) throws ProjectNameNotDefinedException, ArtifactNotFoundException, FolderNameNotDefinedException, GeneratorNotFoundException, ProjectNotFoundException, FolderNotFoundException { Contract.requireArgNotNull("generatorName", generatorName); Contract.requireArgNotNull("artifactName", artifactName); final GeneratorConfig generator = generators.findByName(generatorName); int idx = generator.getArtifacts().indexOf(new Artifact(artifactName)); if (idx < 0) { throw new ArtifactNotFoundException(generatorName, artifactName); } final Artifact artifact = generator.getArtifacts().get(idx); final String projectName; final String folderName; final String targetPattern; final Target target = artifact.findTargetFor(targetPath); if (target == null) { projectName = artifact.getDefProject(); folderName = artifact.getDefFolder(); targetPattern = null; } else { projectName = target.getDefProject(); folderName = target.getDefFolder(); targetPattern = target.getPattern(); } if (projectName == null) { throw new ProjectNameNotDefinedException(generatorName, artifactName, targetPattern); } if (folderName == null) { throw new FolderNameNotDefinedException(generatorName, artifactName, targetPattern); } idx = projects.indexOf(new Project(projectName, "dummy")); if (idx < 0) { throw new ProjectNotFoundException(generatorName, artifactName, targetPattern, projectName); } final Project project = projects.get(idx); idx = project.getFolders().indexOf(new Folder(folderName, "NotUsed")); if (idx < 0) { throw new FolderNotFoundException(generatorName, artifactName, targetPattern, projectName, folderName); } return project.getFolders().get(idx); }
[ "public", "final", "Folder", "findTargetFolder", "(", "@", "NotNull", "final", "String", "generatorName", ",", "@", "NotNull", "final", "String", "artifactName", ",", "final", "String", "targetPath", ")", "throws", "ProjectNameNotDefinedException", ",", "ArtifactNotFoundException", ",", "FolderNameNotDefinedException", ",", "GeneratorNotFoundException", ",", "ProjectNotFoundException", ",", "FolderNotFoundException", "{", "Contract", ".", "requireArgNotNull", "(", "\"generatorName\"", ",", "generatorName", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"artifactName\"", ",", "artifactName", ")", ";", "final", "GeneratorConfig", "generator", "=", "generators", ".", "findByName", "(", "generatorName", ")", ";", "int", "idx", "=", "generator", ".", "getArtifacts", "(", ")", ".", "indexOf", "(", "new", "Artifact", "(", "artifactName", ")", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "throw", "new", "ArtifactNotFoundException", "(", "generatorName", ",", "artifactName", ")", ";", "}", "final", "Artifact", "artifact", "=", "generator", ".", "getArtifacts", "(", ")", ".", "get", "(", "idx", ")", ";", "final", "String", "projectName", ";", "final", "String", "folderName", ";", "final", "String", "targetPattern", ";", "final", "Target", "target", "=", "artifact", ".", "findTargetFor", "(", "targetPath", ")", ";", "if", "(", "target", "==", "null", ")", "{", "projectName", "=", "artifact", ".", "getDefProject", "(", ")", ";", "folderName", "=", "artifact", ".", "getDefFolder", "(", ")", ";", "targetPattern", "=", "null", ";", "}", "else", "{", "projectName", "=", "target", ".", "getDefProject", "(", ")", ";", "folderName", "=", "target", ".", "getDefFolder", "(", ")", ";", "targetPattern", "=", "target", ".", "getPattern", "(", ")", ";", "}", "if", "(", "projectName", "==", "null", ")", "{", "throw", "new", "ProjectNameNotDefinedException", "(", "generatorName", ",", "artifactName", ",", "targetPattern", ")", ";", "}", "if", "(", "folderName", "==", "null", ")", "{", "throw", "new", "FolderNameNotDefinedException", "(", "generatorName", ",", "artifactName", ",", "targetPattern", ")", ";", "}", "idx", "=", "projects", ".", "indexOf", "(", "new", "Project", "(", "projectName", ",", "\"dummy\"", ")", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "throw", "new", "ProjectNotFoundException", "(", "generatorName", ",", "artifactName", ",", "targetPattern", ",", "projectName", ")", ";", "}", "final", "Project", "project", "=", "projects", ".", "get", "(", "idx", ")", ";", "idx", "=", "project", ".", "getFolders", "(", ")", ".", "indexOf", "(", "new", "Folder", "(", "folderName", ",", "\"NotUsed\"", ")", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "throw", "new", "FolderNotFoundException", "(", "generatorName", ",", "artifactName", ",", "targetPattern", ",", "projectName", ",", "folderName", ")", ";", "}", "return", "project", ".", "getFolders", "(", ")", ".", "get", "(", "idx", ")", ";", "}" ]
Returns a target directory for a given combination of generator name, artifact name and target sub path. @param generatorName Name of the generator. @param artifactName Name of the artifact. @param targetPath Current path and file. @return Target file based on the configuration. @throws GeneratorNotFoundException The given generator name was not found in the configuration. @throws ArtifactNotFoundException The given artifact was not found in the generator. @throws ProjectNameNotDefinedException No project name is bound to the given combination. @throws FolderNameNotDefinedException No folder name is bound to the given combination. @throws ProjectNotFoundException The project name based on the selection is unknown. @throws FolderNotFoundException The folder in the project based on the selection is unknown.
[ "Returns", "a", "target", "directory", "for", "a", "given", "combination", "of", "generator", "name", "artifact", "name", "and", "target", "sub", "path", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java#L344-L392
145,020
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java
SrcGen4JConfig.findGeneratorsForParser
@NotNull public final List<GeneratorConfig> findGeneratorsForParser(@NotNull final String parserName) { Contract.requireArgNotNull("parserName", parserName); final List<GeneratorConfig> list = new ArrayList<>(); final List<GeneratorConfig> gcList = generators.getList(); for (final GeneratorConfig gc : gcList) { if (gc.getParser().equals(parserName)) { list.add(gc); } } return list; }
java
@NotNull public final List<GeneratorConfig> findGeneratorsForParser(@NotNull final String parserName) { Contract.requireArgNotNull("parserName", parserName); final List<GeneratorConfig> list = new ArrayList<>(); final List<GeneratorConfig> gcList = generators.getList(); for (final GeneratorConfig gc : gcList) { if (gc.getParser().equals(parserName)) { list.add(gc); } } return list; }
[ "@", "NotNull", "public", "final", "List", "<", "GeneratorConfig", ">", "findGeneratorsForParser", "(", "@", "NotNull", "final", "String", "parserName", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"parserName\"", ",", "parserName", ")", ";", "final", "List", "<", "GeneratorConfig", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "List", "<", "GeneratorConfig", ">", "gcList", "=", "generators", ".", "getList", "(", ")", ";", "for", "(", "final", "GeneratorConfig", "gc", ":", "gcList", ")", "{", "if", "(", "gc", ".", "getParser", "(", ")", ".", "equals", "(", "parserName", ")", ")", "{", "list", ".", "add", "(", "gc", ")", ";", "}", "}", "return", "list", ";", "}" ]
Find all generators that are connected to a given parser. @param parserName Name of the parser to return the generators for. @return List of generators.
[ "Find", "all", "generators", "that", "are", "connected", "to", "a", "given", "parser", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java#L402-L414
145,021
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java
SrcGen4JConfig.createMavenStyleSingleProject
@NotNull public static SrcGen4JConfig createMavenStyleSingleProject(@NotNull final SrcGen4JContext context, @NotNull final String projectName, @NotNull @FileExists @IsDirectory final File rootDir) { Contract.requireArgNotNull("context", context); Contract.requireArgNotNull(ROOT_DIR_VAR, rootDir); FileExistsValidator.requireArgValid(ROOT_DIR_VAR, rootDir); IsDirectoryValidator.requireArgValid(ROOT_DIR_VAR, rootDir); Contract.requireArgNotNull("projectName", projectName); final SrcGen4JConfig config = new SrcGen4JConfig(); final List<Project> projects = new ArrayList<>(); final Project project = new Project(projectName, "."); project.setMaven(true); projects.add(project); config.setProjects(projects); config.init(context, rootDir); return config; }
java
@NotNull public static SrcGen4JConfig createMavenStyleSingleProject(@NotNull final SrcGen4JContext context, @NotNull final String projectName, @NotNull @FileExists @IsDirectory final File rootDir) { Contract.requireArgNotNull("context", context); Contract.requireArgNotNull(ROOT_DIR_VAR, rootDir); FileExistsValidator.requireArgValid(ROOT_DIR_VAR, rootDir); IsDirectoryValidator.requireArgValid(ROOT_DIR_VAR, rootDir); Contract.requireArgNotNull("projectName", projectName); final SrcGen4JConfig config = new SrcGen4JConfig(); final List<Project> projects = new ArrayList<>(); final Project project = new Project(projectName, "."); project.setMaven(true); projects.add(project); config.setProjects(projects); config.init(context, rootDir); return config; }
[ "@", "NotNull", "public", "static", "SrcGen4JConfig", "createMavenStyleSingleProject", "(", "@", "NotNull", "final", "SrcGen4JContext", "context", ",", "@", "NotNull", "final", "String", "projectName", ",", "@", "NotNull", "@", "FileExists", "@", "IsDirectory", "final", "File", "rootDir", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"context\"", ",", "context", ")", ";", "Contract", ".", "requireArgNotNull", "(", "ROOT_DIR_VAR", ",", "rootDir", ")", ";", "FileExistsValidator", ".", "requireArgValid", "(", "ROOT_DIR_VAR", ",", "rootDir", ")", ";", "IsDirectoryValidator", ".", "requireArgValid", "(", "ROOT_DIR_VAR", ",", "rootDir", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"projectName\"", ",", "projectName", ")", ";", "final", "SrcGen4JConfig", "config", "=", "new", "SrcGen4JConfig", "(", ")", ";", "final", "List", "<", "Project", ">", "projects", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "Project", "project", "=", "new", "Project", "(", "projectName", ",", "\".\"", ")", ";", "project", ".", "setMaven", "(", "true", ")", ";", "projects", ".", "add", "(", "project", ")", ";", "config", ".", "setProjects", "(", "projects", ")", ";", "config", ".", "init", "(", "context", ",", "rootDir", ")", ";", "return", "config", ";", "}" ]
Creates a new configuration with a single project and a Maven directory structure. @param context Current context. @param projectName Name of the one and only project. @param rootDir Root directory that is available as variable 'srcgen4jRootDir'. @return New initialized configuration instance.
[ "Creates", "a", "new", "configuration", "with", "a", "single", "project", "and", "a", "Maven", "directory", "structure", "." ]
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4JConfig.java#L428-L446
145,022
fuinorg/srcgen4j-commons
src/main/java/org/fuin/srcgen4j/commons/Artifact.java
Artifact.addTarget
public final void addTarget(@NotNull final Target target) { Contract.requireArgNotNull("target", target); if (targets == null) { targets = new ArrayList<>(); } targets.add(target); }
java
public final void addTarget(@NotNull final Target target) { Contract.requireArgNotNull("target", target); if (targets == null) { targets = new ArrayList<>(); } targets.add(target); }
[ "public", "final", "void", "addTarget", "(", "@", "NotNull", "final", "Target", "target", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"target\"", ",", "target", ")", ";", "if", "(", "targets", "==", "null", ")", "{", "targets", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "targets", ".", "add", "(", "target", ")", ";", "}" ]
Adds a target to the list. If the list does not exist it's created. @param target Target to add.
[ "Adds", "a", "target", "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/Artifact.java#L110-L116
145,023
berkesa/datatree-promise
src/main/java/io/datatree/Resolver.java
Resolver.resolve
public final void resolve(Number value) { future.complete(new Tree((Tree) null, null, value)); }
java
public final void resolve(Number value) { future.complete(new Tree((Tree) null, null, value)); }
[ "public", "final", "void", "resolve", "(", "Number", "value", ")", "{", "future", ".", "complete", "(", "new", "Tree", "(", "(", "Tree", ")", "null", ",", "null", ",", "value", ")", ")", ";", "}" ]
Resolves the value of the current Promise with the given numeric value. @param value the value of the Promise
[ "Resolves", "the", "value", "of", "the", "current", "Promise", "with", "the", "given", "numeric", "value", "." ]
d9093bdb549f69b83b3eff5e29cd511f2014f177
https://github.com/berkesa/datatree-promise/blob/d9093bdb549f69b83b3eff5e29cd511f2014f177/src/main/java/io/datatree/Resolver.java#L90-L92
145,024
berkesa/datatree-promise
src/main/java/io/datatree/Resolver.java
Resolver.resolve
public final void resolve(String value) { future.complete(new Tree((Tree) null, null, value)); }
java
public final void resolve(String value) { future.complete(new Tree((Tree) null, null, value)); }
[ "public", "final", "void", "resolve", "(", "String", "value", ")", "{", "future", ".", "complete", "(", "new", "Tree", "(", "(", "Tree", ")", "null", ",", "null", ",", "value", ")", ")", ";", "}" ]
Resolves the value of the current Promise with the given text. @param value the value of the Promise
[ "Resolves", "the", "value", "of", "the", "current", "Promise", "with", "the", "given", "text", "." ]
d9093bdb549f69b83b3eff5e29cd511f2014f177
https://github.com/berkesa/datatree-promise/blob/d9093bdb549f69b83b3eff5e29cd511f2014f177/src/main/java/io/datatree/Resolver.java#L121-L123
145,025
berkesa/datatree-promise
src/main/java/io/datatree/Resolver.java
Resolver.resolve
public final void resolve(Date value) { future.complete(new Tree((Tree) null, null, value)); }
java
public final void resolve(Date value) { future.complete(new Tree((Tree) null, null, value)); }
[ "public", "final", "void", "resolve", "(", "Date", "value", ")", "{", "future", ".", "complete", "(", "new", "Tree", "(", "(", "Tree", ")", "null", ",", "null", ",", "value", ")", ")", ";", "}" ]
Resolves the value of the current Promise with the given date. @param value the value of the Promise
[ "Resolves", "the", "value", "of", "the", "current", "Promise", "with", "the", "given", "date", "." ]
d9093bdb549f69b83b3eff5e29cd511f2014f177
https://github.com/berkesa/datatree-promise/blob/d9093bdb549f69b83b3eff5e29cd511f2014f177/src/main/java/io/datatree/Resolver.java#L131-L133
145,026
berkesa/datatree-promise
src/main/java/io/datatree/Resolver.java
Resolver.resolve
public final void resolve(UUID value) { future.complete(new Tree((Tree) null, null, value)); }
java
public final void resolve(UUID value) { future.complete(new Tree((Tree) null, null, value)); }
[ "public", "final", "void", "resolve", "(", "UUID", "value", ")", "{", "future", ".", "complete", "(", "new", "Tree", "(", "(", "Tree", ")", "null", ",", "null", ",", "value", ")", ")", ";", "}" ]
Resolves the value of the current Promise with the given UUID. @param value the value of the Promise
[ "Resolves", "the", "value", "of", "the", "current", "Promise", "with", "the", "given", "UUID", "." ]
d9093bdb549f69b83b3eff5e29cd511f2014f177
https://github.com/berkesa/datatree-promise/blob/d9093bdb549f69b83b3eff5e29cd511f2014f177/src/main/java/io/datatree/Resolver.java#L141-L143
145,027
berkesa/datatree-promise
src/main/java/io/datatree/Resolver.java
Resolver.resolve
public final void resolve(InetAddress value) { future.complete(new Tree((Tree) null, null, value)); }
java
public final void resolve(InetAddress value) { future.complete(new Tree((Tree) null, null, value)); }
[ "public", "final", "void", "resolve", "(", "InetAddress", "value", ")", "{", "future", ".", "complete", "(", "new", "Tree", "(", "(", "Tree", ")", "null", ",", "null", ",", "value", ")", ")", ";", "}" ]
Resolves the value of the current Promise with the given InetAddress. @param value the value of the Promise
[ "Resolves", "the", "value", "of", "the", "current", "Promise", "with", "the", "given", "InetAddress", "." ]
d9093bdb549f69b83b3eff5e29cd511f2014f177
https://github.com/berkesa/datatree-promise/blob/d9093bdb549f69b83b3eff5e29cd511f2014f177/src/main/java/io/datatree/Resolver.java#L151-L153
145,028
cwilper/ttff
src/main/java/com/github/cwilper/ttff/Sources.java
Sources.empty
public static <T> Source<T> empty() { return new AbstractSource<T>() { @Override public T computeNext() { return endOfData(); } }; }
java
public static <T> Source<T> empty() { return new AbstractSource<T>() { @Override public T computeNext() { return endOfData(); } }; }
[ "public", "static", "<", "T", ">", "Source", "<", "T", ">", "empty", "(", ")", "{", "return", "new", "AbstractSource", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "computeNext", "(", ")", "{", "return", "endOfData", "(", ")", ";", "}", "}", ";", "}" ]
Gets an empty source. @param <T> the type. @return the source.
[ "Gets", "an", "empty", "source", "." ]
b351883764546078128d69c2ff0a8431dd45796b
https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L23-L30
145,029
cwilper/ttff
src/main/java/com/github/cwilper/ttff/Sources.java
Sources.from
public static <T> Source<T> from(T... items) { return from(Arrays.asList(items)); }
java
public static <T> Source<T> from(T... items) { return from(Arrays.asList(items)); }
[ "public", "static", "<", "T", ">", "Source", "<", "T", ">", "from", "(", "T", "...", "items", ")", "{", "return", "from", "(", "Arrays", ".", "asList", "(", "items", ")", ")", ";", "}" ]
Gets a source from the given items. @param items the items. @param <T> the type. @return the source.
[ "Gets", "a", "source", "from", "the", "given", "items", "." ]
b351883764546078128d69c2ff0a8431dd45796b
https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L72-L74
145,030
cwilper/ttff
src/main/java/com/github/cwilper/ttff/Sources.java
Sources.from
public static <T> Source<T> from(Collection<T> collection) { return from(collection.iterator()); }
java
public static <T> Source<T> from(Collection<T> collection) { return from(collection.iterator()); }
[ "public", "static", "<", "T", ">", "Source", "<", "T", ">", "from", "(", "Collection", "<", "T", ">", "collection", ")", "{", "return", "from", "(", "collection", ".", "iterator", "(", ")", ")", ";", "}" ]
Gets a source from the items in the given collection. @param collection the collection. @param <T> the type. @return the source.
[ "Gets", "a", "source", "from", "the", "items", "in", "the", "given", "collection", "." ]
b351883764546078128d69c2ff0a8431dd45796b
https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L83-L85
145,031
cwilper/ttff
src/main/java/com/github/cwilper/ttff/Sources.java
Sources.from
public static <T> Source<T> from(final Iterator<T> iterator) { return new AbstractSource<T>() { @Override protected T computeNext() throws IOException { if (iterator.hasNext()) { return iterator.next(); } return endOfData(); } }; }
java
public static <T> Source<T> from(final Iterator<T> iterator) { return new AbstractSource<T>() { @Override protected T computeNext() throws IOException { if (iterator.hasNext()) { return iterator.next(); } return endOfData(); } }; }
[ "public", "static", "<", "T", ">", "Source", "<", "T", ">", "from", "(", "final", "Iterator", "<", "T", ">", "iterator", ")", "{", "return", "new", "AbstractSource", "<", "T", ">", "(", ")", "{", "@", "Override", "protected", "T", "computeNext", "(", ")", "throws", "IOException", "{", "if", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "iterator", ".", "next", "(", ")", ";", "}", "return", "endOfData", "(", ")", ";", "}", "}", ";", "}" ]
Gets a source from the items in the given iterator. @param iterator the iterator. @param <T> the type. @return the source.
[ "Gets", "a", "source", "from", "the", "items", "in", "the", "given", "iterator", "." ]
b351883764546078128d69c2ff0a8431dd45796b
https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L94-L104
145,032
triceo/splitlog
splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/DefaultExceptionDescriptor.java
DefaultExceptionDescriptor.parseStackTrace
public static ExceptionDescriptor parseStackTrace(final Collection<String> lines) { if ((lines == null) || lines.isEmpty()) { throw new IllegalArgumentException("No stack trace provided."); } try { final Builder b = new Builder(); final Collection<ExceptionLine> parsedLines = new ExceptionParser().parse(lines); parsedLines.forEach(b::addLine); return b.build(); } catch (final ExceptionParseException e) { // FIXME provides no information as to why there's no exception // found return null; } }
java
public static ExceptionDescriptor parseStackTrace(final Collection<String> lines) { if ((lines == null) || lines.isEmpty()) { throw new IllegalArgumentException("No stack trace provided."); } try { final Builder b = new Builder(); final Collection<ExceptionLine> parsedLines = new ExceptionParser().parse(lines); parsedLines.forEach(b::addLine); return b.build(); } catch (final ExceptionParseException e) { // FIXME provides no information as to why there's no exception // found return null; } }
[ "public", "static", "ExceptionDescriptor", "parseStackTrace", "(", "final", "Collection", "<", "String", ">", "lines", ")", "{", "if", "(", "(", "lines", "==", "null", ")", "||", "lines", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No stack trace provided.\"", ")", ";", "}", "try", "{", "final", "Builder", "b", "=", "new", "Builder", "(", ")", ";", "final", "Collection", "<", "ExceptionLine", ">", "parsedLines", "=", "new", "ExceptionParser", "(", ")", ".", "parse", "(", "lines", ")", ";", "parsedLines", ".", "forEach", "(", "b", "::", "addLine", ")", ";", "return", "b", ".", "build", "(", ")", ";", "}", "catch", "(", "final", "ExceptionParseException", "e", ")", "{", "// FIXME provides no information as to why there's no exception", "// found", "return", "null", ";", "}", "}" ]
Take a chunk of log and try to parse an exception out of it. @param lines Any random log, separated into lines. @return First exception found, including full stack trace with causes, or null if none identified.
[ "Take", "a", "chunk", "of", "log", "and", "try", "to", "parse", "an", "exception", "out", "of", "it", "." ]
4e1b188e8c814119f5cf7343bbc53917843d68a2
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/DefaultExceptionDescriptor.java#L58-L72
145,033
wcm-io-caravan/caravan-hal
docs/src/main/java/io/wcm/caravan/hal/docs/impl/DocsPath.java
DocsPath.get
public static String get(Bundle bundle) { String applicationPath = ApplicationPath.get(bundle); if (applicationPath == null) { return null; } if (!hasHalDocs(bundle)) { return null; } return get(applicationPath); }
java
public static String get(Bundle bundle) { String applicationPath = ApplicationPath.get(bundle); if (applicationPath == null) { return null; } if (!hasHalDocs(bundle)) { return null; } return get(applicationPath); }
[ "public", "static", "String", "get", "(", "Bundle", "bundle", ")", "{", "String", "applicationPath", "=", "ApplicationPath", ".", "get", "(", "bundle", ")", ";", "if", "(", "applicationPath", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "hasHalDocs", "(", "bundle", ")", ")", "{", "return", "null", ";", "}", "return", "get", "(", "applicationPath", ")", ";", "}" ]
Gets documentation URI path. @param bundle Bundle @return Path or null if not a JAX-RS application bundle or no haldocs metadata exist.
[ "Gets", "documentation", "URI", "path", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs/src/main/java/io/wcm/caravan/hal/docs/impl/DocsPath.java#L46-L55
145,034
wcm-io-caravan/caravan-hal
docs/src/main/java/io/wcm/caravan/hal/docs/impl/DocsPath.java
DocsPath.hasHalDocs
public static boolean hasHalDocs(Bundle bundle) { return bundle.getResource(ServiceModelReader.DOCS_CLASSPATH_PREFIX + "/" + ServiceModelReader.SERVICE_DOC_FILE) != null; }
java
public static boolean hasHalDocs(Bundle bundle) { return bundle.getResource(ServiceModelReader.DOCS_CLASSPATH_PREFIX + "/" + ServiceModelReader.SERVICE_DOC_FILE) != null; }
[ "public", "static", "boolean", "hasHalDocs", "(", "Bundle", "bundle", ")", "{", "return", "bundle", ".", "getResource", "(", "ServiceModelReader", ".", "DOCS_CLASSPATH_PREFIX", "+", "\"/\"", "+", "ServiceModelReader", ".", "SERVICE_DOC_FILE", ")", "!=", "null", ";", "}" ]
Checks if the given bundle has documentation metadata stored as resource. @param bundle Bundle @return true if metadata found
[ "Checks", "if", "the", "given", "bundle", "has", "documentation", "metadata", "stored", "as", "resource", "." ]
25d58756b58c70c8c48a17fe781e673dd93d5085
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs/src/main/java/io/wcm/caravan/hal/docs/impl/DocsPath.java#L71-L73
145,035
Mthwate/DatLib
src/main/java/com/mthwate/datlib/IOUtils.java
IOUtils.getClassJar
public static File getClassJar(Class clazz) { File file = null; try { file = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) {} return file; }
java
public static File getClassJar(Class clazz) { File file = null; try { file = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) {} return file; }
[ "public", "static", "File", "getClassJar", "(", "Class", "clazz", ")", "{", "File", "file", "=", "null", ";", "try", "{", "file", "=", "new", "File", "(", "clazz", ".", "getProtectionDomain", "(", ")", ".", "getCodeSource", "(", ")", ".", "getLocation", "(", ")", ".", "toURI", "(", ")", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "}", "return", "file", ";", "}" ]
Gets the jar file a class is contained in. @since 1.0 @param clazz the class to get the container of @return the jar file the class is contained in
[ "Gets", "the", "jar", "file", "a", "class", "is", "contained", "in", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/IOUtils.java#L41-L49
145,036
Mthwate/DatLib
src/main/java/com/mthwate/datlib/IOUtils.java
IOUtils.listZipContents
public static List<String> listZipContents(File zipFile, String path) throws IOException { List<String> names = new ArrayList<>(); if(zipFile.isFile()) { ZipFile zip = null; try { zip = new ZipFile(zipFile); Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (!entry.isDirectory() && name.startsWith(path)) { names.add(name); } } } finally { close(zip); } } return names; }
java
public static List<String> listZipContents(File zipFile, String path) throws IOException { List<String> names = new ArrayList<>(); if(zipFile.isFile()) { ZipFile zip = null; try { zip = new ZipFile(zipFile); Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (!entry.isDirectory() && name.startsWith(path)) { names.add(name); } } } finally { close(zip); } } return names; }
[ "public", "static", "List", "<", "String", ">", "listZipContents", "(", "File", "zipFile", ",", "String", "path", ")", "throws", "IOException", "{", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "zipFile", ".", "isFile", "(", ")", ")", "{", "ZipFile", "zip", "=", "null", ";", "try", "{", "zip", "=", "new", "ZipFile", "(", "zipFile", ")", ";", "Enumeration", "<", "?", "extends", "ZipEntry", ">", "entries", "=", "zip", ".", "entries", "(", ")", ";", "while", "(", "entries", ".", "hasMoreElements", "(", ")", ")", "{", "ZipEntry", "entry", "=", "entries", ".", "nextElement", "(", ")", ";", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "if", "(", "!", "entry", ".", "isDirectory", "(", ")", "&&", "name", ".", "startsWith", "(", "path", ")", ")", "{", "names", ".", "add", "(", "name", ")", ";", "}", "}", "}", "finally", "{", "close", "(", "zip", ")", ";", "}", "}", "return", "names", ";", "}" ]
Lists the contents of a zip file. Only looks in the supplied path within the zip file. @since 1.0 @param zipFile the zip file to use @param path the path inside the jar file @return the contents of the zip file @throws IOException if an I/O error has occurred
[ "Lists", "the", "contents", "of", "a", "zip", "file", ".", "Only", "looks", "in", "the", "supplied", "path", "within", "the", "zip", "file", "." ]
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/IOUtils.java#L73-L95
145,037
LevelFourAB/commons
commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java
FactoryDefinition.getFieldCount
public int getFieldCount() { int result = 0; for(Argument a : arguments) { if(a instanceof FactoryDefinition.SerializedArgument) { result++; } } return result; }
java
public int getFieldCount() { int result = 0; for(Argument a : arguments) { if(a instanceof FactoryDefinition.SerializedArgument) { result++; } } return result; }
[ "public", "int", "getFieldCount", "(", ")", "{", "int", "result", "=", "0", ";", "for", "(", "Argument", "a", ":", "arguments", ")", "{", "if", "(", "a", "instanceof", "FactoryDefinition", ".", "SerializedArgument", ")", "{", "result", "++", ";", "}", "}", "return", "result", ";", "}" ]
Get the number of fields this factory covers. @return
[ "Get", "the", "number", "of", "fields", "this", "factory", "covers", "." ]
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java#L267-L278
145,038
LevelFourAB/commons
commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java
FactoryDefinition.getScore
public int getScore(Map<String, Object> data) { if(! hasSerializedFields) { return 0; } int score = 0; for(Argument arg : arguments) { if(arg instanceof FactoryDefinition.SerializedArgument) { if(data.containsKey(((SerializedArgument) arg).name)) { score++; } } } return score; }
java
public int getScore(Map<String, Object> data) { if(! hasSerializedFields) { return 0; } int score = 0; for(Argument arg : arguments) { if(arg instanceof FactoryDefinition.SerializedArgument) { if(data.containsKey(((SerializedArgument) arg).name)) { score++; } } } return score; }
[ "public", "int", "getScore", "(", "Map", "<", "String", ",", "Object", ">", "data", ")", "{", "if", "(", "!", "hasSerializedFields", ")", "{", "return", "0", ";", "}", "int", "score", "=", "0", ";", "for", "(", "Argument", "arg", ":", "arguments", ")", "{", "if", "(", "arg", "instanceof", "FactoryDefinition", ".", "SerializedArgument", ")", "{", "if", "(", "data", ".", "containsKey", "(", "(", "(", "SerializedArgument", ")", "arg", ")", ".", "name", ")", ")", "{", "score", "++", ";", "}", "}", "}", "return", "score", ";", "}" ]
Get a score for this factory based on the given data. The higher the score the more arguments were found. @param data @return
[ "Get", "a", "score", "for", "this", "factory", "based", "on", "the", "given", "data", ".", "The", "higher", "the", "score", "the", "more", "arguments", "were", "found", "." ]
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java#L287-L308
145,039
LevelFourAB/commons
commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java
FactoryDefinition.create
@SuppressWarnings("unchecked") public T create(Map<String, Object> data) { Object[] args = new Object[arguments.length]; for(int i=0, n=args.length; i<n; i++) { args[i] = arguments[i].getValue(data); } try { return (T) raw.newInstance(args); } catch(IllegalArgumentException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InstantiationException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(IllegalAccessException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InvocationTargetException e) { throw new SerializationException("Unable to create; " + e.getCause().getMessage(), e.getCause()); } }
java
@SuppressWarnings("unchecked") public T create(Map<String, Object> data) { Object[] args = new Object[arguments.length]; for(int i=0, n=args.length; i<n; i++) { args[i] = arguments[i].getValue(data); } try { return (T) raw.newInstance(args); } catch(IllegalArgumentException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InstantiationException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(IllegalAccessException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InvocationTargetException e) { throw new SerializationException("Unable to create; " + e.getCause().getMessage(), e.getCause()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "create", "(", "Map", "<", "String", ",", "Object", ">", "data", ")", "{", "Object", "[", "]", "args", "=", "new", "Object", "[", "arguments", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ",", "n", "=", "args", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "args", "[", "i", "]", "=", "arguments", "[", "i", "]", ".", "getValue", "(", "data", ")", ";", "}", "try", "{", "return", "(", "T", ")", "raw", ".", "newInstance", "(", "args", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getCause", "(", ")", ".", "getMessage", "(", ")", ",", "e", ".", "getCause", "(", ")", ")", ";", "}", "}" ]
Create a new instance using the given deserialized data. The data is only used if this factory has any serialized fields. @param data @return
[ "Create", "a", "new", "instance", "using", "the", "given", "deserialized", "data", ".", "The", "data", "is", "only", "used", "if", "this", "factory", "has", "any", "serialized", "fields", "." ]
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java#L317-L346
145,040
LevelFourAB/commons
commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java
FactoryDefinition.create
@SuppressWarnings("unchecked") public T create(Object[] args) { for(int i=0, n=args.length; i<n; i++) { if(arguments[i] instanceof FactoryDefinition.InjectedArgument) { args[i] = arguments[i].getValue(null); } } try { return (T) raw.newInstance(args); } catch(IllegalArgumentException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InstantiationException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(IllegalAccessException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InvocationTargetException e) { throw new SerializationException("Unable to create; " + e.getCause().getMessage(), e.getCause()); } }
java
@SuppressWarnings("unchecked") public T create(Object[] args) { for(int i=0, n=args.length; i<n; i++) { if(arguments[i] instanceof FactoryDefinition.InjectedArgument) { args[i] = arguments[i].getValue(null); } } try { return (T) raw.newInstance(args); } catch(IllegalArgumentException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InstantiationException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(IllegalAccessException e) { throw new SerializationException("Unable to create; " + e.getMessage(), e); } catch(InvocationTargetException e) { throw new SerializationException("Unable to create; " + e.getCause().getMessage(), e.getCause()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "create", "(", "Object", "[", "]", "args", ")", "{", "for", "(", "int", "i", "=", "0", ",", "n", "=", "args", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "if", "(", "arguments", "[", "i", "]", "instanceof", "FactoryDefinition", ".", "InjectedArgument", ")", "{", "args", "[", "i", "]", "=", "arguments", "[", "i", "]", ".", "getValue", "(", "null", ")", ";", "}", "}", "try", "{", "return", "(", "T", ")", "raw", ".", "newInstance", "(", "args", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "new", "SerializationException", "(", "\"Unable to create; \"", "+", "e", ".", "getCause", "(", ")", ".", "getMessage", "(", ")", ",", "e", ".", "getCause", "(", ")", ")", ";", "}", "}" ]
Create a new instance using a plain arguments array. @param args @return
[ "Create", "a", "new", "instance", "using", "a", "plain", "arguments", "array", "." ]
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/internal/reflection/FactoryDefinition.java#L354-L385
145,041
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.addTimeChart
public void addTimeChart(String chartID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.timeCharts.containsKey(chartID)) { TimeSeriesChartGenerator chart = new TimeSeriesChartGenerator(); chart.setTitle(chartID); chart.setXAxisLabel(xAxisLabel); chart.setYAxisLabel(yAxisLabel); this.timeCharts.put(chartID, chart); } else { throw new DuplicatedChartIDException(chartID); } }
java
public void addTimeChart(String chartID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.timeCharts.containsKey(chartID)) { TimeSeriesChartGenerator chart = new TimeSeriesChartGenerator(); chart.setTitle(chartID); chart.setXAxisLabel(xAxisLabel); chart.setYAxisLabel(yAxisLabel); this.timeCharts.put(chartID, chart); } else { throw new DuplicatedChartIDException(chartID); } }
[ "public", "void", "addTimeChart", "(", "String", "chartID", ",", "String", "xAxisLabel", ",", "String", "yAxisLabel", ")", "throws", "ShanksException", "{", "if", "(", "!", "this", ".", "timeCharts", ".", "containsKey", "(", "chartID", ")", ")", "{", "TimeSeriesChartGenerator", "chart", "=", "new", "TimeSeriesChartGenerator", "(", ")", ";", "chart", ".", "setTitle", "(", "chartID", ")", ";", "chart", ".", "setXAxisLabel", "(", "xAxisLabel", ")", ";", "chart", ".", "setYAxisLabel", "(", "yAxisLabel", ")", ";", "this", ".", "timeCharts", ".", "put", "(", "chartID", ",", "chart", ")", ";", "}", "else", "{", "throw", "new", "DuplicatedChartIDException", "(", "chartID", ")", ";", "}", "}" ]
Add a chart to the simulation @param chartID @param xAxisLabel @param yAxisLabel @throws ShanksException
[ "Add", "a", "chart", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L137-L147
145,042
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.addDataToDataSerieInTimeChart
public void addDataToDataSerieInTimeChart(String chartID, String dataSerieID, double x, double y) throws ShanksException { if (this.containsDataSerieInTimeChart(chartID, dataSerieID)) { this.timeChartData.get(chartID).get(dataSerieID).add(x, y, true); } else { try { this.addDataSerieToTimeChart(chartID, dataSerieID); this.timeChartData.get(chartID).get(dataSerieID).add(x, y, true); } catch (DuplicatedDataSerieIDException e) { e.printStackTrace(); } } }
java
public void addDataToDataSerieInTimeChart(String chartID, String dataSerieID, double x, double y) throws ShanksException { if (this.containsDataSerieInTimeChart(chartID, dataSerieID)) { this.timeChartData.get(chartID).get(dataSerieID).add(x, y, true); } else { try { this.addDataSerieToTimeChart(chartID, dataSerieID); this.timeChartData.get(chartID).get(dataSerieID).add(x, y, true); } catch (DuplicatedDataSerieIDException e) { e.printStackTrace(); } } }
[ "public", "void", "addDataToDataSerieInTimeChart", "(", "String", "chartID", ",", "String", "dataSerieID", ",", "double", "x", ",", "double", "y", ")", "throws", "ShanksException", "{", "if", "(", "this", ".", "containsDataSerieInTimeChart", "(", "chartID", ",", "dataSerieID", ")", ")", "{", "this", ".", "timeChartData", ".", "get", "(", "chartID", ")", ".", "get", "(", "dataSerieID", ")", ".", "add", "(", "x", ",", "y", ",", "true", ")", ";", "}", "else", "{", "try", "{", "this", ".", "addDataSerieToTimeChart", "(", "chartID", ",", "dataSerieID", ")", ";", "this", ".", "timeChartData", ".", "get", "(", "chartID", ")", ".", "get", "(", "dataSerieID", ")", ".", "add", "(", "x", ",", "y", ",", "true", ")", ";", "}", "catch", "(", "DuplicatedDataSerieIDException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}" ]
Add a datum in the chart @param chartID @param dataSerieID @param x @param y @throws ShanksException
[ "Add", "a", "datum", "in", "the", "chart" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L240-L251
145,043
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.addScatterPlot
public void addScatterPlot(String scatterID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.timeCharts.containsKey(scatterID)) { ScatterPlotGenerator scatter = new ScatterPlotGenerator(); scatter.setTitle(scatterID); scatter.setXAxisLabel(xAxisLabel); scatter.setYAxisLabel(yAxisLabel); this.scatterPlots.put(scatterID, scatter); } else { throw new DuplicatedChartIDException(scatterID); } }
java
public void addScatterPlot(String scatterID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.timeCharts.containsKey(scatterID)) { ScatterPlotGenerator scatter = new ScatterPlotGenerator(); scatter.setTitle(scatterID); scatter.setXAxisLabel(xAxisLabel); scatter.setYAxisLabel(yAxisLabel); this.scatterPlots.put(scatterID, scatter); } else { throw new DuplicatedChartIDException(scatterID); } }
[ "public", "void", "addScatterPlot", "(", "String", "scatterID", ",", "String", "xAxisLabel", ",", "String", "yAxisLabel", ")", "throws", "ShanksException", "{", "if", "(", "!", "this", ".", "timeCharts", ".", "containsKey", "(", "scatterID", ")", ")", "{", "ScatterPlotGenerator", "scatter", "=", "new", "ScatterPlotGenerator", "(", ")", ";", "scatter", ".", "setTitle", "(", "scatterID", ")", ";", "scatter", ".", "setXAxisLabel", "(", "xAxisLabel", ")", ";", "scatter", ".", "setYAxisLabel", "(", "yAxisLabel", ")", ";", "this", ".", "scatterPlots", ".", "put", "(", "scatterID", ",", "scatter", ")", ";", "}", "else", "{", "throw", "new", "DuplicatedChartIDException", "(", "scatterID", ")", ";", "}", "}" ]
Add a ScatterPlot to the simulation @param scatterID - An ID for the ScatterPlot @param xAxisLabel - The name of the x axis @param yAxisLabel - The name of the y axis @throws ShanksException
[ "Add", "a", "ScatterPlot", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L261-L271
145,044
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.addDataSerieToScatterPlot
public void addDataSerieToScatterPlot(String scatterID, double[][] dataSerie){ if (this.scatterPlots.containsKey(scatterID)) { this.scatterPlotsData.put(scatterID, dataSerie); this.scatterPlots.get(scatterID).addSeries((double[][])this.scatterPlotsData.get(scatterID), scatterID, null); } }
java
public void addDataSerieToScatterPlot(String scatterID, double[][] dataSerie){ if (this.scatterPlots.containsKey(scatterID)) { this.scatterPlotsData.put(scatterID, dataSerie); this.scatterPlots.get(scatterID).addSeries((double[][])this.scatterPlotsData.get(scatterID), scatterID, null); } }
[ "public", "void", "addDataSerieToScatterPlot", "(", "String", "scatterID", ",", "double", "[", "]", "[", "]", "dataSerie", ")", "{", "if", "(", "this", ".", "scatterPlots", ".", "containsKey", "(", "scatterID", ")", ")", "{", "this", ".", "scatterPlotsData", ".", "put", "(", "scatterID", ",", "dataSerie", ")", ";", "this", ".", "scatterPlots", ".", "get", "(", "scatterID", ")", ".", "addSeries", "(", "(", "double", "[", "]", "[", "]", ")", "this", ".", "scatterPlotsData", ".", "get", "(", "scatterID", ")", ",", "scatterID", ",", "null", ")", ";", "}", "}" ]
Sets the data for the scatterPlot. Should be used only the first time. Use updateDataSerieOnScaterPlot to change the data @param scatterID @param dataSerie the data. The first dimension MUST BE 2 (double[2][whatever_int])
[ "Sets", "the", "data", "for", "the", "scatterPlot", ".", "Should", "be", "used", "only", "the", "first", "time", ".", "Use", "updateDataSerieOnScaterPlot", "to", "change", "the", "data" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L308-L313
145,045
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.updateDataSerieOnScatterPlot
public void updateDataSerieOnScatterPlot(String scatterID, int index, double[][] dataSerie){ if (this.scatterPlots.containsKey(scatterID)){ if (this.scatterPlotsData.containsKey(scatterID)) { double[][] current = this.scatterPlotsData.get(scatterID); this.scatterPlotsData.put(scatterID, concatenateArrays(current, dataSerie)); } else{ // Create the data. addDataSerieToScatterPlot(scatterID, dataSerie); return; } this.scatterPlots.get(scatterID).updateSeries(index, this.scatterPlotsData.get(scatterID)); // this.scatterPlots.get(scatterID).addSeries(this.scatterPlotsData.get(scatterID), scatterID, null); } }
java
public void updateDataSerieOnScatterPlot(String scatterID, int index, double[][] dataSerie){ if (this.scatterPlots.containsKey(scatterID)){ if (this.scatterPlotsData.containsKey(scatterID)) { double[][] current = this.scatterPlotsData.get(scatterID); this.scatterPlotsData.put(scatterID, concatenateArrays(current, dataSerie)); } else{ // Create the data. addDataSerieToScatterPlot(scatterID, dataSerie); return; } this.scatterPlots.get(scatterID).updateSeries(index, this.scatterPlotsData.get(scatterID)); // this.scatterPlots.get(scatterID).addSeries(this.scatterPlotsData.get(scatterID), scatterID, null); } }
[ "public", "void", "updateDataSerieOnScatterPlot", "(", "String", "scatterID", ",", "int", "index", ",", "double", "[", "]", "[", "]", "dataSerie", ")", "{", "if", "(", "this", ".", "scatterPlots", ".", "containsKey", "(", "scatterID", ")", ")", "{", "if", "(", "this", ".", "scatterPlotsData", ".", "containsKey", "(", "scatterID", ")", ")", "{", "double", "[", "]", "[", "]", "current", "=", "this", ".", "scatterPlotsData", ".", "get", "(", "scatterID", ")", ";", "this", ".", "scatterPlotsData", ".", "put", "(", "scatterID", ",", "concatenateArrays", "(", "current", ",", "dataSerie", ")", ")", ";", "}", "else", "{", "// Create the data.\r", "addDataSerieToScatterPlot", "(", "scatterID", ",", "dataSerie", ")", ";", "return", ";", "}", "this", ".", "scatterPlots", ".", "get", "(", "scatterID", ")", ".", "updateSeries", "(", "index", ",", "this", ".", "scatterPlotsData", ".", "get", "(", "scatterID", ")", ")", ";", "// this.scatterPlots.get(scatterID).addSeries(this.scatterPlotsData.get(scatterID), scatterID, null);\r", "}", "}" ]
Updates the data in the scatterPlot @param scatterID @param index the data serie to modify @param dataSerie the series data
[ "Updates", "the", "data", "in", "the", "scatterPlot" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L322-L335
145,046
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.addHistogram
public void addHistogram(String histogramID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.histograms.containsKey(histogramID)) { HistogramGenerator histogram = new HistogramGenerator(); histogram.setTitle(histogramID); histogram.setXAxisLabel(xAxisLabel); histogram.setYAxisLabel(yAxisLabel); this.histograms.put(histogramID, histogram); } else { throw new DuplicatedChartIDException(histogramID); } }
java
public void addHistogram(String histogramID, String xAxisLabel, String yAxisLabel) throws ShanksException { if (!this.histograms.containsKey(histogramID)) { HistogramGenerator histogram = new HistogramGenerator(); histogram.setTitle(histogramID); histogram.setXAxisLabel(xAxisLabel); histogram.setYAxisLabel(yAxisLabel); this.histograms.put(histogramID, histogram); } else { throw new DuplicatedChartIDException(histogramID); } }
[ "public", "void", "addHistogram", "(", "String", "histogramID", ",", "String", "xAxisLabel", ",", "String", "yAxisLabel", ")", "throws", "ShanksException", "{", "if", "(", "!", "this", ".", "histograms", ".", "containsKey", "(", "histogramID", ")", ")", "{", "HistogramGenerator", "histogram", "=", "new", "HistogramGenerator", "(", ")", ";", "histogram", ".", "setTitle", "(", "histogramID", ")", ";", "histogram", ".", "setXAxisLabel", "(", "xAxisLabel", ")", ";", "histogram", ".", "setYAxisLabel", "(", "yAxisLabel", ")", ";", "this", ".", "histograms", ".", "put", "(", "histogramID", ",", "histogram", ")", ";", "}", "else", "{", "throw", "new", "DuplicatedChartIDException", "(", "histogramID", ")", ";", "}", "}" ]
Add a histogram to the simulation @param histogramID @param xAxisLabel @param yAxisLabel @throws ShanksException
[ "Add", "a", "histogram", "to", "the", "simulation" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L345-L355
145,047
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.setHistogramRange
public void setHistogramRange(String histogramID, int lower, int upper) { if (this.histograms.containsKey(histogramID)) this.histograms.get(histogramID).setYAxisRange(lower, upper); }
java
public void setHistogramRange(String histogramID, int lower, int upper) { if (this.histograms.containsKey(histogramID)) this.histograms.get(histogramID).setYAxisRange(lower, upper); }
[ "public", "void", "setHistogramRange", "(", "String", "histogramID", ",", "int", "lower", ",", "int", "upper", ")", "{", "if", "(", "this", ".", "histograms", ".", "containsKey", "(", "histogramID", ")", ")", "this", ".", "histograms", ".", "get", "(", "histogramID", ")", ".", "setYAxisRange", "(", "lower", ",", "upper", ")", ";", "}" ]
Set the histogram range to be displayed @param histogramID The histogram ID @param lower The lower value for the histogram @param upper The upper value for the histogram
[ "Set", "the", "histogram", "range", "to", "be", "displayed" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L428-L431
145,048
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.removeDataSerieFromHistogram
public void removeDataSerieFromHistogram(String histogramID, int index) { if (this.histograms.containsKey(histogramID)) { this.histograms.get(histogramID).removeSeries(index); } }
java
public void removeDataSerieFromHistogram(String histogramID, int index) { if (this.histograms.containsKey(histogramID)) { this.histograms.get(histogramID).removeSeries(index); } }
[ "public", "void", "removeDataSerieFromHistogram", "(", "String", "histogramID", ",", "int", "index", ")", "{", "if", "(", "this", ".", "histograms", ".", "containsKey", "(", "histogramID", ")", ")", "{", "this", ".", "histograms", ".", "get", "(", "histogramID", ")", ".", "removeSeries", "(", "index", ")", ";", "}", "}" ]
Deletes a certain series of data from the histogram. The index will be the order of the histogram. @param histogramID @param index - the index of the data
[ "Deletes", "a", "certain", "series", "of", "data", "from", "the", "histogram", ".", "The", "index", "will", "be", "the", "order", "of", "the", "histogram", "." ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L453-L457
145,049
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java
ScenarioPortrayal.concatenateArrays
private double[][] concatenateArrays(double[][] first, double[][] second){ // I am sure as hell that should be a better way to do this... double[][] result = new double[first.length][first[0].length + second[0].length]; for(int i = 0; i < first.length; i++){ for (int j = 0; j < (first[i].length + second[i].length); j++){ if( j < first[i].length){ result[i][j] = first[i][j]; } else{ result[i][j] = second[i][j - first[i].length]; } } } return result; }
java
private double[][] concatenateArrays(double[][] first, double[][] second){ // I am sure as hell that should be a better way to do this... double[][] result = new double[first.length][first[0].length + second[0].length]; for(int i = 0; i < first.length; i++){ for (int j = 0; j < (first[i].length + second[i].length); j++){ if( j < first[i].length){ result[i][j] = first[i][j]; } else{ result[i][j] = second[i][j - first[i].length]; } } } return result; }
[ "private", "double", "[", "]", "[", "]", "concatenateArrays", "(", "double", "[", "]", "[", "]", "first", ",", "double", "[", "]", "[", "]", "second", ")", "{", "// I am sure as hell that should be a better way to do this...\r", "double", "[", "]", "[", "]", "result", "=", "new", "double", "[", "first", ".", "length", "]", "[", "first", "[", "0", "]", ".", "length", "+", "second", "[", "0", "]", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "first", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "(", "first", "[", "i", "]", ".", "length", "+", "second", "[", "i", "]", ".", "length", ")", ";", "j", "++", ")", "{", "if", "(", "j", "<", "first", "[", "i", "]", ".", "length", ")", "{", "result", "[", "i", "]", "[", "j", "]", "=", "first", "[", "i", "]", "[", "j", "]", ";", "}", "else", "{", "result", "[", "i", "]", "[", "j", "]", "=", "second", "[", "i", "]", "[", "j", "-", "first", "[", "i", "]", ".", "length", "]", ";", "}", "}", "}", "return", "result", ";", "}" ]
Concatenate two two dimensional arrays. Both arrays must have the same dimensions. @param first @param second @return
[ "Concatenate", "two", "two", "dimensional", "arrays", ".", "Both", "arrays", "must", "have", "the", "same", "dimensions", "." ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ScenarioPortrayal.java#L478-L491
145,050
uoa-group-applications/morc
src/main/java/nz/ac/auckland/morc/MorcBuilder.java
MorcBuilder.addProcessors
public Builder addProcessors(Processor... processors) { this.processors.add(new ArrayList<>(Arrays.asList(processors))); return self(); }
java
public Builder addProcessors(Processor... processors) { this.processors.add(new ArrayList<>(Arrays.asList(processors))); return self(); }
[ "public", "Builder", "addProcessors", "(", "Processor", "...", "processors", ")", "{", "this", ".", "processors", ".", "add", "(", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "processors", ")", ")", ")", ";", "return", "self", "(", ")", ";", "}" ]
Adds processors for populating a series of exchanges with an outgoing message - all processors in a single call apply ONLY to a single message, add consecutive calls to addProcessors in order to handle further messages @param processors A list of processors that will handle a separate exchange (in order)
[ "Adds", "processors", "for", "populating", "a", "series", "of", "exchanges", "with", "an", "outgoing", "message", "-", "all", "processors", "in", "a", "single", "call", "apply", "ONLY", "to", "a", "single", "message", "add", "consecutive", "calls", "to", "addProcessors", "in", "order", "to", "handle", "further", "messages" ]
3add6308b1fbfc98187364ac73007c83012ea8ba
https://github.com/uoa-group-applications/morc/blob/3add6308b1fbfc98187364ac73007c83012ea8ba/src/main/java/nz/ac/auckland/morc/MorcBuilder.java#L61-L64
145,051
uoa-group-applications/morc
src/main/java/nz/ac/auckland/morc/MorcBuilder.java
MorcBuilder.addPredicates
public Builder addPredicates(Predicate... predicates) { this.predicates.add(new ArrayList<>(Arrays.asList(predicates))); return self(); }
java
public Builder addPredicates(Predicate... predicates) { this.predicates.add(new ArrayList<>(Arrays.asList(predicates))); return self(); }
[ "public", "Builder", "addPredicates", "(", "Predicate", "...", "predicates", ")", "{", "this", ".", "predicates", ".", "add", "(", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "predicates", ")", ")", ")", ";", "return", "self", "(", ")", ";", "}" ]
Add a set of predicates to validate an incoming exchange - all predicates in a single call apply ONLY to a single message, add consecutive calls to addPredicates in order to handle further messages @param predicates A list of predicates that will validate a separate exchange (in order)
[ "Add", "a", "set", "of", "predicates", "to", "validate", "an", "incoming", "exchange", "-", "all", "predicates", "in", "a", "single", "call", "apply", "ONLY", "to", "a", "single", "message", "add", "consecutive", "calls", "to", "addPredicates", "in", "order", "to", "handle", "further", "messages" ]
3add6308b1fbfc98187364ac73007c83012ea8ba
https://github.com/uoa-group-applications/morc/blob/3add6308b1fbfc98187364ac73007c83012ea8ba/src/main/java/nz/ac/auckland/morc/MorcBuilder.java#L107-L110
145,052
uoa-group-applications/morc
src/main/java/nz/ac/auckland/morc/MorcBuilder.java
MorcBuilder.predicateMultiplier
public Builder predicateMultiplier(int count, Predicate... predicates) { for (int i = 0; i < count; i++) { addPredicates(predicates); } return self(); }
java
public Builder predicateMultiplier(int count, Predicate... predicates) { for (int i = 0; i < count; i++) { addPredicates(predicates); } return self(); }
[ "public", "Builder", "predicateMultiplier", "(", "int", "count", ",", "Predicate", "...", "predicates", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "addPredicates", "(", "predicates", ")", ";", "}", "return", "self", "(", ")", ";", "}" ]
Expect a repeat of the same predicates multiple times @param count The number of times to repeat these predicates (separate responses) @param predicates The set of response validators/predicates that will be used to validate consecutive responses
[ "Expect", "a", "repeat", "of", "the", "same", "predicates", "multiple", "times" ]
3add6308b1fbfc98187364ac73007c83012ea8ba
https://github.com/uoa-group-applications/morc/blob/3add6308b1fbfc98187364ac73007c83012ea8ba/src/main/java/nz/ac/auckland/morc/MorcBuilder.java#L141-L147
145,053
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.closestKey
public static String closestKey(String propertyPrefix, Language language, String... propertyComponents) { return findKey(propertyPrefix, language, propertyComponents); }
java
public static String closestKey(String propertyPrefix, Language language, String... propertyComponents) { return findKey(propertyPrefix, language, propertyComponents); }
[ "public", "static", "String", "closestKey", "(", "String", "propertyPrefix", ",", "Language", "language", ",", "String", "...", "propertyComponents", ")", "{", "return", "findKey", "(", "propertyPrefix", ",", "language", ",", "propertyComponents", ")", ";", "}" ]
Finds the closest key to the given components @param propertyPrefix the property prefix @param language the language @param propertyComponents the property components @return the string
[ "Finds", "the", "closest", "key", "to", "the", "given", "components" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L239-L241
145,054
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.get
public static Val get(Class<?> clazz, String... propertyComponents) { return get(clazz.getName(), propertyComponents); }
java
public static Val get(Class<?> clazz, String... propertyComponents) { return get(clazz.getName(), propertyComponents); }
[ "public", "static", "Val", "get", "(", "Class", "<", "?", ">", "clazz", ",", "String", "...", "propertyComponents", ")", "{", "return", "get", "(", "clazz", ".", "getName", "(", ")", ",", "propertyComponents", ")", ";", "}" ]
Gets the value of a property for a given class @param clazz The class @param propertyComponents The components @return The value associated with clazz.propertyName
[ "Gets", "the", "value", "of", "a", "property", "for", "a", "given", "class" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L322-L324
145,055
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.loadConfig
@SneakyThrows public static void loadConfig(Resource resource) { if (resource == null || !resource.exists()) { return; } if (resource.path() != null && getInstance().loaded.contains(resource.path())) { return; //Only load once! } new ConfigParser(resource).parse(); if (resource.path() != null) { getInstance().loaded.add(resource.path()); } }
java
@SneakyThrows public static void loadConfig(Resource resource) { if (resource == null || !resource.exists()) { return; } if (resource.path() != null && getInstance().loaded.contains(resource.path())) { return; //Only load once! } new ConfigParser(resource).parse(); if (resource.path() != null) { getInstance().loaded.add(resource.path()); } }
[ "@", "SneakyThrows", "public", "static", "void", "loadConfig", "(", "Resource", "resource", ")", "{", "if", "(", "resource", "==", "null", "||", "!", "resource", ".", "exists", "(", ")", ")", "{", "return", ";", "}", "if", "(", "resource", ".", "path", "(", ")", "!=", "null", "&&", "getInstance", "(", ")", ".", "loaded", ".", "contains", "(", "resource", ".", "path", "(", ")", ")", ")", "{", "return", ";", "//Only load once!", "}", "new", "ConfigParser", "(", "resource", ")", ".", "parse", "(", ")", ";", "if", "(", "resource", ".", "path", "(", ")", "!=", "null", ")", "{", "getInstance", "(", ")", ".", "loaded", ".", "add", "(", "resource", ".", "path", "(", ")", ")", ";", "}", "}" ]
Loads a config file @param resource The config file
[ "Loads", "a", "config", "file" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L427-L439
145,056
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.setAllCommandLine
public static void setAllCommandLine(String[] args) { if (args != null) { CommandLineParser parser = new CommandLineParser(); parser.parse(args); setAllCommandLine(parser); } }
java
public static void setAllCommandLine(String[] args) { if (args != null) { CommandLineParser parser = new CommandLineParser(); parser.parse(args); setAllCommandLine(parser); } }
[ "public", "static", "void", "setAllCommandLine", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", "!=", "null", ")", "{", "CommandLineParser", "parser", "=", "new", "CommandLineParser", "(", ")", ";", "parser", ".", "parse", "(", "args", ")", ";", "setAllCommandLine", "(", "parser", ")", ";", "}", "}" ]
Sets all properties from the given array of arguments @param args the args
[ "Sets", "all", "properties", "from", "the", "given", "array", "of", "arguments" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L462-L468
145,057
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.setAllCommandLine
public static void setAllCommandLine(CommandLineParser parser) { if (parser != null) { parser.getSetEntries() .forEach(entry -> getInstance().setterFunction.setProperty(entry.getKey(), entry.getValue(), "CommandLine" ) ); } }
java
public static void setAllCommandLine(CommandLineParser parser) { if (parser != null) { parser.getSetEntries() .forEach(entry -> getInstance().setterFunction.setProperty(entry.getKey(), entry.getValue(), "CommandLine" ) ); } }
[ "public", "static", "void", "setAllCommandLine", "(", "CommandLineParser", "parser", ")", "{", "if", "(", "parser", "!=", "null", ")", "{", "parser", ".", "getSetEntries", "(", ")", ".", "forEach", "(", "entry", "->", "getInstance", "(", ")", ".", "setterFunction", ".", "setProperty", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ",", "\"CommandLine\"", ")", ")", ";", "}", "}" ]
Sets all properties from the given command line parser. @param parser the parser
[ "Sets", "all", "properties", "from", "the", "given", "command", "line", "parser", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L475-L484
145,058
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.loadDefaultConf
protected static boolean loadDefaultConf(String packageName) throws ParseException { if (packageName.endsWith(".conf")) { return false; } packageName = packageName.replaceAll("\\$[0-9]+$", ""); Resource defaultConf = new ClasspathResource((packageName.replaceAll("\\.", "/" ) + "/" + DEFAULT_CONFIG_FILE_NAME).trim(), Config.getDefaultClassLoader() ); // Go through each level of the package until we find one that // has a default properties file or we cannot go any further. while (!defaultConf.exists()) { int idx = packageName.lastIndexOf('.'); if (idx == -1) { defaultConf = new ClasspathResource(packageName + "/" + DEFAULT_CONFIG_FILE_NAME, Config.getDefaultClassLoader() ); break; } packageName = packageName.substring(0, idx); defaultConf = new ClasspathResource(packageName.replaceAll("\\.", "/") + "/" + DEFAULT_CONFIG_FILE_NAME, Config.getDefaultClassLoader() ); } if (defaultConf.exists()) { loadConfig(defaultConf); return true; } return false; }
java
protected static boolean loadDefaultConf(String packageName) throws ParseException { if (packageName.endsWith(".conf")) { return false; } packageName = packageName.replaceAll("\\$[0-9]+$", ""); Resource defaultConf = new ClasspathResource((packageName.replaceAll("\\.", "/" ) + "/" + DEFAULT_CONFIG_FILE_NAME).trim(), Config.getDefaultClassLoader() ); // Go through each level of the package until we find one that // has a default properties file or we cannot go any further. while (!defaultConf.exists()) { int idx = packageName.lastIndexOf('.'); if (idx == -1) { defaultConf = new ClasspathResource(packageName + "/" + DEFAULT_CONFIG_FILE_NAME, Config.getDefaultClassLoader() ); break; } packageName = packageName.substring(0, idx); defaultConf = new ClasspathResource(packageName.replaceAll("\\.", "/") + "/" + DEFAULT_CONFIG_FILE_NAME, Config.getDefaultClassLoader() ); } if (defaultConf.exists()) { loadConfig(defaultConf); return true; } return false; }
[ "protected", "static", "boolean", "loadDefaultConf", "(", "String", "packageName", ")", "throws", "ParseException", "{", "if", "(", "packageName", ".", "endsWith", "(", "\".conf\"", ")", ")", "{", "return", "false", ";", "}", "packageName", "=", "packageName", ".", "replaceAll", "(", "\"\\\\$[0-9]+$\"", ",", "\"\"", ")", ";", "Resource", "defaultConf", "=", "new", "ClasspathResource", "(", "(", "packageName", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"/\"", ")", "+", "\"/\"", "+", "DEFAULT_CONFIG_FILE_NAME", ")", ".", "trim", "(", ")", ",", "Config", ".", "getDefaultClassLoader", "(", ")", ")", ";", "// Go through each level of the package until we find one that", "// has a default properties file or we cannot go any further.", "while", "(", "!", "defaultConf", ".", "exists", "(", ")", ")", "{", "int", "idx", "=", "packageName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "idx", "==", "-", "1", ")", "{", "defaultConf", "=", "new", "ClasspathResource", "(", "packageName", "+", "\"/\"", "+", "DEFAULT_CONFIG_FILE_NAME", ",", "Config", ".", "getDefaultClassLoader", "(", ")", ")", ";", "break", ";", "}", "packageName", "=", "packageName", ".", "substring", "(", "0", ",", "idx", ")", ";", "defaultConf", "=", "new", "ClasspathResource", "(", "packageName", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"/\"", ")", "+", "\"/\"", "+", "DEFAULT_CONFIG_FILE_NAME", ",", "Config", ".", "getDefaultClassLoader", "(", ")", ")", ";", "}", "if", "(", "defaultConf", ".", "exists", "(", ")", ")", "{", "loadConfig", "(", "defaultConf", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Load default conf. @param packageName the package name @return the boolean @throws ParseException the parse exception
[ "Load", "default", "conf", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L584-L622
145,059
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.resolveVariables
static String resolveVariables(String string) { if (string == null) { return null; } String rval = string; Matcher m = STRING_SUBSTITUTION.matcher(string); while (m.find()) { if (getInstance().properties.containsKey(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), get(m.group(1)).asString()); } else if (System.getProperties().contains(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), System.getProperties().get(m.group(1)).toString()); } else if (System.getenv().containsKey(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), System.getenv().get(m.group(1))); } } return rval; }
java
static String resolveVariables(String string) { if (string == null) { return null; } String rval = string; Matcher m = STRING_SUBSTITUTION.matcher(string); while (m.find()) { if (getInstance().properties.containsKey(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), get(m.group(1)).asString()); } else if (System.getProperties().contains(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), System.getProperties().get(m.group(1)).toString()); } else if (System.getenv().containsKey(m.group(1))) { rval = rval.replaceAll(Pattern.quote(m.group(0)), System.getenv().get(m.group(1))); } } return rval; }
[ "static", "String", "resolveVariables", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "String", "rval", "=", "string", ";", "Matcher", "m", "=", "STRING_SUBSTITUTION", ".", "matcher", "(", "string", ")", ";", "while", "(", "m", ".", "find", "(", ")", ")", "{", "if", "(", "getInstance", "(", ")", ".", "properties", ".", "containsKey", "(", "m", ".", "group", "(", "1", ")", ")", ")", "{", "rval", "=", "rval", ".", "replaceAll", "(", "Pattern", ".", "quote", "(", "m", ".", "group", "(", "0", ")", ")", ",", "get", "(", "m", ".", "group", "(", "1", ")", ")", ".", "asString", "(", ")", ")", ";", "}", "else", "if", "(", "System", ".", "getProperties", "(", ")", ".", "contains", "(", "m", ".", "group", "(", "1", ")", ")", ")", "{", "rval", "=", "rval", ".", "replaceAll", "(", "Pattern", ".", "quote", "(", "m", ".", "group", "(", "0", ")", ")", ",", "System", ".", "getProperties", "(", ")", ".", "get", "(", "m", ".", "group", "(", "1", ")", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "if", "(", "System", ".", "getenv", "(", ")", ".", "containsKey", "(", "m", ".", "group", "(", "1", ")", ")", ")", "{", "rval", "=", "rval", ".", "replaceAll", "(", "Pattern", ".", "quote", "(", "m", ".", "group", "(", "0", ")", ")", ",", "System", ".", "getenv", "(", ")", ".", "get", "(", "m", ".", "group", "(", "1", ")", ")", ")", ";", "}", "}", "return", "rval", ";", "}" ]
Resolve variables string. @param string the string @return the string
[ "Resolve", "variables", "string", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L693-L710
145,060
dbracewell/mango
src/main/java/com/davidbracewell/config/Config.java
Config.valueIsScript
public static boolean valueIsScript(String propertyName) { return (getInstance().properties.containsKey(propertyName) && getInstance().properties.get(propertyName) .startsWith( SCRIPT_PROPERTY)); }
java
public static boolean valueIsScript(String propertyName) { return (getInstance().properties.containsKey(propertyName) && getInstance().properties.get(propertyName) .startsWith( SCRIPT_PROPERTY)); }
[ "public", "static", "boolean", "valueIsScript", "(", "String", "propertyName", ")", "{", "return", "(", "getInstance", "(", ")", ".", "properties", ".", "containsKey", "(", "propertyName", ")", "&&", "getInstance", "(", ")", ".", "properties", ".", "get", "(", "propertyName", ")", ".", "startsWith", "(", "SCRIPT_PROPERTY", ")", ")", ";", "}" ]
Determines if the value of the given property is a script or not @param propertyName The name of the property to check @return True if the property exists and its value is a script
[ "Determines", "if", "the", "value", "of", "the", "given", "property", "is", "a", "script", "or", "not" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L741-L745
145,061
gsi-upm/Shanks
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ComplexScenario2DPortrayal.java
ComplexScenario2DPortrayal.situateScenario
public void situateScenario(Scenario scenario, Double2D position, Double2D alpha, Double2D beta, Double2D gamma) throws ShanksException { Scenario2DPortrayal portrayal; try { portrayal = (Scenario2DPortrayal) scenario .createScenarioPortrayal(); ContinuousPortrayal2D devicesPortrayal = (ContinuousPortrayal2D) portrayal .getPortrayals().get(Scenario2DPortrayal.MAIN_DISPLAY_ID) .get(ScenarioPortrayal.DEVICES_PORTRAYAL); Continuous2D devicesSpace = (Continuous2D) devicesPortrayal .getField(); Bag allElements = devicesSpace.getAllObjects(); Object[] all = allElements.objs; for (int i = 0; i < all.length; i++) { Device device = (Device) all[i]; if (device != null) { Double2D devicePosition = devicesSpace .getObjectLocation(device); Double2D rotated = ShanksMath.rotate(devicePosition, alpha, beta, gamma); Double2D finalPosition = ShanksMath.add(rotated, position); this.situateDevice(device, finalPosition.x, finalPosition.y); } } HashMap<String, NetworkElement> elements = scenario .getCurrentElements(); for (Entry<String, NetworkElement> entry : elements.entrySet()) { if (entry.getValue() instanceof Link) { this.drawLink((Link) entry.getValue()); } } if (scenario instanceof ComplexScenario) { this.drawScenarioLinksLinks((ComplexScenario) scenario); } } catch (DuplicatedPortrayalIDException e) { throw e; } }
java
public void situateScenario(Scenario scenario, Double2D position, Double2D alpha, Double2D beta, Double2D gamma) throws ShanksException { Scenario2DPortrayal portrayal; try { portrayal = (Scenario2DPortrayal) scenario .createScenarioPortrayal(); ContinuousPortrayal2D devicesPortrayal = (ContinuousPortrayal2D) portrayal .getPortrayals().get(Scenario2DPortrayal.MAIN_DISPLAY_ID) .get(ScenarioPortrayal.DEVICES_PORTRAYAL); Continuous2D devicesSpace = (Continuous2D) devicesPortrayal .getField(); Bag allElements = devicesSpace.getAllObjects(); Object[] all = allElements.objs; for (int i = 0; i < all.length; i++) { Device device = (Device) all[i]; if (device != null) { Double2D devicePosition = devicesSpace .getObjectLocation(device); Double2D rotated = ShanksMath.rotate(devicePosition, alpha, beta, gamma); Double2D finalPosition = ShanksMath.add(rotated, position); this.situateDevice(device, finalPosition.x, finalPosition.y); } } HashMap<String, NetworkElement> elements = scenario .getCurrentElements(); for (Entry<String, NetworkElement> entry : elements.entrySet()) { if (entry.getValue() instanceof Link) { this.drawLink((Link) entry.getValue()); } } if (scenario instanceof ComplexScenario) { this.drawScenarioLinksLinks((ComplexScenario) scenario); } } catch (DuplicatedPortrayalIDException e) { throw e; } }
[ "public", "void", "situateScenario", "(", "Scenario", "scenario", ",", "Double2D", "position", ",", "Double2D", "alpha", ",", "Double2D", "beta", ",", "Double2D", "gamma", ")", "throws", "ShanksException", "{", "Scenario2DPortrayal", "portrayal", ";", "try", "{", "portrayal", "=", "(", "Scenario2DPortrayal", ")", "scenario", ".", "createScenarioPortrayal", "(", ")", ";", "ContinuousPortrayal2D", "devicesPortrayal", "=", "(", "ContinuousPortrayal2D", ")", "portrayal", ".", "getPortrayals", "(", ")", ".", "get", "(", "Scenario2DPortrayal", ".", "MAIN_DISPLAY_ID", ")", ".", "get", "(", "ScenarioPortrayal", ".", "DEVICES_PORTRAYAL", ")", ";", "Continuous2D", "devicesSpace", "=", "(", "Continuous2D", ")", "devicesPortrayal", ".", "getField", "(", ")", ";", "Bag", "allElements", "=", "devicesSpace", ".", "getAllObjects", "(", ")", ";", "Object", "[", "]", "all", "=", "allElements", ".", "objs", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "all", ".", "length", ";", "i", "++", ")", "{", "Device", "device", "=", "(", "Device", ")", "all", "[", "i", "]", ";", "if", "(", "device", "!=", "null", ")", "{", "Double2D", "devicePosition", "=", "devicesSpace", ".", "getObjectLocation", "(", "device", ")", ";", "Double2D", "rotated", "=", "ShanksMath", ".", "rotate", "(", "devicePosition", ",", "alpha", ",", "beta", ",", "gamma", ")", ";", "Double2D", "finalPosition", "=", "ShanksMath", ".", "add", "(", "rotated", ",", "position", ")", ";", "this", ".", "situateDevice", "(", "device", ",", "finalPosition", ".", "x", ",", "finalPosition", ".", "y", ")", ";", "}", "}", "HashMap", "<", "String", ",", "NetworkElement", ">", "elements", "=", "scenario", ".", "getCurrentElements", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "NetworkElement", ">", "entry", ":", "elements", ".", "entrySet", "(", ")", ")", "{", "if", "(", "entry", ".", "getValue", "(", ")", "instanceof", "Link", ")", "{", "this", ".", "drawLink", "(", "(", "Link", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "if", "(", "scenario", "instanceof", "ComplexScenario", ")", "{", "this", ".", "drawScenarioLinksLinks", "(", "(", "ComplexScenario", ")", "scenario", ")", ";", "}", "}", "catch", "(", "DuplicatedPortrayalIDException", "e", ")", "{", "throw", "e", ";", "}", "}" ]
Situate the scenario in the complex scenario main display @param scenario @param position offset of the scenario @param alpha is the angle in the plane XY @param beta is the angle in the plane XZ (only X rotation will be shown in the 2D portrayal @param gamma is the angle in the plane YZ (only Y rotation will be shown in the 2D portrayal @throws DuplicatedPortrayalIDException @throws ScenarioNotFoundException
[ "Situate", "the", "scenario", "in", "the", "complex", "scenario", "main", "display" ]
35d87a81c22731f4f83bbd0571c9c6d466bd16be
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/ComplexScenario2DPortrayal.java#L63-L100
145,062
dbracewell/mango
src/main/java/com/davidbracewell/concurrent/BlockingThreadPoolExecutor.java
BlockingThreadPoolExecutor.awaitTermination
public void awaitTermination() throws InterruptedException { lock.lock(); try { while (!isDone) { done.await(); } } finally { isDone = false; lock.unlock(); } }
java
public void awaitTermination() throws InterruptedException { lock.lock(); try { while (!isDone) { done.await(); } } finally { isDone = false; lock.unlock(); } }
[ "public", "void", "awaitTermination", "(", ")", "throws", "InterruptedException", "{", "lock", ".", "lock", "(", ")", ";", "try", "{", "while", "(", "!", "isDone", ")", "{", "done", ".", "await", "(", ")", ";", "}", "}", "finally", "{", "isDone", "=", "false", ";", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Awaits termination of the threads @throws InterruptedException The executor was interrupted
[ "Awaits", "termination", "of", "the", "threads" ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/concurrent/BlockingThreadPoolExecutor.java#L117-L127
145,063
keenon/loglinear
src/main/java/com/github/keenon/loglinear/storage/ModelLog.java
ModelLog.add
protected boolean add(GraphicalModel m, boolean recordOnDisk) { boolean success = super.add(m); if (!success) return false; if (recordOnDisk) { try { if (writeWithFactors) { // Attempt to record this to the backing log file, with the factors writeExample(m); } else { // Attempt to record this to the backing log file, without the factors Set<GraphicalModel.Factor> cachedFactors = m.factors; m.factors = new HashSet<>(); writeExample(m); m.factors = cachedFactors; } } catch (IOException e) { e.printStackTrace(); } } return true; }
java
protected boolean add(GraphicalModel m, boolean recordOnDisk) { boolean success = super.add(m); if (!success) return false; if (recordOnDisk) { try { if (writeWithFactors) { // Attempt to record this to the backing log file, with the factors writeExample(m); } else { // Attempt to record this to the backing log file, without the factors Set<GraphicalModel.Factor> cachedFactors = m.factors; m.factors = new HashSet<>(); writeExample(m); m.factors = cachedFactors; } } catch (IOException e) { e.printStackTrace(); } } return true; }
[ "protected", "boolean", "add", "(", "GraphicalModel", "m", ",", "boolean", "recordOnDisk", ")", "{", "boolean", "success", "=", "super", ".", "add", "(", "m", ")", ";", "if", "(", "!", "success", ")", "return", "false", ";", "if", "(", "recordOnDisk", ")", "{", "try", "{", "if", "(", "writeWithFactors", ")", "{", "// Attempt to record this to the backing log file, with the factors", "writeExample", "(", "m", ")", ";", "}", "else", "{", "// Attempt to record this to the backing log file, without the factors", "Set", "<", "GraphicalModel", ".", "Factor", ">", "cachedFactors", "=", "m", ".", "factors", ";", "m", ".", "factors", "=", "new", "HashSet", "<>", "(", ")", ";", "writeExample", "(", "m", ")", ";", "m", ".", "factors", "=", "cachedFactors", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Adds an element to the list, and if recordOnDisk is true, appends it to the backing store. @param m the model to add @param recordOnDisk whether or not to add to the backing disk store @return success
[ "Adds", "an", "element", "to", "the", "list", "and", "if", "recordOnDisk", "is", "true", "appends", "it", "to", "the", "backing", "store", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/storage/ModelLog.java#L40-L60
145,064
UweTrottmann/getglue-java
src/main/java/com/uwetrottmann/getglue/GetGlue.java
GetGlue.getAuthorizationRequest
public static OAuthClientRequest getAuthorizationRequest(String clientId, String redirectUri) throws OAuthSystemException { return OAuthClientRequest .authorizationLocation(OAUTH2_AUTHORIZATION_URL) .setScope("public read write") .setResponseType(ResponseType.CODE.toString()) .setClientId(clientId) .setRedirectURI(redirectUri) .buildQueryMessage(); }
java
public static OAuthClientRequest getAuthorizationRequest(String clientId, String redirectUri) throws OAuthSystemException { return OAuthClientRequest .authorizationLocation(OAUTH2_AUTHORIZATION_URL) .setScope("public read write") .setResponseType(ResponseType.CODE.toString()) .setClientId(clientId) .setRedirectURI(redirectUri) .buildQueryMessage(); }
[ "public", "static", "OAuthClientRequest", "getAuthorizationRequest", "(", "String", "clientId", ",", "String", "redirectUri", ")", "throws", "OAuthSystemException", "{", "return", "OAuthClientRequest", ".", "authorizationLocation", "(", "OAUTH2_AUTHORIZATION_URL", ")", ".", "setScope", "(", "\"public read write\"", ")", ".", "setResponseType", "(", "ResponseType", ".", "CODE", ".", "toString", "(", ")", ")", ".", "setClientId", "(", "clientId", ")", ".", "setRedirectURI", "(", "redirectUri", ")", ".", "buildQueryMessage", "(", ")", ";", "}" ]
Build an OAuth authorization request. @param clientId The OAuth client id obtained from tvtag. @param redirectUri The URI to redirect to with appended auth code query parameter. @throws OAuthSystemException
[ "Build", "an", "OAuth", "authorization", "request", "." ]
9d79c150124f7e71c88568510df5f4f7ccd75d25
https://github.com/UweTrottmann/getglue-java/blob/9d79c150124f7e71c88568510df5f4f7ccd75d25/src/main/java/com/uwetrottmann/getglue/GetGlue.java#L62-L71
145,065
UweTrottmann/getglue-java
src/main/java/com/uwetrottmann/getglue/GetGlue.java
GetGlue.getAccessTokenRequest
public static OAuthClientRequest getAccessTokenRequest(String clientId, String clientSecret, String redirectUri, String authCode) throws OAuthSystemException { return OAuthClientRequest .tokenLocation(OAUTH2_ACCESS_TOKEN_URL) .setGrantType(GrantType.AUTHORIZATION_CODE) .setClientId(clientId) .setClientSecret(clientSecret) .setRedirectURI(redirectUri) .setCode(authCode) .buildQueryMessage(); }
java
public static OAuthClientRequest getAccessTokenRequest(String clientId, String clientSecret, String redirectUri, String authCode) throws OAuthSystemException { return OAuthClientRequest .tokenLocation(OAUTH2_ACCESS_TOKEN_URL) .setGrantType(GrantType.AUTHORIZATION_CODE) .setClientId(clientId) .setClientSecret(clientSecret) .setRedirectURI(redirectUri) .setCode(authCode) .buildQueryMessage(); }
[ "public", "static", "OAuthClientRequest", "getAccessTokenRequest", "(", "String", "clientId", ",", "String", "clientSecret", ",", "String", "redirectUri", ",", "String", "authCode", ")", "throws", "OAuthSystemException", "{", "return", "OAuthClientRequest", ".", "tokenLocation", "(", "OAUTH2_ACCESS_TOKEN_URL", ")", ".", "setGrantType", "(", "GrantType", ".", "AUTHORIZATION_CODE", ")", ".", "setClientId", "(", "clientId", ")", ".", "setClientSecret", "(", "clientSecret", ")", ".", "setRedirectURI", "(", "redirectUri", ")", ".", "setCode", "(", "authCode", ")", ".", "buildQueryMessage", "(", ")", ";", "}" ]
Build an OAuth access token request. @param clientId The OAuth client id obtained from tvtag. @param clientSecret The OAuth client secret obtained from tvtag. @param redirectUri The redirect URI previously used for obtaining the auth code. @param authCode A previously obtained auth code. @return A tvtag OAuth access token request. @throws OAuthSystemException
[ "Build", "an", "OAuth", "access", "token", "request", "." ]
9d79c150124f7e71c88568510df5f4f7ccd75d25
https://github.com/UweTrottmann/getglue-java/blob/9d79c150124f7e71c88568510df5f4f7ccd75d25/src/main/java/com/uwetrottmann/getglue/GetGlue.java#L83-L93
145,066
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgVariable.java
SgVariable.hasAnnotation
public final boolean hasAnnotation(final String name) { if (name == null) { throw new IllegalArgumentException("The argument 'name' cannot be NULL!"); } for (int i = 0; i < annotations.size(); i++) { final SgAnnotation annotation = annotations.get(i); if (annotation.getName().equals(name)) { return true; } } return false; }
java
public final boolean hasAnnotation(final String name) { if (name == null) { throw new IllegalArgumentException("The argument 'name' cannot be NULL!"); } for (int i = 0; i < annotations.size(); i++) { final SgAnnotation annotation = annotations.get(i); if (annotation.getName().equals(name)) { return true; } } return false; }
[ "public", "final", "boolean", "hasAnnotation", "(", "final", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'name' cannot be NULL!\"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "annotations", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "SgAnnotation", "annotation", "=", "annotations", ".", "get", "(", "i", ")", ";", "if", "(", "annotation", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if a given annotation is in the list. @param name Name of the annotation to find - Cannot be null. @return If it's found true else false.
[ "Checks", "if", "a", "given", "annotation", "is", "in", "the", "list", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgVariable.java#L140-L151
145,067
poolik/classfinder
src/main/java/com/poolik/classfinder/filter/Regex.java
Regex.accept
public boolean accept(ClassInfo classInfo, ClassHierarchyResolver hierarchyResolver) { return pattern.matcher(classInfo.getClassName()).find(); }
java
public boolean accept(ClassInfo classInfo, ClassHierarchyResolver hierarchyResolver) { return pattern.matcher(classInfo.getClassName()).find(); }
[ "public", "boolean", "accept", "(", "ClassInfo", "classInfo", ",", "ClassHierarchyResolver", "hierarchyResolver", ")", "{", "return", "pattern", ".", "matcher", "(", "classInfo", ".", "getClassName", "(", ")", ")", ".", "find", "(", ")", ";", "}" ]
Determine whether a class name is to be accepted or not, based on the regular expression specified to the constructor. @param classInfo the {@link com.poolik.classfinder.info.ClassInfo} object to test @return <tt>true</tt> if the class name matches, <tt>false</tt> if it doesn't
[ "Determine", "whether", "a", "class", "name", "is", "to", "be", "accepted", "or", "not", "based", "on", "the", "regular", "expression", "specified", "to", "the", "constructor", "." ]
0544f1c702f4fe6cb4a33db2a85c48b1d93f168f
https://github.com/poolik/classfinder/blob/0544f1c702f4fe6cb4a33db2a85c48b1d93f168f/src/main/java/com/poolik/classfinder/filter/Regex.java#L112-L114
145,068
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.getPropertyManager
public PropertyManager<T> getPropertyManager(T property) { PropertyManager<T> propertyManager = propertyManagerCache.get(property); if (propertyManager == null) { PropertyManager<T> newPropertyManager = new PropertyManager<T>(property, this); propertyManager = propertyManagerCache.putIfAbsent(property, newPropertyManager); if (propertyManager == null) { propertyManager = newPropertyManager; } } return propertyManager; }
java
public PropertyManager<T> getPropertyManager(T property) { PropertyManager<T> propertyManager = propertyManagerCache.get(property); if (propertyManager == null) { PropertyManager<T> newPropertyManager = new PropertyManager<T>(property, this); propertyManager = propertyManagerCache.putIfAbsent(property, newPropertyManager); if (propertyManager == null) { propertyManager = newPropertyManager; } } return propertyManager; }
[ "public", "PropertyManager", "<", "T", ">", "getPropertyManager", "(", "T", "property", ")", "{", "PropertyManager", "<", "T", ">", "propertyManager", "=", "propertyManagerCache", ".", "get", "(", "property", ")", ";", "if", "(", "propertyManager", "==", "null", ")", "{", "PropertyManager", "<", "T", ">", "newPropertyManager", "=", "new", "PropertyManager", "<", "T", ">", "(", "property", ",", "this", ")", ";", "propertyManager", "=", "propertyManagerCache", ".", "putIfAbsent", "(", "property", ",", "newPropertyManager", ")", ";", "if", "(", "propertyManager", "==", "null", ")", "{", "propertyManager", "=", "newPropertyManager", ";", "}", "}", "return", "propertyManager", ";", "}" ]
Get an object that will encapsulate the functionality of this manager specific to a single property. This makes it easier to watch, modify, and generally interact with a single property. @param property the property to manage @return the encapsulation of the functionality of this manager as it pertains to a single property
[ "Get", "an", "object", "that", "will", "encapsulate", "the", "functionality", "of", "this", "manager", "specific", "to", "a", "single", "property", ".", "This", "makes", "it", "easier", "to", "watch", "modify", "and", "generally", "interact", "with", "a", "single", "property", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L260-L278
145,069
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.getIntegerPropertyFallback
public int getIntegerPropertyFallback(T property) throws NumberFormatException { try { return getIntegerProperty(property); } catch (NumberFormatException e) { return Integer.parseInt(getDefaultProperty(property)); } }
java
public int getIntegerPropertyFallback(T property) throws NumberFormatException { try { return getIntegerProperty(property); } catch (NumberFormatException e) { return Integer.parseInt(getDefaultProperty(property)); } }
[ "public", "int", "getIntegerPropertyFallback", "(", "T", "property", ")", "throws", "NumberFormatException", "{", "try", "{", "return", "getIntegerProperty", "(", "property", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "Integer", ".", "parseInt", "(", "getDefaultProperty", "(", "property", ")", ")", ";", "}", "}" ]
Retrieve the value of the given property as an integer. If the current value of the specified property cannot be converted to an integer, the default value will be retrieved. @param property the property to retrieve @return the integer value of the given property or the default value if the current value is not a valid integer @throws NumberFormatException if both the current and default values are not integers
[ "Retrieve", "the", "value", "of", "the", "given", "property", "as", "an", "integer", ".", "If", "the", "current", "value", "of", "the", "specified", "property", "cannot", "be", "converted", "to", "an", "integer", "the", "default", "value", "will", "be", "retrieved", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L436-L446
145,070
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.getLongPropertyFallback
public long getLongPropertyFallback(T property) throws NumberFormatException { try { return getLongProperty(property); } catch (NumberFormatException e) { return Long.parseLong(getDefaultProperty(property)); } }
java
public long getLongPropertyFallback(T property) throws NumberFormatException { try { return getLongProperty(property); } catch (NumberFormatException e) { return Long.parseLong(getDefaultProperty(property)); } }
[ "public", "long", "getLongPropertyFallback", "(", "T", "property", ")", "throws", "NumberFormatException", "{", "try", "{", "return", "getLongProperty", "(", "property", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "Long", ".", "parseLong", "(", "getDefaultProperty", "(", "property", ")", ")", ";", "}", "}" ]
Retrieve the value of the given property as a long. If the current value of the specified property cannot be converted to a long, the default value will be retrieved. @param property the property to retrieve @return the long value of the given property or the default value if the current value is not a valid long @throws NumberFormatException if both the current and default values are not longs
[ "Retrieve", "the", "value", "of", "the", "given", "property", "as", "a", "long", ".", "If", "the", "current", "value", "of", "the", "specified", "property", "cannot", "be", "converted", "to", "a", "long", "the", "default", "value", "will", "be", "retrieved", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L474-L484
145,071
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.getFloatPropertyFallback
public float getFloatPropertyFallback(T property) throws NumberFormatException { try { return getFloatProperty(property); } catch (NumberFormatException e) { return Float.parseFloat(getDefaultProperty(property)); } }
java
public float getFloatPropertyFallback(T property) throws NumberFormatException { try { return getFloatProperty(property); } catch (NumberFormatException e) { return Float.parseFloat(getDefaultProperty(property)); } }
[ "public", "float", "getFloatPropertyFallback", "(", "T", "property", ")", "throws", "NumberFormatException", "{", "try", "{", "return", "getFloatProperty", "(", "property", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "Float", ".", "parseFloat", "(", "getDefaultProperty", "(", "property", ")", ")", ";", "}", "}" ]
Retrieve the value of the given property as a float. If the current value of the specified property cannot be converted to a float, the default value will be retrieved. @param property the property to retrieve @return the float value of the given property or the default value if the current value is not a valid float @throws NumberFormatException if both the current and default values are not floats
[ "Retrieve", "the", "value", "of", "the", "given", "property", "as", "a", "float", ".", "If", "the", "current", "value", "of", "the", "specified", "property", "cannot", "be", "converted", "to", "a", "float", "the", "default", "value", "will", "be", "retrieved", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L512-L522
145,072
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.getDoublePropertyFallback
public double getDoublePropertyFallback(T property) throws NumberFormatException { try { return Double.parseDouble(getProperty(property)); } catch (NumberFormatException e) { return Double.parseDouble(getDefaultProperty(property)); } }
java
public double getDoublePropertyFallback(T property) throws NumberFormatException { try { return Double.parseDouble(getProperty(property)); } catch (NumberFormatException e) { return Double.parseDouble(getDefaultProperty(property)); } }
[ "public", "double", "getDoublePropertyFallback", "(", "T", "property", ")", "throws", "NumberFormatException", "{", "try", "{", "return", "Double", ".", "parseDouble", "(", "getProperty", "(", "property", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "Double", ".", "parseDouble", "(", "getDefaultProperty", "(", "property", ")", ")", ";", "}", "}" ]
Retrieve the value of the given property as a double. If the current value of the specified property cannot be converted to a double, the default value will be retrieved. @param property the property to retrieve @return the double value of the given property or the default value if the current value is not a valid double @throws NumberFormatException if both the current and default values are not doubles
[ "Retrieve", "the", "value", "of", "the", "given", "property", "as", "a", "double", ".", "If", "the", "current", "value", "of", "the", "specified", "property", "cannot", "be", "converted", "to", "a", "double", "the", "default", "value", "will", "be", "retrieved", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L550-L560
145,073
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.isReferencing
public boolean isReferencing(T property1, T property2) { return getEvaluator().isReferencing(getRawProperty(property1), getTranslator().getPropertyName(property2), getRetriever()); }
java
public boolean isReferencing(T property1, T property2) { return getEvaluator().isReferencing(getRawProperty(property1), getTranslator().getPropertyName(property2), getRetriever()); }
[ "public", "boolean", "isReferencing", "(", "T", "property1", ",", "T", "property2", ")", "{", "return", "getEvaluator", "(", ")", ".", "isReferencing", "(", "getRawProperty", "(", "property1", ")", ",", "getTranslator", "(", ")", ".", "getPropertyName", "(", "property2", ")", ",", "getRetriever", "(", ")", ")", ";", "}" ]
Determine whether or not one property holds references to another property. @param property1 the property to check for references @param property2 the target referenced property @return <code>true</code> if the first property references the second; <code>false</code> otherwise
[ "Determine", "whether", "or", "not", "one", "property", "holds", "references", "to", "another", "property", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L709-L714
145,074
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.setProperty
public void setProperty(T property, Object value) throws IllegalArgumentException { if (value == null) { throw new IllegalArgumentException("Cannot set a null value, use reset instead"); } setProperty(property, value.toString()); }
java
public void setProperty(T property, Object value) throws IllegalArgumentException { if (value == null) { throw new IllegalArgumentException("Cannot set a null value, use reset instead"); } setProperty(property, value.toString()); }
[ "public", "void", "setProperty", "(", "T", "property", ",", "Object", "value", ")", "throws", "IllegalArgumentException", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot set a null value, use reset instead\"", ")", ";", "}", "setProperty", "(", "property", ",", "value", ".", "toString", "(", ")", ")", ";", "}" ]
Set the given property using an object's string representation. This will not write the new value to the file system. @see #saveProperty(Object, Object) @param property the property whose value is being set @param value the value to set @throws IllegalArgumentException if a <code>null</code> value is given (see {@link #resetProperty(Object)})
[ "Set", "the", "given", "property", "using", "an", "object", "s", "string", "representation", ".", "This", "will", "not", "write", "the", "new", "value", "to", "the", "file", "system", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L915-L923
145,075
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.setProperty
public void setProperty(T property, String value) throws IllegalArgumentException { if (value == null) { throw new IllegalArgumentException("Cannot set a null value, use reset instead"); } String propertyName = getTranslator().getPropertyName(property); if (properties.setProperty(propertyName, value)) { firePropertyChanged(property); } }
java
public void setProperty(T property, String value) throws IllegalArgumentException { if (value == null) { throw new IllegalArgumentException("Cannot set a null value, use reset instead"); } String propertyName = getTranslator().getPropertyName(property); if (properties.setProperty(propertyName, value)) { firePropertyChanged(property); } }
[ "public", "void", "setProperty", "(", "T", "property", ",", "String", "value", ")", "throws", "IllegalArgumentException", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot set a null value, use reset instead\"", ")", ";", "}", "String", "propertyName", "=", "getTranslator", "(", ")", ".", "getPropertyName", "(", "property", ")", ";", "if", "(", "properties", ".", "setProperty", "(", "propertyName", ",", "value", ")", ")", "{", "firePropertyChanged", "(", "property", ")", ";", "}", "}" ]
Set the given property using a string. This will not write the new value to the file system. @see #saveProperty(Object, String) @param property the property whose value is being set @param value the value to set @throws IllegalArgumentException if a <code>null</code> value is given (see {@link #resetProperty(Object)})
[ "Set", "the", "given", "property", "using", "a", "string", ".", "This", "will", "not", "write", "the", "new", "value", "to", "the", "file", "system", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L939-L951
145,076
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.resetProperty
public void resetProperty(T property) { String propertyName = getTranslator().getPropertyName(property); if (properties.resetToDefault(propertyName)) { firePropertyReset(property); } }
java
public void resetProperty(T property) { String propertyName = getTranslator().getPropertyName(property); if (properties.resetToDefault(propertyName)) { firePropertyReset(property); } }
[ "public", "void", "resetProperty", "(", "T", "property", ")", "{", "String", "propertyName", "=", "getTranslator", "(", ")", ".", "getPropertyName", "(", "property", ")", ";", "if", "(", "properties", ".", "resetToDefault", "(", "propertyName", ")", ")", "{", "firePropertyReset", "(", "property", ")", ";", "}", "}" ]
Reset the given property to its default value. This will not write the new value to the file system. @param property the property whose value is being reset
[ "Reset", "the", "given", "property", "to", "its", "default", "value", ".", "This", "will", "not", "write", "the", "new", "value", "to", "the", "file", "system", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L1166-L1174
145,077
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.firePropertyLoaded
private void firePropertyLoaded(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.loaded(event); } }
java
private void firePropertyLoaded(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.loaded(event); } }
[ "private", "void", "firePropertyLoaded", "(", "T", "property", ")", "{", "PropertyEvent", "<", "T", ">", "event", "=", "null", ";", "for", "(", "PropertyListener", "<", "T", ">", "l", ":", "listeners", ")", "{", "if", "(", "event", "==", "null", ")", "{", "event", "=", "new", "PropertyEvent", "<", "T", ">", "(", "this", ",", "property", ")", ";", "}", "l", ".", "loaded", "(", "event", ")", ";", "}", "}" ]
Notify all listeners that a property has been loaded. @param property the property whose value has been loaded
[ "Notify", "all", "listeners", "that", "a", "property", "has", "been", "loaded", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L1262-L1275
145,078
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.firePropertySaved
private void firePropertySaved(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.saved(event); } }
java
private void firePropertySaved(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.saved(event); } }
[ "private", "void", "firePropertySaved", "(", "T", "property", ")", "{", "PropertyEvent", "<", "T", ">", "event", "=", "null", ";", "for", "(", "PropertyListener", "<", "T", ">", "l", ":", "listeners", ")", "{", "if", "(", "event", "==", "null", ")", "{", "event", "=", "new", "PropertyEvent", "<", "T", ">", "(", "this", ",", "property", ")", ";", "}", "l", ".", "saved", "(", "event", ")", ";", "}", "}" ]
Notify all listeners that a property has been saved. @param property the property whose value has been saved
[ "Notify", "all", "listeners", "that", "a", "property", "has", "been", "saved", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L1291-L1304
145,079
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.firePropertyChanged
private void firePropertyChanged(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.changed(event); } }
java
private void firePropertyChanged(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.changed(event); } }
[ "private", "void", "firePropertyChanged", "(", "T", "property", ")", "{", "PropertyEvent", "<", "T", ">", "event", "=", "null", ";", "for", "(", "PropertyListener", "<", "T", ">", "l", ":", "listeners", ")", "{", "if", "(", "event", "==", "null", ")", "{", "event", "=", "new", "PropertyEvent", "<", "T", ">", "(", "this", ",", "property", ")", ";", "}", "l", ".", "changed", "(", "event", ")", ";", "}", "}" ]
Notify all listeners that a property has changed. @param property the property whose value has changed
[ "Notify", "all", "listeners", "that", "a", "property", "has", "changed", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L1320-L1333
145,080
syphr42/prom
src/main/java/org/syphr/prom/PropertiesManager.java
PropertiesManager.firePropertyReset
private void firePropertyReset(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.reset(event); } }
java
private void firePropertyReset(T property) { PropertyEvent<T> event = null; for (PropertyListener<T> l : listeners) { if (event == null) { event = new PropertyEvent<T>(this, property); } l.reset(event); } }
[ "private", "void", "firePropertyReset", "(", "T", "property", ")", "{", "PropertyEvent", "<", "T", ">", "event", "=", "null", ";", "for", "(", "PropertyListener", "<", "T", ">", "l", ":", "listeners", ")", "{", "if", "(", "event", "==", "null", ")", "{", "event", "=", "new", "PropertyEvent", "<", "T", ">", "(", "this", ",", "property", ")", ";", "}", "l", ".", "reset", "(", "event", ")", ";", "}", "}" ]
Notify all listeners that a property has been reset. @param property the property whose value has changed
[ "Notify", "all", "listeners", "that", "a", "property", "has", "been", "reset", "." ]
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManager.java#L1341-L1354
145,081
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.getVariableMetaDataByReference
public synchronized Map<String, String> getVariableMetaDataByReference(int variableIndex) { while (variableIndex >= variableMetaData.size()) { variableMetaData.add(new HashMap<>()); } return variableMetaData.get(variableIndex); }
java
public synchronized Map<String, String> getVariableMetaDataByReference(int variableIndex) { while (variableIndex >= variableMetaData.size()) { variableMetaData.add(new HashMap<>()); } return variableMetaData.get(variableIndex); }
[ "public", "synchronized", "Map", "<", "String", ",", "String", ">", "getVariableMetaDataByReference", "(", "int", "variableIndex", ")", "{", "while", "(", "variableIndex", ">=", "variableMetaData", ".", "size", "(", ")", ")", "{", "variableMetaData", ".", "add", "(", "new", "HashMap", "<>", "(", ")", ")", ";", "}", "return", "variableMetaData", ".", "get", "(", "variableIndex", ")", ";", "}" ]
Gets the metadata for a variable. Creates blank metadata if does not exists, then returns that. Pass by reference. @param variableIndex the variable number, 0 indexed, to retrieve @return the metadata map corresponding to that variable number
[ "Gets", "the", "metadata", "for", "a", "variable", ".", "Creates", "blank", "metadata", "if", "does", "not", "exists", "then", "returns", "that", ".", "Pass", "by", "reference", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L301-L306
145,082
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.addStaticFactor
public StaticFactor addStaticFactor(int[] neighborIndices, int[] neighborDimensions, Function<int[], Double> assignmentFeaturizer) { NDArrayDoubles doubleArray = new NDArrayDoubles(neighborDimensions); for (int[] assignment : doubleArray) { doubleArray.setAssignmentValue(assignment, assignmentFeaturizer.apply(assignment)); } return addStaticFactor(doubleArray, neighborIndices); }
java
public StaticFactor addStaticFactor(int[] neighborIndices, int[] neighborDimensions, Function<int[], Double> assignmentFeaturizer) { NDArrayDoubles doubleArray = new NDArrayDoubles(neighborDimensions); for (int[] assignment : doubleArray) { doubleArray.setAssignmentValue(assignment, assignmentFeaturizer.apply(assignment)); } return addStaticFactor(doubleArray, neighborIndices); }
[ "public", "StaticFactor", "addStaticFactor", "(", "int", "[", "]", "neighborIndices", ",", "int", "[", "]", "neighborDimensions", ",", "Function", "<", "int", "[", "]", ",", "Double", ">", "assignmentFeaturizer", ")", "{", "NDArrayDoubles", "doubleArray", "=", "new", "NDArrayDoubles", "(", "neighborDimensions", ")", ";", "for", "(", "int", "[", "]", "assignment", ":", "doubleArray", ")", "{", "doubleArray", ".", "setAssignmentValue", "(", "assignment", ",", "assignmentFeaturizer", ".", "apply", "(", "assignment", ")", ")", ";", "}", "return", "addStaticFactor", "(", "doubleArray", ",", "neighborIndices", ")", ";", "}" ]
This adds a static factor to the model, which will always produce the same value regardless of the assignment of weights during inference. @param neighborIndices the names of the variables, as indices @param assignmentFeaturizer a function that maps from an assignment to the variables, represented as an array of assignments in the same order as presented in neighborIndices, to a constant value. @return a reference to the created factor. This can be safely ignored, as the factor is already saved in the model
[ "This", "adds", "a", "static", "factor", "to", "the", "model", "which", "will", "always", "produce", "the", "same", "value", "regardless", "of", "the", "assignment", "of", "weights", "during", "inference", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L317-L323
145,083
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.addBinaryFactor
public Factor addBinaryFactor(int a, int b, BiFunction<Integer, Integer, ConcatVector> featurizer) { int[] variableDims = getVariableSizes(); assert a < variableDims.length; assert b < variableDims.length; return addFactor(new int[]{a, b}, new int[]{variableDims[a], variableDims[b]}, assignment -> featurizer.apply(assignment[0], assignment[1]) ); }
java
public Factor addBinaryFactor(int a, int b, BiFunction<Integer, Integer, ConcatVector> featurizer) { int[] variableDims = getVariableSizes(); assert a < variableDims.length; assert b < variableDims.length; return addFactor(new int[]{a, b}, new int[]{variableDims[a], variableDims[b]}, assignment -> featurizer.apply(assignment[0], assignment[1]) ); }
[ "public", "Factor", "addBinaryFactor", "(", "int", "a", ",", "int", "b", ",", "BiFunction", "<", "Integer", ",", "Integer", ",", "ConcatVector", ">", "featurizer", ")", "{", "int", "[", "]", "variableDims", "=", "getVariableSizes", "(", ")", ";", "assert", "a", "<", "variableDims", ".", "length", ";", "assert", "b", "<", "variableDims", ".", "length", ";", "return", "addFactor", "(", "new", "int", "[", "]", "{", "a", ",", "b", "}", ",", "new", "int", "[", "]", "{", "variableDims", "[", "a", "]", ",", "variableDims", "[", "b", "]", "}", ",", "assignment", "->", "featurizer", ".", "apply", "(", "assignment", "[", "0", "]", ",", "assignment", "[", "1", "]", ")", ")", ";", "}" ]
A simple helper function for defining a binary factor. That is, a factor between two variables in the graphical model. @param a The index of the first variable. @param b The index of the second variable @param featurizer The featurizer. This takes as input two assignments for the two variables, and returns the features on those variables. @return a reference to the created factor. This can be safely ignored, as the factor is already saved in the model
[ "A", "simple", "helper", "function", "for", "defining", "a", "binary", "factor", ".", "That", "is", "a", "factor", "between", "two", "variables", "in", "the", "graphical", "model", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L437-L442
145,084
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.addBinaryFactor
public Factor addBinaryFactor(int a, int cardA, int b, int cardB, BiFunction<Integer, Integer, ConcatVector> featurizer) { return addFactor(new int[]{a, b}, new int[]{cardA, cardB}, assignment -> featurizer.apply(assignment[0], assignment[1]) ); }
java
public Factor addBinaryFactor(int a, int cardA, int b, int cardB, BiFunction<Integer, Integer, ConcatVector> featurizer) { return addFactor(new int[]{a, b}, new int[]{cardA, cardB}, assignment -> featurizer.apply(assignment[0], assignment[1]) ); }
[ "public", "Factor", "addBinaryFactor", "(", "int", "a", ",", "int", "cardA", ",", "int", "b", ",", "int", "cardB", ",", "BiFunction", "<", "Integer", ",", "Integer", ",", "ConcatVector", ">", "featurizer", ")", "{", "return", "addFactor", "(", "new", "int", "[", "]", "{", "a", ",", "b", "}", ",", "new", "int", "[", "]", "{", "cardA", ",", "cardB", "}", ",", "assignment", "->", "featurizer", ".", "apply", "(", "assignment", "[", "0", "]", ",", "assignment", "[", "1", "]", ")", ")", ";", "}" ]
Add a binary factor, with known dimensions for the variables @param a The index of the first variable. @param cardA The cardinality (i.e, dimension) of the first factor @param b The index of the second variable @param cardB The cardinality (i.e, dimension) of the second factor @param featurizer The featurizer. This takes as input two assignments for the two variables, and returns the features on those variables. @return a reference to the created factor. This can be safely ignored, as the factor is already saved in the model
[ "Add", "a", "binary", "factor", "with", "known", "dimensions", "for", "the", "variables" ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L455-L457
145,085
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.setTrainingLabel
public void setTrainingLabel(int variable, int value) { getVariableMetaDataByReference(variable).put(LogLikelihoodDifferentiableFunction.VARIABLE_TRAINING_VALUE, Integer.toString(value)); }
java
public void setTrainingLabel(int variable, int value) { getVariableMetaDataByReference(variable).put(LogLikelihoodDifferentiableFunction.VARIABLE_TRAINING_VALUE, Integer.toString(value)); }
[ "public", "void", "setTrainingLabel", "(", "int", "variable", ",", "int", "value", ")", "{", "getVariableMetaDataByReference", "(", "variable", ")", ".", "put", "(", "LogLikelihoodDifferentiableFunction", ".", "VARIABLE_TRAINING_VALUE", ",", "Integer", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Set a training value for this variable in the graphical model. @param variable The variable to set. @param value The value to set on the variable.
[ "Set", "a", "training", "value", "for", "this", "variable", "in", "the", "graphical", "model", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L500-L502
145,086
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.observe
public void observe(int variable, int value) { getVariableMetaDataByReference(variable).put(CliqueTree.VARIABLE_OBSERVED_VALUE, Integer.toString(value)); }
java
public void observe(int variable, int value) { getVariableMetaDataByReference(variable).put(CliqueTree.VARIABLE_OBSERVED_VALUE, Integer.toString(value)); }
[ "public", "void", "observe", "(", "int", "variable", ",", "int", "value", ")", "{", "getVariableMetaDataByReference", "(", "variable", ")", ".", "put", "(", "CliqueTree", ".", "VARIABLE_OBSERVED_VALUE", ",", "Integer", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Observe a given variable, setting it to a given value. @param variable The variable to set. @param value The value we have observed this variable to have taken.
[ "Observe", "a", "given", "variable", "setting", "it", "to", "a", "given", "value", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L549-L551
145,087
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.numVariables
public int numVariables() { int maxVar = 0; for (Factor f : factors) { for (int n : f.neigborIndices) { if (n > maxVar) maxVar = n; } } return maxVar + 1; }
java
public int numVariables() { int maxVar = 0; for (Factor f : factors) { for (int n : f.neigborIndices) { if (n > maxVar) maxVar = n; } } return maxVar + 1; }
[ "public", "int", "numVariables", "(", ")", "{", "int", "maxVar", "=", "0", ";", "for", "(", "Factor", "f", ":", "factors", ")", "{", "for", "(", "int", "n", ":", "f", ".", "neigborIndices", ")", "{", "if", "(", "n", ">", "maxVar", ")", "maxVar", "=", "n", ";", "}", "}", "return", "maxVar", "+", "1", ";", "}" ]
The number of variables in this graphical model.
[ "The", "number", "of", "variables", "in", "this", "graphical", "model", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L557-L565
145,088
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.readFromStream
public static GraphicalModel readFromStream(InputStream stream) throws IOException { return readFromProto(GraphicalModelProto.GraphicalModel.parseDelimitedFrom(stream)); }
java
public static GraphicalModel readFromStream(InputStream stream) throws IOException { return readFromProto(GraphicalModelProto.GraphicalModel.parseDelimitedFrom(stream)); }
[ "public", "static", "GraphicalModel", "readFromStream", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "return", "readFromProto", "(", "GraphicalModelProto", ".", "GraphicalModel", ".", "parseDelimitedFrom", "(", "stream", ")", ")", ";", "}" ]
Static function to deserialize a graphical model from an input stream. @param stream the stream to read from, assuming protobuf encoding @return a new graphical model @throws IOException passed through from the stream
[ "Static", "function", "to", "deserialize", "a", "graphical", "model", "from", "an", "input", "stream", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L610-L612
145,089
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.readFromProto
public static GraphicalModel readFromProto(GraphicalModelProto.GraphicalModel proto) { if (proto == null) return null; GraphicalModel model = new GraphicalModel(); model.modelMetaData = readMetaDataFromProto(proto.getMetaData()); model.variableMetaData = new ArrayList<>(); for (int i = 0; i < proto.getVariableMetaDataCount(); i++) { model.variableMetaData.add(readMetaDataFromProto(proto.getVariableMetaData(i))); } for (int i = 0; i < proto.getFactorCount(); i++) { model.factors.add(Factor.readFromProto(proto.getFactor(i))); } return model; }
java
public static GraphicalModel readFromProto(GraphicalModelProto.GraphicalModel proto) { if (proto == null) return null; GraphicalModel model = new GraphicalModel(); model.modelMetaData = readMetaDataFromProto(proto.getMetaData()); model.variableMetaData = new ArrayList<>(); for (int i = 0; i < proto.getVariableMetaDataCount(); i++) { model.variableMetaData.add(readMetaDataFromProto(proto.getVariableMetaData(i))); } for (int i = 0; i < proto.getFactorCount(); i++) { model.factors.add(Factor.readFromProto(proto.getFactor(i))); } return model; }
[ "public", "static", "GraphicalModel", "readFromProto", "(", "GraphicalModelProto", ".", "GraphicalModel", "proto", ")", "{", "if", "(", "proto", "==", "null", ")", "return", "null", ";", "GraphicalModel", "model", "=", "new", "GraphicalModel", "(", ")", ";", "model", ".", "modelMetaData", "=", "readMetaDataFromProto", "(", "proto", ".", "getMetaData", "(", ")", ")", ";", "model", ".", "variableMetaData", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "proto", ".", "getVariableMetaDataCount", "(", ")", ";", "i", "++", ")", "{", "model", ".", "variableMetaData", ".", "add", "(", "readMetaDataFromProto", "(", "proto", ".", "getVariableMetaData", "(", "i", ")", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "proto", ".", "getFactorCount", "(", ")", ";", "i", "++", ")", "{", "model", ".", "factors", ".", "add", "(", "Factor", ".", "readFromProto", "(", "proto", ".", "getFactor", "(", "i", ")", ")", ")", ";", "}", "return", "model", ";", "}" ]
Recreates an in-memory GraphicalModel from a proto serialization, recursively creating all the ConcatVectorTable's and ConcatVector's in memory as well. @param proto the proto to read @return an in-memory GraphicalModel
[ "Recreates", "an", "in", "-", "memory", "GraphicalModel", "from", "a", "proto", "serialization", "recursively", "creating", "all", "the", "ConcatVectorTable", "s", "and", "ConcatVector", "s", "in", "memory", "as", "well", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L636-L648
145,090
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.valueEquals
public boolean valueEquals(GraphicalModel other, double tolerance) { if (!modelMetaData.equals(other.modelMetaData)) { return false; } if (!variableMetaData.equals(other.variableMetaData)) { return false; } // compare factor sets for equality Set<Factor> remaining = new HashSet<>(); remaining.addAll(factors); for (Factor otherFactor : other.factors) { Factor match = null; for (Factor factor : remaining) { if (factor.valueEquals(otherFactor, tolerance)) { match = factor; break; } } if (match == null) return false; else remaining.remove(match); } return remaining.size() <= 0; }
java
public boolean valueEquals(GraphicalModel other, double tolerance) { if (!modelMetaData.equals(other.modelMetaData)) { return false; } if (!variableMetaData.equals(other.variableMetaData)) { return false; } // compare factor sets for equality Set<Factor> remaining = new HashSet<>(); remaining.addAll(factors); for (Factor otherFactor : other.factors) { Factor match = null; for (Factor factor : remaining) { if (factor.valueEquals(otherFactor, tolerance)) { match = factor; break; } } if (match == null) return false; else remaining.remove(match); } return remaining.size() <= 0; }
[ "public", "boolean", "valueEquals", "(", "GraphicalModel", "other", ",", "double", "tolerance", ")", "{", "if", "(", "!", "modelMetaData", ".", "equals", "(", "other", ".", "modelMetaData", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "variableMetaData", ".", "equals", "(", "other", ".", "variableMetaData", ")", ")", "{", "return", "false", ";", "}", "// compare factor sets for equality", "Set", "<", "Factor", ">", "remaining", "=", "new", "HashSet", "<>", "(", ")", ";", "remaining", ".", "addAll", "(", "factors", ")", ";", "for", "(", "Factor", "otherFactor", ":", "other", ".", "factors", ")", "{", "Factor", "match", "=", "null", ";", "for", "(", "Factor", "factor", ":", "remaining", ")", "{", "if", "(", "factor", ".", "valueEquals", "(", "otherFactor", ",", "tolerance", ")", ")", "{", "match", "=", "factor", ";", "break", ";", "}", "}", "if", "(", "match", "==", "null", ")", "return", "false", ";", "else", "remaining", ".", "remove", "(", "match", ")", ";", "}", "return", "remaining", ".", "size", "(", ")", "<=", "0", ";", "}" ]
Check that two models are deeply value-equivalent, down to the concat vectors inside the factor tables, within some tolerance. Mostly useful for testing. @param other the graphical model to compare against. @param tolerance the tolerance to accept when comparing concat vectors for value equality. @return whether the two models are tolerance equivalent
[ "Check", "that", "two", "models", "are", "deeply", "value", "-", "equivalent", "down", "to", "the", "concat", "vectors", "inside", "the", "factor", "tables", "within", "some", "tolerance", ".", "Mostly", "useful", "for", "testing", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L658-L680
145,091
keenon/loglinear
src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java
GraphicalModel.cloneModel
public GraphicalModel cloneModel() { GraphicalModel clone = new GraphicalModel(); clone.modelMetaData.putAll(modelMetaData); for (int i = 0; i < variableMetaData.size(); i++) { if (variableMetaData.get(i) != null) { clone.getVariableMetaDataByReference(i).putAll(variableMetaData.get(i)); } } for (Factor f : factors) { clone.factors.add(f.cloneFactor()); } return clone; }
java
public GraphicalModel cloneModel() { GraphicalModel clone = new GraphicalModel(); clone.modelMetaData.putAll(modelMetaData); for (int i = 0; i < variableMetaData.size(); i++) { if (variableMetaData.get(i) != null) { clone.getVariableMetaDataByReference(i).putAll(variableMetaData.get(i)); } } for (Factor f : factors) { clone.factors.add(f.cloneFactor()); } return clone; }
[ "public", "GraphicalModel", "cloneModel", "(", ")", "{", "GraphicalModel", "clone", "=", "new", "GraphicalModel", "(", ")", ";", "clone", ".", "modelMetaData", ".", "putAll", "(", "modelMetaData", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "variableMetaData", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "variableMetaData", ".", "get", "(", "i", ")", "!=", "null", ")", "{", "clone", ".", "getVariableMetaDataByReference", "(", "i", ")", ".", "putAll", "(", "variableMetaData", ".", "get", "(", "i", ")", ")", ";", "}", "}", "for", "(", "Factor", "f", ":", "factors", ")", "{", "clone", ".", "factors", ".", "add", "(", "f", ".", "cloneFactor", "(", ")", ")", ";", "}", "return", "clone", ";", "}" ]
The point here is to allow us to save a copy of the model with a current set of factors and metadata mappings, which can come in super handy with gameplaying applications. The cloned model doesn't instantiate the feature thunks inside factors, those are just taken over individually. @return a clone
[ "The", "point", "here", "is", "to", "allow", "us", "to", "save", "a", "copy", "of", "the", "model", "with", "a", "current", "set", "of", "factors", "and", "metadata", "mappings", "which", "can", "come", "in", "super", "handy", "with", "gameplaying", "applications", ".", "The", "cloned", "model", "doesn", "t", "instantiate", "the", "feature", "thunks", "inside", "factors", "those", "are", "just", "taken", "over", "individually", "." ]
fa0c370ab6782015412f676ef2ab11c97be58e29
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/GraphicalModel.java#L704-L718
145,092
fnklabs/draenei
src/main/java/com/fnklabs/draenei/CassandraClient.java
CassandraClient.close
public void close() { sessionsByKeyspace.entrySet() .forEach(session -> session.getValue().close()); cluster.close(); }
java
public void close() { sessionsByKeyspace.entrySet() .forEach(session -> session.getValue().close()); cluster.close(); }
[ "public", "void", "close", "(", ")", "{", "sessionsByKeyspace", ".", "entrySet", "(", ")", ".", "forEach", "(", "session", "->", "session", ".", "getValue", "(", ")", ".", "close", "(", ")", ")", ";", "cluster", ".", "close", "(", ")", ";", "}" ]
Initiate close cluster and session operations
[ "Initiate", "close", "cluster", "and", "session", "operations" ]
0a8cac54f1f635be3e2950375a23291d38453ae8
https://github.com/fnklabs/draenei/blob/0a8cac54f1f635be3e2950375a23291d38453ae8/src/main/java/com/fnklabs/draenei/CassandraClient.java#L291-L296
145,093
EsfingeFramework/ClassMock
ClassMock/src/main/java/net/sf/esfinge/classmock/MockClassLoader.java
MockClassLoader.getInstance
public static MockClassLoader getInstance() { if (MockClassLoader.instance == null) { MockClassLoader.instance = new MockClassLoader(); } return MockClassLoader.instance; }
java
public static MockClassLoader getInstance() { if (MockClassLoader.instance == null) { MockClassLoader.instance = new MockClassLoader(); } return MockClassLoader.instance; }
[ "public", "static", "MockClassLoader", "getInstance", "(", ")", "{", "if", "(", "MockClassLoader", ".", "instance", "==", "null", ")", "{", "MockClassLoader", ".", "instance", "=", "new", "MockClassLoader", "(", ")", ";", "}", "return", "MockClassLoader", ".", "instance", ";", "}" ]
Access an instance of our class loader. @return singleton
[ "Access", "an", "instance", "of", "our", "class", "loader", "." ]
a354c9dc68e8813fc4e995eef13e34796af58892
https://github.com/EsfingeFramework/ClassMock/blob/a354c9dc68e8813fc4e995eef13e34796af58892/ClassMock/src/main/java/net/sf/esfinge/classmock/MockClassLoader.java#L15-L23
145,094
jbundle/webapp
base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java
HttpServiceActivator.shutdownService
@Override public boolean shutdownService(Object service, BundleContext context) { if (this.service != null) ((HttpServiceTracker)this.service).close(); return true; }
java
@Override public boolean shutdownService(Object service, BundleContext context) { if (this.service != null) ((HttpServiceTracker)this.service).close(); return true; }
[ "@", "Override", "public", "boolean", "shutdownService", "(", "Object", "service", ",", "BundleContext", "context", ")", "{", "if", "(", "this", ".", "service", "!=", "null", ")", "(", "(", "HttpServiceTracker", ")", "this", ".", "service", ")", ".", "close", "(", ")", ";", "return", "true", ";", "}" ]
Shutdown this service. Override this to do all the startup. @return true if successful.
[ "Shutdown", "this", "service", ".", "Override", "this", "to", "do", "all", "the", "startup", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java#L58-L64
145,095
jbundle/webapp
base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java
HttpServiceActivator.createServiceTracker
public HttpServiceTracker createServiceTracker(BundleContext context, HttpContext httpContext, Dictionary<String, String> dictionary) { if (httpContext == null) httpContext = getHttpContext(); return new HttpServiceTracker(context, httpContext, dictionary); }
java
public HttpServiceTracker createServiceTracker(BundleContext context, HttpContext httpContext, Dictionary<String, String> dictionary) { if (httpContext == null) httpContext = getHttpContext(); return new HttpServiceTracker(context, httpContext, dictionary); }
[ "public", "HttpServiceTracker", "createServiceTracker", "(", "BundleContext", "context", ",", "HttpContext", "httpContext", ",", "Dictionary", "<", "String", ",", "String", ">", "dictionary", ")", "{", "if", "(", "httpContext", "==", "null", ")", "httpContext", "=", "getHttpContext", "(", ")", ";", "return", "new", "HttpServiceTracker", "(", "context", ",", "httpContext", ",", "dictionary", ")", ";", "}" ]
Create the service tracker. @param context @param httpContext @param dictionary @return
[ "Create", "the", "service", "tracker", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java#L73-L78
145,096
jbundle/webapp
base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java
HttpServiceActivator.getWebAlias
public String getWebAlias() { String contextPath = context.getProperty(BaseWebappServlet.ALIAS); if (contextPath == null) contextPath = context.getProperty(BaseWebappServlet.ALIAS.substring(BaseWebappServlet.PROPERTY_PREFIX.length())); if (contextPath == null) contextPath = this.getProperty(BaseWebappServlet.ALIAS); if (contextPath == null) contextPath = this.getProperty(BaseWebappServlet.ALIAS.substring(BaseWebappServlet.PROPERTY_PREFIX.length())); if (contextPath == null) { contextPath = this.getServicePid(); if (contextPath.lastIndexOf('.') != -1) contextPath = contextPath.substring(contextPath.lastIndexOf('.') + 1); } if (!contextPath.startsWith("/")) contextPath = "/" + contextPath; return contextPath; }
java
public String getWebAlias() { String contextPath = context.getProperty(BaseWebappServlet.ALIAS); if (contextPath == null) contextPath = context.getProperty(BaseWebappServlet.ALIAS.substring(BaseWebappServlet.PROPERTY_PREFIX.length())); if (contextPath == null) contextPath = this.getProperty(BaseWebappServlet.ALIAS); if (contextPath == null) contextPath = this.getProperty(BaseWebappServlet.ALIAS.substring(BaseWebappServlet.PROPERTY_PREFIX.length())); if (contextPath == null) { contextPath = this.getServicePid(); if (contextPath.lastIndexOf('.') != -1) contextPath = contextPath.substring(contextPath.lastIndexOf('.') + 1); } if (!contextPath.startsWith("/")) contextPath = "/" + contextPath; return contextPath; }
[ "public", "String", "getWebAlias", "(", ")", "{", "String", "contextPath", "=", "context", ".", "getProperty", "(", "BaseWebappServlet", ".", "ALIAS", ")", ";", "if", "(", "contextPath", "==", "null", ")", "contextPath", "=", "context", ".", "getProperty", "(", "BaseWebappServlet", ".", "ALIAS", ".", "substring", "(", "BaseWebappServlet", ".", "PROPERTY_PREFIX", ".", "length", "(", ")", ")", ")", ";", "if", "(", "contextPath", "==", "null", ")", "contextPath", "=", "this", ".", "getProperty", "(", "BaseWebappServlet", ".", "ALIAS", ")", ";", "if", "(", "contextPath", "==", "null", ")", "contextPath", "=", "this", ".", "getProperty", "(", "BaseWebappServlet", ".", "ALIAS", ".", "substring", "(", "BaseWebappServlet", ".", "PROPERTY_PREFIX", ".", "length", "(", ")", ")", ")", ";", "if", "(", "contextPath", "==", "null", ")", "{", "contextPath", "=", "this", ".", "getServicePid", "(", ")", ";", "if", "(", "contextPath", ".", "lastIndexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "contextPath", "=", "contextPath", ".", "substring", "(", "contextPath", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ";", "}", "if", "(", "!", "contextPath", ".", "startsWith", "(", "\"/\"", ")", ")", "contextPath", "=", "\"/\"", "+", "contextPath", ";", "return", "contextPath", ";", "}" ]
Get the web alias for this servlet. @param context @return
[ "Get", "the", "web", "alias", "for", "this", "servlet", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java#L84-L102
145,097
jbundle/webapp
base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java
HttpServiceActivator.getServiceTracker
public static HttpServiceTracker getServiceTracker(BundleContext context, String key, String value) { String filter = "(" + key + "=" + value + ")"; try { ServiceReference[] references = context.getServiceReferences(ServiceTracker.class.getName(), filter); if ((references == null) || (references.length == 0)) references = context.getServiceReferences(ServiceTracker.class.getName(), null); // Being paranoid if (references != null) { for (ServiceReference reference : references) { Object service = context.getService(reference); if (service instanceof HttpServiceTracker) // Always if (value.equals(((HttpServiceTracker)service).getProperty(key))) // Being paranoid return (HttpServiceTracker)service; } } } catch (InvalidSyntaxException e) { e.printStackTrace(); } return null; // Not found }
java
public static HttpServiceTracker getServiceTracker(BundleContext context, String key, String value) { String filter = "(" + key + "=" + value + ")"; try { ServiceReference[] references = context.getServiceReferences(ServiceTracker.class.getName(), filter); if ((references == null) || (references.length == 0)) references = context.getServiceReferences(ServiceTracker.class.getName(), null); // Being paranoid if (references != null) { for (ServiceReference reference : references) { Object service = context.getService(reference); if (service instanceof HttpServiceTracker) // Always if (value.equals(((HttpServiceTracker)service).getProperty(key))) // Being paranoid return (HttpServiceTracker)service; } } } catch (InvalidSyntaxException e) { e.printStackTrace(); } return null; // Not found }
[ "public", "static", "HttpServiceTracker", "getServiceTracker", "(", "BundleContext", "context", ",", "String", "key", ",", "String", "value", ")", "{", "String", "filter", "=", "\"(\"", "+", "key", "+", "\"=\"", "+", "value", "+", "\")\"", ";", "try", "{", "ServiceReference", "[", "]", "references", "=", "context", ".", "getServiceReferences", "(", "ServiceTracker", ".", "class", ".", "getName", "(", ")", ",", "filter", ")", ";", "if", "(", "(", "references", "==", "null", ")", "||", "(", "references", ".", "length", "==", "0", ")", ")", "references", "=", "context", ".", "getServiceReferences", "(", "ServiceTracker", ".", "class", ".", "getName", "(", ")", ",", "null", ")", ";", "// Being paranoid", "if", "(", "references", "!=", "null", ")", "{", "for", "(", "ServiceReference", "reference", ":", "references", ")", "{", "Object", "service", "=", "context", ".", "getService", "(", "reference", ")", ";", "if", "(", "service", "instanceof", "HttpServiceTracker", ")", "// Always", "if", "(", "value", ".", "equals", "(", "(", "(", "HttpServiceTracker", ")", "service", ")", ".", "getProperty", "(", "key", ")", ")", ")", "// Being paranoid", "return", "(", "HttpServiceTracker", ")", "service", ";", "}", "}", "}", "catch", "(", "InvalidSyntaxException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "// Not found", "}" ]
Get this service tracker. @param alias @return
[ "Get", "this", "service", "tracker", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/HttpServiceActivator.java#L125-L145
145,098
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/ByteCodeGenerator.java
ByteCodeGenerator.createCtClass
private CtClass createCtClass(final SgClass modelClass) throws NotFoundException, CannotCompileException { // Create class final CtClass clasz = pool.makeClass(modelClass.getName()); clasz.setModifiers(SgUtils.toModifiers(modelClass.getModifiers())); // Add superclass if (modelClass.getSuperClass() != null) { clasz.setSuperclass(pool.get(modelClass.getSuperClass().getName())); } addInterfaces(modelClass, clasz); addFields(modelClass, clasz); addConstructors(modelClass, clasz); addMethods(modelClass, clasz); return clasz; }
java
private CtClass createCtClass(final SgClass modelClass) throws NotFoundException, CannotCompileException { // Create class final CtClass clasz = pool.makeClass(modelClass.getName()); clasz.setModifiers(SgUtils.toModifiers(modelClass.getModifiers())); // Add superclass if (modelClass.getSuperClass() != null) { clasz.setSuperclass(pool.get(modelClass.getSuperClass().getName())); } addInterfaces(modelClass, clasz); addFields(modelClass, clasz); addConstructors(modelClass, clasz); addMethods(modelClass, clasz); return clasz; }
[ "private", "CtClass", "createCtClass", "(", "final", "SgClass", "modelClass", ")", "throws", "NotFoundException", ",", "CannotCompileException", "{", "// Create class\r", "final", "CtClass", "clasz", "=", "pool", ".", "makeClass", "(", "modelClass", ".", "getName", "(", ")", ")", ";", "clasz", ".", "setModifiers", "(", "SgUtils", ".", "toModifiers", "(", "modelClass", ".", "getModifiers", "(", ")", ")", ")", ";", "// Add superclass\r", "if", "(", "modelClass", ".", "getSuperClass", "(", ")", "!=", "null", ")", "{", "clasz", ".", "setSuperclass", "(", "pool", ".", "get", "(", "modelClass", ".", "getSuperClass", "(", ")", ".", "getName", "(", ")", ")", ")", ";", "}", "addInterfaces", "(", "modelClass", ",", "clasz", ")", ";", "addFields", "(", "modelClass", ",", "clasz", ")", ";", "addConstructors", "(", "modelClass", ",", "clasz", ")", ";", "addMethods", "(", "modelClass", ",", "clasz", ")", ";", "return", "clasz", ";", "}" ]
Creates a Javassist class from a given model class. @param modelClass Model class to convert into a Javassist class. @return Javassist class. @throws NotFoundException A class or interface from the model was not found. @throws CannotCompileException Some source from the model cannot be compiled.
[ "Creates", "a", "Javassist", "class", "from", "a", "given", "model", "class", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/ByteCodeGenerator.java#L123-L141
145,099
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/ByteCodeGenerator.java
ByteCodeGenerator.createWithCurrentThreadContextClassLoader
public static ByteCodeGenerator createWithCurrentThreadContextClassLoader() { final ClassPool pool = ClassPool.getDefault(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); pool.appendClassPath(new LoaderClassPath(classLoader)); return new ByteCodeGenerator(pool, classLoader); }
java
public static ByteCodeGenerator createWithCurrentThreadContextClassLoader() { final ClassPool pool = ClassPool.getDefault(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); pool.appendClassPath(new LoaderClassPath(classLoader)); return new ByteCodeGenerator(pool, classLoader); }
[ "public", "static", "ByteCodeGenerator", "createWithCurrentThreadContextClassLoader", "(", ")", "{", "final", "ClassPool", "pool", "=", "ClassPool", ".", "getDefault", "(", ")", ";", "final", "ClassLoader", "classLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "pool", ".", "appendClassPath", "(", "new", "LoaderClassPath", "(", "classLoader", ")", ")", ";", "return", "new", "ByteCodeGenerator", "(", "pool", ",", "classLoader", ")", ";", "}" ]
Creates a generator initialized with default class pool and the context class loader of the current thread. @return New byte code generator instance.
[ "Creates", "a", "generator", "initialized", "with", "default", "class", "pool", "and", "the", "context", "class", "loader", "of", "the", "current", "thread", "." ]
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/ByteCodeGenerator.java#L351-L356