id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
164,200
eclipse/xtext-lib
org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java
Path.getParent
public Path getParent() { if (!isAbsolute()) throw new IllegalStateException("path is not absolute: " + toString()); if (segments.isEmpty()) return null; return new Path(segments.subList(0, segments.size()-1), true); }
java
public Path getParent() { if (!isAbsolute()) throw new IllegalStateException("path is not absolute: " + toString()); if (segments.isEmpty()) return null; return new Path(segments.subList(0, segments.size()-1), true); }
[ "public", "Path", "getParent", "(", ")", "{", "if", "(", "!", "isAbsolute", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "\"path is not absolute: \"", "+", "toString", "(", ")", ")", ";", "if", "(", "segments", ".", "isEmpty", "(", ")", ")", "return", "null", ";", "return", "new", "Path", "(", "segments", ".", "subList", "(", "0", ",", "segments", ".", "size", "(", ")", "-", "1", ")", ",", "true", ")", ";", "}" ]
Returns the parent of this path or null if this path is the root path. @return the parent of this path or null if this path is the root path.
[ "Returns", "the", "parent", "of", "this", "path", "or", "null", "if", "this", "path", "is", "the", "root", "path", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java#L134-L140
164,201
eclipse/xtext-lib
org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java
Path.relativize
public Path relativize(Path other) { if (other.isAbsolute() != isAbsolute()) throw new IllegalArgumentException("This path and the given path are not both absolute or both relative: " + toString() + " | " + other.toString()); if (startsWith(other)) { return internalRelativize(this, other); } else if (other.startsWith(this)) { return internalRelativize(other, this); } return null; }
java
public Path relativize(Path other) { if (other.isAbsolute() != isAbsolute()) throw new IllegalArgumentException("This path and the given path are not both absolute or both relative: " + toString() + " | " + other.toString()); if (startsWith(other)) { return internalRelativize(this, other); } else if (other.startsWith(this)) { return internalRelativize(other, this); } return null; }
[ "public", "Path", "relativize", "(", "Path", "other", ")", "{", "if", "(", "other", ".", "isAbsolute", "(", ")", "!=", "isAbsolute", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"This path and the given path are not both absolute or both relative: \"", "+", "toString", "(", ")", "+", "\" | \"", "+", "other", ".", "toString", "(", ")", ")", ";", "if", "(", "startsWith", "(", "other", ")", ")", "{", "return", "internalRelativize", "(", "this", ",", "other", ")", ";", "}", "else", "if", "(", "other", ".", "startsWith", "(", "this", ")", ")", "{", "return", "internalRelativize", "(", "other", ",", "this", ")", ";", "}", "return", "null", ";", "}" ]
Constructs a relative path between this path and a given path. <p> Relativization is the inverse of {@link #getAbsolutePath(Path) resolution}. This method attempts to construct a {@link #isAbsolute relative} path that when {@link #getAbsolutePath(Path) resolved} against this path, yields a path that locates the same file as the given path. For example, on UNIX, if this path is {@code "/a/b"} and the given path is {@code "/a/b/c/d"} then the resulting relative path would be {@code "c/d"}. Both paths must be absolute and and either this path or the given path must be a {@link #startsWith(Path) prefix} of the other. @param other the path to relativize against this path @return the resulting relative path or null if neither of the given paths is a prefix of the other @throws IllegalArgumentException if this path and {@code other} are not both absolute or relative
[ "Constructs", "a", "relative", "path", "between", "this", "path", "and", "a", "given", "path", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java#L215-L224
164,202
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_add
@Inline(value = "$1.put($2.getKey(), $2.getValue())", statementExpression = true) public static <K, V> V operator_add(Map<K, V> map, Pair<? extends K, ? extends V> entry) { return map.put(entry.getKey(), entry.getValue()); }
java
@Inline(value = "$1.put($2.getKey(), $2.getValue())", statementExpression = true) public static <K, V> V operator_add(Map<K, V> map, Pair<? extends K, ? extends V> entry) { return map.put(entry.getKey(), entry.getValue()); }
[ "@", "Inline", "(", "value", "=", "\"$1.put($2.getKey(), $2.getValue())\"", ",", "statementExpression", "=", "true", ")", "public", "static", "<", "K", ",", "V", ">", "V", "operator_add", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "Pair", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "entry", ")", "{", "return", "map", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}" ]
Add the given pair into the map. <p> If the pair key already exists in the map, its value is replaced by the value in the pair, and the old value in the map is returned. </p> @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param entry the entry (key, value) to add into the map. @return the value previously associated to the key, or <code>null</code> if the key was not present in the map before the addition. @since 2.15
[ "Add", "the", "given", "pair", "into", "the", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L118-L121
164,203
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_add
@Inline(value = "$1.putAll($2)", statementExpression = true) public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) { outputMap.putAll(inputMap); }
java
@Inline(value = "$1.putAll($2)", statementExpression = true) public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) { outputMap.putAll(inputMap); }
[ "@", "Inline", "(", "value", "=", "\"$1.putAll($2)\"", ",", "statementExpression", "=", "true", ")", "public", "static", "<", "K", ",", "V", ">", "void", "operator_add", "(", "Map", "<", "K", ",", "V", ">", "outputMap", ",", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "inputMap", ")", "{", "outputMap", ".", "putAll", "(", "inputMap", ")", ";", "}" ]
Add the given entries of the input map into the output map. <p> If a key in the inputMap already exists in the outputMap, its value is replaced in the outputMap by the value from the inputMap. </p> @param <K> type of the map keys. @param <V> type of the map values. @param outputMap the map to update. @param inputMap the entries to add. @since 2.15
[ "Add", "the", "given", "entries", "of", "the", "input", "map", "into", "the", "output", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L137-L140
164,204
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_plus
@Pure @Inline(value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))", imported = { MapExtensions.class, Collections.class }) public static <K, V> Map<K, V> operator_plus(Map<K, V> left, final Pair<? extends K, ? extends V> right) { return union(left, Collections.singletonMap(right.getKey(), right.getValue())); }
java
@Pure @Inline(value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))", imported = { MapExtensions.class, Collections.class }) public static <K, V> Map<K, V> operator_plus(Map<K, V> left, final Pair<? extends K, ? extends V> right) { return union(left, Collections.singletonMap(right.getKey(), right.getValue())); }
[ "@", "Pure", "@", "Inline", "(", "value", "=", "\"$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))\"", ",", "imported", "=", "{", "MapExtensions", ".", "class", ",", "Collections", ".", "class", "}", ")", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_plus", "(", "Map", "<", "K", ",", "V", ">", "left", ",", "final", "Pair", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "right", ")", "{", "return", "union", "(", "left", ",", "Collections", ".", "singletonMap", "(", "right", ".", "getKey", "(", ")", ",", "right", ".", "getValue", "(", ")", ")", ")", ";", "}" ]
Add the given pair to a given map for obtaining a new map. <p> The replied map is a view on the given map. It means that any change in the original map is reflected to the result of this operation. </p> <p> Even if the key of the right operand exists in the left operand, the value in the right operand is preferred. </p> @param <K> type of the map keys. @param <V> type of the map values. @param left the map to consider. @param right the entry (key, value) to add into the map. @return an immutable map with the content of the map and with the given entry. @throws IllegalArgumentException - when the right operand key exists in the left operand. @since 2.15
[ "Add", "the", "given", "pair", "to", "a", "given", "map", "for", "obtaining", "a", "new", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L162-L167
164,205
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_plus
@Pure @Inline(value = "$3.union($1, $2)", imported = MapExtensions.class) public static <K, V> Map<K, V> operator_plus(Map<K, V> left, Map<? extends K, ? extends V> right) { return union(left, right); }
java
@Pure @Inline(value = "$3.union($1, $2)", imported = MapExtensions.class) public static <K, V> Map<K, V> operator_plus(Map<K, V> left, Map<? extends K, ? extends V> right) { return union(left, right); }
[ "@", "Pure", "@", "Inline", "(", "value", "=", "\"$3.union($1, $2)\"", ",", "imported", "=", "MapExtensions", ".", "class", ")", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_plus", "(", "Map", "<", "K", ",", "V", ">", "left", ",", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "right", ")", "{", "return", "union", "(", "left", ",", "right", ")", ";", "}" ]
Merge the two maps. <p> The replied map is a view on the given map. It means that any change in the original map is reflected to the result of this operation. </p> <p> If a key exists in the left and right operands, the value in the right operand is preferred. </p> @param <K> type of the map keys. @param <V> type of the map values. @param left the left map. @param right the right map. @return a map with the merged contents from the two maps. @throws IllegalArgumentException - when a right operand key exists in the left operand. @since 2.15
[ "Merge", "the", "two", "maps", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L189-L193
164,206
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_remove
@Inline(value = "$1.remove($2)", statementExpression = true) public static <K, V> V operator_remove(Map<K, V> map, K key) { return map.remove(key); }
java
@Inline(value = "$1.remove($2)", statementExpression = true) public static <K, V> V operator_remove(Map<K, V> map, K key) { return map.remove(key); }
[ "@", "Inline", "(", "value", "=", "\"$1.remove($2)\"", ",", "statementExpression", "=", "true", ")", "public", "static", "<", "K", ",", "V", ">", "V", "operator_remove", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "K", "key", ")", "{", "return", "map", ".", "remove", "(", "key", ")", ";", "}" ]
Remove a key from the given map. @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param key the key to remove. @return the removed value, or <code>null</code> if the key was not present in the map. @since 2.15
[ "Remove", "a", "key", "from", "the", "given", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L206-L209
164,207
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_remove
@Inline(value = "$1.remove($2.getKey(), $2.getValue())", statementExpression = true) public static <K, V> boolean operator_remove(Map<K, V> map, Pair<? extends K, ? extends V> entry) { //TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue()); final K key = entry.getKey(); final V storedValue = map.get(entry.getKey()); if (!Objects.equal(storedValue, entry.getValue()) || (storedValue == null && !map.containsKey(key))) { return false; } map.remove(key); return true; }
java
@Inline(value = "$1.remove($2.getKey(), $2.getValue())", statementExpression = true) public static <K, V> boolean operator_remove(Map<K, V> map, Pair<? extends K, ? extends V> entry) { //TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue()); final K key = entry.getKey(); final V storedValue = map.get(entry.getKey()); if (!Objects.equal(storedValue, entry.getValue()) || (storedValue == null && !map.containsKey(key))) { return false; } map.remove(key); return true; }
[ "@", "Inline", "(", "value", "=", "\"$1.remove($2.getKey(), $2.getValue())\"", ",", "statementExpression", "=", "true", ")", "public", "static", "<", "K", ",", "V", ">", "boolean", "operator_remove", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "Pair", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "entry", ")", "{", "//TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue());", "final", "K", "key", "=", "entry", ".", "getKey", "(", ")", ";", "final", "V", "storedValue", "=", "map", ".", "get", "(", "entry", ".", "getKey", "(", ")", ")", ";", "if", "(", "!", "Objects", ".", "equal", "(", "storedValue", ",", "entry", ".", "getValue", "(", ")", ")", "||", "(", "storedValue", "==", "null", "&&", "!", "map", ".", "containsKey", "(", "key", ")", ")", ")", "{", "return", "false", ";", "}", "map", ".", "remove", "(", "key", ")", ";", "return", "true", ";", "}" ]
Remove the given pair into the map. <p> If the given key is inside the map, but is not mapped to the given value, the map will not be changed. </p> @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param entry the entry (key, value) to remove from the map. @return {@code true} if the pair was removed. @since 2.15
[ "Remove", "the", "given", "pair", "into", "the", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L226-L237
164,208
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_remove
public static <K, V> void operator_remove(Map<K, V> map, Iterable<? super K> keysToRemove) { for (final Object key : keysToRemove) { map.remove(key); } }
java
public static <K, V> void operator_remove(Map<K, V> map, Iterable<? super K> keysToRemove) { for (final Object key : keysToRemove) { map.remove(key); } }
[ "public", "static", "<", "K", ",", "V", ">", "void", "operator_remove", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "Iterable", "<", "?", "super", "K", ">", "keysToRemove", ")", "{", "for", "(", "final", "Object", "key", ":", "keysToRemove", ")", "{", "map", ".", "remove", "(", "key", ")", ";", "}", "}" ]
Remove pairs with the given keys from the map. @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param keysToRemove the keys of the pairs to remove. @since 2.15
[ "Remove", "pairs", "with", "the", "given", "keys", "from", "the", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L248-L252
164,209
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_minus
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Pair<? extends K, ? extends V> right) { return Maps.filterEntries(left, new Predicate<Entry<K, V>>() { @Override public boolean apply(Entry<K, V> input) { return !Objects.equal(input.getKey(), right.getKey()) || !Objects.equal(input.getValue(), right.getValue()); } }); }
java
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Pair<? extends K, ? extends V> right) { return Maps.filterEntries(left, new Predicate<Entry<K, V>>() { @Override public boolean apply(Entry<K, V> input) { return !Objects.equal(input.getKey(), right.getKey()) || !Objects.equal(input.getValue(), right.getValue()); } }); }
[ "@", "Pure", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_minus", "(", "Map", "<", "K", ",", "V", ">", "left", ",", "final", "Pair", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "right", ")", "{", "return", "Maps", ".", "filterEntries", "(", "left", ",", "new", "Predicate", "<", "Entry", "<", "K", ",", "V", ">", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "Entry", "<", "K", ",", "V", ">", "input", ")", "{", "return", "!", "Objects", ".", "equal", "(", "input", ".", "getKey", "(", ")", ",", "right", ".", "getKey", "(", ")", ")", "||", "!", "Objects", ".", "equal", "(", "input", ".", "getValue", "(", ")", ",", "right", ".", "getValue", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
Remove the given pair from a given map for obtaining a new map. <p> If the given key is inside the map, but is not mapped to the given value, the map will not be changed. </p> <p> The replied map is a view on the given map. It means that any change in the original map is reflected to the result of this operation. </p> @param <K> type of the map keys. @param <V> type of the map values. @param left the map to consider. @param right the entry (key, value) to remove from the map. @return an immutable map with the content of the map and with the given entry. @throws IllegalArgumentException - when the right operand key exists in the left operand. @since 2.15
[ "Remove", "the", "given", "pair", "from", "a", "given", "map", "for", "obtaining", "a", "new", "map", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L275-L283
164,210
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_minus
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final K key) { return Maps.filterKeys(map, new Predicate<K>() { @Override public boolean apply(K input) { return !Objects.equal(input, key); } }); }
java
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final K key) { return Maps.filterKeys(map, new Predicate<K>() { @Override public boolean apply(K input) { return !Objects.equal(input, key); } }); }
[ "@", "Pure", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_minus", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "final", "K", "key", ")", "{", "return", "Maps", ".", "filterKeys", "(", "map", ",", "new", "Predicate", "<", "K", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "K", "input", ")", "{", "return", "!", "Objects", ".", "equal", "(", "input", ",", "key", ")", ";", "}", "}", ")", ";", "}" ]
Replies the elements of the given map except the pair with the given key. <p> The replied map is a view on the given map. It means that any change in the original map is reflected to the result of this operation. </p> @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param key the key to remove. @return the map with the content of the map except the key. @since 2.15
[ "Replies", "the", "elements", "of", "the", "given", "map", "except", "the", "pair", "with", "the", "given", "key", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L300-L308
164,211
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_minus
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Map<? extends K, ? extends V> right) { return Maps.filterEntries(left, new Predicate<Entry<K, V>>() { @Override public boolean apply(Entry<K, V> input) { final V value = right.get(input.getKey()); if (value == null) { return input.getValue() == null && right.containsKey(input.getKey()); } return !Objects.equal(input.getValue(), value); } }); }
java
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Map<? extends K, ? extends V> right) { return Maps.filterEntries(left, new Predicate<Entry<K, V>>() { @Override public boolean apply(Entry<K, V> input) { final V value = right.get(input.getKey()); if (value == null) { return input.getValue() == null && right.containsKey(input.getKey()); } return !Objects.equal(input.getValue(), value); } }); }
[ "@", "Pure", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_minus", "(", "Map", "<", "K", ",", "V", ">", "left", ",", "final", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "right", ")", "{", "return", "Maps", ".", "filterEntries", "(", "left", ",", "new", "Predicate", "<", "Entry", "<", "K", ",", "V", ">", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "Entry", "<", "K", ",", "V", ">", "input", ")", "{", "final", "V", "value", "=", "right", ".", "get", "(", "input", ".", "getKey", "(", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "input", ".", "getValue", "(", ")", "==", "null", "&&", "right", ".", "containsKey", "(", "input", ".", "getKey", "(", ")", ")", ";", "}", "return", "!", "Objects", ".", "equal", "(", "input", ".", "getValue", "(", ")", ",", "value", ")", ";", "}", "}", ")", ";", "}" ]
Replies the elements of the left map without the pairs in the right map. If the pair's values differ from the value within the map, the map entry is not removed. <p> The difference is an immutable snapshot of the state of the maps at the time this method is called. It will never change, even if the maps change at a later time. </p> <p> Since this method uses {@code HashMap} instances internally, the keys of the supplied maps must be well-behaved with respect to {@link Object#equals} and {@link Object#hashCode}. </p> @param <K> type of the map keys. @param <V> type of the map values. @param left the map to update. @param right the pairs to remove. @return the map with the content of the left map except the pairs of the right map. @since 2.15
[ "Replies", "the", "elements", "of", "the", "left", "map", "without", "the", "pairs", "in", "the", "right", "map", ".", "If", "the", "pair", "s", "values", "differ", "from", "the", "value", "within", "the", "map", "the", "map", "entry", "is", "not", "removed", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L334-L346
164,212
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.operator_minus
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final Iterable<?> keys) { return Maps.filterKeys(map, new Predicate<K>() { @Override public boolean apply(K input) { return !Iterables.contains(keys, input); } }); }
java
@Pure public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final Iterable<?> keys) { return Maps.filterKeys(map, new Predicate<K>() { @Override public boolean apply(K input) { return !Iterables.contains(keys, input); } }); }
[ "@", "Pure", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "operator_minus", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "final", "Iterable", "<", "?", ">", "keys", ")", "{", "return", "Maps", ".", "filterKeys", "(", "map", ",", "new", "Predicate", "<", "K", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "K", "input", ")", "{", "return", "!", "Iterables", ".", "contains", "(", "keys", ",", "input", ")", ";", "}", "}", ")", ";", "}" ]
Replies the elements of the given map except the pairs with the given keys. <p> The replied map is a view on the given map. It means that any change in the original map is reflected to the result of this operation. </p> @param <K> type of the map keys. @param <V> type of the map values. @param map the map to update. @param keys the keys of the pairs to remove. @return the map with the content of the map except the pairs. @since 2.15
[ "Replies", "the", "elements", "of", "the", "given", "map", "except", "the", "pairs", "with", "the", "given", "keys", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L363-L371
164,213
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java
MapExtensions.union
@Pure @Inline(value = "(new $3<$5, $6>($1, $2))", imported = UnmodifiableMergingMapView.class, constantExpression = true) public static <K, V> Map<K, V> union(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) { return new UnmodifiableMergingMapView<K, V>(left, right); }
java
@Pure @Inline(value = "(new $3<$5, $6>($1, $2))", imported = UnmodifiableMergingMapView.class, constantExpression = true) public static <K, V> Map<K, V> union(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) { return new UnmodifiableMergingMapView<K, V>(left, right); }
[ "@", "Pure", "@", "Inline", "(", "value", "=", "\"(new $3<$5, $6>($1, $2))\"", ",", "imported", "=", "UnmodifiableMergingMapView", ".", "class", ",", "constantExpression", "=", "true", ")", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "union", "(", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "left", ",", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "right", ")", "{", "return", "new", "UnmodifiableMergingMapView", "<", "K", ",", "V", ">", "(", "left", ",", "right", ")", ";", "}" ]
Merge the given maps. <p> The replied map is a view on the given two maps. If a key exists in the two maps, the replied value is the value of the right operand. </p> <p> Even if the key of the right operand exists in the left operand, the value in the right operand is preferred. </p> <p> The replied map is unmodifiable. </p> @param <K> type of the map keys. @param <V> type of the map values. @param left the left map. @param right the right map. @return a map with the merged contents from the two maps. @since 2.15
[ "Merge", "the", "given", "maps", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L396-L400
164,214
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java
FunctionExtensions.curry
@Pure public static <P1, RESULT> Function0<RESULT> curry(final Function1<? super P1, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function0<RESULT>() { @Override public RESULT apply() { return function.apply(argument); } }; }
java
@Pure public static <P1, RESULT> Function0<RESULT> curry(final Function1<? super P1, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function0<RESULT>() { @Override public RESULT apply() { return function.apply(argument); } }; }
[ "@", "Pure", "public", "static", "<", "P1", ",", "RESULT", ">", "Function0", "<", "RESULT", ">", "curry", "(", "final", "Function1", "<", "?", "super", "P1", ",", "?", "extends", "RESULT", ">", "function", ",", "final", "P1", "argument", ")", "{", "if", "(", "function", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"function\"", ")", ";", "return", "new", "Function0", "<", "RESULT", ">", "(", ")", "{", "@", "Override", "public", "RESULT", "apply", "(", ")", "{", "return", "function", ".", "apply", "(", "argument", ")", ";", "}", "}", ";", "}" ]
Curries a function that takes one argument. @param function the original function. May not be <code>null</code>. @param argument the fixed argument. @return a function that takes no arguments. Never <code>null</code>.
[ "Curries", "a", "function", "that", "takes", "one", "argument", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L39-L49
164,215
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java
FunctionExtensions.curry
@Pure public static <P1, P2, RESULT> Function1<P2, RESULT> curry(final Function2<? super P1, ? super P2, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function1<P2, RESULT>() { @Override public RESULT apply(P2 p) { return function.apply(argument, p); } }; }
java
@Pure public static <P1, P2, RESULT> Function1<P2, RESULT> curry(final Function2<? super P1, ? super P2, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function1<P2, RESULT>() { @Override public RESULT apply(P2 p) { return function.apply(argument, p); } }; }
[ "@", "Pure", "public", "static", "<", "P1", ",", "P2", ",", "RESULT", ">", "Function1", "<", "P2", ",", "RESULT", ">", "curry", "(", "final", "Function2", "<", "?", "super", "P1", ",", "?", "super", "P2", ",", "?", "extends", "RESULT", ">", "function", ",", "final", "P1", "argument", ")", "{", "if", "(", "function", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"function\"", ")", ";", "return", "new", "Function1", "<", "P2", ",", "RESULT", ">", "(", ")", "{", "@", "Override", "public", "RESULT", "apply", "(", "P2", "p", ")", "{", "return", "function", ".", "apply", "(", "argument", ",", "p", ")", ";", "}", "}", ";", "}" ]
Curries a function that takes two arguments. @param function the original function. May not be <code>null</code>. @param argument the fixed first argument of {@code function}. @return a function that takes one argument. Never <code>null</code>.
[ "Curries", "a", "function", "that", "takes", "two", "arguments", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L60-L71
164,216
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java
FunctionExtensions.curry
@Pure public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function2<P2, P3, RESULT>() { @Override public RESULT apply(P2 p2, P3 p3) { return function.apply(argument, p2, p3); } }; }
java
@Pure public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function2<P2, P3, RESULT>() { @Override public RESULT apply(P2 p2, P3 p3) { return function.apply(argument, p2, p3); } }; }
[ "@", "Pure", "public", "static", "<", "P1", ",", "P2", ",", "P3", ",", "RESULT", ">", "Function2", "<", "P2", ",", "P3", ",", "RESULT", ">", "curry", "(", "final", "Function3", "<", "?", "super", "P1", ",", "?", "super", "P2", ",", "?", "super", "P3", ",", "?", "extends", "RESULT", ">", "function", ",", "final", "P1", "argument", ")", "{", "if", "(", "function", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"function\"", ")", ";", "return", "new", "Function2", "<", "P2", ",", "P3", ",", "RESULT", ">", "(", ")", "{", "@", "Override", "public", "RESULT", "apply", "(", "P2", "p2", ",", "P3", "p3", ")", "{", "return", "function", ".", "apply", "(", "argument", ",", "p2", ",", "p3", ")", ";", "}", "}", ";", "}" ]
Curries a function that takes three arguments. @param function the original function. May not be <code>null</code>. @param argument the fixed first argument of {@code function}. @return a function that takes two arguments. Never <code>null</code>.
[ "Curries", "a", "function", "that", "takes", "three", "arguments", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L82-L93
164,217
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java
FunctionExtensions.curry
@Pure public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry( final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function3<P2, P3, P4, RESULT>() { @Override public RESULT apply(P2 p2, P3 p3, P4 p4) { return function.apply(argument, p2, p3, p4); } }; }
java
@Pure public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry( final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) { if (function == null) throw new NullPointerException("function"); return new Function3<P2, P3, P4, RESULT>() { @Override public RESULT apply(P2 p2, P3 p3, P4 p4) { return function.apply(argument, p2, p3, p4); } }; }
[ "@", "Pure", "public", "static", "<", "P1", ",", "P2", ",", "P3", ",", "P4", ",", "RESULT", ">", "Function3", "<", "P2", ",", "P3", ",", "P4", ",", "RESULT", ">", "curry", "(", "final", "Function4", "<", "?", "super", "P1", ",", "?", "super", "P2", ",", "?", "super", "P3", ",", "?", "super", "P4", ",", "?", "extends", "RESULT", ">", "function", ",", "final", "P1", "argument", ")", "{", "if", "(", "function", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"function\"", ")", ";", "return", "new", "Function3", "<", "P2", ",", "P3", ",", "P4", ",", "RESULT", ">", "(", ")", "{", "@", "Override", "public", "RESULT", "apply", "(", "P2", "p2", ",", "P3", "p3", ",", "P4", "p4", ")", "{", "return", "function", ".", "apply", "(", "argument", ",", "p2", ",", "p3", ",", "p4", ")", ";", "}", "}", ";", "}" ]
Curries a function that takes four arguments. @param function the original function. May not be <code>null</code>. @param argument the fixed first argument of {@code function}. @return a function that takes three arguments. Never <code>null</code>.
[ "Curries", "a", "function", "that", "takes", "four", "arguments", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L104-L115
164,218
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java
IterableExtensions.filterNull
@Pure public static <T> Iterable<T> filterNull(Iterable<T> unfiltered) { return Iterables.filter(unfiltered, Predicates.notNull()); }
java
@Pure public static <T> Iterable<T> filterNull(Iterable<T> unfiltered) { return Iterables.filter(unfiltered, Predicates.notNull()); }
[ "@", "Pure", "public", "static", "<", "T", ">", "Iterable", "<", "T", ">", "filterNull", "(", "Iterable", "<", "T", ">", "unfiltered", ")", "{", "return", "Iterables", ".", "filter", "(", "unfiltered", ",", "Predicates", ".", "notNull", "(", ")", ")", ";", "}" ]
Returns a new iterable filtering any null references. @param unfiltered the unfiltered iterable. May not be <code>null</code>. @return an unmodifiable iterable containing all elements of the original iterable without any <code>null</code> references. Never <code>null</code>.
[ "Returns", "a", "new", "iterable", "filtering", "any", "null", "references", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L321-L324
164,219
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java
IterableExtensions.sort
public static <T extends Comparable<? super T>> List<T> sort(Iterable<T> iterable) { List<T> asList = Lists.newArrayList(iterable); if (iterable instanceof SortedSet<?>) { if (((SortedSet<T>) iterable).comparator() == null) { return asList; } } return ListExtensions.sortInplace(asList); }
java
public static <T extends Comparable<? super T>> List<T> sort(Iterable<T> iterable) { List<T> asList = Lists.newArrayList(iterable); if (iterable instanceof SortedSet<?>) { if (((SortedSet<T>) iterable).comparator() == null) { return asList; } } return ListExtensions.sortInplace(asList); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "?", "super", "T", ">", ">", "List", "<", "T", ">", "sort", "(", "Iterable", "<", "T", ">", "iterable", ")", "{", "List", "<", "T", ">", "asList", "=", "Lists", ".", "newArrayList", "(", "iterable", ")", ";", "if", "(", "iterable", "instanceof", "SortedSet", "<", "?", ">", ")", "{", "if", "(", "(", "(", "SortedSet", "<", "T", ">", ")", "iterable", ")", ".", "comparator", "(", ")", "==", "null", ")", "{", "return", "asList", ";", "}", "}", "return", "ListExtensions", ".", "sortInplace", "(", "asList", ")", ";", "}" ]
Creates a sorted list that contains the items of the given iterable. The resulting list is in ascending order, according to the natural ordering of the elements in the iterable. @param iterable the items to be sorted. May not be <code>null</code>. @return a sorted list as a shallow copy of the given iterable. @see Collections#sort(List) @see #sort(Iterable, Comparator) @see #sortBy(Iterable, org.eclipse.xtext.xbase.lib.Functions.Function1) @see ListExtensions#sortInplace(List)
[ "Creates", "a", "sorted", "list", "that", "contains", "the", "items", "of", "the", "given", "iterable", ".", "The", "resulting", "list", "is", "in", "ascending", "order", "according", "to", "the", "natural", "ordering", "of", "the", "elements", "in", "the", "iterable", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L726-L734
164,220
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java
IterableExtensions.sortWith
public static <T> List<T> sortWith(Iterable<T> iterable, Comparator<? super T> comparator) { return ListExtensions.sortInplace(Lists.newArrayList(iterable), comparator); }
java
public static <T> List<T> sortWith(Iterable<T> iterable, Comparator<? super T> comparator) { return ListExtensions.sortInplace(Lists.newArrayList(iterable), comparator); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "sortWith", "(", "Iterable", "<", "T", ">", "iterable", ",", "Comparator", "<", "?", "super", "T", ">", "comparator", ")", "{", "return", "ListExtensions", ".", "sortInplace", "(", "Lists", ".", "newArrayList", "(", "iterable", ")", ",", "comparator", ")", ";", "}" ]
Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to the order induced by the specified comparator. @param iterable the items to be sorted. May not be <code>null</code>. @param comparator the comparator to be used. May be <code>null</code> to indicate that the natural ordering of the elements should be used. @return a sorted list as a shallow copy of the given iterable. @see Collections#sort(List, Comparator) @see #sort(Iterable) @see #sortBy(Iterable, org.eclipse.xtext.xbase.lib.Functions.Function1) @see ListExtensions#sortInplace(List, Comparator) @since 2.7
[ "Creates", "a", "sorted", "list", "that", "contains", "the", "items", "of", "the", "given", "iterable", ".", "The", "resulting", "list", "is", "sorted", "according", "to", "the", "order", "induced", "by", "the", "specified", "comparator", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L773-L775
164,221
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java
IterableExtensions.sortBy
public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable, final Functions.Function1<? super T, C> key) { return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key); }
java
public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable, final Functions.Function1<? super T, C> key) { return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key); }
[ "public", "static", "<", "T", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "List", "<", "T", ">", "sortBy", "(", "Iterable", "<", "T", ">", "iterable", ",", "final", "Functions", ".", "Function1", "<", "?", "super", "T", ",", "C", ">", "key", ")", "{", "return", "ListExtensions", ".", "sortInplaceBy", "(", "Lists", ".", "newArrayList", "(", "iterable", ")", ",", "key", ")", ";", "}" ]
Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to the order induced by applying a key function to each element which yields a comparable criteria. @param iterable the elements to be sorted. May not be <code>null</code>. @param key the key function to-be-used. May not be <code>null</code>. @return a sorted list as a shallow copy of the given iterable. @see #sort(Iterable) @see #sort(Iterable, Comparator) @see ListExtensions#sortInplaceBy(List, org.eclipse.xtext.xbase.lib.Functions.Function1)
[ "Creates", "a", "sorted", "list", "that", "contains", "the", "items", "of", "the", "given", "iterable", ".", "The", "resulting", "list", "is", "sorted", "according", "to", "the", "order", "induced", "by", "applying", "a", "key", "function", "to", "each", "element", "which", "yields", "a", "comparable", "criteria", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L790-L793
164,222
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Conversions.java
Conversions.checkComponentType
private static Object checkComponentType(Object array, Class<?> expectedComponentType) { Class<?> actualComponentType = array.getClass().getComponentType(); if (!expectedComponentType.isAssignableFrom(actualComponentType)) { throw new ArrayStoreException( String.format("The expected component type %s is not assignable from the actual type %s", expectedComponentType.getCanonicalName(), actualComponentType.getCanonicalName())); } return array; }
java
private static Object checkComponentType(Object array, Class<?> expectedComponentType) { Class<?> actualComponentType = array.getClass().getComponentType(); if (!expectedComponentType.isAssignableFrom(actualComponentType)) { throw new ArrayStoreException( String.format("The expected component type %s is not assignable from the actual type %s", expectedComponentType.getCanonicalName(), actualComponentType.getCanonicalName())); } return array; }
[ "private", "static", "Object", "checkComponentType", "(", "Object", "array", ",", "Class", "<", "?", ">", "expectedComponentType", ")", "{", "Class", "<", "?", ">", "actualComponentType", "=", "array", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ";", "if", "(", "!", "expectedComponentType", ".", "isAssignableFrom", "(", "actualComponentType", ")", ")", "{", "throw", "new", "ArrayStoreException", "(", "String", ".", "format", "(", "\"The expected component type %s is not assignable from the actual type %s\"", ",", "expectedComponentType", ".", "getCanonicalName", "(", ")", ",", "actualComponentType", ".", "getCanonicalName", "(", ")", ")", ")", ";", "}", "return", "array", ";", "}" ]
Checks the component type of the given array against the expected component type. @param array the array to be checked. May not be <code>null</code>. @param expectedComponentType the expected component type of the array. May not be <code>null</code>. @return the unchanged array. @throws ArrayStoreException if the expected runtime {@code componentType} does not match the actual runtime component type.
[ "Checks", "the", "component", "type", "of", "the", "given", "array", "against", "the", "expected", "component", "type", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Conversions.java#L226-L234
164,223
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java
ToStringBuilder.addDeclaredFields
@GwtIncompatible("Class.getDeclaredFields") public ToStringBuilder addDeclaredFields() { Field[] fields = instance.getClass().getDeclaredFields(); for(Field field : fields) { addField(field); } return this; }
java
@GwtIncompatible("Class.getDeclaredFields") public ToStringBuilder addDeclaredFields() { Field[] fields = instance.getClass().getDeclaredFields(); for(Field field : fields) { addField(field); } return this; }
[ "@", "GwtIncompatible", "(", "\"Class.getDeclaredFields\"", ")", "public", "ToStringBuilder", "addDeclaredFields", "(", ")", "{", "Field", "[", "]", "fields", "=", "instance", ".", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "Field", "field", ":", "fields", ")", "{", "addField", "(", "field", ")", ";", "}", "return", "this", ";", "}" ]
Adds all fields declared directly in the object's class to the output @return this
[ "Adds", "all", "fields", "declared", "directly", "in", "the", "object", "s", "class", "to", "the", "output" ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java#L114-L121
164,224
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java
ToStringBuilder.addAllFields
@GwtIncompatible("Class.getDeclaredFields") public ToStringBuilder addAllFields() { List<Field> fields = getAllDeclaredFields(instance.getClass()); for(Field field : fields) { addField(field); } return this; }
java
@GwtIncompatible("Class.getDeclaredFields") public ToStringBuilder addAllFields() { List<Field> fields = getAllDeclaredFields(instance.getClass()); for(Field field : fields) { addField(field); } return this; }
[ "@", "GwtIncompatible", "(", "\"Class.getDeclaredFields\"", ")", "public", "ToStringBuilder", "addAllFields", "(", ")", "{", "List", "<", "Field", ">", "fields", "=", "getAllDeclaredFields", "(", "instance", ".", "getClass", "(", ")", ")", ";", "for", "(", "Field", "field", ":", "fields", ")", "{", "addField", "(", "field", ")", ";", "}", "return", "this", ";", "}" ]
Adds all fields declared in the object's class and its superclasses to the output. @return this
[ "Adds", "all", "fields", "declared", "in", "the", "object", "s", "class", "and", "its", "superclasses", "to", "the", "output", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java#L127-L134
164,225
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java
IteratorExtensions.filterNull
@Pure public static <T> Iterator<T> filterNull(Iterator<T> unfiltered) { return Iterators.filter(unfiltered, Predicates.notNull()); }
java
@Pure public static <T> Iterator<T> filterNull(Iterator<T> unfiltered) { return Iterators.filter(unfiltered, Predicates.notNull()); }
[ "@", "Pure", "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "filterNull", "(", "Iterator", "<", "T", ">", "unfiltered", ")", "{", "return", "Iterators", ".", "filter", "(", "unfiltered", ",", "Predicates", ".", "notNull", "(", ")", ")", ";", "}" ]
Returns a new iterator filtering any null references. @param unfiltered the unfiltered iterator. May not be <code>null</code>. @return an unmodifiable iterator containing all elements of the original iterator without any <code>null</code> references. Never <code>null</code>.
[ "Returns", "a", "new", "iterator", "filtering", "any", "null", "references", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L350-L353
164,226
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java
IteratorExtensions.toList
public static <T> List<T> toList(Iterator<? extends T> iterator) { return Lists.newArrayList(iterator); }
java
public static <T> List<T> toList(Iterator<? extends T> iterator) { return Lists.newArrayList(iterator); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "toList", "(", "Iterator", "<", "?", "extends", "T", ">", "iterator", ")", "{", "return", "Lists", ".", "newArrayList", "(", "iterator", ")", ";", "}" ]
Returns a list that contains all the entries of the given iterator in the same order. @param iterator the iterator. May not be <code>null</code>. @return a list with the same entries as the given iterator. Never <code>null</code>.
[ "Returns", "a", "list", "that", "contains", "all", "the", "entries", "of", "the", "given", "iterator", "in", "the", "same", "order", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L702-L704
164,227
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java
IteratorExtensions.toSet
public static <T> Set<T> toSet(Iterator<? extends T> iterator) { return Sets.newLinkedHashSet(toIterable(iterator)); }
java
public static <T> Set<T> toSet(Iterator<? extends T> iterator) { return Sets.newLinkedHashSet(toIterable(iterator)); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "toSet", "(", "Iterator", "<", "?", "extends", "T", ">", "iterator", ")", "{", "return", "Sets", ".", "newLinkedHashSet", "(", "toIterable", "(", "iterator", ")", ")", ";", "}" ]
Returns a set that contains all the unique entries of the given iterator in the order of their appearance. The result set is a copy of the iterator with stable order. @param iterator the iterator. May not be <code>null</code>. @return a set with the unique entries of the given iterator. Never <code>null</code>.
[ "Returns", "a", "set", "that", "contains", "all", "the", "unique", "entries", "of", "the", "given", "iterator", "in", "the", "order", "of", "their", "appearance", ".", "The", "result", "set", "is", "a", "copy", "of", "the", "iterator", "with", "stable", "order", "." ]
7063572e1f1bd713a3aa53bdf3a8dc60e25c169a
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L714-L716
164,228
hap-java/HAP-Java
src/main/java/io/github/hapjava/HomekitServer.java
HomekitServer.createBridge
public HomekitRoot createBridge( HomekitAuthInfo authInfo, String label, String manufacturer, String model, String serialNumber) throws IOException { HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo); root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer)); return root; }
java
public HomekitRoot createBridge( HomekitAuthInfo authInfo, String label, String manufacturer, String model, String serialNumber) throws IOException { HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo); root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer)); return root; }
[ "public", "HomekitRoot", "createBridge", "(", "HomekitAuthInfo", "authInfo", ",", "String", "label", ",", "String", "manufacturer", ",", "String", "model", ",", "String", "serialNumber", ")", "throws", "IOException", "{", "HomekitRoot", "root", "=", "new", "HomekitRoot", "(", "label", ",", "http", ",", "localAddress", ",", "authInfo", ")", ";", "root", ".", "addAccessory", "(", "new", "HomekitBridge", "(", "label", ",", "serialNumber", ",", "model", ",", "manufacturer", ")", ")", ";", "return", "root", ";", "}" ]
Creates a bridge accessory, capable of holding multiple child accessories. This has the advantage over multiple standalone accessories of only requiring a single pairing from iOS for the bridge. @param authInfo authentication information for this accessory. These values should be persisted and re-supplied on re-start of your application. @param label label for the bridge. This will show in iOS during pairing. @param manufacturer manufacturer of the bridge. This information is exposed to iOS for unknown purposes. @param model model of the bridge. This is also exposed to iOS for unknown purposes. @param serialNumber serial number of the bridge. Also exposed. Purposes also unknown. @return the bridge, from which you can {@link HomekitRoot#addAccessory add accessories} and then {@link HomekitRoot#start start} handling requests. @throws IOException when mDNS cannot connect to the network
[ "Creates", "a", "bridge", "accessory", "capable", "of", "holding", "multiple", "child", "accessories", ".", "This", "has", "the", "advantage", "over", "multiple", "standalone", "accessories", "of", "only", "requiring", "a", "single", "pairing", "from", "iOS", "for", "the", "bridge", "." ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitServer.java#L104-L114
164,229
hap-java/HAP-Java
src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java
BaseCharacteristic.makeBuilder
protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) { CompletableFuture<T> futureValue = getValue(); if (futureValue == null) { logger.error("Could not retrieve value " + this.getClass().getName()); return null; } return futureValue .exceptionally( t -> { logger.error("Could not retrieve value " + this.getClass().getName(), t); return null; }) .thenApply( value -> { JsonArrayBuilder perms = Json.createArrayBuilder(); if (isWritable) { perms.add("pw"); } if (isReadable) { perms.add("pr"); } if (isEventable) { perms.add("ev"); } JsonObjectBuilder builder = Json.createObjectBuilder() .add("iid", instanceId) .add("type", shortType) .add("perms", perms.build()) .add("format", format) .add("ev", false) .add("description", description); setJsonValue(builder, value); return builder; }); }
java
protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) { CompletableFuture<T> futureValue = getValue(); if (futureValue == null) { logger.error("Could not retrieve value " + this.getClass().getName()); return null; } return futureValue .exceptionally( t -> { logger.error("Could not retrieve value " + this.getClass().getName(), t); return null; }) .thenApply( value -> { JsonArrayBuilder perms = Json.createArrayBuilder(); if (isWritable) { perms.add("pw"); } if (isReadable) { perms.add("pr"); } if (isEventable) { perms.add("ev"); } JsonObjectBuilder builder = Json.createObjectBuilder() .add("iid", instanceId) .add("type", shortType) .add("perms", perms.build()) .add("format", format) .add("ev", false) .add("description", description); setJsonValue(builder, value); return builder; }); }
[ "protected", "CompletableFuture", "<", "JsonObjectBuilder", ">", "makeBuilder", "(", "int", "instanceId", ")", "{", "CompletableFuture", "<", "T", ">", "futureValue", "=", "getValue", "(", ")", ";", "if", "(", "futureValue", "==", "null", ")", "{", "logger", ".", "error", "(", "\"Could not retrieve value \"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "null", ";", "}", "return", "futureValue", ".", "exceptionally", "(", "t", "->", "{", "logger", ".", "error", "(", "\"Could not retrieve value \"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "t", ")", ";", "return", "null", ";", "}", ")", ".", "thenApply", "(", "value", "->", "{", "JsonArrayBuilder", "perms", "=", "Json", ".", "createArrayBuilder", "(", ")", ";", "if", "(", "isWritable", ")", "{", "perms", ".", "add", "(", "\"pw\"", ")", ";", "}", "if", "(", "isReadable", ")", "{", "perms", ".", "add", "(", "\"pr\"", ")", ";", "}", "if", "(", "isEventable", ")", "{", "perms", ".", "add", "(", "\"ev\"", ")", ";", "}", "JsonObjectBuilder", "builder", "=", "Json", ".", "createObjectBuilder", "(", ")", ".", "add", "(", "\"iid\"", ",", "instanceId", ")", ".", "add", "(", "\"type\"", ",", "shortType", ")", ".", "add", "(", "\"perms\"", ",", "perms", ".", "build", "(", ")", ")", ".", "add", "(", "\"format\"", ",", "format", ")", ".", "add", "(", "\"ev\"", ",", "false", ")", ".", "add", "(", "\"description\"", ",", "description", ")", ";", "setJsonValue", "(", "builder", ",", "value", ")", ";", "return", "builder", ";", "}", ")", ";", "}" ]
Creates the JSON serialized form of the accessory for use over the Homekit Accessory Protocol. @param instanceId the static id of the accessory. @return a future that will complete with the JSON builder for the object.
[ "Creates", "the", "JSON", "serialized", "form", "of", "the", "accessory", "for", "use", "over", "the", "Homekit", "Accessory", "Protocol", "." ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java#L70-L107
164,230
hap-java/HAP-Java
src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java
BaseCharacteristic.setJsonValue
protected void setJsonValue(JsonObjectBuilder builder, T value) { // I don't like this - there should really be a way to construct a disconnected JSONValue... if (value instanceof Boolean) { builder.add("value", (Boolean) value); } else if (value instanceof Double) { builder.add("value", (Double) value); } else if (value instanceof Integer) { builder.add("value", (Integer) value); } else if (value instanceof Long) { builder.add("value", (Long) value); } else if (value instanceof BigInteger) { builder.add("value", (BigInteger) value); } else if (value instanceof BigDecimal) { builder.add("value", (BigDecimal) value); } else if (value == null) { builder.addNull("value"); } else { builder.add("value", value.toString()); } }
java
protected void setJsonValue(JsonObjectBuilder builder, T value) { // I don't like this - there should really be a way to construct a disconnected JSONValue... if (value instanceof Boolean) { builder.add("value", (Boolean) value); } else if (value instanceof Double) { builder.add("value", (Double) value); } else if (value instanceof Integer) { builder.add("value", (Integer) value); } else if (value instanceof Long) { builder.add("value", (Long) value); } else if (value instanceof BigInteger) { builder.add("value", (BigInteger) value); } else if (value instanceof BigDecimal) { builder.add("value", (BigDecimal) value); } else if (value == null) { builder.addNull("value"); } else { builder.add("value", value.toString()); } }
[ "protected", "void", "setJsonValue", "(", "JsonObjectBuilder", "builder", ",", "T", "value", ")", "{", "// I don't like this - there should really be a way to construct a disconnected JSONValue...", "if", "(", "value", "instanceof", "Boolean", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "Boolean", ")", "value", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "Double", ")", "value", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "Integer", ")", "value", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "Long", ")", "value", ")", ";", "}", "else", "if", "(", "value", "instanceof", "BigInteger", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "BigInteger", ")", "value", ")", ";", "}", "else", "if", "(", "value", "instanceof", "BigDecimal", ")", "{", "builder", ".", "add", "(", "\"value\"", ",", "(", "BigDecimal", ")", "value", ")", ";", "}", "else", "if", "(", "value", "==", "null", ")", "{", "builder", ".", "addNull", "(", "\"value\"", ")", ";", "}", "else", "{", "builder", ".", "add", "(", "\"value\"", ",", "value", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Writes the value key to the serialized characteristic @param builder The JSON builder to add the value to @param value The value to add
[ "Writes", "the", "value", "key", "to", "the", "serialized", "characteristic" ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java#L167-L186
164,231
hap-java/HAP-Java
src/main/java/io/github/hapjava/impl/connections/SubscriptionManager.java
SubscriptionManager.removeAll
public void removeAll() { LOGGER.debug("Removing {} reverse connections from subscription manager", reverse.size()); Iterator<HomekitClientConnection> i = reverse.keySet().iterator(); while (i.hasNext()) { HomekitClientConnection connection = i.next(); LOGGER.debug("Removing connection {}", connection.hashCode()); removeConnection(connection); } LOGGER.debug("Subscription sizes are {} and {}", reverse.size(), subscriptions.size()); }
java
public void removeAll() { LOGGER.debug("Removing {} reverse connections from subscription manager", reverse.size()); Iterator<HomekitClientConnection> i = reverse.keySet().iterator(); while (i.hasNext()) { HomekitClientConnection connection = i.next(); LOGGER.debug("Removing connection {}", connection.hashCode()); removeConnection(connection); } LOGGER.debug("Subscription sizes are {} and {}", reverse.size(), subscriptions.size()); }
[ "public", "void", "removeAll", "(", ")", "{", "LOGGER", ".", "debug", "(", "\"Removing {} reverse connections from subscription manager\"", ",", "reverse", ".", "size", "(", ")", ")", ";", "Iterator", "<", "HomekitClientConnection", ">", "i", "=", "reverse", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "HomekitClientConnection", "connection", "=", "i", ".", "next", "(", ")", ";", "LOGGER", ".", "debug", "(", "\"Removing connection {}\"", ",", "connection", ".", "hashCode", "(", ")", ")", ";", "removeConnection", "(", "connection", ")", ";", "}", "LOGGER", ".", "debug", "(", "\"Subscription sizes are {} and {}\"", ",", "reverse", ".", "size", "(", ")", ",", "subscriptions", ".", "size", "(", ")", ")", ";", "}" ]
Remove all existing subscriptions
[ "Remove", "all", "existing", "subscriptions" ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/impl/connections/SubscriptionManager.java#L144-L153
164,232
hap-java/HAP-Java
src/main/java/io/github/hapjava/HomekitRoot.java
HomekitRoot.addAccessory
public void addAccessory(HomekitAccessory accessory) { if (accessory.getId() <= 1 && !(accessory instanceof Bridge)) { throw new IndexOutOfBoundsException( "The ID of an accessory used in a bridge must be greater than 1"); } addAccessorySkipRangeCheck(accessory); }
java
public void addAccessory(HomekitAccessory accessory) { if (accessory.getId() <= 1 && !(accessory instanceof Bridge)) { throw new IndexOutOfBoundsException( "The ID of an accessory used in a bridge must be greater than 1"); } addAccessorySkipRangeCheck(accessory); }
[ "public", "void", "addAccessory", "(", "HomekitAccessory", "accessory", ")", "{", "if", "(", "accessory", ".", "getId", "(", ")", "<=", "1", "&&", "!", "(", "accessory", "instanceof", "Bridge", ")", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"The ID of an accessory used in a bridge must be greater than 1\"", ")", ";", "}", "addAccessorySkipRangeCheck", "(", "accessory", ")", ";", "}" ]
Add an accessory to be handled and advertised by this root. Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list. When using this for a bridge, the ID of the accessory must be greater than 1, as that ID is reserved for the Bridge itself. @param accessory to advertise and handle.
[ "Add", "an", "accessory", "to", "be", "handled", "and", "advertised", "by", "this", "root", ".", "Any", "existing", "Homekit", "connections", "will", "be", "terminated", "to", "allow", "the", "clients", "to", "reconnect", "and", "see", "the", "updated", "accessory", "list", ".", "When", "using", "this", "for", "a", "bridge", "the", "ID", "of", "the", "accessory", "must", "be", "greater", "than", "1", "as", "that", "ID", "is", "reserved", "for", "the", "Bridge", "itself", "." ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitRoot.java#L63-L69
164,233
hap-java/HAP-Java
src/main/java/io/github/hapjava/HomekitRoot.java
HomekitRoot.removeAccessory
public void removeAccessory(HomekitAccessory accessory) { this.registry.remove(accessory); logger.info("Removed accessory " + accessory.getLabel()); if (started) { registry.reset(); webHandler.resetConnections(); } }
java
public void removeAccessory(HomekitAccessory accessory) { this.registry.remove(accessory); logger.info("Removed accessory " + accessory.getLabel()); if (started) { registry.reset(); webHandler.resetConnections(); } }
[ "public", "void", "removeAccessory", "(", "HomekitAccessory", "accessory", ")", "{", "this", ".", "registry", ".", "remove", "(", "accessory", ")", ";", "logger", ".", "info", "(", "\"Removed accessory \"", "+", "accessory", ".", "getLabel", "(", ")", ")", ";", "if", "(", "started", ")", "{", "registry", ".", "reset", "(", ")", ";", "webHandler", ".", "resetConnections", "(", ")", ";", "}", "}" ]
Removes an accessory from being handled or advertised by this root. Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list. @param accessory accessory to cease advertising and handling
[ "Removes", "an", "accessory", "from", "being", "handled", "or", "advertised", "by", "this", "root", ".", "Any", "existing", "Homekit", "connections", "will", "be", "terminated", "to", "allow", "the", "clients", "to", "reconnect", "and", "see", "the", "updated", "accessory", "list", "." ]
d2b2f4f1579580a2b5958af3a192128345843db9
https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitRoot.java#L93-L100
164,234
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/ThinDownloadManager.java
ThinDownloadManager.add
@Override public int add(DownloadRequest request) throws IllegalArgumentException { checkReleased("add(...) called on a released ThinDownloadManager."); if (request == null) { throw new IllegalArgumentException("DownloadRequest cannot be null"); } return mRequestQueue.add(request); }
java
@Override public int add(DownloadRequest request) throws IllegalArgumentException { checkReleased("add(...) called on a released ThinDownloadManager."); if (request == null) { throw new IllegalArgumentException("DownloadRequest cannot be null"); } return mRequestQueue.add(request); }
[ "@", "Override", "public", "int", "add", "(", "DownloadRequest", "request", ")", "throws", "IllegalArgumentException", "{", "checkReleased", "(", "\"add(...) called on a released ThinDownloadManager.\"", ")", ";", "if", "(", "request", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"DownloadRequest cannot be null\"", ")", ";", "}", "return", "mRequestQueue", ".", "add", "(", "request", ")", ";", "}" ]
Add a new download. The download will start automatically once the download manager is ready to execute it and connectivity is available. @param request the parameters specifying this download @return an ID for the download, unique across the application. This ID is used to make future calls related to this download. @throws IllegalArgumentException
[ "Add", "a", "new", "download", ".", "The", "download", "will", "start", "automatically", "once", "the", "download", "manager", "is", "ready", "to", "execute", "it", "and", "connectivity", "is", "available", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/ThinDownloadManager.java#L74-L81
164,235
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java
DownloadRequest.addCustomHeader
public DownloadRequest addCustomHeader(String key, String value) { mCustomHeader.put(key, value); return this; }
java
public DownloadRequest addCustomHeader(String key, String value) { mCustomHeader.put(key, value); return this; }
[ "public", "DownloadRequest", "addCustomHeader", "(", "String", "key", ",", "String", "value", ")", "{", "mCustomHeader", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds custom header to request @param key @param value
[ "Adds", "custom", "header", "to", "request" ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java#L112-L115
164,236
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java
DownloadDispatcher.cleanupDestination
private void cleanupDestination(DownloadRequest request, boolean forceClean) { if (!request.isResumable() || forceClean) { Log.d("cleanupDestination() deleting " + request.getDestinationURI().getPath()); File destinationFile = new File(request.getDestinationURI().getPath()); if (destinationFile.exists()) { destinationFile.delete(); } } }
java
private void cleanupDestination(DownloadRequest request, boolean forceClean) { if (!request.isResumable() || forceClean) { Log.d("cleanupDestination() deleting " + request.getDestinationURI().getPath()); File destinationFile = new File(request.getDestinationURI().getPath()); if (destinationFile.exists()) { destinationFile.delete(); } } }
[ "private", "void", "cleanupDestination", "(", "DownloadRequest", "request", ",", "boolean", "forceClean", ")", "{", "if", "(", "!", "request", ".", "isResumable", "(", ")", "||", "forceClean", ")", "{", "Log", ".", "d", "(", "\"cleanupDestination() deleting \"", "+", "request", ".", "getDestinationURI", "(", ")", ".", "getPath", "(", ")", ")", ";", "File", "destinationFile", "=", "new", "File", "(", "request", ".", "getDestinationURI", "(", ")", ".", "getPath", "(", ")", ")", ";", "if", "(", "destinationFile", ".", "exists", "(", ")", ")", "{", "destinationFile", ".", "delete", "(", ")", ";", "}", "}", "}" ]
Called just before the thread finishes, regardless of status, to take any necessary action on the downloaded file with mDownloadedCacheSize file. @param forceClean - It will delete downloaded cache, Even streaming is enabled, If user intentionally cancelled.
[ "Called", "just", "before", "the", "thread", "finishes", "regardless", "of", "status", "to", "take", "any", "necessary", "action", "on", "the", "downloaded", "file", "with", "mDownloadedCacheSize", "file", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java#L438-L446
164,237
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.add
int add(DownloadRequest request) { int downloadId = getDownloadId(); // Tag the request as belonging to this queue and add it to the set of current requests. request.setDownloadRequestQueue(this); synchronized (mCurrentRequests) { mCurrentRequests.add(request); } // Process requests in the order they are added. request.setDownloadId(downloadId); mDownloadQueue.add(request); return downloadId; }
java
int add(DownloadRequest request) { int downloadId = getDownloadId(); // Tag the request as belonging to this queue and add it to the set of current requests. request.setDownloadRequestQueue(this); synchronized (mCurrentRequests) { mCurrentRequests.add(request); } // Process requests in the order they are added. request.setDownloadId(downloadId); mDownloadQueue.add(request); return downloadId; }
[ "int", "add", "(", "DownloadRequest", "request", ")", "{", "int", "downloadId", "=", "getDownloadId", "(", ")", ";", "// Tag the request as belonging to this queue and add it to the set of current requests.", "request", ".", "setDownloadRequestQueue", "(", "this", ")", ";", "synchronized", "(", "mCurrentRequests", ")", "{", "mCurrentRequests", ".", "add", "(", "request", ")", ";", "}", "// Process requests in the order they are added.", "request", ".", "setDownloadId", "(", "downloadId", ")", ";", "mDownloadQueue", ".", "add", "(", "request", ")", ";", "return", "downloadId", ";", "}" ]
Generates a download id for the request and adds the download request to the download request queue for the dispatchers pool to act on immediately. @param request @return downloadId
[ "Generates", "a", "download", "id", "for", "the", "request", "and", "adds", "the", "download", "request", "to", "the", "download", "request", "queue", "for", "the", "dispatchers", "pool", "to", "act", "on", "immediately", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L142-L156
164,238
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.query
int query(int downloadId) { synchronized (mCurrentRequests) { for (DownloadRequest request : mCurrentRequests) { if (request.getDownloadId() == downloadId) { return request.getDownloadState(); } } } return DownloadManager.STATUS_NOT_FOUND; }
java
int query(int downloadId) { synchronized (mCurrentRequests) { for (DownloadRequest request : mCurrentRequests) { if (request.getDownloadId() == downloadId) { return request.getDownloadState(); } } } return DownloadManager.STATUS_NOT_FOUND; }
[ "int", "query", "(", "int", "downloadId", ")", "{", "synchronized", "(", "mCurrentRequests", ")", "{", "for", "(", "DownloadRequest", "request", ":", "mCurrentRequests", ")", "{", "if", "(", "request", ".", "getDownloadId", "(", ")", "==", "downloadId", ")", "{", "return", "request", ".", "getDownloadState", "(", ")", ";", "}", "}", "}", "return", "DownloadManager", ".", "STATUS_NOT_FOUND", ";", "}" ]
Returns the current download state for a download request. @param downloadId @return
[ "Returns", "the", "current", "download", "state", "for", "a", "download", "request", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L164-L173
164,239
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.cancel
int cancel(int downloadId) { synchronized (mCurrentRequests) { for (DownloadRequest request : mCurrentRequests) { if (request.getDownloadId() == downloadId) { request.cancel(); return 1; } } } return 0; }
java
int cancel(int downloadId) { synchronized (mCurrentRequests) { for (DownloadRequest request : mCurrentRequests) { if (request.getDownloadId() == downloadId) { request.cancel(); return 1; } } } return 0; }
[ "int", "cancel", "(", "int", "downloadId", ")", "{", "synchronized", "(", "mCurrentRequests", ")", "{", "for", "(", "DownloadRequest", "request", ":", "mCurrentRequests", ")", "{", "if", "(", "request", ".", "getDownloadId", "(", ")", "==", "downloadId", ")", "{", "request", ".", "cancel", "(", ")", ";", "return", "1", ";", "}", "}", "}", "return", "0", ";", "}" ]
Cancel a particular download in progress. Returns 1 if the download Id is found else returns 0. @param downloadId @return int
[ "Cancel", "a", "particular", "download", "in", "progress", ".", "Returns", "1", "if", "the", "download", "Id", "is", "found", "else", "returns", "0", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L196-L207
164,240
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.release
void release() { if (mCurrentRequests != null) { synchronized (mCurrentRequests) { mCurrentRequests.clear(); mCurrentRequests = null; } } if (mDownloadQueue != null) { mDownloadQueue = null; } if (mDownloadDispatchers != null) { stop(); for (int i = 0; i < mDownloadDispatchers.length; i++) { mDownloadDispatchers[i] = null; } mDownloadDispatchers = null; } }
java
void release() { if (mCurrentRequests != null) { synchronized (mCurrentRequests) { mCurrentRequests.clear(); mCurrentRequests = null; } } if (mDownloadQueue != null) { mDownloadQueue = null; } if (mDownloadDispatchers != null) { stop(); for (int i = 0; i < mDownloadDispatchers.length; i++) { mDownloadDispatchers[i] = null; } mDownloadDispatchers = null; } }
[ "void", "release", "(", ")", "{", "if", "(", "mCurrentRequests", "!=", "null", ")", "{", "synchronized", "(", "mCurrentRequests", ")", "{", "mCurrentRequests", ".", "clear", "(", ")", ";", "mCurrentRequests", "=", "null", ";", "}", "}", "if", "(", "mDownloadQueue", "!=", "null", ")", "{", "mDownloadQueue", "=", "null", ";", "}", "if", "(", "mDownloadDispatchers", "!=", "null", ")", "{", "stop", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mDownloadDispatchers", ".", "length", ";", "i", "++", ")", "{", "mDownloadDispatchers", "[", "i", "]", "=", "null", ";", "}", "mDownloadDispatchers", "=", "null", ";", "}", "}" ]
Cancels all the pending & running requests and releases all the dispatchers.
[ "Cancels", "all", "the", "pending", "&", "running", "requests", "and", "releases", "all", "the", "dispatchers", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L260-L281
164,241
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.initialize
private void initialize(Handler callbackHandler) { int processors = Runtime.getRuntime().availableProcessors(); mDownloadDispatchers = new DownloadDispatcher[processors]; mDelivery = new CallBackDelivery(callbackHandler); }
java
private void initialize(Handler callbackHandler) { int processors = Runtime.getRuntime().availableProcessors(); mDownloadDispatchers = new DownloadDispatcher[processors]; mDelivery = new CallBackDelivery(callbackHandler); }
[ "private", "void", "initialize", "(", "Handler", "callbackHandler", ")", "{", "int", "processors", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", ";", "mDownloadDispatchers", "=", "new", "DownloadDispatcher", "[", "processors", "]", ";", "mDelivery", "=", "new", "CallBackDelivery", "(", "callbackHandler", ")", ";", "}" ]
Perform construction. @param callbackHandler
[ "Perform", "construction", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L290-L294
164,242
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.initialize
private void initialize(Handler callbackHandler, int threadPoolSize) { mDownloadDispatchers = new DownloadDispatcher[threadPoolSize]; mDelivery = new CallBackDelivery(callbackHandler); }
java
private void initialize(Handler callbackHandler, int threadPoolSize) { mDownloadDispatchers = new DownloadDispatcher[threadPoolSize]; mDelivery = new CallBackDelivery(callbackHandler); }
[ "private", "void", "initialize", "(", "Handler", "callbackHandler", ",", "int", "threadPoolSize", ")", "{", "mDownloadDispatchers", "=", "new", "DownloadDispatcher", "[", "threadPoolSize", "]", ";", "mDelivery", "=", "new", "CallBackDelivery", "(", "callbackHandler", ")", ";", "}" ]
Perform construction with custom thread pool size.
[ "Perform", "construction", "with", "custom", "thread", "pool", "size", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L299-L302
164,243
smanikandan14/ThinDownloadManager
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
DownloadRequestQueue.stop
private void stop() { for (int i = 0; i < mDownloadDispatchers.length; i++) { if (mDownloadDispatchers[i] != null) { mDownloadDispatchers[i].quit(); } } }
java
private void stop() { for (int i = 0; i < mDownloadDispatchers.length; i++) { if (mDownloadDispatchers[i] != null) { mDownloadDispatchers[i].quit(); } } }
[ "private", "void", "stop", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mDownloadDispatchers", ".", "length", ";", "i", "++", ")", "{", "if", "(", "mDownloadDispatchers", "[", "i", "]", "!=", "null", ")", "{", "mDownloadDispatchers", "[", "i", "]", ".", "quit", "(", ")", ";", "}", "}", "}" ]
Stops download dispatchers.
[ "Stops", "download", "dispatchers", "." ]
63c153c918eff0b1c9de384171563d2c70baea5e
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L307-L313
164,244
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/Field.java
Field.getValueAsMap
@SuppressWarnings("unchecked") public Map<String, Field> getValueAsMap() { return (Map<String, Field>) type.convert(getValue(), Type.MAP); }
java
@SuppressWarnings("unchecked") public Map<String, Field> getValueAsMap() { return (Map<String, Field>) type.convert(getValue(), Type.MAP); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Map", "<", "String", ",", "Field", ">", "getValueAsMap", "(", ")", "{", "return", "(", "Map", "<", "String", ",", "Field", ">", ")", "type", ".", "convert", "(", "getValue", "(", ")", ",", "Type", ".", "MAP", ")", ";", "}" ]
Returns the Map value of the field. @return the Map value of the field. It returns a reference of the value both for <code>MAP</code> and <code>LIST_MAP</code>. @throws IllegalArgumentException if the value cannot be converted to Map.
[ "Returns", "the", "Map", "value", "of", "the", "field", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L620-L623
164,245
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/Field.java
Field.getValueAsList
@SuppressWarnings("unchecked") public List<Field> getValueAsList() { return (List<Field>) type.convert(getValue(), Type.LIST); }
java
@SuppressWarnings("unchecked") public List<Field> getValueAsList() { return (List<Field>) type.convert(getValue(), Type.LIST); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "Field", ">", "getValueAsList", "(", ")", "{", "return", "(", "List", "<", "Field", ">", ")", "type", ".", "convert", "(", "getValue", "(", ")", ",", "Type", ".", "LIST", ")", ";", "}" ]
Returns the List value of the field. @return the List value of the field. It returns a reference of the value if the type is <code>LIST</code>, if the type is <code>LIST_MAP</code> it returns a copy of the value. @throws IllegalArgumentException if the value cannot be converted to List.
[ "Returns", "the", "List", "value", "of", "the", "field", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L632-L635
164,246
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/Field.java
Field.getValueAsListMap
@SuppressWarnings("unchecked") public LinkedHashMap<String, Field> getValueAsListMap() { return (LinkedHashMap<String, Field>) type.convert(getValue(), Type.LIST_MAP); }
java
@SuppressWarnings("unchecked") public LinkedHashMap<String, Field> getValueAsListMap() { return (LinkedHashMap<String, Field>) type.convert(getValue(), Type.LIST_MAP); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "LinkedHashMap", "<", "String", ",", "Field", ">", "getValueAsListMap", "(", ")", "{", "return", "(", "LinkedHashMap", "<", "String", ",", "Field", ">", ")", "type", ".", "convert", "(", "getValue", "(", ")", ",", "Type", ".", "LIST_MAP", ")", ";", "}" ]
Returns the ordered Map value of the field. @return the ordered Map value of the field. It returns a reference of the value. @throws IllegalArgumentException if the value cannot be converted to ordered Map.
[ "Returns", "the", "ordered", "Map", "value", "of", "the", "field", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L643-L646
164,247
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/Field.java
Field.getAttributeNames
public Set<String> getAttributeNames() { if (attributes == null) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(attributes.keySet()); } }
java
public Set<String> getAttributeNames() { if (attributes == null) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(attributes.keySet()); } }
[ "public", "Set", "<", "String", ">", "getAttributeNames", "(", ")", "{", "if", "(", "attributes", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "else", "{", "return", "Collections", ".", "unmodifiableSet", "(", "attributes", ".", "keySet", "(", ")", ")", ";", "}", "}" ]
Returns the list of user defined attribute names. @return the list of user defined attribute names, if there are none it returns an empty set.
[ "Returns", "the", "list", "of", "user", "defined", "attribute", "names", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L665-L671
164,248
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/Field.java
Field.getAttributes
public Map<String, String> getAttributes() { if (attributes == null) { return null; } else { return Collections.unmodifiableMap(attributes); } }
java
public Map<String, String> getAttributes() { if (attributes == null) { return null; } else { return Collections.unmodifiableMap(attributes); } }
[ "public", "Map", "<", "String", ",", "String", ">", "getAttributes", "(", ")", "{", "if", "(", "attributes", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "Collections", ".", "unmodifiableMap", "(", "attributes", ")", ";", "}", "}" ]
Get all field attributes in an unmodifiable Map, or null if no attributes have been added @return all field attributes, or <code>NULL</code> if none exist
[ "Get", "all", "field", "attributes", "in", "an", "unmodifiable", "Map", "or", "null", "if", "no", "attributes", "have", "been", "added" ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L735-L741
164,249
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/impl/Utils.java
Utils.formatL
public static Object formatL(final String template, final Object... args) { return new Object() { @Override public String toString() { return format(template, args); } }; }
java
public static Object formatL(final String template, final Object... args) { return new Object() { @Override public String toString() { return format(template, args); } }; }
[ "public", "static", "Object", "formatL", "(", "final", "String", "template", ",", "final", "Object", "...", "args", ")", "{", "return", "new", "Object", "(", ")", "{", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "format", "(", "template", ",", "args", ")", ";", "}", "}", ";", "}" ]
format with lazy-eval
[ "format", "with", "lazy", "-", "eval" ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/impl/Utils.java#L123-L130
164,250
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/base/BaseService.java
BaseService.init
@Override public List<ConfigIssue> init(Service.Context context) { this.context = context; return init(); }
java
@Override public List<ConfigIssue> init(Service.Context context) { this.context = context; return init(); }
[ "@", "Override", "public", "List", "<", "ConfigIssue", ">", "init", "(", "Service", ".", "Context", "context", ")", "{", "this", ".", "context", "=", "context", ";", "return", "init", "(", ")", ";", "}" ]
Initializes the service. Stores the <code>Service.Context</code> in instance variables and calls the {@link #init()} method. @param context Service context. @return The list of configuration issues found during initialization, an empty list if none.
[ "Initializes", "the", "service", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/base/BaseService.java#L37-L41
164,251
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/base/configurablestage/DClusterSourceOffsetCommitter.java
DClusterSourceOffsetCommitter.put
@Override public Object put(List<Map.Entry> batch) throws InterruptedException { if (initializeClusterSource()) { return clusterSource.put(batch); } return null; }
java
@Override public Object put(List<Map.Entry> batch) throws InterruptedException { if (initializeClusterSource()) { return clusterSource.put(batch); } return null; }
[ "@", "Override", "public", "Object", "put", "(", "List", "<", "Map", ".", "Entry", ">", "batch", ")", "throws", "InterruptedException", "{", "if", "(", "initializeClusterSource", "(", ")", ")", "{", "return", "clusterSource", ".", "put", "(", "batch", ")", ";", "}", "return", "null", ";", "}" ]
Writes batch of data to the source @param batch @throws InterruptedException
[ "Writes", "batch", "of", "data", "to", "the", "source" ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/base/configurablestage/DClusterSourceOffsetCommitter.java#L69-L75
164,252
streamsets/datacollector-api
src/main/java/com/streamsets/pipeline/api/el/ELEval.java
ELEval.eval
public <T> T eval(ELVars vars, String el, Class<T> returnType) throws ELEvalException { Utils.checkNotNull(vars, "vars"); Utils.checkNotNull(el, "expression"); Utils.checkNotNull(returnType, "returnType"); VARIABLES_IN_SCOPE_TL.set(vars); try { return evaluate(vars, el, returnType); } finally { VARIABLES_IN_SCOPE_TL.set(null); } }
java
public <T> T eval(ELVars vars, String el, Class<T> returnType) throws ELEvalException { Utils.checkNotNull(vars, "vars"); Utils.checkNotNull(el, "expression"); Utils.checkNotNull(returnType, "returnType"); VARIABLES_IN_SCOPE_TL.set(vars); try { return evaluate(vars, el, returnType); } finally { VARIABLES_IN_SCOPE_TL.set(null); } }
[ "public", "<", "T", ">", "T", "eval", "(", "ELVars", "vars", ",", "String", "el", ",", "Class", "<", "T", ">", "returnType", ")", "throws", "ELEvalException", "{", "Utils", ".", "checkNotNull", "(", "vars", ",", "\"vars\"", ")", ";", "Utils", ".", "checkNotNull", "(", "el", ",", "\"expression\"", ")", ";", "Utils", ".", "checkNotNull", "(", "returnType", ",", "\"returnType\"", ")", ";", "VARIABLES_IN_SCOPE_TL", ".", "set", "(", "vars", ")", ";", "try", "{", "return", "evaluate", "(", "vars", ",", "el", ",", "returnType", ")", ";", "}", "finally", "{", "VARIABLES_IN_SCOPE_TL", ".", "set", "(", "null", ")", ";", "}", "}" ]
Evaluates an EL. @param vars the variables to be available for the evaluation. @param el the EL string to evaluate. @param returnType the class the EL evaluates to. @return the evaluated EL as an instance of the specified return type. @throws ELEvalException if the EL could not be evaluated.
[ "Evaluates", "an", "EL", "." ]
ac832a97bea2fcef11f50fac6746e85019adad58
https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/el/ELEval.java#L67-L77
164,253
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java
CTInboxMessageContent.getLinkCopyText
public String getLinkCopyText(JSONObject jsonObject){ if(jsonObject == null) return ""; try { JSONObject copyObject = jsonObject.has("copyText") ? jsonObject.getJSONObject("copyText") : null; if(copyObject != null){ return copyObject.has("text") ? copyObject.getString("text") : ""; }else{ return ""; } } catch (JSONException e) { Logger.v("Unable to get Link Text with JSON - "+e.getLocalizedMessage()); return ""; } }
java
public String getLinkCopyText(JSONObject jsonObject){ if(jsonObject == null) return ""; try { JSONObject copyObject = jsonObject.has("copyText") ? jsonObject.getJSONObject("copyText") : null; if(copyObject != null){ return copyObject.has("text") ? copyObject.getString("text") : ""; }else{ return ""; } } catch (JSONException e) { Logger.v("Unable to get Link Text with JSON - "+e.getLocalizedMessage()); return ""; } }
[ "public", "String", "getLinkCopyText", "(", "JSONObject", "jsonObject", ")", "{", "if", "(", "jsonObject", "==", "null", ")", "return", "\"\"", ";", "try", "{", "JSONObject", "copyObject", "=", "jsonObject", ".", "has", "(", "\"copyText\"", ")", "?", "jsonObject", ".", "getJSONObject", "(", "\"copyText\"", ")", ":", "null", ";", "if", "(", "copyObject", "!=", "null", ")", "{", "return", "copyObject", ".", "has", "(", "\"text\"", ")", "?", "copyObject", ".", "getString", "(", "\"text\"", ")", ":", "\"\"", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Logger", ".", "v", "(", "\"Unable to get Link Text with JSON - \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "return", "\"\"", ";", "}", "}" ]
Returns the text for the JSONObject of Link provided The JSONObject of Link provided should be of the type "copy" @param jsonObject of Link @return String
[ "Returns", "the", "text", "for", "the", "JSONObject", "of", "Link", "provided", "The", "JSONObject", "of", "Link", "provided", "should", "be", "of", "the", "type", "copy" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L279-L292
164,254
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java
CTInboxMessageContent.getLinkUrl
public String getLinkUrl(JSONObject jsonObject){ if(jsonObject == null) return null; try { JSONObject urlObject = jsonObject.has("url") ? jsonObject.getJSONObject("url") : null; if(urlObject == null) return null; JSONObject androidObject = urlObject.has("android") ? urlObject.getJSONObject("android") : null; if(androidObject != null){ return androidObject.has("text") ? androidObject.getString("text") : ""; }else{ return ""; } } catch (JSONException e) { Logger.v("Unable to get Link URL with JSON - "+e.getLocalizedMessage()); return null; } }
java
public String getLinkUrl(JSONObject jsonObject){ if(jsonObject == null) return null; try { JSONObject urlObject = jsonObject.has("url") ? jsonObject.getJSONObject("url") : null; if(urlObject == null) return null; JSONObject androidObject = urlObject.has("android") ? urlObject.getJSONObject("android") : null; if(androidObject != null){ return androidObject.has("text") ? androidObject.getString("text") : ""; }else{ return ""; } } catch (JSONException e) { Logger.v("Unable to get Link URL with JSON - "+e.getLocalizedMessage()); return null; } }
[ "public", "String", "getLinkUrl", "(", "JSONObject", "jsonObject", ")", "{", "if", "(", "jsonObject", "==", "null", ")", "return", "null", ";", "try", "{", "JSONObject", "urlObject", "=", "jsonObject", ".", "has", "(", "\"url\"", ")", "?", "jsonObject", ".", "getJSONObject", "(", "\"url\"", ")", ":", "null", ";", "if", "(", "urlObject", "==", "null", ")", "return", "null", ";", "JSONObject", "androidObject", "=", "urlObject", ".", "has", "(", "\"android\"", ")", "?", "urlObject", ".", "getJSONObject", "(", "\"android\"", ")", ":", "null", ";", "if", "(", "androidObject", "!=", "null", ")", "{", "return", "androidObject", ".", "has", "(", "\"text\"", ")", "?", "androidObject", ".", "getString", "(", "\"text\"", ")", ":", "\"\"", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Logger", ".", "v", "(", "\"Unable to get Link URL with JSON - \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "return", "null", ";", "}", "}" ]
Returns the text for the JSONObject of Link provided The JSONObject of Link provided should be of the type "url" @param jsonObject of Link @return String
[ "Returns", "the", "text", "for", "the", "JSONObject", "of", "Link", "provided", "The", "JSONObject", "of", "Link", "provided", "should", "be", "of", "the", "type", "url" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L300-L315
164,255
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java
CTInboxMessageContent.getLinkColor
public String getLinkColor(JSONObject jsonObject){ if(jsonObject == null) return null; try { return jsonObject.has("color") ? jsonObject.getString("color") : ""; } catch (JSONException e) { Logger.v("Unable to get Link Text Color with JSON - "+e.getLocalizedMessage()); return null; } }
java
public String getLinkColor(JSONObject jsonObject){ if(jsonObject == null) return null; try { return jsonObject.has("color") ? jsonObject.getString("color") : ""; } catch (JSONException e) { Logger.v("Unable to get Link Text Color with JSON - "+e.getLocalizedMessage()); return null; } }
[ "public", "String", "getLinkColor", "(", "JSONObject", "jsonObject", ")", "{", "if", "(", "jsonObject", "==", "null", ")", "return", "null", ";", "try", "{", "return", "jsonObject", ".", "has", "(", "\"color\"", ")", "?", "jsonObject", ".", "getString", "(", "\"color\"", ")", ":", "\"\"", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Logger", ".", "v", "(", "\"Unable to get Link Text Color with JSON - \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "return", "null", ";", "}", "}" ]
Returns the text color for the JSONObject of Link provided @param jsonObject of Link @return String
[ "Returns", "the", "text", "color", "for", "the", "JSONObject", "of", "Link", "provided" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L322-L330
164,256
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.onActivityCreated
static void onActivityCreated(Activity activity) { // make sure we have at least the default instance created here. if (instances == null) { CleverTapAPI.createInstanceIfAvailable(activity, null); } if (instances == null) { Logger.v("Instances is null in onActivityCreated!"); return; } boolean alreadyProcessedByCleverTap = false; Bundle notification = null; Uri deepLink = null; String _accountId = null; // check for launch deep link try { Intent intent = activity.getIntent(); deepLink = intent.getData(); if (deepLink != null) { Bundle queryArgs = UriHelper.getAllKeyValuePairs(deepLink.toString(), true); _accountId = queryArgs.getString(Constants.WZRK_ACCT_ID_KEY); } } catch (Throwable t) { // Ignore } // check for launch via notification click try { notification = activity.getIntent().getExtras(); if (notification != null && !notification.isEmpty()) { try { alreadyProcessedByCleverTap = (notification.containsKey(Constants.WZRK_FROM_KEY) && Constants.WZRK_FROM.equals(notification.get(Constants.WZRK_FROM_KEY))); if (alreadyProcessedByCleverTap){ Logger.v("ActivityLifecycleCallback: Notification Clicked already processed for "+ notification.toString() +", dropping duplicate."); } if (notification.containsKey(Constants.WZRK_ACCT_ID_KEY)) { _accountId = (String) notification.get(Constants.WZRK_ACCT_ID_KEY); } } catch (Throwable t) { // no-op } } } catch (Throwable t) { // Ignore } if (alreadyProcessedByCleverTap && deepLink == null) return; for (String accountId: CleverTapAPI.instances.keySet()) { CleverTapAPI instance = CleverTapAPI.instances.get(accountId); boolean shouldProcess = false; if (instance != null) { shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId); } if (shouldProcess) { if (notification != null && !notification.isEmpty() && notification.containsKey(Constants.NOTIFICATION_TAG)) { instance.pushNotificationClickedEvent(notification); } if (deepLink != null) { try { instance.pushDeepLink(deepLink); } catch (Throwable t) { // no-op } } break; } } }
java
static void onActivityCreated(Activity activity) { // make sure we have at least the default instance created here. if (instances == null) { CleverTapAPI.createInstanceIfAvailable(activity, null); } if (instances == null) { Logger.v("Instances is null in onActivityCreated!"); return; } boolean alreadyProcessedByCleverTap = false; Bundle notification = null; Uri deepLink = null; String _accountId = null; // check for launch deep link try { Intent intent = activity.getIntent(); deepLink = intent.getData(); if (deepLink != null) { Bundle queryArgs = UriHelper.getAllKeyValuePairs(deepLink.toString(), true); _accountId = queryArgs.getString(Constants.WZRK_ACCT_ID_KEY); } } catch (Throwable t) { // Ignore } // check for launch via notification click try { notification = activity.getIntent().getExtras(); if (notification != null && !notification.isEmpty()) { try { alreadyProcessedByCleverTap = (notification.containsKey(Constants.WZRK_FROM_KEY) && Constants.WZRK_FROM.equals(notification.get(Constants.WZRK_FROM_KEY))); if (alreadyProcessedByCleverTap){ Logger.v("ActivityLifecycleCallback: Notification Clicked already processed for "+ notification.toString() +", dropping duplicate."); } if (notification.containsKey(Constants.WZRK_ACCT_ID_KEY)) { _accountId = (String) notification.get(Constants.WZRK_ACCT_ID_KEY); } } catch (Throwable t) { // no-op } } } catch (Throwable t) { // Ignore } if (alreadyProcessedByCleverTap && deepLink == null) return; for (String accountId: CleverTapAPI.instances.keySet()) { CleverTapAPI instance = CleverTapAPI.instances.get(accountId); boolean shouldProcess = false; if (instance != null) { shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId); } if (shouldProcess) { if (notification != null && !notification.isEmpty() && notification.containsKey(Constants.NOTIFICATION_TAG)) { instance.pushNotificationClickedEvent(notification); } if (deepLink != null) { try { instance.pushDeepLink(deepLink); } catch (Throwable t) { // no-op } } break; } } }
[ "static", "void", "onActivityCreated", "(", "Activity", "activity", ")", "{", "// make sure we have at least the default instance created here.", "if", "(", "instances", "==", "null", ")", "{", "CleverTapAPI", ".", "createInstanceIfAvailable", "(", "activity", ",", "null", ")", ";", "}", "if", "(", "instances", "==", "null", ")", "{", "Logger", ".", "v", "(", "\"Instances is null in onActivityCreated!\"", ")", ";", "return", ";", "}", "boolean", "alreadyProcessedByCleverTap", "=", "false", ";", "Bundle", "notification", "=", "null", ";", "Uri", "deepLink", "=", "null", ";", "String", "_accountId", "=", "null", ";", "// check for launch deep link", "try", "{", "Intent", "intent", "=", "activity", ".", "getIntent", "(", ")", ";", "deepLink", "=", "intent", ".", "getData", "(", ")", ";", "if", "(", "deepLink", "!=", "null", ")", "{", "Bundle", "queryArgs", "=", "UriHelper", ".", "getAllKeyValuePairs", "(", "deepLink", ".", "toString", "(", ")", ",", "true", ")", ";", "_accountId", "=", "queryArgs", ".", "getString", "(", "Constants", ".", "WZRK_ACCT_ID_KEY", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "// Ignore", "}", "// check for launch via notification click", "try", "{", "notification", "=", "activity", ".", "getIntent", "(", ")", ".", "getExtras", "(", ")", ";", "if", "(", "notification", "!=", "null", "&&", "!", "notification", ".", "isEmpty", "(", ")", ")", "{", "try", "{", "alreadyProcessedByCleverTap", "=", "(", "notification", ".", "containsKey", "(", "Constants", ".", "WZRK_FROM_KEY", ")", "&&", "Constants", ".", "WZRK_FROM", ".", "equals", "(", "notification", ".", "get", "(", "Constants", ".", "WZRK_FROM_KEY", ")", ")", ")", ";", "if", "(", "alreadyProcessedByCleverTap", ")", "{", "Logger", ".", "v", "(", "\"ActivityLifecycleCallback: Notification Clicked already processed for \"", "+", "notification", ".", "toString", "(", ")", "+", "\", dropping duplicate.\"", ")", ";", "}", "if", "(", "notification", ".", "containsKey", "(", "Constants", ".", "WZRK_ACCT_ID_KEY", ")", ")", "{", "_accountId", "=", "(", "String", ")", "notification", ".", "get", "(", "Constants", ".", "WZRK_ACCT_ID_KEY", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "// no-op", "}", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "// Ignore", "}", "if", "(", "alreadyProcessedByCleverTap", "&&", "deepLink", "==", "null", ")", "return", ";", "for", "(", "String", "accountId", ":", "CleverTapAPI", ".", "instances", ".", "keySet", "(", ")", ")", "{", "CleverTapAPI", "instance", "=", "CleverTapAPI", ".", "instances", ".", "get", "(", "accountId", ")", ";", "boolean", "shouldProcess", "=", "false", ";", "if", "(", "instance", "!=", "null", ")", "{", "shouldProcess", "=", "(", "_accountId", "==", "null", "&&", "instance", ".", "config", ".", "isDefaultInstance", "(", ")", ")", "||", "instance", ".", "getAccountId", "(", ")", ".", "equals", "(", "_accountId", ")", ";", "}", "if", "(", "shouldProcess", ")", "{", "if", "(", "notification", "!=", "null", "&&", "!", "notification", ".", "isEmpty", "(", ")", "&&", "notification", ".", "containsKey", "(", "Constants", ".", "NOTIFICATION_TAG", ")", ")", "{", "instance", ".", "pushNotificationClickedEvent", "(", "notification", ")", ";", "}", "if", "(", "deepLink", "!=", "null", ")", "{", "try", "{", "instance", ".", "pushDeepLink", "(", "deepLink", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// no-op", "}", "}", "break", ";", "}", "}", "}" ]
static lifecycle callbacks
[ "static", "lifecycle", "callbacks" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L307-L380
164,257
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.handleNotificationClicked
static void handleNotificationClicked(Context context,Bundle notification) { if (notification == null) return; String _accountId = null; try { _accountId = notification.getString(Constants.WZRK_ACCT_ID_KEY); } catch (Throwable t) { // no-op } if (instances == null) { CleverTapAPI instance = createInstanceIfAvailable(context, _accountId); if (instance != null) { instance.pushNotificationClickedEvent(notification); } return; } for (String accountId: instances.keySet()) { CleverTapAPI instance = CleverTapAPI.instances.get(accountId); boolean shouldProcess = false; if (instance != null) { shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId); } if (shouldProcess) { instance.pushNotificationClickedEvent(notification); break; } } }
java
static void handleNotificationClicked(Context context,Bundle notification) { if (notification == null) return; String _accountId = null; try { _accountId = notification.getString(Constants.WZRK_ACCT_ID_KEY); } catch (Throwable t) { // no-op } if (instances == null) { CleverTapAPI instance = createInstanceIfAvailable(context, _accountId); if (instance != null) { instance.pushNotificationClickedEvent(notification); } return; } for (String accountId: instances.keySet()) { CleverTapAPI instance = CleverTapAPI.instances.get(accountId); boolean shouldProcess = false; if (instance != null) { shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId); } if (shouldProcess) { instance.pushNotificationClickedEvent(notification); break; } } }
[ "static", "void", "handleNotificationClicked", "(", "Context", "context", ",", "Bundle", "notification", ")", "{", "if", "(", "notification", "==", "null", ")", "return", ";", "String", "_accountId", "=", "null", ";", "try", "{", "_accountId", "=", "notification", ".", "getString", "(", "Constants", ".", "WZRK_ACCT_ID_KEY", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// no-op", "}", "if", "(", "instances", "==", "null", ")", "{", "CleverTapAPI", "instance", "=", "createInstanceIfAvailable", "(", "context", ",", "_accountId", ")", ";", "if", "(", "instance", "!=", "null", ")", "{", "instance", ".", "pushNotificationClickedEvent", "(", "notification", ")", ";", "}", "return", ";", "}", "for", "(", "String", "accountId", ":", "instances", ".", "keySet", "(", ")", ")", "{", "CleverTapAPI", "instance", "=", "CleverTapAPI", ".", "instances", ".", "get", "(", "accountId", ")", ";", "boolean", "shouldProcess", "=", "false", ";", "if", "(", "instance", "!=", "null", ")", "{", "shouldProcess", "=", "(", "_accountId", "==", "null", "&&", "instance", ".", "config", ".", "isDefaultInstance", "(", ")", ")", "||", "instance", ".", "getAccountId", "(", ")", ".", "equals", "(", "_accountId", ")", ";", "}", "if", "(", "shouldProcess", ")", "{", "instance", ".", "pushNotificationClickedEvent", "(", "notification", ")", ";", "break", ";", "}", "}", "}" ]
other static handlers
[ "other", "static", "handlers" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L435-L464
164,258
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getInstance
public static @Nullable CleverTapAPI getInstance(Context context) throws CleverTapMetaDataNotFoundException, CleverTapPermissionsNotSatisfied { // For Google Play Store/Android Studio tracking sdkVersion = BuildConfig.SDK_VERSION_STRING; return getDefaultInstance(context); }
java
public static @Nullable CleverTapAPI getInstance(Context context) throws CleverTapMetaDataNotFoundException, CleverTapPermissionsNotSatisfied { // For Google Play Store/Android Studio tracking sdkVersion = BuildConfig.SDK_VERSION_STRING; return getDefaultInstance(context); }
[ "public", "static", "@", "Nullable", "CleverTapAPI", "getInstance", "(", "Context", "context", ")", "throws", "CleverTapMetaDataNotFoundException", ",", "CleverTapPermissionsNotSatisfied", "{", "// For Google Play Store/Android Studio tracking", "sdkVersion", "=", "BuildConfig", ".", "SDK_VERSION_STRING", ";", "return", "getDefaultInstance", "(", "context", ")", ";", "}" ]
Returns an instance of the CleverTap SDK. @param context The Android context @return The {@link CleverTapAPI} object @deprecated use {@link CleverTapAPI#getDefaultInstance(Context context)}
[ "Returns", "an", "instance", "of", "the", "CleverTap", "SDK", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L473-L477
164,259
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getDefaultInstance
@SuppressWarnings("WeakerAccess") public static @Nullable CleverTapAPI getDefaultInstance(Context context) { // For Google Play Store/Android Studio tracking sdkVersion = BuildConfig.SDK_VERSION_STRING; if (defaultConfig == null) { ManifestInfo manifest = ManifestInfo.getInstance(context); String accountId = manifest.getAccountId(); String accountToken = manifest.getAcountToken(); String accountRegion = manifest.getAccountRegion(); if(accountId == null || accountToken == null) { Logger.i("Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance"); return null; } if (accountRegion == null) { Logger.i("Account Region not specified in the AndroidManifest - using default region"); } defaultConfig = CleverTapInstanceConfig.createDefaultInstance(context, accountId, accountToken, accountRegion); defaultConfig.setDebugLevel(getDebugLevel()); } return instanceWithConfig(context, defaultConfig); }
java
@SuppressWarnings("WeakerAccess") public static @Nullable CleverTapAPI getDefaultInstance(Context context) { // For Google Play Store/Android Studio tracking sdkVersion = BuildConfig.SDK_VERSION_STRING; if (defaultConfig == null) { ManifestInfo manifest = ManifestInfo.getInstance(context); String accountId = manifest.getAccountId(); String accountToken = manifest.getAcountToken(); String accountRegion = manifest.getAccountRegion(); if(accountId == null || accountToken == null) { Logger.i("Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance"); return null; } if (accountRegion == null) { Logger.i("Account Region not specified in the AndroidManifest - using default region"); } defaultConfig = CleverTapInstanceConfig.createDefaultInstance(context, accountId, accountToken, accountRegion); defaultConfig.setDebugLevel(getDebugLevel()); } return instanceWithConfig(context, defaultConfig); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "public", "static", "@", "Nullable", "CleverTapAPI", "getDefaultInstance", "(", "Context", "context", ")", "{", "// For Google Play Store/Android Studio tracking", "sdkVersion", "=", "BuildConfig", ".", "SDK_VERSION_STRING", ";", "if", "(", "defaultConfig", "==", "null", ")", "{", "ManifestInfo", "manifest", "=", "ManifestInfo", ".", "getInstance", "(", "context", ")", ";", "String", "accountId", "=", "manifest", ".", "getAccountId", "(", ")", ";", "String", "accountToken", "=", "manifest", ".", "getAcountToken", "(", ")", ";", "String", "accountRegion", "=", "manifest", ".", "getAccountRegion", "(", ")", ";", "if", "(", "accountId", "==", "null", "||", "accountToken", "==", "null", ")", "{", "Logger", ".", "i", "(", "\"Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance\"", ")", ";", "return", "null", ";", "}", "if", "(", "accountRegion", "==", "null", ")", "{", "Logger", ".", "i", "(", "\"Account Region not specified in the AndroidManifest - using default region\"", ")", ";", "}", "defaultConfig", "=", "CleverTapInstanceConfig", ".", "createDefaultInstance", "(", "context", ",", "accountId", ",", "accountToken", ",", "accountRegion", ")", ";", "defaultConfig", ".", "setDebugLevel", "(", "getDebugLevel", "(", ")", ")", ";", "}", "return", "instanceWithConfig", "(", "context", ",", "defaultConfig", ")", ";", "}" ]
Returns the default shared instance of the CleverTap SDK. @param context The Android context @return The {@link CleverTapAPI} object
[ "Returns", "the", "default", "shared", "instance", "of", "the", "CleverTap", "SDK", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L485-L505
164,260
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.destroySession
private void destroySession() { currentSessionId = 0; setAppLaunchPushed(false); getConfigLogger().verbose(getAccountId(),"Session destroyed; Session ID is now 0"); clearSource(); clearMedium(); clearCampaign(); clearWzrkParams(); }
java
private void destroySession() { currentSessionId = 0; setAppLaunchPushed(false); getConfigLogger().verbose(getAccountId(),"Session destroyed; Session ID is now 0"); clearSource(); clearMedium(); clearCampaign(); clearWzrkParams(); }
[ "private", "void", "destroySession", "(", ")", "{", "currentSessionId", "=", "0", ";", "setAppLaunchPushed", "(", "false", ")", ";", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Session destroyed; Session ID is now 0\"", ")", ";", "clearSource", "(", ")", ";", "clearMedium", "(", ")", ";", "clearCampaign", "(", ")", ";", "clearWzrkParams", "(", ")", ";", "}" ]
Destroys the current session
[ "Destroys", "the", "current", "session" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L562-L570
164,261
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.FCMGetFreshToken
private String FCMGetFreshToken(final String senderID) { String token = null; try { if(senderID != null){ getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token with Sender Id - "+senderID); token = FirebaseInstanceId.getInstance().getToken(senderID, FirebaseMessaging.INSTANCE_ID_SCOPE); }else { getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token"); token = FirebaseInstanceId.getInstance().getToken(); } getConfigLogger().info(getAccountId(),"FCM token: "+token); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "FcmManager: Error requesting FCM token", t); } return token; }
java
private String FCMGetFreshToken(final String senderID) { String token = null; try { if(senderID != null){ getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token with Sender Id - "+senderID); token = FirebaseInstanceId.getInstance().getToken(senderID, FirebaseMessaging.INSTANCE_ID_SCOPE); }else { getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token"); token = FirebaseInstanceId.getInstance().getToken(); } getConfigLogger().info(getAccountId(),"FCM token: "+token); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "FcmManager: Error requesting FCM token", t); } return token; }
[ "private", "String", "FCMGetFreshToken", "(", "final", "String", "senderID", ")", "{", "String", "token", "=", "null", ";", "try", "{", "if", "(", "senderID", "!=", "null", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"FcmManager: Requesting a FCM token with Sender Id - \"", "+", "senderID", ")", ";", "token", "=", "FirebaseInstanceId", ".", "getInstance", "(", ")", ".", "getToken", "(", "senderID", ",", "FirebaseMessaging", ".", "INSTANCE_ID_SCOPE", ")", ";", "}", "else", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"FcmManager: Requesting a FCM token\"", ")", ";", "token", "=", "FirebaseInstanceId", ".", "getInstance", "(", ")", ".", "getToken", "(", ")", ";", "}", "getConfigLogger", "(", ")", ".", "info", "(", "getAccountId", "(", ")", ",", "\"FCM token: \"", "+", "token", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"FcmManager: Error requesting FCM token\"", ",", "t", ")", ";", "}", "return", "token", ";", "}" ]
request token from FCM
[ "request", "token", "from", "FCM" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L789-L804
164,262
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.GCMGetFreshToken
private String GCMGetFreshToken(final String senderID) { getConfigLogger().verbose(getAccountId(), "GcmManager: Requesting a GCM token for Sender ID - " + senderID); String token = null; try { token = InstanceID.getInstance(context) .getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); getConfigLogger().info(getAccountId(), "GCM token : " + token); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "GcmManager: Error requesting GCM token", t); } return token; }
java
private String GCMGetFreshToken(final String senderID) { getConfigLogger().verbose(getAccountId(), "GcmManager: Requesting a GCM token for Sender ID - " + senderID); String token = null; try { token = InstanceID.getInstance(context) .getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); getConfigLogger().info(getAccountId(), "GCM token : " + token); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "GcmManager: Error requesting GCM token", t); } return token; }
[ "private", "String", "GCMGetFreshToken", "(", "final", "String", "senderID", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"GcmManager: Requesting a GCM token for Sender ID - \"", "+", "senderID", ")", ";", "String", "token", "=", "null", ";", "try", "{", "token", "=", "InstanceID", ".", "getInstance", "(", "context", ")", ".", "getToken", "(", "senderID", ",", "GoogleCloudMessaging", ".", "INSTANCE_ID_SCOPE", ",", "null", ")", ";", "getConfigLogger", "(", ")", ".", "info", "(", "getAccountId", "(", ")", ",", "\"GCM token : \"", "+", "token", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"GcmManager: Error requesting GCM token\"", ",", "t", ")", ";", "}", "return", "token", ";", "}" ]
request token from GCM
[ "request", "token", "from", "GCM" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L810-L821
164,263
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.setOffline
@SuppressWarnings({"unused", "WeakerAccess"}) public void setOffline(boolean value){ offline = value; if (offline) { getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to offline, won't send events queue"); } else { getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to online, sending events queue"); flush(); } }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void setOffline(boolean value){ offline = value; if (offline) { getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to offline, won't send events queue"); } else { getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to online, sending events queue"); flush(); } }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "setOffline", "(", "boolean", "value", ")", "{", "offline", "=", "value", ";", "if", "(", "offline", ")", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"CleverTap Instance has been set to offline, won't send events queue\"", ")", ";", "}", "else", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"CleverTap Instance has been set to online, sending events queue\"", ")", ";", "flush", "(", ")", ";", "}", "}" ]
If you want to stop recorded events from being sent to the server, use this method to set the SDK instance to offline. Once offline, events will be recorded and queued locally but will not be sent to the server until offline is disabled. Calling this method again with offline set to false will allow events to be sent to server and the SDK instance will immediately attempt to send events that have been queued while offline. @param value boolean, true sets the sdk offline, false sets the sdk back online
[ "If", "you", "want", "to", "stop", "recorded", "events", "from", "being", "sent", "to", "the", "server", "use", "this", "method", "to", "set", "the", "SDK", "instance", "to", "offline", ".", "Once", "offline", "events", "will", "be", "recorded", "and", "queued", "locally", "but", "will", "not", "be", "sent", "to", "the", "server", "until", "offline", "is", "disabled", ".", "Calling", "this", "method", "again", "with", "offline", "set", "to", "false", "will", "allow", "events", "to", "be", "sent", "to", "server", "and", "the", "SDK", "instance", "will", "immediately", "attempt", "to", "send", "events", "that", "have", "been", "queued", "while", "offline", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1060-L1069
164,264
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.enableDeviceNetworkInfoReporting
@SuppressWarnings({"unused", "WeakerAccess"}) public void enableDeviceNetworkInfoReporting(boolean value){ enableNetworkInfoReporting = value; StorageHelper.putBoolean(context,storageKeyWithSuffix(Constants.NETWORK_INFO),enableNetworkInfoReporting); getConfigLogger().verbose(getAccountId(), "Device Network Information reporting set to " + enableNetworkInfoReporting); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void enableDeviceNetworkInfoReporting(boolean value){ enableNetworkInfoReporting = value; StorageHelper.putBoolean(context,storageKeyWithSuffix(Constants.NETWORK_INFO),enableNetworkInfoReporting); getConfigLogger().verbose(getAccountId(), "Device Network Information reporting set to " + enableNetworkInfoReporting); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "enableDeviceNetworkInfoReporting", "(", "boolean", "value", ")", "{", "enableNetworkInfoReporting", "=", "value", ";", "StorageHelper", ".", "putBoolean", "(", "context", ",", "storageKeyWithSuffix", "(", "Constants", ".", "NETWORK_INFO", ")", ",", "enableNetworkInfoReporting", ")", ";", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Device Network Information reporting set to \"", "+", "enableNetworkInfoReporting", ")", ";", "}" ]
Use this method to enable device network-related information tracking, including IP address. This reporting is disabled by default. To re-disable tracking call this method with enabled set to false. @param value boolean Whether device network info reporting should be enabled/disabled.
[ "Use", "this", "method", "to", "enable", "device", "network", "-", "related", "information", "tracking", "including", "IP", "address", ".", "This", "reporting", "is", "disabled", "by", "default", ".", "To", "re", "-", "disable", "tracking", "call", "this", "method", "with", "enabled", "set", "to", "false", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1082-L1087
164,265
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getDevicePushToken
@SuppressWarnings("unused") public String getDevicePushToken(final PushType type) { switch (type) { case GCM: return getCachedGCMToken(); case FCM: return getCachedFCMToken(); default: return null; } }
java
@SuppressWarnings("unused") public String getDevicePushToken(final PushType type) { switch (type) { case GCM: return getCachedGCMToken(); case FCM: return getCachedFCMToken(); default: return null; } }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "String", "getDevicePushToken", "(", "final", "PushType", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "GCM", ":", "return", "getCachedGCMToken", "(", ")", ";", "case", "FCM", ":", "return", "getCachedFCMToken", "(", ")", ";", "default", ":", "return", "null", ";", "}", "}" ]
Returns the device push token or null @param type com.clevertap.android.sdk.PushType (FCM or GCM) @return String device token or null NOTE: on initial install calling getDevicePushToken may return null, as the device token is not yet available Implement CleverTapAPI.DevicePushTokenRefreshListener to get a callback once the token is available
[ "Returns", "the", "device", "push", "token", "or", "null" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1205-L1215
164,266
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.attachMeta
private void attachMeta(final JSONObject o, final Context context) { // Memory consumption try { o.put("mc", Utils.getMemoryConsumption()); } catch (Throwable t) { // Ignore } // Attach the network type try { o.put("nt", Utils.getCurrentNetworkType(context)); } catch (Throwable t) { // Ignore } }
java
private void attachMeta(final JSONObject o, final Context context) { // Memory consumption try { o.put("mc", Utils.getMemoryConsumption()); } catch (Throwable t) { // Ignore } // Attach the network type try { o.put("nt", Utils.getCurrentNetworkType(context)); } catch (Throwable t) { // Ignore } }
[ "private", "void", "attachMeta", "(", "final", "JSONObject", "o", ",", "final", "Context", "context", ")", "{", "// Memory consumption", "try", "{", "o", ".", "put", "(", "\"mc\"", ",", "Utils", ".", "getMemoryConsumption", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// Ignore", "}", "// Attach the network type", "try", "{", "o", ".", "put", "(", "\"nt\"", ",", "Utils", ".", "getCurrentNetworkType", "(", "context", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// Ignore", "}", "}" ]
Attaches meta info about the current state of the device to an event. Typically, this meta is added only to the ping event.
[ "Attaches", "meta", "info", "about", "the", "current", "state", "of", "the", "device", "to", "an", "event", ".", "Typically", "this", "meta", "is", "added", "only", "to", "the", "ping", "event", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1490-L1504
164,267
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.recordScreen
@SuppressWarnings({"unused", "WeakerAccess"}) public void recordScreen(String screenName){ if(screenName == null || (!currentScreenName.isEmpty() && currentScreenName.equals(screenName))) return; getConfigLogger().debug(getAccountId(), "Screen changed to " + screenName); currentScreenName = screenName; recordPageEventWithExtras(null); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void recordScreen(String screenName){ if(screenName == null || (!currentScreenName.isEmpty() && currentScreenName.equals(screenName))) return; getConfigLogger().debug(getAccountId(), "Screen changed to " + screenName); currentScreenName = screenName; recordPageEventWithExtras(null); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "recordScreen", "(", "String", "screenName", ")", "{", "if", "(", "screenName", "==", "null", "||", "(", "!", "currentScreenName", ".", "isEmpty", "(", ")", "&&", "currentScreenName", ".", "equals", "(", "screenName", ")", ")", ")", "return", ";", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Screen changed to \"", "+", "screenName", ")", ";", "currentScreenName", "=", "screenName", ";", "recordPageEventWithExtras", "(", "null", ")", ";", "}" ]
Record a Screen View event @param screenName String, the name of the screen
[ "Record", "a", "Screen", "View", "event" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1510-L1516
164,268
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.clearQueues
private void clearQueues(final Context context) { synchronized (eventLock) { DBAdapter adapter = loadDBAdapter(context); DBAdapter.Table tableName = DBAdapter.Table.EVENTS; adapter.removeEvents(tableName); tableName = DBAdapter.Table.PROFILE_EVENTS; adapter.removeEvents(tableName); clearUserContext(context); } }
java
private void clearQueues(final Context context) { synchronized (eventLock) { DBAdapter adapter = loadDBAdapter(context); DBAdapter.Table tableName = DBAdapter.Table.EVENTS; adapter.removeEvents(tableName); tableName = DBAdapter.Table.PROFILE_EVENTS; adapter.removeEvents(tableName); clearUserContext(context); } }
[ "private", "void", "clearQueues", "(", "final", "Context", "context", ")", "{", "synchronized", "(", "eventLock", ")", "{", "DBAdapter", "adapter", "=", "loadDBAdapter", "(", "context", ")", ";", "DBAdapter", ".", "Table", "tableName", "=", "DBAdapter", ".", "Table", ".", "EVENTS", ";", "adapter", ".", "removeEvents", "(", "tableName", ")", ";", "tableName", "=", "DBAdapter", ".", "Table", ".", "PROFILE_EVENTS", ";", "adapter", ".", "removeEvents", "(", "tableName", ")", ";", "clearUserContext", "(", "context", ")", ";", "}", "}" ]
Only call async
[ "Only", "call", "async" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1874-L1886
164,269
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.updateCursorForDBObject
private QueueCursor updateCursorForDBObject(JSONObject dbObject, QueueCursor cursor) { if (dbObject == null) return cursor; Iterator<String> keys = dbObject.keys(); if (keys.hasNext()) { String key = keys.next(); cursor.setLastId(key); try { cursor.setData(dbObject.getJSONArray(key)); } catch (JSONException e) { cursor.setLastId(null); cursor.setData(null); } } return cursor; }
java
private QueueCursor updateCursorForDBObject(JSONObject dbObject, QueueCursor cursor) { if (dbObject == null) return cursor; Iterator<String> keys = dbObject.keys(); if (keys.hasNext()) { String key = keys.next(); cursor.setLastId(key); try { cursor.setData(dbObject.getJSONArray(key)); } catch (JSONException e) { cursor.setLastId(null); cursor.setData(null); } } return cursor; }
[ "private", "QueueCursor", "updateCursorForDBObject", "(", "JSONObject", "dbObject", ",", "QueueCursor", "cursor", ")", "{", "if", "(", "dbObject", "==", "null", ")", "return", "cursor", ";", "Iterator", "<", "String", ">", "keys", "=", "dbObject", ".", "keys", "(", ")", ";", "if", "(", "keys", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "keys", ".", "next", "(", ")", ";", "cursor", ".", "setLastId", "(", "key", ")", ";", "try", "{", "cursor", ".", "setData", "(", "dbObject", ".", "getJSONArray", "(", "key", ")", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "cursor", ".", "setLastId", "(", "null", ")", ";", "cursor", ".", "setData", "(", "null", ")", ";", "}", "}", "return", "cursor", ";", "}" ]
helper extracts the cursor data from the db object
[ "helper", "extracts", "the", "cursor", "data", "from", "the", "db", "object" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1981-L1998
164,270
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getARP
private JSONObject getARP(final Context context) { try { final String nameSpaceKey = getNamespaceARPKey(); if (nameSpaceKey == null) return null; final SharedPreferences prefs = StorageHelper.getPreferences(context, nameSpaceKey); final Map<String, ?> all = prefs.getAll(); final Iterator<? extends Map.Entry<String, ?>> iter = all.entrySet().iterator(); while (iter.hasNext()) { final Map.Entry<String, ?> kv = iter.next(); final Object o = kv.getValue(); if (o instanceof Number && ((Number) o).intValue() == -1) { iter.remove(); } } final JSONObject ret = new JSONObject(all); getConfigLogger().verbose(getAccountId(), "Fetched ARP for namespace key: " + nameSpaceKey + " values: " + all.toString()); return ret; } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "Failed to construct ARP object", t); return null; } }
java
private JSONObject getARP(final Context context) { try { final String nameSpaceKey = getNamespaceARPKey(); if (nameSpaceKey == null) return null; final SharedPreferences prefs = StorageHelper.getPreferences(context, nameSpaceKey); final Map<String, ?> all = prefs.getAll(); final Iterator<? extends Map.Entry<String, ?>> iter = all.entrySet().iterator(); while (iter.hasNext()) { final Map.Entry<String, ?> kv = iter.next(); final Object o = kv.getValue(); if (o instanceof Number && ((Number) o).intValue() == -1) { iter.remove(); } } final JSONObject ret = new JSONObject(all); getConfigLogger().verbose(getAccountId(), "Fetched ARP for namespace key: " + nameSpaceKey + " values: " + all.toString()); return ret; } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "Failed to construct ARP object", t); return null; } }
[ "private", "JSONObject", "getARP", "(", "final", "Context", "context", ")", "{", "try", "{", "final", "String", "nameSpaceKey", "=", "getNamespaceARPKey", "(", ")", ";", "if", "(", "nameSpaceKey", "==", "null", ")", "return", "null", ";", "final", "SharedPreferences", "prefs", "=", "StorageHelper", ".", "getPreferences", "(", "context", ",", "nameSpaceKey", ")", ";", "final", "Map", "<", "String", ",", "?", ">", "all", "=", "prefs", ".", "getAll", "(", ")", ";", "final", "Iterator", "<", "?", "extends", "Map", ".", "Entry", "<", "String", ",", "?", ">", ">", "iter", "=", "all", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "final", "Map", ".", "Entry", "<", "String", ",", "?", ">", "kv", "=", "iter", ".", "next", "(", ")", ";", "final", "Object", "o", "=", "kv", ".", "getValue", "(", ")", ";", "if", "(", "o", "instanceof", "Number", "&&", "(", "(", "Number", ")", "o", ")", ".", "intValue", "(", ")", "==", "-", "1", ")", "{", "iter", ".", "remove", "(", ")", ";", "}", "}", "final", "JSONObject", "ret", "=", "new", "JSONObject", "(", "all", ")", ";", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Fetched ARP for namespace key: \"", "+", "nameSpaceKey", "+", "\" values: \"", "+", "all", ".", "toString", "(", ")", ")", ";", "return", "ret", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Failed to construct ARP object\"", ",", "t", ")", ";", "return", "null", ";", "}", "}" ]
The ARP is additional request parameters, which must be sent once received after any HTTP call. This is sort of a proxy for cookies. @return A JSON object containing the ARP key/values. Can be null.
[ "The", "ARP", "is", "additional", "request", "parameters", "which", "must", "be", "sent", "once", "received", "after", "any", "HTTP", "call", ".", "This", "is", "sort", "of", "a", "proxy", "for", "cookies", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L2893-L2916
164,271
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getTotalVisits
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTotalVisits() { EventDetail ed = getLocalDataStore().getEventDetail(Constants.APP_LAUNCHED_EVENT); if (ed != null) return ed.getCount(); return 0; }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTotalVisits() { EventDetail ed = getLocalDataStore().getEventDetail(Constants.APP_LAUNCHED_EVENT); if (ed != null) return ed.getCount(); return 0; }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "int", "getTotalVisits", "(", ")", "{", "EventDetail", "ed", "=", "getLocalDataStore", "(", ")", ".", "getEventDetail", "(", "Constants", ".", "APP_LAUNCHED_EVENT", ")", ";", "if", "(", "ed", "!=", "null", ")", "return", "ed", ".", "getCount", "(", ")", ";", "return", "0", ";", "}" ]
Returns the total number of times the app has been launched @return Total number of app launches in int
[ "Returns", "the", "total", "number", "of", "times", "the", "app", "has", "been", "launched" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3310-L3316
164,272
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getTimeElapsed
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTimeElapsed() { int currentSession = getCurrentSession(); if (currentSession == 0) return -1; int now = (int) (System.currentTimeMillis() / 1000); return now - currentSession; }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTimeElapsed() { int currentSession = getCurrentSession(); if (currentSession == 0) return -1; int now = (int) (System.currentTimeMillis() / 1000); return now - currentSession; }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "int", "getTimeElapsed", "(", ")", "{", "int", "currentSession", "=", "getCurrentSession", "(", ")", ";", "if", "(", "currentSession", "==", "0", ")", "return", "-", "1", ";", "int", "now", "=", "(", "int", ")", "(", "System", ".", "currentTimeMillis", "(", ")", "/", "1000", ")", ";", "return", "now", "-", "currentSession", ";", "}" ]
Returns the time elapsed by the user on the app @return Time elapsed by user on the app in int
[ "Returns", "the", "time", "elapsed", "by", "the", "user", "on", "the", "app" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3331-L3338
164,273
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getUTMDetails
@SuppressWarnings({"unused", "WeakerAccess"}) public UTMDetail getUTMDetails() { UTMDetail ud = new UTMDetail(); ud.setSource(source); ud.setMedium(medium); ud.setCampaign(campaign); return ud; }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public UTMDetail getUTMDetails() { UTMDetail ud = new UTMDetail(); ud.setSource(source); ud.setMedium(medium); ud.setCampaign(campaign); return ud; }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "UTMDetail", "getUTMDetails", "(", ")", "{", "UTMDetail", "ud", "=", "new", "UTMDetail", "(", ")", ";", "ud", ".", "setSource", "(", "source", ")", ";", "ud", ".", "setMedium", "(", "medium", ")", ";", "ud", ".", "setCampaign", "(", "campaign", ")", ";", "return", "ud", ";", "}" ]
Returns a UTMDetail object which consists of UTM parameters like source, medium & campaign @return The {@link UTMDetail} object
[ "Returns", "a", "UTMDetail", "object", "which", "consists", "of", "UTM", "parameters", "like", "source", "medium", "&", "campaign" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3353-L3360
164,274
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI._handleMultiValues
private void _handleMultiValues(ArrayList<String> values, String key, String command) { if (key == null) return; if (values == null || values.isEmpty()) { _generateEmptyMultiValueError(key); return; } ValidationResult vr; // validate the key vr = validator.cleanMultiValuePropertyKey(key); // Check for an error if (vr.getErrorCode() != 0) { pushValidationResult(vr); } // reset the key Object _key = vr.getObject(); String cleanKey = (_key != null) ? vr.getObject().toString() : null; // if key is empty generate an error and return if (cleanKey == null || cleanKey.isEmpty()) { _generateInvalidMultiValueKeyError(key); return; } key = cleanKey; try { JSONArray currentValues = _constructExistingMultiValue(key, command); JSONArray newValues = _cleanMultiValues(values, key); _validateAndPushMultiValue(currentValues, newValues, values, key, command); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "Error handling multi value operation for key " + key, t); } }
java
private void _handleMultiValues(ArrayList<String> values, String key, String command) { if (key == null) return; if (values == null || values.isEmpty()) { _generateEmptyMultiValueError(key); return; } ValidationResult vr; // validate the key vr = validator.cleanMultiValuePropertyKey(key); // Check for an error if (vr.getErrorCode() != 0) { pushValidationResult(vr); } // reset the key Object _key = vr.getObject(); String cleanKey = (_key != null) ? vr.getObject().toString() : null; // if key is empty generate an error and return if (cleanKey == null || cleanKey.isEmpty()) { _generateInvalidMultiValueKeyError(key); return; } key = cleanKey; try { JSONArray currentValues = _constructExistingMultiValue(key, command); JSONArray newValues = _cleanMultiValues(values, key); _validateAndPushMultiValue(currentValues, newValues, values, key, command); } catch (Throwable t) { getConfigLogger().verbose(getAccountId(), "Error handling multi value operation for key " + key, t); } }
[ "private", "void", "_handleMultiValues", "(", "ArrayList", "<", "String", ">", "values", ",", "String", "key", ",", "String", "command", ")", "{", "if", "(", "key", "==", "null", ")", "return", ";", "if", "(", "values", "==", "null", "||", "values", ".", "isEmpty", "(", ")", ")", "{", "_generateEmptyMultiValueError", "(", "key", ")", ";", "return", ";", "}", "ValidationResult", "vr", ";", "// validate the key", "vr", "=", "validator", ".", "cleanMultiValuePropertyKey", "(", "key", ")", ";", "// Check for an error", "if", "(", "vr", ".", "getErrorCode", "(", ")", "!=", "0", ")", "{", "pushValidationResult", "(", "vr", ")", ";", "}", "// reset the key", "Object", "_key", "=", "vr", ".", "getObject", "(", ")", ";", "String", "cleanKey", "=", "(", "_key", "!=", "null", ")", "?", "vr", ".", "getObject", "(", ")", ".", "toString", "(", ")", ":", "null", ";", "// if key is empty generate an error and return", "if", "(", "cleanKey", "==", "null", "||", "cleanKey", ".", "isEmpty", "(", ")", ")", "{", "_generateInvalidMultiValueKeyError", "(", "key", ")", ";", "return", ";", "}", "key", "=", "cleanKey", ";", "try", "{", "JSONArray", "currentValues", "=", "_constructExistingMultiValue", "(", "key", ",", "command", ")", ";", "JSONArray", "newValues", "=", "_cleanMultiValues", "(", "values", ",", "key", ")", ";", "_validateAndPushMultiValue", "(", "currentValues", ",", "newValues", ",", "values", ",", "key", ",", "command", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Error handling multi value operation for key \"", "+", "key", ",", "t", ")", ";", "}", "}" ]
private multi-value handlers and helpers
[ "private", "multi", "-", "value", "handlers", "and", "helpers" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3786-L3824
164,275
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.pushEvent
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushEvent(String eventName) { if (eventName == null || eventName.trim().equals("")) return; pushEvent(eventName, null); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushEvent(String eventName) { if (eventName == null || eventName.trim().equals("")) return; pushEvent(eventName, null); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "pushEvent", "(", "String", "eventName", ")", "{", "if", "(", "eventName", "==", "null", "||", "eventName", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "return", ";", "pushEvent", "(", "eventName", ",", "null", ")", ";", "}" ]
Pushes a basic event. @param eventName The name of the event
[ "Pushes", "a", "basic", "event", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4374-L4380
164,276
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.pushNotificationViewedEvent
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushNotificationViewedEvent(Bundle extras){ if (extras == null || extras.isEmpty() || extras.get(Constants.NOTIFICATION_TAG) == null) { getConfigLogger().debug(getAccountId(), "Push notification: " + (extras == null ? "NULL" : extras.toString()) + " not from CleverTap - will not process Notification Viewed event."); return; } if (!extras.containsKey(Constants.NOTIFICATION_ID_TAG) || (extras.getString(Constants.NOTIFICATION_ID_TAG) == null)) { getConfigLogger().debug(getAccountId(), "Push notification ID Tag is null, not processing Notification Viewed event for: " + extras.toString()); return; } // Check for dupe notification views; if same notficationdId within specified time interval (2 secs) don't process boolean isDuplicate = checkDuplicateNotificationIds(extras, notificationViewedIdTagMap, Constants.NOTIFICATION_VIEWED_ID_TAG_INTERVAL); if (isDuplicate) { getConfigLogger().debug(getAccountId(), "Already processed Notification Viewed event for " + extras.toString() + ", dropping duplicate."); return; } JSONObject event = new JSONObject(); try { JSONObject notif = getWzrkFields(extras); event.put("evtName", Constants.NOTIFICATION_VIEWED_EVENT_NAME); event.put("evtData", notif); } catch (Throwable ignored) { //no-op } queueEvent(context, event, Constants.RAISED_EVENT); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushNotificationViewedEvent(Bundle extras){ if (extras == null || extras.isEmpty() || extras.get(Constants.NOTIFICATION_TAG) == null) { getConfigLogger().debug(getAccountId(), "Push notification: " + (extras == null ? "NULL" : extras.toString()) + " not from CleverTap - will not process Notification Viewed event."); return; } if (!extras.containsKey(Constants.NOTIFICATION_ID_TAG) || (extras.getString(Constants.NOTIFICATION_ID_TAG) == null)) { getConfigLogger().debug(getAccountId(), "Push notification ID Tag is null, not processing Notification Viewed event for: " + extras.toString()); return; } // Check for dupe notification views; if same notficationdId within specified time interval (2 secs) don't process boolean isDuplicate = checkDuplicateNotificationIds(extras, notificationViewedIdTagMap, Constants.NOTIFICATION_VIEWED_ID_TAG_INTERVAL); if (isDuplicate) { getConfigLogger().debug(getAccountId(), "Already processed Notification Viewed event for " + extras.toString() + ", dropping duplicate."); return; } JSONObject event = new JSONObject(); try { JSONObject notif = getWzrkFields(extras); event.put("evtName", Constants.NOTIFICATION_VIEWED_EVENT_NAME); event.put("evtData", notif); } catch (Throwable ignored) { //no-op } queueEvent(context, event, Constants.RAISED_EVENT); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "pushNotificationViewedEvent", "(", "Bundle", "extras", ")", "{", "if", "(", "extras", "==", "null", "||", "extras", ".", "isEmpty", "(", ")", "||", "extras", ".", "get", "(", "Constants", ".", "NOTIFICATION_TAG", ")", "==", "null", ")", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Push notification: \"", "+", "(", "extras", "==", "null", "?", "\"NULL\"", ":", "extras", ".", "toString", "(", ")", ")", "+", "\" not from CleverTap - will not process Notification Viewed event.\"", ")", ";", "return", ";", "}", "if", "(", "!", "extras", ".", "containsKey", "(", "Constants", ".", "NOTIFICATION_ID_TAG", ")", "||", "(", "extras", ".", "getString", "(", "Constants", ".", "NOTIFICATION_ID_TAG", ")", "==", "null", ")", ")", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Push notification ID Tag is null, not processing Notification Viewed event for: \"", "+", "extras", ".", "toString", "(", ")", ")", ";", "return", ";", "}", "// Check for dupe notification views; if same notficationdId within specified time interval (2 secs) don't process", "boolean", "isDuplicate", "=", "checkDuplicateNotificationIds", "(", "extras", ",", "notificationViewedIdTagMap", ",", "Constants", ".", "NOTIFICATION_VIEWED_ID_TAG_INTERVAL", ")", ";", "if", "(", "isDuplicate", ")", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Already processed Notification Viewed event for \"", "+", "extras", ".", "toString", "(", ")", "+", "\", dropping duplicate.\"", ")", ";", "return", ";", "}", "JSONObject", "event", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "JSONObject", "notif", "=", "getWzrkFields", "(", "extras", ")", ";", "event", ".", "put", "(", "\"evtName\"", ",", "Constants", ".", "NOTIFICATION_VIEWED_EVENT_NAME", ")", ";", "event", ".", "put", "(", "\"evtData\"", ",", "notif", ")", ";", "}", "catch", "(", "Throwable", "ignored", ")", "{", "//no-op", "}", "queueEvent", "(", "context", ",", "event", ",", "Constants", ".", "RAISED_EVENT", ")", ";", "}" ]
Pushes the Notification Viewed event to CleverTap. @param extras The {@link Bundle} object that contains the notification details
[ "Pushes", "the", "Notification", "Viewed", "event", "to", "CleverTap", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4389-L4418
164,277
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getCount
@SuppressWarnings({"unused", "WeakerAccess"}) public int getCount(String event) { EventDetail eventDetail = getLocalDataStore().getEventDetail(event); if (eventDetail != null) return eventDetail.getCount(); return -1; }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public int getCount(String event) { EventDetail eventDetail = getLocalDataStore().getEventDetail(event); if (eventDetail != null) return eventDetail.getCount(); return -1; }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "int", "getCount", "(", "String", "event", ")", "{", "EventDetail", "eventDetail", "=", "getLocalDataStore", "(", ")", ".", "getEventDetail", "(", "event", ")", ";", "if", "(", "eventDetail", "!=", "null", ")", "return", "eventDetail", ".", "getCount", "(", ")", ";", "return", "-", "1", ";", "}" ]
Returns the total count of the specified event @param event The event for which you want to get the total count @return Total count in int
[ "Returns", "the", "total", "count", "of", "the", "specified", "event" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4554-L4560
164,278
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.pushDeviceToken
private void pushDeviceToken(final String token, final boolean register, final PushType type) { pushDeviceToken(this.context, token, register, type); }
java
private void pushDeviceToken(final String token, final boolean register, final PushType type) { pushDeviceToken(this.context, token, register, type); }
[ "private", "void", "pushDeviceToken", "(", "final", "String", "token", ",", "final", "boolean", "register", ",", "final", "PushType", "type", ")", "{", "pushDeviceToken", "(", "this", ".", "context", ",", "token", ",", "register", ",", "type", ")", ";", "}" ]
For internal use, don't call the public API internally
[ "For", "internal", "use", "don", "t", "call", "the", "public", "API", "internally" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4830-L4832
164,279
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getNotificationInfo
@SuppressWarnings({"unused", "WeakerAccess"}) public static NotificationInfo getNotificationInfo(final Bundle extras) { if (extras == null) return new NotificationInfo(false, false); boolean fromCleverTap = extras.containsKey(Constants.NOTIFICATION_TAG); boolean shouldRender = fromCleverTap && extras.containsKey("nm"); return new NotificationInfo(fromCleverTap, shouldRender); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public static NotificationInfo getNotificationInfo(final Bundle extras) { if (extras == null) return new NotificationInfo(false, false); boolean fromCleverTap = extras.containsKey(Constants.NOTIFICATION_TAG); boolean shouldRender = fromCleverTap && extras.containsKey("nm"); return new NotificationInfo(fromCleverTap, shouldRender); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "static", "NotificationInfo", "getNotificationInfo", "(", "final", "Bundle", "extras", ")", "{", "if", "(", "extras", "==", "null", ")", "return", "new", "NotificationInfo", "(", "false", ",", "false", ")", ";", "boolean", "fromCleverTap", "=", "extras", ".", "containsKey", "(", "Constants", ".", "NOTIFICATION_TAG", ")", ";", "boolean", "shouldRender", "=", "fromCleverTap", "&&", "extras", ".", "containsKey", "(", "\"nm\"", ")", ";", "return", "new", "NotificationInfo", "(", "fromCleverTap", ",", "shouldRender", ")", ";", "}" ]
Checks whether this notification is from CleverTap. @param extras The payload from the GCM intent @return See {@link NotificationInfo}
[ "Checks", "whether", "this", "notification", "is", "from", "CleverTap", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5092-L5099
164,280
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.pushInstallReferrer
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushInstallReferrer(Intent intent) { try { final Bundle extras = intent.getExtras(); // Preliminary checks if (extras == null || !extras.containsKey("referrer")) { return; } final String url; try { url = URLDecoder.decode(extras.getString("referrer"), "UTF-8"); getConfigLogger().verbose(getAccountId(), "Referrer received: " + url); } catch (Throwable e) { // Could not decode return; } if (url == null) { return; } int now = (int) (System.currentTimeMillis() / 1000); if (installReferrerMap.containsKey(url) && now - installReferrerMap.get(url) < 10) { getConfigLogger().verbose(getAccountId(),"Skipping install referrer due to duplicate within 10 seconds"); return; } installReferrerMap.put(url, now); Uri uri = Uri.parse("wzrk://track?install=true&" + url); pushDeepLink(uri, true); } catch (Throwable t) { // no-op } }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushInstallReferrer(Intent intent) { try { final Bundle extras = intent.getExtras(); // Preliminary checks if (extras == null || !extras.containsKey("referrer")) { return; } final String url; try { url = URLDecoder.decode(extras.getString("referrer"), "UTF-8"); getConfigLogger().verbose(getAccountId(), "Referrer received: " + url); } catch (Throwable e) { // Could not decode return; } if (url == null) { return; } int now = (int) (System.currentTimeMillis() / 1000); if (installReferrerMap.containsKey(url) && now - installReferrerMap.get(url) < 10) { getConfigLogger().verbose(getAccountId(),"Skipping install referrer due to duplicate within 10 seconds"); return; } installReferrerMap.put(url, now); Uri uri = Uri.parse("wzrk://track?install=true&" + url); pushDeepLink(uri, true); } catch (Throwable t) { // no-op } }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "pushInstallReferrer", "(", "Intent", "intent", ")", "{", "try", "{", "final", "Bundle", "extras", "=", "intent", ".", "getExtras", "(", ")", ";", "// Preliminary checks", "if", "(", "extras", "==", "null", "||", "!", "extras", ".", "containsKey", "(", "\"referrer\"", ")", ")", "{", "return", ";", "}", "final", "String", "url", ";", "try", "{", "url", "=", "URLDecoder", ".", "decode", "(", "extras", ".", "getString", "(", "\"referrer\"", ")", ",", "\"UTF-8\"", ")", ";", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Referrer received: \"", "+", "url", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "// Could not decode", "return", ";", "}", "if", "(", "url", "==", "null", ")", "{", "return", ";", "}", "int", "now", "=", "(", "int", ")", "(", "System", ".", "currentTimeMillis", "(", ")", "/", "1000", ")", ";", "if", "(", "installReferrerMap", ".", "containsKey", "(", "url", ")", "&&", "now", "-", "installReferrerMap", ".", "get", "(", "url", ")", "<", "10", ")", "{", "getConfigLogger", "(", ")", ".", "verbose", "(", "getAccountId", "(", ")", ",", "\"Skipping install referrer due to duplicate within 10 seconds\"", ")", ";", "return", ";", "}", "installReferrerMap", ".", "put", "(", "url", ",", "now", ")", ";", "Uri", "uri", "=", "Uri", ".", "parse", "(", "\"wzrk://track?install=true&\"", "+", "url", ")", ";", "pushDeepLink", "(", "uri", ",", "true", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// no-op", "}", "}" ]
This method is used to push install referrer via Intent @param intent An Intent with the install referrer parameters
[ "This", "method", "is", "used", "to", "push", "install", "referrer", "via", "Intent" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5896-L5931
164,281
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.pushInstallReferrer
@SuppressWarnings({"unused", "WeakerAccess"}) public synchronized void pushInstallReferrer(String source, String medium, String campaign) { if (source == null && medium == null && campaign == null) return; try { // If already pushed, don't send it again int status = StorageHelper.getInt(context, "app_install_status", 0); if (status != 0) { Logger.d("Install referrer has already been set. Will not override it"); return; } StorageHelper.putInt(context, "app_install_status", 1); if (source != null) source = Uri.encode(source); if (medium != null) medium = Uri.encode(medium); if (campaign != null) campaign = Uri.encode(campaign); String uriStr = "wzrk://track?install=true"; if (source != null) uriStr += "&utm_source=" + source; if (medium != null) uriStr += "&utm_medium=" + medium; if (campaign != null) uriStr += "&utm_campaign=" + campaign; Uri uri = Uri.parse(uriStr); pushDeepLink(uri, true); } catch (Throwable t) { Logger.v("Failed to push install referrer", t); } }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public synchronized void pushInstallReferrer(String source, String medium, String campaign) { if (source == null && medium == null && campaign == null) return; try { // If already pushed, don't send it again int status = StorageHelper.getInt(context, "app_install_status", 0); if (status != 0) { Logger.d("Install referrer has already been set. Will not override it"); return; } StorageHelper.putInt(context, "app_install_status", 1); if (source != null) source = Uri.encode(source); if (medium != null) medium = Uri.encode(medium); if (campaign != null) campaign = Uri.encode(campaign); String uriStr = "wzrk://track?install=true"; if (source != null) uriStr += "&utm_source=" + source; if (medium != null) uriStr += "&utm_medium=" + medium; if (campaign != null) uriStr += "&utm_campaign=" + campaign; Uri uri = Uri.parse(uriStr); pushDeepLink(uri, true); } catch (Throwable t) { Logger.v("Failed to push install referrer", t); } }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "synchronized", "void", "pushInstallReferrer", "(", "String", "source", ",", "String", "medium", ",", "String", "campaign", ")", "{", "if", "(", "source", "==", "null", "&&", "medium", "==", "null", "&&", "campaign", "==", "null", ")", "return", ";", "try", "{", "// If already pushed, don't send it again", "int", "status", "=", "StorageHelper", ".", "getInt", "(", "context", ",", "\"app_install_status\"", ",", "0", ")", ";", "if", "(", "status", "!=", "0", ")", "{", "Logger", ".", "d", "(", "\"Install referrer has already been set. Will not override it\"", ")", ";", "return", ";", "}", "StorageHelper", ".", "putInt", "(", "context", ",", "\"app_install_status\"", ",", "1", ")", ";", "if", "(", "source", "!=", "null", ")", "source", "=", "Uri", ".", "encode", "(", "source", ")", ";", "if", "(", "medium", "!=", "null", ")", "medium", "=", "Uri", ".", "encode", "(", "medium", ")", ";", "if", "(", "campaign", "!=", "null", ")", "campaign", "=", "Uri", ".", "encode", "(", "campaign", ")", ";", "String", "uriStr", "=", "\"wzrk://track?install=true\"", ";", "if", "(", "source", "!=", "null", ")", "uriStr", "+=", "\"&utm_source=\"", "+", "source", ";", "if", "(", "medium", "!=", "null", ")", "uriStr", "+=", "\"&utm_medium=\"", "+", "medium", ";", "if", "(", "campaign", "!=", "null", ")", "uriStr", "+=", "\"&utm_campaign=\"", "+", "campaign", ";", "Uri", "uri", "=", "Uri", ".", "parse", "(", "uriStr", ")", ";", "pushDeepLink", "(", "uri", ",", "true", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "Logger", ".", "v", "(", "\"Failed to push install referrer\"", ",", "t", ")", ";", "}", "}" ]
This method is used to push install referrer via UTM source, medium & campaign parameters @param source The UTM source parameter @param medium The UTM medium parameter @param campaign The UTM campaign parameter
[ "This", "method", "is", "used", "to", "push", "install", "referrer", "via", "UTM", "source", "medium", "&", "campaign", "parameters" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5939-L5965
164,282
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.changeCredentials
@SuppressWarnings("unused") public static void changeCredentials(String accountID, String token) { changeCredentials(accountID, token, null); }
java
@SuppressWarnings("unused") public static void changeCredentials(String accountID, String token) { changeCredentials(accountID, token, null); }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "static", "void", "changeCredentials", "(", "String", "accountID", ",", "String", "token", ")", "{", "changeCredentials", "(", "accountID", ",", "token", ",", "null", ")", ";", "}" ]
This method is used to change the credentials of CleverTap account Id and token programmatically @param accountID CleverTap Account Id @param token CleverTap Account Token
[ "This", "method", "is", "used", "to", "change", "the", "credentials", "of", "CleverTap", "account", "Id", "and", "token", "programmatically" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5972-L5975
164,283
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.changeCredentials
@SuppressWarnings({"unused", "WeakerAccess"}) public static void changeCredentials(String accountID, String token, String region) { if(defaultConfig != null){ Logger.i("CleverTap SDK already initialized with accountID:"+defaultConfig.getAccountId() +" and token:"+defaultConfig.getAccountToken()+". Cannot change credentials to " + accountID + " and " + token); return; } ManifestInfo.changeCredentials(accountID,token,region); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public static void changeCredentials(String accountID, String token, String region) { if(defaultConfig != null){ Logger.i("CleverTap SDK already initialized with accountID:"+defaultConfig.getAccountId() +" and token:"+defaultConfig.getAccountToken()+". Cannot change credentials to " + accountID + " and " + token); return; } ManifestInfo.changeCredentials(accountID,token,region); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "static", "void", "changeCredentials", "(", "String", "accountID", ",", "String", "token", ",", "String", "region", ")", "{", "if", "(", "defaultConfig", "!=", "null", ")", "{", "Logger", ".", "i", "(", "\"CleverTap SDK already initialized with accountID:\"", "+", "defaultConfig", ".", "getAccountId", "(", ")", "+", "\" and token:\"", "+", "defaultConfig", ".", "getAccountToken", "(", ")", "+", "\". Cannot change credentials to \"", "+", "accountID", "+", "\" and \"", "+", "token", ")", ";", "return", ";", "}", "ManifestInfo", ".", "changeCredentials", "(", "accountID", ",", "token", ",", "region", ")", ";", "}" ]
This method is used to change the credentials of CleverTap account Id, token and region programmatically @param accountID CleverTap Account Id @param token CleverTap Account Token @param region Clever Tap Account Region
[ "This", "method", "is", "used", "to", "change", "the", "credentials", "of", "CleverTap", "account", "Id", "token", "and", "region", "programmatically" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5983-L5993
164,284
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getInboxMessageCount
@SuppressWarnings({"unused", "WeakerAccess"}) public int getInboxMessageCount(){ synchronized (inboxControllerLock) { if (this.ctInboxController != null) { return ctInboxController.count(); } else { getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized"); return -1; } } }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public int getInboxMessageCount(){ synchronized (inboxControllerLock) { if (this.ctInboxController != null) { return ctInboxController.count(); } else { getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized"); return -1; } } }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "int", "getInboxMessageCount", "(", ")", "{", "synchronized", "(", "inboxControllerLock", ")", "{", "if", "(", "this", ".", "ctInboxController", "!=", "null", ")", "{", "return", "ctInboxController", ".", "count", "(", ")", ";", "}", "else", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Notification Inbox not initialized\"", ")", ";", "return", "-", "1", ";", "}", "}", "}" ]
Returns the count of all inbox messages for the user @return int - count of all inbox messages
[ "Returns", "the", "count", "of", "all", "inbox", "messages", "for", "the", "user" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6187-L6197
164,285
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.getInboxMessageUnreadCount
@SuppressWarnings({"unused", "WeakerAccess"}) public int getInboxMessageUnreadCount(){ synchronized (inboxControllerLock) { if (this.ctInboxController != null) { return ctInboxController.unreadCount(); } else { getConfigLogger().debug(getAccountId(), "Notification Inbox not initialized"); return -1; } } }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public int getInboxMessageUnreadCount(){ synchronized (inboxControllerLock) { if (this.ctInboxController != null) { return ctInboxController.unreadCount(); } else { getConfigLogger().debug(getAccountId(), "Notification Inbox not initialized"); return -1; } } }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "int", "getInboxMessageUnreadCount", "(", ")", "{", "synchronized", "(", "inboxControllerLock", ")", "{", "if", "(", "this", ".", "ctInboxController", "!=", "null", ")", "{", "return", "ctInboxController", ".", "unreadCount", "(", ")", ";", "}", "else", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Notification Inbox not initialized\"", ")", ";", "return", "-", "1", ";", "}", "}", "}" ]
Returns the count of total number of unread inbox messages for the user @return int - count of all unread messages
[ "Returns", "the", "count", "of", "total", "number", "of", "unread", "inbox", "messages", "for", "the", "user" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6203-L6213
164,286
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.markReadInboxMessage
@SuppressWarnings({"unused", "WeakerAccess"}) public void markReadInboxMessage(final CTInboxMessage message){ postAsyncSafely("markReadInboxMessage", new Runnable() { @Override public void run() { synchronized (inboxControllerLock) { if(ctInboxController != null){ boolean read = ctInboxController.markReadForMessageWithId(message.getMessageId()); if (read) { _notifyInboxMessagesDidUpdate(); } } else { getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized"); } } } }); }
java
@SuppressWarnings({"unused", "WeakerAccess"}) public void markReadInboxMessage(final CTInboxMessage message){ postAsyncSafely("markReadInboxMessage", new Runnable() { @Override public void run() { synchronized (inboxControllerLock) { if(ctInboxController != null){ boolean read = ctInboxController.markReadForMessageWithId(message.getMessageId()); if (read) { _notifyInboxMessagesDidUpdate(); } } else { getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized"); } } } }); }
[ "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"WeakerAccess\"", "}", ")", "public", "void", "markReadInboxMessage", "(", "final", "CTInboxMessage", "message", ")", "{", "postAsyncSafely", "(", "\"markReadInboxMessage\"", ",", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "synchronized", "(", "inboxControllerLock", ")", "{", "if", "(", "ctInboxController", "!=", "null", ")", "{", "boolean", "read", "=", "ctInboxController", ".", "markReadForMessageWithId", "(", "message", ".", "getMessageId", "(", ")", ")", ";", "if", "(", "read", ")", "{", "_notifyInboxMessagesDidUpdate", "(", ")", ";", "}", "}", "else", "{", "getConfigLogger", "(", ")", ".", "debug", "(", "getAccountId", "(", ")", ",", "\"Notification Inbox not initialized\"", ")", ";", "}", "}", "}", "}", ")", ";", "}" ]
marks the message as read
[ "marks", "the", "message", "as", "read" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6260-L6277
164,287
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.advance
boolean advance() { if (header.frameCount <= 0) { return false; } if(framePointer == getFrameCount() - 1) { loopIndex++; } if(header.loopCount != LOOP_FOREVER && loopIndex > header.loopCount) { return false; } framePointer = (framePointer + 1) % header.frameCount; return true; }
java
boolean advance() { if (header.frameCount <= 0) { return false; } if(framePointer == getFrameCount() - 1) { loopIndex++; } if(header.loopCount != LOOP_FOREVER && loopIndex > header.loopCount) { return false; } framePointer = (framePointer + 1) % header.frameCount; return true; }
[ "boolean", "advance", "(", ")", "{", "if", "(", "header", ".", "frameCount", "<=", "0", ")", "{", "return", "false", ";", "}", "if", "(", "framePointer", "==", "getFrameCount", "(", ")", "-", "1", ")", "{", "loopIndex", "++", ";", "}", "if", "(", "header", ".", "loopCount", "!=", "LOOP_FOREVER", "&&", "loopIndex", ">", "header", ".", "loopCount", ")", "{", "return", "false", ";", "}", "framePointer", "=", "(", "framePointer", "+", "1", ")", "%", "header", ".", "frameCount", ";", "return", "true", ";", "}" ]
Move the animation frame counter forward. @return boolean specifying if animation should continue or if loopCount has been fulfilled.
[ "Move", "the", "animation", "frame", "counter", "forward", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L219-L234
164,288
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.getDelay
int getDelay(int n) { int delay = -1; if ((n >= 0) && (n < header.frameCount)) { delay = header.frames.get(n).delay; } return delay; }
java
int getDelay(int n) { int delay = -1; if ((n >= 0) && (n < header.frameCount)) { delay = header.frames.get(n).delay; } return delay; }
[ "int", "getDelay", "(", "int", "n", ")", "{", "int", "delay", "=", "-", "1", ";", "if", "(", "(", "n", ">=", "0", ")", "&&", "(", "n", "<", "header", ".", "frameCount", ")", ")", "{", "delay", "=", "header", ".", "frames", ".", "get", "(", "n", ")", ".", "delay", ";", "}", "return", "delay", ";", "}" ]
Gets display duration for specified frame. @param n int index of frame. @return delay in milliseconds.
[ "Gets", "display", "duration", "for", "specified", "frame", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L242-L248
164,289
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.setFrameIndex
boolean setFrameIndex(int frame) { if(frame < INITIAL_FRAME_POINTER || frame >= getFrameCount()) { return false; } framePointer = frame; return true; }
java
boolean setFrameIndex(int frame) { if(frame < INITIAL_FRAME_POINTER || frame >= getFrameCount()) { return false; } framePointer = frame; return true; }
[ "boolean", "setFrameIndex", "(", "int", "frame", ")", "{", "if", "(", "frame", "<", "INITIAL_FRAME_POINTER", "||", "frame", ">=", "getFrameCount", "(", ")", ")", "{", "return", "false", ";", "}", "framePointer", "=", "frame", ";", "return", "true", ";", "}" ]
Sets the frame pointer to a specific frame @return boolean true if the move was successful
[ "Sets", "the", "frame", "pointer", "to", "a", "specific", "frame" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L284-L290
164,290
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.read
int read(InputStream is, int contentLength) { if (is != null) { try { int capacity = (contentLength > 0) ? (contentLength + 4096) : 16384; ByteArrayOutputStream buffer = new ByteArrayOutputStream(capacity); int nRead; byte[] data = new byte[16384]; while ((nRead = is.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); read(buffer.toByteArray()); } catch (IOException e) { Logger.d(TAG, "Error reading data from stream", e); } } else { status = STATUS_OPEN_ERROR; } try { if (is != null) { is.close(); } } catch (IOException e) { Logger.d(TAG, "Error closing stream", e); } return status; }
java
int read(InputStream is, int contentLength) { if (is != null) { try { int capacity = (contentLength > 0) ? (contentLength + 4096) : 16384; ByteArrayOutputStream buffer = new ByteArrayOutputStream(capacity); int nRead; byte[] data = new byte[16384]; while ((nRead = is.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); read(buffer.toByteArray()); } catch (IOException e) { Logger.d(TAG, "Error reading data from stream", e); } } else { status = STATUS_OPEN_ERROR; } try { if (is != null) { is.close(); } } catch (IOException e) { Logger.d(TAG, "Error closing stream", e); } return status; }
[ "int", "read", "(", "InputStream", "is", ",", "int", "contentLength", ")", "{", "if", "(", "is", "!=", "null", ")", "{", "try", "{", "int", "capacity", "=", "(", "contentLength", ">", "0", ")", "?", "(", "contentLength", "+", "4096", ")", ":", "16384", ";", "ByteArrayOutputStream", "buffer", "=", "new", "ByteArrayOutputStream", "(", "capacity", ")", ";", "int", "nRead", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "16384", "]", ";", "while", "(", "(", "nRead", "=", "is", ".", "read", "(", "data", ",", "0", ",", "data", ".", "length", ")", ")", "!=", "-", "1", ")", "{", "buffer", ".", "write", "(", "data", ",", "0", ",", "nRead", ")", ";", "}", "buffer", ".", "flush", "(", ")", ";", "read", "(", "buffer", ".", "toByteArray", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Logger", ".", "d", "(", "TAG", ",", "\"Error reading data from stream\"", ",", "e", ")", ";", "}", "}", "else", "{", "status", "=", "STATUS_OPEN_ERROR", ";", "}", "try", "{", "if", "(", "is", "!=", "null", ")", "{", "is", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "Logger", ".", "d", "(", "TAG", ",", "\"Error closing stream\"", ",", "e", ")", ";", "}", "return", "status", ";", "}" ]
Reads GIF image from stream. @param is containing GIF file. @return read status code (0 = no errors).
[ "Reads", "GIF", "image", "from", "stream", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L388-L417
164,291
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.read
synchronized int read(byte[] data) { this.header = getHeaderParser().setData(data).parseHeader(); if (data != null) { setData(header, data); } return status; }
java
synchronized int read(byte[] data) { this.header = getHeaderParser().setData(data).parseHeader(); if (data != null) { setData(header, data); } return status; }
[ "synchronized", "int", "read", "(", "byte", "[", "]", "data", ")", "{", "this", ".", "header", "=", "getHeaderParser", "(", ")", ".", "setData", "(", "data", ")", ".", "parseHeader", "(", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "setData", "(", "header", ",", "data", ")", ";", "}", "return", "status", ";", "}" ]
Reads GIF image from byte array. @param data containing GIF file. @return read status code (0 = no errors).
[ "Reads", "GIF", "image", "from", "byte", "array", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L496-L503
164,292
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java
GifDecoder.readChunkIfNeeded
private void readChunkIfNeeded() { if (workBufferSize > workBufferPosition) { return; } if (workBuffer == null) { workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE); } workBufferPosition = 0; workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE); rawData.get(workBuffer, 0, workBufferSize); }
java
private void readChunkIfNeeded() { if (workBufferSize > workBufferPosition) { return; } if (workBuffer == null) { workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE); } workBufferPosition = 0; workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE); rawData.get(workBuffer, 0, workBufferSize); }
[ "private", "void", "readChunkIfNeeded", "(", ")", "{", "if", "(", "workBufferSize", ">", "workBufferPosition", ")", "{", "return", ";", "}", "if", "(", "workBuffer", "==", "null", ")", "{", "workBuffer", "=", "bitmapProvider", ".", "obtainByteArray", "(", "WORK_BUFFER_SIZE", ")", ";", "}", "workBufferPosition", "=", "0", ";", "workBufferSize", "=", "Math", ".", "min", "(", "rawData", ".", "remaining", "(", ")", ",", "WORK_BUFFER_SIZE", ")", ";", "rawData", ".", "get", "(", "workBuffer", ",", "0", ",", "workBufferSize", ")", ";", "}" ]
Reads the next chunk for the intermediate work buffer.
[ "Reads", "the", "next", "chunk", "for", "the", "intermediate", "work", "buffer", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L838-L848
164,293
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java
ActivityLifecycleCallback.register
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static synchronized void register(android.app.Application application) { if (application == null) { Logger.i("Application instance is null/system API is too old"); return; } if (registered) { Logger.v("Lifecycle callbacks have already been registered"); return; } registered = true; application.registerActivityLifecycleCallbacks( new android.app.Application.ActivityLifecycleCallbacks() { @Override public void onActivityCreated(Activity activity, Bundle bundle) { CleverTapAPI.onActivityCreated(activity); } @Override public void onActivityStarted(Activity activity) {} @Override public void onActivityResumed(Activity activity) { CleverTapAPI.onActivityResumed(activity); } @Override public void onActivityPaused(Activity activity) { CleverTapAPI.onActivityPaused(); } @Override public void onActivityStopped(Activity activity) {} @Override public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {} @Override public void onActivityDestroyed(Activity activity) {} } ); Logger.i("Activity Lifecycle Callback successfully registered"); }
java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static synchronized void register(android.app.Application application) { if (application == null) { Logger.i("Application instance is null/system API is too old"); return; } if (registered) { Logger.v("Lifecycle callbacks have already been registered"); return; } registered = true; application.registerActivityLifecycleCallbacks( new android.app.Application.ActivityLifecycleCallbacks() { @Override public void onActivityCreated(Activity activity, Bundle bundle) { CleverTapAPI.onActivityCreated(activity); } @Override public void onActivityStarted(Activity activity) {} @Override public void onActivityResumed(Activity activity) { CleverTapAPI.onActivityResumed(activity); } @Override public void onActivityPaused(Activity activity) { CleverTapAPI.onActivityPaused(); } @Override public void onActivityStopped(Activity activity) {} @Override public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {} @Override public void onActivityDestroyed(Activity activity) {} } ); Logger.i("Activity Lifecycle Callback successfully registered"); }
[ "@", "TargetApi", "(", "Build", ".", "VERSION_CODES", ".", "ICE_CREAM_SANDWICH", ")", "public", "static", "synchronized", "void", "register", "(", "android", ".", "app", ".", "Application", "application", ")", "{", "if", "(", "application", "==", "null", ")", "{", "Logger", ".", "i", "(", "\"Application instance is null/system API is too old\"", ")", ";", "return", ";", "}", "if", "(", "registered", ")", "{", "Logger", ".", "v", "(", "\"Lifecycle callbacks have already been registered\"", ")", ";", "return", ";", "}", "registered", "=", "true", ";", "application", ".", "registerActivityLifecycleCallbacks", "(", "new", "android", ".", "app", ".", "Application", ".", "ActivityLifecycleCallbacks", "(", ")", "{", "@", "Override", "public", "void", "onActivityCreated", "(", "Activity", "activity", ",", "Bundle", "bundle", ")", "{", "CleverTapAPI", ".", "onActivityCreated", "(", "activity", ")", ";", "}", "@", "Override", "public", "void", "onActivityStarted", "(", "Activity", "activity", ")", "{", "}", "@", "Override", "public", "void", "onActivityResumed", "(", "Activity", "activity", ")", "{", "CleverTapAPI", ".", "onActivityResumed", "(", "activity", ")", ";", "}", "@", "Override", "public", "void", "onActivityPaused", "(", "Activity", "activity", ")", "{", "CleverTapAPI", ".", "onActivityPaused", "(", ")", ";", "}", "@", "Override", "public", "void", "onActivityStopped", "(", "Activity", "activity", ")", "{", "}", "@", "Override", "public", "void", "onActivitySaveInstanceState", "(", "Activity", "activity", ",", "Bundle", "bundle", ")", "{", "}", "@", "Override", "public", "void", "onActivityDestroyed", "(", "Activity", "activity", ")", "{", "}", "}", ")", ";", "Logger", ".", "i", "(", "\"Activity Lifecycle Callback successfully registered\"", ")", ";", "}" ]
Enables lifecycle callbacks for Android devices @param application App's Application object
[ "Enables", "lifecycle", "callbacks", "for", "Android", "devices" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java#L19-L65
164,294
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java
Validator.cleanObjectKey
ValidationResult cleanObjectKey(String name) { ValidationResult vr = new ValidationResult(); name = name.trim(); for (String x : objectKeyCharsNotAllowed) name = name.replace(x, ""); if (name.length() > Constants.MAX_KEY_LENGTH) { name = name.substring(0, Constants.MAX_KEY_LENGTH-1); vr.setErrorDesc(name.trim() + "... exceeds the limit of "+ Constants.MAX_KEY_LENGTH + " characters. Trimmed"); vr.setErrorCode(520); } vr.setObject(name.trim()); return vr; }
java
ValidationResult cleanObjectKey(String name) { ValidationResult vr = new ValidationResult(); name = name.trim(); for (String x : objectKeyCharsNotAllowed) name = name.replace(x, ""); if (name.length() > Constants.MAX_KEY_LENGTH) { name = name.substring(0, Constants.MAX_KEY_LENGTH-1); vr.setErrorDesc(name.trim() + "... exceeds the limit of "+ Constants.MAX_KEY_LENGTH + " characters. Trimmed"); vr.setErrorCode(520); } vr.setObject(name.trim()); return vr; }
[ "ValidationResult", "cleanObjectKey", "(", "String", "name", ")", "{", "ValidationResult", "vr", "=", "new", "ValidationResult", "(", ")", ";", "name", "=", "name", ".", "trim", "(", ")", ";", "for", "(", "String", "x", ":", "objectKeyCharsNotAllowed", ")", "name", "=", "name", ".", "replace", "(", "x", ",", "\"\"", ")", ";", "if", "(", "name", ".", "length", "(", ")", ">", "Constants", ".", "MAX_KEY_LENGTH", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "Constants", ".", "MAX_KEY_LENGTH", "-", "1", ")", ";", "vr", ".", "setErrorDesc", "(", "name", ".", "trim", "(", ")", "+", "\"... exceeds the limit of \"", "+", "Constants", ".", "MAX_KEY_LENGTH", "+", "\" characters. Trimmed\"", ")", ";", "vr", ".", "setErrorCode", "(", "520", ")", ";", "}", "vr", ".", "setObject", "(", "name", ".", "trim", "(", ")", ")", ";", "return", "vr", ";", "}" ]
Cleans the object key. @param name Name of the object key @return The {@link ValidationResult} object containing the object, and the error code(if any)
[ "Cleans", "the", "object", "key", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L75-L90
164,295
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java
Validator.cleanMultiValuePropertyKey
ValidationResult cleanMultiValuePropertyKey(String name) { ValidationResult vr = cleanObjectKey(name); name = (String) vr.getObject(); // make sure its not a known property key (reserved in the case of multi-value) try { RestrictedMultiValueFields rf = RestrictedMultiValueFields.valueOf(name); //noinspection ConstantConditions if (rf != null) { vr.setErrorDesc(name + "... is a restricted key for multi-value properties. Operation aborted."); vr.setErrorCode(523); vr.setObject(null); } } catch (Throwable t) { //no-op } return vr; }
java
ValidationResult cleanMultiValuePropertyKey(String name) { ValidationResult vr = cleanObjectKey(name); name = (String) vr.getObject(); // make sure its not a known property key (reserved in the case of multi-value) try { RestrictedMultiValueFields rf = RestrictedMultiValueFields.valueOf(name); //noinspection ConstantConditions if (rf != null) { vr.setErrorDesc(name + "... is a restricted key for multi-value properties. Operation aborted."); vr.setErrorCode(523); vr.setObject(null); } } catch (Throwable t) { //no-op } return vr; }
[ "ValidationResult", "cleanMultiValuePropertyKey", "(", "String", "name", ")", "{", "ValidationResult", "vr", "=", "cleanObjectKey", "(", "name", ")", ";", "name", "=", "(", "String", ")", "vr", ".", "getObject", "(", ")", ";", "// make sure its not a known property key (reserved in the case of multi-value)", "try", "{", "RestrictedMultiValueFields", "rf", "=", "RestrictedMultiValueFields", ".", "valueOf", "(", "name", ")", ";", "//noinspection ConstantConditions", "if", "(", "rf", "!=", "null", ")", "{", "vr", ".", "setErrorDesc", "(", "name", "+", "\"... is a restricted key for multi-value properties. Operation aborted.\"", ")", ";", "vr", ".", "setErrorCode", "(", "523", ")", ";", "vr", ".", "setObject", "(", "null", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "//no-op", "}", "return", "vr", ";", "}" ]
Cleans a multi-value property key. @param name Name of the property key @return The {@link ValidationResult} object containing the key, and the error code(if any) <p/> First calls cleanObjectKey Known property keys are reserved for multi-value properties, subsequent validation is done for those
[ "Cleans", "a", "multi", "-", "value", "property", "key", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L102-L122
164,296
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java
Validator.isRestrictedEventName
ValidationResult isRestrictedEventName(String name) { ValidationResult error = new ValidationResult(); if (name == null) { error.setErrorCode(510); error.setErrorDesc("Event Name is null"); return error; } for (String x : restrictedNames) if (name.equalsIgnoreCase(x)) { // The event name is restricted error.setErrorCode(513); error.setErrorDesc(name + " is a restricted event name. Last event aborted."); Logger.v(name + " is a restricted system event name. Last event aborted."); return error; } return error; }
java
ValidationResult isRestrictedEventName(String name) { ValidationResult error = new ValidationResult(); if (name == null) { error.setErrorCode(510); error.setErrorDesc("Event Name is null"); return error; } for (String x : restrictedNames) if (name.equalsIgnoreCase(x)) { // The event name is restricted error.setErrorCode(513); error.setErrorDesc(name + " is a restricted event name. Last event aborted."); Logger.v(name + " is a restricted system event name. Last event aborted."); return error; } return error; }
[ "ValidationResult", "isRestrictedEventName", "(", "String", "name", ")", "{", "ValidationResult", "error", "=", "new", "ValidationResult", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "error", ".", "setErrorCode", "(", "510", ")", ";", "error", ".", "setErrorDesc", "(", "\"Event Name is null\"", ")", ";", "return", "error", ";", "}", "for", "(", "String", "x", ":", "restrictedNames", ")", "if", "(", "name", ".", "equalsIgnoreCase", "(", "x", ")", ")", "{", "// The event name is restricted", "error", ".", "setErrorCode", "(", "513", ")", ";", "error", ".", "setErrorDesc", "(", "name", "+", "\" is a restricted event name. Last event aborted.\"", ")", ";", "Logger", ".", "v", "(", "name", "+", "\" is a restricted system event name. Last event aborted.\"", ")", ";", "return", "error", ";", "}", "return", "error", ";", "}" ]
Checks whether the specified event name is restricted. If it is, then create a pending error, and abort. @param name The event name @return Boolean indication whether the event name is restricted
[ "Checks", "whether", "the", "specified", "event", "name", "is", "restricted", ".", "If", "it", "is", "then", "create", "a", "pending", "error", "and", "abort", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L290-L307
164,297
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java
Validator._mergeListInternalForKey
private ValidationResult _mergeListInternalForKey(String key, JSONArray left, JSONArray right, boolean remove, ValidationResult vr) { if (left == null) { vr.setObject(null); return vr; } if (right == null) { vr.setObject(left); return vr; } int maxValNum = Constants.MAX_MULTI_VALUE_ARRAY_LENGTH; JSONArray mergedList = new JSONArray(); HashSet<String> set = new HashSet<>(); int lsize = left.length(), rsize = right.length(); BitSet dupSetForAdd = null; if (!remove) dupSetForAdd = new BitSet(lsize + rsize); int lidx = 0; int ridx = scan(right, set, dupSetForAdd, lsize); if (!remove && set.size() < maxValNum) { lidx = scan(left, set, dupSetForAdd, 0); } for (int i = lidx; i < lsize; i++) { try { if (remove) { String _j = (String) left.get(i); if (!set.contains(_j)) { mergedList.put(_j); } } else if (!dupSetForAdd.get(i)) { mergedList.put(left.get(i)); } } catch (Throwable t) { //no-op } } if (!remove && mergedList.length() < maxValNum) { for (int i = ridx; i < rsize; i++) { try { if (!dupSetForAdd.get(i + lsize)) { mergedList.put(right.get(i)); } } catch (Throwable t) { //no-op } } } // check to see if the list got trimmed in the merge if (ridx > 0 || lidx > 0) { vr.setErrorDesc("Multi value property for key " + key + " exceeds the limit of " + maxValNum + " items. Trimmed"); vr.setErrorCode(521); } vr.setObject(mergedList); return vr; }
java
private ValidationResult _mergeListInternalForKey(String key, JSONArray left, JSONArray right, boolean remove, ValidationResult vr) { if (left == null) { vr.setObject(null); return vr; } if (right == null) { vr.setObject(left); return vr; } int maxValNum = Constants.MAX_MULTI_VALUE_ARRAY_LENGTH; JSONArray mergedList = new JSONArray(); HashSet<String> set = new HashSet<>(); int lsize = left.length(), rsize = right.length(); BitSet dupSetForAdd = null; if (!remove) dupSetForAdd = new BitSet(lsize + rsize); int lidx = 0; int ridx = scan(right, set, dupSetForAdd, lsize); if (!remove && set.size() < maxValNum) { lidx = scan(left, set, dupSetForAdd, 0); } for (int i = lidx; i < lsize; i++) { try { if (remove) { String _j = (String) left.get(i); if (!set.contains(_j)) { mergedList.put(_j); } } else if (!dupSetForAdd.get(i)) { mergedList.put(left.get(i)); } } catch (Throwable t) { //no-op } } if (!remove && mergedList.length() < maxValNum) { for (int i = ridx; i < rsize; i++) { try { if (!dupSetForAdd.get(i + lsize)) { mergedList.put(right.get(i)); } } catch (Throwable t) { //no-op } } } // check to see if the list got trimmed in the merge if (ridx > 0 || lidx > 0) { vr.setErrorDesc("Multi value property for key " + key + " exceeds the limit of " + maxValNum + " items. Trimmed"); vr.setErrorCode(521); } vr.setObject(mergedList); return vr; }
[ "private", "ValidationResult", "_mergeListInternalForKey", "(", "String", "key", ",", "JSONArray", "left", ",", "JSONArray", "right", ",", "boolean", "remove", ",", "ValidationResult", "vr", ")", "{", "if", "(", "left", "==", "null", ")", "{", "vr", ".", "setObject", "(", "null", ")", ";", "return", "vr", ";", "}", "if", "(", "right", "==", "null", ")", "{", "vr", ".", "setObject", "(", "left", ")", ";", "return", "vr", ";", "}", "int", "maxValNum", "=", "Constants", ".", "MAX_MULTI_VALUE_ARRAY_LENGTH", ";", "JSONArray", "mergedList", "=", "new", "JSONArray", "(", ")", ";", "HashSet", "<", "String", ">", "set", "=", "new", "HashSet", "<>", "(", ")", ";", "int", "lsize", "=", "left", ".", "length", "(", ")", ",", "rsize", "=", "right", ".", "length", "(", ")", ";", "BitSet", "dupSetForAdd", "=", "null", ";", "if", "(", "!", "remove", ")", "dupSetForAdd", "=", "new", "BitSet", "(", "lsize", "+", "rsize", ")", ";", "int", "lidx", "=", "0", ";", "int", "ridx", "=", "scan", "(", "right", ",", "set", ",", "dupSetForAdd", ",", "lsize", ")", ";", "if", "(", "!", "remove", "&&", "set", ".", "size", "(", ")", "<", "maxValNum", ")", "{", "lidx", "=", "scan", "(", "left", ",", "set", ",", "dupSetForAdd", ",", "0", ")", ";", "}", "for", "(", "int", "i", "=", "lidx", ";", "i", "<", "lsize", ";", "i", "++", ")", "{", "try", "{", "if", "(", "remove", ")", "{", "String", "_j", "=", "(", "String", ")", "left", ".", "get", "(", "i", ")", ";", "if", "(", "!", "set", ".", "contains", "(", "_j", ")", ")", "{", "mergedList", ".", "put", "(", "_j", ")", ";", "}", "}", "else", "if", "(", "!", "dupSetForAdd", ".", "get", "(", "i", ")", ")", "{", "mergedList", ".", "put", "(", "left", ".", "get", "(", "i", ")", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "//no-op", "}", "}", "if", "(", "!", "remove", "&&", "mergedList", ".", "length", "(", ")", "<", "maxValNum", ")", "{", "for", "(", "int", "i", "=", "ridx", ";", "i", "<", "rsize", ";", "i", "++", ")", "{", "try", "{", "if", "(", "!", "dupSetForAdd", ".", "get", "(", "i", "+", "lsize", ")", ")", "{", "mergedList", ".", "put", "(", "right", ".", "get", "(", "i", ")", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "//no-op", "}", "}", "}", "// check to see if the list got trimmed in the merge", "if", "(", "ridx", ">", "0", "||", "lidx", ">", "0", ")", "{", "vr", ".", "setErrorDesc", "(", "\"Multi value property for key \"", "+", "key", "+", "\" exceeds the limit of \"", "+", "maxValNum", "+", "\" items. Trimmed\"", ")", ";", "vr", ".", "setErrorCode", "(", "521", ")", ";", "}", "vr", ".", "setObject", "(", "mergedList", ")", ";", "return", "vr", ";", "}" ]
scans right to left until max to maintain latest max values for the multi-value property specified by key. @param key the property key @param left original list @param right new list @param remove if remove new list from original @param vr ValidationResult for error and merged list return
[ "scans", "right", "to", "left", "until", "max", "to", "maintain", "latest", "max", "values", "for", "the", "multi", "-", "value", "property", "specified", "by", "key", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L321-L395
164,298
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DeviceInfo.java
DeviceInfo.initDeviceID
@SuppressWarnings({"WeakerAccess"}) protected void initDeviceID() { getDeviceCachedInfo(); // put this here to avoid running on main thread // generate a provisional while we do the rest async generateProvisionalGUID(); // grab and cache the googleAdID in any event if available // if we already have a deviceID we won't user ad id as the guid cacheGoogleAdID(); // if we already have a device ID use it and just notify // otherwise generate one, either from ad id if available or the provisional String deviceID = getDeviceID(); if (deviceID == null || deviceID.trim().length() <= 2) { generateDeviceID(); } }
java
@SuppressWarnings({"WeakerAccess"}) protected void initDeviceID() { getDeviceCachedInfo(); // put this here to avoid running on main thread // generate a provisional while we do the rest async generateProvisionalGUID(); // grab and cache the googleAdID in any event if available // if we already have a deviceID we won't user ad id as the guid cacheGoogleAdID(); // if we already have a device ID use it and just notify // otherwise generate one, either from ad id if available or the provisional String deviceID = getDeviceID(); if (deviceID == null || deviceID.trim().length() <= 2) { generateDeviceID(); } }
[ "@", "SuppressWarnings", "(", "{", "\"WeakerAccess\"", "}", ")", "protected", "void", "initDeviceID", "(", ")", "{", "getDeviceCachedInfo", "(", ")", ";", "// put this here to avoid running on main thread", "// generate a provisional while we do the rest async", "generateProvisionalGUID", "(", ")", ";", "// grab and cache the googleAdID in any event if available", "// if we already have a deviceID we won't user ad id as the guid", "cacheGoogleAdID", "(", ")", ";", "// if we already have a device ID use it and just notify", "// otherwise generate one, either from ad id if available or the provisional", "String", "deviceID", "=", "getDeviceID", "(", ")", ";", "if", "(", "deviceID", "==", "null", "||", "deviceID", ".", "trim", "(", ")", ".", "length", "(", ")", "<=", "2", ")", "{", "generateDeviceID", "(", ")", ";", "}", "}" ]
don't run on main thread
[ "don", "t", "run", "on", "main", "thread" ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DeviceInfo.java#L78-L95
164,299
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Logger.java
Logger.i
static void i(String message){ if (getStaticDebugLevel() >= CleverTapAPI.LogLevel.INFO.intValue()){ Log.i(Constants.CLEVERTAP_LOG_TAG,message); } }
java
static void i(String message){ if (getStaticDebugLevel() >= CleverTapAPI.LogLevel.INFO.intValue()){ Log.i(Constants.CLEVERTAP_LOG_TAG,message); } }
[ "static", "void", "i", "(", "String", "message", ")", "{", "if", "(", "getStaticDebugLevel", "(", ")", ">=", "CleverTapAPI", ".", "LogLevel", ".", "INFO", ".", "intValue", "(", ")", ")", "{", "Log", ".", "i", "(", "Constants", ".", "CLEVERTAP_LOG_TAG", ",", "message", ")", ";", "}", "}" ]
Logs to Info if the debug level is greater than or equal to 1.
[ "Logs", "to", "Info", "if", "the", "debug", "level", "is", "greater", "than", "or", "equal", "to", "1", "." ]
be134c06a4f07494c398335ad9ff4976633743e1
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Logger.java#L114-L118