repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
11
218
func_name
stringlengths
4
140
whole_func_string
stringlengths
153
5.32k
language
stringclasses
1 value
func_code_string
stringlengths
72
4k
func_code_tokens
sequencelengths
20
832
func_documentation_string
stringlengths
61
2k
func_documentation_tokens
sequencelengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
102
339
alkacon/opencms-core
src/org/opencms/staticexport/CmsLinkManager.java
CmsLinkManager.getSitePath
@Deprecated public static String getSitePath(CmsObject cms, String basePath, String targetUri) { """ Returns the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site.<p> @param cms the current users OpenCms context @param basePath path to use as base site for the target URI (can be <code>null</code>) @param targetUri the target URI @return the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site @deprecated use {@link #getRootPath(CmsObject, String, String)} instead, obtain the link manager with {@link OpenCms#getLinkManager()} """ return OpenCms.getLinkManager().getRootPath(cms, targetUri, basePath); }
java
@Deprecated public static String getSitePath(CmsObject cms, String basePath, String targetUri) { return OpenCms.getLinkManager().getRootPath(cms, targetUri, basePath); }
[ "@", "Deprecated", "public", "static", "String", "getSitePath", "(", "CmsObject", "cms", ",", "String", "basePath", ",", "String", "targetUri", ")", "{", "return", "OpenCms", ".", "getLinkManager", "(", ")", ".", "getRootPath", "(", "cms", ",", "targetUri", ",", "basePath", ")", ";", "}" ]
Returns the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site.<p> @param cms the current users OpenCms context @param basePath path to use as base site for the target URI (can be <code>null</code>) @param targetUri the target URI @return the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site @deprecated use {@link #getRootPath(CmsObject, String, String)} instead, obtain the link manager with {@link OpenCms#getLinkManager()}
[ "Returns", "the", "resource", "root", "path", "for", "the", "given", "target", "URI", "in", "the", "OpenCms", "VFS", "or", "<code", ">", "null<", "/", "code", ">", "in", "case", "the", "target", "URI", "points", "to", "an", "external", "site", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L192-L196
landawn/AbacusUtil
src/com/landawn/abacus/util/FileSystemUtil.java
FileSystemUtil.freeSpaceKb
public static long freeSpaceKb(final String path, final long timeout) throws IOException { """ Returns the free space on a drive or volume in kilobytes by invoking the command line. <pre> FileSystemUtils.freeSpaceKb("C:"); // Windows FileSystemUtils.freeSpaceKb("/volume"); // *nix </pre> The free space is calculated via the command line. It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix. <p> In order to work, you must be running Windows, or have a implementation of Unix df that supports GNU format when passed -k (or -kP). If you are going to rely on this code, please check that it works on your OS by running some simple tests to compare the command line with the output from this class. If your operating system isn't supported, please raise a JIRA call detailing the exact result from df -k and as much other detail as possible, thanks. @param path the path to get free space for, not null, not empty on Unix @param timeout The timeout amount in milliseconds or no timeout if the value is zero or less @return the amount of free drive space on the drive or volume in kilobytes @throws IllegalArgumentException if the path is invalid @throws IllegalStateException if an error occurred in initialisation @throws IOException if an error occurs when finding the free space @since 2.0 """ return INSTANCE.freeSpaceOS(path, OS, true, timeout); }
java
public static long freeSpaceKb(final String path, final long timeout) throws IOException { return INSTANCE.freeSpaceOS(path, OS, true, timeout); }
[ "public", "static", "long", "freeSpaceKb", "(", "final", "String", "path", ",", "final", "long", "timeout", ")", "throws", "IOException", "{", "return", "INSTANCE", ".", "freeSpaceOS", "(", "path", ",", "OS", ",", "true", ",", "timeout", ")", ";", "}" ]
Returns the free space on a drive or volume in kilobytes by invoking the command line. <pre> FileSystemUtils.freeSpaceKb("C:"); // Windows FileSystemUtils.freeSpaceKb("/volume"); // *nix </pre> The free space is calculated via the command line. It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix. <p> In order to work, you must be running Windows, or have a implementation of Unix df that supports GNU format when passed -k (or -kP). If you are going to rely on this code, please check that it works on your OS by running some simple tests to compare the command line with the output from this class. If your operating system isn't supported, please raise a JIRA call detailing the exact result from df -k and as much other detail as possible, thanks. @param path the path to get free space for, not null, not empty on Unix @param timeout The timeout amount in milliseconds or no timeout if the value is zero or less @return the amount of free drive space on the drive or volume in kilobytes @throws IllegalArgumentException if the path is invalid @throws IllegalStateException if an error occurred in initialisation @throws IOException if an error occurs when finding the free space @since 2.0
[ "Returns", "the", "free", "space", "on", "a", "drive", "or", "volume", "in", "kilobytes", "by", "invoking", "the", "command", "line", ".", "<pre", ">", "FileSystemUtils", ".", "freeSpaceKb", "(", "C", ":", ")", ";", "//", "Windows", "FileSystemUtils", ".", "freeSpaceKb", "(", "/", "volume", ")", ";", "//", "*", "nix", "<", "/", "pre", ">", "The", "free", "space", "is", "calculated", "via", "the", "command", "line", ".", "It", "uses", "dir", "/", "-", "c", "on", "Windows", "df", "-", "kP", "on", "AIX", "/", "HP", "-", "UX", "and", "df", "-", "k", "on", "other", "Unix", ".", "<p", ">", "In", "order", "to", "work", "you", "must", "be", "running", "Windows", "or", "have", "a", "implementation", "of", "Unix", "df", "that", "supports", "GNU", "format", "when", "passed", "-", "k", "(", "or", "-", "kP", ")", ".", "If", "you", "are", "going", "to", "rely", "on", "this", "code", "please", "check", "that", "it", "works", "on", "your", "OS", "by", "running", "some", "simple", "tests", "to", "compare", "the", "command", "line", "with", "the", "output", "from", "this", "class", ".", "If", "your", "operating", "system", "isn", "t", "supported", "please", "raise", "a", "JIRA", "call", "detailing", "the", "exact", "result", "from", "df", "-", "k", "and", "as", "much", "other", "detail", "as", "possible", "thanks", "." ]
train
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/FileSystemUtil.java#L161-L163
asterisk-java/asterisk-java
src/main/java/org/asteriskjava/util/AstState.java
AstState.str2state
public static Integer str2state(String str) { """ This is the inverse to <code>ast_state2str</code> in <code>channel.c</code>. @param str state as a descriptive text. @return numeric state. """ Integer state; if (str == null) { return null; } state = inverseStateMap.get(str); if (state == null) { Matcher matcher = UNKNOWN_STATE_PATTERN.matcher(str); if (matcher.matches()) { try { state = Integer.valueOf(matcher.group(1)); } catch (NumberFormatException e) { // should not happen as the pattern requires \d+ for the state. throw new IllegalArgumentException("Unable to convert state '" + str + "' to integer representation", e); } } } return state; }
java
public static Integer str2state(String str) { Integer state; if (str == null) { return null; } state = inverseStateMap.get(str); if (state == null) { Matcher matcher = UNKNOWN_STATE_PATTERN.matcher(str); if (matcher.matches()) { try { state = Integer.valueOf(matcher.group(1)); } catch (NumberFormatException e) { // should not happen as the pattern requires \d+ for the state. throw new IllegalArgumentException("Unable to convert state '" + str + "' to integer representation", e); } } } return state; }
[ "public", "static", "Integer", "str2state", "(", "String", "str", ")", "{", "Integer", "state", ";", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "state", "=", "inverseStateMap", ".", "get", "(", "str", ")", ";", "if", "(", "state", "==", "null", ")", "{", "Matcher", "matcher", "=", "UNKNOWN_STATE_PATTERN", ".", "matcher", "(", "str", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "try", "{", "state", "=", "Integer", ".", "valueOf", "(", "matcher", ".", "group", "(", "1", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "// should not happen as the pattern requires \\d+ for the state.", "throw", "new", "IllegalArgumentException", "(", "\"Unable to convert state '\"", "+", "str", "+", "\"' to integer representation\"", ",", "e", ")", ";", "}", "}", "}", "return", "state", ";", "}" ]
This is the inverse to <code>ast_state2str</code> in <code>channel.c</code>. @param str state as a descriptive text. @return numeric state.
[ "This", "is", "the", "inverse", "to", "<code", ">", "ast_state2str<", "/", "code", ">", "in", "<code", ">", "channel", ".", "c<", "/", "code", ">", "." ]
train
https://github.com/asterisk-java/asterisk-java/blob/cdc9849270d97ef75afa447a02c5194ed29121eb/src/main/java/org/asteriskjava/util/AstState.java#L101-L130
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeSingleNullableDesc
public static byte[] decodeSingleNullableDesc(byte[] src, int prefixPadding, int suffixPadding) throws CorruptEncodingException { """ Decodes the given byte array which was encoded by {@link KeyEncoder#encodeSingleNullableDesc}. Always returns a new byte array instance. @param prefixPadding amount of extra bytes to skip from start of encoded byte array @param suffixPadding amount of extra bytes to skip at end of encoded byte array """ try { byte b = src[prefixPadding]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } int length = src.length - suffixPadding - 1 - prefixPadding; if (length == 0) { return EMPTY_BYTE_ARRAY; } byte[] dst = new byte[length]; while (--length >= 0) { dst[length] = (byte) (~src[1 + prefixPadding + length]); } return dst; } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static byte[] decodeSingleNullableDesc(byte[] src, int prefixPadding, int suffixPadding) throws CorruptEncodingException { try { byte b = src[prefixPadding]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } int length = src.length - suffixPadding - 1 - prefixPadding; if (length == 0) { return EMPTY_BYTE_ARRAY; } byte[] dst = new byte[length]; while (--length >= 0) { dst[length] = (byte) (~src[1 + prefixPadding + length]); } return dst; } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "byte", "[", "]", "decodeSingleNullableDesc", "(", "byte", "[", "]", "src", ",", "int", "prefixPadding", ",", "int", "suffixPadding", ")", "throws", "CorruptEncodingException", "{", "try", "{", "byte", "b", "=", "src", "[", "prefixPadding", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "int", "length", "=", "src", ".", "length", "-", "suffixPadding", "-", "1", "-", "prefixPadding", ";", "if", "(", "length", "==", "0", ")", "{", "return", "EMPTY_BYTE_ARRAY", ";", "}", "byte", "[", "]", "dst", "=", "new", "byte", "[", "length", "]", ";", "while", "(", "--", "length", ">=", "0", ")", "{", "dst", "[", "length", "]", "=", "(", "byte", ")", "(", "~", "src", "[", "1", "+", "prefixPadding", "+", "length", "]", ")", ";", "}", "return", "dst", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes the given byte array which was encoded by {@link KeyEncoder#encodeSingleNullableDesc}. Always returns a new byte array instance. @param prefixPadding amount of extra bytes to skip from start of encoded byte array @param suffixPadding amount of extra bytes to skip at end of encoded byte array
[ "Decodes", "the", "given", "byte", "array", "which", "was", "encoded", "by", "{", "@link", "KeyEncoder#encodeSingleNullableDesc", "}", ".", "Always", "returns", "a", "new", "byte", "array", "instance", "." ]
train
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L881-L901
deeplearning4j/deeplearning4j
nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/NDArrayMessage.java
NDArrayMessage.numChunksForMessage
public static int numChunksForMessage(NDArrayMessage message, int chunkSize) { """ Determine the number of chunks @param message @param chunkSize @return """ int sizeOfMessage = NDArrayMessage.byteBufferSizeForMessage(message); int numMessages = sizeOfMessage / chunkSize; //increase by 1 for padding if (numMessages * chunkSize < sizeOfMessage) numMessages++; return numMessages; }
java
public static int numChunksForMessage(NDArrayMessage message, int chunkSize) { int sizeOfMessage = NDArrayMessage.byteBufferSizeForMessage(message); int numMessages = sizeOfMessage / chunkSize; //increase by 1 for padding if (numMessages * chunkSize < sizeOfMessage) numMessages++; return numMessages; }
[ "public", "static", "int", "numChunksForMessage", "(", "NDArrayMessage", "message", ",", "int", "chunkSize", ")", "{", "int", "sizeOfMessage", "=", "NDArrayMessage", ".", "byteBufferSizeForMessage", "(", "message", ")", ";", "int", "numMessages", "=", "sizeOfMessage", "/", "chunkSize", ";", "//increase by 1 for padding", "if", "(", "numMessages", "*", "chunkSize", "<", "sizeOfMessage", ")", "numMessages", "++", ";", "return", "numMessages", ";", "}" ]
Determine the number of chunks @param message @param chunkSize @return
[ "Determine", "the", "number", "of", "chunks" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/NDArrayMessage.java#L85-L92
cternes/openkeepass
src/main/java/de/slackspace/openkeepass/KeePassDatabase.java
KeePassDatabase.openDatabase
public KeePassFile openDatabase(String password, InputStream keyFileStream) { """ Opens a KeePass database with the given password and keyfile stream and returns the KeePassFile for further processing. <p> If the database cannot be decrypted with the provided password and keyfile stream an exception will be thrown. @param password the password to open the database @param keyFileStream the keyfile to open the database as stream @return a KeePassFile @see KeePassFile """ if (password == null) { throw new IllegalArgumentException(MSG_EMPTY_MASTER_KEY); } if (keyFileStream == null) { throw new IllegalArgumentException("You must provide a non-empty KeePass keyfile stream."); } try { byte[] passwordBytes = password.getBytes(UTF_8); byte[] hashedPassword = Sha256.hash(passwordBytes); byte[] protectedBuffer = new KeyFileReader().readKeyFile(keyFileStream); return new KeePassDatabaseReader(keepassHeader).decryptAndParseDatabase(ByteUtils.concat(hashedPassword, protectedBuffer), keepassFile); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException(MSG_UTF8_NOT_SUPPORTED, e); } }
java
public KeePassFile openDatabase(String password, InputStream keyFileStream) { if (password == null) { throw new IllegalArgumentException(MSG_EMPTY_MASTER_KEY); } if (keyFileStream == null) { throw new IllegalArgumentException("You must provide a non-empty KeePass keyfile stream."); } try { byte[] passwordBytes = password.getBytes(UTF_8); byte[] hashedPassword = Sha256.hash(passwordBytes); byte[] protectedBuffer = new KeyFileReader().readKeyFile(keyFileStream); return new KeePassDatabaseReader(keepassHeader).decryptAndParseDatabase(ByteUtils.concat(hashedPassword, protectedBuffer), keepassFile); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException(MSG_UTF8_NOT_SUPPORTED, e); } }
[ "public", "KeePassFile", "openDatabase", "(", "String", "password", ",", "InputStream", "keyFileStream", ")", "{", "if", "(", "password", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "MSG_EMPTY_MASTER_KEY", ")", ";", "}", "if", "(", "keyFileStream", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"You must provide a non-empty KeePass keyfile stream.\"", ")", ";", "}", "try", "{", "byte", "[", "]", "passwordBytes", "=", "password", ".", "getBytes", "(", "UTF_8", ")", ";", "byte", "[", "]", "hashedPassword", "=", "Sha256", ".", "hash", "(", "passwordBytes", ")", ";", "byte", "[", "]", "protectedBuffer", "=", "new", "KeyFileReader", "(", ")", ".", "readKeyFile", "(", "keyFileStream", ")", ";", "return", "new", "KeePassDatabaseReader", "(", "keepassHeader", ")", ".", "decryptAndParseDatabase", "(", "ByteUtils", ".", "concat", "(", "hashedPassword", ",", "protectedBuffer", ")", ",", "keepassFile", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "MSG_UTF8_NOT_SUPPORTED", ",", "e", ")", ";", "}", "}" ]
Opens a KeePass database with the given password and keyfile stream and returns the KeePassFile for further processing. <p> If the database cannot be decrypted with the provided password and keyfile stream an exception will be thrown. @param password the password to open the database @param keyFileStream the keyfile to open the database as stream @return a KeePassFile @see KeePassFile
[ "Opens", "a", "KeePass", "database", "with", "the", "given", "password", "and", "keyfile", "stream", "and", "returns", "the", "KeePassFile", "for", "further", "processing", ".", "<p", ">", "If", "the", "database", "cannot", "be", "decrypted", "with", "the", "provided", "password", "and", "keyfile", "stream", "an", "exception", "will", "be", "thrown", "." ]
train
https://github.com/cternes/openkeepass/blob/4a354aecaea38af3c0dce5eb81b533f297e8d94f/src/main/java/de/slackspace/openkeepass/KeePassDatabase.java#L225-L242
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.setTermMeta
public void setTermMeta(final long termId, final List<Meta> termMeta) throws SQLException { """ Sets metadata for a term. <p> Clears existing metadata. </p> @param termId The term id. @param termMeta The metadata. @throws SQLException on database error. """ clearTermMeta(termId); if(termMeta == null || termMeta.size() == 0) { return; } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTermMetaSQL); for(Meta meta : termMeta) { stmt.setLong(1, termId); stmt.setString(2, meta.key); stmt.setString(3, meta.value); stmt.executeUpdate(); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void setTermMeta(final long termId, final List<Meta> termMeta) throws SQLException { clearTermMeta(termId); if(termMeta == null || termMeta.size() == 0) { return; } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTermMetaSQL); for(Meta meta : termMeta) { stmt.setLong(1, termId); stmt.setString(2, meta.key); stmt.setString(3, meta.value); stmt.executeUpdate(); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "setTermMeta", "(", "final", "long", "termId", ",", "final", "List", "<", "Meta", ">", "termMeta", ")", "throws", "SQLException", "{", "clearTermMeta", "(", "termId", ")", ";", "if", "(", "termMeta", "==", "null", "||", "termMeta", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "setTermMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "insertTermMetaSQL", ")", ";", "for", "(", "Meta", "meta", ":", "termMeta", ")", "{", "stmt", ".", "setLong", "(", "1", ",", "termId", ")", ";", "stmt", ".", "setString", "(", "2", ",", "meta", ".", "key", ")", ";", "stmt", ".", "setString", "(", "3", ",", "meta", ".", "value", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Sets metadata for a term. <p> Clears existing metadata. </p> @param termId The term id. @param termMeta The metadata. @throws SQLException on database error.
[ "Sets", "metadata", "for", "a", "term", ".", "<p", ">", "Clears", "existing", "metadata", ".", "<", "/", "p", ">" ]
train
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2085-L2108
palatable/lambda
src/main/java/com/jnape/palatable/lambda/optics/lenses/ListLens.java
ListLens.asCopy
public static <X> Lens.Simple<List<X>, List<X>> asCopy() { """ Convenience static factory method for creating a lens over a copy of a list. Useful for composition to avoid mutating a list reference. @param <X> the list element type @return a lens that focuses on copies of lists """ return simpleLens(ArrayList::new, (xs, ys) -> ys); }
java
public static <X> Lens.Simple<List<X>, List<X>> asCopy() { return simpleLens(ArrayList::new, (xs, ys) -> ys); }
[ "public", "static", "<", "X", ">", "Lens", ".", "Simple", "<", "List", "<", "X", ">", ",", "List", "<", "X", ">", ">", "asCopy", "(", ")", "{", "return", "simpleLens", "(", "ArrayList", "::", "new", ",", "(", "xs", ",", "ys", ")", "->", "ys", ")", ";", "}" ]
Convenience static factory method for creating a lens over a copy of a list. Useful for composition to avoid mutating a list reference. @param <X> the list element type @return a lens that focuses on copies of lists
[ "Convenience", "static", "factory", "method", "for", "creating", "a", "lens", "over", "a", "copy", "of", "a", "list", ".", "Useful", "for", "composition", "to", "avoid", "mutating", "a", "list", "reference", "." ]
train
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/optics/lenses/ListLens.java#L32-L34
dbracewell/hermes
hermes-core/src/main/java/com/davidbracewell/hermes/HString.java
HString.rightContext
public HString rightContext(@NonNull AnnotationType type, int windowSize) { """ Right context h string. @param type the type @param windowSize the window size @return the h string """ windowSize = Math.abs(windowSize); Preconditions.checkArgument(windowSize >= 0); int sentenceEnd = sentence().end(); if (windowSize == 0 || end() >= sentenceEnd) { return Fragments.detachedEmptyHString(); } HString context = lastToken().next(type); for (int i = 1; i < windowSize; i++) { HString next = context .lastToken() .next(type); if (next.start() >= sentenceEnd) { break; } context = context.union(next); } return context; }
java
public HString rightContext(@NonNull AnnotationType type, int windowSize) { windowSize = Math.abs(windowSize); Preconditions.checkArgument(windowSize >= 0); int sentenceEnd = sentence().end(); if (windowSize == 0 || end() >= sentenceEnd) { return Fragments.detachedEmptyHString(); } HString context = lastToken().next(type); for (int i = 1; i < windowSize; i++) { HString next = context .lastToken() .next(type); if (next.start() >= sentenceEnd) { break; } context = context.union(next); } return context; }
[ "public", "HString", "rightContext", "(", "@", "NonNull", "AnnotationType", "type", ",", "int", "windowSize", ")", "{", "windowSize", "=", "Math", ".", "abs", "(", "windowSize", ")", ";", "Preconditions", ".", "checkArgument", "(", "windowSize", ">=", "0", ")", ";", "int", "sentenceEnd", "=", "sentence", "(", ")", ".", "end", "(", ")", ";", "if", "(", "windowSize", "==", "0", "||", "end", "(", ")", ">=", "sentenceEnd", ")", "{", "return", "Fragments", ".", "detachedEmptyHString", "(", ")", ";", "}", "HString", "context", "=", "lastToken", "(", ")", ".", "next", "(", "type", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "windowSize", ";", "i", "++", ")", "{", "HString", "next", "=", "context", ".", "lastToken", "(", ")", ".", "next", "(", "type", ")", ";", "if", "(", "next", ".", "start", "(", ")", ">=", "sentenceEnd", ")", "{", "break", ";", "}", "context", "=", "context", ".", "union", "(", "next", ")", ";", "}", "return", "context", ";", "}" ]
Right context h string. @param type the type @param windowSize the window size @return the h string
[ "Right", "context", "h", "string", "." ]
train
https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/HString.java#L879-L897
Pi4J/pi4j
pi4j-core/src/main/java/com/pi4j/wiringpi/Lcd.java
Lcd.lcdPuts
public static void lcdPuts(int handle, String data, String... args) { """ <p>Write formatted string of data to the LCD display.</p> <p>(ATTENTION: the 'data' argument can only be a maximum of 512 characters.)</p> @see <a href="http://wiringpi.com/dev-lib/lcd-library/">http://wiringpi.com/dev-lib/lcd-library/</a> @param handle file handle @param data format string to write @param args string arguments to use in formatted string """ lcdPuts(handle, String.format(data, (Object[]) args)); }
java
public static void lcdPuts(int handle, String data, String... args) { lcdPuts(handle, String.format(data, (Object[]) args)); }
[ "public", "static", "void", "lcdPuts", "(", "int", "handle", ",", "String", "data", ",", "String", "...", "args", ")", "{", "lcdPuts", "(", "handle", ",", "String", ".", "format", "(", "data", ",", "(", "Object", "[", "]", ")", "args", ")", ")", ";", "}" ]
<p>Write formatted string of data to the LCD display.</p> <p>(ATTENTION: the 'data' argument can only be a maximum of 512 characters.)</p> @see <a href="http://wiringpi.com/dev-lib/lcd-library/">http://wiringpi.com/dev-lib/lcd-library/</a> @param handle file handle @param data format string to write @param args string arguments to use in formatted string
[ "<p", ">", "Write", "formatted", "string", "of", "data", "to", "the", "LCD", "display", ".", "<", "/", "p", ">" ]
train
https://github.com/Pi4J/pi4j/blob/03cacc62223cc59b3118bfcefadabab979fd84c7/pi4j-core/src/main/java/com/pi4j/wiringpi/Lcd.java#L269-L271
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getMaxStringWidth
public float getMaxStringWidth(List<String> strings, FontOptions options) { """ Gets max rendering width of an array of string. @param strings the strings @param options the options @return the max string width """ float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
java
public float getMaxStringWidth(List<String> strings, FontOptions options) { float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
[ "public", "float", "getMaxStringWidth", "(", "List", "<", "String", ">", "strings", ",", "FontOptions", "options", ")", "{", "float", "width", "=", "0", ";", "for", "(", "String", "str", ":", "strings", ")", "width", "=", "Math", ".", "max", "(", "width", ",", "getStringWidth", "(", "str", ",", "options", ")", ")", ";", "return", "width", ";", "}", "/**\n\t * Gets the rendering width of a character.\n\t *\n\t * @param c the c\n\t * @param options the options\n\t * @return the char width\n\t */", "public", "float", "getCharWidth", "(", "char", "c", ",", "FontOptions", "options", ")", "{", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "return", "0", ";", "if", "(", "c", "==", "'", "'", ")", "return", "getCharWidth", "(", "'", "'", ",", "options", ")", "*", "4", ";", "return", "getCharData", "(", "c", ")", ".", "getCharWidth", "(", ")", "/", "fontGeneratorOptions", ".", "fontSize", "*", "(", "options", "!=", "null", "?", "options", ".", "getFontScale", "(", ")", ":", "1", ")", "*", "9", ";", "}" ]
Gets max rendering width of an array of string. @param strings the strings @param options the options @return the max string width
[ "Gets", "max", "rendering", "width", "of", "an", "array", "of", "string", "." ]
train
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L508-L531
watson-developer-cloud/java-sdk
discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java
AggregationDeserializer.parseArray
private void parseArray(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException { """ Parses a JSON array and adds it to the main object map. @param in {@link JsonReader} object used for parsing @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object @param name key value to go with the resulting value of this method pass @throws IOException signals that there has been an IO exception """ List<HashMap<String, Object>> array = new ArrayList<>(); in.beginArray(); while (in.peek() != JsonToken.END_ARRAY) { HashMap<String, Object> arrayItem = new HashMap<>(); parseNext(in, arrayItem); array.add(arrayItem); } in.endArray(); objMap.put(name, array); }
java
private void parseArray(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException { List<HashMap<String, Object>> array = new ArrayList<>(); in.beginArray(); while (in.peek() != JsonToken.END_ARRAY) { HashMap<String, Object> arrayItem = new HashMap<>(); parseNext(in, arrayItem); array.add(arrayItem); } in.endArray(); objMap.put(name, array); }
[ "private", "void", "parseArray", "(", "JsonReader", "in", ",", "HashMap", "<", "String", ",", "Object", ">", "objMap", ",", "String", "name", ")", "throws", "IOException", "{", "List", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "array", "=", "new", "ArrayList", "<>", "(", ")", ";", "in", ".", "beginArray", "(", ")", ";", "while", "(", "in", ".", "peek", "(", ")", "!=", "JsonToken", ".", "END_ARRAY", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "arrayItem", "=", "new", "HashMap", "<>", "(", ")", ";", "parseNext", "(", "in", ",", "arrayItem", ")", ";", "array", ".", "add", "(", "arrayItem", ")", ";", "}", "in", ".", "endArray", "(", ")", ";", "objMap", ".", "put", "(", "name", ",", "array", ")", ";", "}" ]
Parses a JSON array and adds it to the main object map. @param in {@link JsonReader} object used for parsing @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object @param name key value to go with the resulting value of this method pass @throws IOException signals that there has been an IO exception
[ "Parses", "a", "JSON", "array", "and", "adds", "it", "to", "the", "main", "object", "map", "." ]
train
https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java#L157-L169
padrig64/ValidationFramework
validationframework-core/src/main/java/com/google/code/validationframework/base/property/AbstractReadableMapProperty.java
AbstractReadableMapProperty.doNotifyListenersOfChangedValues
protected void doNotifyListenersOfChangedValues(Map<K, R> oldValues, Map<K, R> newValues) { """ Notifies the change listeners that values have been replaced. <p> Note that the specified maps of values will be wrapped in unmodifiable maps before being passed to the listeners. @param oldValues Previous values. @param newValues New values. """ List<MapValueChangeListener<K, R>> listenersCopy = new ArrayList<MapValueChangeListener<K, R>>(listeners); Map<K, R> oldUnmodifiable = Collections.unmodifiableMap(oldValues); Map<K, R> newUnmodifiable = Collections.unmodifiableMap(newValues); for (MapValueChangeListener<K, R> listener : listenersCopy) { listener.valuesChanged(this, oldUnmodifiable, newUnmodifiable); } }
java
protected void doNotifyListenersOfChangedValues(Map<K, R> oldValues, Map<K, R> newValues) { List<MapValueChangeListener<K, R>> listenersCopy = new ArrayList<MapValueChangeListener<K, R>>(listeners); Map<K, R> oldUnmodifiable = Collections.unmodifiableMap(oldValues); Map<K, R> newUnmodifiable = Collections.unmodifiableMap(newValues); for (MapValueChangeListener<K, R> listener : listenersCopy) { listener.valuesChanged(this, oldUnmodifiable, newUnmodifiable); } }
[ "protected", "void", "doNotifyListenersOfChangedValues", "(", "Map", "<", "K", ",", "R", ">", "oldValues", ",", "Map", "<", "K", ",", "R", ">", "newValues", ")", "{", "List", "<", "MapValueChangeListener", "<", "K", ",", "R", ">", ">", "listenersCopy", "=", "new", "ArrayList", "<", "MapValueChangeListener", "<", "K", ",", "R", ">", ">", "(", "listeners", ")", ";", "Map", "<", "K", ",", "R", ">", "oldUnmodifiable", "=", "Collections", ".", "unmodifiableMap", "(", "oldValues", ")", ";", "Map", "<", "K", ",", "R", ">", "newUnmodifiable", "=", "Collections", ".", "unmodifiableMap", "(", "newValues", ")", ";", "for", "(", "MapValueChangeListener", "<", "K", ",", "R", ">", "listener", ":", "listenersCopy", ")", "{", "listener", ".", "valuesChanged", "(", "this", ",", "oldUnmodifiable", ",", "newUnmodifiable", ")", ";", "}", "}" ]
Notifies the change listeners that values have been replaced. <p> Note that the specified maps of values will be wrapped in unmodifiable maps before being passed to the listeners. @param oldValues Previous values. @param newValues New values.
[ "Notifies", "the", "change", "listeners", "that", "values", "have", "been", "replaced", ".", "<p", ">", "Note", "that", "the", "specified", "maps", "of", "values", "will", "be", "wrapped", "in", "unmodifiable", "maps", "before", "being", "passed", "to", "the", "listeners", "." ]
train
https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/property/AbstractReadableMapProperty.java#L108-L115
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/StanzaCollector.java
StanzaCollector.nextResultOrThrow
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { """ Returns the next available stanza. The method call will block until a stanza is available or the <tt>timeout</tt> has elapsed. This method does also cancel the collector in every case. <p> Three things can happen when waiting for an response: </p> <ol> <li>A result response arrives.</li> <li>An error response arrives.</li> <li>An timeout occurs.</li> <li>The thread is interrupted</li> </ol> <p> in which this method will </p> <ol> <li>return with the result.</li> <li>throw an {@link XMPPErrorException}.</li> <li>throw an {@link NoResponseException}.</li> <li>throw an {@link InterruptedException}.</li> </ol> <p> Additionally the method will throw a {@link NotConnectedException} if no response was received and the connection got disconnected. </p> @param timeout the amount of time to wait for the next stanza in milliseconds. @param <P> type of the result stanza. @return the next available stanza. @throws NoResponseException if there was no response from the server. @throws XMPPErrorException in case an error response was received. @throws InterruptedException if the calling thread was interrupted. @throws NotConnectedException if there was no response and the connection got disconnected. """ P result; try { result = nextResult(timeout); } finally { cancel(); } if (result == null) { if (connectionException != null) { throw new NotConnectedException(connection, packetFilter, connectionException); } if (!connection.isConnected()) { throw new NotConnectedException(connection, packetFilter); } throw NoResponseException.newWith(timeout, this, cancelled); } XMPPErrorException.ifHasErrorThenThrow(result); return result; }
java
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { P result; try { result = nextResult(timeout); } finally { cancel(); } if (result == null) { if (connectionException != null) { throw new NotConnectedException(connection, packetFilter, connectionException); } if (!connection.isConnected()) { throw new NotConnectedException(connection, packetFilter); } throw NoResponseException.newWith(timeout, this, cancelled); } XMPPErrorException.ifHasErrorThenThrow(result); return result; }
[ "public", "<", "P", "extends", "Stanza", ">", "P", "nextResultOrThrow", "(", "long", "timeout", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "InterruptedException", ",", "NotConnectedException", "{", "P", "result", ";", "try", "{", "result", "=", "nextResult", "(", "timeout", ")", ";", "}", "finally", "{", "cancel", "(", ")", ";", "}", "if", "(", "result", "==", "null", ")", "{", "if", "(", "connectionException", "!=", "null", ")", "{", "throw", "new", "NotConnectedException", "(", "connection", ",", "packetFilter", ",", "connectionException", ")", ";", "}", "if", "(", "!", "connection", ".", "isConnected", "(", ")", ")", "{", "throw", "new", "NotConnectedException", "(", "connection", ",", "packetFilter", ")", ";", "}", "throw", "NoResponseException", ".", "newWith", "(", "timeout", ",", "this", ",", "cancelled", ")", ";", "}", "XMPPErrorException", ".", "ifHasErrorThenThrow", "(", "result", ")", ";", "return", "result", ";", "}" ]
Returns the next available stanza. The method call will block until a stanza is available or the <tt>timeout</tt> has elapsed. This method does also cancel the collector in every case. <p> Three things can happen when waiting for an response: </p> <ol> <li>A result response arrives.</li> <li>An error response arrives.</li> <li>An timeout occurs.</li> <li>The thread is interrupted</li> </ol> <p> in which this method will </p> <ol> <li>return with the result.</li> <li>throw an {@link XMPPErrorException}.</li> <li>throw an {@link NoResponseException}.</li> <li>throw an {@link InterruptedException}.</li> </ol> <p> Additionally the method will throw a {@link NotConnectedException} if no response was received and the connection got disconnected. </p> @param timeout the amount of time to wait for the next stanza in milliseconds. @param <P> type of the result stanza. @return the next available stanza. @throws NoResponseException if there was no response from the server. @throws XMPPErrorException in case an error response was received. @throws InterruptedException if the calling thread was interrupted. @throws NotConnectedException if there was no response and the connection got disconnected.
[ "Returns", "the", "next", "available", "stanza", ".", "The", "method", "call", "will", "block", "until", "a", "stanza", "is", "available", "or", "the", "<tt", ">", "timeout<", "/", "tt", ">", "has", "elapsed", ".", "This", "method", "does", "also", "cancel", "the", "collector", "in", "every", "case", ".", "<p", ">", "Three", "things", "can", "happen", "when", "waiting", "for", "an", "response", ":", "<", "/", "p", ">", "<ol", ">", "<li", ">", "A", "result", "response", "arrives", ".", "<", "/", "li", ">", "<li", ">", "An", "error", "response", "arrives", ".", "<", "/", "li", ">", "<li", ">", "An", "timeout", "occurs", ".", "<", "/", "li", ">", "<li", ">", "The", "thread", "is", "interrupted<", "/", "li", ">", "<", "/", "ol", ">", "<p", ">", "in", "which", "this", "method", "will", "<", "/", "p", ">", "<ol", ">", "<li", ">", "return", "with", "the", "result", ".", "<", "/", "li", ">", "<li", ">", "throw", "an", "{", "@link", "XMPPErrorException", "}", ".", "<", "/", "li", ">", "<li", ">", "throw", "an", "{", "@link", "NoResponseException", "}", ".", "<", "/", "li", ">", "<li", ">", "throw", "an", "{", "@link", "InterruptedException", "}", ".", "<", "/", "li", ">", "<", "/", "ol", ">", "<p", ">", "Additionally", "the", "method", "will", "throw", "a", "{", "@link", "NotConnectedException", "}", "if", "no", "response", "was", "received", "and", "the", "connection", "got", "disconnected", ".", "<", "/", "p", ">" ]
train
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/StanzaCollector.java#L278-L299
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/RBFKernel.java
RBFKernel.setSigma
public void setSigma(double sigma) { """ Sets the sigma parameter, which must be a positive value @param sigma the sigma value """ if(sigma <= 0) throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma); this.sigma = sigma; this.sigmaSqrd2Inv = 0.5/(sigma*sigma); }
java
public void setSigma(double sigma) { if(sigma <= 0) throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma); this.sigma = sigma; this.sigmaSqrd2Inv = 0.5/(sigma*sigma); }
[ "public", "void", "setSigma", "(", "double", "sigma", ")", "{", "if", "(", "sigma", "<=", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Sigma must be a positive constant, not \"", "+", "sigma", ")", ";", "this", ".", "sigma", "=", "sigma", ";", "this", ".", "sigmaSqrd2Inv", "=", "0.5", "/", "(", "sigma", "*", "sigma", ")", ";", "}" ]
Sets the sigma parameter, which must be a positive value @param sigma the sigma value
[ "Sets", "the", "sigma", "parameter", "which", "must", "be", "a", "positive", "value" ]
train
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/RBFKernel.java#L79-L85
UrielCh/ovh-java-sdk
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
ApiOvhOrder.cart_cartId_item_itemId_GET
public OvhItem cart_cartId_item_itemId_GET(String cartId, Long itemId) throws IOException { """ Retrieve information about a specific item of a cart REST: GET /order/cart/{cartId}/item/{itemId} @param cartId [required] Cart identifier @param itemId [required] Product item identifier """ String qPath = "/order/cart/{cartId}/item/{itemId}"; StringBuilder sb = path(qPath, cartId, itemId); String resp = execN(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhItem.class); }
java
public OvhItem cart_cartId_item_itemId_GET(String cartId, Long itemId) throws IOException { String qPath = "/order/cart/{cartId}/item/{itemId}"; StringBuilder sb = path(qPath, cartId, itemId); String resp = execN(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhItem.class); }
[ "public", "OvhItem", "cart_cartId_item_itemId_GET", "(", "String", "cartId", ",", "Long", "itemId", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/order/cart/{cartId}/item/{itemId}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "cartId", ",", "itemId", ")", ";", "String", "resp", "=", "execN", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhItem", ".", "class", ")", ";", "}" ]
Retrieve information about a specific item of a cart REST: GET /order/cart/{cartId}/item/{itemId} @param cartId [required] Cart identifier @param itemId [required] Product item identifier
[ "Retrieve", "information", "about", "a", "specific", "item", "of", "a", "cart" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L8005-L8010
UrielCh/ovh-java-sdk
ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java
ApiOvhHostingweb.serviceName_cron_id_PUT
public void serviceName_cron_id_PUT(String serviceName, Long id, OvhCron body) throws IOException { """ Alter this object properties REST: PUT /hosting/web/{serviceName}/cron/{id} @param body [required] New object properties @param serviceName [required] The internal name of your hosting @param id [required] Cron's id """ String qPath = "/hosting/web/{serviceName}/cron/{id}"; StringBuilder sb = path(qPath, serviceName, id); exec(qPath, "PUT", sb.toString(), body); }
java
public void serviceName_cron_id_PUT(String serviceName, Long id, OvhCron body) throws IOException { String qPath = "/hosting/web/{serviceName}/cron/{id}"; StringBuilder sb = path(qPath, serviceName, id); exec(qPath, "PUT", sb.toString(), body); }
[ "public", "void", "serviceName_cron_id_PUT", "(", "String", "serviceName", ",", "Long", "id", ",", "OvhCron", "body", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/hosting/web/{serviceName}/cron/{id}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "id", ")", ";", "exec", "(", "qPath", ",", "\"PUT\"", ",", "sb", ".", "toString", "(", ")", ",", "body", ")", ";", "}" ]
Alter this object properties REST: PUT /hosting/web/{serviceName}/cron/{id} @param body [required] New object properties @param serviceName [required] The internal name of your hosting @param id [required] Cron's id
[ "Alter", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L2095-L2099
LMAX-Exchange/disruptor
src/main/java/com/lmax/disruptor/dsl/Disruptor.java
Disruptor.handleEventsWithWorkerPool
@SafeVarargs @SuppressWarnings("varargs") public final EventHandlerGroup<T> handleEventsWithWorkerPool(final WorkHandler<T>... workHandlers) { """ Set up a {@link WorkerPool} to distribute an event to one of a pool of work handler threads. Each event will only be processed by one of the work handlers. The Disruptor will automatically start this processors when {@link #start()} is called. @param workHandlers the work handlers that will process events. @return a {@link EventHandlerGroup} that can be used to chain dependencies. """ return createWorkerPool(new Sequence[0], workHandlers); }
java
@SafeVarargs @SuppressWarnings("varargs") public final EventHandlerGroup<T> handleEventsWithWorkerPool(final WorkHandler<T>... workHandlers) { return createWorkerPool(new Sequence[0], workHandlers); }
[ "@", "SafeVarargs", "@", "SuppressWarnings", "(", "\"varargs\"", ")", "public", "final", "EventHandlerGroup", "<", "T", ">", "handleEventsWithWorkerPool", "(", "final", "WorkHandler", "<", "T", ">", "...", "workHandlers", ")", "{", "return", "createWorkerPool", "(", "new", "Sequence", "[", "0", "]", ",", "workHandlers", ")", ";", "}" ]
Set up a {@link WorkerPool} to distribute an event to one of a pool of work handler threads. Each event will only be processed by one of the work handlers. The Disruptor will automatically start this processors when {@link #start()} is called. @param workHandlers the work handlers that will process events. @return a {@link EventHandlerGroup} that can be used to chain dependencies.
[ "Set", "up", "a", "{", "@link", "WorkerPool", "}", "to", "distribute", "an", "event", "to", "one", "of", "a", "pool", "of", "work", "handler", "threads", ".", "Each", "event", "will", "only", "be", "processed", "by", "one", "of", "the", "work", "handlers", ".", "The", "Disruptor", "will", "automatically", "start", "this", "processors", "when", "{", "@link", "#start", "()", "}", "is", "called", "." ]
train
https://github.com/LMAX-Exchange/disruptor/blob/4266d00c5250190313446fdd7c8aa7a4edb5c818/src/main/java/com/lmax/disruptor/dsl/Disruptor.java#L233-L238
rundeck/rundeck
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java
JettyCombinedLdapLoginModule.getUserRoles
@Override protected List getUserRoles(final DirContext dirContext, final String username) throws LoginException, NamingException { """ Override to perform behavior of "ignoreRoles" option @param dirContext context @param username username @return empty or supplemental roles list only if "ignoreRoles" is true, otherwise performs normal LDAP lookup @throws LoginException @throws NamingException """ if (_ignoreRoles) { ArrayList<String> strings = new ArrayList<>(); addSupplementalRoles(strings); return strings; } else { return super.getUserRoles(dirContext, username); } }
java
@Override protected List getUserRoles(final DirContext dirContext, final String username) throws LoginException, NamingException { if (_ignoreRoles) { ArrayList<String> strings = new ArrayList<>(); addSupplementalRoles(strings); return strings; } else { return super.getUserRoles(dirContext, username); } }
[ "@", "Override", "protected", "List", "getUserRoles", "(", "final", "DirContext", "dirContext", ",", "final", "String", "username", ")", "throws", "LoginException", ",", "NamingException", "{", "if", "(", "_ignoreRoles", ")", "{", "ArrayList", "<", "String", ">", "strings", "=", "new", "ArrayList", "<>", "(", ")", ";", "addSupplementalRoles", "(", "strings", ")", ";", "return", "strings", ";", "}", "else", "{", "return", "super", ".", "getUserRoles", "(", "dirContext", ",", "username", ")", ";", "}", "}" ]
Override to perform behavior of "ignoreRoles" option @param dirContext context @param username username @return empty or supplemental roles list only if "ignoreRoles" is true, otherwise performs normal LDAP lookup @throws LoginException @throws NamingException
[ "Override", "to", "perform", "behavior", "of", "ignoreRoles", "option" ]
train
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java#L89-L100
strator-dev/greenpepper
samples-application/src/main/java/com/greenpepper/samples/application/system/AccountManager.java
AccountManager.isUserAssociatedToGroup
public boolean isUserAssociatedToGroup(String user, String group) { """ <p>isUserAssociatedToGroup.</p> @param user a {@link java.lang.String} object. @param group a {@link java.lang.String} object. @return a boolean. """ if (!isUserExist(user)) { throw new SystemException(String.format("User '%s' does not exist.", user)); } if (!isGroupExist(group)) { throw new SystemException(String.format("Group '%s' does not exist.", group)); } List<String> userGroups = allAssociations.get(user); return userGroups != null && userGroups.contains(group); }
java
public boolean isUserAssociatedToGroup(String user, String group) { if (!isUserExist(user)) { throw new SystemException(String.format("User '%s' does not exist.", user)); } if (!isGroupExist(group)) { throw new SystemException(String.format("Group '%s' does not exist.", group)); } List<String> userGroups = allAssociations.get(user); return userGroups != null && userGroups.contains(group); }
[ "public", "boolean", "isUserAssociatedToGroup", "(", "String", "user", ",", "String", "group", ")", "{", "if", "(", "!", "isUserExist", "(", "user", ")", ")", "{", "throw", "new", "SystemException", "(", "String", ".", "format", "(", "\"User '%s' does not exist.\"", ",", "user", ")", ")", ";", "}", "if", "(", "!", "isGroupExist", "(", "group", ")", ")", "{", "throw", "new", "SystemException", "(", "String", ".", "format", "(", "\"Group '%s' does not exist.\"", ",", "group", ")", ")", ";", "}", "List", "<", "String", ">", "userGroups", "=", "allAssociations", ".", "get", "(", "user", ")", ";", "return", "userGroups", "!=", "null", "&&", "userGroups", ".", "contains", "(", "group", ")", ";", "}" ]
<p>isUserAssociatedToGroup.</p> @param user a {@link java.lang.String} object. @param group a {@link java.lang.String} object. @return a boolean.
[ "<p", ">", "isUserAssociatedToGroup", ".", "<", "/", "p", ">" ]
train
https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/samples-application/src/main/java/com/greenpepper/samples/application/system/AccountManager.java#L211-L226
Azure/azure-sdk-for-java
authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/DenyAssignmentsInner.java
DenyAssignmentsInner.getAsync
public Observable<DenyAssignmentInner> getAsync(String scope, String denyAssignmentId) { """ Get the specified deny assignment. @param scope The scope of the deny assignment. @param denyAssignmentId The ID of the deny assignment to get. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DenyAssignmentInner object """ return getWithServiceResponseAsync(scope, denyAssignmentId).map(new Func1<ServiceResponse<DenyAssignmentInner>, DenyAssignmentInner>() { @Override public DenyAssignmentInner call(ServiceResponse<DenyAssignmentInner> response) { return response.body(); } }); }
java
public Observable<DenyAssignmentInner> getAsync(String scope, String denyAssignmentId) { return getWithServiceResponseAsync(scope, denyAssignmentId).map(new Func1<ServiceResponse<DenyAssignmentInner>, DenyAssignmentInner>() { @Override public DenyAssignmentInner call(ServiceResponse<DenyAssignmentInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "DenyAssignmentInner", ">", "getAsync", "(", "String", "scope", ",", "String", "denyAssignmentId", ")", "{", "return", "getWithServiceResponseAsync", "(", "scope", ",", "denyAssignmentId", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "DenyAssignmentInner", ">", ",", "DenyAssignmentInner", ">", "(", ")", "{", "@", "Override", "public", "DenyAssignmentInner", "call", "(", "ServiceResponse", "<", "DenyAssignmentInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Get the specified deny assignment. @param scope The scope of the deny assignment. @param denyAssignmentId The ID of the deny assignment to get. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DenyAssignmentInner object
[ "Get", "the", "specified", "deny", "assignment", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/DenyAssignmentsInner.java#L861-L868
citrusframework/citrus
modules/citrus-core/src/main/java/com/consol/citrus/message/MessageSelectorBuilder.java
MessageSelectorBuilder.fromKeyValueMap
public static MessageSelectorBuilder fromKeyValueMap(Map<String, Object> valueMap) { """ Static builder method using a key value map. @param valueMap @return """ StringBuffer buf = new StringBuffer(); Iterator<Entry<String, Object>> iter = valueMap.entrySet().iterator(); if (iter.hasNext()) { Entry<String, Object> entry = iter.next(); String key = entry.getKey(); String value = entry.getValue().toString(); buf.append(key + " = '" + value + "'"); } while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); String key = entry.getKey(); String value = entry.getValue().toString(); buf.append(" AND " + key + " = '" + value + "'"); } return new MessageSelectorBuilder(buf.toString()); }
java
public static MessageSelectorBuilder fromKeyValueMap(Map<String, Object> valueMap) { StringBuffer buf = new StringBuffer(); Iterator<Entry<String, Object>> iter = valueMap.entrySet().iterator(); if (iter.hasNext()) { Entry<String, Object> entry = iter.next(); String key = entry.getKey(); String value = entry.getValue().toString(); buf.append(key + " = '" + value + "'"); } while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); String key = entry.getKey(); String value = entry.getValue().toString(); buf.append(" AND " + key + " = '" + value + "'"); } return new MessageSelectorBuilder(buf.toString()); }
[ "public", "static", "MessageSelectorBuilder", "fromKeyValueMap", "(", "Map", "<", "String", ",", "Object", ">", "valueMap", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "Iterator", "<", "Entry", "<", "String", ",", "Object", ">", ">", "iter", "=", "valueMap", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "if", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Entry", "<", "String", ",", "Object", ">", "entry", "=", "iter", ".", "next", "(", ")", ";", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "String", "value", "=", "entry", ".", "getValue", "(", ")", ".", "toString", "(", ")", ";", "buf", ".", "append", "(", "key", "+", "\" = '\"", "+", "value", "+", "\"'\"", ")", ";", "}", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Entry", "<", "String", ",", "Object", ">", "entry", "=", "iter", ".", "next", "(", ")", ";", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "String", "value", "=", "entry", ".", "getValue", "(", ")", ".", "toString", "(", ")", ";", "buf", ".", "append", "(", "\" AND \"", "+", "key", "+", "\" = '\"", "+", "value", "+", "\"'\"", ")", ";", "}", "return", "new", "MessageSelectorBuilder", "(", "buf", ".", "toString", "(", ")", ")", ";", "}" ]
Static builder method using a key value map. @param valueMap @return
[ "Static", "builder", "method", "using", "a", "key", "value", "map", "." ]
train
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/message/MessageSelectorBuilder.java#L77-L99
ZuInnoTe/hadoopcryptoledger
inputformat/src/main/java/org/zuinnote/hadoop/ethereum/format/common/EthereumUtil.java
EthereumUtil.convertVarNumberToBigInteger
public static BigInteger convertVarNumberToBigInteger(byte[] rawData) { """ * Converts a variable size number (e.g. byte,short,int,long) in a RLPElement to long @param rawData byte array containing variable number @return number as long or null if not a correct number """ BigInteger result=BigInteger.ZERO; if (rawData!=null) { if (rawData.length>0) { result = new BigInteger(1,rawData); // we know it is always positive } } return result; }
java
public static BigInteger convertVarNumberToBigInteger(byte[] rawData) { BigInteger result=BigInteger.ZERO; if (rawData!=null) { if (rawData.length>0) { result = new BigInteger(1,rawData); // we know it is always positive } } return result; }
[ "public", "static", "BigInteger", "convertVarNumberToBigInteger", "(", "byte", "[", "]", "rawData", ")", "{", "BigInteger", "result", "=", "BigInteger", ".", "ZERO", ";", "if", "(", "rawData", "!=", "null", ")", "{", "if", "(", "rawData", ".", "length", ">", "0", ")", "{", "result", "=", "new", "BigInteger", "(", "1", ",", "rawData", ")", ";", "// we know it is always positive", "}", "}", "return", "result", ";", "}" ]
* Converts a variable size number (e.g. byte,short,int,long) in a RLPElement to long @param rawData byte array containing variable number @return number as long or null if not a correct number
[ "*", "Converts", "a", "variable", "size", "number", "(", "e", ".", "g", ".", "byte", "short", "int", "long", ")", "in", "a", "RLPElement", "to", "long" ]
train
https://github.com/ZuInnoTe/hadoopcryptoledger/blob/5c9bfb61dd1a82374cd0de8413a7c66391ee4414/inputformat/src/main/java/org/zuinnote/hadoop/ethereum/format/common/EthereumUtil.java#L540-L548
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/util/HierarchicalTable.java
HierarchicalTable.setHandle
public FieldList setHandle(Object bookmark, int iHandleType) throws DBException { """ Reposition to this record Using this bookmark. @exception DBException File exception. """ Record recMain = this.getRecord(); this.setCurrentTable(this.getNextTable()); FieldList record = super.setHandle(bookmark, iHandleType); if (record == null) { // Not found in the main table, try the other tables Iterator<BaseTable> iterator = this.getTables(); while (iterator.hasNext()) { BaseTable table = iterator.next(); if ((table != null) && (table != this.getNextTable())) { Record recAlt = table.getRecord(); record = recAlt.setHandle(bookmark, iHandleType); if (record != null) { this.syncRecordToBase(recMain, recAlt, false); this.setCurrentTable(table); break; } } } } return record; }
java
public FieldList setHandle(Object bookmark, int iHandleType) throws DBException { Record recMain = this.getRecord(); this.setCurrentTable(this.getNextTable()); FieldList record = super.setHandle(bookmark, iHandleType); if (record == null) { // Not found in the main table, try the other tables Iterator<BaseTable> iterator = this.getTables(); while (iterator.hasNext()) { BaseTable table = iterator.next(); if ((table != null) && (table != this.getNextTable())) { Record recAlt = table.getRecord(); record = recAlt.setHandle(bookmark, iHandleType); if (record != null) { this.syncRecordToBase(recMain, recAlt, false); this.setCurrentTable(table); break; } } } } return record; }
[ "public", "FieldList", "setHandle", "(", "Object", "bookmark", ",", "int", "iHandleType", ")", "throws", "DBException", "{", "Record", "recMain", "=", "this", ".", "getRecord", "(", ")", ";", "this", ".", "setCurrentTable", "(", "this", ".", "getNextTable", "(", ")", ")", ";", "FieldList", "record", "=", "super", ".", "setHandle", "(", "bookmark", ",", "iHandleType", ")", ";", "if", "(", "record", "==", "null", ")", "{", "// Not found in the main table, try the other tables", "Iterator", "<", "BaseTable", ">", "iterator", "=", "this", ".", "getTables", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "BaseTable", "table", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "(", "table", "!=", "null", ")", "&&", "(", "table", "!=", "this", ".", "getNextTable", "(", ")", ")", ")", "{", "Record", "recAlt", "=", "table", ".", "getRecord", "(", ")", ";", "record", "=", "recAlt", ".", "setHandle", "(", "bookmark", ",", "iHandleType", ")", ";", "if", "(", "record", "!=", "null", ")", "{", "this", ".", "syncRecordToBase", "(", "recMain", ",", "recAlt", ",", "false", ")", ";", "this", ".", "setCurrentTable", "(", "table", ")", ";", "break", ";", "}", "}", "}", "}", "return", "record", ";", "}" ]
Reposition to this record Using this bookmark. @exception DBException File exception.
[ "Reposition", "to", "this", "record", "Using", "this", "bookmark", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/util/HierarchicalTable.java#L307-L333
molgenis/molgenis
molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/PackageCopier.java
PackageCopier.assignUniqueLabel
private void assignUniqueLabel(Package pack, Package targetPackage) { """ Checks if there's a Package in the target location with the same label. If so, keeps adding a postfix until the label is unique. """ Set<String> existingLabels; if (targetPackage != null) { existingLabels = stream(targetPackage.getChildren()).map(Package::getLabel).collect(toSet()); } else { existingLabels = dataService .query(PACKAGE, Package.class) .eq(PackageMetadata.PARENT, null) .findAll() .map(Package::getLabel) .collect(toSet()); } pack.setLabel(generateUniqueLabel(pack.getLabel(), existingLabels)); }
java
private void assignUniqueLabel(Package pack, Package targetPackage) { Set<String> existingLabels; if (targetPackage != null) { existingLabels = stream(targetPackage.getChildren()).map(Package::getLabel).collect(toSet()); } else { existingLabels = dataService .query(PACKAGE, Package.class) .eq(PackageMetadata.PARENT, null) .findAll() .map(Package::getLabel) .collect(toSet()); } pack.setLabel(generateUniqueLabel(pack.getLabel(), existingLabels)); }
[ "private", "void", "assignUniqueLabel", "(", "Package", "pack", ",", "Package", "targetPackage", ")", "{", "Set", "<", "String", ">", "existingLabels", ";", "if", "(", "targetPackage", "!=", "null", ")", "{", "existingLabels", "=", "stream", "(", "targetPackage", ".", "getChildren", "(", ")", ")", ".", "map", "(", "Package", "::", "getLabel", ")", ".", "collect", "(", "toSet", "(", ")", ")", ";", "}", "else", "{", "existingLabels", "=", "dataService", ".", "query", "(", "PACKAGE", ",", "Package", ".", "class", ")", ".", "eq", "(", "PackageMetadata", ".", "PARENT", ",", "null", ")", ".", "findAll", "(", ")", ".", "map", "(", "Package", "::", "getLabel", ")", ".", "collect", "(", "toSet", "(", ")", ")", ";", "}", "pack", ".", "setLabel", "(", "generateUniqueLabel", "(", "pack", ".", "getLabel", "(", ")", ",", "existingLabels", ")", ")", ";", "}" ]
Checks if there's a Package in the target location with the same label. If so, keeps adding a postfix until the label is unique.
[ "Checks", "if", "there", "s", "a", "Package", "in", "the", "target", "location", "with", "the", "same", "label", ".", "If", "so", "keeps", "adding", "a", "postfix", "until", "the", "label", "is", "unique", "." ]
train
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/PackageCopier.java#L62-L76
orbisgis/h2gis
h2gis-network/src/main/java/org/h2gis/network/functions/ST_GraphAnalysis.java
ST_GraphAnalysis.doGraphAnalysis
public static boolean doGraphAnalysis(Connection connection, String inputTable, String orientation) throws SQLException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { """ Calculate centrality indices on the nodes and edges of a graph constructed from the input table. @param connection Connection @param inputTable Input table @param orientation Global orientation @return True if the calculation was successful @throws SQLException @throws NoSuchMethodException @throws InstantiationException @throws IllegalAccessException @throws InvocationTargetException """ return doGraphAnalysis(connection, inputTable, orientation, null); }
java
public static boolean doGraphAnalysis(Connection connection, String inputTable, String orientation) throws SQLException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { return doGraphAnalysis(connection, inputTable, orientation, null); }
[ "public", "static", "boolean", "doGraphAnalysis", "(", "Connection", "connection", ",", "String", "inputTable", ",", "String", "orientation", ")", "throws", "SQLException", ",", "NoSuchMethodException", ",", "InstantiationException", ",", "IllegalAccessException", ",", "InvocationTargetException", "{", "return", "doGraphAnalysis", "(", "connection", ",", "inputTable", ",", "orientation", ",", "null", ")", ";", "}" ]
Calculate centrality indices on the nodes and edges of a graph constructed from the input table. @param connection Connection @param inputTable Input table @param orientation Global orientation @return True if the calculation was successful @throws SQLException @throws NoSuchMethodException @throws InstantiationException @throws IllegalAccessException @throws InvocationTargetException
[ "Calculate", "centrality", "indices", "on", "the", "nodes", "and", "edges", "of", "a", "graph", "constructed", "from", "the", "input", "table", "." ]
train
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-network/src/main/java/org/h2gis/network/functions/ST_GraphAnalysis.java#L104-L110
pryzach/midao
midao-jdbc-dbcp-1-4/src/main/java/org/midao/jdbc/core/pool/MjdbcPoolBinder.java
MjdbcPoolBinder.createDataSource
public static DataSource createDataSource(String driverClassName, String url, String userName, String password) throws SQLException { """ Returns new Pooled {@link DataSource} implementation <p/> In case this function won't work - use {@link #createDataSource(java.util.Properties)} @param driverClassName Driver Class name @param url Database connection url @param userName Database user name @param password Database user password @return new Pooled {@link DataSource} implementation @throws SQLException """ return createDataSource(driverClassName, url, userName, password, 10, 100); }
java
public static DataSource createDataSource(String driverClassName, String url, String userName, String password) throws SQLException { return createDataSource(driverClassName, url, userName, password, 10, 100); }
[ "public", "static", "DataSource", "createDataSource", "(", "String", "driverClassName", ",", "String", "url", ",", "String", "userName", ",", "String", "password", ")", "throws", "SQLException", "{", "return", "createDataSource", "(", "driverClassName", ",", "url", ",", "userName", ",", "password", ",", "10", ",", "100", ")", ";", "}" ]
Returns new Pooled {@link DataSource} implementation <p/> In case this function won't work - use {@link #createDataSource(java.util.Properties)} @param driverClassName Driver Class name @param url Database connection url @param userName Database user name @param password Database user password @return new Pooled {@link DataSource} implementation @throws SQLException
[ "Returns", "new", "Pooled", "{", "@link", "DataSource", "}", "implementation", "<p", "/", ">", "In", "case", "this", "function", "won", "t", "work", "-", "use", "{", "@link", "#createDataSource", "(", "java", ".", "util", ".", "Properties", ")", "}" ]
train
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-dbcp-1-4/src/main/java/org/midao/jdbc/core/pool/MjdbcPoolBinder.java#L103-L105
geomajas/geomajas-project-client-gwt
client/src/main/java/org/geomajas/gwt/client/map/MapModel.java
MapModel.addLayerWithoutFireEvent
private void addLayerWithoutFireEvent(ClientLayerInfo layerInfo) { """ Add a layer to the map, but do not fire an event for update. @param layerInfo the client layer info """ switch (layerInfo.getLayerType()) { case RASTER: if (layerInfo instanceof ClientWmsLayerInfo) { InternalClientWmsLayer internalClientWmsLayer = new InternalClientWmsLayer(this, (ClientWmsLayerInfo) layerInfo); layers.add(internalClientWmsLayer); } else { RasterLayer rasterLayer = new RasterLayer(this, (ClientRasterLayerInfo) layerInfo); layers.add(rasterLayer); } break; default: VectorLayer vectorLayer = new VectorLayer(this, (ClientVectorLayerInfo) layerInfo); layers.add(vectorLayer); vectorLayer.addFeatureSelectionHandler(selectionPropagator); break; } }
java
private void addLayerWithoutFireEvent(ClientLayerInfo layerInfo) { switch (layerInfo.getLayerType()) { case RASTER: if (layerInfo instanceof ClientWmsLayerInfo) { InternalClientWmsLayer internalClientWmsLayer = new InternalClientWmsLayer(this, (ClientWmsLayerInfo) layerInfo); layers.add(internalClientWmsLayer); } else { RasterLayer rasterLayer = new RasterLayer(this, (ClientRasterLayerInfo) layerInfo); layers.add(rasterLayer); } break; default: VectorLayer vectorLayer = new VectorLayer(this, (ClientVectorLayerInfo) layerInfo); layers.add(vectorLayer); vectorLayer.addFeatureSelectionHandler(selectionPropagator); break; } }
[ "private", "void", "addLayerWithoutFireEvent", "(", "ClientLayerInfo", "layerInfo", ")", "{", "switch", "(", "layerInfo", ".", "getLayerType", "(", ")", ")", "{", "case", "RASTER", ":", "if", "(", "layerInfo", "instanceof", "ClientWmsLayerInfo", ")", "{", "InternalClientWmsLayer", "internalClientWmsLayer", "=", "new", "InternalClientWmsLayer", "(", "this", ",", "(", "ClientWmsLayerInfo", ")", "layerInfo", ")", ";", "layers", ".", "add", "(", "internalClientWmsLayer", ")", ";", "}", "else", "{", "RasterLayer", "rasterLayer", "=", "new", "RasterLayer", "(", "this", ",", "(", "ClientRasterLayerInfo", ")", "layerInfo", ")", ";", "layers", ".", "add", "(", "rasterLayer", ")", ";", "}", "break", ";", "default", ":", "VectorLayer", "vectorLayer", "=", "new", "VectorLayer", "(", "this", ",", "(", "ClientVectorLayerInfo", ")", "layerInfo", ")", ";", "layers", ".", "add", "(", "vectorLayer", ")", ";", "vectorLayer", ".", "addFeatureSelectionHandler", "(", "selectionPropagator", ")", ";", "break", ";", "}", "}" ]
Add a layer to the map, but do not fire an event for update. @param layerInfo the client layer info
[ "Add", "a", "layer", "to", "the", "map", "but", "do", "not", "fire", "an", "event", "for", "update", "." ]
train
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/MapModel.java#L1069-L1087
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/Actor.java
Actor.initActor
public final void initActor(UUID uuid, String path, ActorContext context, Mailbox mailbox) { """ <p>INTERNAL API</p> Initialization of actor @param uuid uuid of actor @param path path of actor @param context context of actor @param mailbox mailbox of actor """ this.uuid = uuid; this.path = path; this.context = context; this.mailbox = mailbox; this.askPattern = new ActorAskImpl(self()); this.typedAsk = new TypedAskExtensions(self()); this.callbackExtension = new CallbackExtension(self()); this.extensions.add(askPattern); this.extensions.add(typedAsk); this.extensions.add(callbackExtension); this.extensions.add(new RunnableExtension()); }
java
public final void initActor(UUID uuid, String path, ActorContext context, Mailbox mailbox) { this.uuid = uuid; this.path = path; this.context = context; this.mailbox = mailbox; this.askPattern = new ActorAskImpl(self()); this.typedAsk = new TypedAskExtensions(self()); this.callbackExtension = new CallbackExtension(self()); this.extensions.add(askPattern); this.extensions.add(typedAsk); this.extensions.add(callbackExtension); this.extensions.add(new RunnableExtension()); }
[ "public", "final", "void", "initActor", "(", "UUID", "uuid", ",", "String", "path", ",", "ActorContext", "context", ",", "Mailbox", "mailbox", ")", "{", "this", ".", "uuid", "=", "uuid", ";", "this", ".", "path", "=", "path", ";", "this", ".", "context", "=", "context", ";", "this", ".", "mailbox", "=", "mailbox", ";", "this", ".", "askPattern", "=", "new", "ActorAskImpl", "(", "self", "(", ")", ")", ";", "this", ".", "typedAsk", "=", "new", "TypedAskExtensions", "(", "self", "(", ")", ")", ";", "this", ".", "callbackExtension", "=", "new", "CallbackExtension", "(", "self", "(", ")", ")", ";", "this", ".", "extensions", ".", "add", "(", "askPattern", ")", ";", "this", ".", "extensions", ".", "add", "(", "typedAsk", ")", ";", "this", ".", "extensions", ".", "add", "(", "callbackExtension", ")", ";", "this", ".", "extensions", ".", "add", "(", "new", "RunnableExtension", "(", ")", ")", ";", "}" ]
<p>INTERNAL API</p> Initialization of actor @param uuid uuid of actor @param path path of actor @param context context of actor @param mailbox mailbox of actor
[ "<p", ">", "INTERNAL", "API<", "/", "p", ">", "Initialization", "of", "actor" ]
train
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/Actor.java#L49-L61
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/event/CheckMoveHandler.java
CheckMoveHandler.init
public void init(BaseField field, BaseField fldDest, BaseField fldSource) { """ Constructor. @param field The basefield owner of this listener (usually null and set on setOwner()). @param fldDest The destination field. @param fldSource The source field. """ super.init(field, fldDest, fldSource, false, false, false); }
java
public void init(BaseField field, BaseField fldDest, BaseField fldSource) { super.init(field, fldDest, fldSource, false, false, false); }
[ "public", "void", "init", "(", "BaseField", "field", ",", "BaseField", "fldDest", ",", "BaseField", "fldSource", ")", "{", "super", ".", "init", "(", "field", ",", "fldDest", ",", "fldSource", ",", "false", ",", "false", ",", "false", ")", ";", "}" ]
Constructor. @param field The basefield owner of this listener (usually null and set on setOwner()). @param fldDest The destination field. @param fldSource The source field.
[ "Constructor", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/CheckMoveHandler.java#L50-L53
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/SerializationUtil.java
SerializationUtil.writeNullablePartitionIdSet
public static void writeNullablePartitionIdSet(PartitionIdSet partitionIds, ObjectDataOutput out) throws IOException { """ Writes a nullable {@link PartitionIdSet} to the given data output. @param partitionIds @param out @throws IOException """ if (partitionIds == null) { out.writeInt(-1); return; } out.writeInt(partitionIds.getPartitionCount()); out.writeInt(partitionIds.size()); PrimitiveIterator.OfInt intIterator = partitionIds.intIterator(); while (intIterator.hasNext()) { out.writeInt(intIterator.nextInt()); } }
java
public static void writeNullablePartitionIdSet(PartitionIdSet partitionIds, ObjectDataOutput out) throws IOException { if (partitionIds == null) { out.writeInt(-1); return; } out.writeInt(partitionIds.getPartitionCount()); out.writeInt(partitionIds.size()); PrimitiveIterator.OfInt intIterator = partitionIds.intIterator(); while (intIterator.hasNext()) { out.writeInt(intIterator.nextInt()); } }
[ "public", "static", "void", "writeNullablePartitionIdSet", "(", "PartitionIdSet", "partitionIds", ",", "ObjectDataOutput", "out", ")", "throws", "IOException", "{", "if", "(", "partitionIds", "==", "null", ")", "{", "out", ".", "writeInt", "(", "-", "1", ")", ";", "return", ";", "}", "out", ".", "writeInt", "(", "partitionIds", ".", "getPartitionCount", "(", ")", ")", ";", "out", ".", "writeInt", "(", "partitionIds", ".", "size", "(", ")", ")", ";", "PrimitiveIterator", ".", "OfInt", "intIterator", "=", "partitionIds", ".", "intIterator", "(", ")", ";", "while", "(", "intIterator", ".", "hasNext", "(", ")", ")", "{", "out", ".", "writeInt", "(", "intIterator", ".", "nextInt", "(", ")", ")", ";", "}", "}" ]
Writes a nullable {@link PartitionIdSet} to the given data output. @param partitionIds @param out @throws IOException
[ "Writes", "a", "nullable", "{" ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/SerializationUtil.java#L275-L286
nguyenq/tess4j
src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java
ImageIOHelper.deskewImage
public static File deskewImage(File imageFile, double minimumDeskewThreshold) throws IOException { """ Deskews image. @param imageFile input image @param minimumDeskewThreshold minimum deskew threshold (typically, 0.05d) @return temporary multi-page TIFF image file @throws IOException """ List<BufferedImage> imageList = getImageList(imageFile); for (int i = 0; i < imageList.size(); i++) { BufferedImage bi = imageList.get(i); ImageDeskew deskew = new ImageDeskew(bi); double imageSkewAngle = deskew.getSkewAngle(); if ((imageSkewAngle > minimumDeskewThreshold || imageSkewAngle < -(minimumDeskewThreshold))) { bi = ImageUtil.rotate(bi, -imageSkewAngle, bi.getWidth() / 2, bi.getHeight() / 2); imageList.set(i, bi); // replace original with deskewed image } } File tempImageFile = File.createTempFile(FilenameUtils.getBaseName(imageFile.getName()), ".tif"); mergeTiff(imageList.toArray(new BufferedImage[0]), tempImageFile); return tempImageFile; }
java
public static File deskewImage(File imageFile, double minimumDeskewThreshold) throws IOException { List<BufferedImage> imageList = getImageList(imageFile); for (int i = 0; i < imageList.size(); i++) { BufferedImage bi = imageList.get(i); ImageDeskew deskew = new ImageDeskew(bi); double imageSkewAngle = deskew.getSkewAngle(); if ((imageSkewAngle > minimumDeskewThreshold || imageSkewAngle < -(minimumDeskewThreshold))) { bi = ImageUtil.rotate(bi, -imageSkewAngle, bi.getWidth() / 2, bi.getHeight() / 2); imageList.set(i, bi); // replace original with deskewed image } } File tempImageFile = File.createTempFile(FilenameUtils.getBaseName(imageFile.getName()), ".tif"); mergeTiff(imageList.toArray(new BufferedImage[0]), tempImageFile); return tempImageFile; }
[ "public", "static", "File", "deskewImage", "(", "File", "imageFile", ",", "double", "minimumDeskewThreshold", ")", "throws", "IOException", "{", "List", "<", "BufferedImage", ">", "imageList", "=", "getImageList", "(", "imageFile", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "imageList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "BufferedImage", "bi", "=", "imageList", ".", "get", "(", "i", ")", ";", "ImageDeskew", "deskew", "=", "new", "ImageDeskew", "(", "bi", ")", ";", "double", "imageSkewAngle", "=", "deskew", ".", "getSkewAngle", "(", ")", ";", "if", "(", "(", "imageSkewAngle", ">", "minimumDeskewThreshold", "||", "imageSkewAngle", "<", "-", "(", "minimumDeskewThreshold", ")", ")", ")", "{", "bi", "=", "ImageUtil", ".", "rotate", "(", "bi", ",", "-", "imageSkewAngle", ",", "bi", ".", "getWidth", "(", ")", "/", "2", ",", "bi", ".", "getHeight", "(", ")", "/", "2", ")", ";", "imageList", ".", "set", "(", "i", ",", "bi", ")", ";", "// replace original with deskewed image", "}", "}", "File", "tempImageFile", "=", "File", ".", "createTempFile", "(", "FilenameUtils", ".", "getBaseName", "(", "imageFile", ".", "getName", "(", ")", ")", ",", "\".tif\"", ")", ";", "mergeTiff", "(", "imageList", ".", "toArray", "(", "new", "BufferedImage", "[", "0", "]", ")", ",", "tempImageFile", ")", ";", "return", "tempImageFile", ";", "}" ]
Deskews image. @param imageFile input image @param minimumDeskewThreshold minimum deskew threshold (typically, 0.05d) @return temporary multi-page TIFF image file @throws IOException
[ "Deskews", "image", "." ]
train
https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java#L604-L621
querydsl/querydsl
querydsl-sql/src/main/java/com/querydsl/sql/Configuration.java
Configuration.registerTableOverride
@Deprecated public SchemaAndTable registerTableOverride(SchemaAndTable from, SchemaAndTable to) { """ Register a schema specific table override @param from schema and table to override @param to override @return previous override @deprecated Use {@link #setDynamicNameMapping(NameMapping)} instead. """ return internalNameMapping.registerTableOverride(from, to); }
java
@Deprecated public SchemaAndTable registerTableOverride(SchemaAndTable from, SchemaAndTable to) { return internalNameMapping.registerTableOverride(from, to); }
[ "@", "Deprecated", "public", "SchemaAndTable", "registerTableOverride", "(", "SchemaAndTable", "from", ",", "SchemaAndTable", "to", ")", "{", "return", "internalNameMapping", ".", "registerTableOverride", "(", "from", ",", "to", ")", ";", "}" ]
Register a schema specific table override @param from schema and table to override @param to override @return previous override @deprecated Use {@link #setDynamicNameMapping(NameMapping)} instead.
[ "Register", "a", "schema", "specific", "table", "override" ]
train
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/Configuration.java#L382-L385
wildfly/wildfly-core
controller/src/main/java/org/jboss/as/controller/capability/RuntimeCapability.java
RuntimeCapability.getCapabilityServiceName
public ServiceName getCapabilityServiceName(PathAddress address, Class<?> serviceValueType) { """ Gets the name of service provided by this capability. @param address the path from which dynamic portion of the capability name is calculated from. Cannot be {@code null} @param serviceValueType the expected type of the service's value. Only used to provide validate that the service value type provided by the capability matches the caller's expectation. May be {@code null} in which case no validation is performed @return the name of the service. Will not be {@code null} @throws IllegalArgumentException if the capability does not provide a service or if its value type is not assignable to {@code serviceValueType} @throws IllegalStateException if {@link #isDynamicallyNamed()} does not return {@code true} """ return fromBaseCapability(address).getCapabilityServiceName(serviceValueType); }
java
public ServiceName getCapabilityServiceName(PathAddress address, Class<?> serviceValueType) { return fromBaseCapability(address).getCapabilityServiceName(serviceValueType); }
[ "public", "ServiceName", "getCapabilityServiceName", "(", "PathAddress", "address", ",", "Class", "<", "?", ">", "serviceValueType", ")", "{", "return", "fromBaseCapability", "(", "address", ")", ".", "getCapabilityServiceName", "(", "serviceValueType", ")", ";", "}" ]
Gets the name of service provided by this capability. @param address the path from which dynamic portion of the capability name is calculated from. Cannot be {@code null} @param serviceValueType the expected type of the service's value. Only used to provide validate that the service value type provided by the capability matches the caller's expectation. May be {@code null} in which case no validation is performed @return the name of the service. Will not be {@code null} @throws IllegalArgumentException if the capability does not provide a service or if its value type is not assignable to {@code serviceValueType} @throws IllegalStateException if {@link #isDynamicallyNamed()} does not return {@code true}
[ "Gets", "the", "name", "of", "service", "provided", "by", "this", "capability", "." ]
train
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/capability/RuntimeCapability.java#L215-L217
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getDeclaringParent
public static Node getDeclaringParent(Node targetNode) { """ Returns the node that is effectively declaring the given target. <p>Examples: <pre><code> const a = 1; // getDeclaringParent(a) returns CONST let {[expression]: [x = 3]} = obj; // getDeclaringParent(x) returns LET function foo({a, b}) {}; // getDeclaringParent(a) returns PARAM_LIST function foo(a = 1) {}; // getDeclaringParent(a) returns PARAM_LIST function foo({a, b} = obj) {}; // getDeclaringParent(a) returns PARAM_LIST function foo(...a) {}; // getDeclaringParent(a) returns PARAM_LIST function foo() {}; // gotRootTarget(foo) returns FUNCTION class foo {}; // gotRootTarget(foo) returns CLASS import foo from './foo'; // getDeclaringParent(foo) returns IMPORT import {foo} from './foo'; // getDeclaringParent(foo) returns IMPORT import {foo as bar} from './foo'; // getDeclaringParent(bar) returns IMPORT } catch (err) { // getDeclaringParent(err) returns CATCH </code></pre> @param targetNode a NAME, OBJECT_PATTERN, or ARRAY_PATTERN @return node of type LET, CONST, VAR, FUNCTION, CLASS, PARAM_LIST, CATCH, or IMPORT @throws IllegalStateException if targetNode is not actually used as a declaration target """ Node rootTarget = getRootTarget(targetNode); Node parent = rootTarget.getParent(); if (parent.isRest() || parent.isDefaultValue()) { // e.g. `function foo(targetNode1 = default, ...targetNode2) {}` parent = parent.getParent(); checkState(parent.isParamList(), parent); } else if (parent.isDestructuringLhs()) { // e.g. `let [a, b] = something;` targetNode is `[a, b]` parent = parent.getParent(); checkState(isNameDeclaration(parent), parent); } else if (parent.isClass() || parent.isFunction()) { // e.g. `function targetNode() {}` // e.g. `class targetNode {}` checkState(targetNode == parent.getFirstChild(), targetNode); } else if (parent.isImportSpec()) { // e.g. `import {foo as targetNode} from './foo'; checkState(targetNode == parent.getSecondChild(), targetNode); // import -> import_specs -> import_spec // we want import parent = parent.getGrandparent(); checkState(parent.isImport(), parent); } else { // e.g. `function foo(targetNode) {};` // e.g. `let targetNode = something;` // e.g. `import targetNode from './foo'; // e.g. `} catch (foo) {` checkState( parent.isParamList() || isNameDeclaration(parent) || parent.isImport() || parent.isCatch(), parent); } return parent; }
java
public static Node getDeclaringParent(Node targetNode) { Node rootTarget = getRootTarget(targetNode); Node parent = rootTarget.getParent(); if (parent.isRest() || parent.isDefaultValue()) { // e.g. `function foo(targetNode1 = default, ...targetNode2) {}` parent = parent.getParent(); checkState(parent.isParamList(), parent); } else if (parent.isDestructuringLhs()) { // e.g. `let [a, b] = something;` targetNode is `[a, b]` parent = parent.getParent(); checkState(isNameDeclaration(parent), parent); } else if (parent.isClass() || parent.isFunction()) { // e.g. `function targetNode() {}` // e.g. `class targetNode {}` checkState(targetNode == parent.getFirstChild(), targetNode); } else if (parent.isImportSpec()) { // e.g. `import {foo as targetNode} from './foo'; checkState(targetNode == parent.getSecondChild(), targetNode); // import -> import_specs -> import_spec // we want import parent = parent.getGrandparent(); checkState(parent.isImport(), parent); } else { // e.g. `function foo(targetNode) {};` // e.g. `let targetNode = something;` // e.g. `import targetNode from './foo'; // e.g. `} catch (foo) {` checkState( parent.isParamList() || isNameDeclaration(parent) || parent.isImport() || parent.isCatch(), parent); } return parent; }
[ "public", "static", "Node", "getDeclaringParent", "(", "Node", "targetNode", ")", "{", "Node", "rootTarget", "=", "getRootTarget", "(", "targetNode", ")", ";", "Node", "parent", "=", "rootTarget", ".", "getParent", "(", ")", ";", "if", "(", "parent", ".", "isRest", "(", ")", "||", "parent", ".", "isDefaultValue", "(", ")", ")", "{", "// e.g. `function foo(targetNode1 = default, ...targetNode2) {}`", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "checkState", "(", "parent", ".", "isParamList", "(", ")", ",", "parent", ")", ";", "}", "else", "if", "(", "parent", ".", "isDestructuringLhs", "(", ")", ")", "{", "// e.g. `let [a, b] = something;` targetNode is `[a, b]`", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "checkState", "(", "isNameDeclaration", "(", "parent", ")", ",", "parent", ")", ";", "}", "else", "if", "(", "parent", ".", "isClass", "(", ")", "||", "parent", ".", "isFunction", "(", ")", ")", "{", "// e.g. `function targetNode() {}`", "// e.g. `class targetNode {}`", "checkState", "(", "targetNode", "==", "parent", ".", "getFirstChild", "(", ")", ",", "targetNode", ")", ";", "}", "else", "if", "(", "parent", ".", "isImportSpec", "(", ")", ")", "{", "// e.g. `import {foo as targetNode} from './foo';", "checkState", "(", "targetNode", "==", "parent", ".", "getSecondChild", "(", ")", ",", "targetNode", ")", ";", "// import -> import_specs -> import_spec", "// we want import", "parent", "=", "parent", ".", "getGrandparent", "(", ")", ";", "checkState", "(", "parent", ".", "isImport", "(", ")", ",", "parent", ")", ";", "}", "else", "{", "// e.g. `function foo(targetNode) {};`", "// e.g. `let targetNode = something;`", "// e.g. `import targetNode from './foo';", "// e.g. `} catch (foo) {`", "checkState", "(", "parent", ".", "isParamList", "(", ")", "||", "isNameDeclaration", "(", "parent", ")", "||", "parent", ".", "isImport", "(", ")", "||", "parent", ".", "isCatch", "(", ")", ",", "parent", ")", ";", "}", "return", "parent", ";", "}" ]
Returns the node that is effectively declaring the given target. <p>Examples: <pre><code> const a = 1; // getDeclaringParent(a) returns CONST let {[expression]: [x = 3]} = obj; // getDeclaringParent(x) returns LET function foo({a, b}) {}; // getDeclaringParent(a) returns PARAM_LIST function foo(a = 1) {}; // getDeclaringParent(a) returns PARAM_LIST function foo({a, b} = obj) {}; // getDeclaringParent(a) returns PARAM_LIST function foo(...a) {}; // getDeclaringParent(a) returns PARAM_LIST function foo() {}; // gotRootTarget(foo) returns FUNCTION class foo {}; // gotRootTarget(foo) returns CLASS import foo from './foo'; // getDeclaringParent(foo) returns IMPORT import {foo} from './foo'; // getDeclaringParent(foo) returns IMPORT import {foo as bar} from './foo'; // getDeclaringParent(bar) returns IMPORT } catch (err) { // getDeclaringParent(err) returns CATCH </code></pre> @param targetNode a NAME, OBJECT_PATTERN, or ARRAY_PATTERN @return node of type LET, CONST, VAR, FUNCTION, CLASS, PARAM_LIST, CATCH, or IMPORT @throws IllegalStateException if targetNode is not actually used as a declaration target
[ "Returns", "the", "node", "that", "is", "effectively", "declaring", "the", "given", "target", "." ]
train
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3439-L3474
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UResourceBundle.java
UResourceBundle.getBundleInstance
public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ClassLoader loader) { """ <strong>[icu]</strong> Creates a UResourceBundle, from which users can extract resources by using their corresponding keys.<br><br> Note: Please use this API for loading non-ICU resources. Java security does not allow loading of resources across jar files. You must provide your class loader to load the resources @param baseName string containing the name of the data package. If null the default ICU package name is used. @param locale specifies the locale for which we want to open the resource. If null the bundle for default locale is opened. @param loader the loader to use @return a resource bundle for the given base name and locale """ if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } if (locale == null) { locale = ULocale.getDefault(); } return getBundleInstance(baseName, locale.getBaseName(), loader, false); }
java
public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ClassLoader loader) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } if (locale == null) { locale = ULocale.getDefault(); } return getBundleInstance(baseName, locale.getBaseName(), loader, false); }
[ "public", "static", "UResourceBundle", "getBundleInstance", "(", "String", "baseName", ",", "ULocale", "locale", ",", "ClassLoader", "loader", ")", "{", "if", "(", "baseName", "==", "null", ")", "{", "baseName", "=", "ICUData", ".", "ICU_BASE_NAME", ";", "}", "if", "(", "locale", "==", "null", ")", "{", "locale", "=", "ULocale", ".", "getDefault", "(", ")", ";", "}", "return", "getBundleInstance", "(", "baseName", ",", "locale", ".", "getBaseName", "(", ")", ",", "loader", ",", "false", ")", ";", "}" ]
<strong>[icu]</strong> Creates a UResourceBundle, from which users can extract resources by using their corresponding keys.<br><br> Note: Please use this API for loading non-ICU resources. Java security does not allow loading of resources across jar files. You must provide your class loader to load the resources @param baseName string containing the name of the data package. If null the default ICU package name is used. @param locale specifies the locale for which we want to open the resource. If null the bundle for default locale is opened. @param loader the loader to use @return a resource bundle for the given base name and locale
[ "<strong", ">", "[", "icu", "]", "<", "/", "strong", ">", "Creates", "a", "UResourceBundle", "from", "which", "users", "can", "extract", "resources", "by", "using", "their", "corresponding", "keys", ".", "<br", ">", "<br", ">", "Note", ":", "Please", "use", "this", "API", "for", "loading", "non", "-", "ICU", "resources", ".", "Java", "security", "does", "not", "allow", "loading", "of", "resources", "across", "jar", "files", ".", "You", "must", "provide", "your", "class", "loader", "to", "load", "the", "resources" ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UResourceBundle.java#L261-L270
codescape/bitvunit
bitvunit-core/src/main/java/de/codescape/bitvunit/report/TextReportWriter.java
TextReportWriter.printTitle
private void printTitle(HtmlPage htmlPage, PrintWriter out) { """ Writes the header. @param htmlPage {@link HtmlPage} that was inspected @param out target where the report is written to """ out.println(String.format("BitvUnit %s Report - %s - %s", getBitvUnitVersion(), htmlPage.getUrl(), getFormattedDate())); }
java
private void printTitle(HtmlPage htmlPage, PrintWriter out) { out.println(String.format("BitvUnit %s Report - %s - %s", getBitvUnitVersion(), htmlPage.getUrl(), getFormattedDate())); }
[ "private", "void", "printTitle", "(", "HtmlPage", "htmlPage", ",", "PrintWriter", "out", ")", "{", "out", ".", "println", "(", "String", ".", "format", "(", "\"BitvUnit %s Report - %s - %s\"", ",", "getBitvUnitVersion", "(", ")", ",", "htmlPage", ".", "getUrl", "(", ")", ",", "getFormattedDate", "(", ")", ")", ")", ";", "}" ]
Writes the header. @param htmlPage {@link HtmlPage} that was inspected @param out target where the report is written to
[ "Writes", "the", "header", "." ]
train
https://github.com/codescape/bitvunit/blob/cef6d9af60d684e41294981c10b6d92c8f063a4e/bitvunit-core/src/main/java/de/codescape/bitvunit/report/TextReportWriter.java#L49-L51
UrielCh/ovh-java-sdk
ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java
ApiOvhDedicatedCloud.serviceName_datacenter_datacenterId_host_hostId_hourlyConsumption_GET
public net.minidev.ovh.api.dedicatedcloud.host.OvhHourlyConsumption serviceName_datacenter_datacenterId_host_hostId_hourlyConsumption_GET(String serviceName, Long datacenterId, Long hostId) throws IOException { """ Hourly consumption associated with this host. REST: GET /dedicatedCloud/{serviceName}/datacenter/{datacenterId}/host/{hostId}/hourlyConsumption @param serviceName [required] Domain of the service @param datacenterId [required] @param hostId [required] Id of the host """ String qPath = "/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/host/{hostId}/hourlyConsumption"; StringBuilder sb = path(qPath, serviceName, datacenterId, hostId); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, net.minidev.ovh.api.dedicatedcloud.host.OvhHourlyConsumption.class); }
java
public net.minidev.ovh.api.dedicatedcloud.host.OvhHourlyConsumption serviceName_datacenter_datacenterId_host_hostId_hourlyConsumption_GET(String serviceName, Long datacenterId, Long hostId) throws IOException { String qPath = "/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/host/{hostId}/hourlyConsumption"; StringBuilder sb = path(qPath, serviceName, datacenterId, hostId); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, net.minidev.ovh.api.dedicatedcloud.host.OvhHourlyConsumption.class); }
[ "public", "net", ".", "minidev", ".", "ovh", ".", "api", ".", "dedicatedcloud", ".", "host", ".", "OvhHourlyConsumption", "serviceName_datacenter_datacenterId_host_hostId_hourlyConsumption_GET", "(", "String", "serviceName", ",", "Long", "datacenterId", ",", "Long", "hostId", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/host/{hostId}/hourlyConsumption\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "datacenterId", ",", "hostId", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "net", ".", "minidev", ".", "ovh", ".", "api", ".", "dedicatedcloud", ".", "host", ".", "OvhHourlyConsumption", ".", "class", ")", ";", "}" ]
Hourly consumption associated with this host. REST: GET /dedicatedCloud/{serviceName}/datacenter/{datacenterId}/host/{hostId}/hourlyConsumption @param serviceName [required] Domain of the service @param datacenterId [required] @param hostId [required] Id of the host
[ "Hourly", "consumption", "associated", "with", "this", "host", "." ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L1605-L1610
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java
CheckMethodAdapter.checkSignedByte
static void checkSignedByte(final int value, final String msg) { """ Checks that the given value is a signed byte. @param value the value to be checked. @param msg an message to be used in case of error. """ if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { throw new IllegalArgumentException(msg + " (must be a signed byte): " + value); } }
java
static void checkSignedByte(final int value, final String msg) { if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { throw new IllegalArgumentException(msg + " (must be a signed byte): " + value); } }
[ "static", "void", "checkSignedByte", "(", "final", "int", "value", ",", "final", "String", "msg", ")", "{", "if", "(", "value", "<", "Byte", ".", "MIN_VALUE", "||", "value", ">", "Byte", ".", "MAX_VALUE", ")", "{", "throw", "new", "IllegalArgumentException", "(", "msg", "+", "\" (must be a signed byte): \"", "+", "value", ")", ";", "}", "}" ]
Checks that the given value is a signed byte. @param value the value to be checked. @param msg an message to be used in case of error.
[ "Checks", "that", "the", "given", "value", "is", "a", "signed", "byte", "." ]
train
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1110-L1115
imsweb/naaccr-xml
src/main/java/com/imsweb/naaccrxml/NaaccrXmlUtils.java
NaaccrXmlUtils.lineToPatient
public static Patient lineToPatient(String line, NaaccrContext context) throws NaaccrIOException { """ Translates a single line representing a flat file line into a patient object. The resulting patient will have 0 or 1 tumor. <br/><br/> Unlike the methods dealing with files, this method takes a context as a parameter. The reason for that difference is that this method uses a stream to convert the line, and so the stream needs to be re-created every time the method is invoked on a given line. This is very inefficient and would be too slow if this method was used in a loop (which is the common use-case). Having a shared context that is created once outside the loop avoids that inefficiency. <br/><br/> It is very important to not re-create the context when this method is called in a loop: <br><br/> This is NOT correct: <code> for (String line : lines) NaaccrXmlUtils.lineToPatient(line, new NaaccrContext(NaaccrFormat.NAACCR_FORMAT_16_ABSTRACT)); </code> This is correct: <code> NaaccrContext context = new NaaccrContext(NaaccrFormat.NAACCR_FORMAT_16_ABSTRACT); for (String line : lines) NaaccrXmlUtils.lineToPatient(line, context); </code> @param line the line to translate, required @param context the context to use for the translation, required @return the corresponding patient, never null @throws NaaccrIOException if there is problem translating the line """ if (line == null) throw new NaaccrIOException("Line is required"); if (context == null) throw new NaaccrIOException("Context is required"); NaaccrFormat format = NaaccrFormat.getInstance(context.getFormat()); if (line.length() != format.getLineLength()) throw new NaaccrIOException("Expected line length to be " + format.getLineLength() + " but was " + line.length()); boolean updateType = !format.getRecordType().equals(line.substring(0, 1).trim()); boolean updateVersion = !format.getNaaccrVersion().equals(line.substring(16, 19).trim()); if (updateType || updateVersion) { StringBuilder buf = new StringBuilder(line); buf.replace(0, 1, format.getRecordType()); buf.replace(16, 19, format.getNaaccrVersion()); line = buf.toString(); } try (PatientFlatReader reader = new PatientFlatReader(new StringReader(line), context.getOptions(), context.getUserDictionaries(), context.getStreamConfiguration())) { return reader.readPatient(); } }
java
public static Patient lineToPatient(String line, NaaccrContext context) throws NaaccrIOException { if (line == null) throw new NaaccrIOException("Line is required"); if (context == null) throw new NaaccrIOException("Context is required"); NaaccrFormat format = NaaccrFormat.getInstance(context.getFormat()); if (line.length() != format.getLineLength()) throw new NaaccrIOException("Expected line length to be " + format.getLineLength() + " but was " + line.length()); boolean updateType = !format.getRecordType().equals(line.substring(0, 1).trim()); boolean updateVersion = !format.getNaaccrVersion().equals(line.substring(16, 19).trim()); if (updateType || updateVersion) { StringBuilder buf = new StringBuilder(line); buf.replace(0, 1, format.getRecordType()); buf.replace(16, 19, format.getNaaccrVersion()); line = buf.toString(); } try (PatientFlatReader reader = new PatientFlatReader(new StringReader(line), context.getOptions(), context.getUserDictionaries(), context.getStreamConfiguration())) { return reader.readPatient(); } }
[ "public", "static", "Patient", "lineToPatient", "(", "String", "line", ",", "NaaccrContext", "context", ")", "throws", "NaaccrIOException", "{", "if", "(", "line", "==", "null", ")", "throw", "new", "NaaccrIOException", "(", "\"Line is required\"", ")", ";", "if", "(", "context", "==", "null", ")", "throw", "new", "NaaccrIOException", "(", "\"Context is required\"", ")", ";", "NaaccrFormat", "format", "=", "NaaccrFormat", ".", "getInstance", "(", "context", ".", "getFormat", "(", ")", ")", ";", "if", "(", "line", ".", "length", "(", ")", "!=", "format", ".", "getLineLength", "(", ")", ")", "throw", "new", "NaaccrIOException", "(", "\"Expected line length to be \"", "+", "format", ".", "getLineLength", "(", ")", "+", "\" but was \"", "+", "line", ".", "length", "(", ")", ")", ";", "boolean", "updateType", "=", "!", "format", ".", "getRecordType", "(", ")", ".", "equals", "(", "line", ".", "substring", "(", "0", ",", "1", ")", ".", "trim", "(", ")", ")", ";", "boolean", "updateVersion", "=", "!", "format", ".", "getNaaccrVersion", "(", ")", ".", "equals", "(", "line", ".", "substring", "(", "16", ",", "19", ")", ".", "trim", "(", ")", ")", ";", "if", "(", "updateType", "||", "updateVersion", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "line", ")", ";", "buf", ".", "replace", "(", "0", ",", "1", ",", "format", ".", "getRecordType", "(", ")", ")", ";", "buf", ".", "replace", "(", "16", ",", "19", ",", "format", ".", "getNaaccrVersion", "(", ")", ")", ";", "line", "=", "buf", ".", "toString", "(", ")", ";", "}", "try", "(", "PatientFlatReader", "reader", "=", "new", "PatientFlatReader", "(", "new", "StringReader", "(", "line", ")", ",", "context", ".", "getOptions", "(", ")", ",", "context", ".", "getUserDictionaries", "(", ")", ",", "context", ".", "getStreamConfiguration", "(", ")", ")", ")", "{", "return", "reader", ".", "readPatient", "(", ")", ";", "}", "}" ]
Translates a single line representing a flat file line into a patient object. The resulting patient will have 0 or 1 tumor. <br/><br/> Unlike the methods dealing with files, this method takes a context as a parameter. The reason for that difference is that this method uses a stream to convert the line, and so the stream needs to be re-created every time the method is invoked on a given line. This is very inefficient and would be too slow if this method was used in a loop (which is the common use-case). Having a shared context that is created once outside the loop avoids that inefficiency. <br/><br/> It is very important to not re-create the context when this method is called in a loop: <br><br/> This is NOT correct: <code> for (String line : lines) NaaccrXmlUtils.lineToPatient(line, new NaaccrContext(NaaccrFormat.NAACCR_FORMAT_16_ABSTRACT)); </code> This is correct: <code> NaaccrContext context = new NaaccrContext(NaaccrFormat.NAACCR_FORMAT_16_ABSTRACT); for (String line : lines) NaaccrXmlUtils.lineToPatient(line, context); </code> @param line the line to translate, required @param context the context to use for the translation, required @return the corresponding patient, never null @throws NaaccrIOException if there is problem translating the line
[ "Translates", "a", "single", "line", "representing", "a", "flat", "file", "line", "into", "a", "patient", "object", ".", "The", "resulting", "patient", "will", "have", "0", "or", "1", "tumor", ".", "<br", "/", ">", "<br", "/", ">", "Unlike", "the", "methods", "dealing", "with", "files", "this", "method", "takes", "a", "context", "as", "a", "parameter", ".", "The", "reason", "for", "that", "difference", "is", "that", "this", "method", "uses", "a", "stream", "to", "convert", "the", "line", "and", "so", "the", "stream", "needs", "to", "be", "re", "-", "created", "every", "time", "the", "method", "is", "invoked", "on", "a", "given", "line", ".", "This", "is", "very", "inefficient", "and", "would", "be", "too", "slow", "if", "this", "method", "was", "used", "in", "a", "loop", "(", "which", "is", "the", "common", "use", "-", "case", ")", ".", "Having", "a", "shared", "context", "that", "is", "created", "once", "outside", "the", "loop", "avoids", "that", "inefficiency", ".", "<br", "/", ">", "<br", "/", ">", "It", "is", "very", "important", "to", "not", "re", "-", "create", "the", "context", "when", "this", "method", "is", "called", "in", "a", "loop", ":", "<br", ">", "<br", "/", ">", "This", "is", "NOT", "correct", ":", "<code", ">", "for", "(", "String", "line", ":", "lines", ")", "NaaccrXmlUtils", ".", "lineToPatient", "(", "line", "new", "NaaccrContext", "(", "NaaccrFormat", ".", "NAACCR_FORMAT_16_ABSTRACT", "))", ";", "<", "/", "code", ">", "This", "is", "correct", ":", "<code", ">", "NaaccrContext", "context", "=", "new", "NaaccrContext", "(", "NaaccrFormat", ".", "NAACCR_FORMAT_16_ABSTRACT", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "NaaccrXmlUtils", ".", "lineToPatient", "(", "line", "context", ")", ";", "<", "/", "code", ">" ]
train
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/NaaccrXmlUtils.java#L274-L296
caelum/vraptor4
vraptor-core/src/main/java/br/com/caelum/vraptor/view/DefaultLogicResult.java
DefaultLogicResult.forwardTo
@Override public <T> T forwardTo(final Class<T> type) { """ This implementation don't actually use request dispatcher for the forwarding. It runs forwarding logic, and renders its <b>default</b> view. """ return proxifier.proxify(type, new MethodInvocation<T>() { @Override public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { try { logger.debug("Executing {}", method); ControllerMethod old = methodInfo.getControllerMethod(); methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method)); Object methodResult = method.invoke(container.instanceFor(type), args); methodInfo.setControllerMethod(old); Type returnType = method.getGenericReturnType(); if (!(returnType == void.class)) { request.setAttribute(extractor.nameFor(returnType), methodResult); } if (response.isCommitted()) { logger.debug("Response already commited, not forwarding."); return null; } String path = resolver.pathFor(DefaultControllerMethod.instanceFor(type, method)); logger.debug("Forwarding to {}", path); request.getRequestDispatcher(path).forward(request, response); return null; } catch (InvocationTargetException e) { propagateIfPossible(e.getCause()); throw new ProxyInvocationException(e); } catch (Exception e) { throw new ProxyInvocationException(e); } } }); }
java
@Override public <T> T forwardTo(final Class<T> type) { return proxifier.proxify(type, new MethodInvocation<T>() { @Override public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { try { logger.debug("Executing {}", method); ControllerMethod old = methodInfo.getControllerMethod(); methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method)); Object methodResult = method.invoke(container.instanceFor(type), args); methodInfo.setControllerMethod(old); Type returnType = method.getGenericReturnType(); if (!(returnType == void.class)) { request.setAttribute(extractor.nameFor(returnType), methodResult); } if (response.isCommitted()) { logger.debug("Response already commited, not forwarding."); return null; } String path = resolver.pathFor(DefaultControllerMethod.instanceFor(type, method)); logger.debug("Forwarding to {}", path); request.getRequestDispatcher(path).forward(request, response); return null; } catch (InvocationTargetException e) { propagateIfPossible(e.getCause()); throw new ProxyInvocationException(e); } catch (Exception e) { throw new ProxyInvocationException(e); } } }); }
[ "@", "Override", "public", "<", "T", ">", "T", "forwardTo", "(", "final", "Class", "<", "T", ">", "type", ")", "{", "return", "proxifier", ".", "proxify", "(", "type", ",", "new", "MethodInvocation", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "Object", "intercept", "(", "T", "proxy", ",", "Method", "method", ",", "Object", "[", "]", "args", ",", "SuperMethod", "superMethod", ")", "{", "try", "{", "logger", ".", "debug", "(", "\"Executing {}\"", ",", "method", ")", ";", "ControllerMethod", "old", "=", "methodInfo", ".", "getControllerMethod", "(", ")", ";", "methodInfo", ".", "setControllerMethod", "(", "DefaultControllerMethod", ".", "instanceFor", "(", "type", ",", "method", ")", ")", ";", "Object", "methodResult", "=", "method", ".", "invoke", "(", "container", ".", "instanceFor", "(", "type", ")", ",", "args", ")", ";", "methodInfo", ".", "setControllerMethod", "(", "old", ")", ";", "Type", "returnType", "=", "method", ".", "getGenericReturnType", "(", ")", ";", "if", "(", "!", "(", "returnType", "==", "void", ".", "class", ")", ")", "{", "request", ".", "setAttribute", "(", "extractor", ".", "nameFor", "(", "returnType", ")", ",", "methodResult", ")", ";", "}", "if", "(", "response", ".", "isCommitted", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Response already commited, not forwarding.\"", ")", ";", "return", "null", ";", "}", "String", "path", "=", "resolver", ".", "pathFor", "(", "DefaultControllerMethod", ".", "instanceFor", "(", "type", ",", "method", ")", ")", ";", "logger", ".", "debug", "(", "\"Forwarding to {}\"", ",", "path", ")", ";", "request", ".", "getRequestDispatcher", "(", "path", ")", ".", "forward", "(", "request", ",", "response", ")", ";", "return", "null", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "propagateIfPossible", "(", "e", ".", "getCause", "(", ")", ")", ";", "throw", "new", "ProxyInvocationException", "(", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ProxyInvocationException", "(", "e", ")", ";", "}", "}", "}", ")", ";", "}" ]
This implementation don't actually use request dispatcher for the forwarding. It runs forwarding logic, and renders its <b>default</b> view.
[ "This", "implementation", "don", "t", "actually", "use", "request", "dispatcher", "for", "the", "forwarding", ".", "It", "runs", "forwarding", "logic", "and", "renders", "its", "<b", ">", "default<", "/", "b", ">", "view", "." ]
train
https://github.com/caelum/vraptor4/blob/593ce9ad60f9d38c360881b2132417c56b8cc093/vraptor-core/src/main/java/br/com/caelum/vraptor/view/DefaultLogicResult.java#L97-L131
iig-uni-freiburg/SEWOL
ext/org/deckfour/spex/SXTag.java
SXTag.addAttribute
public synchronized void addAttribute(String aName, String aValue) throws IOException { """ Adds an attribute to this tag node. Will result in something like: <code><i>aName</i>=<i>aValue</i></code> <b>WARNING:</b> <ul> <li>Attributes must be added immediately after creation of a tag, i.e.:</li> <li>All attributes must have been added <b>before</b> adding the first child node.</li> </ul> @param aName Name, i.e. key, of this attribute @param aValue Value of this attribute """ // reject modification of already closed node if(isOpen==false) { throw new IOException("Attempted to add attribute '" + aName + "' to already closed tag '" + name + "'!"); } // check for sane input if((aName==null) || (aValue==null) || (aName.trim().length()==0) || (aValue.trim().length()==0)) { return; // reject unnecessary attributes } // add attributes if(lastChildNode==null) { // encode and write attribute aName = aName.trim(); aValue = SXmlCharacterMethods.convertCharsToXml(aValue.trim()); writer.write(" " + aName + "=\"" + aValue + "\""); } else { // usage contract broken! (no adding of attributes after adding first child node) throw new IOException("No attributes can be added to a node " + "after the first child has been added! ('" + name + "')"); } }
java
public synchronized void addAttribute(String aName, String aValue) throws IOException { // reject modification of already closed node if(isOpen==false) { throw new IOException("Attempted to add attribute '" + aName + "' to already closed tag '" + name + "'!"); } // check for sane input if((aName==null) || (aValue==null) || (aName.trim().length()==0) || (aValue.trim().length()==0)) { return; // reject unnecessary attributes } // add attributes if(lastChildNode==null) { // encode and write attribute aName = aName.trim(); aValue = SXmlCharacterMethods.convertCharsToXml(aValue.trim()); writer.write(" " + aName + "=\"" + aValue + "\""); } else { // usage contract broken! (no adding of attributes after adding first child node) throw new IOException("No attributes can be added to a node " + "after the first child has been added! ('" + name + "')"); } }
[ "public", "synchronized", "void", "addAttribute", "(", "String", "aName", ",", "String", "aValue", ")", "throws", "IOException", "{", "// reject modification of already closed node", "if", "(", "isOpen", "==", "false", ")", "{", "throw", "new", "IOException", "(", "\"Attempted to add attribute '\"", "+", "aName", "+", "\"' to already closed tag '\"", "+", "name", "+", "\"'!\"", ")", ";", "}", "// check for sane input", "if", "(", "(", "aName", "==", "null", ")", "||", "(", "aValue", "==", "null", ")", "||", "(", "aName", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "||", "(", "aValue", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", ";", "// reject unnecessary attributes", "}", "// add attributes", "if", "(", "lastChildNode", "==", "null", ")", "{", "// encode and write attribute", "aName", "=", "aName", ".", "trim", "(", ")", ";", "aValue", "=", "SXmlCharacterMethods", ".", "convertCharsToXml", "(", "aValue", ".", "trim", "(", ")", ")", ";", "writer", ".", "write", "(", "\" \"", "+", "aName", "+", "\"=\\\"\"", "+", "aValue", "+", "\"\\\"\"", ")", ";", "}", "else", "{", "// usage contract broken! (no adding of attributes after adding first child node)", "throw", "new", "IOException", "(", "\"No attributes can be added to a node \"", "+", "\"after the first child has been added! ('\"", "+", "name", "+", "\"')\"", ")", ";", "}", "}" ]
Adds an attribute to this tag node. Will result in something like: <code><i>aName</i>=<i>aValue</i></code> <b>WARNING:</b> <ul> <li>Attributes must be added immediately after creation of a tag, i.e.:</li> <li>All attributes must have been added <b>before</b> adding the first child node.</li> </ul> @param aName Name, i.e. key, of this attribute @param aValue Value of this attribute
[ "Adds", "an", "attribute", "to", "this", "tag", "node", ".", "Will", "result", "in", "something", "like", ":", "<code", ">", "<i", ">", "aName<", "/", "i", ">", "=", "<i", ">", "aValue<", "/", "i", ">", "<", "/", "code", ">", "<b", ">", "WARNING", ":", "<", "/", "b", ">", "<ul", ">", "<li", ">", "Attributes", "must", "be", "added", "immediately", "after", "creation", "of", "a", "tag", "i", ".", "e", ".", ":", "<", "/", "li", ">", "<li", ">", "All", "attributes", "must", "have", "been", "added", "<b", ">", "before<", "/", "b", ">", "adding", "the", "first", "child", "node", ".", "<", "/", "li", ">", "<", "/", "ul", ">" ]
train
https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/spex/SXTag.java#L111-L134
offbynull/coroutines
instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/GenericGenerators.java
GenericGenerators.combineObjectArrays
public static InsnList combineObjectArrays(Variable destArrayVar, Variable firstArrayVar, Variable secondArrayVar) { """ Concatenates two object arrays together. @param destArrayVar variable to put concatenated object array in @param firstArrayVar variable of first object array @param secondArrayVar variable of second object array @return instructions to create a new object array where the first part of the array is the contents of {@code firstArrayVar} and the second part of the array is the contents of {@code secondArrayVar} @throws NullPointerException if any argument is {@code null} @throws IllegalArgumentException if variables have the same index, or if variables have been released, or if variables are of wrong type """ Validate.notNull(destArrayVar); Validate.notNull(firstArrayVar); Validate.notNull(secondArrayVar); Validate.isTrue(destArrayVar.getType().equals(Type.getType(Object[].class))); Validate.isTrue(firstArrayVar.getType().equals(Type.getType(Object[].class))); Validate.isTrue(secondArrayVar.getType().equals(Type.getType(Object[].class))); validateLocalIndicies(destArrayVar.getIndex(), firstArrayVar.getIndex(), secondArrayVar.getIndex()); InsnList ret = merge( // destArrayVar = new Object[firstArrayVar.length + secondArrayVar.length] createNewObjectArray( addIntegers( loadArrayLength(loadVar(firstArrayVar)), loadArrayLength(loadVar(secondArrayVar)) ) ), saveVar(destArrayVar), // System.arrayCopy(firstArrayVar, 0, destArrayVar, 0, firstArrayVar.length) call(SYSTEM_ARRAY_COPY_METHOD, loadVar(firstArrayVar), loadIntConst(0), loadVar(destArrayVar), loadIntConst(0), loadArrayLength(loadVar(firstArrayVar)) ), // System.arrayCopy(secondArrayVar, 0, destArrayVar, firstArrayVar.length, secondArrayVar.length) call(SYSTEM_ARRAY_COPY_METHOD, loadVar(secondArrayVar), loadIntConst(0), loadVar(destArrayVar), loadArrayLength(loadVar(firstArrayVar)), loadArrayLength(loadVar(secondArrayVar)) ) ); return ret; }
java
public static InsnList combineObjectArrays(Variable destArrayVar, Variable firstArrayVar, Variable secondArrayVar) { Validate.notNull(destArrayVar); Validate.notNull(firstArrayVar); Validate.notNull(secondArrayVar); Validate.isTrue(destArrayVar.getType().equals(Type.getType(Object[].class))); Validate.isTrue(firstArrayVar.getType().equals(Type.getType(Object[].class))); Validate.isTrue(secondArrayVar.getType().equals(Type.getType(Object[].class))); validateLocalIndicies(destArrayVar.getIndex(), firstArrayVar.getIndex(), secondArrayVar.getIndex()); InsnList ret = merge( // destArrayVar = new Object[firstArrayVar.length + secondArrayVar.length] createNewObjectArray( addIntegers( loadArrayLength(loadVar(firstArrayVar)), loadArrayLength(loadVar(secondArrayVar)) ) ), saveVar(destArrayVar), // System.arrayCopy(firstArrayVar, 0, destArrayVar, 0, firstArrayVar.length) call(SYSTEM_ARRAY_COPY_METHOD, loadVar(firstArrayVar), loadIntConst(0), loadVar(destArrayVar), loadIntConst(0), loadArrayLength(loadVar(firstArrayVar)) ), // System.arrayCopy(secondArrayVar, 0, destArrayVar, firstArrayVar.length, secondArrayVar.length) call(SYSTEM_ARRAY_COPY_METHOD, loadVar(secondArrayVar), loadIntConst(0), loadVar(destArrayVar), loadArrayLength(loadVar(firstArrayVar)), loadArrayLength(loadVar(secondArrayVar)) ) ); return ret; }
[ "public", "static", "InsnList", "combineObjectArrays", "(", "Variable", "destArrayVar", ",", "Variable", "firstArrayVar", ",", "Variable", "secondArrayVar", ")", "{", "Validate", ".", "notNull", "(", "destArrayVar", ")", ";", "Validate", ".", "notNull", "(", "firstArrayVar", ")", ";", "Validate", ".", "notNull", "(", "secondArrayVar", ")", ";", "Validate", ".", "isTrue", "(", "destArrayVar", ".", "getType", "(", ")", ".", "equals", "(", "Type", ".", "getType", "(", "Object", "[", "]", ".", "class", ")", ")", ")", ";", "Validate", ".", "isTrue", "(", "firstArrayVar", ".", "getType", "(", ")", ".", "equals", "(", "Type", ".", "getType", "(", "Object", "[", "]", ".", "class", ")", ")", ")", ";", "Validate", ".", "isTrue", "(", "secondArrayVar", ".", "getType", "(", ")", ".", "equals", "(", "Type", ".", "getType", "(", "Object", "[", "]", ".", "class", ")", ")", ")", ";", "validateLocalIndicies", "(", "destArrayVar", ".", "getIndex", "(", ")", ",", "firstArrayVar", ".", "getIndex", "(", ")", ",", "secondArrayVar", ".", "getIndex", "(", ")", ")", ";", "InsnList", "ret", "=", "merge", "(", "// destArrayVar = new Object[firstArrayVar.length + secondArrayVar.length]", "createNewObjectArray", "(", "addIntegers", "(", "loadArrayLength", "(", "loadVar", "(", "firstArrayVar", ")", ")", ",", "loadArrayLength", "(", "loadVar", "(", "secondArrayVar", ")", ")", ")", ")", ",", "saveVar", "(", "destArrayVar", ")", ",", "// System.arrayCopy(firstArrayVar, 0, destArrayVar, 0, firstArrayVar.length)", "call", "(", "SYSTEM_ARRAY_COPY_METHOD", ",", "loadVar", "(", "firstArrayVar", ")", ",", "loadIntConst", "(", "0", ")", ",", "loadVar", "(", "destArrayVar", ")", ",", "loadIntConst", "(", "0", ")", ",", "loadArrayLength", "(", "loadVar", "(", "firstArrayVar", ")", ")", ")", ",", "// System.arrayCopy(secondArrayVar, 0, destArrayVar, firstArrayVar.length, secondArrayVar.length)", "call", "(", "SYSTEM_ARRAY_COPY_METHOD", ",", "loadVar", "(", "secondArrayVar", ")", ",", "loadIntConst", "(", "0", ")", ",", "loadVar", "(", "destArrayVar", ")", ",", "loadArrayLength", "(", "loadVar", "(", "firstArrayVar", ")", ")", ",", "loadArrayLength", "(", "loadVar", "(", "secondArrayVar", ")", ")", ")", ")", ";", "return", "ret", ";", "}" ]
Concatenates two object arrays together. @param destArrayVar variable to put concatenated object array in @param firstArrayVar variable of first object array @param secondArrayVar variable of second object array @return instructions to create a new object array where the first part of the array is the contents of {@code firstArrayVar} and the second part of the array is the contents of {@code secondArrayVar} @throws NullPointerException if any argument is {@code null} @throws IllegalArgumentException if variables have the same index, or if variables have been released, or if variables are of wrong type
[ "Concatenates", "two", "object", "arrays", "together", "." ]
train
https://github.com/offbynull/coroutines/blob/b1b83c293945f53a2f63fca8f15a53e88b796bf5/instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/GenericGenerators.java#L850-L887
netty/netty
common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java
GlobalEventExecutor.awaitInactivity
public boolean awaitInactivity(long timeout, TimeUnit unit) throws InterruptedException { """ Waits until the worker thread of this executor has no tasks left in its task queue and terminates itself. Because a new worker thread will be started again when a new task is submitted, this operation is only useful when you want to ensure that the worker thread is terminated <strong>after</strong> your application is shut down and there's no chance of submitting a new task afterwards. @return {@code true} if and only if the worker thread has been terminated """ if (unit == null) { throw new NullPointerException("unit"); } final Thread thread = this.thread; if (thread == null) { throw new IllegalStateException("thread was not started"); } thread.join(unit.toMillis(timeout)); return !thread.isAlive(); }
java
public boolean awaitInactivity(long timeout, TimeUnit unit) throws InterruptedException { if (unit == null) { throw new NullPointerException("unit"); } final Thread thread = this.thread; if (thread == null) { throw new IllegalStateException("thread was not started"); } thread.join(unit.toMillis(timeout)); return !thread.isAlive(); }
[ "public", "boolean", "awaitInactivity", "(", "long", "timeout", ",", "TimeUnit", "unit", ")", "throws", "InterruptedException", "{", "if", "(", "unit", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"unit\"", ")", ";", "}", "final", "Thread", "thread", "=", "this", ".", "thread", ";", "if", "(", "thread", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"thread was not started\"", ")", ";", "}", "thread", ".", "join", "(", "unit", ".", "toMillis", "(", "timeout", ")", ")", ";", "return", "!", "thread", ".", "isAlive", "(", ")", ";", "}" ]
Waits until the worker thread of this executor has no tasks left in its task queue and terminates itself. Because a new worker thread will be started again when a new task is submitted, this operation is only useful when you want to ensure that the worker thread is terminated <strong>after</strong> your application is shut down and there's no chance of submitting a new task afterwards. @return {@code true} if and only if the worker thread has been terminated
[ "Waits", "until", "the", "worker", "thread", "of", "this", "executor", "has", "no", "tasks", "left", "in", "its", "task", "queue", "and", "terminates", "itself", ".", "Because", "a", "new", "worker", "thread", "will", "be", "started", "again", "when", "a", "new", "task", "is", "submitted", "this", "operation", "is", "only", "useful", "when", "you", "want", "to", "ensure", "that", "the", "worker", "thread", "is", "terminated", "<strong", ">", "after<", "/", "strong", ">", "your", "application", "is", "shut", "down", "and", "there", "s", "no", "chance", "of", "submitting", "a", "new", "task", "afterwards", "." ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java#L194-L205
alkacon/opencms-core
src/org/opencms/importexport/CmsImportVersion10.java
CmsImportVersion10.addRelation
public void addRelation() { """ Adds a relation to be imported from the current xml data.<p> @see #addResourceRelationRules(Digester, String) """ try { if (m_throwable != null) { // relation data is corrupt, ignore relation if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key( Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_RELATION_1, m_destination), m_throwable); } getReport().println(m_throwable); getReport().addError(m_throwable); m_throwable = null; return; } RelationData relData = new RelationData(m_relationPath, m_relationId, m_relationType); m_relationsForResource.add(relData); m_relationData.put(Integer.valueOf(m_fileCounter), relData); } finally { m_relationId = null; m_relationPath = null; m_relationType = null; } }
java
public void addRelation() { try { if (m_throwable != null) { // relation data is corrupt, ignore relation if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key( Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_RELATION_1, m_destination), m_throwable); } getReport().println(m_throwable); getReport().addError(m_throwable); m_throwable = null; return; } RelationData relData = new RelationData(m_relationPath, m_relationId, m_relationType); m_relationsForResource.add(relData); m_relationData.put(Integer.valueOf(m_fileCounter), relData); } finally { m_relationId = null; m_relationPath = null; m_relationType = null; } }
[ "public", "void", "addRelation", "(", ")", "{", "try", "{", "if", "(", "m_throwable", "!=", "null", ")", "{", "// relation data is corrupt, ignore relation", "if", "(", "LOG", ".", "isWarnEnabled", "(", ")", ")", "{", "LOG", ".", "warn", "(", "Messages", ".", "get", "(", ")", ".", "getBundle", "(", ")", ".", "key", "(", "Messages", ".", "LOG_IMPORTEXPORT_ERROR_IMPORTING_RELATION_1", ",", "m_destination", ")", ",", "m_throwable", ")", ";", "}", "getReport", "(", ")", ".", "println", "(", "m_throwable", ")", ";", "getReport", "(", ")", ".", "addError", "(", "m_throwable", ")", ";", "m_throwable", "=", "null", ";", "return", ";", "}", "RelationData", "relData", "=", "new", "RelationData", "(", "m_relationPath", ",", "m_relationId", ",", "m_relationType", ")", ";", "m_relationsForResource", ".", "add", "(", "relData", ")", ";", "m_relationData", ".", "put", "(", "Integer", ".", "valueOf", "(", "m_fileCounter", ")", ",", "relData", ")", ";", "}", "finally", "{", "m_relationId", "=", "null", ";", "m_relationPath", "=", "null", ";", "m_relationType", "=", "null", ";", "}", "}" ]
Adds a relation to be imported from the current xml data.<p> @see #addResourceRelationRules(Digester, String)
[ "Adds", "a", "relation", "to", "be", "imported", "from", "the", "current", "xml", "data", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/importexport/CmsImportVersion10.java#L824-L849
opsmatters/newrelic-api
src/main/java/com/opsmatters/newrelic/api/NewRelicClient.java
NewRelicClient.initialize
public NewRelicClient initialize() { """ Called after setting configuration properties. @return This object """ Client client = provider.getClient(); String protocol = provider.useSsl() ? "https" : "http"; httpContext = new HttpContext(client, protocol, hostname, port); httpContext.setUriPrefix(getUriPrefix()); httpContext.setThrowExceptions(handleErrors); String className = getClass().getName(); logger.fine(className.substring(className.lastIndexOf(".")+1)+" initialized"); return this; }
java
public NewRelicClient initialize() { Client client = provider.getClient(); String protocol = provider.useSsl() ? "https" : "http"; httpContext = new HttpContext(client, protocol, hostname, port); httpContext.setUriPrefix(getUriPrefix()); httpContext.setThrowExceptions(handleErrors); String className = getClass().getName(); logger.fine(className.substring(className.lastIndexOf(".")+1)+" initialized"); return this; }
[ "public", "NewRelicClient", "initialize", "(", ")", "{", "Client", "client", "=", "provider", ".", "getClient", "(", ")", ";", "String", "protocol", "=", "provider", ".", "useSsl", "(", ")", "?", "\"https\"", ":", "\"http\"", ";", "httpContext", "=", "new", "HttpContext", "(", "client", ",", "protocol", ",", "hostname", ",", "port", ")", ";", "httpContext", ".", "setUriPrefix", "(", "getUriPrefix", "(", ")", ")", ";", "httpContext", ".", "setThrowExceptions", "(", "handleErrors", ")", ";", "String", "className", "=", "getClass", "(", ")", ".", "getName", "(", ")", ";", "logger", ".", "fine", "(", "className", ".", "substring", "(", "className", ".", "lastIndexOf", "(", "\".\"", ")", "+", "1", ")", "+", "\" initialized\"", ")", ";", "return", "this", ";", "}" ]
Called after setting configuration properties. @return This object
[ "Called", "after", "setting", "configuration", "properties", "." ]
train
https://github.com/opsmatters/newrelic-api/blob/5bc2ea62ec368db891e4fd5fe3dcdf529d086b5e/src/main/java/com/opsmatters/newrelic/api/NewRelicClient.java#L68-L78
wcm-io/wcm-io-wcm
commons/src/main/java/io/wcm/wcm/commons/caching/CacheHeader.java
CacheHeader.setExpiresDays
public static void setExpiresDays(@NotNull HttpServletResponse response, int days) { """ Set expires header to given amount of days in the future. @param response Response @param days Days to expire """ Date expiresDate = DateUtils.addDays(new Date(), days); setExpires(response, expiresDate); }
java
public static void setExpiresDays(@NotNull HttpServletResponse response, int days) { Date expiresDate = DateUtils.addDays(new Date(), days); setExpires(response, expiresDate); }
[ "public", "static", "void", "setExpiresDays", "(", "@", "NotNull", "HttpServletResponse", "response", ",", "int", "days", ")", "{", "Date", "expiresDate", "=", "DateUtils", ".", "addDays", "(", "new", "Date", "(", ")", ",", "days", ")", ";", "setExpires", "(", "response", ",", "expiresDate", ")", ";", "}" ]
Set expires header to given amount of days in the future. @param response Response @param days Days to expire
[ "Set", "expires", "header", "to", "given", "amount", "of", "days", "in", "the", "future", "." ]
train
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/commons/src/main/java/io/wcm/wcm/commons/caching/CacheHeader.java#L252-L255
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiUtil.java
HttpApiUtil.newResponse
public static HttpResponse newResponse(RequestContext ctx, HttpStatus status, String message) { """ Returns a newly created {@link HttpResponse} with the specified {@link HttpStatus} and {@code message}. """ requireNonNull(ctx, "ctx"); requireNonNull(status, "status"); requireNonNull(message, "message"); return newResponse0(ctx, status, null, message); }
java
public static HttpResponse newResponse(RequestContext ctx, HttpStatus status, String message) { requireNonNull(ctx, "ctx"); requireNonNull(status, "status"); requireNonNull(message, "message"); return newResponse0(ctx, status, null, message); }
[ "public", "static", "HttpResponse", "newResponse", "(", "RequestContext", "ctx", ",", "HttpStatus", "status", ",", "String", "message", ")", "{", "requireNonNull", "(", "ctx", ",", "\"ctx\"", ")", ";", "requireNonNull", "(", "status", ",", "\"status\"", ")", ";", "requireNonNull", "(", "message", ",", "\"message\"", ")", ";", "return", "newResponse0", "(", "ctx", ",", "status", ",", "null", ",", "message", ")", ";", "}" ]
Returns a newly created {@link HttpResponse} with the specified {@link HttpStatus} and {@code message}.
[ "Returns", "a", "newly", "created", "{" ]
train
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiUtil.java#L115-L120
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/FileUtils.java
FileUtils.crapToDisk
public static int crapToDisk(Context ctx, String filename, byte[] data) { """ Dump Data straight to the SDCard @param ctx the application context @param filename the dump filename @param data the data to dump @return the return """ int code = IO_FAIL; File dir = Environment.getExternalStorageDirectory(); File output = new File(dir, filename); try { FileOutputStream fos = new FileOutputStream(output); try { fos.write(data); code = IO_SUCCESS; } catch (IOException e) { code = IO_FAIL; } finally { fos.close(); } } catch (IOException e) { e.printStackTrace(); } return code; }
java
public static int crapToDisk(Context ctx, String filename, byte[] data){ int code = IO_FAIL; File dir = Environment.getExternalStorageDirectory(); File output = new File(dir, filename); try { FileOutputStream fos = new FileOutputStream(output); try { fos.write(data); code = IO_SUCCESS; } catch (IOException e) { code = IO_FAIL; } finally { fos.close(); } } catch (IOException e) { e.printStackTrace(); } return code; }
[ "public", "static", "int", "crapToDisk", "(", "Context", "ctx", ",", "String", "filename", ",", "byte", "[", "]", "data", ")", "{", "int", "code", "=", "IO_FAIL", ";", "File", "dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ";", "File", "output", "=", "new", "File", "(", "dir", ",", "filename", ")", ";", "try", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "output", ")", ";", "try", "{", "fos", ".", "write", "(", "data", ")", ";", "code", "=", "IO_SUCCESS", ";", "}", "catch", "(", "IOException", "e", ")", "{", "code", "=", "IO_FAIL", ";", "}", "finally", "{", "fos", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "code", ";", "}" ]
Dump Data straight to the SDCard @param ctx the application context @param filename the dump filename @param data the data to dump @return the return
[ "Dump", "Data", "straight", "to", "the", "SDCard" ]
train
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/FileUtils.java#L196-L217
alkacon/opencms-core
src/org/opencms/ui/sitemap/CmsSitemapTreeController.java
CmsSitemapTreeController.openPageCopyDialog
public void openPageCopyDialog(CmsSitemapTreeNode node, CmsSitemapTreeNodeData entry) { """ Opens the page copy dialog for a tree entry.<p> @param node the tree node widget @param entry the tree entry """ CmsObject cms = A_CmsUI.getCmsObject(); try { CmsResource resource = cms.readResource( entry.getClientEntry().getId(), CmsResourceFilter.IGNORE_EXPIRATION); DialogContext context = new DialogContext(resource, node); CmsCopyPageDialog dialog = new CmsCopyPageDialog(context); String title = CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_DIALOG_TITLE_0); context.start(title, dialog); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); CmsErrorDialog.showErrorDialog(e); } }
java
public void openPageCopyDialog(CmsSitemapTreeNode node, CmsSitemapTreeNodeData entry) { CmsObject cms = A_CmsUI.getCmsObject(); try { CmsResource resource = cms.readResource( entry.getClientEntry().getId(), CmsResourceFilter.IGNORE_EXPIRATION); DialogContext context = new DialogContext(resource, node); CmsCopyPageDialog dialog = new CmsCopyPageDialog(context); String title = CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_DIALOG_TITLE_0); context.start(title, dialog); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); CmsErrorDialog.showErrorDialog(e); } }
[ "public", "void", "openPageCopyDialog", "(", "CmsSitemapTreeNode", "node", ",", "CmsSitemapTreeNodeData", "entry", ")", "{", "CmsObject", "cms", "=", "A_CmsUI", ".", "getCmsObject", "(", ")", ";", "try", "{", "CmsResource", "resource", "=", "cms", ".", "readResource", "(", "entry", ".", "getClientEntry", "(", ")", ".", "getId", "(", ")", ",", "CmsResourceFilter", ".", "IGNORE_EXPIRATION", ")", ";", "DialogContext", "context", "=", "new", "DialogContext", "(", "resource", ",", "node", ")", ";", "CmsCopyPageDialog", "dialog", "=", "new", "CmsCopyPageDialog", "(", "context", ")", ";", "String", "title", "=", "CmsVaadinUtils", ".", "getMessageText", "(", "Messages", ".", "GUI_COPYPAGE_DIALOG_TITLE_0", ")", ";", "context", ".", "start", "(", "title", ",", "dialog", ")", ";", "}", "catch", "(", "CmsException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "CmsErrorDialog", ".", "showErrorDialog", "(", "e", ")", ";", "}", "}" ]
Opens the page copy dialog for a tree entry.<p> @param node the tree node widget @param entry the tree entry
[ "Opens", "the", "page", "copy", "dialog", "for", "a", "tree", "entry", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/sitemap/CmsSitemapTreeController.java#L1130-L1145
javagl/CommonUI
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
CheckBoxTree.setSelectionState
private void setSelectionState(Object node, State state, boolean propagate) { """ Set the selection state of the given node @param node The node @param state The state @param propagate Whether the state change should be propagated to its children and ancestor nodes """ Objects.requireNonNull(state, "The state may not be null"); Objects.requireNonNull(node, "The node may not be null"); State oldState = selectionStates.put(node, state); if (!state.equals(oldState)) { fireStateChanged(node, oldState, state); if (propagate) { updateSelection(node); } } repaint(); }
java
private void setSelectionState(Object node, State state, boolean propagate) { Objects.requireNonNull(state, "The state may not be null"); Objects.requireNonNull(node, "The node may not be null"); State oldState = selectionStates.put(node, state); if (!state.equals(oldState)) { fireStateChanged(node, oldState, state); if (propagate) { updateSelection(node); } } repaint(); }
[ "private", "void", "setSelectionState", "(", "Object", "node", ",", "State", "state", ",", "boolean", "propagate", ")", "{", "Objects", ".", "requireNonNull", "(", "state", ",", "\"The state may not be null\"", ")", ";", "Objects", ".", "requireNonNull", "(", "node", ",", "\"The node may not be null\"", ")", ";", "State", "oldState", "=", "selectionStates", ".", "put", "(", "node", ",", "state", ")", ";", "if", "(", "!", "state", ".", "equals", "(", "oldState", ")", ")", "{", "fireStateChanged", "(", "node", ",", "oldState", ",", "state", ")", ";", "if", "(", "propagate", ")", "{", "updateSelection", "(", "node", ")", ";", "}", "}", "repaint", "(", ")", ";", "}" ]
Set the selection state of the given node @param node The node @param state The state @param propagate Whether the state change should be propagated to its children and ancestor nodes
[ "Set", "the", "selection", "state", "of", "the", "given", "node" ]
train
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L256-L270
xcesco/kripton
kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/AnnotationUtility.java
AnnotationUtility.extractAsInt
public static int extractAsInt(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attributeName) { """ Extract as int. @param item the item @param annotationClass the annotation class @param attributeName the attribute name @return the int """ final Elements elementUtils=BaseProcessor.elementUtils; final One<Integer> result = new One<Integer>(); result.value0 = 0; extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() { @Override public void onFound(String value) { result.value0 = Integer.parseInt(value); } }); return result.value0; }
java
public static int extractAsInt(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attributeName) { final Elements elementUtils=BaseProcessor.elementUtils; final One<Integer> result = new One<Integer>(); result.value0 = 0; extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() { @Override public void onFound(String value) { result.value0 = Integer.parseInt(value); } }); return result.value0; }
[ "public", "static", "int", "extractAsInt", "(", "Element", "item", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ",", "AnnotationAttributeType", "attributeName", ")", "{", "final", "Elements", "elementUtils", "=", "BaseProcessor", ".", "elementUtils", ";", "final", "One", "<", "Integer", ">", "result", "=", "new", "One", "<", "Integer", ">", "(", ")", ";", "result", ".", "value0", "=", "0", ";", "extractString", "(", "elementUtils", ",", "item", ",", "annotationClass", ",", "attributeName", ",", "new", "OnAttributeFoundListener", "(", ")", "{", "@", "Override", "public", "void", "onFound", "(", "String", "value", ")", "{", "result", ".", "value0", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}", ")", ";", "return", "result", ".", "value0", ";", "}" ]
Extract as int. @param item the item @param annotationClass the annotation class @param attributeName the attribute name @return the int
[ "Extract", "as", "int", "." ]
train
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/AnnotationUtility.java#L532-L546
stratosphere/stratosphere
stratosphere-core/src/main/java/eu/stratosphere/api/common/operators/DualInputSemanticProperties.java
DualInputSemanticProperties.addForwardedField2
public void addForwardedField2(int sourceField, FieldSet destinationFields) { """ Adds, to the existing information, a field that is forwarded directly from the source record(s) in the second input to multiple fields in the destination record(s). @param sourceField the position in the source record(s) @param destinationFields the position in the destination record(s) """ FieldSet fs; if((fs = this.forwardedFields2.get(sourceField)) != null) { fs.addAll(destinationFields); } else { fs = new FieldSet(destinationFields); this.forwardedFields2.put(sourceField, fs); } }
java
public void addForwardedField2(int sourceField, FieldSet destinationFields) { FieldSet fs; if((fs = this.forwardedFields2.get(sourceField)) != null) { fs.addAll(destinationFields); } else { fs = new FieldSet(destinationFields); this.forwardedFields2.put(sourceField, fs); } }
[ "public", "void", "addForwardedField2", "(", "int", "sourceField", ",", "FieldSet", "destinationFields", ")", "{", "FieldSet", "fs", ";", "if", "(", "(", "fs", "=", "this", ".", "forwardedFields2", ".", "get", "(", "sourceField", ")", ")", "!=", "null", ")", "{", "fs", ".", "addAll", "(", "destinationFields", ")", ";", "}", "else", "{", "fs", "=", "new", "FieldSet", "(", "destinationFields", ")", ";", "this", ".", "forwardedFields2", ".", "put", "(", "sourceField", ",", "fs", ")", ";", "}", "}" ]
Adds, to the existing information, a field that is forwarded directly from the source record(s) in the second input to multiple fields in the destination record(s). @param sourceField the position in the source record(s) @param destinationFields the position in the destination record(s)
[ "Adds", "to", "the", "existing", "information", "a", "field", "that", "is", "forwarded", "directly", "from", "the", "source", "record", "(", "s", ")", "in", "the", "second", "input", "to", "multiple", "fields", "in", "the", "destination", "record", "(", "s", ")", "." ]
train
https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-core/src/main/java/eu/stratosphere/api/common/operators/DualInputSemanticProperties.java#L142-L150
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Session.java
Ssh2Session.requestX11Forwarding
boolean requestX11Forwarding(boolean singleconnection, String protocol, String cookie, int screen) throws SshException { """ Send a request for X Forwarding. @param singleconnection @param protocol @param cookie @param display @return boolean @throws SshException """ ByteArrayWriter request = new ByteArrayWriter(); try { request.writeBoolean(singleconnection); request.writeString(protocol); request.writeString(cookie); request.writeInt(screen); return sendRequest("x11-req", true, request.toByteArray()); } catch (IOException ex) { throw new SshException(ex, SshException.INTERNAL_ERROR); } finally { try { request.close(); } catch (IOException e) { } } }
java
boolean requestX11Forwarding(boolean singleconnection, String protocol, String cookie, int screen) throws SshException { ByteArrayWriter request = new ByteArrayWriter(); try { request.writeBoolean(singleconnection); request.writeString(protocol); request.writeString(cookie); request.writeInt(screen); return sendRequest("x11-req", true, request.toByteArray()); } catch (IOException ex) { throw new SshException(ex, SshException.INTERNAL_ERROR); } finally { try { request.close(); } catch (IOException e) { } } }
[ "boolean", "requestX11Forwarding", "(", "boolean", "singleconnection", ",", "String", "protocol", ",", "String", "cookie", ",", "int", "screen", ")", "throws", "SshException", "{", "ByteArrayWriter", "request", "=", "new", "ByteArrayWriter", "(", ")", ";", "try", "{", "request", ".", "writeBoolean", "(", "singleconnection", ")", ";", "request", ".", "writeString", "(", "protocol", ")", ";", "request", ".", "writeString", "(", "cookie", ")", ";", "request", ".", "writeInt", "(", "screen", ")", ";", "return", "sendRequest", "(", "\"x11-req\"", ",", "true", ",", "request", ".", "toByteArray", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "SshException", "(", "ex", ",", "SshException", ".", "INTERNAL_ERROR", ")", ";", "}", "finally", "{", "try", "{", "request", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}" ]
Send a request for X Forwarding. @param singleconnection @param protocol @param cookie @param display @return boolean @throws SshException
[ "Send", "a", "request", "for", "X", "Forwarding", "." ]
train
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Session.java#L276-L294
phax/ph-bdve
ph-bdve-cii/src/main/java/com/helger/bdve/cii/CIIValidation.java
CIIValidation.initCIID16B
public static void initCIID16B (@Nonnull final ValidationExecutorSetRegistry aRegistry) { """ Register all standard CII D16B validation execution sets to the provided registry. @param aRegistry The registry to add the artefacts. May not be <code>null</code>. """ ValueEnforcer.notNull (aRegistry, "Registry"); // For better error messages LocationBeautifierSPI.addMappings (CIID16BNamespaceContext.getInstance ()); final boolean bNotDeprecated = false; for (final ECIID16BDocumentType e : ECIID16BDocumentType.values ()) { final String sName = e.getLocalName (); final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_D16B); // No Schematrons here aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID, "CII " + sName + " " + VERSION_D16B, bNotDeprecated, ValidationExecutorXSD.create (e))); } }
java
public static void initCIID16B (@Nonnull final ValidationExecutorSetRegistry aRegistry) { ValueEnforcer.notNull (aRegistry, "Registry"); // For better error messages LocationBeautifierSPI.addMappings (CIID16BNamespaceContext.getInstance ()); final boolean bNotDeprecated = false; for (final ECIID16BDocumentType e : ECIID16BDocumentType.values ()) { final String sName = e.getLocalName (); final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_D16B); // No Schematrons here aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID, "CII " + sName + " " + VERSION_D16B, bNotDeprecated, ValidationExecutorXSD.create (e))); } }
[ "public", "static", "void", "initCIID16B", "(", "@", "Nonnull", "final", "ValidationExecutorSetRegistry", "aRegistry", ")", "{", "ValueEnforcer", ".", "notNull", "(", "aRegistry", ",", "\"Registry\"", ")", ";", "// For better error messages", "LocationBeautifierSPI", ".", "addMappings", "(", "CIID16BNamespaceContext", ".", "getInstance", "(", ")", ")", ";", "final", "boolean", "bNotDeprecated", "=", "false", ";", "for", "(", "final", "ECIID16BDocumentType", "e", ":", "ECIID16BDocumentType", ".", "values", "(", ")", ")", "{", "final", "String", "sName", "=", "e", ".", "getLocalName", "(", ")", ";", "final", "VESID", "aVESID", "=", "new", "VESID", "(", "GROUP_ID", ",", "sName", ".", "toLowerCase", "(", "Locale", ".", "US", ")", ",", "VERSION_D16B", ")", ";", "// No Schematrons here", "aRegistry", ".", "registerValidationExecutorSet", "(", "ValidationExecutorSet", ".", "create", "(", "aVESID", ",", "\"CII \"", "+", "sName", "+", "\" \"", "+", "VERSION_D16B", ",", "bNotDeprecated", ",", "ValidationExecutorXSD", ".", "create", "(", "e", ")", ")", ")", ";", "}", "}" ]
Register all standard CII D16B validation execution sets to the provided registry. @param aRegistry The registry to add the artefacts. May not be <code>null</code>.
[ "Register", "all", "standard", "CII", "D16B", "validation", "execution", "sets", "to", "the", "provided", "registry", "." ]
train
https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-cii/src/main/java/com/helger/bdve/cii/CIIValidation.java#L58-L77
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java
GridDialects.getDelegateOrNull
public static <T extends GridDialect> T getDelegateOrNull(GridDialect gridDialect, Class<T> delegateType) { """ Returns that delegate of the given grid dialect of the given type. In case the given dialect itself is of the given type, it will be returned itself. In case the given grid dialect is a {@link ForwardingGridDialect}, its delegates will recursively be searched, until the first delegate of the given type is found. """ if ( gridDialect.getClass() == delegateType ) { return delegateType.cast( gridDialect ); } else if ( gridDialect instanceof ForwardingGridDialect ) { return getDelegateOrNull( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), delegateType ); } else { return null; } }
java
public static <T extends GridDialect> T getDelegateOrNull(GridDialect gridDialect, Class<T> delegateType) { if ( gridDialect.getClass() == delegateType ) { return delegateType.cast( gridDialect ); } else if ( gridDialect instanceof ForwardingGridDialect ) { return getDelegateOrNull( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), delegateType ); } else { return null; } }
[ "public", "static", "<", "T", "extends", "GridDialect", ">", "T", "getDelegateOrNull", "(", "GridDialect", "gridDialect", ",", "Class", "<", "T", ">", "delegateType", ")", "{", "if", "(", "gridDialect", ".", "getClass", "(", ")", "==", "delegateType", ")", "{", "return", "delegateType", ".", "cast", "(", "gridDialect", ")", ";", "}", "else", "if", "(", "gridDialect", "instanceof", "ForwardingGridDialect", ")", "{", "return", "getDelegateOrNull", "(", "(", "(", "ForwardingGridDialect", "<", "?", ">", ")", "gridDialect", ")", ".", "getGridDialect", "(", ")", ",", "delegateType", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns that delegate of the given grid dialect of the given type. In case the given dialect itself is of the given type, it will be returned itself. In case the given grid dialect is a {@link ForwardingGridDialect}, its delegates will recursively be searched, until the first delegate of the given type is found.
[ "Returns", "that", "delegate", "of", "the", "given", "grid", "dialect", "of", "the", "given", "type", ".", "In", "case", "the", "given", "dialect", "itself", "is", "of", "the", "given", "type", "it", "will", "be", "returned", "itself", ".", "In", "case", "the", "given", "grid", "dialect", "is", "a", "{" ]
train
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java#L81-L91
baasbox/Android-SDK
library/src/main/java/com/baasbox/android/BaasDocument.java
BaasDocument.countSync
public static BaasResult<Long> countSync(String collection, BaasQuery.Criteria filter) { """ Synchronously retrieves the number of document readable to the user that match <code>filter</code> in <code>collection</code> @param collection the collection to doCount not <code>null</code> @param filter a filter to apply to the request @return the result of the request """ BaasBox box = BaasBox.getDefaultChecked(); if (collection == null) throw new IllegalArgumentException("collection cannot be null"); filter = filter==null?BaasQuery.builder().count(true).criteria() :filter.buildUpon().count(true).criteria(); Count request = new Count(box, collection, filter, RequestOptions.DEFAULT, null); return box.submitSync(request); }
java
public static BaasResult<Long> countSync(String collection, BaasQuery.Criteria filter) { BaasBox box = BaasBox.getDefaultChecked(); if (collection == null) throw new IllegalArgumentException("collection cannot be null"); filter = filter==null?BaasQuery.builder().count(true).criteria() :filter.buildUpon().count(true).criteria(); Count request = new Count(box, collection, filter, RequestOptions.DEFAULT, null); return box.submitSync(request); }
[ "public", "static", "BaasResult", "<", "Long", ">", "countSync", "(", "String", "collection", ",", "BaasQuery", ".", "Criteria", "filter", ")", "{", "BaasBox", "box", "=", "BaasBox", ".", "getDefaultChecked", "(", ")", ";", "if", "(", "collection", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"collection cannot be null\"", ")", ";", "filter", "=", "filter", "==", "null", "?", "BaasQuery", ".", "builder", "(", ")", ".", "count", "(", "true", ")", ".", "criteria", "(", ")", ":", "filter", ".", "buildUpon", "(", ")", ".", "count", "(", "true", ")", ".", "criteria", "(", ")", ";", "Count", "request", "=", "new", "Count", "(", "box", ",", "collection", ",", "filter", ",", "RequestOptions", ".", "DEFAULT", ",", "null", ")", ";", "return", "box", ".", "submitSync", "(", "request", ")", ";", "}" ]
Synchronously retrieves the number of document readable to the user that match <code>filter</code> in <code>collection</code> @param collection the collection to doCount not <code>null</code> @param filter a filter to apply to the request @return the result of the request
[ "Synchronously", "retrieves", "the", "number", "of", "document", "readable", "to", "the", "user", "that", "match", "<code", ">", "filter<", "/", "code", ">", "in", "<code", ">", "collection<", "/", "code", ">" ]
train
https://github.com/baasbox/Android-SDK/blob/6bb2203246b885b2ad63a7bfaf37c83caf15e0d8/library/src/main/java/com/baasbox/android/BaasDocument.java#L357-L364
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/ShellConsole.java
ShellConsole.getConsole
public static ShellConsole getConsole(InputStream in, PrintStream ps, Charset cs) { """ Returns a new {@link ShellConsole} which uses the supplied {@link InputStream} and {@link PrintStream} for its input/output """ return new SimpleShellConsole(in, ps, cs); }
java
public static ShellConsole getConsole(InputStream in, PrintStream ps, Charset cs) { return new SimpleShellConsole(in, ps, cs); }
[ "public", "static", "ShellConsole", "getConsole", "(", "InputStream", "in", ",", "PrintStream", "ps", ",", "Charset", "cs", ")", "{", "return", "new", "SimpleShellConsole", "(", "in", ",", "ps", ",", "cs", ")", ";", "}" ]
Returns a new {@link ShellConsole} which uses the supplied {@link InputStream} and {@link PrintStream} for its input/output
[ "Returns", "a", "new", "{" ]
train
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/ShellConsole.java#L321-L324
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java
MultipleFieldConverter.setString
public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value { """ Convert and move string to this field. Override this method to convert the String to the actual Physical Data Type. @param strString the state to set the data to. @param bDisplayOption Display the data on the screen if true. @param iMoveMode INIT, SCREEN, or READ move mode. @return The error code (or NORMAL_RETURN). """ m_bSetData = true; // Make sure getNextConverter is called correctly (if it is called). int iErrorCode = super.setString(strString, bDisplayOption, iMoveMode); m_bSetData = false; return iErrorCode; }
java
public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value { m_bSetData = true; // Make sure getNextConverter is called correctly (if it is called). int iErrorCode = super.setString(strString, bDisplayOption, iMoveMode); m_bSetData = false; return iErrorCode; }
[ "public", "int", "setString", "(", "String", "strString", ",", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "// init this field override for other value", "{", "m_bSetData", "=", "true", ";", "// Make sure getNextConverter is called correctly (if it is called).", "int", "iErrorCode", "=", "super", ".", "setString", "(", "strString", ",", "bDisplayOption", ",", "iMoveMode", ")", ";", "m_bSetData", "=", "false", ";", "return", "iErrorCode", ";", "}" ]
Convert and move string to this field. Override this method to convert the String to the actual Physical Data Type. @param strString the state to set the data to. @param bDisplayOption Display the data on the screen if true. @param iMoveMode INIT, SCREEN, or READ move mode. @return The error code (or NORMAL_RETURN).
[ "Convert", "and", "move", "string", "to", "this", "field", ".", "Override", "this", "method", "to", "convert", "the", "String", "to", "the", "actual", "Physical", "Data", "Type", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MultipleFieldConverter.java#L158-L164
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/IDNA.java
IDNA.convertIDNToASCII
@Deprecated public static StringBuffer convertIDNToASCII(StringBuffer src, int options) throws StringPrepParseException { """ IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com". It is important to note that this operation can fail. If it fails, then the input domain name cannot be used as an Internationalized Domain Name and the application should have methods defined to deal with the failure. <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, and then convert. This function does not offer that level of granularity. The options once set will apply to all labels in the domain name @param src The input string as a StringBuffer to be processed @param options A bit set of options: - IDNA.DEFAULT Use default options, i.e., do not process unassigned code points and do not use STD3 ASCII rules If unassigned code points are found the operation fails with ParseException. - IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations If this option is set, the unassigned code points are in the input are treated as normal Unicode code points. - IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions If this option is set and the input does not satisfy STD3 rules, the operation will fail with ParseException @return StringBuffer the converted String @deprecated ICU 55 Use UTS 46 instead via {@link #getUTS46Instance(int)}. @hide original deprecated declaration """ return convertIDNToASCII(src.toString(), options); }
java
@Deprecated public static StringBuffer convertIDNToASCII(StringBuffer src, int options) throws StringPrepParseException{ return convertIDNToASCII(src.toString(), options); }
[ "@", "Deprecated", "public", "static", "StringBuffer", "convertIDNToASCII", "(", "StringBuffer", "src", ",", "int", "options", ")", "throws", "StringPrepParseException", "{", "return", "convertIDNToASCII", "(", "src", ".", "toString", "(", ")", ",", "options", ")", ";", "}" ]
IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com". It is important to note that this operation can fail. If it fails, then the input domain name cannot be used as an Internationalized Domain Name and the application should have methods defined to deal with the failure. <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, and then convert. This function does not offer that level of granularity. The options once set will apply to all labels in the domain name @param src The input string as a StringBuffer to be processed @param options A bit set of options: - IDNA.DEFAULT Use default options, i.e., do not process unassigned code points and do not use STD3 ASCII rules If unassigned code points are found the operation fails with ParseException. - IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations If this option is set, the unassigned code points are in the input are treated as normal Unicode code points. - IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions If this option is set and the input does not satisfy STD3 rules, the operation will fail with ParseException @return StringBuffer the converted String @deprecated ICU 55 Use UTS 46 instead via {@link #getUTS46Instance(int)}. @hide original deprecated declaration
[ "IDNA2003", ":", "Convenience", "function", "that", "implements", "the", "IDNToASCII", "operation", "as", "defined", "in", "the", "IDNA", "RFC", ".", "This", "operation", "is", "done", "on", "complete", "domain", "names", "e", ".", "g", ":", "www", ".", "example", ".", "com", ".", "It", "is", "important", "to", "note", "that", "this", "operation", "can", "fail", ".", "If", "it", "fails", "then", "the", "input", "domain", "name", "cannot", "be", "used", "as", "an", "Internationalized", "Domain", "Name", "and", "the", "application", "should", "have", "methods", "defined", "to", "deal", "with", "the", "failure", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/IDNA.java#L615-L619
Azure/azure-sdk-for-java
network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java
VirtualHubsInner.beginCreateOrUpdateAsync
public Observable<VirtualHubInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualHubName, VirtualHubInner virtualHubParameters) { """ Creates a VirtualHub resource if it doesn't exist else updates the existing VirtualHub. @param resourceGroupName The resource group name of the VirtualHub. @param virtualHubName The name of the VirtualHub. @param virtualHubParameters Parameters supplied to create or update VirtualHub. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the VirtualHubInner object """ return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualHubName, virtualHubParameters).map(new Func1<ServiceResponse<VirtualHubInner>, VirtualHubInner>() { @Override public VirtualHubInner call(ServiceResponse<VirtualHubInner> response) { return response.body(); } }); }
java
public Observable<VirtualHubInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualHubName, VirtualHubInner virtualHubParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualHubName, virtualHubParameters).map(new Func1<ServiceResponse<VirtualHubInner>, VirtualHubInner>() { @Override public VirtualHubInner call(ServiceResponse<VirtualHubInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "VirtualHubInner", ">", "beginCreateOrUpdateAsync", "(", "String", "resourceGroupName", ",", "String", "virtualHubName", ",", "VirtualHubInner", "virtualHubParameters", ")", "{", "return", "beginCreateOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "virtualHubName", ",", "virtualHubParameters", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "VirtualHubInner", ">", ",", "VirtualHubInner", ">", "(", ")", "{", "@", "Override", "public", "VirtualHubInner", "call", "(", "ServiceResponse", "<", "VirtualHubInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Creates a VirtualHub resource if it doesn't exist else updates the existing VirtualHub. @param resourceGroupName The resource group name of the VirtualHub. @param virtualHubName The name of the VirtualHub. @param virtualHubParameters Parameters supplied to create or update VirtualHub. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the VirtualHubInner object
[ "Creates", "a", "VirtualHub", "resource", "if", "it", "doesn", "t", "exist", "else", "updates", "the", "existing", "VirtualHub", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java#L313-L320
aws/aws-sdk-java
aws-java-sdk-secretsmanager/src/main/java/com/amazonaws/services/secretsmanager/model/DescribeSecretResult.java
DescribeSecretResult.setVersionIdsToStages
public void setVersionIdsToStages(java.util.Map<String, java.util.List<String>> versionIdsToStages) { """ <p> A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different versions during the rotation process. </p> <note> <p> A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such versions are not included in this list. </p> </note> @param versionIdsToStages A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different versions during the rotation process.</p> <note> <p> A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such versions are not included in this list. </p> """ this.versionIdsToStages = versionIdsToStages; }
java
public void setVersionIdsToStages(java.util.Map<String, java.util.List<String>> versionIdsToStages) { this.versionIdsToStages = versionIdsToStages; }
[ "public", "void", "setVersionIdsToStages", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "java", ".", "util", ".", "List", "<", "String", ">", ">", "versionIdsToStages", ")", "{", "this", ".", "versionIdsToStages", "=", "versionIdsToStages", ";", "}" ]
<p> A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different versions during the rotation process. </p> <note> <p> A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such versions are not included in this list. </p> </note> @param versionIdsToStages A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different versions during the rotation process.</p> <note> <p> A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such versions are not included in this list. </p>
[ "<p", ">", "A", "list", "of", "all", "of", "the", "currently", "assigned", "<code", ">", "VersionStage<", "/", "code", ">", "staging", "labels", "and", "the", "<code", ">", "VersionId<", "/", "code", ">", "that", "each", "is", "attached", "to", ".", "Staging", "labels", "are", "used", "to", "keep", "track", "of", "the", "different", "versions", "during", "the", "rotation", "process", ".", "<", "/", "p", ">", "<note", ">", "<p", ">", "A", "version", "that", "does", "not", "have", "any", "staging", "labels", "attached", "is", "considered", "deprecated", "and", "subject", "to", "deletion", ".", "Such", "versions", "are", "not", "included", "in", "this", "list", ".", "<", "/", "p", ">", "<", "/", "note", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-secretsmanager/src/main/java/com/amazonaws/services/secretsmanager/model/DescribeSecretResult.java#L799-L801
alkacon/opencms-core
src/org/opencms/xml/content/CmsXmlContentPropertyHelper.java
CmsXmlContentPropertyHelper.getMacroResolverForProperties
public static CmsMacroResolver getMacroResolverForProperties( final CmsObject cms, final I_CmsXmlContentHandler contentHandler, final CmsXmlContent content, final Function<String, String> stringtemplateSource, final CmsResource containerPage) { """ Creates and configures a new macro resolver for resolving macros which occur in property definitions.<p> @param cms the CMS context @param contentHandler the content handler which contains the message bundle that should be available in the macro resolver @param content the XML content object @param stringtemplateSource provides stringtemplate templates for use in %(stringtemplate:...) macros @param containerPage the current container page @return a new macro resolver """ Locale locale = OpenCms.getLocaleManager().getBestAvailableLocaleForXmlContent(cms, content.getFile(), content); final CmsGalleryNameMacroResolver resolver = new CmsGalleryNameMacroResolver(cms, content, locale) { @SuppressWarnings("synthetic-access") @Override public String getMacroValue(String macro) { if (macro.startsWith(PAGE_PROPERTY_PREFIX)) { String remainder = macro.substring(PAGE_PROPERTY_PREFIX.length()); int secondColonPos = remainder.indexOf(":"); String defaultValue = ""; String propName = null; if (secondColonPos >= 0) { propName = remainder.substring(0, secondColonPos); defaultValue = remainder.substring(secondColonPos + 1); } else { propName = remainder; } if (containerPage != null) { try { CmsProperty prop = cms.readPropertyObject(containerPage, propName, true); String propValue = prop.getValue(); if ((propValue == null) || PROPERTY_EMPTY_MARKER.equals(propValue)) { propValue = defaultValue; } return propValue; } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); return defaultValue; } } } return super.getMacroValue(macro); } }; resolver.setStringTemplateSource(stringtemplateSource); Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms); CmsMultiMessages messages = new CmsMultiMessages(wpLocale); messages.addMessages(OpenCms.getWorkplaceManager().getMessages(wpLocale)); messages.addMessages(content.getContentDefinition().getContentHandler().getMessages(wpLocale)); resolver.setCmsObject(cms); resolver.setKeepEmptyMacros(true); resolver.setMessages(messages); return resolver; }
java
public static CmsMacroResolver getMacroResolverForProperties( final CmsObject cms, final I_CmsXmlContentHandler contentHandler, final CmsXmlContent content, final Function<String, String> stringtemplateSource, final CmsResource containerPage) { Locale locale = OpenCms.getLocaleManager().getBestAvailableLocaleForXmlContent(cms, content.getFile(), content); final CmsGalleryNameMacroResolver resolver = new CmsGalleryNameMacroResolver(cms, content, locale) { @SuppressWarnings("synthetic-access") @Override public String getMacroValue(String macro) { if (macro.startsWith(PAGE_PROPERTY_PREFIX)) { String remainder = macro.substring(PAGE_PROPERTY_PREFIX.length()); int secondColonPos = remainder.indexOf(":"); String defaultValue = ""; String propName = null; if (secondColonPos >= 0) { propName = remainder.substring(0, secondColonPos); defaultValue = remainder.substring(secondColonPos + 1); } else { propName = remainder; } if (containerPage != null) { try { CmsProperty prop = cms.readPropertyObject(containerPage, propName, true); String propValue = prop.getValue(); if ((propValue == null) || PROPERTY_EMPTY_MARKER.equals(propValue)) { propValue = defaultValue; } return propValue; } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); return defaultValue; } } } return super.getMacroValue(macro); } }; resolver.setStringTemplateSource(stringtemplateSource); Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms); CmsMultiMessages messages = new CmsMultiMessages(wpLocale); messages.addMessages(OpenCms.getWorkplaceManager().getMessages(wpLocale)); messages.addMessages(content.getContentDefinition().getContentHandler().getMessages(wpLocale)); resolver.setCmsObject(cms); resolver.setKeepEmptyMacros(true); resolver.setMessages(messages); return resolver; }
[ "public", "static", "CmsMacroResolver", "getMacroResolverForProperties", "(", "final", "CmsObject", "cms", ",", "final", "I_CmsXmlContentHandler", "contentHandler", ",", "final", "CmsXmlContent", "content", ",", "final", "Function", "<", "String", ",", "String", ">", "stringtemplateSource", ",", "final", "CmsResource", "containerPage", ")", "{", "Locale", "locale", "=", "OpenCms", ".", "getLocaleManager", "(", ")", ".", "getBestAvailableLocaleForXmlContent", "(", "cms", ",", "content", ".", "getFile", "(", ")", ",", "content", ")", ";", "final", "CmsGalleryNameMacroResolver", "resolver", "=", "new", "CmsGalleryNameMacroResolver", "(", "cms", ",", "content", ",", "locale", ")", "{", "@", "SuppressWarnings", "(", "\"synthetic-access\"", ")", "@", "Override", "public", "String", "getMacroValue", "(", "String", "macro", ")", "{", "if", "(", "macro", ".", "startsWith", "(", "PAGE_PROPERTY_PREFIX", ")", ")", "{", "String", "remainder", "=", "macro", ".", "substring", "(", "PAGE_PROPERTY_PREFIX", ".", "length", "(", ")", ")", ";", "int", "secondColonPos", "=", "remainder", ".", "indexOf", "(", "\":\"", ")", ";", "String", "defaultValue", "=", "\"\"", ";", "String", "propName", "=", "null", ";", "if", "(", "secondColonPos", ">=", "0", ")", "{", "propName", "=", "remainder", ".", "substring", "(", "0", ",", "secondColonPos", ")", ";", "defaultValue", "=", "remainder", ".", "substring", "(", "secondColonPos", "+", "1", ")", ";", "}", "else", "{", "propName", "=", "remainder", ";", "}", "if", "(", "containerPage", "!=", "null", ")", "{", "try", "{", "CmsProperty", "prop", "=", "cms", ".", "readPropertyObject", "(", "containerPage", ",", "propName", ",", "true", ")", ";", "String", "propValue", "=", "prop", ".", "getValue", "(", ")", ";", "if", "(", "(", "propValue", "==", "null", ")", "||", "PROPERTY_EMPTY_MARKER", ".", "equals", "(", "propValue", ")", ")", "{", "propValue", "=", "defaultValue", ";", "}", "return", "propValue", ";", "}", "catch", "(", "CmsException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "return", "defaultValue", ";", "}", "}", "}", "return", "super", ".", "getMacroValue", "(", "macro", ")", ";", "}", "}", ";", "resolver", ".", "setStringTemplateSource", "(", "stringtemplateSource", ")", ";", "Locale", "wpLocale", "=", "OpenCms", ".", "getWorkplaceManager", "(", ")", ".", "getWorkplaceLocale", "(", "cms", ")", ";", "CmsMultiMessages", "messages", "=", "new", "CmsMultiMessages", "(", "wpLocale", ")", ";", "messages", ".", "addMessages", "(", "OpenCms", ".", "getWorkplaceManager", "(", ")", ".", "getMessages", "(", "wpLocale", ")", ")", ";", "messages", ".", "addMessages", "(", "content", ".", "getContentDefinition", "(", ")", ".", "getContentHandler", "(", ")", ".", "getMessages", "(", "wpLocale", ")", ")", ";", "resolver", ".", "setCmsObject", "(", "cms", ")", ";", "resolver", ".", "setKeepEmptyMacros", "(", "true", ")", ";", "resolver", ".", "setMessages", "(", "messages", ")", ";", "return", "resolver", ";", "}" ]
Creates and configures a new macro resolver for resolving macros which occur in property definitions.<p> @param cms the CMS context @param contentHandler the content handler which contains the message bundle that should be available in the macro resolver @param content the XML content object @param stringtemplateSource provides stringtemplate templates for use in %(stringtemplate:...) macros @param containerPage the current container page @return a new macro resolver
[ "Creates", "and", "configures", "a", "new", "macro", "resolver", "for", "resolving", "macros", "which", "occur", "in", "property", "definitions", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsXmlContentPropertyHelper.java#L214-L268
xcesco/kripton
kripton/src/main/java/com/abubusoft/kripton/xml/XMLSerializer.java
XMLSerializer.setFeature
public void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException { """ Sets the feature. @param name the name @param state the state @throws IllegalArgumentException the illegal argument exception @throws IllegalStateException the illegal state exception """ if (name == null) { throw new IllegalArgumentException("feature name can not be null"); } if (FEATURE_NAMES_INTERNED.equals(name)) { namesInterned = state; } else if (FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals(name)) { attributeUseApostrophe = state; } else { throw new IllegalStateException("unsupported feature " + name); } }
java
public void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException { if (name == null) { throw new IllegalArgumentException("feature name can not be null"); } if (FEATURE_NAMES_INTERNED.equals(name)) { namesInterned = state; } else if (FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals(name)) { attributeUseApostrophe = state; } else { throw new IllegalStateException("unsupported feature " + name); } }
[ "public", "void", "setFeature", "(", "String", "name", ",", "boolean", "state", ")", "throws", "IllegalArgumentException", ",", "IllegalStateException", "{", "if", "(", "name", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"feature name can not be null\"", ")", ";", "}", "if", "(", "FEATURE_NAMES_INTERNED", ".", "equals", "(", "name", ")", ")", "{", "namesInterned", "=", "state", ";", "}", "else", "if", "(", "FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE", ".", "equals", "(", "name", ")", ")", "{", "attributeUseApostrophe", "=", "state", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"unsupported feature \"", "+", "name", ")", ";", "}", "}" ]
Sets the feature. @param name the name @param state the state @throws IllegalArgumentException the illegal argument exception @throws IllegalStateException the illegal state exception
[ "Sets", "the", "feature", "." ]
train
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton/src/main/java/com/abubusoft/kripton/xml/XMLSerializer.java#L328-L339
kaazing/gateway
mina.netty/src/main/java/org/kaazing/mina/core/future/DefaultBindFuture.java
DefaultBindFuture.combineFutures
public static BindFuture combineFutures(BindFuture future1, BindFuture future2) { """ Combine futures in a way that minimizes cost(no object creation) for the common case where both have already been fulfilled. """ if (future1 == null || future1.isBound()) { return future2; } else if (future2 == null || future2.isBound()) { return future1; } else { return new CompositeBindFuture(Arrays.asList(future1, future2)); } }
java
public static BindFuture combineFutures(BindFuture future1, BindFuture future2) { if (future1 == null || future1.isBound()) { return future2; } else if (future2 == null || future2.isBound()) { return future1; } else { return new CompositeBindFuture(Arrays.asList(future1, future2)); } }
[ "public", "static", "BindFuture", "combineFutures", "(", "BindFuture", "future1", ",", "BindFuture", "future2", ")", "{", "if", "(", "future1", "==", "null", "||", "future1", ".", "isBound", "(", ")", ")", "{", "return", "future2", ";", "}", "else", "if", "(", "future2", "==", "null", "||", "future2", ".", "isBound", "(", ")", ")", "{", "return", "future1", ";", "}", "else", "{", "return", "new", "CompositeBindFuture", "(", "Arrays", ".", "asList", "(", "future1", ",", "future2", ")", ")", ";", "}", "}" ]
Combine futures in a way that minimizes cost(no object creation) for the common case where both have already been fulfilled.
[ "Combine", "futures", "in", "a", "way", "that", "minimizes", "cost", "(", "no", "object", "creation", ")", "for", "the", "common", "case", "where", "both", "have", "already", "been", "fulfilled", "." ]
train
https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.netty/src/main/java/org/kaazing/mina/core/future/DefaultBindFuture.java#L44-L54
goldmansachs/gs-collections
collections/src/main/java/com/gs/collections/impl/utility/Iterate.java
Iterate.forEach
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure) { """ The procedure is evaluated for each element of the iterable. <p> Example using a Java 8 lambda expression: <pre> Iterate.<b>forEach</b>(people, person -> LOGGER.info(person.getName()); </pre> <p> Example using an anonymous inner class: <pre> Iterate.<b>forEach</b>(people, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } }); </pre> """ if (iterable instanceof InternalIterable) { ((InternalIterable<T>) iterable).forEach(procedure); } else if (iterable instanceof ArrayList) { ArrayListIterate.forEach((ArrayList<T>) iterable, procedure); } else if (iterable instanceof List) { ListIterate.forEach((List<T>) iterable, procedure); } else if (iterable != null) { IterableIterate.forEach(iterable, procedure); } else { throw new IllegalArgumentException("Cannot perform a forEach on null"); } }
java
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure) { if (iterable instanceof InternalIterable) { ((InternalIterable<T>) iterable).forEach(procedure); } else if (iterable instanceof ArrayList) { ArrayListIterate.forEach((ArrayList<T>) iterable, procedure); } else if (iterable instanceof List) { ListIterate.forEach((List<T>) iterable, procedure); } else if (iterable != null) { IterableIterate.forEach(iterable, procedure); } else { throw new IllegalArgumentException("Cannot perform a forEach on null"); } }
[ "public", "static", "<", "T", ">", "void", "forEach", "(", "Iterable", "<", "T", ">", "iterable", ",", "Procedure", "<", "?", "super", "T", ">", "procedure", ")", "{", "if", "(", "iterable", "instanceof", "InternalIterable", ")", "{", "(", "(", "InternalIterable", "<", "T", ">", ")", "iterable", ")", ".", "forEach", "(", "procedure", ")", ";", "}", "else", "if", "(", "iterable", "instanceof", "ArrayList", ")", "{", "ArrayListIterate", ".", "forEach", "(", "(", "ArrayList", "<", "T", ">", ")", "iterable", ",", "procedure", ")", ";", "}", "else", "if", "(", "iterable", "instanceof", "List", ")", "{", "ListIterate", ".", "forEach", "(", "(", "List", "<", "T", ">", ")", "iterable", ",", "procedure", ")", ";", "}", "else", "if", "(", "iterable", "!=", "null", ")", "{", "IterableIterate", ".", "forEach", "(", "iterable", ",", "procedure", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot perform a forEach on null\"", ")", ";", "}", "}" ]
The procedure is evaluated for each element of the iterable. <p> Example using a Java 8 lambda expression: <pre> Iterate.<b>forEach</b>(people, person -> LOGGER.info(person.getName()); </pre> <p> Example using an anonymous inner class: <pre> Iterate.<b>forEach</b>(people, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } }); </pre>
[ "The", "procedure", "is", "evaluated", "for", "each", "element", "of", "the", "iterable", ".", "<p", ">", "Example", "using", "a", "Java", "8", "lambda", "expression", ":", "<pre", ">", "Iterate", ".", "<b", ">", "forEach<", "/", "b", ">", "(", "people", "person", "-", ">", "LOGGER", ".", "info", "(", "person", ".", "getName", "()", ")", ";", "<", "/", "pre", ">", "<p", ">", "Example", "using", "an", "anonymous", "inner", "class", ":", "<pre", ">", "Iterate", ".", "<b", ">", "forEach<", "/", "b", ">", "(", "people", "new", "Procedure<Person", ">", "()", "{", "public", "void", "value", "(", "Person", "person", ")", "{", "LOGGER", ".", "info", "(", "person", ".", "getName", "()", ")", ";", "}", "}", ")", ";", "<", "/", "pre", ">" ]
train
https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/Iterate.java#L125-L147
Mozu/mozu-java
mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/attributedefinition/producttypes/ProductTypeOptionUrl.java
ProductTypeOptionUrl.addOptionUrl
public static MozuUrl addOptionUrl(Integer productTypeId, String responseFields) { """ Get Resource Url for AddOption @param productTypeId Identifier of the product type. @param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss. @return String Resource Url """ UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/attributedefinition/producttypes/{productTypeId}/Options?responseFields={responseFields}"); formatter.formatUrl("productTypeId", productTypeId); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
java
public static MozuUrl addOptionUrl(Integer productTypeId, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/attributedefinition/producttypes/{productTypeId}/Options?responseFields={responseFields}"); formatter.formatUrl("productTypeId", productTypeId); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
[ "public", "static", "MozuUrl", "addOptionUrl", "(", "Integer", "productTypeId", ",", "String", "responseFields", ")", "{", "UrlFormatter", "formatter", "=", "new", "UrlFormatter", "(", "\"/api/commerce/catalog/admin/attributedefinition/producttypes/{productTypeId}/Options?responseFields={responseFields}\"", ")", ";", "formatter", ".", "formatUrl", "(", "\"productTypeId\"", ",", "productTypeId", ")", ";", "formatter", ".", "formatUrl", "(", "\"responseFields\"", ",", "responseFields", ")", ";", "return", "new", "MozuUrl", "(", "formatter", ".", "getResourceUrl", "(", ")", ",", "MozuUrl", ".", "UrlLocation", ".", "TENANT_POD", ")", ";", "}" ]
Get Resource Url for AddOption @param productTypeId Identifier of the product type. @param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss. @return String Resource Url
[ "Get", "Resource", "Url", "for", "AddOption" ]
train
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/attributedefinition/producttypes/ProductTypeOptionUrl.java#L50-L56
zeroturnaround/zt-zip
src/main/java/org/zeroturnaround/zip/ZipUtil.java
ZipUtil.transformEntry
public static boolean transformEntry(InputStream is, String path, ZipEntryTransformer transformer, OutputStream os) { """ Copies an existing ZIP file and transforms a given entry in it. @param is a ZIP input stream. @param path new ZIP entry path. @param transformer transformer for the given ZIP entry. @param os a ZIP output stream. @return <code>true</code> if the entry was replaced. """ return transformEntry(is, new ZipEntryTransformerEntry(path, transformer), os); }
java
public static boolean transformEntry(InputStream is, String path, ZipEntryTransformer transformer, OutputStream os) { return transformEntry(is, new ZipEntryTransformerEntry(path, transformer), os); }
[ "public", "static", "boolean", "transformEntry", "(", "InputStream", "is", ",", "String", "path", ",", "ZipEntryTransformer", "transformer", ",", "OutputStream", "os", ")", "{", "return", "transformEntry", "(", "is", ",", "new", "ZipEntryTransformerEntry", "(", "path", ",", "transformer", ")", ",", "os", ")", ";", "}" ]
Copies an existing ZIP file and transforms a given entry in it. @param is a ZIP input stream. @param path new ZIP entry path. @param transformer transformer for the given ZIP entry. @param os a ZIP output stream. @return <code>true</code> if the entry was replaced.
[ "Copies", "an", "existing", "ZIP", "file", "and", "transforms", "a", "given", "entry", "in", "it", "." ]
train
https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L2895-L2897
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/refactoring/rename/EcorePackageRenameStrategy.java
EcorePackageRenameStrategy.getDeclarationTextEdit
protected TextEdit getDeclarationTextEdit(String newName, ResourceSet resourceSet) { """ Replies the text update for the rename. @param newName the new package name. @param resourceSet the set of resources. @return the text update. """ final EObject object = resourceSet.getEObject(this.uriProvider.apply(resourceSet), true); if (object instanceof SarlScript) { final ITextRegion region = getOriginalPackageRegion((SarlScript) object); if (region != null) { return new ReplaceEdit(region.getOffset(), region.getLength(), newName); } } throw new RefactoringException("SARL script not loaded."); //$NON-NLS-1$ }
java
protected TextEdit getDeclarationTextEdit(String newName, ResourceSet resourceSet) { final EObject object = resourceSet.getEObject(this.uriProvider.apply(resourceSet), true); if (object instanceof SarlScript) { final ITextRegion region = getOriginalPackageRegion((SarlScript) object); if (region != null) { return new ReplaceEdit(region.getOffset(), region.getLength(), newName); } } throw new RefactoringException("SARL script not loaded."); //$NON-NLS-1$ }
[ "protected", "TextEdit", "getDeclarationTextEdit", "(", "String", "newName", ",", "ResourceSet", "resourceSet", ")", "{", "final", "EObject", "object", "=", "resourceSet", ".", "getEObject", "(", "this", ".", "uriProvider", ".", "apply", "(", "resourceSet", ")", ",", "true", ")", ";", "if", "(", "object", "instanceof", "SarlScript", ")", "{", "final", "ITextRegion", "region", "=", "getOriginalPackageRegion", "(", "(", "SarlScript", ")", "object", ")", ";", "if", "(", "region", "!=", "null", ")", "{", "return", "new", "ReplaceEdit", "(", "region", ".", "getOffset", "(", ")", ",", "region", ".", "getLength", "(", ")", ",", "newName", ")", ";", "}", "}", "throw", "new", "RefactoringException", "(", "\"SARL script not loaded.\"", ")", ";", "//$NON-NLS-1$", "}" ]
Replies the text update for the rename. @param newName the new package name. @param resourceSet the set of resources. @return the text update.
[ "Replies", "the", "text", "update", "for", "the", "rename", "." ]
train
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/refactoring/rename/EcorePackageRenameStrategy.java#L138-L147
bazaarvoice/emodb
sor/src/main/java/com/bazaarvoice/emodb/sor/db/ScanRange.java
ScanRange.unwrapped
public List<ScanRange> unwrapped() { """ If necessary splits the scan range into two range such that "from" is less than "to" in each range. This is necessary if the scan range wraps the token range. """ if (compare(_from, _to) < 0) { return ImmutableList.of(this); } ImmutableList.Builder<ScanRange> ranges = ImmutableList.builder(); if (compare(_from, MAX_VALUE) < 0) { ranges.add(new ScanRange(_from, MAX_VALUE)); } if (compare(_to, MIN_VALUE) > 0) { ranges.add(new ScanRange(MIN_VALUE, _to)); } return ranges.build(); }
java
public List<ScanRange> unwrapped() { if (compare(_from, _to) < 0) { return ImmutableList.of(this); } ImmutableList.Builder<ScanRange> ranges = ImmutableList.builder(); if (compare(_from, MAX_VALUE) < 0) { ranges.add(new ScanRange(_from, MAX_VALUE)); } if (compare(_to, MIN_VALUE) > 0) { ranges.add(new ScanRange(MIN_VALUE, _to)); } return ranges.build(); }
[ "public", "List", "<", "ScanRange", ">", "unwrapped", "(", ")", "{", "if", "(", "compare", "(", "_from", ",", "_to", ")", "<", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", "this", ")", ";", "}", "ImmutableList", ".", "Builder", "<", "ScanRange", ">", "ranges", "=", "ImmutableList", ".", "builder", "(", ")", ";", "if", "(", "compare", "(", "_from", ",", "MAX_VALUE", ")", "<", "0", ")", "{", "ranges", ".", "add", "(", "new", "ScanRange", "(", "_from", ",", "MAX_VALUE", ")", ")", ";", "}", "if", "(", "compare", "(", "_to", ",", "MIN_VALUE", ")", ">", "0", ")", "{", "ranges", ".", "add", "(", "new", "ScanRange", "(", "MIN_VALUE", ",", "_to", ")", ")", ";", "}", "return", "ranges", ".", "build", "(", ")", ";", "}" ]
If necessary splits the scan range into two range such that "from" is less than "to" in each range. This is necessary if the scan range wraps the token range.
[ "If", "necessary", "splits", "the", "scan", "range", "into", "two", "range", "such", "that", "from", "is", "less", "than", "to", "in", "each", "range", ".", "This", "is", "necessary", "if", "the", "scan", "range", "wraps", "the", "token", "range", "." ]
train
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/sor/src/main/java/com/bazaarvoice/emodb/sor/db/ScanRange.java#L88-L100
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java
FrequencySketch.incrementAt
private boolean incrementAt(int i, int j) { """ Increments the specified counter by 1 if it is not already at the maximum value (15). @param i the table index (16 counters) @param j the counter to increment @return if incremented """ int offset = j << 2; long mask = (0xfL << offset); long t = tableAt(i); if ((t & mask) != mask) { tableAt(i, t + (1L << offset)); return true; } return false; }
java
private boolean incrementAt(int i, int j) { int offset = j << 2; long mask = (0xfL << offset); long t = tableAt(i); if ((t & mask) != mask) { tableAt(i, t + (1L << offset)); return true; } return false; }
[ "private", "boolean", "incrementAt", "(", "int", "i", ",", "int", "j", ")", "{", "int", "offset", "=", "j", "<<", "2", ";", "long", "mask", "=", "(", "0xf", "L", "<<", "offset", ")", ";", "long", "t", "=", "tableAt", "(", "i", ")", ";", "if", "(", "(", "t", "&", "mask", ")", "!=", "mask", ")", "{", "tableAt", "(", "i", ",", "t", "+", "(", "1L", "<<", "offset", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Increments the specified counter by 1 if it is not already at the maximum value (15). @param i the table index (16 counters) @param j the counter to increment @return if incremented
[ "Increments", "the", "specified", "counter", "by", "1", "if", "it", "is", "not", "already", "at", "the", "maximum", "value", "(", "15", ")", "." ]
train
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java#L181-L192
matthewhorridge/owlapi-gwt
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLImportsDeclarationImpl_CustomFieldSerializer.java
OWLImportsDeclarationImpl_CustomFieldSerializer.serializeInstance
@Override public void serializeInstance(SerializationStreamWriter streamWriter, OWLImportsDeclarationImpl instance) throws SerializationException { """ Serializes the content of the object into the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter}. @param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the object's content to @param instance the object instance to serialize @throws com.google.gwt.user.client.rpc.SerializationException if the serialization operation is not successful """ serialize(streamWriter, instance); }
java
@Override public void serializeInstance(SerializationStreamWriter streamWriter, OWLImportsDeclarationImpl instance) throws SerializationException { serialize(streamWriter, instance); }
[ "@", "Override", "public", "void", "serializeInstance", "(", "SerializationStreamWriter", "streamWriter", ",", "OWLImportsDeclarationImpl", "instance", ")", "throws", "SerializationException", "{", "serialize", "(", "streamWriter", ",", "instance", ")", ";", "}" ]
Serializes the content of the object into the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter}. @param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the object's content to @param instance the object instance to serialize @throws com.google.gwt.user.client.rpc.SerializationException if the serialization operation is not successful
[ "Serializes", "the", "content", "of", "the", "object", "into", "the", "{" ]
train
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLImportsDeclarationImpl_CustomFieldSerializer.java#L63-L66
taimos/GPSd4Java
src/main/java/de/taimos/gpsd4java/backend/GISTool.java
GISTool.getDistance
public static double getDistance(final double x1, final double x2, final double y1, final double y2) { """ calculates the distance between two locations, which are given as coordinates, in kilometers<br> the method used is the great-circle-distance with hypersine formula @param x1 - longitude of position 1 @param x2 - longitude of position 2 @param y1 - latitude of position 1 @param y2 - latitude of position 2 @return distance in kilometers """ // transform to radian final double deg2rad = Math.PI / 180; final double x1rad = x1 * deg2rad; final double x2rad = x2 * deg2rad; final double y1rad = y1 * deg2rad; final double y2rad = y2 * deg2rad; // great-circle-distance with hypersine formula final double dlong = x1rad - x2rad; final double dlat = y1rad - y2rad; final double a = Math.pow(Math.sin(dlat / 2), 2) + (Math.cos(y1rad) * Math.cos(y2rad) * Math.pow(Math.sin(dlong / 2), 2)); final double c = 2 * Math.asin(Math.sqrt(a)); return GISTool.EARTH_RADIUS_KILOMETERS * c; }
java
public static double getDistance(final double x1, final double x2, final double y1, final double y2) { // transform to radian final double deg2rad = Math.PI / 180; final double x1rad = x1 * deg2rad; final double x2rad = x2 * deg2rad; final double y1rad = y1 * deg2rad; final double y2rad = y2 * deg2rad; // great-circle-distance with hypersine formula final double dlong = x1rad - x2rad; final double dlat = y1rad - y2rad; final double a = Math.pow(Math.sin(dlat / 2), 2) + (Math.cos(y1rad) * Math.cos(y2rad) * Math.pow(Math.sin(dlong / 2), 2)); final double c = 2 * Math.asin(Math.sqrt(a)); return GISTool.EARTH_RADIUS_KILOMETERS * c; }
[ "public", "static", "double", "getDistance", "(", "final", "double", "x1", ",", "final", "double", "x2", ",", "final", "double", "y1", ",", "final", "double", "y2", ")", "{", "// transform to radian", "final", "double", "deg2rad", "=", "Math", ".", "PI", "/", "180", ";", "final", "double", "x1rad", "=", "x1", "*", "deg2rad", ";", "final", "double", "x2rad", "=", "x2", "*", "deg2rad", ";", "final", "double", "y1rad", "=", "y1", "*", "deg2rad", ";", "final", "double", "y2rad", "=", "y2", "*", "deg2rad", ";", "// great-circle-distance with hypersine formula", "final", "double", "dlong", "=", "x1rad", "-", "x2rad", ";", "final", "double", "dlat", "=", "y1rad", "-", "y2rad", ";", "final", "double", "a", "=", "Math", ".", "pow", "(", "Math", ".", "sin", "(", "dlat", "/", "2", ")", ",", "2", ")", "+", "(", "Math", ".", "cos", "(", "y1rad", ")", "*", "Math", ".", "cos", "(", "y2rad", ")", "*", "Math", ".", "pow", "(", "Math", ".", "sin", "(", "dlong", "/", "2", ")", ",", "2", ")", ")", ";", "final", "double", "c", "=", "2", "*", "Math", ".", "asin", "(", "Math", ".", "sqrt", "(", "a", ")", ")", ";", "return", "GISTool", ".", "EARTH_RADIUS_KILOMETERS", "*", "c", ";", "}" ]
calculates the distance between two locations, which are given as coordinates, in kilometers<br> the method used is the great-circle-distance with hypersine formula @param x1 - longitude of position 1 @param x2 - longitude of position 2 @param y1 - latitude of position 1 @param y2 - latitude of position 2 @return distance in kilometers
[ "calculates", "the", "distance", "between", "two", "locations", "which", "are", "given", "as", "coordinates", "in", "kilometers<br", ">", "the", "method", "used", "is", "the", "great", "-", "circle", "-", "distance", "with", "hypersine", "formula" ]
train
https://github.com/taimos/GPSd4Java/blob/f3bdfcc5eed628417ea72bf20d108519f24d105b/src/main/java/de/taimos/gpsd4java/backend/GISTool.java#L60-L76
moparisthebest/beehive
beehive-controls/src/main/java/org/apache/beehive/controls/runtime/bean/ControlBean.java
ControlBean.preInvoke
protected void preInvoke(Method m, Object [] args) { """ The preinvoke method is called before all operations on the control. It is the basic hook for logging, context initialization, resource management, and other common services """ try { preInvoke(m, args, null); } catch (InterceptorPivotException ipe) { //this will never happen because no interceptor is passed. } }
java
protected void preInvoke(Method m, Object [] args) { try { preInvoke(m, args, null); } catch (InterceptorPivotException ipe) { //this will never happen because no interceptor is passed. } }
[ "protected", "void", "preInvoke", "(", "Method", "m", ",", "Object", "[", "]", "args", ")", "{", "try", "{", "preInvoke", "(", "m", ",", "args", ",", "null", ")", ";", "}", "catch", "(", "InterceptorPivotException", "ipe", ")", "{", "//this will never happen because no interceptor is passed.", "}", "}" ]
The preinvoke method is called before all operations on the control. It is the basic hook for logging, context initialization, resource management, and other common services
[ "The", "preinvoke", "method", "is", "called", "before", "all", "operations", "on", "the", "control", ".", "It", "is", "the", "basic", "hook", "for", "logging", "context", "initialization", "resource", "management", "and", "other", "common", "services" ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-controls/src/main/java/org/apache/beehive/controls/runtime/bean/ControlBean.java#L421-L431
eclipse/xtext-extras
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/XbaseTypeComputer.java
XbaseTypeComputer.addLocalToCurrentScope
protected void addLocalToCurrentScope(XExpression expression, ITypeComputationState state) { """ If the expression is a variable declaration, then add it to the current scope; DSLs introducing new containers for variable declarations should override this method and explicitly add nested variable declarations. @since 2.9 """ if (expression instanceof XVariableDeclaration) { addLocalToCurrentScope((XVariableDeclaration)expression, state); } }
java
protected void addLocalToCurrentScope(XExpression expression, ITypeComputationState state) { if (expression instanceof XVariableDeclaration) { addLocalToCurrentScope((XVariableDeclaration)expression, state); } }
[ "protected", "void", "addLocalToCurrentScope", "(", "XExpression", "expression", ",", "ITypeComputationState", "state", ")", "{", "if", "(", "expression", "instanceof", "XVariableDeclaration", ")", "{", "addLocalToCurrentScope", "(", "(", "XVariableDeclaration", ")", "expression", ",", "state", ")", ";", "}", "}" ]
If the expression is a variable declaration, then add it to the current scope; DSLs introducing new containers for variable declarations should override this method and explicitly add nested variable declarations. @since 2.9
[ "If", "the", "expression", "is", "a", "variable", "declaration", "then", "add", "it", "to", "the", "current", "scope", ";", "DSLs", "introducing", "new", "containers", "for", "variable", "declarations", "should", "override", "this", "method", "and", "explicitly", "add", "nested", "variable", "declarations", "." ]
train
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/XbaseTypeComputer.java#L511-L515
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java
DrizzlePreparedStatement.setTimestamp
public void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException { """ Sets the designated parameter to the given <code>java.sql.Timestamp</code> value. The driver converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the database. @param parameterIndex the first parameter is 1, the second is 2, ... @param x the parameter value @throws java.sql.SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closed <code>PreparedStatement</code> """ if(x == null) { setNull(parameterIndex, Types.TIMESTAMP); return; } setParameter(parameterIndex, new TimestampParameter(x.getTime())); }
java
public void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException { if(x == null) { setNull(parameterIndex, Types.TIMESTAMP); return; } setParameter(parameterIndex, new TimestampParameter(x.getTime())); }
[ "public", "void", "setTimestamp", "(", "final", "int", "parameterIndex", ",", "final", "Timestamp", "x", ")", "throws", "SQLException", "{", "if", "(", "x", "==", "null", ")", "{", "setNull", "(", "parameterIndex", ",", "Types", ".", "TIMESTAMP", ")", ";", "return", ";", "}", "setParameter", "(", "parameterIndex", ",", "new", "TimestampParameter", "(", "x", ".", "getTime", "(", ")", ")", ")", ";", "}" ]
Sets the designated parameter to the given <code>java.sql.Timestamp</code> value. The driver converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the database. @param parameterIndex the first parameter is 1, the second is 2, ... @param x the parameter value @throws java.sql.SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closed <code>PreparedStatement</code>
[ "Sets", "the", "designated", "parameter", "to", "the", "given", "<code", ">", "java", ".", "sql", ".", "Timestamp<", "/", "code", ">", "value", ".", "The", "driver", "converts", "this", "to", "an", "SQL", "<code", ">", "TIMESTAMP<", "/", "code", ">", "value", "when", "it", "sends", "it", "to", "the", "database", "." ]
train
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java#L1174-L1182
highsource/jaxb2-basics
runtime/src/main/java/org/jvnet/jaxb2_commons/lang/ClassUtils.java
ClassUtils.getShortClassName
public static String getShortClassName(String className) { """ <p> Gets the class name minus the package name from a String. </p> <p> The string passed in is assumed to be a class name - it is not checked. </p> @param className the className to get the short name for @return the class name of the class without the package name or an empty string """ if (className == null) { return ""; } if (className.length() == 0) { return ""; } char[] chars = className.toCharArray(); int lastDot = 0; for (int i = 0; i < chars.length; i++) { if (chars[i] == PACKAGE_SEPARATOR_CHAR) { lastDot = i + 1; } else if (chars[i] == INNER_CLASS_SEPARATOR_CHAR) { // handle inner // classes chars[i] = PACKAGE_SEPARATOR_CHAR; } } return new String(chars, lastDot, chars.length - lastDot); }
java
public static String getShortClassName(String className) { if (className == null) { return ""; } if (className.length() == 0) { return ""; } char[] chars = className.toCharArray(); int lastDot = 0; for (int i = 0; i < chars.length; i++) { if (chars[i] == PACKAGE_SEPARATOR_CHAR) { lastDot = i + 1; } else if (chars[i] == INNER_CLASS_SEPARATOR_CHAR) { // handle inner // classes chars[i] = PACKAGE_SEPARATOR_CHAR; } } return new String(chars, lastDot, chars.length - lastDot); }
[ "public", "static", "String", "getShortClassName", "(", "String", "className", ")", "{", "if", "(", "className", "==", "null", ")", "{", "return", "\"\"", ";", "}", "if", "(", "className", ".", "length", "(", ")", "==", "0", ")", "{", "return", "\"\"", ";", "}", "char", "[", "]", "chars", "=", "className", ".", "toCharArray", "(", ")", ";", "int", "lastDot", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "if", "(", "chars", "[", "i", "]", "==", "PACKAGE_SEPARATOR_CHAR", ")", "{", "lastDot", "=", "i", "+", "1", ";", "}", "else", "if", "(", "chars", "[", "i", "]", "==", "INNER_CLASS_SEPARATOR_CHAR", ")", "{", "// handle inner\r", "// classes\r", "chars", "[", "i", "]", "=", "PACKAGE_SEPARATOR_CHAR", ";", "}", "}", "return", "new", "String", "(", "chars", ",", "lastDot", ",", "chars", ".", "length", "-", "lastDot", ")", ";", "}" ]
<p> Gets the class name minus the package name from a String. </p> <p> The string passed in is assumed to be a class name - it is not checked. </p> @param className the className to get the short name for @return the class name of the class without the package name or an empty string
[ "<p", ">", "Gets", "the", "class", "name", "minus", "the", "package", "name", "from", "a", "String", ".", "<", "/", "p", ">" ]
train
https://github.com/highsource/jaxb2-basics/blob/571cca0ce58a75d984324d33d8af453bf5862e75/runtime/src/main/java/org/jvnet/jaxb2_commons/lang/ClassUtils.java#L42-L60
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.updateClassification
public String updateClassification(String classificationType) { """ Updates a metadata classification on the specified file. @param classificationType the metadata classification type. @return the new metadata classification type updated on the file. """ Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String updateClassification(String classificationType) { Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "updateClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", "\"enterprise\"", ",", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ")", ";", "metadata", ".", "add", "(", "\"/Box__Security__Classification__Key\"", ",", "classificationType", ")", ";", "Metadata", "classification", "=", "this", ".", "updateMetadata", "(", "metadata", ")", ";", "return", "classification", ".", "getString", "(", "Metadata", ".", "CLASSIFICATION_KEY", ")", ";", "}" ]
Updates a metadata classification on the specified file. @param classificationType the metadata classification type. @return the new metadata classification type updated on the file.
[ "Updates", "a", "metadata", "classification", "on", "the", "specified", "file", "." ]
train
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1099-L1105
james-hu/jabb-core
src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java
AbstractHibernateDao.countByHql
public long countByHql(String secondHalfOfHql, Object[] paramValues, Type[] paramTypes) { """ Get the count of all records in database @param secondHalfOfHql parts after "from &lt;class_name&gt; " @param paramValues @param paramTypes @return the count """ StringBuilder queryStr = new StringBuilder(); queryStr.append("select count(*) from ") .append(this.clazz.getName()) .append(" "); if (secondHalfOfHql != null){ queryStr.append(secondHalfOfHql); } Session session = this.getCurrentSession(); Query query = session.createQuery(queryStr.toString()); setupQuery(query, paramValues, paramTypes, null, null); return ((Number)query.uniqueResult()).longValue(); }
java
public long countByHql(String secondHalfOfHql, Object[] paramValues, Type[] paramTypes){ StringBuilder queryStr = new StringBuilder(); queryStr.append("select count(*) from ") .append(this.clazz.getName()) .append(" "); if (secondHalfOfHql != null){ queryStr.append(secondHalfOfHql); } Session session = this.getCurrentSession(); Query query = session.createQuery(queryStr.toString()); setupQuery(query, paramValues, paramTypes, null, null); return ((Number)query.uniqueResult()).longValue(); }
[ "public", "long", "countByHql", "(", "String", "secondHalfOfHql", ",", "Object", "[", "]", "paramValues", ",", "Type", "[", "]", "paramTypes", ")", "{", "StringBuilder", "queryStr", "=", "new", "StringBuilder", "(", ")", ";", "queryStr", ".", "append", "(", "\"select count(*) from \"", ")", ".", "append", "(", "this", ".", "clazz", ".", "getName", "(", ")", ")", ".", "append", "(", "\" \"", ")", ";", "if", "(", "secondHalfOfHql", "!=", "null", ")", "{", "queryStr", ".", "append", "(", "secondHalfOfHql", ")", ";", "}", "Session", "session", "=", "this", ".", "getCurrentSession", "(", ")", ";", "Query", "query", "=", "session", ".", "createQuery", "(", "queryStr", ".", "toString", "(", ")", ")", ";", "setupQuery", "(", "query", ",", "paramValues", ",", "paramTypes", ",", "null", ",", "null", ")", ";", "return", "(", "(", "Number", ")", "query", ".", "uniqueResult", "(", ")", ")", ".", "longValue", "(", ")", ";", "}" ]
Get the count of all records in database @param secondHalfOfHql parts after "from &lt;class_name&gt; " @param paramValues @param paramTypes @return the count
[ "Get", "the", "count", "of", "all", "records", "in", "database" ]
train
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java#L331-L344
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ParameterUtil.java
ParameterUtil.getUsedHiddenParametersMap
public static Map<String, QueryParameter> getUsedHiddenParametersMap(Report report) { """ Get used hidden parameters map where the key is the parameter name and the value is the parameter Not all the report parameters have to be used, some may only be defined for further usage. The result will contain only the hidden parameters. @param report next report object @return used hidden parameters map """ return getUsedParametersMap(report, false, true); }
java
public static Map<String, QueryParameter> getUsedHiddenParametersMap(Report report) { return getUsedParametersMap(report, false, true); }
[ "public", "static", "Map", "<", "String", ",", "QueryParameter", ">", "getUsedHiddenParametersMap", "(", "Report", "report", ")", "{", "return", "getUsedParametersMap", "(", "report", ",", "false", ",", "true", ")", ";", "}" ]
Get used hidden parameters map where the key is the parameter name and the value is the parameter Not all the report parameters have to be used, some may only be defined for further usage. The result will contain only the hidden parameters. @param report next report object @return used hidden parameters map
[ "Get", "used", "hidden", "parameters", "map", "where", "the", "key", "is", "the", "parameter", "name", "and", "the", "value", "is", "the", "parameter", "Not", "all", "the", "report", "parameters", "have", "to", "be", "used", "some", "may", "only", "be", "defined", "for", "further", "usage", ".", "The", "result", "will", "contain", "only", "the", "hidden", "parameters", "." ]
train
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L667-L669
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/util/Util.java
Util.sortIMarkers
public static void sortIMarkers(IMarker[] markers) { """ Sorts an array of IMarkers based on their underlying resource name @param markers """ Arrays.sort(markers, new Comparator<IMarker>() { @Override public int compare(IMarker arg0, IMarker arg1) { IResource resource0 = arg0.getResource(); IResource resource1 = arg1.getResource(); if (resource0 != null && resource1 != null) { return resource0.getName().compareTo(resource1.getName()); } if (resource0 != null && resource1 == null) { return 1; } if (resource0 == null && resource1 != null) { return -1; } return 0; } }); }
java
public static void sortIMarkers(IMarker[] markers) { Arrays.sort(markers, new Comparator<IMarker>() { @Override public int compare(IMarker arg0, IMarker arg1) { IResource resource0 = arg0.getResource(); IResource resource1 = arg1.getResource(); if (resource0 != null && resource1 != null) { return resource0.getName().compareTo(resource1.getName()); } if (resource0 != null && resource1 == null) { return 1; } if (resource0 == null && resource1 != null) { return -1; } return 0; } }); }
[ "public", "static", "void", "sortIMarkers", "(", "IMarker", "[", "]", "markers", ")", "{", "Arrays", ".", "sort", "(", "markers", ",", "new", "Comparator", "<", "IMarker", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "IMarker", "arg0", ",", "IMarker", "arg1", ")", "{", "IResource", "resource0", "=", "arg0", ".", "getResource", "(", ")", ";", "IResource", "resource1", "=", "arg1", ".", "getResource", "(", ")", ";", "if", "(", "resource0", "!=", "null", "&&", "resource1", "!=", "null", ")", "{", "return", "resource0", ".", "getName", "(", ")", ".", "compareTo", "(", "resource1", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "resource0", "!=", "null", "&&", "resource1", "==", "null", ")", "{", "return", "1", ";", "}", "if", "(", "resource0", "==", "null", "&&", "resource1", "!=", "null", ")", "{", "return", "-", "1", ";", "}", "return", "0", ";", "}", "}", ")", ";", "}" ]
Sorts an array of IMarkers based on their underlying resource name @param markers
[ "Sorts", "an", "array", "of", "IMarkers", "based", "on", "their", "underlying", "resource", "name" ]
train
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/util/Util.java#L215-L233
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteUser
public String deleteUser(String uid, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { """ Deletes a user. @param uid ID of the user @param eventTime timestamp of the event @return ID of this event """ return createEvent(deleteUserAsFuture(uid, eventTime)); }
java
public String deleteUser(String uid, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(deleteUserAsFuture(uid, eventTime)); }
[ "public", "String", "deleteUser", "(", "String", "uid", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "deleteUserAsFuture", "(", "uid", ",", "eventTime", ")", ")", ";", "}" ]
Deletes a user. @param uid ID of the user @param eventTime timestamp of the event @return ID of this event
[ "Deletes", "a", "user", "." ]
train
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L428-L431
phax/ph-oton
ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/typeahead/TypeaheadEditSelection.java
TypeaheadEditSelection.getSelectionForRequiredObject
@Nonnull public static TypeaheadEditSelection getSelectionForRequiredObject (@Nonnull final IWebPageExecutionContext aWPEC, @Nullable final String sEditFieldName, @Nullable final String sHiddenFieldName) { """ Get the current selection in the case that it is mandatory to select an available object. @param aWPEC The current web page execution context. May not be <code>null</code> . @param sEditFieldName The name of the edit input field. @param sHiddenFieldName The name of the hidden field with the ID. @return Never <code>null</code>. """ ValueEnforcer.notNull (aWPEC, "WPEC"); String sEditValue = aWPEC.params ().getAsString (sEditFieldName); String sHiddenFieldValue = aWPEC.params ().getAsString (sHiddenFieldName); if (StringHelper.hasText (sHiddenFieldValue)) { if (StringHelper.hasNoText (sEditValue)) { // The content of the edit field was deleted after a valid item was once // selected sHiddenFieldValue = null; } } else { if (StringHelper.hasText (sEditValue)) { // No ID but a text -> no object selected but only a string typed sEditValue = null; } } return new TypeaheadEditSelection (sEditValue, sHiddenFieldValue); }
java
@Nonnull public static TypeaheadEditSelection getSelectionForRequiredObject (@Nonnull final IWebPageExecutionContext aWPEC, @Nullable final String sEditFieldName, @Nullable final String sHiddenFieldName) { ValueEnforcer.notNull (aWPEC, "WPEC"); String sEditValue = aWPEC.params ().getAsString (sEditFieldName); String sHiddenFieldValue = aWPEC.params ().getAsString (sHiddenFieldName); if (StringHelper.hasText (sHiddenFieldValue)) { if (StringHelper.hasNoText (sEditValue)) { // The content of the edit field was deleted after a valid item was once // selected sHiddenFieldValue = null; } } else { if (StringHelper.hasText (sEditValue)) { // No ID but a text -> no object selected but only a string typed sEditValue = null; } } return new TypeaheadEditSelection (sEditValue, sHiddenFieldValue); }
[ "@", "Nonnull", "public", "static", "TypeaheadEditSelection", "getSelectionForRequiredObject", "(", "@", "Nonnull", "final", "IWebPageExecutionContext", "aWPEC", ",", "@", "Nullable", "final", "String", "sEditFieldName", ",", "@", "Nullable", "final", "String", "sHiddenFieldName", ")", "{", "ValueEnforcer", ".", "notNull", "(", "aWPEC", ",", "\"WPEC\"", ")", ";", "String", "sEditValue", "=", "aWPEC", ".", "params", "(", ")", ".", "getAsString", "(", "sEditFieldName", ")", ";", "String", "sHiddenFieldValue", "=", "aWPEC", ".", "params", "(", ")", ".", "getAsString", "(", "sHiddenFieldName", ")", ";", "if", "(", "StringHelper", ".", "hasText", "(", "sHiddenFieldValue", ")", ")", "{", "if", "(", "StringHelper", ".", "hasNoText", "(", "sEditValue", ")", ")", "{", "// The content of the edit field was deleted after a valid item was once", "// selected", "sHiddenFieldValue", "=", "null", ";", "}", "}", "else", "{", "if", "(", "StringHelper", ".", "hasText", "(", "sEditValue", ")", ")", "{", "// No ID but a text -> no object selected but only a string typed", "sEditValue", "=", "null", ";", "}", "}", "return", "new", "TypeaheadEditSelection", "(", "sEditValue", ",", "sHiddenFieldValue", ")", ";", "}" ]
Get the current selection in the case that it is mandatory to select an available object. @param aWPEC The current web page execution context. May not be <code>null</code> . @param sEditFieldName The name of the edit input field. @param sHiddenFieldName The name of the hidden field with the ID. @return Never <code>null</code>.
[ "Get", "the", "current", "selection", "in", "the", "case", "that", "it", "is", "mandatory", "to", "select", "an", "available", "object", "." ]
train
https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/typeahead/TypeaheadEditSelection.java#L93-L121
opendatatrentino/s-match
src/main/java/it/unitn/disi/common/utils/MiscUtils.java
MiscUtils.readObject
public static Object readObject(String fileName, boolean isInternalFile) throws DISIException { """ Reads Java object from a file. @param fileName the file where the object is stored @parm isInternalFile reads from internal data file in resources folder @return the object @throws DISIException DISIException """ Object result; try { InputStream fos = null; if (isInternalFile == true) { fos = Thread.currentThread().getContextClassLoader().getResource(fileName).openStream(); } else { fos = new FileInputStream(fileName); } BufferedInputStream bis = new BufferedInputStream(fos); ObjectInputStream oos = new ObjectInputStream(bis); try { result = oos.readObject(); } catch (IOException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } catch (ClassNotFoundException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } oos.close(); bis.close(); fos.close(); } catch (IOException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } return result; }
java
public static Object readObject(String fileName, boolean isInternalFile) throws DISIException { Object result; try { InputStream fos = null; if (isInternalFile == true) { fos = Thread.currentThread().getContextClassLoader().getResource(fileName).openStream(); } else { fos = new FileInputStream(fileName); } BufferedInputStream bis = new BufferedInputStream(fos); ObjectInputStream oos = new ObjectInputStream(bis); try { result = oos.readObject(); } catch (IOException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } catch (ClassNotFoundException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } oos.close(); bis.close(); fos.close(); } catch (IOException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new DISIException(errMessage, e); } return result; }
[ "public", "static", "Object", "readObject", "(", "String", "fileName", ",", "boolean", "isInternalFile", ")", "throws", "DISIException", "{", "Object", "result", ";", "try", "{", "InputStream", "fos", "=", "null", ";", "if", "(", "isInternalFile", "==", "true", ")", "{", "fos", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResource", "(", "fileName", ")", ".", "openStream", "(", ")", ";", "}", "else", "{", "fos", "=", "new", "FileInputStream", "(", "fileName", ")", ";", "}", "BufferedInputStream", "bis", "=", "new", "BufferedInputStream", "(", "fos", ")", ";", "ObjectInputStream", "oos", "=", "new", "ObjectInputStream", "(", "bis", ")", ";", "try", "{", "result", "=", "oos", ".", "readObject", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "final", "String", "errMessage", "=", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "errMessage", ",", "e", ")", ";", "throw", "new", "DISIException", "(", "errMessage", ",", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "final", "String", "errMessage", "=", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "errMessage", ",", "e", ")", ";", "throw", "new", "DISIException", "(", "errMessage", ",", "e", ")", ";", "}", "oos", ".", "close", "(", ")", ";", "bis", ".", "close", "(", ")", ";", "fos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "final", "String", "errMessage", "=", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "errMessage", ",", "e", ")", ";", "throw", "new", "DISIException", "(", "errMessage", ",", "e", ")", ";", "}", "return", "result", ";", "}" ]
Reads Java object from a file. @param fileName the file where the object is stored @parm isInternalFile reads from internal data file in resources folder @return the object @throws DISIException DISIException
[ "Reads", "Java", "object", "from", "a", "file", "." ]
train
https://github.com/opendatatrentino/s-match/blob/ba5982ef406b7010c2f92592e43887a485935aa1/src/main/java/it/unitn/disi/common/utils/MiscUtils.java#L62-L95
jbehave/jbehave-core
jbehave-groovy/src/main/java/org/jbehave/core/configuration/groovy/GroovyContext.java
GroovyContext.newInstance
public Object newInstance(String resource) { """ Creates an object instance from the Groovy resource @param resource the Groovy resource to parse @return An Object instance """ try { String name = resource.startsWith("/") ? resource : "/" + resource; File file = new File(this.getClass().getResource(name).toURI()); return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true)); } catch (Exception e) { throw new GroovyClassInstantiationFailed(classLoader, resource, e); } }
java
public Object newInstance(String resource) { try { String name = resource.startsWith("/") ? resource : "/" + resource; File file = new File(this.getClass().getResource(name).toURI()); return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true)); } catch (Exception e) { throw new GroovyClassInstantiationFailed(classLoader, resource, e); } }
[ "public", "Object", "newInstance", "(", "String", "resource", ")", "{", "try", "{", "String", "name", "=", "resource", ".", "startsWith", "(", "\"/\"", ")", "?", "resource", ":", "\"/\"", "+", "resource", ";", "File", "file", "=", "new", "File", "(", "this", ".", "getClass", "(", ")", ".", "getResource", "(", "name", ")", ".", "toURI", "(", ")", ")", ";", "return", "newInstance", "(", "classLoader", ".", "parseClass", "(", "new", "GroovyCodeSource", "(", "file", ")", ",", "true", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "GroovyClassInstantiationFailed", "(", "classLoader", ",", "resource", ",", "e", ")", ";", "}", "}" ]
Creates an object instance from the Groovy resource @param resource the Groovy resource to parse @return An Object instance
[ "Creates", "an", "object", "instance", "from", "the", "Groovy", "resource" ]
train
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-groovy/src/main/java/org/jbehave/core/configuration/groovy/GroovyContext.java#L59-L67
box/box-android-sdk
box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiMetadata.java
BoxApiMetadata.getMetadataTemplateSchemaRequest
public BoxRequestsMetadata.GetMetadataTemplateSchema getMetadataTemplateSchemaRequest(String scope, String template) { """ Gets a request that retrieves a metadata template schema (scope defaults to BOX_API_SCOPE_ENTERPRISE) @param scope currently only global and enterprise scopes are supported @param template metadata template to use @return request to retrieve a metadata template schema """ BoxRequestsMetadata.GetMetadataTemplateSchema request = new BoxRequestsMetadata.GetMetadataTemplateSchema(getMetadataTemplatesUrl(scope, template), mSession); return request; }
java
public BoxRequestsMetadata.GetMetadataTemplateSchema getMetadataTemplateSchemaRequest(String scope, String template) { BoxRequestsMetadata.GetMetadataTemplateSchema request = new BoxRequestsMetadata.GetMetadataTemplateSchema(getMetadataTemplatesUrl(scope, template), mSession); return request; }
[ "public", "BoxRequestsMetadata", ".", "GetMetadataTemplateSchema", "getMetadataTemplateSchemaRequest", "(", "String", "scope", ",", "String", "template", ")", "{", "BoxRequestsMetadata", ".", "GetMetadataTemplateSchema", "request", "=", "new", "BoxRequestsMetadata", ".", "GetMetadataTemplateSchema", "(", "getMetadataTemplatesUrl", "(", "scope", ",", "template", ")", ",", "mSession", ")", ";", "return", "request", ";", "}" ]
Gets a request that retrieves a metadata template schema (scope defaults to BOX_API_SCOPE_ENTERPRISE) @param scope currently only global and enterprise scopes are supported @param template metadata template to use @return request to retrieve a metadata template schema
[ "Gets", "a", "request", "that", "retrieves", "a", "metadata", "template", "schema", "(", "scope", "defaults", "to", "BOX_API_SCOPE_ENTERPRISE", ")" ]
train
https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiMetadata.java#L300-L303
micronaut-projects/micronaut-core
core/src/main/java/io/micronaut/core/reflect/ReflectionUtils.java
ReflectionUtils.invokeMethod
public static <R, T> R invokeMethod(T instance, Method method, Object... arguments) { """ Invokes a method. @param instance The instance @param method The method @param arguments The arguments @param <R> The return type @param <T> The instance type @return The result """ try { return (R) method.invoke(instance, arguments); } catch (IllegalAccessException e) { throw new InvocationException("Illegal access invoking method [" + method + "]: " + e.getMessage(), e); } catch (InvocationTargetException e) { throw new InvocationException("Exception occurred invoking method [" + method + "]: " + e.getMessage(), e); } }
java
public static <R, T> R invokeMethod(T instance, Method method, Object... arguments) { try { return (R) method.invoke(instance, arguments); } catch (IllegalAccessException e) { throw new InvocationException("Illegal access invoking method [" + method + "]: " + e.getMessage(), e); } catch (InvocationTargetException e) { throw new InvocationException("Exception occurred invoking method [" + method + "]: " + e.getMessage(), e); } }
[ "public", "static", "<", "R", ",", "T", ">", "R", "invokeMethod", "(", "T", "instance", ",", "Method", "method", ",", "Object", "...", "arguments", ")", "{", "try", "{", "return", "(", "R", ")", "method", ".", "invoke", "(", "instance", ",", "arguments", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "InvocationException", "(", "\"Illegal access invoking method [\"", "+", "method", "+", "\"]: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "new", "InvocationException", "(", "\"Exception occurred invoking method [\"", "+", "method", "+", "\"]: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Invokes a method. @param instance The instance @param method The method @param arguments The arguments @param <R> The return type @param <T> The instance type @return The result
[ "Invokes", "a", "method", "." ]
train
https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/reflect/ReflectionUtils.java#L196-L204
mygreen/xlsmapper
src/main/java/com/gh/mygreen/xlsmapper/util/ArgUtils.java
ArgUtils.notMax
@SuppressWarnings( { """ 引数が {@literal 'arg' <= 'max'} の関係か検証する。 @param arg 検証対象の値 @param max 最大値 @param name 検証対象の引数の名前 @throws IllegalArgumentException {@literal arg == null || arg > max.} """"rawtypes", "unchecked"}) public static <T extends Comparable> void notMax(final T arg, final T max, final String name) { if(arg == null) { throw new IllegalArgumentException(String.format("%s should not be null.", name)); } if(arg.compareTo(max) > 0) { throw new IllegalArgumentException(String.format("%s cannot be greater than %s", name, max.toString())); } }
java
@SuppressWarnings({"rawtypes", "unchecked"}) public static <T extends Comparable> void notMax(final T arg, final T max, final String name) { if(arg == null) { throw new IllegalArgumentException(String.format("%s should not be null.", name)); } if(arg.compareTo(max) > 0) { throw new IllegalArgumentException(String.format("%s cannot be greater than %s", name, max.toString())); } }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "static", "<", "T", "extends", "Comparable", ">", "void", "notMax", "(", "final", "T", "arg", ",", "final", "T", "max", ",", "final", "String", "name", ")", "{", "if", "(", "arg", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"%s should not be null.\"", ",", "name", ")", ")", ";", "}", "if", "(", "arg", ".", "compareTo", "(", "max", ")", ">", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"%s cannot be greater than %s\"", ",", "name", ",", "max", ".", "toString", "(", ")", ")", ")", ";", "}", "}" ]
引数が {@literal 'arg' <= 'max'} の関係か検証する。 @param arg 検証対象の値 @param max 最大値 @param name 検証対象の引数の名前 @throws IllegalArgumentException {@literal arg == null || arg > max.}
[ "引数が", "{" ]
train
https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/ArgUtils.java#L115-L126
datacleaner/AnalyzerBeans
env/xml-config/src/main/java/org/eobjects/analyzer/configuration/DatastoreXmlExternalizer.java
DatastoreXmlExternalizer.toElement
public Element toElement(CsvDatastore datastore, String filename) { """ Externalizes a {@link CsvDatastore} to a XML element. @param datastore the datastore to externalize @param filename the filename/path to use in the XML element. Since the appropriate path will depend on the reading application's environment (supported {@link Resource} types), this specific property of the datastore is provided separately. @return a XML element representing the datastore. """ final Element datastoreElement = getDocument().createElement("csv-datastore"); datastoreElement.setAttribute("name", datastore.getName()); final String description = datastore.getDescription(); if (!StringUtils.isNullOrEmpty(description)) { datastoreElement.setAttribute("description", description); } appendElement(datastoreElement, "filename", filename); appendElement(datastoreElement, "quote-char", datastore.getQuoteChar()); appendElement(datastoreElement, "separator-char", datastore.getSeparatorChar()); appendElement(datastoreElement, "escape-char", datastore.getEscapeChar()); appendElement(datastoreElement, "encoding", datastore.getEncoding()); appendElement(datastoreElement, "fail-on-inconsistencies", datastore.isFailOnInconsistencies()); appendElement(datastoreElement, "multiline-values", datastore.isMultilineValues()); appendElement(datastoreElement, "header-line-number", datastore.getHeaderLineNumber()); return datastoreElement; }
java
public Element toElement(CsvDatastore datastore, String filename) { final Element datastoreElement = getDocument().createElement("csv-datastore"); datastoreElement.setAttribute("name", datastore.getName()); final String description = datastore.getDescription(); if (!StringUtils.isNullOrEmpty(description)) { datastoreElement.setAttribute("description", description); } appendElement(datastoreElement, "filename", filename); appendElement(datastoreElement, "quote-char", datastore.getQuoteChar()); appendElement(datastoreElement, "separator-char", datastore.getSeparatorChar()); appendElement(datastoreElement, "escape-char", datastore.getEscapeChar()); appendElement(datastoreElement, "encoding", datastore.getEncoding()); appendElement(datastoreElement, "fail-on-inconsistencies", datastore.isFailOnInconsistencies()); appendElement(datastoreElement, "multiline-values", datastore.isMultilineValues()); appendElement(datastoreElement, "header-line-number", datastore.getHeaderLineNumber()); return datastoreElement; }
[ "public", "Element", "toElement", "(", "CsvDatastore", "datastore", ",", "String", "filename", ")", "{", "final", "Element", "datastoreElement", "=", "getDocument", "(", ")", ".", "createElement", "(", "\"csv-datastore\"", ")", ";", "datastoreElement", ".", "setAttribute", "(", "\"name\"", ",", "datastore", ".", "getName", "(", ")", ")", ";", "final", "String", "description", "=", "datastore", ".", "getDescription", "(", ")", ";", "if", "(", "!", "StringUtils", ".", "isNullOrEmpty", "(", "description", ")", ")", "{", "datastoreElement", ".", "setAttribute", "(", "\"description\"", ",", "description", ")", ";", "}", "appendElement", "(", "datastoreElement", ",", "\"filename\"", ",", "filename", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"quote-char\"", ",", "datastore", ".", "getQuoteChar", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"separator-char\"", ",", "datastore", ".", "getSeparatorChar", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"escape-char\"", ",", "datastore", ".", "getEscapeChar", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"encoding\"", ",", "datastore", ".", "getEncoding", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"fail-on-inconsistencies\"", ",", "datastore", ".", "isFailOnInconsistencies", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"multiline-values\"", ",", "datastore", ".", "isMultilineValues", "(", ")", ")", ";", "appendElement", "(", "datastoreElement", ",", "\"header-line-number\"", ",", "datastore", ".", "getHeaderLineNumber", "(", ")", ")", ";", "return", "datastoreElement", ";", "}" ]
Externalizes a {@link CsvDatastore} to a XML element. @param datastore the datastore to externalize @param filename the filename/path to use in the XML element. Since the appropriate path will depend on the reading application's environment (supported {@link Resource} types), this specific property of the datastore is provided separately. @return a XML element representing the datastore.
[ "Externalizes", "a", "{", "@link", "CsvDatastore", "}", "to", "a", "XML", "element", "." ]
train
https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/env/xml-config/src/main/java/org/eobjects/analyzer/configuration/DatastoreXmlExternalizer.java#L296-L315
teatrove/teatrove
build-tools/teatools/src/main/java/org/teatrove/teatools/TeaToolsUtils.java
TeaToolsUtils.isDeprecated
protected boolean isDeprecated(Class<?> clazz, String methodName, Class<?>... paramTypes) { """ Returns whether the given method or any super method or interface declaration is deprecated. @see Deprecated """ // check if type is annotated if (isDeprecated(clazz)) { return true; } // check if method is annotated try { Method method = clazz.getDeclaredMethod(methodName, paramTypes); if (method.getAnnotation(Deprecated.class) != null) { return true; } } catch (NoSuchMethodException nsme) { // ignore and continue } // check superclass Class<?> superClass = clazz.getSuperclass(); if (superClass != null) { return isDeprecated(superClass, methodName, paramTypes); } // check interfaces for (Class<?> iface : clazz.getInterfaces()) { return isDeprecated(iface, methodName, paramTypes); } // none found return false; }
java
protected boolean isDeprecated(Class<?> clazz, String methodName, Class<?>... paramTypes) { // check if type is annotated if (isDeprecated(clazz)) { return true; } // check if method is annotated try { Method method = clazz.getDeclaredMethod(methodName, paramTypes); if (method.getAnnotation(Deprecated.class) != null) { return true; } } catch (NoSuchMethodException nsme) { // ignore and continue } // check superclass Class<?> superClass = clazz.getSuperclass(); if (superClass != null) { return isDeprecated(superClass, methodName, paramTypes); } // check interfaces for (Class<?> iface : clazz.getInterfaces()) { return isDeprecated(iface, methodName, paramTypes); } // none found return false; }
[ "protected", "boolean", "isDeprecated", "(", "Class", "<", "?", ">", "clazz", ",", "String", "methodName", ",", "Class", "<", "?", ">", "...", "paramTypes", ")", "{", "// check if type is annotated", "if", "(", "isDeprecated", "(", "clazz", ")", ")", "{", "return", "true", ";", "}", "// check if method is annotated", "try", "{", "Method", "method", "=", "clazz", ".", "getDeclaredMethod", "(", "methodName", ",", "paramTypes", ")", ";", "if", "(", "method", ".", "getAnnotation", "(", "Deprecated", ".", "class", ")", "!=", "null", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "NoSuchMethodException", "nsme", ")", "{", "// ignore and continue", "}", "// check superclass", "Class", "<", "?", ">", "superClass", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "if", "(", "superClass", "!=", "null", ")", "{", "return", "isDeprecated", "(", "superClass", ",", "methodName", ",", "paramTypes", ")", ";", "}", "// check interfaces", "for", "(", "Class", "<", "?", ">", "iface", ":", "clazz", ".", "getInterfaces", "(", ")", ")", "{", "return", "isDeprecated", "(", "iface", ",", "methodName", ",", "paramTypes", ")", ";", "}", "// none found", "return", "false", ";", "}" ]
Returns whether the given method or any super method or interface declaration is deprecated. @see Deprecated
[ "Returns", "whether", "the", "given", "method", "or", "any", "super", "method", "or", "interface", "declaration", "is", "deprecated", "." ]
train
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/TeaToolsUtils.java#L331-L363
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/TableFormBuilder.java
TableFormBuilder.addTextArea
public JComponent[] addTextArea(String fieldName, String attributes) { """ Adds the field to the form by using a text area component which is wrapped inside a scrollpane. {@link #createTextArea(String)} is used to create the component for the text area field <p> Note: this method ensures that the the label of the textarea has a top vertical alignment if <code>valign</code> is not defined in the default label attributes @param fieldName the name of the field to add @param attributes optional layout attributes for the scrollpane. See {@link TableLayoutBuilder} for syntax details @return an array containing the label, the textarea and the scrollpane and which where added to the form @see #createTextArea(String) """ JComponent textArea = createTextArea(fieldName); String labelAttributes = getLabelAttributes(); if (labelAttributes == null) { labelAttributes = VALIGN_TOP; } else if (!labelAttributes.contains(TableLayoutBuilder.VALIGN)) { labelAttributes += " " + VALIGN_TOP; } return addBinding(createBinding(fieldName, textArea), new JScrollPane(textArea), attributes, labelAttributes); }
java
public JComponent[] addTextArea(String fieldName, String attributes) { JComponent textArea = createTextArea(fieldName); String labelAttributes = getLabelAttributes(); if (labelAttributes == null) { labelAttributes = VALIGN_TOP; } else if (!labelAttributes.contains(TableLayoutBuilder.VALIGN)) { labelAttributes += " " + VALIGN_TOP; } return addBinding(createBinding(fieldName, textArea), new JScrollPane(textArea), attributes, labelAttributes); }
[ "public", "JComponent", "[", "]", "addTextArea", "(", "String", "fieldName", ",", "String", "attributes", ")", "{", "JComponent", "textArea", "=", "createTextArea", "(", "fieldName", ")", ";", "String", "labelAttributes", "=", "getLabelAttributes", "(", ")", ";", "if", "(", "labelAttributes", "==", "null", ")", "{", "labelAttributes", "=", "VALIGN_TOP", ";", "}", "else", "if", "(", "!", "labelAttributes", ".", "contains", "(", "TableLayoutBuilder", ".", "VALIGN", ")", ")", "{", "labelAttributes", "+=", "\" \"", "+", "VALIGN_TOP", ";", "}", "return", "addBinding", "(", "createBinding", "(", "fieldName", ",", "textArea", ")", ",", "new", "JScrollPane", "(", "textArea", ")", ",", "attributes", ",", "labelAttributes", ")", ";", "}" ]
Adds the field to the form by using a text area component which is wrapped inside a scrollpane. {@link #createTextArea(String)} is used to create the component for the text area field <p> Note: this method ensures that the the label of the textarea has a top vertical alignment if <code>valign</code> is not defined in the default label attributes @param fieldName the name of the field to add @param attributes optional layout attributes for the scrollpane. See {@link TableLayoutBuilder} for syntax details @return an array containing the label, the textarea and the scrollpane and which where added to the form @see #createTextArea(String)
[ "Adds", "the", "field", "to", "the", "form", "by", "using", "a", "text", "area", "component", "which", "is", "wrapped", "inside", "a", "scrollpane", ".", "{", "@link", "#createTextArea", "(", "String", ")", "}", "is", "used", "to", "create", "the", "component", "for", "the", "text", "area", "field", "<p", ">", "Note", ":", "this", "method", "ensures", "that", "the", "the", "label", "of", "the", "textarea", "has", "a", "top", "vertical", "alignment", "if", "<code", ">", "valign<", "/", "code", ">", "is", "not", "defined", "in", "the", "default", "label", "attributes" ]
train
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/TableFormBuilder.java#L245-L254
sockeqwe/SwipeBack
library/src/com/hannesdorfmann/swipeback/SwipeBack.java
SwipeBack.setContentView
public SwipeBack setContentView(View view) { """ Set the content to an explicit view. @param view The desired content to display. """ setContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return this; }
java
public SwipeBack setContentView(View view) { setContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return this; }
[ "public", "SwipeBack", "setContentView", "(", "View", "view", ")", "{", "setContentView", "(", "view", ",", "new", "LayoutParams", "(", "LayoutParams", ".", "MATCH_PARENT", ",", "LayoutParams", ".", "MATCH_PARENT", ")", ")", ";", "return", "this", ";", "}" ]
Set the content to an explicit view. @param view The desired content to display.
[ "Set", "the", "content", "to", "an", "explicit", "view", "." ]
train
https://github.com/sockeqwe/SwipeBack/blob/09ed11f48e930ed47fd4f07ad1c786fc9fff3c48/library/src/com/hannesdorfmann/swipeback/SwipeBack.java#L1443-L1446
Ordinastie/MalisisCore
src/main/java/net/malisis/core/client/gui/MalisisGui.java
MalisisGui.sendAction
public static void sendAction(ActionType action, MalisisSlot slot, int code) { """ Sends a GUI action to the server. @param action the action @param slot the slot @param code the keyboard code """ if (action == null || current() == null || current().inventoryContainer == null) return; int inventoryId = slot != null ? slot.getInventoryId() : 0; int slotNumber = slot != null ? slot.getSlotIndex() : 0; current().inventoryContainer.handleAction(action, inventoryId, slotNumber, code); InventoryActionMessage.sendAction(action, inventoryId, slotNumber, code); }
java
public static void sendAction(ActionType action, MalisisSlot slot, int code) { if (action == null || current() == null || current().inventoryContainer == null) return; int inventoryId = slot != null ? slot.getInventoryId() : 0; int slotNumber = slot != null ? slot.getSlotIndex() : 0; current().inventoryContainer.handleAction(action, inventoryId, slotNumber, code); InventoryActionMessage.sendAction(action, inventoryId, slotNumber, code); }
[ "public", "static", "void", "sendAction", "(", "ActionType", "action", ",", "MalisisSlot", "slot", ",", "int", "code", ")", "{", "if", "(", "action", "==", "null", "||", "current", "(", ")", "==", "null", "||", "current", "(", ")", ".", "inventoryContainer", "==", "null", ")", "return", ";", "int", "inventoryId", "=", "slot", "!=", "null", "?", "slot", ".", "getInventoryId", "(", ")", ":", "0", ";", "int", "slotNumber", "=", "slot", "!=", "null", "?", "slot", ".", "getSlotIndex", "(", ")", ":", "0", ";", "current", "(", ")", ".", "inventoryContainer", ".", "handleAction", "(", "action", ",", "inventoryId", ",", "slotNumber", ",", "code", ")", ";", "InventoryActionMessage", ".", "sendAction", "(", "action", ",", "inventoryId", ",", "slotNumber", ",", "code", ")", ";", "}" ]
Sends a GUI action to the server. @param action the action @param slot the slot @param code the keyboard code
[ "Sends", "a", "GUI", "action", "to", "the", "server", "." ]
train
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/MalisisGui.java#L773-L783
apache/incubator-gobblin
gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/Counters.java
Counters.initialize
public void initialize(final MetricContext metricContext, final Class<E> enumClass, final Class<?> instrumentedClass) { """ Creates a {@link Counter} for every value of the enumClass. Use {@link #inc(Enum, long)} to increment the counter associated with a enum value @param metricContext that {@link Counter}s will be registered @param enumClass that define the names of {@link Counter}s. One counter is created per value @param instrumentedClass name that will be prefixed in the metric name """ Builder<E, Counter> builder = ImmutableMap.builder(); for (E e : Arrays.asList(enumClass.getEnumConstants())) { builder.put(e, metricContext.counter(MetricRegistry.name(instrumentedClass, e.name()))); } counters = builder.build(); }
java
public void initialize(final MetricContext metricContext, final Class<E> enumClass, final Class<?> instrumentedClass) { Builder<E, Counter> builder = ImmutableMap.builder(); for (E e : Arrays.asList(enumClass.getEnumConstants())) { builder.put(e, metricContext.counter(MetricRegistry.name(instrumentedClass, e.name()))); } counters = builder.build(); }
[ "public", "void", "initialize", "(", "final", "MetricContext", "metricContext", ",", "final", "Class", "<", "E", ">", "enumClass", ",", "final", "Class", "<", "?", ">", "instrumentedClass", ")", "{", "Builder", "<", "E", ",", "Counter", ">", "builder", "=", "ImmutableMap", ".", "builder", "(", ")", ";", "for", "(", "E", "e", ":", "Arrays", ".", "asList", "(", "enumClass", ".", "getEnumConstants", "(", ")", ")", ")", "{", "builder", ".", "put", "(", "e", ",", "metricContext", ".", "counter", "(", "MetricRegistry", ".", "name", "(", "instrumentedClass", ",", "e", ".", "name", "(", ")", ")", ")", ")", ";", "}", "counters", "=", "builder", ".", "build", "(", ")", ";", "}" ]
Creates a {@link Counter} for every value of the enumClass. Use {@link #inc(Enum, long)} to increment the counter associated with a enum value @param metricContext that {@link Counter}s will be registered @param enumClass that define the names of {@link Counter}s. One counter is created per value @param instrumentedClass name that will be prefixed in the metric name
[ "Creates", "a", "{", "@link", "Counter", "}", "for", "every", "value", "of", "the", "enumClass", ".", "Use", "{", "@link", "#inc", "(", "Enum", "long", ")", "}", "to", "increment", "the", "counter", "associated", "with", "a", "enum", "value" ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/Counters.java#L45-L54
samskivert/samskivert
src/main/java/com/samskivert/swing/util/SwingUtil.java
SwingUtil.restoreAntiAliasing
public static void restoreAntiAliasing (Graphics2D gfx, Object rock) { """ Restores anti-aliasing in the supplied graphics context to its original setting. @param rock the results of a previous call to {@link #activateAntiAliasing} or null, in which case this method will NOOP. This alleviates every caller having to conditionally avoid calling restore if they chose not to activate earlier. """ if (rock != null) { gfx.setRenderingHints((RenderingHints)rock); } }
java
public static void restoreAntiAliasing (Graphics2D gfx, Object rock) { if (rock != null) { gfx.setRenderingHints((RenderingHints)rock); } }
[ "public", "static", "void", "restoreAntiAliasing", "(", "Graphics2D", "gfx", ",", "Object", "rock", ")", "{", "if", "(", "rock", "!=", "null", ")", "{", "gfx", ".", "setRenderingHints", "(", "(", "RenderingHints", ")", "rock", ")", ";", "}", "}" ]
Restores anti-aliasing in the supplied graphics context to its original setting. @param rock the results of a previous call to {@link #activateAntiAliasing} or null, in which case this method will NOOP. This alleviates every caller having to conditionally avoid calling restore if they chose not to activate earlier.
[ "Restores", "anti", "-", "aliasing", "in", "the", "supplied", "graphics", "context", "to", "its", "original", "setting", "." ]
train
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/SwingUtil.java#L429-L434
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java
Error.badConversion
public static void badConversion(Field destinationField, Class<?> destinationClass, Field sourceField, Class<?> sourceClass,String plus) { """ Thrown when conversions are badly written. @param destinationField destination field @param destinationClass destination class @param sourceField source field @param sourceClass source class @param plus added messages of internal exceptions thrown """ throw new UndefinedMappingException(MSG.INSTANCE.message(undefinedMappingException,destinationField.getName(),destinationClass.getSimpleName(),sourceField.getName(),sourceClass.getSimpleName()) + ". More information: "+plus); }
java
public static void badConversion(Field destinationField, Class<?> destinationClass, Field sourceField, Class<?> sourceClass,String plus){ throw new UndefinedMappingException(MSG.INSTANCE.message(undefinedMappingException,destinationField.getName(),destinationClass.getSimpleName(),sourceField.getName(),sourceClass.getSimpleName()) + ". More information: "+plus); }
[ "public", "static", "void", "badConversion", "(", "Field", "destinationField", ",", "Class", "<", "?", ">", "destinationClass", ",", "Field", "sourceField", ",", "Class", "<", "?", ">", "sourceClass", ",", "String", "plus", ")", "{", "throw", "new", "UndefinedMappingException", "(", "MSG", ".", "INSTANCE", ".", "message", "(", "undefinedMappingException", ",", "destinationField", ".", "getName", "(", ")", ",", "destinationClass", ".", "getSimpleName", "(", ")", ",", "sourceField", ".", "getName", "(", ")", ",", "sourceClass", ".", "getSimpleName", "(", ")", ")", "+", "\". More information: \"", "+", "plus", ")", ";", "}" ]
Thrown when conversions are badly written. @param destinationField destination field @param destinationClass destination class @param sourceField source field @param sourceClass source class @param plus added messages of internal exceptions thrown
[ "Thrown", "when", "conversions", "are", "badly", "written", "." ]
train
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java#L408-L410
guicamest/bsoneer
compiler/compiler/src/main/java/com/sleepcamel/bsoneer/processor/util/Util.java
Util.getAnnotation
public static Map<String, Object> getAnnotation(Class<?> annotationType, Element element) { """ Returns the annotation on {@code element} formatted as a Map. This returns a Map rather than an instance of the annotation interface to work-around the fact that Class and Class[] fields won't work at code generation time. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5089128 """ for (AnnotationMirror annotation : element.getAnnotationMirrors()) { if (!rawTypeToString(annotation.getAnnotationType(), '$').equals( annotationType.getName())) { continue; } return parseAnnotationMirror(annotationType, annotation); } return null; // Annotation not found. }
java
public static Map<String, Object> getAnnotation(Class<?> annotationType, Element element) { for (AnnotationMirror annotation : element.getAnnotationMirrors()) { if (!rawTypeToString(annotation.getAnnotationType(), '$').equals( annotationType.getName())) { continue; } return parseAnnotationMirror(annotationType, annotation); } return null; // Annotation not found. }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "getAnnotation", "(", "Class", "<", "?", ">", "annotationType", ",", "Element", "element", ")", "{", "for", "(", "AnnotationMirror", "annotation", ":", "element", ".", "getAnnotationMirrors", "(", ")", ")", "{", "if", "(", "!", "rawTypeToString", "(", "annotation", ".", "getAnnotationType", "(", ")", ",", "'", "'", ")", ".", "equals", "(", "annotationType", ".", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "return", "parseAnnotationMirror", "(", "annotationType", ",", "annotation", ")", ";", "}", "return", "null", ";", "// Annotation not found.", "}" ]
Returns the annotation on {@code element} formatted as a Map. This returns a Map rather than an instance of the annotation interface to work-around the fact that Class and Class[] fields won't work at code generation time. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5089128
[ "Returns", "the", "annotation", "on", "{" ]
train
https://github.com/guicamest/bsoneer/blob/170a4a5d99519c49ee01a38bb1562a42375f686d/compiler/compiler/src/main/java/com/sleepcamel/bsoneer/processor/util/Util.java#L137-L148
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTemplateElement.java
ElemTemplateElement.replaceChild
public Node replaceChild(Node newChild, Node oldChild) throws DOMException { """ Replace the old child with a new child. @param newChild New child to replace with @param oldChild Old child to be replaced @return The new child @throws DOMException """ if (oldChild == null || oldChild.getParentNode() != this) return null; ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild); ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild); // Fix up previous sibling. ElemTemplateElement prev = (ElemTemplateElement) oldChildElem.getPreviousSibling(); if (null != prev) prev.m_nextSibling = newChildElem; // Fix up parent (this) if (m_firstChild == oldChildElem) m_firstChild = newChildElem; newChildElem.m_parentNode = this; oldChildElem.m_parentNode = null; newChildElem.m_nextSibling = oldChildElem.m_nextSibling; oldChildElem.m_nextSibling = null; // newChildElem.m_stylesheet = oldChildElem.m_stylesheet; // oldChildElem.m_stylesheet = null; return newChildElem; }
java
public Node replaceChild(Node newChild, Node oldChild) throws DOMException { if (oldChild == null || oldChild.getParentNode() != this) return null; ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild); ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild); // Fix up previous sibling. ElemTemplateElement prev = (ElemTemplateElement) oldChildElem.getPreviousSibling(); if (null != prev) prev.m_nextSibling = newChildElem; // Fix up parent (this) if (m_firstChild == oldChildElem) m_firstChild = newChildElem; newChildElem.m_parentNode = this; oldChildElem.m_parentNode = null; newChildElem.m_nextSibling = oldChildElem.m_nextSibling; oldChildElem.m_nextSibling = null; // newChildElem.m_stylesheet = oldChildElem.m_stylesheet; // oldChildElem.m_stylesheet = null; return newChildElem; }
[ "public", "Node", "replaceChild", "(", "Node", "newChild", ",", "Node", "oldChild", ")", "throws", "DOMException", "{", "if", "(", "oldChild", "==", "null", "||", "oldChild", ".", "getParentNode", "(", ")", "!=", "this", ")", "return", "null", ";", "ElemTemplateElement", "newChildElem", "=", "(", "(", "ElemTemplateElement", ")", "newChild", ")", ";", "ElemTemplateElement", "oldChildElem", "=", "(", "(", "ElemTemplateElement", ")", "oldChild", ")", ";", "// Fix up previous sibling.", "ElemTemplateElement", "prev", "=", "(", "ElemTemplateElement", ")", "oldChildElem", ".", "getPreviousSibling", "(", ")", ";", "if", "(", "null", "!=", "prev", ")", "prev", ".", "m_nextSibling", "=", "newChildElem", ";", "// Fix up parent (this)", "if", "(", "m_firstChild", "==", "oldChildElem", ")", "m_firstChild", "=", "newChildElem", ";", "newChildElem", ".", "m_parentNode", "=", "this", ";", "oldChildElem", ".", "m_parentNode", "=", "null", ";", "newChildElem", ".", "m_nextSibling", "=", "oldChildElem", ".", "m_nextSibling", ";", "oldChildElem", ".", "m_nextSibling", "=", "null", ";", "// newChildElem.m_stylesheet = oldChildElem.m_stylesheet;", "// oldChildElem.m_stylesheet = null;", "return", "newChildElem", ";", "}" ]
Replace the old child with a new child. @param newChild New child to replace with @param oldChild Old child to be replaced @return The new child @throws DOMException
[ "Replace", "the", "old", "child", "with", "a", "new", "child", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTemplateElement.java#L394-L422
facebookarchive/hadoop-20
src/core/org/apache/hadoop/fs/FileSystem.java
FileSystem.setDefaultUri
public static void setDefaultUri(Configuration conf, URI uri) { """ Set the default filesystem URI in a configuration. @param conf the configuration to alter @param uri the new default filesystem uri """ conf.set(FS_DEFAULT_NAME_KEY, uri.toString()); }
java
public static void setDefaultUri(Configuration conf, URI uri) { conf.set(FS_DEFAULT_NAME_KEY, uri.toString()); }
[ "public", "static", "void", "setDefaultUri", "(", "Configuration", "conf", ",", "URI", "uri", ")", "{", "conf", ".", "set", "(", "FS_DEFAULT_NAME_KEY", ",", "uri", ".", "toString", "(", ")", ")", ";", "}" ]
Set the default filesystem URI in a configuration. @param conf the configuration to alter @param uri the new default filesystem uri
[ "Set", "the", "default", "filesystem", "URI", "in", "a", "configuration", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/fs/FileSystem.java#L124-L126
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.getNamedObject
public <T> T getNamedObject(String name, Class<T> type) { """ Retrieves a named object of a specific type from this binder. """ return type.cast(_named.get(name)); }
java
public <T> T getNamedObject(String name, Class<T> type) { return type.cast(_named.get(name)); }
[ "public", "<", "T", ">", "T", "getNamedObject", "(", "String", "name", ",", "Class", "<", "T", ">", "type", ")", "{", "return", "type", ".", "cast", "(", "_named", ".", "get", "(", "name", ")", ")", ";", "}" ]
Retrieves a named object of a specific type from this binder.
[ "Retrieves", "a", "named", "object", "of", "a", "specific", "type", "from", "this", "binder", "." ]
train
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L120-L122