repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/SettingsPack.java
SettingsPack.connectionsLimit
public SettingsPack connectionsLimit(int value) { sp.set_int(settings_pack.int_types.connections_limit.swigValue(), value); return this; }
java
public SettingsPack connectionsLimit(int value) { sp.set_int(settings_pack.int_types.connections_limit.swigValue(), value); return this; }
[ "public", "SettingsPack", "connectionsLimit", "(", "int", "value", ")", "{", "sp", ".", "set_int", "(", "settings_pack", ".", "int_types", ".", "connections_limit", ".", "swigValue", "(", ")", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a global limit on the number of connections opened. The number of connections is set to a hard minimum of at least two per torrent, so if you set a too low connections limit, and open too many torrents, the limit will not be met. @param value
[ "Sets", "a", "global", "limit", "on", "the", "number", "of", "connections", "opened", ".", "The", "number", "of", "connections", "is", "set", "to", "a", "hard", "minimum", "of", "at", "least", "two", "per", "torrent", "so", "if", "you", "set", "a", "to...
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SettingsPack.java#L326-L329
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/SettingsPack.java
SettingsPack.maxPeerlistSize
public SettingsPack maxPeerlistSize(int value) { sp.set_int(settings_pack.int_types.max_peerlist_size.swigValue(), value); return this; }
java
public SettingsPack maxPeerlistSize(int value) { sp.set_int(settings_pack.int_types.max_peerlist_size.swigValue(), value); return this; }
[ "public", "SettingsPack", "maxPeerlistSize", "(", "int", "value", ")", "{", "sp", ".", "set_int", "(", "settings_pack", ".", "int_types", ".", "max_peerlist_size", ".", "swigValue", "(", ")", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets the maximum number of peers in the list of known peers. These peers are not necessarily connected, so this number should be much greater than the maximum number of connected peers. Peers are evicted from the cache when the list grows passed 90% of this limit, and once the size hits the limit, peers are no longer a...
[ "Sets", "the", "maximum", "number", "of", "peers", "in", "the", "list", "of", "known", "peers", ".", "These", "peers", "are", "not", "necessarily", "connected", "so", "this", "number", "should", "be", "much", "greater", "than", "the", "maximum", "number", ...
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SettingsPack.java#L349-L352
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/SettingsPack.java
SettingsPack.inactivityTimeout
public SettingsPack inactivityTimeout(int value) { sp.set_int(settings_pack.int_types.inactivity_timeout.swigValue(), value); return this; }
java
public SettingsPack inactivityTimeout(int value) { sp.set_int(settings_pack.int_types.inactivity_timeout.swigValue(), value); return this; }
[ "public", "SettingsPack", "inactivityTimeout", "(", "int", "value", ")", "{", "sp", ".", "set_int", "(", "settings_pack", ".", "int_types", ".", "inactivity_timeout", ".", "swigValue", "(", ")", ",", "value", ")", ";", "return", "this", ";", "}" ]
if a peer is uninteresting and uninterested for longer than this number of seconds, it will be disconnected. default is 10 minutes @param value
[ "if", "a", "peer", "is", "uninteresting", "and", "uninterested", "for", "longer", "than", "this", "number", "of", "seconds", "it", "will", "be", "disconnected", ".", "default", "is", "10", "minutes" ]
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SettingsPack.java#L471-L474
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/SettingsPack.java
SettingsPack.enableDht
public SettingsPack enableDht(boolean value) { sp.set_bool(settings_pack.bool_types.enable_dht.swigValue(), value); return this; }
java
public SettingsPack enableDht(boolean value) { sp.set_bool(settings_pack.bool_types.enable_dht.swigValue(), value); return this; }
[ "public", "SettingsPack", "enableDht", "(", "boolean", "value", ")", "{", "sp", ".", "set_bool", "(", "settings_pack", ".", "bool_types", ".", "enable_dht", ".", "swigValue", "(", ")", ",", "value", ")", ";", "return", "this", ";", "}" ]
Starts the dht node and makes the trackerless service available to torrents. @param value @return this
[ "Starts", "the", "dht", "node", "and", "makes", "the", "trackerless", "service", "available", "to", "torrents", "." ]
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SettingsPack.java#L545-L548
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/SettingsPack.java
SettingsPack.upnpIgnoreNonRouters
public SettingsPack upnpIgnoreNonRouters(boolean value) { sp.set_bool(settings_pack.bool_types.upnp_ignore_nonrouters.swigValue(), value); return this; }
java
public SettingsPack upnpIgnoreNonRouters(boolean value) { sp.set_bool(settings_pack.bool_types.upnp_ignore_nonrouters.swigValue(), value); return this; }
[ "public", "SettingsPack", "upnpIgnoreNonRouters", "(", "boolean", "value", ")", "{", "sp", ".", "set_bool", "(", "settings_pack", ".", "bool_types", ".", "upnp_ignore_nonrouters", ".", "swigValue", "(", ")", ",", "value", ")", ";", "return", "this", ";", "}" ]
Indicates whether or not the UPnP implementation should ignore any broadcast response from a device whose address is not the configured router for this machine. i.e. it's a way to not talk to other people's routers by mistake. @param value the new value @return this
[ "Indicates", "whether", "or", "not", "the", "UPnP", "implementation", "should", "ignore", "any", "broadcast", "response", "from", "a", "device", "whose", "address", "is", "not", "the", "configured", "router", "for", "this", "machine", ".", "i", ".", "e", "."...
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SettingsPack.java#L631-L634
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java
TorrentBuilder.addNode
public TorrentBuilder addNode(Pair<String, Integer> value) { if (value != null) { this.nodes.add(value); } return this; }
java
public TorrentBuilder addNode(Pair<String, Integer> value) { if (value != null) { this.nodes.add(value); } return this; }
[ "public", "TorrentBuilder", "addNode", "(", "Pair", "<", "String", ",", "Integer", ">", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "this", ".", "nodes", ".", "add", "(", "value", ")", ";", "}", "return", "this", ";", "}" ]
This adds a DHT node to the torrent. This especially useful if you're creating a tracker less torrent. It can be used by clients to bootstrap their DHT node from. The node is a hostname and a port number where there is a DHT node running. You can have any number of DHT nodes in a torrent. @param value @return
[ "This", "adds", "a", "DHT", "node", "to", "the", "torrent", ".", "This", "especially", "useful", "if", "you", "re", "creating", "a", "tracker", "less", "torrent", ".", "It", "can", "be", "used", "by", "clients", "to", "bootstrap", "their", "DHT", "node",...
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java#L290-L295
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java
TorrentBuilder.generate
public Result generate() throws IOException { if (path == null) { throw new IOException("path can't be null"); } File absPath = path.getAbsoluteFile(); file_storage fs = new file_storage(); add_files_listener l1 = new add_files_listener() { @Override ...
java
public Result generate() throws IOException { if (path == null) { throw new IOException("path can't be null"); } File absPath = path.getAbsoluteFile(); file_storage fs = new file_storage(); add_files_listener l1 = new add_files_listener() { @Override ...
[ "public", "Result", "generate", "(", ")", "throws", "IOException", "{", "if", "(", "path", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"path can't be null\"", ")", ";", "}", "File", "absPath", "=", "path", ".", "getAbsoluteFile", "(", ")"...
This function will generate a result withe the .torrent file as a bencode tree. @return @throws IOException
[ "This", "function", "will", "generate", "a", "result", "withe", "the", ".", "torrent", "file", "as", "a", "bencode", "tree", "." ]
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java#L472-L544
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/Files.java
Files.bytes
public static byte[] bytes(File file) throws IOException { InputStream in = null; try { in = openInputStream(file); return toByteArray(in, file.length()); } finally { closeQuietly(in); } }
java
public static byte[] bytes(File file) throws IOException { InputStream in = null; try { in = openInputStream(file); return toByteArray(in, file.length()); } finally { closeQuietly(in); } }
[ "public", "static", "byte", "[", "]", "bytes", "(", "File", "file", ")", "throws", "IOException", "{", "InputStream", "in", "=", "null", ";", "try", "{", "in", "=", "openInputStream", "(", "file", ")", ";", "return", "toByteArray", "(", "in", ",", "fil...
Reads the contents of a file into a byte array. The file is always closed. @param file the file to read, must not be {@code null} @return the file contents, never {@code null} @throws IOException in case of an I/O error @since 1.1
[ "Reads", "the", "contents", "of", "a", "file", "into", "a", "byte", "array", ".", "The", "file", "is", "always", "closed", "." ]
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/Files.java#L38-L46
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/TorrentHandle.java
TorrentHandle.filePriorities
public Priority[] filePriorities() { int_vector v = th.get_file_priorities2(); int size = (int) v.size(); Priority[] arr = new Priority[size]; for (int i = 0; i < size; i++) { arr[i] = Priority.fromSwig(v.get(i)); } return arr; }
java
public Priority[] filePriorities() { int_vector v = th.get_file_priorities2(); int size = (int) v.size(); Priority[] arr = new Priority[size]; for (int i = 0; i < size; i++) { arr[i] = Priority.fromSwig(v.get(i)); } return arr; }
[ "public", "Priority", "[", "]", "filePriorities", "(", ")", "{", "int_vector", "v", "=", "th", ".", "get_file_priorities2", "(", ")", ";", "int", "size", "=", "(", "int", ")", "v", ".", "size", "(", ")", ";", "Priority", "[", "]", "arr", "=", "new"...
Returns a vector with the priorities of all files. @return the array of priorities.
[ "Returns", "a", "vector", "with", "the", "priorities", "of", "all", "files", "." ]
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentHandle.java#L1149-L1157
train
frostwire/frostwire-jlibtorrent
src/main/java/com/frostwire/jlibtorrent/TorrentHandle.java
TorrentHandle.name
public String name() { torrent_status ts = th.status(torrent_handle.query_name); return ts.getName(); }
java
public String name() { torrent_status ts = th.status(torrent_handle.query_name); return ts.getName(); }
[ "public", "String", "name", "(", ")", "{", "torrent_status", "ts", "=", "th", ".", "status", "(", "torrent_handle", ".", "query_name", ")", ";", "return", "ts", ".", "getName", "(", ")", ";", "}" ]
The name of the torrent. Typically this is derived from the .torrent file. In case the torrent was started without metadata, and hasn't completely received it yet, it returns the name given to it when added to the session. @return the name
[ "The", "name", "of", "the", "torrent", ".", "Typically", "this", "is", "derived", "from", "the", ".", "torrent", "file", ".", "In", "case", "the", "torrent", "was", "started", "without", "metadata", "and", "hasn", "t", "completely", "received", "it", "yet"...
a29249a940d34aba8c4677d238b472ef01833506
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentHandle.java#L1291-L1294
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/gson/Optional.java
Optional.of
public static <T, S extends T> Optional<T> of(S value) { if (value == null) { throw new IllegalArgumentException("Optional does not support NULL, use Optional.empty() instead."); } return new Optional<T>(value); }
java
public static <T, S extends T> Optional<T> of(S value) { if (value == null) { throw new IllegalArgumentException("Optional does not support NULL, use Optional.empty() instead."); } return new Optional<T>(value); }
[ "public", "static", "<", "T", ",", "S", "extends", "T", ">", "Optional", "<", "T", ">", "of", "(", "S", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Optional does not support NULL, use O...
Create a new Optional containing value. @param value The value contained. @return The value wrapped in an Optional.
[ "Create", "a", "new", "Optional", "containing", "value", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/gson/Optional.java#L26-L32
train
plaid/plaid-java
src/main/java/com/plaid/client/PlaidClient.java
PlaidClient.parseError
public ErrorResponse parseError(Response response) { if (response.isSuccessful()) { throw new IllegalArgumentException("Response must be unsuccessful."); } Converter<ResponseBody, ErrorResponse> responseBodyObjectConverter = retrofit.responseBodyConverter(ErrorResponse.class, new Annotation[0])...
java
public ErrorResponse parseError(Response response) { if (response.isSuccessful()) { throw new IllegalArgumentException("Response must be unsuccessful."); } Converter<ResponseBody, ErrorResponse> responseBodyObjectConverter = retrofit.responseBodyConverter(ErrorResponse.class, new Annotation[0])...
[ "public", "ErrorResponse", "parseError", "(", "Response", "response", ")", "{", "if", "(", "response", ".", "isSuccessful", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Response must be unsuccessful.\"", ")", ";", "}", "Converter", "<", ...
A helper to assist with decoding unsuccessful responses. This is not done automatically, because an unsuccessful result may have many causes such as network issues, intervening HTTP proxies, load balancers, partial responses, etc, which means that a response can easily be incomplete, or not even the expected well-form...
[ "A", "helper", "to", "assist", "with", "decoding", "unsuccessful", "responses", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/PlaidClient.java#L80-L93
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.notEmpty
public static void notEmpty(Collection collection, String name) { notNull(collection, name); if (collection.isEmpty()) { throw new IllegalArgumentException(name + " must not be empty"); } }
java
public static void notEmpty(Collection collection, String name) { notNull(collection, name); if (collection.isEmpty()) { throw new IllegalArgumentException(name + " must not be empty"); } }
[ "public", "static", "void", "notEmpty", "(", "Collection", "collection", ",", "String", "name", ")", "{", "notNull", "(", "collection", ",", "name", ")", ";", "if", "(", "collection", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentExce...
Checks that a given collection is not null and not empty. @param collection The collection to check @param name The name of the collection to use when raising an error. @throws IllegalArgumentException If the collection was null or empty.
[ "Checks", "that", "a", "given", "collection", "is", "not", "null", "and", "not", "empty", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L30-L36
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.notEmpty
public static void notEmpty(Object[] arr, String name) { notNull(arr, name); if (arr.length == 0) { throw new IllegalArgumentException(name + "must not be empty"); } }
java
public static void notEmpty(Object[] arr, String name) { notNull(arr, name); if (arr.length == 0) { throw new IllegalArgumentException(name + "must not be empty"); } }
[ "public", "static", "void", "notEmpty", "(", "Object", "[", "]", "arr", ",", "String", "name", ")", "{", "notNull", "(", "arr", ",", "name", ")", ";", "if", "(", "arr", ".", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "...
Checks that a given array is not null and not empty. @param arr The array to check @param name The name of the array to use when raising an error. @throws IllegalArgumentException If the collection was null or empty.
[ "Checks", "that", "a", "given", "array", "is", "not", "null", "and", "not", "empty", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L45-L51
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.notEmpty
public static void notEmpty(Map map, String name) { notNull(map, name); if (map.isEmpty()) { throw new IllegalArgumentException(name + " must not be empty"); } }
java
public static void notEmpty(Map map, String name) { notNull(map, name); if (map.isEmpty()) { throw new IllegalArgumentException(name + " must not be empty"); } }
[ "public", "static", "void", "notEmpty", "(", "Map", "map", ",", "String", "name", ")", "{", "notNull", "(", "map", ",", "name", ")", ";", "if", "(", "map", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "name", "...
Checks that a given map is not null and not empty. @param map The map to check @param name The name of the collection to use when raising an error. @throws IllegalArgumentException If the collection was null or empty.
[ "Checks", "that", "a", "given", "map", "is", "not", "null", "and", "not", "empty", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L60-L66
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.isBetween
public static void isBetween(Integer value, int min, int max, String name) { notNull(value, name); if (value < min || value > max) { throw new IllegalArgumentException(name + "(" + value + ") out of range: " + min + " <= " + name + " <= " + max); } }
java
public static void isBetween(Integer value, int min, int max, String name) { notNull(value, name); if (value < min || value > max) { throw new IllegalArgumentException(name + "(" + value + ") out of range: " + min + " <= " + name + " <= " + max); } }
[ "public", "static", "void", "isBetween", "(", "Integer", "value", ",", "int", "min", ",", "int", "max", ",", "String", "name", ")", "{", "notNull", "(", "value", ",", "name", ")", ";", "if", "(", "value", "<", "min", "||", "value", ">", "max", ")",...
Checks that i is not null and is in the range min &lt;= i &lt;= max. @param value The integer value to check. @param min The minimum bound, inclusive. @param max The maximum bound, inclusive. @param name The name of the variable being checked, included when an error is raised. @throws IllegalArgumentException If ...
[ "Checks", "that", "i", "is", "not", "null", "and", "is", "in", "the", "range", "min", "&lt", ";", "=", "i", "&lt", ";", "=", "max", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L77-L83
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.isPositive
public static void isPositive(Integer value, String name) { notNull(value, name); if (value < 0) { throw new IllegalArgumentException(name + "must be a positive number."); } }
java
public static void isPositive(Integer value, String name) { notNull(value, name); if (value < 0) { throw new IllegalArgumentException(name + "must be a positive number."); } }
[ "public", "static", "void", "isPositive", "(", "Integer", "value", ",", "String", "name", ")", "{", "notNull", "(", "value", ",", "name", ")", ";", "if", "(", "value", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "name", "+", "\...
Checks that i is not null and is a positive number @param value The integer value to check. @param name The name of the variable being checked, included when an error is raised. @throws IllegalArgumentException If i is null or less than 0
[ "Checks", "that", "i", "is", "not", "null", "and", "is", "a", "positive", "number" ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L92-L98
train
plaid/plaid-java
src/main/java/com/plaid/client/internal/Util.java
Util.arrayToMap
public static Map<String, String> arrayToMap(String[] args) { if (args.length % 2 != 0) { throw new IllegalArgumentException("Must pass in an even number of args, one key per value."); } Map<String, String> ret = new HashMap<>(); for (int i = 0; i < args.length; i += 2) { ret.put(args[i], ...
java
public static Map<String, String> arrayToMap(String[] args) { if (args.length % 2 != 0) { throw new IllegalArgumentException("Must pass in an even number of args, one key per value."); } Map<String, String> ret = new HashMap<>(); for (int i = 0; i < args.length; i += 2) { ret.put(args[i], ...
[ "public", "static", "Map", "<", "String", ",", "String", ">", "arrayToMap", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "%", "2", "!=", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Must pass in an ev...
Helper to convert an alternating key1,value1,key2,value2,... array into a map. @param args Alternating arguments. @return Resulting map.
[ "Helper", "to", "convert", "an", "alternating", "key1", "value1", "key2", "value2", "...", "array", "into", "a", "map", "." ]
360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117
https://github.com/plaid/plaid-java/blob/360f1f8a5178fa0c3c2c2e07a58f8ccec5f33117/src/main/java/com/plaid/client/internal/Util.java#L107-L119
train
Netflix/zeno
src/main/java/com/netflix/zeno/util/collections/algorithms/BinarySearch.java
BinarySearch.binarySearch0
private static <T> int binarySearch0(Sortable<T> a, int fromIndex, int toIndex, T key, Comparator<? super T> c) { if (c == null) { throw new NullPointerException(); } int low = fromIndex; int high = toIndex - 1; while (low <= high) { int mid = (low + high...
java
private static <T> int binarySearch0(Sortable<T> a, int fromIndex, int toIndex, T key, Comparator<? super T> c) { if (c == null) { throw new NullPointerException(); } int low = fromIndex; int high = toIndex - 1; while (low <= high) { int mid = (low + high...
[ "private", "static", "<", "T", ">", "int", "binarySearch0", "(", "Sortable", "<", "T", ">", "a", ",", "int", "fromIndex", ",", "int", "toIndex", ",", "T", "key", ",", "Comparator", "<", "?", "super", "T", ">", "c", ")", "{", "if", "(", "c", "==",...
Like public version, but without range checks.
[ "Like", "public", "version", "but", "without", "range", "checks", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/util/collections/algorithms/BinarySearch.java#L97-L116
train
Netflix/zeno
src/main/java/com/netflix/zeno/diff/history/DiffHistoryTracker.java
DiffHistoryTracker.addState
public void addState() { DiffHistoryDataState nextState = new DiffHistoryDataState(stateEngine, typeDiffInstructions); if(currentDataState != null) newHistoricalState(currentDataState, nextState); currentDataState = nextState; }
java
public void addState() { DiffHistoryDataState nextState = new DiffHistoryDataState(stateEngine, typeDiffInstructions); if(currentDataState != null) newHistoricalState(currentDataState, nextState); currentDataState = nextState; }
[ "public", "void", "addState", "(", ")", "{", "DiffHistoryDataState", "nextState", "=", "new", "DiffHistoryDataState", "(", "stateEngine", ",", "typeDiffInstructions", ")", ";", "if", "(", "currentDataState", "!=", "null", ")", "newHistoricalState", "(", "currentData...
Call this method after new data has been loaded by the FastBlobStateEngine. This will add a historical record of the differences between the previous state and this new state.
[ "Call", "this", "method", "after", "new", "data", "has", "been", "loaded", "by", "the", "FastBlobStateEngine", ".", "This", "will", "add", "a", "historical", "record", "of", "the", "differences", "between", "the", "previous", "state", "and", "this", "new", "...
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/diff/history/DiffHistoryTracker.java#L76-L83
train
Netflix/zeno
src/main/java/com/netflix/zeno/genericobject/DiffHtmlGenerator.java
DiffHtmlGenerator.generateDiff
public String generateDiff(String objectType, Object from, Object to) { GenericObject fromGenericObject = from == null ? null : genericObjectFramework.serialize(from, objectType); GenericObject toGenericObject = to == null ? null : genericObjectFramework.serialize(to, objectType); return genera...
java
public String generateDiff(String objectType, Object from, Object to) { GenericObject fromGenericObject = from == null ? null : genericObjectFramework.serialize(from, objectType); GenericObject toGenericObject = to == null ? null : genericObjectFramework.serialize(to, objectType); return genera...
[ "public", "String", "generateDiff", "(", "String", "objectType", ",", "Object", "from", ",", "Object", "to", ")", "{", "GenericObject", "fromGenericObject", "=", "from", "==", "null", "?", "null", ":", "genericObjectFramework", ".", "serialize", "(", "from", "...
Generate the HTML difference between two objects. @param objectType - The NFTypeSerializer name of the objects @param from - The first object to diff @param to - The second object to diff @return
[ "Generate", "the", "HTML", "difference", "between", "two", "objects", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/genericobject/DiffHtmlGenerator.java#L65-L70
train
Netflix/zeno
src/main/java/com/netflix/zeno/genericobject/DiffHtmlGenerator.java
DiffHtmlGenerator.generateDiff
public String generateDiff(GenericObject from, GenericObject to) { StringBuilder builder = new StringBuilder(); builder.append("<table class=\"nomargin diff\">"); builder.append("<thead>"); builder.append("<tr>"); builder.append("<th/>"); builder.append("<th class=\"text...
java
public String generateDiff(GenericObject from, GenericObject to) { StringBuilder builder = new StringBuilder(); builder.append("<table class=\"nomargin diff\">"); builder.append("<thead>"); builder.append("<tr>"); builder.append("<th/>"); builder.append("<th class=\"text...
[ "public", "String", "generateDiff", "(", "GenericObject", "from", ",", "GenericObject", "to", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"<table class=\\\"nomargin diff\\\">\"", ")", ";", "bui...
Generate the HTML difference between two GenericObjects. @return
[ "Generate", "the", "HTML", "difference", "between", "two", "GenericObjects", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/genericobject/DiffHtmlGenerator.java#L77-L98
train
Netflix/zeno
src/main/java/com/netflix/zeno/diff/DiffOperation.java
DiffOperation.performDiff
public DiffReport performDiff(FastBlobStateEngine fromState, FastBlobStateEngine toState) throws DiffReportGenerationException { return performDiff(null, fromState, toState); }
java
public DiffReport performDiff(FastBlobStateEngine fromState, FastBlobStateEngine toState) throws DiffReportGenerationException { return performDiff(null, fromState, toState); }
[ "public", "DiffReport", "performDiff", "(", "FastBlobStateEngine", "fromState", ",", "FastBlobStateEngine", "toState", ")", "throws", "DiffReportGenerationException", "{", "return", "performDiff", "(", "null", ",", "fromState", ",", "toState", ")", ";", "}" ]
Perform a diff between two data states. Note: For now, this operation will ignore type instructions for non-unique keys. @param fromState - The "from" state engine, populated with one of the deserialized data states to compare @param toState - the "to" state engine, populated with the other deserialized data state t...
[ "Perform", "a", "diff", "between", "two", "data", "states", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/diff/DiffOperation.java#L53-L55
train
Netflix/zeno
src/examples/java/com/netflix/zeno/examples/HeapFriendlyHashMapExample.java
HeapFriendlyHashMapExample.runCycle
public void runCycle(int... valuesForMap) { /// prepare the map Object array recycler for a new cycle. HeapFriendlyMapArrayRecycler.get().swapCycleObjectArrays(); try { makeDataAvailableToApplication(valuesForMap); } finally { // fill all of the Object arrays whi...
java
public void runCycle(int... valuesForMap) { /// prepare the map Object array recycler for a new cycle. HeapFriendlyMapArrayRecycler.get().swapCycleObjectArrays(); try { makeDataAvailableToApplication(valuesForMap); } finally { // fill all of the Object arrays whi...
[ "public", "void", "runCycle", "(", "int", "...", "valuesForMap", ")", "{", "/// prepare the map Object array recycler for a new cycle.", "HeapFriendlyMapArrayRecycler", ".", "get", "(", ")", ".", "swapCycleObjectArrays", "(", ")", ";", "try", "{", "makeDataAvailableToAppl...
For each cycle, we need to perform some administrative tasks.
[ "For", "each", "cycle", "we", "need", "to", "perform", "some", "administrative", "tasks", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/examples/java/com/netflix/zeno/examples/HeapFriendlyHashMapExample.java#L55-L66
train
Netflix/zeno
src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java
FrameworkSerializer.serializePrimitive
public void serializePrimitive(S rec, String fieldName, long value) { serializePrimitive(rec, fieldName, Long.valueOf(value)); }
java
public void serializePrimitive(S rec, String fieldName, long value) { serializePrimitive(rec, fieldName, Long.valueOf(value)); }
[ "public", "void", "serializePrimitive", "(", "S", "rec", ",", "String", "fieldName", ",", "long", "value", ")", "{", "serializePrimitive", "(", "rec", ",", "fieldName", ",", "Long", ".", "valueOf", "(", "value", ")", ")", ";", "}" ]
Can be overridden to avoid boxing a long where appropriate
[ "Can", "be", "overridden", "to", "avoid", "boxing", "a", "long", "where", "appropriate" ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java#L76-L78
train
Netflix/zeno
src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java
FrameworkSerializer.serializePrimitive
public void serializePrimitive(S rec, String fieldName, float value) { serializePrimitive(rec, fieldName, Float.valueOf(value)); }
java
public void serializePrimitive(S rec, String fieldName, float value) { serializePrimitive(rec, fieldName, Float.valueOf(value)); }
[ "public", "void", "serializePrimitive", "(", "S", "rec", ",", "String", "fieldName", ",", "float", "value", ")", "{", "serializePrimitive", "(", "rec", ",", "fieldName", ",", "Float", ".", "valueOf", "(", "value", ")", ")", ";", "}" ]
Can be overridden to avoid boxing a float where appropriate
[ "Can", "be", "overridden", "to", "avoid", "boxing", "a", "float", "where", "appropriate" ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java#L83-L85
train
Netflix/zeno
src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java
FrameworkSerializer.serializePrimitive
public void serializePrimitive(S rec, String fieldName, double value) { serializePrimitive(rec, fieldName, Double.valueOf(value)); }
java
public void serializePrimitive(S rec, String fieldName, double value) { serializePrimitive(rec, fieldName, Double.valueOf(value)); }
[ "public", "void", "serializePrimitive", "(", "S", "rec", ",", "String", "fieldName", ",", "double", "value", ")", "{", "serializePrimitive", "(", "rec", ",", "fieldName", ",", "Double", ".", "valueOf", "(", "value", ")", ")", ";", "}" ]
Can be overridden to avoid boxing a double where appropriate
[ "Can", "be", "overridden", "to", "avoid", "boxing", "a", "double", "where", "appropriate" ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java#L90-L92
train
Netflix/zeno
src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java
FrameworkSerializer.serializeSortedMap
public <K, V> void serializeSortedMap(S rec, String fieldName, String keyTypeName, String valueTypeName, SortedMap<K, V> obj) { serializeMap(rec, fieldName, keyTypeName, valueTypeName, obj); }
java
public <K, V> void serializeSortedMap(S rec, String fieldName, String keyTypeName, String valueTypeName, SortedMap<K, V> obj) { serializeMap(rec, fieldName, keyTypeName, valueTypeName, obj); }
[ "public", "<", "K", ",", "V", ">", "void", "serializeSortedMap", "(", "S", "rec", ",", "String", "fieldName", ",", "String", "keyTypeName", ",", "String", "valueTypeName", ",", "SortedMap", "<", "K", ",", "V", ">", "obj", ")", "{", "serializeMap", "(", ...
Serialize sorted map @param rec @param fieldName @param typeName @param obj
[ "Serialize", "sorted", "map" ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/serializer/FrameworkSerializer.java#L165-L167
train
Netflix/zeno
src/main/java/com/netflix/zeno/json/JsonFrameworkSerializer.java
JsonFrameworkSerializer.sortedEntryList
private <K, V> List<Map.Entry<K, V>> sortedEntryList(Map<K, V> obj) { List<Map.Entry<K, V>> entryList = new ArrayList<Map.Entry<K, V>>(obj.entrySet()); Collections.sort(entryList, new Comparator<Map.Entry<K, V>>() { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) ...
java
private <K, V> List<Map.Entry<K, V>> sortedEntryList(Map<K, V> obj) { List<Map.Entry<K, V>> entryList = new ArrayList<Map.Entry<K, V>>(obj.entrySet()); Collections.sort(entryList, new Comparator<Map.Entry<K, V>>() { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) ...
[ "private", "<", "K", ",", "V", ">", "List", "<", "Map", ".", "Entry", "<", "K", ",", "V", ">", ">", "sortedEntryList", "(", "Map", "<", "K", ",", "V", ">", "obj", ")", "{", "List", "<", "Map", ".", "Entry", "<", "K", ",", "V", ">", ">", "...
diffs to match up better.
[ "diffs", "to", "match", "up", "better", "." ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/json/JsonFrameworkSerializer.java#L167-L186
train
Netflix/zeno
src/main/java/com/netflix/zeno/diff/DiffRecordValueListMap.java
DiffRecordValueListMap.getList
public List<Object> getList(DiffPropertyPath path) { Integer listIndex = fieldValuesLists.get(path); if(listIndex == null) return null; return getList(listIndex.intValue()); }
java
public List<Object> getList(DiffPropertyPath path) { Integer listIndex = fieldValuesLists.get(path); if(listIndex == null) return null; return getList(listIndex.intValue()); }
[ "public", "List", "<", "Object", ">", "getList", "(", "DiffPropertyPath", "path", ")", "{", "Integer", "listIndex", "=", "fieldValuesLists", ".", "get", "(", "path", ")", ";", "if", "(", "listIndex", "==", "null", ")", "return", "null", ";", "return", "g...
Get the list of values associated with the supplied DiffPropertyPath
[ "Get", "the", "list", "of", "values", "associated", "with", "the", "supplied", "DiffPropertyPath" ]
e571a3f1e304942724d454408fe6417fe18c20fd
https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/diff/DiffRecordValueListMap.java#L58-L63
train
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java
FrequencySketch.reset
private void reset() { int count = 0; for (int i = 0; i < tableLength; i++) { long t = tableAt(i); count += Long.bitCount(t & ONE_MASK); tableAt(i, (t >>> 1) & RESET_MASK); } size = (size >>> 1) - (count >>> 2); }
java
private void reset() { int count = 0; for (int i = 0; i < tableLength; i++) { long t = tableAt(i); count += Long.bitCount(t & ONE_MASK); tableAt(i, (t >>> 1) & RESET_MASK); } size = (size >>> 1) - (count >>> 2); }
[ "private", "void", "reset", "(", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tableLength", ";", "i", "++", ")", "{", "long", "t", "=", "tableAt", "(", "i", ")", ";", "count", "+=", "Long", ".", ...
Reduces every counter by half of its original value.
[ "Reduces", "every", "counter", "by", "half", "of", "its", "original", "value", "." ]
af47142711993a3eaaf3b496332c27e2b43454e4
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java#L197-L207
train
snazy/ohc
ohc-benchmark/src/main/java/org/caffinitas/ohc/benchmark/distribution/Distribution.java
Distribution.average
public long average() { double sum = 0; int count = 0; for (float d = 0 ; d <= 1.0d ; d += 0.02d) { sum += inverseCumProb(d); count += 1; } return (long) (sum / count); }
java
public long average() { double sum = 0; int count = 0; for (float d = 0 ; d <= 1.0d ; d += 0.02d) { sum += inverseCumProb(d); count += 1; } return (long) (sum / count); }
[ "public", "long", "average", "(", ")", "{", "double", "sum", "=", "0", ";", "int", "count", "=", "0", ";", "for", "(", "float", "d", "=", "0", ";", "d", "<=", "1.0d", ";", "d", "+=", "0.02d", ")", "{", "sum", "+=", "inverseCumProb", "(", "d", ...
approximation of the average; slightly costly to calculate, so should not be invoked frequently
[ "approximation", "of", "the", "average", ";", "slightly", "costly", "to", "calculate", "so", "should", "not", "be", "invoked", "frequently" ]
af47142711993a3eaaf3b496332c27e2b43454e4
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-benchmark/src/main/java/org/caffinitas/ohc/benchmark/distribution/Distribution.java#L45-L55
train
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java
Timeouts.add
void add(long hashEntryAdr, long expireAt) { // just ignore the fact that expireAt can be less than current time int slotNum = slot(expireAt); slots[slotNum].add(hashEntryAdr, expireAt); }
java
void add(long hashEntryAdr, long expireAt) { // just ignore the fact that expireAt can be less than current time int slotNum = slot(expireAt); slots[slotNum].add(hashEntryAdr, expireAt); }
[ "void", "add", "(", "long", "hashEntryAdr", ",", "long", "expireAt", ")", "{", "// just ignore the fact that expireAt can be less than current time", "int", "slotNum", "=", "slot", "(", "expireAt", ")", ";", "slots", "[", "slotNum", "]", ".", "add", "(", "hashEntr...
Add a cache entry. @param hashEntryAdr address of the cache entry @param expireAt absolute expiration timestamp
[ "Add", "a", "cache", "entry", "." ]
af47142711993a3eaaf3b496332c27e2b43454e4
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java#L81-L87
train
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java
Timeouts.remove
void remove(long hashEntryAdr, long expireAt) { int slot = slot(expireAt); slots[slot].remove(hashEntryAdr); }
java
void remove(long hashEntryAdr, long expireAt) { int slot = slot(expireAt); slots[slot].remove(hashEntryAdr); }
[ "void", "remove", "(", "long", "hashEntryAdr", ",", "long", "expireAt", ")", "{", "int", "slot", "=", "slot", "(", "expireAt", ")", ";", "slots", "[", "slot", "]", ".", "remove", "(", "hashEntryAdr", ")", ";", "}" ]
Remote a cache entry. @param hashEntryAdr address of the cache entry @param expireAt absolute expiration timestamp
[ "Remote", "a", "cache", "entry", "." ]
af47142711993a3eaaf3b496332c27e2b43454e4
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java#L95-L99
train
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java
Timeouts.removeExpired
int removeExpired(TimeoutHandler expireHandler) { // ensure the clock never goes backwards long t = ticker.currentTimeMillis(); int expired = 0; for (int i = 0; i < slotCount; i++) { expired += slots[i].removeExpired(t, expireHandler); } return ex...
java
int removeExpired(TimeoutHandler expireHandler) { // ensure the clock never goes backwards long t = ticker.currentTimeMillis(); int expired = 0; for (int i = 0; i < slotCount; i++) { expired += slots[i].removeExpired(t, expireHandler); } return ex...
[ "int", "removeExpired", "(", "TimeoutHandler", "expireHandler", ")", "{", "// ensure the clock never goes backwards", "long", "t", "=", "ticker", ".", "currentTimeMillis", "(", ")", ";", "int", "expired", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", ...
Remove expired entries. @param expireHandler implementation that will be called for each expired entry.
[ "Remove", "expired", "entries", "." ]
af47142711993a3eaaf3b496332c27e2b43454e4
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/Timeouts.java#L114-L125
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/AnnotationAuditingMetadata.java
AnnotationAuditingMetadata.assertValidDateFieldType
private void assertValidDateFieldType(Optional<Field> field) { field.ifPresent(it -> { if (SUPPORTED_DATE_TYPES.contains(it.getType().getName())) { return; } Class<?> type = it.getType(); if (Jsr310Converters.supports(type) || ThreeTenBackPortConverters.supports(type)) { return; } ...
java
private void assertValidDateFieldType(Optional<Field> field) { field.ifPresent(it -> { if (SUPPORTED_DATE_TYPES.contains(it.getType().getName())) { return; } Class<?> type = it.getType(); if (Jsr310Converters.supports(type) || ThreeTenBackPortConverters.supports(type)) { return; } ...
[ "private", "void", "assertValidDateFieldType", "(", "Optional", "<", "Field", ">", "field", ")", "{", "field", ".", "ifPresent", "(", "it", "->", "{", "if", "(", "SUPPORTED_DATE_TYPES", ".", "contains", "(", "it", ".", "getType", "(", ")", ".", "getName", ...
Checks whether the given field has a type that is a supported date type. @param field
[ "Checks", "whether", "the", "given", "field", "has", "a", "type", "that", "is", "a", "supported", "date", "type", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/AnnotationAuditingMetadata.java#L123-L142
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/repository/support/SqlSessionRepositorySupport.java
SqlSessionRepositorySupport.calculateTotal
protected <X> long calculateTotal(Pageable pager, List<X> result) { if (pager.hasPrevious()) { if (CollectionUtils.isEmpty(result)) { return -1; } if (result.size() == pager.getPageSize()) { return -1; } return (pager.getPageNumber() - 1) * pager.getPageSize() + result.size(); } if (result....
java
protected <X> long calculateTotal(Pageable pager, List<X> result) { if (pager.hasPrevious()) { if (CollectionUtils.isEmpty(result)) { return -1; } if (result.size() == pager.getPageSize()) { return -1; } return (pager.getPageNumber() - 1) * pager.getPageSize() + result.size(); } if (result....
[ "protected", "<", "X", ">", "long", "calculateTotal", "(", "Pageable", "pager", ",", "List", "<", "X", ">", "result", ")", "{", "if", "(", "pager", ".", "hasPrevious", "(", ")", ")", "{", "if", "(", "CollectionUtils", ".", "isEmpty", "(", "result", "...
Calculate total mount. @return if return -1 means can not judge ,need count from database.
[ "Calculate", "total", "mount", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/repository/support/SqlSessionRepositorySupport.java#L92-L106
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/AbstractLimitHandler.java
AbstractLimitHandler.bindLimitParameters
protected final int bindLimitParameters(RowSelection selection, PreparedStatement statement, int index) throws SQLException { if (!supportsVariableLimit() || !LimitHelper.hasMaxRows(selection)) { return 0; } final int firstRow = convertToFirstRowValue(LimitHelper.getFirstRow(selection)); final int lastRow...
java
protected final int bindLimitParameters(RowSelection selection, PreparedStatement statement, int index) throws SQLException { if (!supportsVariableLimit() || !LimitHelper.hasMaxRows(selection)) { return 0; } final int firstRow = convertToFirstRowValue(LimitHelper.getFirstRow(selection)); final int lastRow...
[ "protected", "final", "int", "bindLimitParameters", "(", "RowSelection", "selection", ",", "PreparedStatement", "statement", ",", "int", "index", ")", "throws", "SQLException", "{", "if", "(", "!", "supportsVariableLimit", "(", ")", "||", "!", "LimitHelper", ".", ...
Default implementation of binding parameter values needed by the LIMIT clause. @param selection the selection criteria for rows. @param statement Statement to which to bind limit parameter values. @param index Index from which to start binding. @return The number of parameter values bound. @throws SQLException Indicat...
[ "Default", "implementation", "of", "binding", "parameter", "values", "needed", "by", "the", "LIMIT", "clause", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/AbstractLimitHandler.java#L123-L137
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java
MybatisAuditingHandler.markCreated
public <T> T markCreated(T source) { Assert.notNull(source, "Entity must not be null!"); return touch(source, true); }
java
public <T> T markCreated(T source) { Assert.notNull(source, "Entity must not be null!"); return touch(source, true); }
[ "public", "<", "T", ">", "T", "markCreated", "(", "T", "source", ")", "{", "Assert", ".", "notNull", "(", "source", ",", "\"Entity must not be null!\"", ")", ";", "return", "touch", "(", "source", ",", "true", ")", ";", "}" ]
Marks the given object as created. @param source
[ "Marks", "the", "given", "object", "as", "created", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java#L105-L110
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java
MybatisAuditingHandler.markModified
public <T> T markModified(T source) { Assert.notNull(source, "Entity must not be null!"); return touch(source, false); }
java
public <T> T markModified(T source) { Assert.notNull(source, "Entity must not be null!"); return touch(source, false); }
[ "public", "<", "T", ">", "T", "markModified", "(", "T", "source", ")", "{", "Assert", ".", "notNull", "(", "source", ",", "\"Entity must not be null!\"", ")", ";", "return", "touch", "(", "source", ",", "false", ")", ";", "}" ]
Marks the given object as modified. @param source
[ "Marks", "the", "given", "object", "as", "modified", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java#L116-L121
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java
MybatisAuditingHandler.isAuditable
protected final boolean isAuditable(Object source) { Assert.notNull(source, "Source must not be null!"); return factory.getBeanWrapperFor(source).isPresent(); }
java
protected final boolean isAuditable(Object source) { Assert.notNull(source, "Source must not be null!"); return factory.getBeanWrapperFor(source).isPresent(); }
[ "protected", "final", "boolean", "isAuditable", "(", "Object", "source", ")", "{", "Assert", ".", "notNull", "(", "source", ",", "\"Source must not be null!\"", ")", ";", "return", "factory", ".", "getBeanWrapperFor", "(", "source", ")", ".", "isPresent", "(", ...
Returns whether the given source is considered to be auditable in the first place @param source must not be {@literal null}. @return
[ "Returns", "whether", "the", "given", "source", "is", "considered", "to", "be", "auditable", "in", "the", "first", "place" ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java#L128-L133
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java
MybatisAuditingHandler.touchAuditor
private Optional<Object> touchAuditor(AuditableBeanWrapper<?> wrapper, boolean isNew) { Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!"); return auditorAware.map(it -> { Optional<?> auditor = it.getCurrentAuditor(); Assert.notNull(auditor, () -> String.format("Auditor must not be ...
java
private Optional<Object> touchAuditor(AuditableBeanWrapper<?> wrapper, boolean isNew) { Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!"); return auditorAware.map(it -> { Optional<?> auditor = it.getCurrentAuditor(); Assert.notNull(auditor, () -> String.format("Auditor must not be ...
[ "private", "Optional", "<", "Object", ">", "touchAuditor", "(", "AuditableBeanWrapper", "<", "?", ">", "wrapper", ",", "boolean", "isNew", ")", "{", "Assert", ".", "notNull", "(", "wrapper", ",", "\"AuditableBeanWrapper must not be null!\"", ")", ";", "return", ...
Sets modifying and creating auditor. Creating auditor is only set on new auditables. @return
[ "Sets", "modifying", "and", "creating", "auditor", ".", "Creating", "auditor", "is", "only", "set", "on", "new", "auditables", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java#L164-L183
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java
MybatisAuditingHandler.touchDate
private Optional<TemporalAccessor> touchDate(AuditableBeanWrapper<?> wrapper, boolean isNew) { Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!"); Optional<TemporalAccessor> now = dateTimeProvider.getNow(); Assert.notNull(now, () -> String.format("Now must not be null! Returned by: %s!", ...
java
private Optional<TemporalAccessor> touchDate(AuditableBeanWrapper<?> wrapper, boolean isNew) { Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!"); Optional<TemporalAccessor> now = dateTimeProvider.getNow(); Assert.notNull(now, () -> String.format("Now must not be null! Returned by: %s!", ...
[ "private", "Optional", "<", "TemporalAccessor", ">", "touchDate", "(", "AuditableBeanWrapper", "<", "?", ">", "wrapper", ",", "boolean", "isNew", ")", "{", "Assert", ".", "notNull", "(", "wrapper", ",", "\"AuditableBeanWrapper must not be null!\"", ")", ";", "Opti...
Touches the auditable regarding modification and creation date. Creation date is only set on new auditables. @param wrapper @return
[ "Touches", "the", "auditable", "regarding", "modification", "and", "creation", "date", ".", "Creation", "date", "is", "only", "set", "on", "new", "auditables", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/auditing/MybatisAuditingHandler.java#L191-L206
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/repository/support/MybatisMapperBuildAssistant.java
MybatisMapperBuildAssistant.buildSqlSourceFromStrings
protected SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass) { final StringBuilder sql = new StringBuilder(); for (String fragment : strings) { sql.append(fragment); sql.append(" "); } LanguageDriver languageDriver = getLanguageDriver(); return languageDriver.createSql...
java
protected SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass) { final StringBuilder sql = new StringBuilder(); for (String fragment : strings) { sql.append(fragment); sql.append(" "); } LanguageDriver languageDriver = getLanguageDriver(); return languageDriver.createSql...
[ "protected", "SqlSource", "buildSqlSourceFromStrings", "(", "String", "[", "]", "strings", ",", "Class", "<", "?", ">", "parameterTypeClass", ")", "{", "final", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "fragment...
build sql source for mybatis from string concat by array.
[ "build", "sql", "source", "for", "mybatis", "from", "string", "concat", "by", "array", "." ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/repository/support/MybatisMapperBuildAssistant.java#L390-L400
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/LimitHelper.java
LimitHelper.hasMaxRows
public static boolean hasMaxRows(RowSelection selection) { return selection != null && selection.getMaxRows() != null && selection.getMaxRows() > 0; }
java
public static boolean hasMaxRows(RowSelection selection) { return selection != null && selection.getMaxRows() != null && selection.getMaxRows() > 0; }
[ "public", "static", "boolean", "hasMaxRows", "(", "RowSelection", "selection", ")", "{", "return", "selection", "!=", "null", "&&", "selection", ".", "getMaxRows", "(", ")", "!=", "null", "&&", "selection", ".", "getMaxRows", "(", ")", ">", "0", ";", "}" ]
Is a max row limit indicated? @param selection The row selection options @return Whether a max row limit was indicated
[ "Is", "a", "max", "row", "limit", "indicated?" ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/LimitHelper.java#L15-L17
train
hatunet/spring-data-mybatis
spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/LimitHelper.java
LimitHelper.getFirstRow
public static int getFirstRow(RowSelection selection) { return (selection == null || selection.getFirstRow() == null) ? 0 : selection.getFirstRow(); }
java
public static int getFirstRow(RowSelection selection) { return (selection == null || selection.getFirstRow() == null) ? 0 : selection.getFirstRow(); }
[ "public", "static", "int", "getFirstRow", "(", "RowSelection", "selection", ")", "{", "return", "(", "selection", "==", "null", "||", "selection", ".", "getFirstRow", "(", ")", "==", "null", ")", "?", "0", ":", "selection", ".", "getFirstRow", "(", ")", ...
Retrieve the indicated first row for pagination @param selection The row selection options @return The first row
[ "Retrieve", "the", "indicated", "first", "row", "for", "pagination" ]
ee6316f2c29f45e8e9ef1538957a29c21c89055f
https://github.com/hatunet/spring-data-mybatis/blob/ee6316f2c29f45e8e9ef1538957a29c21c89055f/spring-data-mybatis/src/main/java/org/springframework/data/mybatis/dialect/pagination/LimitHelper.java#L46-L48
train
gocardless/gocardless-pro-java
src/main/java/com/gocardless/Webhook.java
Webhook.parse
public static List<Event> parse(String requestBody, String signatureHeader, String webhookEndpointSecret) { if (isValidSignature(requestBody, signatureHeader, webhookEndpointSecret)) { return WebhookParser.parse(requestBody); } else { throw new InvalidSignatureExcepti...
java
public static List<Event> parse(String requestBody, String signatureHeader, String webhookEndpointSecret) { if (isValidSignature(requestBody, signatureHeader, webhookEndpointSecret)) { return WebhookParser.parse(requestBody); } else { throw new InvalidSignatureExcepti...
[ "public", "static", "List", "<", "Event", ">", "parse", "(", "String", "requestBody", ",", "String", "signatureHeader", ",", "String", "webhookEndpointSecret", ")", "{", "if", "(", "isValidSignature", "(", "requestBody", ",", "signatureHeader", ",", "webhookEndpoi...
Validates that a webhook was genuinely sent by GoCardless using `isValidSignature`, and then parses it into an array of `com.gocardless.resources.Event` objects representing each event included in the webhook. @param requestBody the request body @param signatureHeader the signature included in the request, found in th...
[ "Validates", "that", "a", "webhook", "was", "genuinely", "sent", "by", "GoCardless", "using", "isValidSignature", "and", "then", "parses", "it", "into", "an", "array", "of", "com", ".", "gocardless", ".", "resources", ".", "Event", "objects", "representing", "...
e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1
https://github.com/gocardless/gocardless-pro-java/blob/e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1/src/main/java/com/gocardless/Webhook.java#L34-L41
train
gocardless/gocardless-pro-java
src/main/java/com/gocardless/Webhook.java
Webhook.isValidSignature
public static boolean isValidSignature(String requestBody, String signatureHeader, String webhookEndpointSecret) { String computedSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_256, webhookEndpointSecret) .hmacHex(requestBody); return MessageDigest....
java
public static boolean isValidSignature(String requestBody, String signatureHeader, String webhookEndpointSecret) { String computedSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_256, webhookEndpointSecret) .hmacHex(requestBody); return MessageDigest....
[ "public", "static", "boolean", "isValidSignature", "(", "String", "requestBody", ",", "String", "signatureHeader", ",", "String", "webhookEndpointSecret", ")", "{", "String", "computedSignature", "=", "new", "HmacUtils", "(", "HmacAlgorithms", ".", "HMAC_SHA_256", ","...
Validates that a webhook was genuinely sent by GoCardless by computing its signature using the body and your webhook endpoint secret, and comparing that with the signature included in the `Webhook-Signature` header. @param requestBody the request body @param signatureHeader the signature included in the request, found...
[ "Validates", "that", "a", "webhook", "was", "genuinely", "sent", "by", "GoCardless", "by", "computing", "its", "signature", "using", "the", "body", "and", "your", "webhook", "endpoint", "secret", "and", "comparing", "that", "with", "the", "signature", "included"...
e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1
https://github.com/gocardless/gocardless-pro-java/blob/e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1/src/main/java/com/gocardless/Webhook.java#L55-L61
train
gocardless/gocardless-pro-java
src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java
GoCardlessErrorMapper.toException
public static GoCardlessApiException toException(ApiErrorResponse error) { switch (error.getType()) { case GOCARDLESS: return new GoCardlessInternalException(error); case INVALID_API_USAGE: return new InvalidApiUsageException(error); case INVAL...
java
public static GoCardlessApiException toException(ApiErrorResponse error) { switch (error.getType()) { case GOCARDLESS: return new GoCardlessInternalException(error); case INVALID_API_USAGE: return new InvalidApiUsageException(error); case INVAL...
[ "public", "static", "GoCardlessApiException", "toException", "(", "ApiErrorResponse", "error", ")", "{", "switch", "(", "error", ".", "getType", "(", ")", ")", "{", "case", "GOCARDLESS", ":", "return", "new", "GoCardlessInternalException", "(", "error", ")", ";"...
Maps an error response to an exception. @param error the error response to map
[ "Maps", "an", "error", "response", "to", "an", "exception", "." ]
e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1
https://github.com/gocardless/gocardless-pro-java/blob/e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1/src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java#L13-L25
train
gocardless/gocardless-pro-java
src/main/java/com/gocardless/errors/ApiError.java
ApiError.getLinks
public Map<String, String> getLinks() { if (links == null) { return ImmutableMap.of(); } return ImmutableMap.copyOf(links); }
java
public Map<String, String> getLinks() { if (links == null) { return ImmutableMap.of(); } return ImmutableMap.copyOf(links); }
[ "public", "Map", "<", "String", ",", "String", ">", "getLinks", "(", ")", "{", "if", "(", "links", "==", "null", ")", "{", "return", "ImmutableMap", ".", "of", "(", ")", ";", "}", "return", "ImmutableMap", ".", "copyOf", "(", "links", ")", ";", "}"...
Returns the IDs of related objects.
[ "Returns", "the", "IDs", "of", "related", "objects", "." ]
e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1
https://github.com/gocardless/gocardless-pro-java/blob/e121320c9bdfdfc7ca0996b431e5a45c91d0c1c1/src/main/java/com/gocardless/errors/ApiError.java#L60-L65
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java
AllocationMethodAdapter.buildRecorderFromObject
private void buildRecorderFromObject( int opcode, String owner, String name, String signature, boolean itf) { super.visitMethodInsn(opcode, owner, name, signature, itf); // -> stack: ... newobj super.visitInsn(Opcodes.DUP); // -> stack: ... newobj newobj super.visitInsn(Opcodes.DUP); // ->...
java
private void buildRecorderFromObject( int opcode, String owner, String name, String signature, boolean itf) { super.visitMethodInsn(opcode, owner, name, signature, itf); // -> stack: ... newobj super.visitInsn(Opcodes.DUP); // -> stack: ... newobj newobj super.visitInsn(Opcodes.DUP); // ->...
[ "private", "void", "buildRecorderFromObject", "(", "int", "opcode", ",", "String", "owner", ",", "String", "name", ",", "String", "signature", ",", "boolean", "itf", ")", "{", "super", ".", "visitMethodInsn", "(", "opcode", ",", "owner", ",", "name", ",", ...
object, then we get the class and invoke the recorder.
[ "object", "then", "we", "get", "the", "class", "and", "invoke", "the", "recorder", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java#L388-L406
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java
AllocationMethodAdapter.visitMaxs
@Override public void visitMaxs(int maxStack, int maxLocals) { if (localScopes != null) { for (VariableScope scope : localScopes) { super.visitLocalVariable( "xxxxx$" + scope.index, scope.desc, null, scope.start, scope.end, scope.index); } } super.visitMaxs(maxStack, maxLoc...
java
@Override public void visitMaxs(int maxStack, int maxLocals) { if (localScopes != null) { for (VariableScope scope : localScopes) { super.visitLocalVariable( "xxxxx$" + scope.index, scope.desc, null, scope.start, scope.end, scope.index); } } super.visitMaxs(maxStack, maxLoc...
[ "@", "Override", "public", "void", "visitMaxs", "(", "int", "maxStack", ",", "int", "maxLocals", ")", "{", "if", "(", "localScopes", "!=", "null", ")", "{", "for", "(", "VariableScope", "scope", ":", "localScopes", ")", "{", "super", ".", "visitLocalVariab...
Called by the ASM framework once the class is done being visited to compute stack & local variable count maximums.
[ "Called", "by", "the", "ASM", "framework", "once", "the", "class", "is", "done", "being", "visited", "to", "compute", "stack", "&", "local", "variable", "count", "maximums", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java#L466-L475
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java
AllocationMethodAdapter.newLocal
private int newLocal(Type type, String typeDesc, Label begin, Label end) { int newVar = lvs.newLocal(type); getLocalScopes().add(new VariableScope(newVar, begin, end, typeDesc)); return newVar; }
java
private int newLocal(Type type, String typeDesc, Label begin, Label end) { int newVar = lvs.newLocal(type); getLocalScopes().add(new VariableScope(newVar, begin, end, typeDesc)); return newVar; }
[ "private", "int", "newLocal", "(", "Type", "type", ",", "String", "typeDesc", ",", "Label", "begin", ",", "Label", "end", ")", "{", "int", "newVar", "=", "lvs", ".", "newLocal", "(", "type", ")", ";", "getLocalScopes", "(", ")", ".", "add", "(", "new...
Helper method to allocate a new local variable and account for its scope.
[ "Helper", "method", "to", "allocate", "a", "new", "local", "variable", "and", "account", "for", "its", "scope", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java#L478-L482
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java
AllocationMethodAdapter.visitMultiANewArrayInsn
@Override public void visitMultiANewArrayInsn(String typeName, int dimCount) { // stack: ... dim1 dim2 dim3 ... dimN super.visitMultiANewArrayInsn(typeName, dimCount); // -> stack: ... aref calculateArrayLengthAndDispatch(typeName, dimCount); }
java
@Override public void visitMultiANewArrayInsn(String typeName, int dimCount) { // stack: ... dim1 dim2 dim3 ... dimN super.visitMultiANewArrayInsn(typeName, dimCount); // -> stack: ... aref calculateArrayLengthAndDispatch(typeName, dimCount); }
[ "@", "Override", "public", "void", "visitMultiANewArrayInsn", "(", "String", "typeName", ",", "int", "dimCount", ")", "{", "// stack: ... dim1 dim2 dim3 ... dimN", "super", ".", "visitMultiANewArrayInsn", "(", "typeName", ",", "dimCount", ")", ";", "// -> stack: ... are...
multianewarray gets its very own visit method in the ASM framework, so we hook it here. This bytecode is different from most in that it consumes a variable number of stack elements during execution. The number of stack elements consumed is specified by the dimCount operand.
[ "multianewarray", "gets", "its", "very", "own", "visit", "method", "in", "the", "ASM", "framework", "so", "we", "hook", "it", "here", ".", "This", "bytecode", "is", "different", "from", "most", "in", "that", "it", "consumes", "a", "variable", "number", "of...
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java#L523-L529
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
ConstructorInstrumenter.instrumentClass
public static void instrumentClass(Class<?> c, ConstructorCallback<?> sampler) throws UnmodifiableClassException { // IMPORTANT: Don't forget that other threads may be accessing this // class while this code is running. Specifically, the class may be // executed directly after the retransformClasses ...
java
public static void instrumentClass(Class<?> c, ConstructorCallback<?> sampler) throws UnmodifiableClassException { // IMPORTANT: Don't forget that other threads may be accessing this // class while this code is running. Specifically, the class may be // executed directly after the retransformClasses ...
[ "public", "static", "void", "instrumentClass", "(", "Class", "<", "?", ">", "c", ",", "ConstructorCallback", "<", "?", ">", "sampler", ")", "throws", "UnmodifiableClassException", "{", "// IMPORTANT: Don't forget that other threads may be accessing this", "// class while th...
Ensures that the given sampler will be invoked every time a constructor for class c is invoked. @param c The class to be tracked @param sampler the code to be invoked when an instance of c is constructed @throws UnmodifiableClassException if c cannot be modified.
[ "Ensures", "that", "the", "given", "sampler", "will", "be", "invoked", "every", "time", "a", "constructor", "for", "class", "c", "is", "invoked", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java#L68-L89
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
ConstructorInstrumenter.instrument
public static byte[] instrument(byte[] originalBytes, Class<?> classBeingRedefined) { try { ClassReader cr = new ClassReader(originalBytes); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS); VerifyingClassAdapter vcw = new VerifyingClassAdapter(cw, originalBytes, cr.getClassName()); ...
java
public static byte[] instrument(byte[] originalBytes, Class<?> classBeingRedefined) { try { ClassReader cr = new ClassReader(originalBytes); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS); VerifyingClassAdapter vcw = new VerifyingClassAdapter(cw, originalBytes, cr.getClassName()); ...
[ "public", "static", "byte", "[", "]", "instrument", "(", "byte", "[", "]", "originalBytes", ",", "Class", "<", "?", ">", "classBeingRedefined", ")", "{", "try", "{", "ClassReader", "cr", "=", "new", "ClassReader", "(", "originalBytes", ")", ";", "ClassWrit...
Given the bytes representing a class, add invocations of the ConstructorCallback method to the constructor. @param originalBytes the original <code>byte[]</code> code. @param classBeingRedefined the class being redefined. @return the instrumented <code>byte[]</code> code.
[ "Given", "the", "bytes", "representing", "a", "class", "add", "invocations", "of", "the", "ConstructorCallback", "method", "to", "the", "constructor", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java#L116-L133
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
ConstructorInstrumenter.invokeSamplers
@SuppressWarnings("unchecked") public static void invokeSamplers(Object o) { Class<?> currentClass = o.getClass(); while (currentClass != null) { List<ConstructorCallback<?>> samplers = samplerMap.get(currentClass); if (samplers != null) { // Leave in the @SuppressWarnings, because we defi...
java
@SuppressWarnings("unchecked") public static void invokeSamplers(Object o) { Class<?> currentClass = o.getClass(); while (currentClass != null) { List<ConstructorCallback<?>> samplers = samplerMap.get(currentClass); if (samplers != null) { // Leave in the @SuppressWarnings, because we defi...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "invokeSamplers", "(", "Object", "o", ")", "{", "Class", "<", "?", ">", "currentClass", "=", "o", ".", "getClass", "(", ")", ";", "while", "(", "currentClass", "!=", "null", ...
Bytecode is rewritten to invoke this method; it calls the sampler for the given class. Note that, unless the javaagent command line argument "subclassesAlso" is specified, it won't do anything if o is a subclass of the class that was supposed to be tracked. @param o the object passed to the samplers.
[ "Bytecode", "is", "rewritten", "to", "invoke", "this", "method", ";", "it", "calls", "the", "sampler", "for", "the", "given", "class", ".", "Note", "that", "unless", "the", "javaagent", "command", "line", "argument", "subclassesAlso", "is", "specified", "it", ...
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java#L183-L210
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/VerifyingClassAdapter.java
VerifyingClassAdapter.toByteArray
public byte[] toByteArray() { if (state != State.PASS) { logger.log(Level.WARNING, "Failed to instrument class " + className + " because " + message); return original; } return cw.toByteArray(); }
java
public byte[] toByteArray() { if (state != State.PASS) { logger.log(Level.WARNING, "Failed to instrument class " + className + " because " + message); return original; } return cw.toByteArray(); }
[ "public", "byte", "[", "]", "toByteArray", "(", ")", "{", "if", "(", "state", "!=", "State", ".", "PASS", ")", "{", "logger", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Failed to instrument class \"", "+", "className", "+", "\" because \"", "+", "...
Returns the byte array that contains the byte code for this class. @return a byte array.
[ "Returns", "the", "byte", "array", "that", "contains", "the", "byte", "code", "for", "this", "class", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/VerifyingClassAdapter.java#L113-L119
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java
AllocationRecorder.getObjectSize
private static long getObjectSize(Object obj, boolean isArray, Instrumentation instr) { if (isArray) { return instr.getObjectSize(obj); } Class<?> clazz = obj.getClass(); Long classSize = classSizesMap.get(clazz); if (classSize == null) { classSize = instr.getObjectSize(obj); clas...
java
private static long getObjectSize(Object obj, boolean isArray, Instrumentation instr) { if (isArray) { return instr.getObjectSize(obj); } Class<?> clazz = obj.getClass(); Long classSize = classSizesMap.get(clazz); if (classSize == null) { classSize = instr.getObjectSize(obj); clas...
[ "private", "static", "long", "getObjectSize", "(", "Object", "obj", ",", "boolean", "isArray", ",", "Instrumentation", "instr", ")", "{", "if", "(", "isArray", ")", "{", "return", "instr", ".", "getObjectSize", "(", "obj", ")", ";", "}", "Class", "<", "?...
Returns the size of the given object. If the object is not an array, we check the cache first, and update it as necessary. @param obj the object. @param isArray indicates if the given object is an array. @param instr the instrumentation object to use for finding the object size @return the size of the given object.
[ "Returns", "the", "size", "of", "the", "given", "object", ".", "If", "the", "object", "is", "not", "an", "array", "we", "check", "the", "cache", "first", "and", "update", "it", "as", "necessary", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java#L180-L193
train
google/allocation-instrumenter
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java
AllocationRecorder.recordAllocation
public static void recordAllocation(int count, String desc, Object newObj) { if (Objects.equals(recordingAllocation.get(), Boolean.TRUE)) { return; } recordingAllocation.set(Boolean.TRUE); if (count >= 0) { desc = desc.replace('.', '/'); } // Copy value into local variable to prev...
java
public static void recordAllocation(int count, String desc, Object newObj) { if (Objects.equals(recordingAllocation.get(), Boolean.TRUE)) { return; } recordingAllocation.set(Boolean.TRUE); if (count >= 0) { desc = desc.replace('.', '/'); } // Copy value into local variable to prev...
[ "public", "static", "void", "recordAllocation", "(", "int", "count", ",", "String", "desc", ",", "Object", "newObj", ")", "{", "if", "(", "Objects", ".", "equals", "(", "recordingAllocation", ".", "get", "(", ")", ",", "Boolean", ".", "TRUE", ")", ")", ...
Records the allocation. This method is invoked on every allocation performed by the system. @param count the count of how many instances are being allocated, if an array is being allocated. If an array is not being allocated, then this value will be -1. @param desc the descriptor of the class/primitive type being allo...
[ "Records", "the", "allocation", ".", "This", "method", "is", "invoked", "on", "every", "allocation", "performed", "by", "the", "system", "." ]
58d8473e8832e51f39ae7aa38328f61c4b747bff
https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java#L210-L244
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java
LynxPresenter.onNewTraces
@Override public void onNewTraces(List<Trace> traces) { int tracesRemoved = updateTraceBuffer(traces); List<Trace> tracesToNotify = getCurrentTraces(); view.showTraces(tracesToNotify, tracesRemoved); }
java
@Override public void onNewTraces(List<Trace> traces) { int tracesRemoved = updateTraceBuffer(traces); List<Trace> tracesToNotify = getCurrentTraces(); view.showTraces(tracesToNotify, tracesRemoved); }
[ "@", "Override", "public", "void", "onNewTraces", "(", "List", "<", "Trace", ">", "traces", ")", "{", "int", "tracesRemoved", "=", "updateTraceBuffer", "(", "traces", ")", ";", "List", "<", "Trace", ">", "tracesToNotify", "=", "getCurrentTraces", "(", ")", ...
Given a list of Trace objects to show, updates the buffer of traces and refresh the view.
[ "Given", "a", "list", "of", "Trace", "objects", "to", "show", "updates", "the", "buffer", "of", "traces", "and", "refresh", "the", "view", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java#L88-L92
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java
LynxPresenter.updateFilter
public void updateFilter(String filter) { if (isInitialized) { LynxConfig lynxConfig = lynx.getConfig(); lynxConfig.setFilter(filter); lynx.setConfig(lynxConfig); clearView(); restartLynx(); } }
java
public void updateFilter(String filter) { if (isInitialized) { LynxConfig lynxConfig = lynx.getConfig(); lynxConfig.setFilter(filter); lynx.setConfig(lynxConfig); clearView(); restartLynx(); } }
[ "public", "void", "updateFilter", "(", "String", "filter", ")", "{", "if", "(", "isInitialized", ")", "{", "LynxConfig", "lynxConfig", "=", "lynx", ".", "getConfig", "(", ")", ";", "lynxConfig", ".", "setFilter", "(", "filter", ")", ";", "lynx", ".", "se...
Updates the filter used to know which Trace objects we have to show in the UI. @param filter the filter to use
[ "Updates", "the", "filter", "used", "to", "know", "which", "Trace", "objects", "we", "have", "to", "show", "in", "the", "UI", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java#L99-L107
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java
LynxPresenter.onShareButtonClicked
public void onShareButtonClicked() { List<Trace> tracesToShare = new LinkedList<Trace>(traceBuffer.getTraces()); String plainTraces = generatePlainTracesToShare(tracesToShare); if (!view.shareTraces(plainTraces)) { view.notifyShareTracesFailed(); } }
java
public void onShareButtonClicked() { List<Trace> tracesToShare = new LinkedList<Trace>(traceBuffer.getTraces()); String plainTraces = generatePlainTracesToShare(tracesToShare); if (!view.shareTraces(plainTraces)) { view.notifyShareTracesFailed(); } }
[ "public", "void", "onShareButtonClicked", "(", ")", "{", "List", "<", "Trace", ">", "tracesToShare", "=", "new", "LinkedList", "<", "Trace", ">", "(", "traceBuffer", ".", "getTraces", "(", ")", ")", ";", "String", "plainTraces", "=", "generatePlainTracesToShar...
Generates a plain representation of all the Trace objects this presenter has stored and share them to other applications.
[ "Generates", "a", "plain", "representation", "of", "all", "the", "Trace", "objects", "this", "presenter", "has", "stored", "and", "share", "them", "to", "other", "applications", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/presenter/LynxPresenter.java#L123-L129
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/model/Logcat.java
Logcat.run
@Override public void run() { super.run(); try { process = Runtime.getRuntime().exec("logcat -v time"); } catch (IOException e) { Log.e(LOGTAG, "IOException executing logcat command.", e); } readLogcat(); }
java
@Override public void run() { super.run(); try { process = Runtime.getRuntime().exec("logcat -v time"); } catch (IOException e) { Log.e(LOGTAG, "IOException executing logcat command.", e); } readLogcat(); }
[ "@", "Override", "public", "void", "run", "(", ")", "{", "super", ".", "run", "(", ")", ";", "try", "{", "process", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "\"logcat -v time\"", ")", ";", "}", "catch", "(", "IOException", "e", ...
Starts reading traces from the application logcat and notifying listeners if needed.
[ "Starts", "reading", "traces", "from", "the", "application", "logcat", "and", "notifying", "listeners", "if", "needed", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/model/Logcat.java#L67-L75
train
pedrovgs/Lynx
sample/src/main/java/com/github/pedrovgs/sample/MainActivity.java
MainActivity.generateFiveRandomTracesPerSecond
private void generateFiveRandomTracesPerSecond() { logGeneratorThread = new Thread(new Runnable() { @Override public void run() { while (continueReading) { int traceLevel = traceCounter % 6; switch (traceLevel) { case 0: Log.d("Lynx", traceCounter + " - De...
java
private void generateFiveRandomTracesPerSecond() { logGeneratorThread = new Thread(new Runnable() { @Override public void run() { while (continueReading) { int traceLevel = traceCounter % 6; switch (traceLevel) { case 0: Log.d("Lynx", traceCounter + " - De...
[ "private", "void", "generateFiveRandomTracesPerSecond", "(", ")", "{", "logGeneratorThread", "=", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "while", "(", "continueReading", ")", "{", "int...
Random traces generator used just for this demo application.
[ "Random", "traces", "generator", "used", "just", "for", "this", "demo", "application", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/sample/src/main/java/com/github/pedrovgs/sample/MainActivity.java#L85-L118
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java
LynxView.onVisibilityChanged
@Override protected void onVisibilityChanged(View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (changedView != this) { return; } if (visibility == View.VISIBLE) { resumePresenter(); } else { pausePresenter(); } }
java
@Override protected void onVisibilityChanged(View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (changedView != this) { return; } if (visibility == View.VISIBLE) { resumePresenter(); } else { pausePresenter(); } }
[ "@", "Override", "protected", "void", "onVisibilityChanged", "(", "View", "changedView", ",", "int", "visibility", ")", "{", "super", ".", "onVisibilityChanged", "(", "changedView", ",", "visibility", ")", ";", "if", "(", "changedView", "!=", "this", ")", "{",...
Initializes or stops LynxPresenter based on visibility changes. Doing this Lynx is not going to read your application Logcat if LynxView is not visible or attached.
[ "Initializes", "or", "stops", "LynxPresenter", "based", "on", "visibility", "changes", ".", "Doing", "this", "Lynx", "is", "not", "going", "to", "read", "your", "application", "Logcat", "if", "LynxView", "is", "not", "visible", "or", "attached", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java#L118-L129
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java
LynxView.setLynxConfig
public void setLynxConfig(LynxConfig lynxConfig) { validateLynxConfig(lynxConfig); boolean hasChangedLynxConfig = !this.lynxConfig.equals(lynxConfig); if (hasChangedLynxConfig) { this.lynxConfig = (LynxConfig) lynxConfig.clone(); updateFilterText(); updateAdapter(); updateSpinner(); ...
java
public void setLynxConfig(LynxConfig lynxConfig) { validateLynxConfig(lynxConfig); boolean hasChangedLynxConfig = !this.lynxConfig.equals(lynxConfig); if (hasChangedLynxConfig) { this.lynxConfig = (LynxConfig) lynxConfig.clone(); updateFilterText(); updateAdapter(); updateSpinner(); ...
[ "public", "void", "setLynxConfig", "(", "LynxConfig", "lynxConfig", ")", "{", "validateLynxConfig", "(", "lynxConfig", ")", ";", "boolean", "hasChangedLynxConfig", "=", "!", "this", ".", "lynxConfig", ".", "equals", "(", "lynxConfig", ")", ";", "if", "(", "has...
Given a valid LynxConfig object update all the dependencies to apply this new configuration. @param lynxConfig the lynx configuration
[ "Given", "a", "valid", "LynxConfig", "object", "update", "all", "the", "dependencies", "to", "apply", "this", "new", "configuration", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java#L136-L146
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java
LynxView.shareTraces
@CheckResult @Override public boolean shareTraces(String fullTraces) { try { shareTracesInternal(fullTraces); return true; } catch (RuntimeException exception1) { // Likely cause is a TransactionTooLargeException on API levels 15+. try { /* * Limit trace size to between 100kB ...
java
@CheckResult @Override public boolean shareTraces(String fullTraces) { try { shareTracesInternal(fullTraces); return true; } catch (RuntimeException exception1) { // Likely cause is a TransactionTooLargeException on API levels 15+. try { /* * Limit trace size to between 100kB ...
[ "@", "CheckResult", "@", "Override", "public", "boolean", "shareTraces", "(", "String", "fullTraces", ")", "{", "try", "{", "shareTracesInternal", "(", "fullTraces", ")", ";", "return", "true", ";", "}", "catch", "(", "RuntimeException", "exception1", ")", "{"...
Uses an intent to share content and given one String with all the information related to the List of traces shares this information with other applications.
[ "Uses", "an", "intent", "to", "share", "content", "and", "given", "one", "String", "with", "all", "the", "information", "related", "to", "the", "List", "of", "traces", "shares", "this", "information", "with", "other", "applications", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java#L188-L205
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java
LynxView.configureCursorColor
private void configureCursorColor() { try { Field f = TextView.class.getDeclaredField("mCursorDrawableRes"); f.setAccessible(true); f.set(et_filter, R.drawable.edit_text_cursor_color); } catch (Exception e) { Log.e(LOGTAG, "Error trying to change cursor color text cursor drawable to null...
java
private void configureCursorColor() { try { Field f = TextView.class.getDeclaredField("mCursorDrawableRes"); f.setAccessible(true); f.set(et_filter, R.drawable.edit_text_cursor_color); } catch (Exception e) { Log.e(LOGTAG, "Error trying to change cursor color text cursor drawable to null...
[ "private", "void", "configureCursorColor", "(", ")", "{", "try", "{", "Field", "f", "=", "TextView", ".", "class", ".", "getDeclaredField", "(", "\"mCursorDrawableRes\"", ")", ";", "f", ".", "setAccessible", "(", "true", ")", ";", "f", ".", "set", "(", "...
Hack to change EditText cursor color even if the API level is lower than 12. Please, don't do this at home.
[ "Hack", "to", "change", "EditText", "cursor", "color", "even", "if", "the", "API", "level", "is", "lower", "than", "12", ".", "Please", "don", "t", "do", "this", "at", "home", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxView.java#L288-L296
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxActivity.java
LynxActivity.getIntent
public static Intent getIntent(Context context, LynxConfig lynxConfig) { if (lynxConfig == null) { lynxConfig = new LynxConfig(); } Intent intent = new Intent(context, LynxActivity.class); intent.putExtra(LYNX_CONFIG_EXTRA, lynxConfig); return intent; }
java
public static Intent getIntent(Context context, LynxConfig lynxConfig) { if (lynxConfig == null) { lynxConfig = new LynxConfig(); } Intent intent = new Intent(context, LynxActivity.class); intent.putExtra(LYNX_CONFIG_EXTRA, lynxConfig); return intent; }
[ "public", "static", "Intent", "getIntent", "(", "Context", "context", ",", "LynxConfig", "lynxConfig", ")", "{", "if", "(", "lynxConfig", "==", "null", ")", "{", "lynxConfig", "=", "new", "LynxConfig", "(", ")", ";", "}", "Intent", "intent", "=", "new", ...
Generates an Intent to start LynxActivity with a LynxConfig configuration passed as parameter. @param context the application context @param lynxConfig the lynx configuration @return a new {@code Intent} to start {@link LynxActivity}
[ "Generates", "an", "Intent", "to", "start", "LynxActivity", "with", "a", "LynxConfig", "configuration", "passed", "as", "parameter", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxActivity.java#L54-L61
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/model/Lynx.java
Lynx.startReading
public void startReading() { logcat.setListener(new Logcat.Listener() { @Override public void onTraceRead(String logcatTrace) { try { addTraceToTheBuffer(logcatTrace); } catch (IllegalTraceException e) { return; } notifyNewTraces(); } }); boole...
java
public void startReading() { logcat.setListener(new Logcat.Listener() { @Override public void onTraceRead(String logcatTrace) { try { addTraceToTheBuffer(logcatTrace); } catch (IllegalTraceException e) { return; } notifyNewTraces(); } }); boole...
[ "public", "void", "startReading", "(", ")", "{", "logcat", ".", "setListener", "(", "new", "Logcat", ".", "Listener", "(", ")", "{", "@", "Override", "public", "void", "onTraceRead", "(", "String", "logcatTrace", ")", "{", "try", "{", "addTraceToTheBuffer", ...
Configures a Logcat.Listener and initialize Logcat dependency to read traces from the OS log.
[ "Configures", "a", "Logcat", ".", "Listener", "and", "initialize", "Logcat", "dependency", "to", "read", "traces", "from", "the", "OS", "log", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/model/Lynx.java#L88-L103
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/model/Lynx.java
Lynx.restart
public synchronized void restart() { Logcat.Listener previousListener = logcat.getListener(); logcat.stopReading(); logcat.interrupt(); logcat = (Logcat) logcat.clone(); logcat.setListener(previousListener); lastNotificationTime = 0; tracesToNotify.clear(); logcat.start(); }
java
public synchronized void restart() { Logcat.Listener previousListener = logcat.getListener(); logcat.stopReading(); logcat.interrupt(); logcat = (Logcat) logcat.clone(); logcat.setListener(previousListener); lastNotificationTime = 0; tracesToNotify.clear(); logcat.start(); }
[ "public", "synchronized", "void", "restart", "(", ")", "{", "Logcat", ".", "Listener", "previousListener", "=", "logcat", ".", "getListener", "(", ")", ";", "logcat", ".", "stopReading", "(", ")", ";", "logcat", ".", "interrupt", "(", ")", ";", "logcat", ...
Stops the configured Logcat dependency and creates a clone to restart using Logcat and LogcatListener configured previously.
[ "Stops", "the", "configured", "Logcat", "dependency", "and", "creates", "a", "clone", "to", "restart", "using", "Logcat", "and", "LogcatListener", "configured", "previously", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/model/Lynx.java#L117-L126
train
pedrovgs/Lynx
lynx/src/main/java/com/github/pedrovgs/lynx/LynxShakeDetector.java
LynxShakeDetector.init
public void init(final LynxConfig lynxConfig) { ShakeDetector shakeDetector = new ShakeDetector(new ShakeDetector.Listener() { @Override public void hearShake() { if (isEnabled) { openLynxActivity(lynxConfig); } } }); SensorManager sensorManager = (SensorManager) contex...
java
public void init(final LynxConfig lynxConfig) { ShakeDetector shakeDetector = new ShakeDetector(new ShakeDetector.Listener() { @Override public void hearShake() { if (isEnabled) { openLynxActivity(lynxConfig); } } }); SensorManager sensorManager = (SensorManager) contex...
[ "public", "void", "init", "(", "final", "LynxConfig", "lynxConfig", ")", "{", "ShakeDetector", "shakeDetector", "=", "new", "ShakeDetector", "(", "new", "ShakeDetector", ".", "Listener", "(", ")", "{", "@", "Override", "public", "void", "hearShake", "(", ")", ...
Starts listening shakes to open LynxActivity if a shake is detected and if the ShakeDetector is enabled.
[ "Starts", "listening", "shakes", "to", "open", "LynxActivity", "if", "a", "shake", "is", "detected", "and", "if", "the", "ShakeDetector", "is", "enabled", "." ]
6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d
https://github.com/pedrovgs/Lynx/blob/6097ab18b76c1ebdd0819c10e5d09ec19ea5bf4d/lynx/src/main/java/com/github/pedrovgs/lynx/LynxShakeDetector.java#L52-L62
train
blinkfox/zealot
src/main/java/com/blinkfox/zealot/config/scanner/DefaultVfs.java
DefaultVfs.list
public List<String> list(URL url, String path) throws IOException { InputStream is = null; try { List<String> resources = new ArrayList<String>(); // First, try to find the URL of a JAR file containing the requested resource. If a JAR // file is found, then we'll lis...
java
public List<String> list(URL url, String path) throws IOException { InputStream is = null; try { List<String> resources = new ArrayList<String>(); // First, try to find the URL of a JAR file containing the requested resource. If a JAR // file is found, then we'll lis...
[ "public", "List", "<", "String", ">", "list", "(", "URL", "url", ",", "String", "path", ")", "throws", "IOException", "{", "InputStream", "is", "=", "null", ";", "try", "{", "List", "<", "String", ">", "resources", "=", "new", "ArrayList", "<", "String...
Recursively list the full resource path of all the resources that are children of the resource identified by a URL. @param url The URL that identifies the resource to list. @param path The path to the resource that is identified by the URL. Generally, this is the value passed to get the resource URL. @return A list co...
[ "Recursively", "list", "the", "full", "resource", "path", "of", "all", "the", "resources", "that", "are", "children", "of", "the", "resource", "identified", "by", "a", "URL", "." ]
21b00fa3e4ed42188eef3116d494e112e7a4194c
https://github.com/blinkfox/zealot/blob/21b00fa3e4ed42188eef3116d494e112e7a4194c/src/main/java/com/blinkfox/zealot/config/scanner/DefaultVfs.java#L64-L98
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/util/BackgroundOperation.java
BackgroundOperation.doBackgroundOp
public void doBackgroundOp( final Runnable run, final boolean showWaitCursor ) { final Component[] key = new Component[1]; ExecutorService jobRunner = getJobRunner(); if( jobRunner != null ) { jobRunner.submit( () -> performBackgroundOp( run, key, showWaitCursor ) ); } else { r...
java
public void doBackgroundOp( final Runnable run, final boolean showWaitCursor ) { final Component[] key = new Component[1]; ExecutorService jobRunner = getJobRunner(); if( jobRunner != null ) { jobRunner.submit( () -> performBackgroundOp( run, key, showWaitCursor ) ); } else { r...
[ "public", "void", "doBackgroundOp", "(", "final", "Runnable", "run", ",", "final", "boolean", "showWaitCursor", ")", "{", "final", "Component", "[", "]", "key", "=", "new", "Component", "[", "1", "]", ";", "ExecutorService", "jobRunner", "=", "getJobRunner", ...
Runs a job in a background thread, using the ExecutorService, and optionally sets the cursor to the wait cursor and blocks input.
[ "Runs", "a", "job", "in", "a", "background", "thread", "using", "the", "ExecutorService", "and", "optionally", "sets", "the", "cursor", "to", "the", "wait", "cursor", "and", "blocks", "input", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/util/BackgroundOperation.java#L40-L52
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/parser/statements/LoopStatement.java
LoopStatement.getArrayLength
public static int getArrayLength( Object obj ) { if( obj == null ) { return 0; } IType type = TypeLoaderAccess.instance().getIntrinsicTypeFromObject( obj ); if( type.isArray() ) { return type.getArrayLength( obj ); } if( obj instanceof CharSequence ) { return ((...
java
public static int getArrayLength( Object obj ) { if( obj == null ) { return 0; } IType type = TypeLoaderAccess.instance().getIntrinsicTypeFromObject( obj ); if( type.isArray() ) { return type.getArrayLength( obj ); } if( obj instanceof CharSequence ) { return ((...
[ "public", "static", "int", "getArrayLength", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "0", ";", "}", "IType", "type", "=", "TypeLoaderAccess", ".", "instance", "(", ")", ".", "getIntrinsicTypeFromObject", "(", "...
Return the length of the specified Array or Collection.
[ "Return", "the", "length", "of", "the", "specified", "Array", "or", "Collection", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/statements/LoopStatement.java#L158-L193
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/parser/MetaTypeTypeInfo.java
MetaTypeTypeInfo.canAccessPrivateMembers
private boolean canAccessPrivateMembers( IType ownersClass, IType whosAskin ) { return getOwnersType() == whosAskin || getTopLevelTypeName( whosAskin ).equals( getTopLevelTypeName( ownersClass ) ); }
java
private boolean canAccessPrivateMembers( IType ownersClass, IType whosAskin ) { return getOwnersType() == whosAskin || getTopLevelTypeName( whosAskin ).equals( getTopLevelTypeName( ownersClass ) ); }
[ "private", "boolean", "canAccessPrivateMembers", "(", "IType", "ownersClass", ",", "IType", "whosAskin", ")", "{", "return", "getOwnersType", "(", ")", "==", "whosAskin", "||", "getTopLevelTypeName", "(", "whosAskin", ")", ".", "equals", "(", "getTopLevelTypeName", ...
A private feature is accessible from its declaring class and any inner class defined in its declaring class.
[ "A", "private", "feature", "is", "accessible", "from", "its", "declaring", "class", "and", "any", "inner", "class", "defined", "in", "its", "declaring", "class", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/MetaTypeTypeInfo.java#L302-L306
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/util/EditorUtilities.java
EditorUtilities.findAncestor
public static <T> T findAncestor( Component start, Class<T> aClass ) { if( start == null ) { return null; } return findAtOrAbove( start.getParent(), aClass ); }
java
public static <T> T findAncestor( Component start, Class<T> aClass ) { if( start == null ) { return null; } return findAtOrAbove( start.getParent(), aClass ); }
[ "public", "static", "<", "T", ">", "T", "findAncestor", "(", "Component", "start", ",", "Class", "<", "T", ">", "aClass", ")", "{", "if", "(", "start", "==", "null", ")", "{", "return", "null", ";", "}", "return", "findAtOrAbove", "(", "start", ".", ...
Finds the first widget above the passed in widget of the given class
[ "Finds", "the", "first", "widget", "above", "the", "passed", "in", "widget", "of", "the", "given", "class" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/util/EditorUtilities.java#L757-L764
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/util/EditorUtilities.java
EditorUtilities.findAtOrAbove
public static <T> T findAtOrAbove( Component start, Class<T> aClass ) { Component comp = start; while( comp != null ) { if( aClass.isInstance( comp ) ) { return (T)comp; } else { comp = comp.getParent(); } } return null; }
java
public static <T> T findAtOrAbove( Component start, Class<T> aClass ) { Component comp = start; while( comp != null ) { if( aClass.isInstance( comp ) ) { return (T)comp; } else { comp = comp.getParent(); } } return null; }
[ "public", "static", "<", "T", ">", "T", "findAtOrAbove", "(", "Component", "start", ",", "Class", "<", "T", ">", "aClass", ")", "{", "Component", "comp", "=", "start", ";", "while", "(", "comp", "!=", "null", ")", "{", "if", "(", "aClass", ".", "is...
Finds the first widget at or above the passed in widget of the given class
[ "Finds", "the", "first", "widget", "at", "or", "above", "the", "passed", "in", "widget", "of", "the", "given", "class" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/util/EditorUtilities.java#L769-L784
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/xml/simple/SimpleXmlNode.java
SimpleXmlNode.shallowCopy
public SimpleXmlNode shallowCopy() { SimpleXmlNode copy = new SimpleXmlNode(_name); copy.setText(_text); copy.getAttributes().putAll(_attributes); return copy; }
java
public SimpleXmlNode shallowCopy() { SimpleXmlNode copy = new SimpleXmlNode(_name); copy.setText(_text); copy.getAttributes().putAll(_attributes); return copy; }
[ "public", "SimpleXmlNode", "shallowCopy", "(", ")", "{", "SimpleXmlNode", "copy", "=", "new", "SimpleXmlNode", "(", "_name", ")", ";", "copy", ".", "setText", "(", "_text", ")", ";", "copy", ".", "getAttributes", "(", ")", ".", "putAll", "(", "_attributes"...
Makes a shallow copy of this node, including its name, text, and attributes. The returned node will have no children and no parent. @return a shallow copy of this node
[ "Makes", "a", "shallow", "copy", "of", "this", "node", "including", "its", "name", "text", "and", "attributes", ".", "The", "returned", "node", "will", "have", "no", "children", "and", "no", "parent", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/xml/simple/SimpleXmlNode.java#L163-L168
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/xml/simple/SimpleXmlNode.java
SimpleXmlNode.deepCopy
public SimpleXmlNode deepCopy() { SimpleXmlNode rootCopy = shallowCopy(); for (SimpleXmlNode child : _children) { rootCopy.getChildren().add(child.deepCopy()); } return rootCopy; }
java
public SimpleXmlNode deepCopy() { SimpleXmlNode rootCopy = shallowCopy(); for (SimpleXmlNode child : _children) { rootCopy.getChildren().add(child.deepCopy()); } return rootCopy; }
[ "public", "SimpleXmlNode", "deepCopy", "(", ")", "{", "SimpleXmlNode", "rootCopy", "=", "shallowCopy", "(", ")", ";", "for", "(", "SimpleXmlNode", "child", ":", "_children", ")", "{", "rootCopy", ".", "getChildren", "(", ")", ".", "add", "(", "child", ".",...
Makes a deep copy of this node, including copies of all contained children. The returned node will have the same name, text, and attributes as this node, and its list of children will contain deep copies of each child of this node. @return a deep copy of this node
[ "Makes", "a", "deep", "copy", "of", "this", "node", "including", "copies", "of", "all", "contained", "children", ".", "The", "returned", "node", "will", "have", "the", "same", "name", "text", "and", "attributes", "as", "this", "node", "and", "its", "list",...
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/xml/simple/SimpleXmlNode.java#L177-L183
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/properties/PropertyNode.java
PropertyNode.removeUseless
private void removeUseless() { Set<Map.Entry<String, PropertyNode>> entries = _children.entrySet(); for (Iterator<Map.Entry<String, PropertyNode>> it = entries.iterator(); it.hasNext(); ) { Map.Entry<String, PropertyNode> entry = it.next(); PropertyNode child = entry.getValue(); child.removeUs...
java
private void removeUseless() { Set<Map.Entry<String, PropertyNode>> entries = _children.entrySet(); for (Iterator<Map.Entry<String, PropertyNode>> it = entries.iterator(); it.hasNext(); ) { Map.Entry<String, PropertyNode> entry = it.next(); PropertyNode child = entry.getValue(); child.removeUs...
[ "private", "void", "removeUseless", "(", ")", "{", "Set", "<", "Map", ".", "Entry", "<", "String", ",", "PropertyNode", ">", ">", "entries", "=", "_children", ".", "entrySet", "(", ")", ";", "for", "(", "Iterator", "<", "Map", ".", "Entry", "<", "Str...
removes all useless nodes in the tree represented by this node as a root
[ "removes", "all", "useless", "nodes", "in", "the", "tree", "represented", "by", "this", "node", "as", "a", "root" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/properties/PropertyNode.java#L169-L179
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/reflect/TypedPropertyDescriptor.java
TypedPropertyDescriptor.setReadMethod
public void setReadMethod( Method getter ) throws IntrospectionException { super.setReadMethod( getter ); if( _propertyClass == null ) { _propertyClass = super.getPropertyType(); } }
java
public void setReadMethod( Method getter ) throws IntrospectionException { super.setReadMethod( getter ); if( _propertyClass == null ) { _propertyClass = super.getPropertyType(); } }
[ "public", "void", "setReadMethod", "(", "Method", "getter", ")", "throws", "IntrospectionException", "{", "super", ".", "setReadMethod", "(", "getter", ")", ";", "if", "(", "_propertyClass", "==", "null", ")", "{", "_propertyClass", "=", "super", ".", "getProp...
this class maintains its own copy of propertyType.
[ "this", "class", "maintains", "its", "own", "copy", "of", "propertyType", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/TypedPropertyDescriptor.java#L35-L42
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/ir/transform/GosuClassTransformer.java
GosuClassTransformer.compileJavaInteropBridgeConstructor
private void compileJavaInteropBridgeConstructor( DynamicFunctionSymbol dfs ) { DynamicFunctionSymbol copy = new DynamicFunctionSymbol( dfs ); copy.setValue( null ); copy.setInitializer( null ); ConstructorStatement fs = new ConstructorStatement( true ); fs.setDynamicFunctionSymbol( copy ); fs...
java
private void compileJavaInteropBridgeConstructor( DynamicFunctionSymbol dfs ) { DynamicFunctionSymbol copy = new DynamicFunctionSymbol( dfs ); copy.setValue( null ); copy.setInitializer( null ); ConstructorStatement fs = new ConstructorStatement( true ); fs.setDynamicFunctionSymbol( copy ); fs...
[ "private", "void", "compileJavaInteropBridgeConstructor", "(", "DynamicFunctionSymbol", "dfs", ")", "{", "DynamicFunctionSymbol", "copy", "=", "new", "DynamicFunctionSymbol", "(", "dfs", ")", ";", "copy", ".", "setValue", "(", "null", ")", ";", "copy", ".", "setIn...
Add constructor so Java can use the Gosu generic class without explicitly passing in type arguments. Note this constructor forwards to the given constructor with default type arguments.
[ "Add", "constructor", "so", "Java", "can", "use", "the", "Gosu", "generic", "class", "without", "explicitly", "passing", "in", "type", "arguments", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/ir/transform/GosuClassTransformer.java#L565-L626
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/parser/expressions/TypeAsExpression.java
TypeAsExpression.evaluate
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } Object value = getLHS().evaluate(); IType argType = getType(); if( value instanceof IType && argType instanceof IJavaType && JavaTypes.CLASS() == TypeLord.getPureGenericType( argType ) ) { ...
java
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } Object value = getLHS().evaluate(); IType argType = getType(); if( value instanceof IType && argType instanceof IJavaType && JavaTypes.CLASS() == TypeLord.getPureGenericType( argType ) ) { ...
[ "public", "Object", "evaluate", "(", ")", "{", "if", "(", "!", "isCompileTimeConstant", "(", ")", ")", "{", "return", "super", ".", "evaluate", "(", ")", ";", "}", "Object", "value", "=", "getLHS", "(", ")", ".", "evaluate", "(", ")", ";", "IType", ...
Perform a type cast.
[ "Perform", "a", "type", "cast", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/expressions/TypeAsExpression.java#L73-L120
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/util/ProgressFeedback.java
ProgressFeedback.runWithProgress
public static ProgressFeedback runWithProgress( final String strNotice, final IRunnableWithProgress task ) { return runWithProgress( strNotice, task, false, false ); }
java
public static ProgressFeedback runWithProgress( final String strNotice, final IRunnableWithProgress task ) { return runWithProgress( strNotice, task, false, false ); }
[ "public", "static", "ProgressFeedback", "runWithProgress", "(", "final", "String", "strNotice", ",", "final", "IRunnableWithProgress", "task", ")", "{", "return", "runWithProgress", "(", "strNotice", ",", "task", ",", "false", ",", "false", ")", ";", "}" ]
A helper method that executes a task in a worker thread and displays feedback in a progress windows. @param strNotice The text notice to display in the ProgressWindow. @param task The task to execute in a separate (worker) thread.
[ "A", "helper", "method", "that", "executes", "a", "task", "in", "a", "worker", "thread", "and", "displays", "feedback", "in", "a", "progress", "windows", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/util/ProgressFeedback.java#L42-L45
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/reflect/json/SimpleParserImpl.java
SimpleParserImpl.parse
public Object parse() { Object val = null; if(T.isValueType()) { val = parseValue(); } else { addError(); } return val; }
java
public Object parse() { Object val = null; if(T.isValueType()) { val = parseValue(); } else { addError(); } return val; }
[ "public", "Object", "parse", "(", ")", "{", "Object", "val", "=", "null", ";", "if", "(", "T", ".", "isValueType", "(", ")", ")", "{", "val", "=", "parseValue", "(", ")", ";", "}", "else", "{", "addError", "(", ")", ";", "}", "return", "val", "...
jsonText = value.
[ "jsonText", "=", "value", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/json/SimpleParserImpl.java#L57-L65
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/reflect/json/SimpleParserImpl.java
SimpleParserImpl.parseValue
public Object parseValue() { Object val; switch(T.getType()) { case LCURLY: val = parseObject(); break; case LSQUARE: val = parseArray(); break; case INTEGER: if(useBig) { val = new BigInteger(T.getString()); } else { try { ...
java
public Object parseValue() { Object val; switch(T.getType()) { case LCURLY: val = parseObject(); break; case LSQUARE: val = parseArray(); break; case INTEGER: if(useBig) { val = new BigInteger(T.getString()); } else { try { ...
[ "public", "Object", "parseValue", "(", ")", "{", "Object", "val", ";", "switch", "(", "T", ".", "getType", "(", ")", ")", "{", "case", "LCURLY", ":", "val", "=", "parseObject", "(", ")", ";", "break", ";", "case", "LSQUARE", ":", "val", "=", "parse...
value = object | array | number | string | "true" | "false" | "null" .
[ "value", "=", "object", "|", "array", "|", "number", "|", "string", "|", "true", "|", "false", "|", "null", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/json/SimpleParserImpl.java#L137-L192
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/reflect/FunctionType.java
FunctionType.mapTypes
private TypeVarToTypeMap mapTypes( TypeVarToTypeMap actualParamByVarName, IType... types ) { for( int i = 0; i < types.length; i++ ) { IType type = types[i]; if( type instanceof ITypeVariableType ) { actualParamByVarName.put( (ITypeVariableType)types[i], types[i] ); } if(...
java
private TypeVarToTypeMap mapTypes( TypeVarToTypeMap actualParamByVarName, IType... types ) { for( int i = 0; i < types.length; i++ ) { IType type = types[i]; if( type instanceof ITypeVariableType ) { actualParamByVarName.put( (ITypeVariableType)types[i], types[i] ); } if(...
[ "private", "TypeVarToTypeMap", "mapTypes", "(", "TypeVarToTypeMap", "actualParamByVarName", ",", "IType", "...", "types", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "IType", "type", "=", ...
Move Intrinsic type helper up here
[ "Move", "Intrinsic", "type", "helper", "up", "here" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/FunctionType.java#L1046-L1076
train
gosu-lang/gosu-lang
gosu-process/src/main/java/gw/util/process/ProcessRunner.java
ProcessRunner.withEnvironmentVariable
public ProcessRunner withEnvironmentVariable(String name, String value) { _env.put(name, value); return this; }
java
public ProcessRunner withEnvironmentVariable(String name, String value) { _env.put(name, value); return this; }
[ "public", "ProcessRunner", "withEnvironmentVariable", "(", "String", "name", ",", "String", "value", ")", "{", "_env", ".", "put", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a name-value pair into this process' environment. This can be called multiple times in a chain to set multiple environment variables. @param name the variable name @param value the variable value @return this object for chaining @see ProcessBuilder @see System#getenv()
[ "Adds", "a", "name", "-", "value", "pair", "into", "this", "process", "environment", ".", "This", "can", "be", "called", "multiple", "times", "in", "a", "chain", "to", "set", "multiple", "environment", "variables", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-process/src/main/java/gw/util/process/ProcessRunner.java#L273-L276
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/util/concurrent/Cache.java
Cache.put
public V put(K key, V value) { return _cacheImpl.put(key, value); }
java
public V put(K key, V value) { return _cacheImpl.put(key, value); }
[ "public", "V", "put", "(", "K", "key", ",", "V", "value", ")", "{", "return", "_cacheImpl", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
This will put a specific entry in the cache @param key this is the key @param value this is the value @return the old value for this key
[ "This", "will", "put", "a", "specific", "entry", "in", "the", "cache" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/concurrent/Cache.java#L77-L79
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/util/concurrent/Cache.java
Cache.get
public V get(K key) { V value = _cacheImpl.get(key); _requests.incrementAndGet(); if (value == null) { value = _missHandler.load(key); _cacheImpl.put(key, value); _misses.incrementAndGet(); } else { _hits.incrementAndGet(); } return value; }
java
public V get(K key) { V value = _cacheImpl.get(key); _requests.incrementAndGet(); if (value == null) { value = _missHandler.load(key); _cacheImpl.put(key, value); _misses.incrementAndGet(); } else { _hits.incrementAndGet(); } return value; }
[ "public", "V", "get", "(", "K", "key", ")", "{", "V", "value", "=", "_cacheImpl", ".", "get", "(", "key", ")", ";", "_requests", ".", "incrementAndGet", "(", ")", ";", "if", "(", "value", "==", "null", ")", "{", "value", "=", "_missHandler", ".", ...
This will get a specific entry, it will call the missHandler if it is not found. @param key the object to find @return the found object (may be null)
[ "This", "will", "get", "a", "specific", "entry", "it", "will", "call", "the", "missHandler", "if", "it", "is", "not", "found", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/concurrent/Cache.java#L86-L97
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/util/concurrent/Cache.java
Cache.logEveryNSeconds
public synchronized Cache<K, V> logEveryNSeconds(int seconds, final ILogger logger) { if (_loggingTask == null) { ScheduledExecutorService service = Executors.newScheduledThreadPool(1); _loggingTask = service.scheduleAtFixedRate(new Runnable() { public void run() { logger.info(Cache.th...
java
public synchronized Cache<K, V> logEveryNSeconds(int seconds, final ILogger logger) { if (_loggingTask == null) { ScheduledExecutorService service = Executors.newScheduledThreadPool(1); _loggingTask = service.scheduleAtFixedRate(new Runnable() { public void run() { logger.info(Cache.th...
[ "public", "synchronized", "Cache", "<", "K", ",", "V", ">", "logEveryNSeconds", "(", "int", "seconds", ",", "final", "ILogger", "logger", ")", "{", "if", "(", "_loggingTask", "==", "null", ")", "{", "ScheduledExecutorService", "service", "=", "Executors", "....
Sets up a recurring task every n seconds to report on the status of this cache. This can be useful if you are doing exploratory caching and wish to monitor the performance of this cache with minimal fuss. Consider @param seconds how often to log the entry @param logger the logger to use @return this
[ "Sets", "up", "a", "recurring", "task", "every", "n", "seconds", "to", "report", "on", "the", "status", "of", "this", "cache", ".", "This", "can", "be", "useful", "if", "you", "are", "doing", "exploratory", "caching", "and", "wish", "to", "monitor", "the...
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/concurrent/Cache.java#L137-L149
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/EditorHost.java
EditorHost.setUndoableEditListener
@Override public void setUndoableEditListener( UndoableEditListener uel ) { if( _uel != null ) { getEditor().getDocument().removeUndoableEditListener( _uel ); } _uel = uel; if( _uel != null ) { getEditor().getDocument().addUndoableEditListener( _uel ); } }
java
@Override public void setUndoableEditListener( UndoableEditListener uel ) { if( _uel != null ) { getEditor().getDocument().removeUndoableEditListener( _uel ); } _uel = uel; if( _uel != null ) { getEditor().getDocument().addUndoableEditListener( _uel ); } }
[ "@", "Override", "public", "void", "setUndoableEditListener", "(", "UndoableEditListener", "uel", ")", "{", "if", "(", "_uel", "!=", "null", ")", "{", "getEditor", "(", ")", ".", "getDocument", "(", ")", ".", "removeUndoableEditListener", "(", "_uel", ")", "...
Sets the one and only undoable edit listener for this editor section. The primary use case for this method is to establish an undo manager connection. @param uel The UndoableEditListener to connect to this section's document.
[ "Sets", "the", "one", "and", "only", "undoable", "edit", "listener", "for", "this", "editor", "section", ".", "The", "primary", "use", "case", "for", "this", "method", "is", "to", "establish", "an", "undo", "manager", "connection", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/EditorHost.java#L482-L496
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/parser/GosuClassTypeInfo.java
GosuClassTypeInfo.getCompilingClass
private IType getCompilingClass() { if( isIncludeAll() ) { return _gsClass; } IType type = GosuClassCompilingStack.getCurrentCompilingType(); if( type != null ) { return type; } ISymbolTable symTableCtx = CompiledGosuClassSymbolTable.getSymTableCtx(); ISymbol thisSymbo...
java
private IType getCompilingClass() { if( isIncludeAll() ) { return _gsClass; } IType type = GosuClassCompilingStack.getCurrentCompilingType(); if( type != null ) { return type; } ISymbolTable symTableCtx = CompiledGosuClassSymbolTable.getSymTableCtx(); ISymbol thisSymbo...
[ "private", "IType", "getCompilingClass", "(", ")", "{", "if", "(", "isIncludeAll", "(", ")", ")", "{", "return", "_gsClass", ";", "}", "IType", "type", "=", "GosuClassCompilingStack", ".", "getCurrentCompilingType", "(", ")", ";", "if", "(", "type", "!=", ...
We expose type info in a context sensitive manner. For instance, we only expose private features from within the containing class. We can determine the context class from the current compiling class. The compiling class is obtained from either 1) the actual CompiledGosuClass stack the Gosu Class TypeLoader manages or 2...
[ "We", "expose", "type", "info", "in", "a", "context", "sensitive", "manner", ".", "For", "instance", "we", "only", "expose", "private", "features", "from", "within", "the", "containing", "class", ".", "We", "can", "determine", "the", "context", "class", "fro...
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/GosuClassTypeInfo.java#L254-L277
train
gosu-lang/gosu-lang
gosu-core/src/main/java/gw/internal/gosu/parser/expressions/ConditionalOrExpression.java
ConditionalOrExpression.evaluate
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } return (Boolean)getLHS().evaluate() || (Boolean)getRHS().evaluate(); }
java
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } return (Boolean)getLHS().evaluate() || (Boolean)getRHS().evaluate(); }
[ "public", "Object", "evaluate", "(", ")", "{", "if", "(", "!", "isCompileTimeConstant", "(", ")", ")", "{", "return", "super", ".", "evaluate", "(", ")", ";", "}", "return", "(", "Boolean", ")", "getLHS", "(", ")", ".", "evaluate", "(", ")", "||", ...
Performs a logical OR operation. Note this operation is naturally short- circuited by using || in conjunction with postponing RHS evaluation.
[ "Performs", "a", "logical", "OR", "operation", ".", "Note", "this", "operation", "is", "naturally", "short", "-", "circuited", "by", "using", "||", "in", "conjunction", "with", "postponing", "RHS", "evaluation", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/expressions/ConditionalOrExpression.java#L27-L35
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/reflect/Modifier.java
Modifier.getModifiersFrom
public static int getModifiersFrom( IAttributedFeatureInfo afi ) { int iModifiers = 0; iModifiers = Modifier.setBit( iModifiers, afi.isPublic(), PUBLIC ); iModifiers = Modifier.setBit( iModifiers, afi.isPrivate(), PRIVATE ); iModifiers = Modifier.setBit( iModifiers, afi.isProtected(), PROTECTED ); ...
java
public static int getModifiersFrom( IAttributedFeatureInfo afi ) { int iModifiers = 0; iModifiers = Modifier.setBit( iModifiers, afi.isPublic(), PUBLIC ); iModifiers = Modifier.setBit( iModifiers, afi.isPrivate(), PRIVATE ); iModifiers = Modifier.setBit( iModifiers, afi.isProtected(), PROTECTED ); ...
[ "public", "static", "int", "getModifiersFrom", "(", "IAttributedFeatureInfo", "afi", ")", "{", "int", "iModifiers", "=", "0", ";", "iModifiers", "=", "Modifier", ".", "setBit", "(", "iModifiers", ",", "afi", ".", "isPublic", "(", ")", ",", "PUBLIC", ")", "...
Match the Java value for the annotation modifier
[ "Match", "the", "Java", "value", "for", "the", "annotation", "modifier" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/Modifier.java#L45-L56
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/date/GosuDateUtil.java
GosuDateUtil.isAM
public static boolean isAM(Date date) { return dateToCalendar(date).get(Calendar.AM_PM) == Calendar.AM; }
java
public static boolean isAM(Date date) { return dateToCalendar(date).get(Calendar.AM_PM) == Calendar.AM; }
[ "public", "static", "boolean", "isAM", "(", "Date", "date", ")", "{", "return", "dateToCalendar", "(", "date", ")", ".", "get", "(", "Calendar", ".", "AM_PM", ")", "==", "Calendar", ".", "AM", ";", "}" ]
Is the time AM? @param date The time. @return true if the time is AM, false otherwise
[ "Is", "the", "time", "AM?" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/date/GosuDateUtil.java#L171-L173
train
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/date/GosuDateUtil.java
GosuDateUtil.isPM
public static boolean isPM(Date date) { return dateToCalendar(date).get(Calendar.AM_PM) == Calendar.PM; }
java
public static boolean isPM(Date date) { return dateToCalendar(date).get(Calendar.AM_PM) == Calendar.PM; }
[ "public", "static", "boolean", "isPM", "(", "Date", "date", ")", "{", "return", "dateToCalendar", "(", "date", ")", ".", "get", "(", "Calendar", ".", "AM_PM", ")", "==", "Calendar", ".", "PM", ";", "}" ]
Is the time PM? @param date The time. @return true if the time is PM, false otherwise
[ "Is", "the", "time", "PM?" ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/date/GosuDateUtil.java#L182-L184
train
gosu-lang/gosu-lang
gosu-lab/src/main/java/editor/GosuStyleContext.java
GosuStyleContext.getForeground
public Color getForeground( int code ) { Style s = _tokenStyles.get( new Integer( code ) ); if( s == null ) { s = getStyle( DEFAULT_STYLE ); } return getForeground( s ); }
java
public Color getForeground( int code ) { Style s = _tokenStyles.get( new Integer( code ) ); if( s == null ) { s = getStyle( DEFAULT_STYLE ); } return getForeground( s ); }
[ "public", "Color", "getForeground", "(", "int", "code", ")", "{", "Style", "s", "=", "_tokenStyles", ".", "get", "(", "new", "Integer", "(", "code", ")", ")", ";", "if", "(", "s", "==", "null", ")", "{", "s", "=", "getStyle", "(", "DEFAULT_STYLE", ...
Fetch the foreground color to use for a lexical token with the given value.
[ "Fetch", "the", "foreground", "color", "to", "use", "for", "a", "lexical", "token", "with", "the", "given", "value", "." ]
d6e9261b137ce66fef3726cabe7826d4a1f946b7
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/GosuStyleContext.java#L320-L328
train