id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
7,500
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.getUnsignedIntegerAsLong
public Long getUnsignedIntegerAsLong (int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.UINT); if (tuple == null) { return null; } return (Long) tuple.value; }
java
public Long getUnsignedIntegerAsLong (int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.UINT); if (tuple == null) { return null; } return (Long) tuple.value; }
[ "public", "Long", "getUnsignedIntegerAsLong", "(", "int", "key", ")", "{", "PebbleTuple", "tuple", "=", "getTuple", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "UINT", ")", ";", "if", "(", "tuple", "==", "null", ")", "{", "return", "null", ";", "}", "return", "(", "Long", ")", "tuple", ".", "value", ";", "}" ]
Returns the unsigned integer as a long to which the specified key is mapped, or null if the key does not exist in this dictionary. We are using the Long type here so that we can remove the guava dependency. This is done so that we dont have incompatibility issues with the UnsignedInteger class from the Holo application, which uses a newer version of Guava. @param key key whose associated value is to be returned @return value to which the specified key is mapped
[ "Returns", "the", "unsigned", "integer", "as", "a", "long", "to", "which", "the", "specified", "key", "is", "mapped", "or", "null", "if", "the", "key", "does", "not", "exist", "in", "this", "dictionary", ".", "We", "are", "using", "the", "Long", "type", "here", "so", "that", "we", "can", "remove", "the", "guava", "dependency", ".", "This", "is", "done", "so", "that", "we", "dont", "have", "incompatibility", "issues", "with", "the", "UnsignedInteger", "class", "from", "the", "Holo", "application", "which", "uses", "a", "newer", "version", "of", "Guava", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L221-L227
7,501
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.getBytes
public byte[] getBytes(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.BYTES); if (tuple == null) { return null; } return (byte[]) tuple.value; }
java
public byte[] getBytes(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.BYTES); if (tuple == null) { return null; } return (byte[]) tuple.value; }
[ "public", "byte", "[", "]", "getBytes", "(", "int", "key", ")", "{", "PebbleTuple", "tuple", "=", "getTuple", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "BYTES", ")", ";", "if", "(", "tuple", "==", "null", ")", "{", "return", "null", ";", "}", "return", "(", "byte", "[", "]", ")", "tuple", ".", "value", ";", "}" ]
Returns the byte array to which the specified key is mapped, or null if the key does not exist in this dictionary. @param key key whose associated value is to be returned @return value to which the specified key is mapped
[ "Returns", "the", "byte", "array", "to", "which", "the", "specified", "key", "is", "mapped", "or", "null", "if", "the", "key", "does", "not", "exist", "in", "this", "dictionary", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L238-L244
7,502
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.getString
public String getString(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.STRING); if (tuple == null) { return null; } return (String) tuple.value; }
java
public String getString(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.STRING); if (tuple == null) { return null; } return (String) tuple.value; }
[ "public", "String", "getString", "(", "int", "key", ")", "{", "PebbleTuple", "tuple", "=", "getTuple", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "STRING", ")", ";", "if", "(", "tuple", "==", "null", ")", "{", "return", "null", ";", "}", "return", "(", "String", ")", "tuple", ".", "value", ";", "}" ]
Returns the string to which the specified key is mapped, or null if the key does not exist in this dictionary. @param key key whose associated value is to be returned @return value to which the specified key is mapped
[ "Returns", "the", "string", "to", "which", "the", "specified", "key", "is", "mapped", "or", "null", "if", "the", "key", "does", "not", "exist", "in", "this", "dictionary", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L254-L260
7,503
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.toJsonString
public String toJsonString() { try { JSONArray array = new JSONArray(); for (PebbleTuple t : tuples.values()) { array.put(serializeTuple(t)); } return array.toString(); } catch (JSONException je) { je.printStackTrace(); } return null; }
java
public String toJsonString() { try { JSONArray array = new JSONArray(); for (PebbleTuple t : tuples.values()) { array.put(serializeTuple(t)); } return array.toString(); } catch (JSONException je) { je.printStackTrace(); } return null; }
[ "public", "String", "toJsonString", "(", ")", "{", "try", "{", "JSONArray", "array", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "PebbleTuple", "t", ":", "tuples", ".", "values", "(", ")", ")", "{", "array", ".", "put", "(", "serializeTuple", "(", "t", ")", ")", ";", "}", "return", "array", ".", "toString", "(", ")", ";", "}", "catch", "(", "JSONException", "je", ")", "{", "je", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns a JSON representation of this dictionary. @return a JSON representation of this dictionary
[ "Returns", "a", "JSON", "representation", "of", "this", "dictionary", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L288-L299
7,504
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.fromJson
public static PebbleDictionary fromJson(String jsonString) throws JSONException { PebbleDictionary d = new PebbleDictionary(); JSONArray elements = new JSONArray(jsonString); for (int idx = 0; idx < elements.length(); ++idx) { JSONObject o = elements.getJSONObject(idx); final int key = o.getInt(KEY); final PebbleTuple.TupleType type = PebbleTuple.TYPE_NAMES.get(o.getString(TYPE)); final PebbleTuple.Width width = PebbleTuple.WIDTH_MAP.get(o.getInt(LENGTH)); switch (type) { case BYTES: byte[] bytes = Base64.decode(o.getString(VALUE), Base64.NO_WRAP); d.addBytes(key, bytes); break; case STRING: d.addString(key, o.getString(VALUE)); break; case INT: if (width == PebbleTuple.Width.BYTE) { d.addInt8(key, (byte) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.SHORT) { d.addInt16(key, (short) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.WORD) { d.addInt32(key, o.getInt(VALUE)); } break; case UINT: if (width == PebbleTuple.Width.BYTE) { d.addUint8(key, (byte) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.SHORT) { d.addUint16(key, (short) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.WORD) { d.addUint32(key, o.getInt(VALUE)); } break; } } return d; }
java
public static PebbleDictionary fromJson(String jsonString) throws JSONException { PebbleDictionary d = new PebbleDictionary(); JSONArray elements = new JSONArray(jsonString); for (int idx = 0; idx < elements.length(); ++idx) { JSONObject o = elements.getJSONObject(idx); final int key = o.getInt(KEY); final PebbleTuple.TupleType type = PebbleTuple.TYPE_NAMES.get(o.getString(TYPE)); final PebbleTuple.Width width = PebbleTuple.WIDTH_MAP.get(o.getInt(LENGTH)); switch (type) { case BYTES: byte[] bytes = Base64.decode(o.getString(VALUE), Base64.NO_WRAP); d.addBytes(key, bytes); break; case STRING: d.addString(key, o.getString(VALUE)); break; case INT: if (width == PebbleTuple.Width.BYTE) { d.addInt8(key, (byte) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.SHORT) { d.addInt16(key, (short) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.WORD) { d.addInt32(key, o.getInt(VALUE)); } break; case UINT: if (width == PebbleTuple.Width.BYTE) { d.addUint8(key, (byte) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.SHORT) { d.addUint16(key, (short) o.getInt(VALUE)); } else if (width == PebbleTuple.Width.WORD) { d.addUint32(key, o.getInt(VALUE)); } break; } } return d; }
[ "public", "static", "PebbleDictionary", "fromJson", "(", "String", "jsonString", ")", "throws", "JSONException", "{", "PebbleDictionary", "d", "=", "new", "PebbleDictionary", "(", ")", ";", "JSONArray", "elements", "=", "new", "JSONArray", "(", "jsonString", ")", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "elements", ".", "length", "(", ")", ";", "++", "idx", ")", "{", "JSONObject", "o", "=", "elements", ".", "getJSONObject", "(", "idx", ")", ";", "final", "int", "key", "=", "o", ".", "getInt", "(", "KEY", ")", ";", "final", "PebbleTuple", ".", "TupleType", "type", "=", "PebbleTuple", ".", "TYPE_NAMES", ".", "get", "(", "o", ".", "getString", "(", "TYPE", ")", ")", ";", "final", "PebbleTuple", ".", "Width", "width", "=", "PebbleTuple", ".", "WIDTH_MAP", ".", "get", "(", "o", ".", "getInt", "(", "LENGTH", ")", ")", ";", "switch", "(", "type", ")", "{", "case", "BYTES", ":", "byte", "[", "]", "bytes", "=", "Base64", ".", "decode", "(", "o", ".", "getString", "(", "VALUE", ")", ",", "Base64", ".", "NO_WRAP", ")", ";", "d", ".", "addBytes", "(", "key", ",", "bytes", ")", ";", "break", ";", "case", "STRING", ":", "d", ".", "addString", "(", "key", ",", "o", ".", "getString", "(", "VALUE", ")", ")", ";", "break", ";", "case", "INT", ":", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "BYTE", ")", "{", "d", ".", "addInt8", "(", "key", ",", "(", "byte", ")", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "else", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "SHORT", ")", "{", "d", ".", "addInt16", "(", "key", ",", "(", "short", ")", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "else", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "WORD", ")", "{", "d", ".", "addInt32", "(", "key", ",", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "break", ";", "case", "UINT", ":", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "BYTE", ")", "{", "d", ".", "addUint8", "(", "key", ",", "(", "byte", ")", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "else", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "SHORT", ")", "{", "d", ".", "addUint16", "(", "key", ",", "(", "short", ")", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "else", "if", "(", "width", "==", "PebbleTuple", ".", "Width", ".", "WORD", ")", "{", "d", ".", "addUint32", "(", "key", ",", "o", ".", "getInt", "(", "VALUE", ")", ")", ";", "}", "break", ";", "}", "}", "return", "d", ";", "}" ]
Deserializes a JSON representation of a PebbleDictionary. @param jsonString the JSON representation to be deserialized @throws JSONException thrown if the specified JSON representation cannot be parsed
[ "Deserializes", "a", "JSON", "representation", "of", "a", "PebbleDictionary", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L310-L350
7,505
Minecrell/TerminalConsoleAppender
src/main/java/net/minecrell/terminalconsole/SimpleTerminalConsole.java
SimpleTerminalConsole.processInput
protected void processInput(String input) { String command = input.trim(); if (!command.isEmpty()) { runCommand(command); } }
java
protected void processInput(String input) { String command = input.trim(); if (!command.isEmpty()) { runCommand(command); } }
[ "protected", "void", "processInput", "(", "String", "input", ")", "{", "String", "command", "=", "input", ".", "trim", "(", ")", ";", "if", "(", "!", "command", ".", "isEmpty", "(", ")", ")", "{", "runCommand", "(", "command", ")", ";", "}", "}" ]
Process an input line entered through the console. <p>The default implementation trims leading and trailing whitespace from the input and skips execution if the command is empty.</p> @param input The input line
[ "Process", "an", "input", "line", "entered", "through", "the", "console", "." ]
a540454b397ee488993019fbcacc49b2d88f1752
https://github.com/Minecrell/TerminalConsoleAppender/blob/a540454b397ee488993019fbcacc49b2d88f1752/src/main/java/net/minecrell/terminalconsole/SimpleTerminalConsole.java#L83-L88
7,506
Minecrell/TerminalConsoleAppender
src/main/java/net/minecrell/terminalconsole/SimpleTerminalConsole.java
SimpleTerminalConsole.start
public void start() { try { final Terminal terminal = TerminalConsoleAppender.getTerminal(); if (terminal != null) { readCommands(terminal); } else { readCommands(System.in); } } catch (IOException e) { LogManager.getLogger("TerminalConsole").error("Failed to read console input", e); } }
java
public void start() { try { final Terminal terminal = TerminalConsoleAppender.getTerminal(); if (terminal != null) { readCommands(terminal); } else { readCommands(System.in); } } catch (IOException e) { LogManager.getLogger("TerminalConsole").error("Failed to read console input", e); } }
[ "public", "void", "start", "(", ")", "{", "try", "{", "final", "Terminal", "terminal", "=", "TerminalConsoleAppender", ".", "getTerminal", "(", ")", ";", "if", "(", "terminal", "!=", "null", ")", "{", "readCommands", "(", "terminal", ")", ";", "}", "else", "{", "readCommands", "(", "System", ".", "in", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LogManager", ".", "getLogger", "(", "\"TerminalConsole\"", ")", ".", "error", "(", "\"Failed to read console input\"", ",", "e", ")", ";", "}", "}" ]
Start reading commands from the console. <p>Note that this method won't return until one of the following conditions are met:</p> <ul> <li>{@link #isRunning()} returns {@code false}, indicating that the application is shutting down.</li> <li>{@link #shutdown()} is triggered by the user (e.g. due to pressing CTRL+C)</li> <li>The input stream is closed.</li> </ul>
[ "Start", "reading", "commands", "from", "the", "console", "." ]
a540454b397ee488993019fbcacc49b2d88f1752
https://github.com/Minecrell/TerminalConsoleAppender/blob/a540454b397ee488993019fbcacc49b2d88f1752/src/main/java/net/minecrell/terminalconsole/SimpleTerminalConsole.java#L136-L147
7,507
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java
SportsState.setPaceInSec
public void setPaceInSec(int paceInSec) { this.speed = null; this.paceInSec = Math.max(0, Math.min(paceInSec, 3599)); }
java
public void setPaceInSec(int paceInSec) { this.speed = null; this.paceInSec = Math.max(0, Math.min(paceInSec, 3599)); }
[ "public", "void", "setPaceInSec", "(", "int", "paceInSec", ")", "{", "this", ".", "speed", "=", "null", ";", "this", ".", "paceInSec", "=", "Math", ".", "max", "(", "0", ",", "Math", ".", "min", "(", "paceInSec", ",", "3599", ")", ")", ";", "}" ]
Set the current pace in seconds per kilometer or seconds per mile. The possible range is currently limited from 0 to 3599, inclusive (59min 59sec). Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively. It will be presented as a duration string in the UI. Minutes and seconds will be separated by colons. Currently pace and speed cannot be presented at the same time. Setting speed will discard the value set through pace. @param paceInSec The pace to set, in seconds per kilometer or seconds per mile.
[ "Set", "the", "current", "pace", "in", "seconds", "per", "kilometer", "or", "seconds", "per", "mile", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java#L110-L113
7,508
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java
SportsState.setSpeed
public void setSpeed(float speed) { this.paceInSec = null; this.speed = Math.max(0, Math.min(speed, 99.9)); }
java
public void setSpeed(float speed) { this.paceInSec = null; this.speed = Math.max(0, Math.min(speed, 99.9)); }
[ "public", "void", "setSpeed", "(", "float", "speed", ")", "{", "this", ".", "paceInSec", "=", "null", ";", "this", ".", "speed", "=", "Math", ".", "max", "(", "0", ",", "Math", ".", "min", "(", "speed", ",", "99.9", ")", ")", ";", "}" ]
Set the current speed in kilometers per hour or miles per hour. The possible range is currently limited from 0 to 99.9, inclusive. Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively. It will be presented as a decimal number in the UI. The decimal part will be rounded to one digit. Currently pace and speed cannot be presented at the same time. Setting pace will discard the value set through speed. @param speed The current speed to set, in kilometers per hour or miles per hour.
[ "Set", "the", "current", "speed", "in", "kilometers", "per", "hour", "or", "miles", "per", "hour", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java#L143-L146
7,509
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java
SportsState.synchronize
public void synchronize(final Context context) { SportsState previousState = this.previousState; boolean firstMessage = false; if (previousState == null) { previousState = this.previousState = new SportsState(); firstMessage = true; } PebbleDictionary message = new PebbleDictionary(); if (getTimeInSec() != previousState.getTimeInSec() || firstMessage) { previousState.setTimeInSec(getTimeInSec()); message.addString(Constants.SPORTS_TIME_KEY, convertSecondsToString(getTimeInSec())); } if (getDistance() != previousState.getDistance() || firstMessage) { previousState.setDistance(getDistance()); message.addString(Constants.SPORTS_DISTANCE_KEY, convertDistanceToString(getDistance())); } if (this.paceInSec != null) { message.addUint8(Constants.SPORTS_LABEL_KEY, (byte)Constants.SPORTS_DATA_PACE); if (getPaceInSec() != previousState.getPaceInSec()) { previousState.setPaceInSec(getPaceInSec()); message.addString(Constants.SPORTS_DATA_KEY, convertSecondsToString(getPaceInSec())); } } if (this.speed != null) { message.addUint8(Constants.SPORTS_LABEL_KEY, (byte)Constants.SPORTS_DATA_SPEED); if (getSpeed() != previousState.getSpeed()) { previousState.setSpeed(getSpeed()); message.addString(Constants.SPORTS_DATA_KEY, convertDistanceToString(getSpeed())); } } if (this.heartBPM != null) { if (getHeartBPM() != previousState.getHeartBPM()) { previousState.setHeartBPM(getHeartBPM()); message.addUint8(Constants.SPORTS_HR_BPM_KEY, getHeartBPM()); } } if (getCustomLabel() != null && getCustomValue() != null) { if (!getCustomLabel().equals(previousState.getCustomLabel())) { previousState.setCustomLabel(getCustomLabel()); message.addString(Constants.SPORTS_CUSTOM_LABEL_KEY, getCustomLabel()); } if (!getCustomValue().equals(previousState.getCustomValue())) { previousState.setCustomValue(getCustomValue()); message.addString(Constants.SPORTS_CUSTOM_VALUE_KEY, getCustomValue()); } } PebbleKit.sendDataToPebble(context, Constants.SPORTS_UUID, message); }
java
public void synchronize(final Context context) { SportsState previousState = this.previousState; boolean firstMessage = false; if (previousState == null) { previousState = this.previousState = new SportsState(); firstMessage = true; } PebbleDictionary message = new PebbleDictionary(); if (getTimeInSec() != previousState.getTimeInSec() || firstMessage) { previousState.setTimeInSec(getTimeInSec()); message.addString(Constants.SPORTS_TIME_KEY, convertSecondsToString(getTimeInSec())); } if (getDistance() != previousState.getDistance() || firstMessage) { previousState.setDistance(getDistance()); message.addString(Constants.SPORTS_DISTANCE_KEY, convertDistanceToString(getDistance())); } if (this.paceInSec != null) { message.addUint8(Constants.SPORTS_LABEL_KEY, (byte)Constants.SPORTS_DATA_PACE); if (getPaceInSec() != previousState.getPaceInSec()) { previousState.setPaceInSec(getPaceInSec()); message.addString(Constants.SPORTS_DATA_KEY, convertSecondsToString(getPaceInSec())); } } if (this.speed != null) { message.addUint8(Constants.SPORTS_LABEL_KEY, (byte)Constants.SPORTS_DATA_SPEED); if (getSpeed() != previousState.getSpeed()) { previousState.setSpeed(getSpeed()); message.addString(Constants.SPORTS_DATA_KEY, convertDistanceToString(getSpeed())); } } if (this.heartBPM != null) { if (getHeartBPM() != previousState.getHeartBPM()) { previousState.setHeartBPM(getHeartBPM()); message.addUint8(Constants.SPORTS_HR_BPM_KEY, getHeartBPM()); } } if (getCustomLabel() != null && getCustomValue() != null) { if (!getCustomLabel().equals(previousState.getCustomLabel())) { previousState.setCustomLabel(getCustomLabel()); message.addString(Constants.SPORTS_CUSTOM_LABEL_KEY, getCustomLabel()); } if (!getCustomValue().equals(previousState.getCustomValue())) { previousState.setCustomValue(getCustomValue()); message.addString(Constants.SPORTS_CUSTOM_VALUE_KEY, getCustomValue()); } } PebbleKit.sendDataToPebble(context, Constants.SPORTS_UUID, message); }
[ "public", "void", "synchronize", "(", "final", "Context", "context", ")", "{", "SportsState", "previousState", "=", "this", ".", "previousState", ";", "boolean", "firstMessage", "=", "false", ";", "if", "(", "previousState", "==", "null", ")", "{", "previousState", "=", "this", ".", "previousState", "=", "new", "SportsState", "(", ")", ";", "firstMessage", "=", "true", ";", "}", "PebbleDictionary", "message", "=", "new", "PebbleDictionary", "(", ")", ";", "if", "(", "getTimeInSec", "(", ")", "!=", "previousState", ".", "getTimeInSec", "(", ")", "||", "firstMessage", ")", "{", "previousState", ".", "setTimeInSec", "(", "getTimeInSec", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_TIME_KEY", ",", "convertSecondsToString", "(", "getTimeInSec", "(", ")", ")", ")", ";", "}", "if", "(", "getDistance", "(", ")", "!=", "previousState", ".", "getDistance", "(", ")", "||", "firstMessage", ")", "{", "previousState", ".", "setDistance", "(", "getDistance", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_DISTANCE_KEY", ",", "convertDistanceToString", "(", "getDistance", "(", ")", ")", ")", ";", "}", "if", "(", "this", ".", "paceInSec", "!=", "null", ")", "{", "message", ".", "addUint8", "(", "Constants", ".", "SPORTS_LABEL_KEY", ",", "(", "byte", ")", "Constants", ".", "SPORTS_DATA_PACE", ")", ";", "if", "(", "getPaceInSec", "(", ")", "!=", "previousState", ".", "getPaceInSec", "(", ")", ")", "{", "previousState", ".", "setPaceInSec", "(", "getPaceInSec", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_DATA_KEY", ",", "convertSecondsToString", "(", "getPaceInSec", "(", ")", ")", ")", ";", "}", "}", "if", "(", "this", ".", "speed", "!=", "null", ")", "{", "message", ".", "addUint8", "(", "Constants", ".", "SPORTS_LABEL_KEY", ",", "(", "byte", ")", "Constants", ".", "SPORTS_DATA_SPEED", ")", ";", "if", "(", "getSpeed", "(", ")", "!=", "previousState", ".", "getSpeed", "(", ")", ")", "{", "previousState", ".", "setSpeed", "(", "getSpeed", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_DATA_KEY", ",", "convertDistanceToString", "(", "getSpeed", "(", ")", ")", ")", ";", "}", "}", "if", "(", "this", ".", "heartBPM", "!=", "null", ")", "{", "if", "(", "getHeartBPM", "(", ")", "!=", "previousState", ".", "getHeartBPM", "(", ")", ")", "{", "previousState", ".", "setHeartBPM", "(", "getHeartBPM", "(", ")", ")", ";", "message", ".", "addUint8", "(", "Constants", ".", "SPORTS_HR_BPM_KEY", ",", "getHeartBPM", "(", ")", ")", ";", "}", "}", "if", "(", "getCustomLabel", "(", ")", "!=", "null", "&&", "getCustomValue", "(", ")", "!=", "null", ")", "{", "if", "(", "!", "getCustomLabel", "(", ")", ".", "equals", "(", "previousState", ".", "getCustomLabel", "(", ")", ")", ")", "{", "previousState", ".", "setCustomLabel", "(", "getCustomLabel", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_CUSTOM_LABEL_KEY", ",", "getCustomLabel", "(", ")", ")", ";", "}", "if", "(", "!", "getCustomValue", "(", ")", ".", "equals", "(", "previousState", ".", "getCustomValue", "(", ")", ")", ")", "{", "previousState", ".", "setCustomValue", "(", "getCustomValue", "(", ")", ")", ";", "message", ".", "addString", "(", "Constants", ".", "SPORTS_CUSTOM_VALUE_KEY", ",", "getCustomValue", "(", ")", ")", ";", "}", "}", "PebbleKit", ".", "sendDataToPebble", "(", "context", ",", "Constants", ".", "SPORTS_UUID", ",", "message", ")", ";", "}" ]
Synchronizes the current state of the Sports App to the connected watch. The method tries to send the minimal set of changes since the last time the method was used, to try to minimize communication with the watch. @param context The context used to send the broadcast.
[ "Synchronizes", "the", "current", "state", "of", "the", "Sports", "App", "to", "the", "connected", "watch", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/SportsState.java#L240-L289
7,510
vinaysshenoy/mugen
library/src/main/java/com/mugen/attachers/BaseAttacher.java
BaseAttacher.start
public BaseAttacher start() { if(mAdapterView == null) { throw new IllegalStateException("Adapter View cannot be null"); } if(mMugenCallbacks == null) { throw new IllegalStateException("MugenCallbacks cannot be null"); } if(mLoadMoreOffset <= 0) { throw new IllegalStateException("Trigger Offset must be > 0"); } mIsLoadMoreEnabled = true; init(); return this; }
java
public BaseAttacher start() { if(mAdapterView == null) { throw new IllegalStateException("Adapter View cannot be null"); } if(mMugenCallbacks == null) { throw new IllegalStateException("MugenCallbacks cannot be null"); } if(mLoadMoreOffset <= 0) { throw new IllegalStateException("Trigger Offset must be > 0"); } mIsLoadMoreEnabled = true; init(); return this; }
[ "public", "BaseAttacher", "start", "(", ")", "{", "if", "(", "mAdapterView", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Adapter View cannot be null\"", ")", ";", "}", "if", "(", "mMugenCallbacks", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"MugenCallbacks cannot be null\"", ")", ";", "}", "if", "(", "mLoadMoreOffset", "<=", "0", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Trigger Offset must be > 0\"", ")", ";", "}", "mIsLoadMoreEnabled", "=", "true", ";", "init", "(", ")", ";", "return", "this", ";", "}" ]
Begin load more on the attached Adapter View @throws java.lang.IllegalStateException If any configuration is incorrect
[ "Begin", "load", "more", "on", "the", "attached", "Adapter", "View" ]
2ace4312c940fed6b82d221a6a7fbd8681e91e9e
https://github.com/vinaysshenoy/mugen/blob/2ace4312c940fed6b82d221a6a7fbd8681e91e9e/library/src/main/java/com/mugen/attachers/BaseAttacher.java#L126-L142
7,511
yandex-qatools/matchers-java
matcher-decorators/src/main/java/ru/yandex/qatools/matchers/decorators/MatcherDecorators.java
MatcherDecorators.should
public static <T> MatcherDecoratorsBuilder<T> should(final Matcher<? super T> matcher) { return MatcherDecoratorsBuilder.should(matcher); }
java
public static <T> MatcherDecoratorsBuilder<T> should(final Matcher<? super T> matcher) { return MatcherDecoratorsBuilder.should(matcher); }
[ "public", "static", "<", "T", ">", "MatcherDecoratorsBuilder", "<", "T", ">", "should", "(", "final", "Matcher", "<", "?", "super", "T", ">", "matcher", ")", "{", "return", "MatcherDecoratorsBuilder", ".", "should", "(", "matcher", ")", ";", "}" ]
Factory method for decorating matcher with action, condition or waiter. @param matcher Matcher to be decorated.
[ "Factory", "method", "for", "decorating", "matcher", "with", "action", "condition", "or", "waiter", "." ]
559fcc03fa568d4d293c9d82797df0c183edb55e
https://github.com/yandex-qatools/matchers-java/blob/559fcc03fa568d4d293c9d82797df0c183edb55e/matcher-decorators/src/main/java/ru/yandex/qatools/matchers/decorators/MatcherDecorators.java#L22-L24
7,512
thulab/iotdb-jdbc
src/main/java/cn/edu/tsinghua/iotdb/jdbc/TsfileQueryResultSet.java
TsfileQueryResultSet.nextWithoutLimit
private boolean nextWithoutLimit() throws SQLException { if (maxRows > 0 && rowsFetched >= maxRows) { System.out.println("Reach max rows " + maxRows); return false; } if ((recordItr == null || !recordItr.hasNext()) && !emptyResultSet) { TSFetchResultsReq req = new TSFetchResultsReq(sql, fetchSize); try { TSFetchResultsResp resp = client.fetchResults(req); Utils.verifySuccess(resp.getStatus()); if (!resp.hasResultSet) { emptyResultSet = true; } else { TSQueryDataSet tsQueryDataSet = resp.getQueryDataSet(); List<RowRecord> records = Utils.convertRowRecords(tsQueryDataSet); recordItr = records.iterator(); } } catch (TException e) { throw new SQLException("Cannot fetch result from server, because of network connection"); } } if (emptyResultSet) { return false; } record = recordItr.next(); // if(record.getDeltaObjectType() != null && // record.getDeltaObjectType().equals(AGGREGATION_STR)){ // if(columnInfo.containsKey(TIMESTAMP_STR)){ // columnInfo.remove(TIMESTAMP_STR); // } // } rowsFetched++; // maxRows is a constraint that exists in parallel with the LIMIT&SLIMIT constraints, // so rowsFetched will increase whenever the row is fetched, // regardless of whether the row satisfies the LIMIT&SLIMIT constraints or not. return true; }
java
private boolean nextWithoutLimit() throws SQLException { if (maxRows > 0 && rowsFetched >= maxRows) { System.out.println("Reach max rows " + maxRows); return false; } if ((recordItr == null || !recordItr.hasNext()) && !emptyResultSet) { TSFetchResultsReq req = new TSFetchResultsReq(sql, fetchSize); try { TSFetchResultsResp resp = client.fetchResults(req); Utils.verifySuccess(resp.getStatus()); if (!resp.hasResultSet) { emptyResultSet = true; } else { TSQueryDataSet tsQueryDataSet = resp.getQueryDataSet(); List<RowRecord> records = Utils.convertRowRecords(tsQueryDataSet); recordItr = records.iterator(); } } catch (TException e) { throw new SQLException("Cannot fetch result from server, because of network connection"); } } if (emptyResultSet) { return false; } record = recordItr.next(); // if(record.getDeltaObjectType() != null && // record.getDeltaObjectType().equals(AGGREGATION_STR)){ // if(columnInfo.containsKey(TIMESTAMP_STR)){ // columnInfo.remove(TIMESTAMP_STR); // } // } rowsFetched++; // maxRows is a constraint that exists in parallel with the LIMIT&SLIMIT constraints, // so rowsFetched will increase whenever the row is fetched, // regardless of whether the row satisfies the LIMIT&SLIMIT constraints or not. return true; }
[ "private", "boolean", "nextWithoutLimit", "(", ")", "throws", "SQLException", "{", "if", "(", "maxRows", ">", "0", "&&", "rowsFetched", ">=", "maxRows", ")", "{", "System", ".", "out", ".", "println", "(", "\"Reach max rows \"", "+", "maxRows", ")", ";", "return", "false", ";", "}", "if", "(", "(", "recordItr", "==", "null", "||", "!", "recordItr", ".", "hasNext", "(", ")", ")", "&&", "!", "emptyResultSet", ")", "{", "TSFetchResultsReq", "req", "=", "new", "TSFetchResultsReq", "(", "sql", ",", "fetchSize", ")", ";", "try", "{", "TSFetchResultsResp", "resp", "=", "client", ".", "fetchResults", "(", "req", ")", ";", "Utils", ".", "verifySuccess", "(", "resp", ".", "getStatus", "(", ")", ")", ";", "if", "(", "!", "resp", ".", "hasResultSet", ")", "{", "emptyResultSet", "=", "true", ";", "}", "else", "{", "TSQueryDataSet", "tsQueryDataSet", "=", "resp", ".", "getQueryDataSet", "(", ")", ";", "List", "<", "RowRecord", ">", "records", "=", "Utils", ".", "convertRowRecords", "(", "tsQueryDataSet", ")", ";", "recordItr", "=", "records", ".", "iterator", "(", ")", ";", "}", "}", "catch", "(", "TException", "e", ")", "{", "throw", "new", "SQLException", "(", "\"Cannot fetch result from server, because of network connection\"", ")", ";", "}", "}", "if", "(", "emptyResultSet", ")", "{", "return", "false", ";", "}", "record", "=", "recordItr", ".", "next", "(", ")", ";", "// if(record.getDeltaObjectType() != null &&", "// record.getDeltaObjectType().equals(AGGREGATION_STR)){", "// if(columnInfo.containsKey(TIMESTAMP_STR)){", "// columnInfo.remove(TIMESTAMP_STR);", "// }", "// }", "rowsFetched", "++", ";", "// maxRows is a constraint that exists in parallel with the LIMIT&SLIMIT constraints,", "// so rowsFetched will increase whenever the row is fetched,", "// regardless of whether the row satisfies the LIMIT&SLIMIT constraints or not.", "return", "true", ";", "}" ]
the next record rule without considering the LIMIT&SLIMIT constraints
[ "the", "next", "record", "rule", "without", "considering", "the", "LIMIT&SLIMIT", "constraints" ]
badd5b304fd628da9d69e621477769eeefe0870d
https://github.com/thulab/iotdb-jdbc/blob/badd5b304fd628da9d69e621477769eeefe0870d/src/main/java/cn/edu/tsinghua/iotdb/jdbc/TsfileQueryResultSet.java#L674-L715
7,513
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/impl/QueryAtomGroupImpl.java
QueryAtomGroupImpl.pop
public QueryAtomGroupImpl pop() { QueryAtomGroupImpl group = new QueryAtomGroupImpl(); boolean first = true; for (QueryAtom atom : atoms) { if (first) { first = false; } else { group.addAtom(atom); } } return group; }
java
public QueryAtomGroupImpl pop() { QueryAtomGroupImpl group = new QueryAtomGroupImpl(); boolean first = true; for (QueryAtom atom : atoms) { if (first) { first = false; } else { group.addAtom(atom); } } return group; }
[ "public", "QueryAtomGroupImpl", "pop", "(", ")", "{", "QueryAtomGroupImpl", "group", "=", "new", "QueryAtomGroupImpl", "(", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "QueryAtom", "atom", ":", "atoms", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "group", ".", "addAtom", "(", "atom", ")", ";", "}", "}", "return", "group", ";", "}" ]
A convenience method to clone the atom group instance and pop the first atom. Only the instance itself will be cloned not the atoms. @return A new query instance with the first atom removed.
[ "A", "convenience", "method", "to", "clone", "the", "atom", "group", "instance", "and", "pop", "the", "first", "atom", ".", "Only", "the", "instance", "itself", "will", "be", "cloned", "not", "the", "atoms", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/impl/QueryAtomGroupImpl.java#L74-L86
7,514
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/impl/QueryAtomGroupImpl.java
QueryAtomGroupImpl.bind
public QueryAtomGroupImpl bind(QueryBinding binding) { QueryAtomGroupImpl group = new QueryAtomGroupImpl(); for (QueryAtom atom : atoms) { group.addAtom(atom.bind(binding)); } return group; }
java
public QueryAtomGroupImpl bind(QueryBinding binding) { QueryAtomGroupImpl group = new QueryAtomGroupImpl(); for (QueryAtom atom : atoms) { group.addAtom(atom.bind(binding)); } return group; }
[ "public", "QueryAtomGroupImpl", "bind", "(", "QueryBinding", "binding", ")", "{", "QueryAtomGroupImpl", "group", "=", "new", "QueryAtomGroupImpl", "(", ")", ";", "for", "(", "QueryAtom", "atom", ":", "atoms", ")", "{", "group", ".", "addAtom", "(", "atom", ".", "bind", "(", "binding", ")", ")", ";", "}", "return", "group", ";", "}" ]
A convenience method to clone the atom group instance while inserting a new binding to all atoms of the group. The instance and the atoms will be cloned.
[ "A", "convenience", "method", "to", "clone", "the", "atom", "group", "instance", "while", "inserting", "a", "new", "binding", "to", "all", "atoms", "of", "the", "group", ".", "The", "instance", "and", "the", "atoms", "will", "be", "cloned", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/impl/QueryAtomGroupImpl.java#L93-L99
7,515
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/impl/QueryImpl.java
QueryImpl.addResultVar
public void addResultVar(QueryArgument arg) { if(arg.getType() == QueryArgumentType.VAR) { resultVars.add(arg); } }
java
public void addResultVar(QueryArgument arg) { if(arg.getType() == QueryArgumentType.VAR) { resultVars.add(arg); } }
[ "public", "void", "addResultVar", "(", "QueryArgument", "arg", ")", "{", "if", "(", "arg", ".", "getType", "(", ")", "==", "QueryArgumentType", ".", "VAR", ")", "{", "resultVars", ".", "add", "(", "arg", ")", ";", "}", "}" ]
Add a result variable to the query. @param arg QueryArgument has to be a variable.
[ "Add", "a", "result", "variable", "to", "the", "query", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/impl/QueryImpl.java#L52-L57
7,516
rhiot/rhiot
lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java
DefaultInstaller.isCommandInstalled
public boolean isCommandInstalled(String command, String failureMessage){ List<String> output = getProcessManager().executeAndJoinOutput(command); return output.size() > 0 && !output.get(0).contains(failureMessage); }
java
public boolean isCommandInstalled(String command, String failureMessage){ List<String> output = getProcessManager().executeAndJoinOutput(command); return output.size() > 0 && !output.get(0).contains(failureMessage); }
[ "public", "boolean", "isCommandInstalled", "(", "String", "command", ",", "String", "failureMessage", ")", "{", "List", "<", "String", ">", "output", "=", "getProcessManager", "(", ")", ".", "executeAndJoinOutput", "(", "command", ")", ";", "return", "output", ".", "size", "(", ")", ">", "0", "&&", "!", "output", ".", "get", "(", "0", ")", ".", "contains", "(", "failureMessage", ")", ";", "}" ]
True if the given command is installed in the shell, false otherwise. @param command eg brew, aptitude, sudo etc @param failureMessage the message expected upon failure. @return <tt>true</tt> if the given command is installed in the shell, false otherwise.
[ "True", "if", "the", "given", "command", "is", "installed", "in", "the", "shell", "false", "otherwise", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java#L82-L85
7,517
rhiot/rhiot
lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java
DefaultInstaller.confirmInstalled
public boolean confirmInstalled(String packageName, List<String> output){ if (output != null) { return output.stream().anyMatch(s -> s != null && s.contains(getInstallSuccess())); } else { return true; //may be successful } }
java
public boolean confirmInstalled(String packageName, List<String> output){ if (output != null) { return output.stream().anyMatch(s -> s != null && s.contains(getInstallSuccess())); } else { return true; //may be successful } }
[ "public", "boolean", "confirmInstalled", "(", "String", "packageName", ",", "List", "<", "String", ">", "output", ")", "{", "if", "(", "output", "!=", "null", ")", "{", "return", "output", ".", "stream", "(", ")", ".", "anyMatch", "(", "s", "->", "s", "!=", "null", "&&", "s", ".", "contains", "(", "getInstallSuccess", "(", ")", ")", ")", ";", "}", "else", "{", "return", "true", ";", "//may be successful", "}", "}" ]
Checks the output to confirm the package is installed. @param packageName package name, eg gpsd @param output result of the installation process @return returns true if the package is installed, false otherwise.
[ "Checks", "the", "output", "to", "confirm", "the", "package", "is", "installed", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java#L125-L131
7,518
rhiot/rhiot
lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java
DefaultInstaller.isPermissionDenied
protected boolean isPermissionDenied(List<String> output){ return output.stream().anyMatch(s -> s != null && s.contains(PERMISSION_DENIED_MESSAGE)); }
java
protected boolean isPermissionDenied(List<String> output){ return output.stream().anyMatch(s -> s != null && s.contains(PERMISSION_DENIED_MESSAGE)); }
[ "protected", "boolean", "isPermissionDenied", "(", "List", "<", "String", ">", "output", ")", "{", "return", "output", ".", "stream", "(", ")", ".", "anyMatch", "(", "s", "->", "s", "!=", "null", "&&", "s", ".", "contains", "(", "PERMISSION_DENIED_MESSAGE", ")", ")", ";", "}" ]
Returns true if permission was denied. @param output Output from the install/uninstall process. @return true if permission was denied.
[ "Returns", "true", "if", "permission", "was", "denied", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/lib/utils/src/main/java/io/rhiot/utils/install/DefaultInstaller.java#L183-L185
7,519
SahaginOrg/sahagin-java
src/main/java/org/sahagin/main/SahaginPreMain.java
SahaginPreMain.premain
public static void premain(String agentArgs, Instrumentation inst) throws YamlConvertException, IllegalTestScriptException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { String configFilePath; String propValue = System.getProperty("sahagin.configPath"); if (!StringUtils.isBlank(propValue)) { configFilePath = propValue; } else if (agentArgs != null) { // check agent argument for backward compatibility configFilePath = agentArgs; } else { configFilePath = "sahagin.yml"; } JavaConfig config = JavaConfig.generateFromYamlConfig(new File(configFilePath)); Logging.setLoggerEnabled(config.isOutputLog()); AcceptableLocales locales = AcceptableLocales.getInstance(config.getUserLocale()); JavaAdapterContainer.globalInitialize(locales, config.getTestFramework()); SysMessages.globalInitialize(locales); // default adapters new JavaSystemAdapter().initialSetAdapter(); new JUnit3Adapter().initialSetAdapter(); new JUnit4Adapter().initialSetAdapter(); new TestNGAdapter().initialSetAdapter(); new JavaLibAdapter().initialSetAdapter(); new WebDriverAdapter().initialSetAdapter(); new AppiumAdapter().initialSetAdapter(); new SelendroidAdapter().initialSetAdapter(); new IOSDriverAdapter().initialSetAdapter(); new FluentLeniumAdapter().initialSetAdapter(); for (String adapterClassName : config.getAdapterClassNames()) { // TODO handle exception thrown by forName or newInstance method // more appropriately Class<?> adapterClass = Class.forName(adapterClassName); assert adapterClass != null; Object adapterObj = adapterClass.newInstance(); assert adapterObj != null; assert adapterObj instanceof Adapter; Adapter adapter = (Adapter) adapterObj; adapter.initialSetAdapter(); } if (!JavaAdapterContainer.globalInstance().isRootMethodAdapterSet()) { throw new RuntimeException(String.format( MSG_TEST_FRAMEWORK_NOT_FOUND, config.getTestFramework())); } // delete previous data if (config.getRootBaseRunOutputIntermediateDataDir().exists()) { FileUtils.deleteDirectory(config.getRootBaseRunOutputIntermediateDataDir()); } SrcTree srcTree = generateAndDumpSrcTree(config, locales); RunResultsGenerateHookSetter transformer = new RunResultsGenerateHookSetter(configFilePath, srcTree); inst.addTransformer(transformer); }
java
public static void premain(String agentArgs, Instrumentation inst) throws YamlConvertException, IllegalTestScriptException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { String configFilePath; String propValue = System.getProperty("sahagin.configPath"); if (!StringUtils.isBlank(propValue)) { configFilePath = propValue; } else if (agentArgs != null) { // check agent argument for backward compatibility configFilePath = agentArgs; } else { configFilePath = "sahagin.yml"; } JavaConfig config = JavaConfig.generateFromYamlConfig(new File(configFilePath)); Logging.setLoggerEnabled(config.isOutputLog()); AcceptableLocales locales = AcceptableLocales.getInstance(config.getUserLocale()); JavaAdapterContainer.globalInitialize(locales, config.getTestFramework()); SysMessages.globalInitialize(locales); // default adapters new JavaSystemAdapter().initialSetAdapter(); new JUnit3Adapter().initialSetAdapter(); new JUnit4Adapter().initialSetAdapter(); new TestNGAdapter().initialSetAdapter(); new JavaLibAdapter().initialSetAdapter(); new WebDriverAdapter().initialSetAdapter(); new AppiumAdapter().initialSetAdapter(); new SelendroidAdapter().initialSetAdapter(); new IOSDriverAdapter().initialSetAdapter(); new FluentLeniumAdapter().initialSetAdapter(); for (String adapterClassName : config.getAdapterClassNames()) { // TODO handle exception thrown by forName or newInstance method // more appropriately Class<?> adapterClass = Class.forName(adapterClassName); assert adapterClass != null; Object adapterObj = adapterClass.newInstance(); assert adapterObj != null; assert adapterObj instanceof Adapter; Adapter adapter = (Adapter) adapterObj; adapter.initialSetAdapter(); } if (!JavaAdapterContainer.globalInstance().isRootMethodAdapterSet()) { throw new RuntimeException(String.format( MSG_TEST_FRAMEWORK_NOT_FOUND, config.getTestFramework())); } // delete previous data if (config.getRootBaseRunOutputIntermediateDataDir().exists()) { FileUtils.deleteDirectory(config.getRootBaseRunOutputIntermediateDataDir()); } SrcTree srcTree = generateAndDumpSrcTree(config, locales); RunResultsGenerateHookSetter transformer = new RunResultsGenerateHookSetter(configFilePath, srcTree); inst.addTransformer(transformer); }
[ "public", "static", "void", "premain", "(", "String", "agentArgs", ",", "Instrumentation", "inst", ")", "throws", "YamlConvertException", ",", "IllegalTestScriptException", ",", "IOException", ",", "ClassNotFoundException", ",", "InstantiationException", ",", "IllegalAccessException", "{", "String", "configFilePath", ";", "String", "propValue", "=", "System", ".", "getProperty", "(", "\"sahagin.configPath\"", ")", ";", "if", "(", "!", "StringUtils", ".", "isBlank", "(", "propValue", ")", ")", "{", "configFilePath", "=", "propValue", ";", "}", "else", "if", "(", "agentArgs", "!=", "null", ")", "{", "// check agent argument for backward compatibility", "configFilePath", "=", "agentArgs", ";", "}", "else", "{", "configFilePath", "=", "\"sahagin.yml\"", ";", "}", "JavaConfig", "config", "=", "JavaConfig", ".", "generateFromYamlConfig", "(", "new", "File", "(", "configFilePath", ")", ")", ";", "Logging", ".", "setLoggerEnabled", "(", "config", ".", "isOutputLog", "(", ")", ")", ";", "AcceptableLocales", "locales", "=", "AcceptableLocales", ".", "getInstance", "(", "config", ".", "getUserLocale", "(", ")", ")", ";", "JavaAdapterContainer", ".", "globalInitialize", "(", "locales", ",", "config", ".", "getTestFramework", "(", ")", ")", ";", "SysMessages", ".", "globalInitialize", "(", "locales", ")", ";", "// default adapters", "new", "JavaSystemAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "JUnit3Adapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "JUnit4Adapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "TestNGAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "JavaLibAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "WebDriverAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "AppiumAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "SelendroidAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "IOSDriverAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "new", "FluentLeniumAdapter", "(", ")", ".", "initialSetAdapter", "(", ")", ";", "for", "(", "String", "adapterClassName", ":", "config", ".", "getAdapterClassNames", "(", ")", ")", "{", "// TODO handle exception thrown by forName or newInstance method", "// more appropriately", "Class", "<", "?", ">", "adapterClass", "=", "Class", ".", "forName", "(", "adapterClassName", ")", ";", "assert", "adapterClass", "!=", "null", ";", "Object", "adapterObj", "=", "adapterClass", ".", "newInstance", "(", ")", ";", "assert", "adapterObj", "!=", "null", ";", "assert", "adapterObj", "instanceof", "Adapter", ";", "Adapter", "adapter", "=", "(", "Adapter", ")", "adapterObj", ";", "adapter", ".", "initialSetAdapter", "(", ")", ";", "}", "if", "(", "!", "JavaAdapterContainer", ".", "globalInstance", "(", ")", ".", "isRootMethodAdapterSet", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "MSG_TEST_FRAMEWORK_NOT_FOUND", ",", "config", ".", "getTestFramework", "(", ")", ")", ")", ";", "}", "// delete previous data", "if", "(", "config", ".", "getRootBaseRunOutputIntermediateDataDir", "(", ")", ".", "exists", "(", ")", ")", "{", "FileUtils", ".", "deleteDirectory", "(", "config", ".", "getRootBaseRunOutputIntermediateDataDir", "(", ")", ")", ";", "}", "SrcTree", "srcTree", "=", "generateAndDumpSrcTree", "(", "config", ",", "locales", ")", ";", "RunResultsGenerateHookSetter", "transformer", "=", "new", "RunResultsGenerateHookSetter", "(", "configFilePath", ",", "srcTree", ")", ";", "inst", ".", "addTransformer", "(", "transformer", ")", ";", "}" ]
agentArgs is configuration YAML file path
[ "agentArgs", "is", "configuration", "YAML", "file", "path" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/main/SahaginPreMain.java#L43-L99
7,520
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/LittleEndian.java
LittleEndian.getUInt16
public static int getUInt16(byte[] src, int offset) { final int v0 = src[offset + 0] & 0xFF; final int v1 = src[offset + 1] & 0xFF; return ((v1 << 8) | v0); }
java
public static int getUInt16(byte[] src, int offset) { final int v0 = src[offset + 0] & 0xFF; final int v1 = src[offset + 1] & 0xFF; return ((v1 << 8) | v0); }
[ "public", "static", "int", "getUInt16", "(", "byte", "[", "]", "src", ",", "int", "offset", ")", "{", "final", "int", "v0", "=", "src", "[", "offset", "+", "0", "]", "&", "0xFF", ";", "final", "int", "v1", "=", "src", "[", "offset", "+", "1", "]", "&", "0xFF", ";", "return", "(", "(", "v1", "<<", "8", ")", "|", "v0", ")", ";", "}" ]
Gets a 16-bit unsigned integer from the given byte array at the given offset. @param src @param offset
[ "Gets", "a", "16", "-", "bit", "unsigned", "integer", "from", "the", "given", "byte", "array", "at", "the", "given", "offset", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/LittleEndian.java#L50-L54
7,521
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/LittleEndian.java
LittleEndian.setInt16
public static void setInt16(byte[] dst, int offset, int value) { assert (value & 0xffff) == value : "value out of range"; dst[offset + 0] = (byte) (value & 0xFF); dst[offset + 1] = (byte) ((value >>> 8) & 0xFF); }
java
public static void setInt16(byte[] dst, int offset, int value) { assert (value & 0xffff) == value : "value out of range"; dst[offset + 0] = (byte) (value & 0xFF); dst[offset + 1] = (byte) ((value >>> 8) & 0xFF); }
[ "public", "static", "void", "setInt16", "(", "byte", "[", "]", "dst", ",", "int", "offset", ",", "int", "value", ")", "{", "assert", "(", "value", "&", "0xffff", ")", "==", "value", ":", "\"value out of range\"", ";", "dst", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "value", "&", "0xFF", ")", ";", "dst", "[", "offset", "+", "1", "]", "=", "(", "byte", ")", "(", "(", "value", ">>>", "8", ")", "&", "0xFF", ")", ";", "}" ]
Sets a 16-bit integer in the given byte array at the given offset.
[ "Sets", "a", "16", "-", "bit", "integer", "in", "the", "given", "byte", "array", "at", "the", "given", "offset", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/LittleEndian.java#L82-L87
7,522
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/LittleEndian.java
LittleEndian.setInt32
public static void setInt32(byte[] dst, int offset, long value) throws IllegalArgumentException { assert value <= Integer.MAX_VALUE : "value out of range"; dst[offset + 0] = (byte) (value & 0xFF); dst[offset + 1] = (byte) ((value >>> 8) & 0xFF); dst[offset + 2] = (byte) ((value >>> 16) & 0xFF); dst[offset + 3] = (byte) ((value >>> 24) & 0xFF); }
java
public static void setInt32(byte[] dst, int offset, long value) throws IllegalArgumentException { assert value <= Integer.MAX_VALUE : "value out of range"; dst[offset + 0] = (byte) (value & 0xFF); dst[offset + 1] = (byte) ((value >>> 8) & 0xFF); dst[offset + 2] = (byte) ((value >>> 16) & 0xFF); dst[offset + 3] = (byte) ((value >>> 24) & 0xFF); }
[ "public", "static", "void", "setInt32", "(", "byte", "[", "]", "dst", ",", "int", "offset", ",", "long", "value", ")", "throws", "IllegalArgumentException", "{", "assert", "value", "<=", "Integer", ".", "MAX_VALUE", ":", "\"value out of range\"", ";", "dst", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "value", "&", "0xFF", ")", ";", "dst", "[", "offset", "+", "1", "]", "=", "(", "byte", ")", "(", "(", "value", ">>>", "8", ")", "&", "0xFF", ")", ";", "dst", "[", "offset", "+", "2", "]", "=", "(", "byte", ")", "(", "(", "value", ">>>", "16", ")", "&", "0xFF", ")", ";", "dst", "[", "offset", "+", "3", "]", "=", "(", "byte", ")", "(", "(", "value", ">>>", "24", ")", "&", "0xFF", ")", ";", "}" ]
Sets a 32-bit integer in the given byte array at the given offset.
[ "Sets", "a", "32", "-", "bit", "integer", "in", "the", "given", "byte", "array", "at", "the", "given", "offset", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/LittleEndian.java#L92-L101
7,523
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/SuperFloppyFormatter.java
SuperFloppyFormatter.format
public FatFileSystem format() throws IOException { final int sectorSize = device.getSectorSize(); final int totalSectors = (int)(device.getSize() / sectorSize); final FsInfoSector fsi; final BootSector bs; if (sectorsPerCluster == 0) throw new AssertionError(); if (fatType == FatType.FAT32) { bs = new Fat32BootSector(device); initBootSector(bs); final Fat32BootSector f32bs = (Fat32BootSector) bs; f32bs.setFsInfoSectorNr(1); f32bs.setSectorsPerFat(sectorsPerFat(0, totalSectors)); final Random rnd = new Random(System.currentTimeMillis()); f32bs.setFileSystemId(rnd.nextInt()); f32bs.setVolumeLabel(label); /* create FS info sector */ fsi = FsInfoSector.create(f32bs); } else { bs = new Fat16BootSector(device); initBootSector(bs); final Fat16BootSector f16bs = (Fat16BootSector) bs; final int rootDirEntries = rootDirectorySize( device.getSectorSize(), totalSectors); f16bs.setRootDirEntryCount(rootDirEntries); f16bs.setSectorsPerFat(sectorsPerFat(rootDirEntries, totalSectors)); if (label != null) f16bs.setVolumeLabel(label); fsi = null; } final Fat fat = Fat.create(bs, 0); final AbstractDirectory rootDirStore; if (fatType == FatType.FAT32) { rootDirStore = ClusterChainDirectory.createRoot(fat); fsi.setFreeClusterCount(fat.getFreeClusterCount()); fsi.setLastAllocatedCluster(fat.getLastAllocatedCluster()); fsi.write(); } else { rootDirStore = Fat16RootDirectory.create((Fat16BootSector) bs); } final FatLfnDirectory rootDir = new FatLfnDirectory(rootDirStore, fat, false); rootDir.flush(); for (int i = 0; i < bs.getNrFats(); i++) { fat.writeCopy(bs.getFatOffset(i)); } bs.write(); /* possibly write boot sector copy */ if (fatType == FatType.FAT32) { Fat32BootSector f32bs = (Fat32BootSector) bs; f32bs.writeCopy(device); } FatFileSystem fs = FatFileSystem.read(device, false); if (label != null) { fs.setVolumeLabel(label); } fs.flush(); return fs; }
java
public FatFileSystem format() throws IOException { final int sectorSize = device.getSectorSize(); final int totalSectors = (int)(device.getSize() / sectorSize); final FsInfoSector fsi; final BootSector bs; if (sectorsPerCluster == 0) throw new AssertionError(); if (fatType == FatType.FAT32) { bs = new Fat32BootSector(device); initBootSector(bs); final Fat32BootSector f32bs = (Fat32BootSector) bs; f32bs.setFsInfoSectorNr(1); f32bs.setSectorsPerFat(sectorsPerFat(0, totalSectors)); final Random rnd = new Random(System.currentTimeMillis()); f32bs.setFileSystemId(rnd.nextInt()); f32bs.setVolumeLabel(label); /* create FS info sector */ fsi = FsInfoSector.create(f32bs); } else { bs = new Fat16BootSector(device); initBootSector(bs); final Fat16BootSector f16bs = (Fat16BootSector) bs; final int rootDirEntries = rootDirectorySize( device.getSectorSize(), totalSectors); f16bs.setRootDirEntryCount(rootDirEntries); f16bs.setSectorsPerFat(sectorsPerFat(rootDirEntries, totalSectors)); if (label != null) f16bs.setVolumeLabel(label); fsi = null; } final Fat fat = Fat.create(bs, 0); final AbstractDirectory rootDirStore; if (fatType == FatType.FAT32) { rootDirStore = ClusterChainDirectory.createRoot(fat); fsi.setFreeClusterCount(fat.getFreeClusterCount()); fsi.setLastAllocatedCluster(fat.getLastAllocatedCluster()); fsi.write(); } else { rootDirStore = Fat16RootDirectory.create((Fat16BootSector) bs); } final FatLfnDirectory rootDir = new FatLfnDirectory(rootDirStore, fat, false); rootDir.flush(); for (int i = 0; i < bs.getNrFats(); i++) { fat.writeCopy(bs.getFatOffset(i)); } bs.write(); /* possibly write boot sector copy */ if (fatType == FatType.FAT32) { Fat32BootSector f32bs = (Fat32BootSector) bs; f32bs.writeCopy(device); } FatFileSystem fs = FatFileSystem.read(device, false); if (label != null) { fs.setVolumeLabel(label); } fs.flush(); return fs; }
[ "public", "FatFileSystem", "format", "(", ")", "throws", "IOException", "{", "final", "int", "sectorSize", "=", "device", ".", "getSectorSize", "(", ")", ";", "final", "int", "totalSectors", "=", "(", "int", ")", "(", "device", ".", "getSize", "(", ")", "/", "sectorSize", ")", ";", "final", "FsInfoSector", "fsi", ";", "final", "BootSector", "bs", ";", "if", "(", "sectorsPerCluster", "==", "0", ")", "throw", "new", "AssertionError", "(", ")", ";", "if", "(", "fatType", "==", "FatType", ".", "FAT32", ")", "{", "bs", "=", "new", "Fat32BootSector", "(", "device", ")", ";", "initBootSector", "(", "bs", ")", ";", "final", "Fat32BootSector", "f32bs", "=", "(", "Fat32BootSector", ")", "bs", ";", "f32bs", ".", "setFsInfoSectorNr", "(", "1", ")", ";", "f32bs", ".", "setSectorsPerFat", "(", "sectorsPerFat", "(", "0", ",", "totalSectors", ")", ")", ";", "final", "Random", "rnd", "=", "new", "Random", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "f32bs", ".", "setFileSystemId", "(", "rnd", ".", "nextInt", "(", ")", ")", ";", "f32bs", ".", "setVolumeLabel", "(", "label", ")", ";", "/* create FS info sector */", "fsi", "=", "FsInfoSector", ".", "create", "(", "f32bs", ")", ";", "}", "else", "{", "bs", "=", "new", "Fat16BootSector", "(", "device", ")", ";", "initBootSector", "(", "bs", ")", ";", "final", "Fat16BootSector", "f16bs", "=", "(", "Fat16BootSector", ")", "bs", ";", "final", "int", "rootDirEntries", "=", "rootDirectorySize", "(", "device", ".", "getSectorSize", "(", ")", ",", "totalSectors", ")", ";", "f16bs", ".", "setRootDirEntryCount", "(", "rootDirEntries", ")", ";", "f16bs", ".", "setSectorsPerFat", "(", "sectorsPerFat", "(", "rootDirEntries", ",", "totalSectors", ")", ")", ";", "if", "(", "label", "!=", "null", ")", "f16bs", ".", "setVolumeLabel", "(", "label", ")", ";", "fsi", "=", "null", ";", "}", "final", "Fat", "fat", "=", "Fat", ".", "create", "(", "bs", ",", "0", ")", ";", "final", "AbstractDirectory", "rootDirStore", ";", "if", "(", "fatType", "==", "FatType", ".", "FAT32", ")", "{", "rootDirStore", "=", "ClusterChainDirectory", ".", "createRoot", "(", "fat", ")", ";", "fsi", ".", "setFreeClusterCount", "(", "fat", ".", "getFreeClusterCount", "(", ")", ")", ";", "fsi", ".", "setLastAllocatedCluster", "(", "fat", ".", "getLastAllocatedCluster", "(", ")", ")", ";", "fsi", ".", "write", "(", ")", ";", "}", "else", "{", "rootDirStore", "=", "Fat16RootDirectory", ".", "create", "(", "(", "Fat16BootSector", ")", "bs", ")", ";", "}", "final", "FatLfnDirectory", "rootDir", "=", "new", "FatLfnDirectory", "(", "rootDirStore", ",", "fat", ",", "false", ")", ";", "rootDir", ".", "flush", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bs", ".", "getNrFats", "(", ")", ";", "i", "++", ")", "{", "fat", ".", "writeCopy", "(", "bs", ".", "getFatOffset", "(", "i", ")", ")", ";", "}", "bs", ".", "write", "(", ")", ";", "/* possibly write boot sector copy */", "if", "(", "fatType", "==", "FatType", ".", "FAT32", ")", "{", "Fat32BootSector", "f32bs", "=", "(", "Fat32BootSector", ")", "bs", ";", "f32bs", ".", "writeCopy", "(", "device", ")", ";", "}", "FatFileSystem", "fs", "=", "FatFileSystem", ".", "read", "(", "device", ",", "false", ")", ";", "if", "(", "label", "!=", "null", ")", "{", "fs", ".", "setVolumeLabel", "(", "label", ")", ";", "}", "fs", ".", "flush", "(", ")", ";", "return", "fs", ";", "}" ]
Initializes the boot sector and file system for the device. The file system created by this method will always be in read-write mode. @return the file system that was created @throws IOException on write error
[ "Initializes", "the", "boot", "sector", "and", "file", "system", "for", "the", "device", ".", "The", "file", "system", "created", "by", "this", "method", "will", "always", "be", "in", "read", "-", "write", "mode", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/SuperFloppyFormatter.java#L185-L261
7,524
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/runresults/LineScreenCapture.java
LineScreenCapture.matchesStackLines
public boolean matchesStackLines(List<StackLine> targetStackLines) { if (targetStackLines.size() != getStackLines().size()) { return false; } for (int i = 0; i < targetStackLines.size(); i++) { StackLine targetLine = targetStackLines.get(i); StackLine line = getStackLines().get(i); if (!targetLine.getMethod().getKey().equals(line.getMethod().getKey())) { return false; } if (targetLine.getCodeBodyIndex() != line.getCodeBodyIndex()) { return false; } } return true; }
java
public boolean matchesStackLines(List<StackLine> targetStackLines) { if (targetStackLines.size() != getStackLines().size()) { return false; } for (int i = 0; i < targetStackLines.size(); i++) { StackLine targetLine = targetStackLines.get(i); StackLine line = getStackLines().get(i); if (!targetLine.getMethod().getKey().equals(line.getMethod().getKey())) { return false; } if (targetLine.getCodeBodyIndex() != line.getCodeBodyIndex()) { return false; } } return true; }
[ "public", "boolean", "matchesStackLines", "(", "List", "<", "StackLine", ">", "targetStackLines", ")", "{", "if", "(", "targetStackLines", ".", "size", "(", ")", "!=", "getStackLines", "(", ")", ".", "size", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "targetStackLines", ".", "size", "(", ")", ";", "i", "++", ")", "{", "StackLine", "targetLine", "=", "targetStackLines", ".", "get", "(", "i", ")", ";", "StackLine", "line", "=", "getStackLines", "(", ")", ".", "get", "(", "i", ")", ";", "if", "(", "!", "targetLine", ".", "getMethod", "(", ")", ".", "getKey", "(", ")", ".", "equals", "(", "line", ".", "getMethod", "(", ")", ".", "getKey", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "targetLine", ".", "getCodeBodyIndex", "(", ")", "!=", "line", ".", "getCodeBodyIndex", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
check if stack line for this instance matches targetStackLines
[ "check", "if", "stack", "line", "for", "this", "instance", "matches", "targetStackLines" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/runresults/LineScreenCapture.java#L51-L66
7,525
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamComponent.java
WebcamComponent.getWebcam
public Webcam getWebcam(String name, Dimension dimension) { if (name == null) { return getWebcam(dimension); } Webcam webcam = webcams.get(name); openWebcam(webcam, dimension); return webcam; }
java
public Webcam getWebcam(String name, Dimension dimension) { if (name == null) { return getWebcam(dimension); } Webcam webcam = webcams.get(name); openWebcam(webcam, dimension); return webcam; }
[ "public", "Webcam", "getWebcam", "(", "String", "name", ",", "Dimension", "dimension", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "getWebcam", "(", "dimension", ")", ";", "}", "Webcam", "webcam", "=", "webcams", ".", "get", "(", "name", ")", ";", "openWebcam", "(", "webcam", ",", "dimension", ")", ";", "return", "webcam", ";", "}" ]
Returns the webcam by name, null if not found. @param name webcam name @return webcam instance
[ "Returns", "the", "webcam", "by", "name", "null", "if", "not", "found", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamComponent.java#L234-L242
7,526
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamComponent.java
WebcamComponent.getWebcam
public Webcam getWebcam(Dimension dimension) { if (webcams.size() == 0) { throw new IllegalStateException("No webcams found"); } Webcam webcam = webcams.values().iterator().next(); openWebcam(webcam, dimension); return webcam; }
java
public Webcam getWebcam(Dimension dimension) { if (webcams.size() == 0) { throw new IllegalStateException("No webcams found"); } Webcam webcam = webcams.values().iterator().next(); openWebcam(webcam, dimension); return webcam; }
[ "public", "Webcam", "getWebcam", "(", "Dimension", "dimension", ")", "{", "if", "(", "webcams", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No webcams found\"", ")", ";", "}", "Webcam", "webcam", "=", "webcams", ".", "values", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "openWebcam", "(", "webcam", ",", "dimension", ")", ";", "return", "webcam", ";", "}" ]
Returns the first webcam.
[ "Returns", "the", "first", "webcam", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamComponent.java#L247-L256
7,527
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.beforeMethodHook
public void beforeMethodHook(String hookedClassQualifiedName, String hookedMethodSimpleName, String actualHookedMethodSimpleName) { if (currentRunResult != null) { return; // maybe called inside of the root method } List<TestMethod> rootMethods = srcTree.getRootMethodTable().getByName( hookedClassQualifiedName, hookedMethodSimpleName); if (rootMethods.size() == 0) { return; // hooked method is not root method } assert rootMethods.size() == 1; TestMethod rootMethod = rootMethods.get(0); logger.info("beforeMethodHook: " + hookedMethodSimpleName); // initialize current captureNo and runResult currentCaptureNo = 1; currentRunResult = new RootMethodRunResult(); currentRunResult.setRootMethodKey(rootMethod.getKey()); currentRunResult.setRootMethod(rootMethod); currentActualRootMethodSimpleName = actualHookedMethodSimpleName; startMethodTime = System.currentTimeMillis(); }
java
public void beforeMethodHook(String hookedClassQualifiedName, String hookedMethodSimpleName, String actualHookedMethodSimpleName) { if (currentRunResult != null) { return; // maybe called inside of the root method } List<TestMethod> rootMethods = srcTree.getRootMethodTable().getByName( hookedClassQualifiedName, hookedMethodSimpleName); if (rootMethods.size() == 0) { return; // hooked method is not root method } assert rootMethods.size() == 1; TestMethod rootMethod = rootMethods.get(0); logger.info("beforeMethodHook: " + hookedMethodSimpleName); // initialize current captureNo and runResult currentCaptureNo = 1; currentRunResult = new RootMethodRunResult(); currentRunResult.setRootMethodKey(rootMethod.getKey()); currentRunResult.setRootMethod(rootMethod); currentActualRootMethodSimpleName = actualHookedMethodSimpleName; startMethodTime = System.currentTimeMillis(); }
[ "public", "void", "beforeMethodHook", "(", "String", "hookedClassQualifiedName", ",", "String", "hookedMethodSimpleName", ",", "String", "actualHookedMethodSimpleName", ")", "{", "if", "(", "currentRunResult", "!=", "null", ")", "{", "return", ";", "// maybe called inside of the root method", "}", "List", "<", "TestMethod", ">", "rootMethods", "=", "srcTree", ".", "getRootMethodTable", "(", ")", ".", "getByName", "(", "hookedClassQualifiedName", ",", "hookedMethodSimpleName", ")", ";", "if", "(", "rootMethods", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "// hooked method is not root method", "}", "assert", "rootMethods", ".", "size", "(", ")", "==", "1", ";", "TestMethod", "rootMethod", "=", "rootMethods", ".", "get", "(", "0", ")", ";", "logger", ".", "info", "(", "\"beforeMethodHook: \"", "+", "hookedMethodSimpleName", ")", ";", "// initialize current captureNo and runResult", "currentCaptureNo", "=", "1", ";", "currentRunResult", "=", "new", "RootMethodRunResult", "(", ")", ";", "currentRunResult", ".", "setRootMethodKey", "(", "rootMethod", ".", "getKey", "(", ")", ")", ";", "currentRunResult", ".", "setRootMethod", "(", "rootMethod", ")", ";", "currentActualRootMethodSimpleName", "=", "actualHookedMethodSimpleName", ";", "startMethodTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "}" ]
initialize runResult information if the method for the arguments is root method
[ "initialize", "runResult", "information", "if", "the", "method", "for", "the", "arguments", "is", "root", "method" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L62-L86
7,528
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.methodErrorHook
public void methodErrorHook(String hookedClassQualifiedName, String hookedMethodSimpleName, Throwable e) { if (currentRunResult == null) { return; // maybe called outside of the root method } TestMethod rootMethod = currentRunResult.getRootMethod(); if (!rootMethod.getTestClassKey().equals(hookedClassQualifiedName) || !rootMethod.getSimpleName().equals(hookedMethodSimpleName)) { return; // hooked method is not current root method } RunFailure runFailure = new RunFailure(); runFailure.setMessage(e.getClass().getCanonicalName() + ": " + e.getLocalizedMessage()); runFailure.setStackTrace(ExceptionUtils.getStackTrace(e)); LineReplacer replacer = new LineReplacer() { @Override public void replace(String classQualifiedName, String methodSimpleName, int line) { super.replace(classQualifiedName, methodSimpleName, line); if (StringUtils.equals(methodSimpleName, currentActualRootMethodSimpleName)) { replaceMethodSimpleName(currentRunResult.getRootMethod().getSimpleName()); } } }; List<StackLine> stackLines = StackLineUtils.getStackLines(srcTree, e.getStackTrace(), replacer); for (StackLine stackLine : stackLines) { runFailure.addStackLine(stackLine); } currentRunResult.addRunFailure(runFailure); captureScreenForStackLines(rootMethod, Arrays.asList(stackLines), Arrays.asList(-1)); }
java
public void methodErrorHook(String hookedClassQualifiedName, String hookedMethodSimpleName, Throwable e) { if (currentRunResult == null) { return; // maybe called outside of the root method } TestMethod rootMethod = currentRunResult.getRootMethod(); if (!rootMethod.getTestClassKey().equals(hookedClassQualifiedName) || !rootMethod.getSimpleName().equals(hookedMethodSimpleName)) { return; // hooked method is not current root method } RunFailure runFailure = new RunFailure(); runFailure.setMessage(e.getClass().getCanonicalName() + ": " + e.getLocalizedMessage()); runFailure.setStackTrace(ExceptionUtils.getStackTrace(e)); LineReplacer replacer = new LineReplacer() { @Override public void replace(String classQualifiedName, String methodSimpleName, int line) { super.replace(classQualifiedName, methodSimpleName, line); if (StringUtils.equals(methodSimpleName, currentActualRootMethodSimpleName)) { replaceMethodSimpleName(currentRunResult.getRootMethod().getSimpleName()); } } }; List<StackLine> stackLines = StackLineUtils.getStackLines(srcTree, e.getStackTrace(), replacer); for (StackLine stackLine : stackLines) { runFailure.addStackLine(stackLine); } currentRunResult.addRunFailure(runFailure); captureScreenForStackLines(rootMethod, Arrays.asList(stackLines), Arrays.asList(-1)); }
[ "public", "void", "methodErrorHook", "(", "String", "hookedClassQualifiedName", ",", "String", "hookedMethodSimpleName", ",", "Throwable", "e", ")", "{", "if", "(", "currentRunResult", "==", "null", ")", "{", "return", ";", "// maybe called outside of the root method", "}", "TestMethod", "rootMethod", "=", "currentRunResult", ".", "getRootMethod", "(", ")", ";", "if", "(", "!", "rootMethod", ".", "getTestClassKey", "(", ")", ".", "equals", "(", "hookedClassQualifiedName", ")", "||", "!", "rootMethod", ".", "getSimpleName", "(", ")", ".", "equals", "(", "hookedMethodSimpleName", ")", ")", "{", "return", ";", "// hooked method is not current root method", "}", "RunFailure", "runFailure", "=", "new", "RunFailure", "(", ")", ";", "runFailure", ".", "setMessage", "(", "e", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\": \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "runFailure", ".", "setStackTrace", "(", "ExceptionUtils", ".", "getStackTrace", "(", "e", ")", ")", ";", "LineReplacer", "replacer", "=", "new", "LineReplacer", "(", ")", "{", "@", "Override", "public", "void", "replace", "(", "String", "classQualifiedName", ",", "String", "methodSimpleName", ",", "int", "line", ")", "{", "super", ".", "replace", "(", "classQualifiedName", ",", "methodSimpleName", ",", "line", ")", ";", "if", "(", "StringUtils", ".", "equals", "(", "methodSimpleName", ",", "currentActualRootMethodSimpleName", ")", ")", "{", "replaceMethodSimpleName", "(", "currentRunResult", ".", "getRootMethod", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "}", "}", ";", "List", "<", "StackLine", ">", "stackLines", "=", "StackLineUtils", ".", "getStackLines", "(", "srcTree", ",", "e", ".", "getStackTrace", "(", ")", ",", "replacer", ")", ";", "for", "(", "StackLine", "stackLine", ":", "stackLines", ")", "{", "runFailure", ".", "addStackLine", "(", "stackLine", ")", ";", "}", "currentRunResult", ".", "addRunFailure", "(", "runFailure", ")", ";", "captureScreenForStackLines", "(", "rootMethod", ",", "Arrays", ".", "asList", "(", "stackLines", ")", ",", "Arrays", ".", "asList", "(", "-", "1", ")", ")", ";", "}" ]
This method must be called before afterMethodHook is called
[ "This", "method", "must", "be", "called", "before", "afterMethodHook", "is", "called" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L90-L121
7,529
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.afterMethodHook
public void afterMethodHook(String hookedClassQualifiedName, String hookedMethodSimpleName) { if (currentRunResult == null) { return; // maybe called outside of the root method } TestMethod rootMethod = currentRunResult.getRootMethod(); if (!rootMethod.getTestClassKey().equals(hookedClassQualifiedName) || !rootMethod.getSimpleName().equals(hookedMethodSimpleName)) { return; // hooked method is not current root method } long currentTime = System.currentTimeMillis(); currentRunResult.setExecutionTime((int) (currentTime - startMethodTime)); logger.info("afterMethodHook: " + hookedMethodSimpleName); // use encoded name to avoid various possible file name encoding problem // and to escape invalid file name character (Method name may contain such characters // if method is Groovy method, for example). File runResultFile = new File(String.format("%s/%s/%s", runResultsRootDir, CommonUtils.encodeToSafeAsciiFileNameString(hookedClassQualifiedName, StandardCharsets.UTF_8), CommonUtils.encodeToSafeAsciiFileNameString(hookedMethodSimpleName, StandardCharsets.UTF_8))); if (runResultFile.getParentFile() != null) { runResultFile.getParentFile().mkdirs(); } // write runResult to YAML file YamlUtils.dump(currentRunResult.toYamlObject(), runResultFile); // clear current captureNo and runResult currentCaptureNo = -1; currentRunResult = null; currentActualRootMethodSimpleName = null; }
java
public void afterMethodHook(String hookedClassQualifiedName, String hookedMethodSimpleName) { if (currentRunResult == null) { return; // maybe called outside of the root method } TestMethod rootMethod = currentRunResult.getRootMethod(); if (!rootMethod.getTestClassKey().equals(hookedClassQualifiedName) || !rootMethod.getSimpleName().equals(hookedMethodSimpleName)) { return; // hooked method is not current root method } long currentTime = System.currentTimeMillis(); currentRunResult.setExecutionTime((int) (currentTime - startMethodTime)); logger.info("afterMethodHook: " + hookedMethodSimpleName); // use encoded name to avoid various possible file name encoding problem // and to escape invalid file name character (Method name may contain such characters // if method is Groovy method, for example). File runResultFile = new File(String.format("%s/%s/%s", runResultsRootDir, CommonUtils.encodeToSafeAsciiFileNameString(hookedClassQualifiedName, StandardCharsets.UTF_8), CommonUtils.encodeToSafeAsciiFileNameString(hookedMethodSimpleName, StandardCharsets.UTF_8))); if (runResultFile.getParentFile() != null) { runResultFile.getParentFile().mkdirs(); } // write runResult to YAML file YamlUtils.dump(currentRunResult.toYamlObject(), runResultFile); // clear current captureNo and runResult currentCaptureNo = -1; currentRunResult = null; currentActualRootMethodSimpleName = null; }
[ "public", "void", "afterMethodHook", "(", "String", "hookedClassQualifiedName", ",", "String", "hookedMethodSimpleName", ")", "{", "if", "(", "currentRunResult", "==", "null", ")", "{", "return", ";", "// maybe called outside of the root method", "}", "TestMethod", "rootMethod", "=", "currentRunResult", ".", "getRootMethod", "(", ")", ";", "if", "(", "!", "rootMethod", ".", "getTestClassKey", "(", ")", ".", "equals", "(", "hookedClassQualifiedName", ")", "||", "!", "rootMethod", ".", "getSimpleName", "(", ")", ".", "equals", "(", "hookedMethodSimpleName", ")", ")", "{", "return", ";", "// hooked method is not current root method", "}", "long", "currentTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "currentRunResult", ".", "setExecutionTime", "(", "(", "int", ")", "(", "currentTime", "-", "startMethodTime", ")", ")", ";", "logger", ".", "info", "(", "\"afterMethodHook: \"", "+", "hookedMethodSimpleName", ")", ";", "// use encoded name to avoid various possible file name encoding problem", "// and to escape invalid file name character (Method name may contain such characters", "// if method is Groovy method, for example).", "File", "runResultFile", "=", "new", "File", "(", "String", ".", "format", "(", "\"%s/%s/%s\"", ",", "runResultsRootDir", ",", "CommonUtils", ".", "encodeToSafeAsciiFileNameString", "(", "hookedClassQualifiedName", ",", "StandardCharsets", ".", "UTF_8", ")", ",", "CommonUtils", ".", "encodeToSafeAsciiFileNameString", "(", "hookedMethodSimpleName", ",", "StandardCharsets", ".", "UTF_8", ")", ")", ")", ";", "if", "(", "runResultFile", ".", "getParentFile", "(", ")", "!=", "null", ")", "{", "runResultFile", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "}", "// write runResult to YAML file", "YamlUtils", ".", "dump", "(", "currentRunResult", ".", "toYamlObject", "(", ")", ",", "runResultFile", ")", ";", "// clear current captureNo and runResult", "currentCaptureNo", "=", "-", "1", ";", "currentRunResult", "=", "null", ";", "currentActualRootMethodSimpleName", "=", "null", ";", "}" ]
write runResult to YAML file if the method for the arguments is root method
[ "write", "runResult", "to", "YAML", "file", "if", "the", "method", "for", "the", "arguments", "is", "root", "method" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L124-L154
7,530
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.getCodeLineHookedStackLines
private List<StackLine> getCodeLineHookedStackLines( final String hookedMethodSimpleName, final String actualHookedMethodSimpleName, final int hookedLine, final int actualHookedLine) { // this replacer replaces method name and line to the actual hooked method name and line LineReplacer replacer = new LineReplacer() { @Override public void replace(String classQualifiedName, String methodSimpleName, int line) { super.replace(classQualifiedName, methodSimpleName, line); // replacing root method name if (StringUtils.equals(methodSimpleName, currentActualRootMethodSimpleName)) { replaceMethodSimpleName(currentRunResult.getRootMethod().getSimpleName()); } // replacing hooked method name and line number if (StringUtils.equals(methodSimpleName, actualHookedMethodSimpleName) && (line == actualHookedLine)) { replaceMethodSimpleName(hookedMethodSimpleName); replaceLine(hookedLine); } } }; List<StackLine> result = StackLineUtils.getStackLines( srcTree, Thread.currentThread().getStackTrace(), replacer); assert result.size() > 0; return result; }
java
private List<StackLine> getCodeLineHookedStackLines( final String hookedMethodSimpleName, final String actualHookedMethodSimpleName, final int hookedLine, final int actualHookedLine) { // this replacer replaces method name and line to the actual hooked method name and line LineReplacer replacer = new LineReplacer() { @Override public void replace(String classQualifiedName, String methodSimpleName, int line) { super.replace(classQualifiedName, methodSimpleName, line); // replacing root method name if (StringUtils.equals(methodSimpleName, currentActualRootMethodSimpleName)) { replaceMethodSimpleName(currentRunResult.getRootMethod().getSimpleName()); } // replacing hooked method name and line number if (StringUtils.equals(methodSimpleName, actualHookedMethodSimpleName) && (line == actualHookedLine)) { replaceMethodSimpleName(hookedMethodSimpleName); replaceLine(hookedLine); } } }; List<StackLine> result = StackLineUtils.getStackLines( srcTree, Thread.currentThread().getStackTrace(), replacer); assert result.size() > 0; return result; }
[ "private", "List", "<", "StackLine", ">", "getCodeLineHookedStackLines", "(", "final", "String", "hookedMethodSimpleName", ",", "final", "String", "actualHookedMethodSimpleName", ",", "final", "int", "hookedLine", ",", "final", "int", "actualHookedLine", ")", "{", "// this replacer replaces method name and line to the actual hooked method name and line", "LineReplacer", "replacer", "=", "new", "LineReplacer", "(", ")", "{", "@", "Override", "public", "void", "replace", "(", "String", "classQualifiedName", ",", "String", "methodSimpleName", ",", "int", "line", ")", "{", "super", ".", "replace", "(", "classQualifiedName", ",", "methodSimpleName", ",", "line", ")", ";", "// replacing root method name", "if", "(", "StringUtils", ".", "equals", "(", "methodSimpleName", ",", "currentActualRootMethodSimpleName", ")", ")", "{", "replaceMethodSimpleName", "(", "currentRunResult", ".", "getRootMethod", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "// replacing hooked method name and line number", "if", "(", "StringUtils", ".", "equals", "(", "methodSimpleName", ",", "actualHookedMethodSimpleName", ")", "&&", "(", "line", "==", "actualHookedLine", ")", ")", "{", "replaceMethodSimpleName", "(", "hookedMethodSimpleName", ")", ";", "replaceLine", "(", "hookedLine", ")", ";", "}", "}", "}", ";", "List", "<", "StackLine", ">", "result", "=", "StackLineUtils", ".", "getStackLines", "(", "srcTree", ",", "Thread", ".", "currentThread", "(", ")", ".", "getStackTrace", "(", ")", ",", "replacer", ")", ";", "assert", "result", ".", "size", "(", ")", ">", "0", ";", "return", "result", ";", "}" ]
get the stackLines for the hook method code line.
[ "get", "the", "stackLines", "for", "the", "hook", "method", "code", "line", "." ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L215-L241
7,531
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.getCodeLineKey
private String getCodeLineKey(final String hookedClassQualifiedName, final String hookedMethodSimpleName, String hookedArgClassesStr, final int hookedLine) { return String.format("%s_%s_%s_%d_%d", hookedClassQualifiedName, hookedMethodSimpleName, hookedArgClassesStr, hookedLine, Thread.currentThread().getStackTrace().length); }
java
private String getCodeLineKey(final String hookedClassQualifiedName, final String hookedMethodSimpleName, String hookedArgClassesStr, final int hookedLine) { return String.format("%s_%s_%s_%d_%d", hookedClassQualifiedName, hookedMethodSimpleName, hookedArgClassesStr, hookedLine, Thread.currentThread().getStackTrace().length); }
[ "private", "String", "getCodeLineKey", "(", "final", "String", "hookedClassQualifiedName", ",", "final", "String", "hookedMethodSimpleName", ",", "String", "hookedArgClassesStr", ",", "final", "int", "hookedLine", ")", "{", "return", "String", ".", "format", "(", "\"%s_%s_%s_%d_%d\"", ",", "hookedClassQualifiedName", ",", "hookedMethodSimpleName", ",", "hookedArgClassesStr", ",", "hookedLine", ",", "Thread", ".", "currentThread", "(", ")", ".", "getStackTrace", "(", ")", ".", "length", ")", ";", "}" ]
Calculate unique key for each code line hook
[ "Calculate", "unique", "key", "for", "each", "code", "line", "hook" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L399-L408
7,532
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.captureScreen
private File captureScreen(TestMethod rootMethod) { byte[] screenData = AdapterContainer.globalInstance().captureScreen(); if (screenData == null) { return null; } // use encoded name to avoid various possible file name encoding problem // and to escape invalid file name character (Method name may contain such characters // if method is Groovy method, for example). File captureFile = new File(String.format("%s/%s/%s/%03d.png", captureRootDir, CommonUtils.encodeToSafeAsciiFileNameString(rootMethod.getTestClass().getQualifiedName(), StandardCharsets.UTF_8), CommonUtils.encodeToSafeAsciiFileNameString(rootMethod.getSimpleName(), StandardCharsets.UTF_8), currentCaptureNo)); currentCaptureNo++; if (captureFile.getParentFile() != null) { captureFile.getParentFile().mkdirs(); } FileOutputStream stream = null; try { stream = new FileOutputStream(captureFile); stream.write(screenData); } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(stream); } return captureFile; }
java
private File captureScreen(TestMethod rootMethod) { byte[] screenData = AdapterContainer.globalInstance().captureScreen(); if (screenData == null) { return null; } // use encoded name to avoid various possible file name encoding problem // and to escape invalid file name character (Method name may contain such characters // if method is Groovy method, for example). File captureFile = new File(String.format("%s/%s/%s/%03d.png", captureRootDir, CommonUtils.encodeToSafeAsciiFileNameString(rootMethod.getTestClass().getQualifiedName(), StandardCharsets.UTF_8), CommonUtils.encodeToSafeAsciiFileNameString(rootMethod.getSimpleName(), StandardCharsets.UTF_8), currentCaptureNo)); currentCaptureNo++; if (captureFile.getParentFile() != null) { captureFile.getParentFile().mkdirs(); } FileOutputStream stream = null; try { stream = new FileOutputStream(captureFile); stream.write(screenData); } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(stream); } return captureFile; }
[ "private", "File", "captureScreen", "(", "TestMethod", "rootMethod", ")", "{", "byte", "[", "]", "screenData", "=", "AdapterContainer", ".", "globalInstance", "(", ")", ".", "captureScreen", "(", ")", ";", "if", "(", "screenData", "==", "null", ")", "{", "return", "null", ";", "}", "// use encoded name to avoid various possible file name encoding problem", "// and to escape invalid file name character (Method name may contain such characters", "// if method is Groovy method, for example).", "File", "captureFile", "=", "new", "File", "(", "String", ".", "format", "(", "\"%s/%s/%s/%03d.png\"", ",", "captureRootDir", ",", "CommonUtils", ".", "encodeToSafeAsciiFileNameString", "(", "rootMethod", ".", "getTestClass", "(", ")", ".", "getQualifiedName", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ",", "CommonUtils", ".", "encodeToSafeAsciiFileNameString", "(", "rootMethod", ".", "getSimpleName", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ",", "currentCaptureNo", ")", ")", ";", "currentCaptureNo", "++", ";", "if", "(", "captureFile", ".", "getParentFile", "(", ")", "!=", "null", ")", "{", "captureFile", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "}", "FileOutputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "new", "FileOutputStream", "(", "captureFile", ")", ";", "stream", ".", "write", "(", "screenData", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "stream", ")", ";", "}", "return", "captureFile", ";", "}" ]
returns null if not executed
[ "returns", "null", "if", "not", "executed" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L411-L439
7,533
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.captureScreenForStackLines
private File captureScreenForStackLines( TestMethod rootMethod, List<List<StackLine>> stackLinesList, List<Integer> executionTimes) { if (stackLinesList == null) { throw new NullPointerException(); } if (stackLinesList.size() == 0) { throw new IllegalArgumentException("empty list"); } if (stackLinesList.size() != executionTimes.size()) { throw new IllegalArgumentException("size mismatch"); } File captureFile = captureScreen(rootMethod); if (captureFile == null) { return null; } for (int i = 0; i < stackLinesList.size(); i++) { LineScreenCapture capture = new LineScreenCapture(); capture.setPath(new File(captureFile.getAbsolutePath())); capture.addAllStackLines(stackLinesList.get(i)); capture.setExecutionTime(executionTimes.get(i)); currentRunResult.addLineScreenCapture(capture); } return captureFile; }
java
private File captureScreenForStackLines( TestMethod rootMethod, List<List<StackLine>> stackLinesList, List<Integer> executionTimes) { if (stackLinesList == null) { throw new NullPointerException(); } if (stackLinesList.size() == 0) { throw new IllegalArgumentException("empty list"); } if (stackLinesList.size() != executionTimes.size()) { throw new IllegalArgumentException("size mismatch"); } File captureFile = captureScreen(rootMethod); if (captureFile == null) { return null; } for (int i = 0; i < stackLinesList.size(); i++) { LineScreenCapture capture = new LineScreenCapture(); capture.setPath(new File(captureFile.getAbsolutePath())); capture.addAllStackLines(stackLinesList.get(i)); capture.setExecutionTime(executionTimes.get(i)); currentRunResult.addLineScreenCapture(capture); } return captureFile; }
[ "private", "File", "captureScreenForStackLines", "(", "TestMethod", "rootMethod", ",", "List", "<", "List", "<", "StackLine", ">", ">", "stackLinesList", ",", "List", "<", "Integer", ">", "executionTimes", ")", "{", "if", "(", "stackLinesList", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "stackLinesList", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"empty list\"", ")", ";", "}", "if", "(", "stackLinesList", ".", "size", "(", ")", "!=", "executionTimes", ".", "size", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"size mismatch\"", ")", ";", "}", "File", "captureFile", "=", "captureScreen", "(", "rootMethod", ")", ";", "if", "(", "captureFile", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stackLinesList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "LineScreenCapture", "capture", "=", "new", "LineScreenCapture", "(", ")", ";", "capture", ".", "setPath", "(", "new", "File", "(", "captureFile", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "capture", ".", "addAllStackLines", "(", "stackLinesList", ".", "get", "(", "i", ")", ")", ";", "capture", ".", "setExecutionTime", "(", "executionTimes", ".", "get", "(", "i", ")", ")", ";", "currentRunResult", ".", "addLineScreenCapture", "(", "capture", ")", ";", "}", "return", "captureFile", ";", "}" ]
- returns null if fails to capture
[ "-", "returns", "null", "if", "fails", "to", "capture" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L445-L468
7,534
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java
HookMethodManager.canStepInCaptureTo
private boolean canStepInCaptureTo(List<StackLine> stackLines) { // stack bottom line ( = root line) is always regarded as stepIn true line for (int i = 0; i < stackLines.size() - 1; i++) { StackLine stackLine = stackLines.get(i); CaptureStyle style = stackLine.getMethod().getCaptureStyle(); if (style != CaptureStyle.STEP_IN && style != CaptureStyle.STEP_IN_ONLY) { return false; } } return true; }
java
private boolean canStepInCaptureTo(List<StackLine> stackLines) { // stack bottom line ( = root line) is always regarded as stepIn true line for (int i = 0; i < stackLines.size() - 1; i++) { StackLine stackLine = stackLines.get(i); CaptureStyle style = stackLine.getMethod().getCaptureStyle(); if (style != CaptureStyle.STEP_IN && style != CaptureStyle.STEP_IN_ONLY) { return false; } } return true; }
[ "private", "boolean", "canStepInCaptureTo", "(", "List", "<", "StackLine", ">", "stackLines", ")", "{", "// stack bottom line ( = root line) is always regarded as stepIn true line", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stackLines", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "StackLine", "stackLine", "=", "stackLines", ".", "get", "(", "i", ")", ";", "CaptureStyle", "style", "=", "stackLine", ".", "getMethod", "(", ")", ".", "getCaptureStyle", "(", ")", ";", "if", "(", "style", "!=", "CaptureStyle", ".", "STEP_IN", "&&", "style", "!=", "CaptureStyle", ".", "STEP_IN_ONLY", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
if method is called from not stepInCapture line, then returns false.
[ "if", "method", "is", "called", "from", "not", "stepInCapture", "line", "then", "returns", "false", "." ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodManager.java#L471-L481
7,535
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/APIAccessService.java
APIAccessService.getAPIAccessMode
public String getAPIAccessMode() { String apiAccessMode = (String) getScenarioGlobals().getAttribute(API_ACCESS_MODE_KEY); return apiAccessMode == null ? HTTP_API_ACCESS_MODE : apiAccessMode; }
java
public String getAPIAccessMode() { String apiAccessMode = (String) getScenarioGlobals().getAttribute(API_ACCESS_MODE_KEY); return apiAccessMode == null ? HTTP_API_ACCESS_MODE : apiAccessMode; }
[ "public", "String", "getAPIAccessMode", "(", ")", "{", "String", "apiAccessMode", "=", "(", "String", ")", "getScenarioGlobals", "(", ")", ".", "getAttribute", "(", "API_ACCESS_MODE_KEY", ")", ";", "return", "apiAccessMode", "==", "null", "?", "HTTP_API_ACCESS_MODE", ":", "apiAccessMode", ";", "}" ]
When the api is accessed though the browser selenium is used, though straight HTTP calls we can choose to POST or GET the api @return the api access mode being either {@link APIAccessService#HTTP_API_ACCESS_MODE} (default) or {@link APIAccessService#BROWSER_API_ACCESS_MODE}
[ "When", "the", "api", "is", "accessed", "though", "the", "browser", "selenium", "is", "used", "though", "straight", "HTTP", "calls", "we", "can", "choose", "to", "POST", "or", "GET", "the", "api" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/APIAccessService.java#L81-L84
7,536
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/APIAccessService.java
APIAccessService.setRequestHeaders
private void setRequestHeaders(HttpURLConnection ucon, GenericUser authenticationUser, String[] requestHedaers) { if(authenticationUser != null) { String authenticationString = authenticationUser.getUserName() + ":" + authenticationUser.getPassword(); byte[] encodedAuthentication = Base64.encodeBase64(authenticationString.getBytes()); String authenticationHeaderValue = "Basic " + new String(encodedAuthentication); ucon.setRequestProperty("Authorization", authenticationHeaderValue); } for(int i = 0;i<requestHedaers.length;i = i+2) { ucon.setRequestProperty(getReferenceService().namespaceString(requestHedaers[i]), getReferenceService().namespaceString(requestHedaers[i+1])); } }
java
private void setRequestHeaders(HttpURLConnection ucon, GenericUser authenticationUser, String[] requestHedaers) { if(authenticationUser != null) { String authenticationString = authenticationUser.getUserName() + ":" + authenticationUser.getPassword(); byte[] encodedAuthentication = Base64.encodeBase64(authenticationString.getBytes()); String authenticationHeaderValue = "Basic " + new String(encodedAuthentication); ucon.setRequestProperty("Authorization", authenticationHeaderValue); } for(int i = 0;i<requestHedaers.length;i = i+2) { ucon.setRequestProperty(getReferenceService().namespaceString(requestHedaers[i]), getReferenceService().namespaceString(requestHedaers[i+1])); } }
[ "private", "void", "setRequestHeaders", "(", "HttpURLConnection", "ucon", ",", "GenericUser", "authenticationUser", ",", "String", "[", "]", "requestHedaers", ")", "{", "if", "(", "authenticationUser", "!=", "null", ")", "{", "String", "authenticationString", "=", "authenticationUser", ".", "getUserName", "(", ")", "+", "\":\"", "+", "authenticationUser", ".", "getPassword", "(", ")", ";", "byte", "[", "]", "encodedAuthentication", "=", "Base64", ".", "encodeBase64", "(", "authenticationString", ".", "getBytes", "(", ")", ")", ";", "String", "authenticationHeaderValue", "=", "\"Basic \"", "+", "new", "String", "(", "encodedAuthentication", ")", ";", "ucon", ".", "setRequestProperty", "(", "\"Authorization\"", ",", "authenticationHeaderValue", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "requestHedaers", ".", "length", ";", "i", "=", "i", "+", "2", ")", "{", "ucon", ".", "setRequestProperty", "(", "getReferenceService", "(", ")", ".", "namespaceString", "(", "requestHedaers", "[", "i", "]", ")", ",", "getReferenceService", "(", ")", ".", "namespaceString", "(", "requestHedaers", "[", "i", "+", "1", "]", ")", ")", ";", "}", "}" ]
Add the request headers to the request @param ucon the connection to append the http headers to @param authenticationUser The username:password combination to pass along as basic http authentication @param requestHedaers the https header name:value pairs. This means the headers should always come in an even number (name + value) * n
[ "Add", "the", "request", "headers", "to", "the", "request" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/APIAccessService.java#L322-L335
7,537
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/srctreegen/ASTUtils.java
ASTUtils.getAllPageDocs
private static Map<Locale, String> getAllPageDocs(IAnnotationBinding[] annotations) { // all @PageDoc or @Page annotations including annotations contained in @PageDocs or @Page List<IAnnotationBinding> allPageAnnotations = new ArrayList<>(2); List<Class<?>> singlePageAnnotationClasses = new ArrayList<>(2); singlePageAnnotationClasses.add(PageDoc.class); singlePageAnnotationClasses.add(Page.class); for (Class<?> annotationClass : singlePageAnnotationClasses) { IAnnotationBinding annotation = getAnnotationBinding(annotations, annotationClass); if (annotation == null) { continue; // annotation is not found } if (allPageAnnotations.size() > 0) { // TODO throw IllegalTestScriptException throw new RuntimeException("don't use multiple page annoations at the same place"); } allPageAnnotations.add(annotation); } List<Class<?>> multiplePageAnnotationClasses = new ArrayList<>(2); multiplePageAnnotationClasses.add(PageDocs.class); multiplePageAnnotationClasses.add(Pages.class); for (Class<?> annotationClass : multiplePageAnnotationClasses) { IAnnotationBinding annotation = getAnnotationBinding(annotations, annotationClass); if (annotation == null) { continue; // annotation is not found } if (allPageAnnotations.size() > 0) { // TODO throw IllegalTestScriptException throw new RuntimeException("don't use multiple page annoations at the same place"); } // get @PageDoc or @Page from @PageDocs or @Pages Object value = getAnnotationValue(annotation, "value"); Object[] values = (Object[]) value; for (Object element : values) { allPageAnnotations.add((IAnnotationBinding) element); } } // get resultPageMap Map<Locale, String> resultPageMap = new HashMap<>(allPageAnnotations.size()); for (IAnnotationBinding eachPageAnnotation : allPageAnnotations) { Object value = getAnnotationValue(eachPageAnnotation, "value"); Locale locale = getAnnotationLocaleValue(eachPageAnnotation, "locale"); resultPageMap.put(locale, (String) value); } return resultPageMap; }
java
private static Map<Locale, String> getAllPageDocs(IAnnotationBinding[] annotations) { // all @PageDoc or @Page annotations including annotations contained in @PageDocs or @Page List<IAnnotationBinding> allPageAnnotations = new ArrayList<>(2); List<Class<?>> singlePageAnnotationClasses = new ArrayList<>(2); singlePageAnnotationClasses.add(PageDoc.class); singlePageAnnotationClasses.add(Page.class); for (Class<?> annotationClass : singlePageAnnotationClasses) { IAnnotationBinding annotation = getAnnotationBinding(annotations, annotationClass); if (annotation == null) { continue; // annotation is not found } if (allPageAnnotations.size() > 0) { // TODO throw IllegalTestScriptException throw new RuntimeException("don't use multiple page annoations at the same place"); } allPageAnnotations.add(annotation); } List<Class<?>> multiplePageAnnotationClasses = new ArrayList<>(2); multiplePageAnnotationClasses.add(PageDocs.class); multiplePageAnnotationClasses.add(Pages.class); for (Class<?> annotationClass : multiplePageAnnotationClasses) { IAnnotationBinding annotation = getAnnotationBinding(annotations, annotationClass); if (annotation == null) { continue; // annotation is not found } if (allPageAnnotations.size() > 0) { // TODO throw IllegalTestScriptException throw new RuntimeException("don't use multiple page annoations at the same place"); } // get @PageDoc or @Page from @PageDocs or @Pages Object value = getAnnotationValue(annotation, "value"); Object[] values = (Object[]) value; for (Object element : values) { allPageAnnotations.add((IAnnotationBinding) element); } } // get resultPageMap Map<Locale, String> resultPageMap = new HashMap<>(allPageAnnotations.size()); for (IAnnotationBinding eachPageAnnotation : allPageAnnotations) { Object value = getAnnotationValue(eachPageAnnotation, "value"); Locale locale = getAnnotationLocaleValue(eachPageAnnotation, "locale"); resultPageMap.put(locale, (String) value); } return resultPageMap; }
[ "private", "static", "Map", "<", "Locale", ",", "String", ">", "getAllPageDocs", "(", "IAnnotationBinding", "[", "]", "annotations", ")", "{", "// all @PageDoc or @Page annotations including annotations contained in @PageDocs or @Page", "List", "<", "IAnnotationBinding", ">", "allPageAnnotations", "=", "new", "ArrayList", "<>", "(", "2", ")", ";", "List", "<", "Class", "<", "?", ">", ">", "singlePageAnnotationClasses", "=", "new", "ArrayList", "<>", "(", "2", ")", ";", "singlePageAnnotationClasses", ".", "add", "(", "PageDoc", ".", "class", ")", ";", "singlePageAnnotationClasses", ".", "add", "(", "Page", ".", "class", ")", ";", "for", "(", "Class", "<", "?", ">", "annotationClass", ":", "singlePageAnnotationClasses", ")", "{", "IAnnotationBinding", "annotation", "=", "getAnnotationBinding", "(", "annotations", ",", "annotationClass", ")", ";", "if", "(", "annotation", "==", "null", ")", "{", "continue", ";", "// annotation is not found", "}", "if", "(", "allPageAnnotations", ".", "size", "(", ")", ">", "0", ")", "{", "// TODO throw IllegalTestScriptException", "throw", "new", "RuntimeException", "(", "\"don't use multiple page annoations at the same place\"", ")", ";", "}", "allPageAnnotations", ".", "add", "(", "annotation", ")", ";", "}", "List", "<", "Class", "<", "?", ">", ">", "multiplePageAnnotationClasses", "=", "new", "ArrayList", "<>", "(", "2", ")", ";", "multiplePageAnnotationClasses", ".", "add", "(", "PageDocs", ".", "class", ")", ";", "multiplePageAnnotationClasses", ".", "add", "(", "Pages", ".", "class", ")", ";", "for", "(", "Class", "<", "?", ">", "annotationClass", ":", "multiplePageAnnotationClasses", ")", "{", "IAnnotationBinding", "annotation", "=", "getAnnotationBinding", "(", "annotations", ",", "annotationClass", ")", ";", "if", "(", "annotation", "==", "null", ")", "{", "continue", ";", "// annotation is not found", "}", "if", "(", "allPageAnnotations", ".", "size", "(", ")", ">", "0", ")", "{", "// TODO throw IllegalTestScriptException", "throw", "new", "RuntimeException", "(", "\"don't use multiple page annoations at the same place\"", ")", ";", "}", "// get @PageDoc or @Page from @PageDocs or @Pages", "Object", "value", "=", "getAnnotationValue", "(", "annotation", ",", "\"value\"", ")", ";", "Object", "[", "]", "values", "=", "(", "Object", "[", "]", ")", "value", ";", "for", "(", "Object", "element", ":", "values", ")", "{", "allPageAnnotations", ".", "add", "(", "(", "IAnnotationBinding", ")", "element", ")", ";", "}", "}", "// get resultPageMap", "Map", "<", "Locale", ",", "String", ">", "resultPageMap", "=", "new", "HashMap", "<>", "(", "allPageAnnotations", ".", "size", "(", ")", ")", ";", "for", "(", "IAnnotationBinding", "eachPageAnnotation", ":", "allPageAnnotations", ")", "{", "Object", "value", "=", "getAnnotationValue", "(", "eachPageAnnotation", ",", "\"value\"", ")", ";", "Locale", "locale", "=", "getAnnotationLocaleValue", "(", "eachPageAnnotation", ",", "\"locale\"", ")", ";", "resultPageMap", ".", "put", "(", "locale", ",", "(", "String", ")", "value", ")", ";", "}", "return", "resultPageMap", ";", "}" ]
return empty list if no Page is found
[ "return", "empty", "list", "if", "no", "Page", "is", "found" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/srctreegen/ASTUtils.java#L172-L220
7,538
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/srctreegen/ASTUtils.java
ASTUtils.getPageDoc
private static String getPageDoc( IAnnotationBinding[] annotations, AcceptableLocales locales) { Map<Locale, String> allPages = getAllPageDocs(annotations); if (allPages.isEmpty()) { return null; // no @Page found } for (Locale locale : locales.getLocales()) { String value = allPages.get(locale); if (value != null) { return value; } } // set empty string if no locale matched data is found return ""; }
java
private static String getPageDoc( IAnnotationBinding[] annotations, AcceptableLocales locales) { Map<Locale, String> allPages = getAllPageDocs(annotations); if (allPages.isEmpty()) { return null; // no @Page found } for (Locale locale : locales.getLocales()) { String value = allPages.get(locale); if (value != null) { return value; } } // set empty string if no locale matched data is found return ""; }
[ "private", "static", "String", "getPageDoc", "(", "IAnnotationBinding", "[", "]", "annotations", ",", "AcceptableLocales", "locales", ")", "{", "Map", "<", "Locale", ",", "String", ">", "allPages", "=", "getAllPageDocs", "(", "annotations", ")", ";", "if", "(", "allPages", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "// no @Page found", "}", "for", "(", "Locale", "locale", ":", "locales", ".", "getLocales", "(", ")", ")", "{", "String", "value", "=", "allPages", ".", "get", "(", "locale", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "return", "value", ";", "}", "}", "// set empty string if no locale matched data is found", "return", "\"\"", ";", "}" ]
return null if no Page found
[ "return", "null", "if", "no", "Page", "found" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/srctreegen/ASTUtils.java#L250-L265
7,539
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.read
private void read() throws IOException { final byte[] data = new byte[sectorCount * sectorSize]; device.read(offset, ByteBuffer.wrap(data)); for (int i = 0; i < entries.length; i++) entries[i] = fatType.readEntry(data, i); }
java
private void read() throws IOException { final byte[] data = new byte[sectorCount * sectorSize]; device.read(offset, ByteBuffer.wrap(data)); for (int i = 0; i < entries.length; i++) entries[i] = fatType.readEntry(data, i); }
[ "private", "void", "read", "(", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "data", "=", "new", "byte", "[", "sectorCount", "*", "sectorSize", "]", ";", "device", ".", "read", "(", "offset", ",", "ByteBuffer", ".", "wrap", "(", "data", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entries", ".", "length", ";", "i", "++", ")", "entries", "[", "i", "]", "=", "fatType", ".", "readEntry", "(", "data", ",", "i", ")", ";", "}" ]
Read the contents of this FAT from the given device at the given offset. @param offset the byte offset where to read the FAT from the device @throws IOException on read error
[ "Read", "the", "contents", "of", "this", "FAT", "from", "the", "given", "device", "at", "the", "given", "offset", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L177-L183
7,540
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.writeCopy
public void writeCopy(long offset) throws IOException { final byte[] data = new byte[sectorCount * sectorSize]; for (int index = 0; index < entries.length; index++) { fatType.writeEntry(data, index, entries[index]); } device.write(offset, ByteBuffer.wrap(data)); }
java
public void writeCopy(long offset) throws IOException { final byte[] data = new byte[sectorCount * sectorSize]; for (int index = 0; index < entries.length; index++) { fatType.writeEntry(data, index, entries[index]); } device.write(offset, ByteBuffer.wrap(data)); }
[ "public", "void", "writeCopy", "(", "long", "offset", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "data", "=", "new", "byte", "[", "sectorCount", "*", "sectorSize", "]", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "entries", ".", "length", ";", "index", "++", ")", "{", "fatType", ".", "writeEntry", "(", "data", ",", "index", ",", "entries", "[", "index", "]", ")", ";", "}", "device", ".", "write", "(", "offset", ",", "ByteBuffer", ".", "wrap", "(", "data", ")", ")", ";", "}" ]
Write the contents of this FAT to the given device at the given offset. @param offset the device offset where to write the FAT copy @throws IOException on write error
[ "Write", "the", "contents", "of", "this", "FAT", "to", "the", "given", "device", "at", "the", "given", "offset", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L195-L203
7,541
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.getNextCluster
public long getNextCluster(long cluster) { testCluster(cluster); long entry = entries[(int) cluster]; if (isEofCluster(entry)) { return -1; } else { return entry; } }
java
public long getNextCluster(long cluster) { testCluster(cluster); long entry = entries[(int) cluster]; if (isEofCluster(entry)) { return -1; } else { return entry; } }
[ "public", "long", "getNextCluster", "(", "long", "cluster", ")", "{", "testCluster", "(", "cluster", ")", ";", "long", "entry", "=", "entries", "[", "(", "int", ")", "cluster", "]", ";", "if", "(", "isEofCluster", "(", "entry", ")", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "entry", ";", "}", "}" ]
Gets the cluster after the given cluster @param cluster @return long The next cluster number or -1 which means eof.
[ "Gets", "the", "cluster", "after", "the", "given", "cluster" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L260-L268
7,542
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.allocNew
public long allocNew() throws IOException { int i; int entryIndex = -1; for (i = lastAllocatedCluster; i < lastClusterIndex; i++) { if (isFreeCluster(i)) { entryIndex = i; break; } } if (entryIndex < 0) { for (i = FIRST_CLUSTER; i < lastAllocatedCluster; i++) { if (isFreeCluster(i)) { entryIndex = i; break; } } } if (entryIndex < 0) { throw new IOException( "FAT Full (" + (lastClusterIndex - FIRST_CLUSTER) + ", " + i + ")"); //NOI18N } entries[entryIndex] = fatType.getEofMarker(); lastAllocatedCluster = entryIndex % lastClusterIndex; if (lastAllocatedCluster < FIRST_CLUSTER) lastAllocatedCluster = FIRST_CLUSTER; return entryIndex; }
java
public long allocNew() throws IOException { int i; int entryIndex = -1; for (i = lastAllocatedCluster; i < lastClusterIndex; i++) { if (isFreeCluster(i)) { entryIndex = i; break; } } if (entryIndex < 0) { for (i = FIRST_CLUSTER; i < lastAllocatedCluster; i++) { if (isFreeCluster(i)) { entryIndex = i; break; } } } if (entryIndex < 0) { throw new IOException( "FAT Full (" + (lastClusterIndex - FIRST_CLUSTER) + ", " + i + ")"); //NOI18N } entries[entryIndex] = fatType.getEofMarker(); lastAllocatedCluster = entryIndex % lastClusterIndex; if (lastAllocatedCluster < FIRST_CLUSTER) lastAllocatedCluster = FIRST_CLUSTER; return entryIndex; }
[ "public", "long", "allocNew", "(", ")", "throws", "IOException", "{", "int", "i", ";", "int", "entryIndex", "=", "-", "1", ";", "for", "(", "i", "=", "lastAllocatedCluster", ";", "i", "<", "lastClusterIndex", ";", "i", "++", ")", "{", "if", "(", "isFreeCluster", "(", "i", ")", ")", "{", "entryIndex", "=", "i", ";", "break", ";", "}", "}", "if", "(", "entryIndex", "<", "0", ")", "{", "for", "(", "i", "=", "FIRST_CLUSTER", ";", "i", "<", "lastAllocatedCluster", ";", "i", "++", ")", "{", "if", "(", "isFreeCluster", "(", "i", ")", ")", "{", "entryIndex", "=", "i", ";", "break", ";", "}", "}", "}", "if", "(", "entryIndex", "<", "0", ")", "{", "throw", "new", "IOException", "(", "\"FAT Full (\"", "+", "(", "lastClusterIndex", "-", "FIRST_CLUSTER", ")", "+", "\", \"", "+", "i", "+", "\")\"", ")", ";", "//NOI18N", "}", "entries", "[", "entryIndex", "]", "=", "fatType", ".", "getEofMarker", "(", ")", ";", "lastAllocatedCluster", "=", "entryIndex", "%", "lastClusterIndex", ";", "if", "(", "lastAllocatedCluster", "<", "FIRST_CLUSTER", ")", "lastAllocatedCluster", "=", "FIRST_CLUSTER", ";", "return", "entryIndex", ";", "}" ]
Allocate a cluster for a new file @return long the number of the newly allocated cluster @throws IOException if there are no free clusters
[ "Allocate", "a", "cluster", "for", "a", "new", "file" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L276-L309
7,543
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.allocNew
public long[] allocNew(int nrClusters) throws IOException { final long rc[] = new long[nrClusters]; rc[0] = allocNew(); for (int i = 1; i < nrClusters; i++) { rc[i] = allocAppend(rc[i - 1]); } return rc; }
java
public long[] allocNew(int nrClusters) throws IOException { final long rc[] = new long[nrClusters]; rc[0] = allocNew(); for (int i = 1; i < nrClusters; i++) { rc[i] = allocAppend(rc[i - 1]); } return rc; }
[ "public", "long", "[", "]", "allocNew", "(", "int", "nrClusters", ")", "throws", "IOException", "{", "final", "long", "rc", "[", "]", "=", "new", "long", "[", "nrClusters", "]", ";", "rc", "[", "0", "]", "=", "allocNew", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "nrClusters", ";", "i", "++", ")", "{", "rc", "[", "i", "]", "=", "allocAppend", "(", "rc", "[", "i", "-", "1", "]", ")", ";", "}", "return", "rc", ";", "}" ]
Allocate a series of clusters for a new file. @param nrClusters when number of clusters to allocate @return long @throws IOException if there are no free clusters
[ "Allocate", "a", "series", "of", "clusters", "for", "a", "new", "file", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L348-L357
7,544
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat.java
Fat.allocAppend
public long allocAppend(long cluster) throws IOException { testCluster(cluster); while (!isEofCluster(entries[(int) cluster])) { cluster = entries[(int) cluster]; } long newCluster = allocNew(); entries[(int) cluster] = newCluster; return newCluster; }
java
public long allocAppend(long cluster) throws IOException { testCluster(cluster); while (!isEofCluster(entries[(int) cluster])) { cluster = entries[(int) cluster]; } long newCluster = allocNew(); entries[(int) cluster] = newCluster; return newCluster; }
[ "public", "long", "allocAppend", "(", "long", "cluster", ")", "throws", "IOException", "{", "testCluster", "(", "cluster", ")", ";", "while", "(", "!", "isEofCluster", "(", "entries", "[", "(", "int", ")", "cluster", "]", ")", ")", "{", "cluster", "=", "entries", "[", "(", "int", ")", "cluster", "]", ";", "}", "long", "newCluster", "=", "allocNew", "(", ")", ";", "entries", "[", "(", "int", ")", "cluster", "]", "=", "newCluster", ";", "return", "newCluster", ";", "}" ]
Allocate a cluster to append to a new file @param cluster a cluster from a chain where the new cluster should be appended @return long the newly allocated and appended cluster number @throws IOException if there are no free clusters
[ "Allocate", "a", "cluster", "to", "append", "to", "a", "new", "file" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat.java#L367-L380
7,545
rhiot/rhiot
gateway/components/camel-gpsd/src/main/java/io/rhiot/component/gpsd/GpsdHelper.java
GpsdHelper.consumeTPVObject
public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) { // Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream. LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint); Validate.notNull(tpv); Validate.notNull(processor); Validate.notNull(endpoint); GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude()); Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly). withHeader(TPV_HEADER, tpv).withBody(coordinates).build(); try { processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
java
public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) { // Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream. LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint); Validate.notNull(tpv); Validate.notNull(processor); Validate.notNull(endpoint); GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude()); Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly). withHeader(TPV_HEADER, tpv).withBody(coordinates).build(); try { processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
[ "public", "static", "void", "consumeTPVObject", "(", "TPVObject", "tpv", ",", "Processor", "processor", ",", "GpsdEndpoint", "endpoint", ",", "ExceptionHandler", "exceptionHandler", ")", "{", "// Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream.", "LOG", ".", "debug", "(", "\"About to consume TPV object {},{} from {}\"", ",", "tpv", ".", "getLatitude", "(", ")", ",", "tpv", ".", "getLongitude", "(", ")", ",", "endpoint", ")", ";", "Validate", ".", "notNull", "(", "tpv", ")", ";", "Validate", ".", "notNull", "(", "processor", ")", ";", "Validate", ".", "notNull", "(", "endpoint", ")", ";", "GpsCoordinates", "coordinates", "=", "gpsCoordinates", "(", "new", "Date", "(", "new", "Double", "(", "tpv", ".", "getTimestamp", "(", ")", ")", ".", "longValue", "(", ")", ")", ",", "tpv", ".", "getLatitude", "(", ")", ",", "tpv", ".", "getLongitude", "(", ")", ")", ";", "Exchange", "exchange", "=", "anExchange", "(", "endpoint", ".", "getCamelContext", "(", ")", ")", ".", "withPattern", "(", "OutOnly", ")", ".", "withHeader", "(", "TPV_HEADER", ",", "tpv", ")", ".", "withBody", "(", "coordinates", ")", ".", "build", "(", ")", ";", "try", "{", "processor", ".", "process", "(", "exchange", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "exceptionHandler", ".", "handleException", "(", "e", ")", ";", "}", "}" ]
Process the TPVObject, all params required. @param tpv The time-position-velocity object to process @param processor Processor that handles the exchange. @param endpoint GpsdEndpoint receiving the exchange.
[ "Process", "the", "TPVObject", "all", "params", "required", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-gpsd/src/main/java/io/rhiot/component/gpsd/GpsdHelper.java#L49-L66
7,546
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/data/SenBotReferenceService.java
SenBotReferenceService.namespaceString
public String namespaceString(String plainString) throws RuntimeException { if(plainString.startsWith(NAME_SPACE_PREFIX)) { return (plainString.replace(NAME_SPACE_PREFIX, nameSpaceThreadLocale.get())); } if(plainString.startsWith(SCENARIO_NAME_SPACE_PREFIX)) { if(cucumberManager.getCurrentScenarioGlobals() == null) { throw new ScenarioNameSpaceAccessOutsideScenarioScopeException("You cannot fetch a Scneario namespace outside the scope of a scenario"); } return (plainString.replace(SCENARIO_NAME_SPACE_PREFIX, cucumberManager.getCurrentScenarioGlobals().getNameSpace())); } else { return plainString; } }
java
public String namespaceString(String plainString) throws RuntimeException { if(plainString.startsWith(NAME_SPACE_PREFIX)) { return (plainString.replace(NAME_SPACE_PREFIX, nameSpaceThreadLocale.get())); } if(plainString.startsWith(SCENARIO_NAME_SPACE_PREFIX)) { if(cucumberManager.getCurrentScenarioGlobals() == null) { throw new ScenarioNameSpaceAccessOutsideScenarioScopeException("You cannot fetch a Scneario namespace outside the scope of a scenario"); } return (plainString.replace(SCENARIO_NAME_SPACE_PREFIX, cucumberManager.getCurrentScenarioGlobals().getNameSpace())); } else { return plainString; } }
[ "public", "String", "namespaceString", "(", "String", "plainString", ")", "throws", "RuntimeException", "{", "if", "(", "plainString", ".", "startsWith", "(", "NAME_SPACE_PREFIX", ")", ")", "{", "return", "(", "plainString", ".", "replace", "(", "NAME_SPACE_PREFIX", ",", "nameSpaceThreadLocale", ".", "get", "(", ")", ")", ")", ";", "}", "if", "(", "plainString", ".", "startsWith", "(", "SCENARIO_NAME_SPACE_PREFIX", ")", ")", "{", "if", "(", "cucumberManager", ".", "getCurrentScenarioGlobals", "(", ")", "==", "null", ")", "{", "throw", "new", "ScenarioNameSpaceAccessOutsideScenarioScopeException", "(", "\"You cannot fetch a Scneario namespace outside the scope of a scenario\"", ")", ";", "}", "return", "(", "plainString", ".", "replace", "(", "SCENARIO_NAME_SPACE_PREFIX", ",", "cucumberManager", ".", "getCurrentScenarioGlobals", "(", ")", ".", "getNameSpace", "(", ")", ")", ")", ";", "}", "else", "{", "return", "plainString", ";", "}", "}" ]
Extends the name space prefix with the actual name space All tests that need to ensure privacy, i.e. no other test shall mess up their data, shall use name spacing. Data that can be messed up by other tests and there fore needs to be unique shall contain the name space prefix that will be replaced at run time. @param plainString The string that contains the name spacing string @return The namespacenized string @throws RuntimeExpression In case the name spacing string lives at the wrong location
[ "Extends", "the", "name", "space", "prefix", "with", "the", "actual", "name", "space", "All", "tests", "that", "need", "to", "ensure", "privacy", "i", ".", "e", ".", "no", "other", "test", "shall", "mess", "up", "their", "data", "shall", "use", "name", "spacing", ".", "Data", "that", "can", "be", "messed", "up", "by", "other", "tests", "and", "there", "fore", "needs", "to", "be", "unique", "shall", "contain", "the", "name", "space", "prefix", "that", "will", "be", "replaced", "at", "run", "time", "." ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/data/SenBotReferenceService.java#L243-L256
7,547
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java
ElementService.findExpectedElement
public WebElement findExpectedElement(By by, boolean includeHiddenElements) { log.debug("findExpectedElement() called with: " + by); waitForLoaders(); try { WebElement foundElement = new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()) .until(ExpectedConditions.presenceOfElementLocated(by)); if (includeHiddenElements || foundElement.isDisplayed()) { return foundElement; } else { // the element is found but not visible. Wait to see if it // becomes visible try { new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()).until(ExpectedConditions .visibilityOfElementLocated(by)); return foundElement; } catch (WebDriverException toe) { fail("Element: " + by.toString() + " is found but not visible"); } } } catch (WebDriverException wde) { log.error("Expected element not found: ", wde); fail("Element: " + by.toString() + " not found after waiting for " + getSeleniumManager().getTimeout() + " seconds. Webdriver though exception: " + wde.getClass().getCanonicalName() + " with error message: " + wde.getMessage()); } return null; }
java
public WebElement findExpectedElement(By by, boolean includeHiddenElements) { log.debug("findExpectedElement() called with: " + by); waitForLoaders(); try { WebElement foundElement = new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()) .until(ExpectedConditions.presenceOfElementLocated(by)); if (includeHiddenElements || foundElement.isDisplayed()) { return foundElement; } else { // the element is found but not visible. Wait to see if it // becomes visible try { new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()).until(ExpectedConditions .visibilityOfElementLocated(by)); return foundElement; } catch (WebDriverException toe) { fail("Element: " + by.toString() + " is found but not visible"); } } } catch (WebDriverException wde) { log.error("Expected element not found: ", wde); fail("Element: " + by.toString() + " not found after waiting for " + getSeleniumManager().getTimeout() + " seconds. Webdriver though exception: " + wde.getClass().getCanonicalName() + " with error message: " + wde.getMessage()); } return null; }
[ "public", "WebElement", "findExpectedElement", "(", "By", "by", ",", "boolean", "includeHiddenElements", ")", "{", "log", ".", "debug", "(", "\"findExpectedElement() called with: \"", "+", "by", ")", ";", "waitForLoaders", "(", ")", ";", "try", "{", "WebElement", "foundElement", "=", "new", "WebDriverWait", "(", "getWebDriver", "(", ")", ",", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", ")", ".", "until", "(", "ExpectedConditions", ".", "presenceOfElementLocated", "(", "by", ")", ")", ";", "if", "(", "includeHiddenElements", "||", "foundElement", ".", "isDisplayed", "(", ")", ")", "{", "return", "foundElement", ";", "}", "else", "{", "// the element is found but not visible. Wait to see if it", "// becomes visible", "try", "{", "new", "WebDriverWait", "(", "getWebDriver", "(", ")", ",", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", ")", ".", "until", "(", "ExpectedConditions", ".", "visibilityOfElementLocated", "(", "by", ")", ")", ";", "return", "foundElement", ";", "}", "catch", "(", "WebDriverException", "toe", ")", "{", "fail", "(", "\"Element: \"", "+", "by", ".", "toString", "(", ")", "+", "\" is found but not visible\"", ")", ";", "}", "}", "}", "catch", "(", "WebDriverException", "wde", ")", "{", "log", ".", "error", "(", "\"Expected element not found: \"", ",", "wde", ")", ";", "fail", "(", "\"Element: \"", "+", "by", ".", "toString", "(", ")", "+", "\" not found after waiting for \"", "+", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", "+", "\" seconds. Webdriver though exception: \"", "+", "wde", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\" with error message: \"", "+", "wde", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Find an element that is expected to be on the page @param by - the {@link By} to find @param includeHiddenElements - should hidden elements on the page be included or not @return the matched {@link WebElement} @throws AssertionError if no {@link WebElement} is found or the search times out
[ "Find", "an", "element", "that", "is", "expected", "to", "be", "on", "the", "page" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java#L110-L136
7,548
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java
ElementService.findExpectedElements
public List<WebElement> findExpectedElements(By by) { waitForLoaders(); try { return new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } catch (WebDriverException wde) { log.error("Expected elements not found: ", wde); fail("Element: " + by.toString() + " not found after waiting for " + getSeleniumManager().getTimeout() + " seconds. Webdriver though exception: " + wde.getClass().getCanonicalName() + " with error message: " + wde.getMessage()); } return null; }
java
public List<WebElement> findExpectedElements(By by) { waitForLoaders(); try { return new WebDriverWait(getWebDriver(), getSeleniumManager().getTimeout()) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } catch (WebDriverException wde) { log.error("Expected elements not found: ", wde); fail("Element: " + by.toString() + " not found after waiting for " + getSeleniumManager().getTimeout() + " seconds. Webdriver though exception: " + wde.getClass().getCanonicalName() + " with error message: " + wde.getMessage()); } return null; }
[ "public", "List", "<", "WebElement", ">", "findExpectedElements", "(", "By", "by", ")", "{", "waitForLoaders", "(", ")", ";", "try", "{", "return", "new", "WebDriverWait", "(", "getWebDriver", "(", ")", ",", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", ")", ".", "until", "(", "ExpectedConditions", ".", "presenceOfAllElementsLocatedBy", "(", "by", ")", ")", ";", "}", "catch", "(", "WebDriverException", "wde", ")", "{", "log", ".", "error", "(", "\"Expected elements not found: \"", ",", "wde", ")", ";", "fail", "(", "\"Element: \"", "+", "by", ".", "toString", "(", ")", "+", "\" not found after waiting for \"", "+", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", "+", "\" seconds. Webdriver though exception: \"", "+", "wde", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\" with error message: \"", "+", "wde", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Find all elements expected on the page @param by - the {@link By} to find @return A list of the matched elements {List<@link WebElement>} @throws AssertionError if no {@link WebElement} is found or the search times out
[ "Find", "all", "elements", "expected", "on", "the", "page" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java#L147-L158
7,549
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java
ElementService.getElementExists
public boolean getElementExists(By locator) { waitForLoaders(); List<WebElement> foundElements = getWebDriver().findElements(locator); return (foundElements.size() > 0); }
java
public boolean getElementExists(By locator) { waitForLoaders(); List<WebElement> foundElements = getWebDriver().findElements(locator); return (foundElements.size() > 0); }
[ "public", "boolean", "getElementExists", "(", "By", "locator", ")", "{", "waitForLoaders", "(", ")", ";", "List", "<", "WebElement", ">", "foundElements", "=", "getWebDriver", "(", ")", ".", "findElements", "(", "locator", ")", ";", "return", "(", "foundElements", ".", "size", "(", ")", ">", "0", ")", ";", "}" ]
Tells whether the passed element exists @param locator {@link By} to be matched @return true if the element exists
[ "Tells", "whether", "the", "passed", "element", "exists" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java#L261-L265
7,550
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java
ElementService.viewShouldNotShowElement
public void viewShouldNotShowElement(String viewName, String elementName) throws IllegalAccessException, InterruptedException { boolean pass = false; long startOfLookup = System.currentTimeMillis(); int timeoutInMillies = getSeleniumManager().getTimeout() * 1000; while (!pass) { WebElement found = getElementFromReferencedView(viewName, elementName); try { pass = !found.isDisplayed(); } catch (NoSuchElementException e) { pass = true; } if (!pass) { Thread.sleep(100); } if (System.currentTimeMillis() - startOfLookup > timeoutInMillies) { String foundLocator = getElementLocatorFromReferencedView(viewName, elementName); fail("The element \"" + foundLocator + "\" referenced by \"" + elementName + "\" on view/page \"" + viewName + "\" is still found where it is not expected after " + getSeleniumManager().getTimeout() + " seconds."); break; } } }
java
public void viewShouldNotShowElement(String viewName, String elementName) throws IllegalAccessException, InterruptedException { boolean pass = false; long startOfLookup = System.currentTimeMillis(); int timeoutInMillies = getSeleniumManager().getTimeout() * 1000; while (!pass) { WebElement found = getElementFromReferencedView(viewName, elementName); try { pass = !found.isDisplayed(); } catch (NoSuchElementException e) { pass = true; } if (!pass) { Thread.sleep(100); } if (System.currentTimeMillis() - startOfLookup > timeoutInMillies) { String foundLocator = getElementLocatorFromReferencedView(viewName, elementName); fail("The element \"" + foundLocator + "\" referenced by \"" + elementName + "\" on view/page \"" + viewName + "\" is still found where it is not expected after " + getSeleniumManager().getTimeout() + " seconds."); break; } } }
[ "public", "void", "viewShouldNotShowElement", "(", "String", "viewName", ",", "String", "elementName", ")", "throws", "IllegalAccessException", ",", "InterruptedException", "{", "boolean", "pass", "=", "false", ";", "long", "startOfLookup", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "int", "timeoutInMillies", "=", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", "*", "1000", ";", "while", "(", "!", "pass", ")", "{", "WebElement", "found", "=", "getElementFromReferencedView", "(", "viewName", ",", "elementName", ")", ";", "try", "{", "pass", "=", "!", "found", ".", "isDisplayed", "(", ")", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "pass", "=", "true", ";", "}", "if", "(", "!", "pass", ")", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "if", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "startOfLookup", ">", "timeoutInMillies", ")", "{", "String", "foundLocator", "=", "getElementLocatorFromReferencedView", "(", "viewName", ",", "elementName", ")", ";", "fail", "(", "\"The element \\\"\"", "+", "foundLocator", "+", "\"\\\" referenced by \\\"\"", "+", "elementName", "+", "\"\\\" on view/page \\\"\"", "+", "viewName", "+", "\"\\\" is still found where it is not expected after \"", "+", "getSeleniumManager", "(", ")", ".", "getTimeout", "(", ")", "+", "\" seconds.\"", ")", ";", "break", ";", "}", "}", "}" ]
The referenced view should not show the element identified by elementName @param viewName @param elementName @throws IllegalAccessException @throws InterruptedException
[ "The", "referenced", "view", "should", "not", "show", "the", "element", "identified", "by", "elementName" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/ElementService.java#L488-L514
7,551
rhiot/rhiot
lib/utils/src/main/java/io/rhiot/utils/geo/Geos.java
Geos.convertDdmCoordinatesToDecimal
public static double convertDdmCoordinatesToDecimal(String ddmCoordinate) { checkArgument(isNotBlank(ddmCoordinate), "Coordinate to convert can't be null nor blank."); int dotIndex = ddmCoordinate.indexOf('.'); double degrees = parseDouble(ddmCoordinate.substring(0, dotIndex - 2)); double minutes = parseDouble(ddmCoordinate.substring(dotIndex - 2)); double decimalCoordinates = degrees + minutes/60; LOG.debug("Converted NMEA DDM degree coordinate {} (degrees/minutes: {}/{}) to decimal coordinate {}.", ddmCoordinate, degrees, minutes, decimalCoordinates); return decimalCoordinates; }
java
public static double convertDdmCoordinatesToDecimal(String ddmCoordinate) { checkArgument(isNotBlank(ddmCoordinate), "Coordinate to convert can't be null nor blank."); int dotIndex = ddmCoordinate.indexOf('.'); double degrees = parseDouble(ddmCoordinate.substring(0, dotIndex - 2)); double minutes = parseDouble(ddmCoordinate.substring(dotIndex - 2)); double decimalCoordinates = degrees + minutes/60; LOG.debug("Converted NMEA DDM degree coordinate {} (degrees/minutes: {}/{}) to decimal coordinate {}.", ddmCoordinate, degrees, minutes, decimalCoordinates); return decimalCoordinates; }
[ "public", "static", "double", "convertDdmCoordinatesToDecimal", "(", "String", "ddmCoordinate", ")", "{", "checkArgument", "(", "isNotBlank", "(", "ddmCoordinate", ")", ",", "\"Coordinate to convert can't be null nor blank.\"", ")", ";", "int", "dotIndex", "=", "ddmCoordinate", ".", "indexOf", "(", "'", "'", ")", ";", "double", "degrees", "=", "parseDouble", "(", "ddmCoordinate", ".", "substring", "(", "0", ",", "dotIndex", "-", "2", ")", ")", ";", "double", "minutes", "=", "parseDouble", "(", "ddmCoordinate", ".", "substring", "(", "dotIndex", "-", "2", ")", ")", ";", "double", "decimalCoordinates", "=", "degrees", "+", "minutes", "/", "60", ";", "LOG", ".", "debug", "(", "\"Converted NMEA DDM degree coordinate {} (degrees/minutes: {}/{}) to decimal coordinate {}.\"", ",", "ddmCoordinate", ",", "degrees", ",", "minutes", ",", "decimalCoordinates", ")", ";", "return", "decimalCoordinates", ";", "}" ]
Converts Degrees Decimal Minutes GPS coordinate string into the decimal value. @param ddmCoordinate Degrees Decimal Minutes GPS coordinate to convert. Can't be null nor blank. @return GPS coordinates in decimal format
[ "Converts", "Degrees", "Decimal", "Minutes", "GPS", "coordinate", "string", "into", "the", "decimal", "value", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/lib/utils/src/main/java/io/rhiot/utils/geo/Geos.java#L39-L48
7,552
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/yaml/YamlUtils.java
YamlUtils.getYamlObjectValue
public static Map<String, Object> getYamlObjectValue(Map<String, Object> yamlObject, String key, boolean allowsEmpty) throws YamlConvertException { Object obj = getObjectValue(yamlObject, key, allowsEmpty); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) obj; return result; }
java
public static Map<String, Object> getYamlObjectValue(Map<String, Object> yamlObject, String key, boolean allowsEmpty) throws YamlConvertException { Object obj = getObjectValue(yamlObject, key, allowsEmpty); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) obj; return result; }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "getYamlObjectValue", "(", "Map", "<", "String", ",", "Object", ">", "yamlObject", ",", "String", "key", ",", "boolean", "allowsEmpty", ")", "throws", "YamlConvertException", "{", "Object", "obj", "=", "getObjectValue", "(", "yamlObject", ",", "key", ",", "allowsEmpty", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "obj", ";", "return", "result", ";", "}" ]
returns null for empty
[ "returns", "null", "for", "empty" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/yaml/YamlUtils.java#L187-L193
7,553
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/yaml/YamlUtils.java
YamlUtils.getYamlObjectValue
public static Map<String, Object> getYamlObjectValue(Map<String, Object> yamlObject, String key) throws YamlConvertException { return getYamlObjectValue(yamlObject, key, false); }
java
public static Map<String, Object> getYamlObjectValue(Map<String, Object> yamlObject, String key) throws YamlConvertException { return getYamlObjectValue(yamlObject, key, false); }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "getYamlObjectValue", "(", "Map", "<", "String", ",", "Object", ">", "yamlObject", ",", "String", "key", ")", "throws", "YamlConvertException", "{", "return", "getYamlObjectValue", "(", "yamlObject", ",", "key", ",", "false", ")", ";", "}" ]
for null or not found, returns null
[ "for", "null", "or", "not", "found", "returns", "null" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/yaml/YamlUtils.java#L196-L199
7,554
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/yaml/YamlUtils.java
YamlUtils.getStrListValue
public static List<String> getStrListValue(Map<String, Object> yamlObject, String key, boolean allowsEmpty) throws YamlConvertException { Object obj = getObjectValue(yamlObject, key, allowsEmpty); @SuppressWarnings("unchecked") List<String> result = (List<String>) obj; if (result == null) { if (!allowsEmpty) { throw new YamlConvertException(MSG_LIST_MUST_NOT_BE_NULL); } result = new ArrayList<>(0); } return result; }
java
public static List<String> getStrListValue(Map<String, Object> yamlObject, String key, boolean allowsEmpty) throws YamlConvertException { Object obj = getObjectValue(yamlObject, key, allowsEmpty); @SuppressWarnings("unchecked") List<String> result = (List<String>) obj; if (result == null) { if (!allowsEmpty) { throw new YamlConvertException(MSG_LIST_MUST_NOT_BE_NULL); } result = new ArrayList<>(0); } return result; }
[ "public", "static", "List", "<", "String", ">", "getStrListValue", "(", "Map", "<", "String", ",", "Object", ">", "yamlObject", ",", "String", "key", ",", "boolean", "allowsEmpty", ")", "throws", "YamlConvertException", "{", "Object", "obj", "=", "getObjectValue", "(", "yamlObject", ",", "key", ",", "allowsEmpty", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "String", ">", "result", "=", "(", "List", "<", "String", ">", ")", "obj", ";", "if", "(", "result", "==", "null", ")", "{", "if", "(", "!", "allowsEmpty", ")", "{", "throw", "new", "YamlConvertException", "(", "MSG_LIST_MUST_NOT_BE_NULL", ")", ";", "}", "result", "=", "new", "ArrayList", "<>", "(", "0", ")", ";", "}", "return", "result", ";", "}" ]
for null or not found key, returns empty list
[ "for", "null", "or", "not", "found", "key", "returns", "empty", "list" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/yaml/YamlUtils.java#L202-L214
7,555
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/yaml/YamlUtils.java
YamlUtils.load
public static Map<String, Object> load(InputStream input) { Yaml yaml = new Yaml(); Object rawYamlObj = yaml.load(input); @SuppressWarnings("unchecked") Map<String, Object> yamlObj = (Map<String, Object>) rawYamlObj; return yamlObj; }
java
public static Map<String, Object> load(InputStream input) { Yaml yaml = new Yaml(); Object rawYamlObj = yaml.load(input); @SuppressWarnings("unchecked") Map<String, Object> yamlObj = (Map<String, Object>) rawYamlObj; return yamlObj; }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "load", "(", "InputStream", "input", ")", "{", "Yaml", "yaml", "=", "new", "Yaml", "(", ")", ";", "Object", "rawYamlObj", "=", "yaml", ".", "load", "(", "input", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Object", ">", "yamlObj", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "rawYamlObj", ";", "return", "yamlObj", ";", "}" ]
this method does not close the stream
[ "this", "method", "does", "not", "close", "the", "stream" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/yaml/YamlUtils.java#L279-L285
7,556
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/Query.java
Query.create
public static Query create(String query) throws QueryParserException { QueryTokenizer tokenizer = new QueryTokenizerImpl(); QueryParser parser = new QueryParserImpl(); return parser.parse(tokenizer.tokenize(query)); }
java
public static Query create(String query) throws QueryParserException { QueryTokenizer tokenizer = new QueryTokenizerImpl(); QueryParser parser = new QueryParserImpl(); return parser.parse(tokenizer.tokenize(query)); }
[ "public", "static", "Query", "create", "(", "String", "query", ")", "throws", "QueryParserException", "{", "QueryTokenizer", "tokenizer", "=", "new", "QueryTokenizerImpl", "(", ")", ";", "QueryParser", "parser", "=", "new", "QueryParserImpl", "(", ")", ";", "return", "parser", ".", "parse", "(", "tokenizer", ".", "tokenize", "(", "query", ")", ")", ";", "}" ]
A factory method to create a query from string. @param query @return @throws QueryParserException
[ "A", "factory", "method", "to", "create", "a", "query", "from", "string", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/Query.java#L100-L107
7,557
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java
Fat16BootSector.getVolumeLabel
public String getVolumeLabel() { final StringBuilder sb = new StringBuilder(); for (int i=0; i < MAX_VOLUME_LABEL_LENGTH; i++) { final char c = (char) get8(VOLUME_LABEL_OFFSET + i); if (c != 0) { sb.append(c); } else { break; } } return sb.toString(); }
java
public String getVolumeLabel() { final StringBuilder sb = new StringBuilder(); for (int i=0; i < MAX_VOLUME_LABEL_LENGTH; i++) { final char c = (char) get8(VOLUME_LABEL_OFFSET + i); if (c != 0) { sb.append(c); } else { break; } } return sb.toString(); }
[ "public", "String", "getVolumeLabel", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "MAX_VOLUME_LABEL_LENGTH", ";", "i", "++", ")", "{", "final", "char", "c", "=", "(", "char", ")", "get8", "(", "VOLUME_LABEL_OFFSET", "+", "i", ")", ";", "if", "(", "c", "!=", "0", ")", "{", "sb", ".", "append", "(", "c", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns the volume label that is stored in this boot sector. @return the volume label
[ "Returns", "the", "volume", "label", "that", "is", "stored", "in", "this", "boot", "sector", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java#L102-L116
7,558
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java
Fat16BootSector.setVolumeLabel
public void setVolumeLabel(String label) throws IllegalArgumentException { if (label.length() > MAX_VOLUME_LABEL_LENGTH) throw new IllegalArgumentException("volume label too long"); for (int i = 0; i < MAX_VOLUME_LABEL_LENGTH; i++) { set8(VOLUME_LABEL_OFFSET + i, i < label.length() ? label.charAt(i) : 0); } }
java
public void setVolumeLabel(String label) throws IllegalArgumentException { if (label.length() > MAX_VOLUME_LABEL_LENGTH) throw new IllegalArgumentException("volume label too long"); for (int i = 0; i < MAX_VOLUME_LABEL_LENGTH; i++) { set8(VOLUME_LABEL_OFFSET + i, i < label.length() ? label.charAt(i) : 0); } }
[ "public", "void", "setVolumeLabel", "(", "String", "label", ")", "throws", "IllegalArgumentException", "{", "if", "(", "label", ".", "length", "(", ")", ">", "MAX_VOLUME_LABEL_LENGTH", ")", "throw", "new", "IllegalArgumentException", "(", "\"volume label too long\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "MAX_VOLUME_LABEL_LENGTH", ";", "i", "++", ")", "{", "set8", "(", "VOLUME_LABEL_OFFSET", "+", "i", ",", "i", "<", "label", ".", "length", "(", ")", "?", "label", ".", "charAt", "(", "i", ")", ":", "0", ")", ";", "}", "}" ]
Sets the volume label that is stored in this boot sector. @param label the new volume label @throws IllegalArgumentException if the specified label is longer than {@link #MAX_VOLUME_LABEL_LENGTH}
[ "Sets", "the", "volume", "label", "that", "is", "stored", "in", "this", "boot", "sector", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java#L125-L133
7,559
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java
Fat16BootSector.setRootDirEntryCount
public void setRootDirEntryCount(int v) throws IllegalArgumentException { if (v < 0) throw new IllegalArgumentException(); if (v == getRootDirEntryCount()) return; set16(ROOT_DIR_ENTRIES_OFFSET, v); }
java
public void setRootDirEntryCount(int v) throws IllegalArgumentException { if (v < 0) throw new IllegalArgumentException(); if (v == getRootDirEntryCount()) return; set16(ROOT_DIR_ENTRIES_OFFSET, v); }
[ "public", "void", "setRootDirEntryCount", "(", "int", "v", ")", "throws", "IllegalArgumentException", "{", "if", "(", "v", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "if", "(", "v", "==", "getRootDirEntryCount", "(", ")", ")", "return", ";", "set16", "(", "ROOT_DIR_ENTRIES_OFFSET", ",", "v", ")", ";", "}" ]
Sets the number of entries in the root directory @param v the new number of entries in the root directory @throws IllegalArgumentException for negative values
[ "Sets", "the", "number", "of", "entries", "in", "the", "root", "directory" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java#L208-L213
7,560
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java
AbstractDirectory.setEntries
public void setEntries(List<FatDirectoryEntry> newEntries) { if (newEntries.size() > capacity) throw new IllegalArgumentException("too many entries"); this.entries.clear(); this.entries.addAll(newEntries); }
java
public void setEntries(List<FatDirectoryEntry> newEntries) { if (newEntries.size() > capacity) throw new IllegalArgumentException("too many entries"); this.entries.clear(); this.entries.addAll(newEntries); }
[ "public", "void", "setEntries", "(", "List", "<", "FatDirectoryEntry", ">", "newEntries", ")", "{", "if", "(", "newEntries", ".", "size", "(", ")", ">", "capacity", ")", "throw", "new", "IllegalArgumentException", "(", "\"too many entries\"", ")", ";", "this", ".", "entries", ".", "clear", "(", ")", ";", "this", ".", "entries", ".", "addAll", "(", "newEntries", ")", ";", "}" ]
Replaces all entries in this directory. @param newEntries the new directory entries
[ "Replaces", "all", "entries", "in", "this", "directory", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java#L118-L124
7,561
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java
AbstractDirectory.flush
public void flush() throws IOException { final ByteBuffer data = ByteBuffer.allocate( getCapacity() * FatDirectoryEntry.SIZE + (volumeLabel != null ? FatDirectoryEntry.SIZE : 0)); for (FatDirectoryEntry entry : this.entries) { if (entry != null) { entry.write(data); } } /* TODO: the label could be placed directly the dot entries */ if (this.volumeLabel != null) { final FatDirectoryEntry labelEntry = FatDirectoryEntry.createVolumeLabel(type, volumeLabel); labelEntry.write(data); } if (data.hasRemaining()) { FatDirectoryEntry.writeNullEntry(data); } data.flip(); write(data); resetDirty(); }
java
public void flush() throws IOException { final ByteBuffer data = ByteBuffer.allocate( getCapacity() * FatDirectoryEntry.SIZE + (volumeLabel != null ? FatDirectoryEntry.SIZE : 0)); for (FatDirectoryEntry entry : this.entries) { if (entry != null) { entry.write(data); } } /* TODO: the label could be placed directly the dot entries */ if (this.volumeLabel != null) { final FatDirectoryEntry labelEntry = FatDirectoryEntry.createVolumeLabel(type, volumeLabel); labelEntry.write(data); } if (data.hasRemaining()) { FatDirectoryEntry.writeNullEntry(data); } data.flip(); write(data); resetDirty(); }
[ "public", "void", "flush", "(", ")", "throws", "IOException", "{", "final", "ByteBuffer", "data", "=", "ByteBuffer", ".", "allocate", "(", "getCapacity", "(", ")", "*", "FatDirectoryEntry", ".", "SIZE", "+", "(", "volumeLabel", "!=", "null", "?", "FatDirectoryEntry", ".", "SIZE", ":", "0", ")", ")", ";", "for", "(", "FatDirectoryEntry", "entry", ":", "this", ".", "entries", ")", "{", "if", "(", "entry", "!=", "null", ")", "{", "entry", ".", "write", "(", "data", ")", ";", "}", "}", "/* TODO: the label could be placed directly the dot entries */", "if", "(", "this", ".", "volumeLabel", "!=", "null", ")", "{", "final", "FatDirectoryEntry", "labelEntry", "=", "FatDirectoryEntry", ".", "createVolumeLabel", "(", "type", ",", "volumeLabel", ")", ";", "labelEntry", ".", "write", "(", "data", ")", ";", "}", "if", "(", "data", ".", "hasRemaining", "(", ")", ")", "{", "FatDirectoryEntry", ".", "writeNullEntry", "(", "data", ")", ";", "}", "data", ".", "flip", "(", ")", ";", "write", "(", "data", ")", ";", "resetDirty", "(", ")", ";", "}" ]
Flush the contents of this directory to the persistent storage
[ "Flush", "the", "contents", "of", "this", "directory", "to", "the", "persistent", "storage" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java#L214-L242
7,562
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java
AbstractDirectory.setLabel
public void setLabel(String label) throws IllegalArgumentException, UnsupportedOperationException, IOException { checkRoot(); if (label != null && label.length() > MAX_LABEL_LENGTH) throw new IllegalArgumentException("label too long"); if (this.volumeLabel != null) { if (label == null) { changeSize(getSize() - 1); this.volumeLabel = null; } else { ShortName.checkValidChars(label.getBytes(ShortName.ASCII)); this.volumeLabel = label; } } else { if (label != null) { changeSize(getSize() + 1); ShortName.checkValidChars(label.getBytes(ShortName.ASCII)); this.volumeLabel = label; } } this.dirty = true; }
java
public void setLabel(String label) throws IllegalArgumentException, UnsupportedOperationException, IOException { checkRoot(); if (label != null && label.length() > MAX_LABEL_LENGTH) throw new IllegalArgumentException("label too long"); if (this.volumeLabel != null) { if (label == null) { changeSize(getSize() - 1); this.volumeLabel = null; } else { ShortName.checkValidChars(label.getBytes(ShortName.ASCII)); this.volumeLabel = label; } } else { if (label != null) { changeSize(getSize() + 1); ShortName.checkValidChars(label.getBytes(ShortName.ASCII)); this.volumeLabel = label; } } this.dirty = true; }
[ "public", "void", "setLabel", "(", "String", "label", ")", "throws", "IllegalArgumentException", ",", "UnsupportedOperationException", ",", "IOException", "{", "checkRoot", "(", ")", ";", "if", "(", "label", "!=", "null", "&&", "label", ".", "length", "(", ")", ">", "MAX_LABEL_LENGTH", ")", "throw", "new", "IllegalArgumentException", "(", "\"label too long\"", ")", ";", "if", "(", "this", ".", "volumeLabel", "!=", "null", ")", "{", "if", "(", "label", "==", "null", ")", "{", "changeSize", "(", "getSize", "(", ")", "-", "1", ")", ";", "this", ".", "volumeLabel", "=", "null", ";", "}", "else", "{", "ShortName", ".", "checkValidChars", "(", "label", ".", "getBytes", "(", "ShortName", ".", "ASCII", ")", ")", ";", "this", ".", "volumeLabel", "=", "label", ";", "}", "}", "else", "{", "if", "(", "label", "!=", "null", ")", "{", "changeSize", "(", "getSize", "(", ")", "+", "1", ")", ";", "ShortName", ".", "checkValidChars", "(", "label", ".", "getBytes", "(", "ShortName", ".", "ASCII", ")", ")", ";", "this", ".", "volumeLabel", "=", "label", ";", "}", "}", "this", ".", "dirty", "=", "true", ";", "}" ]
Sets the volume label that is stored in this directory. Setting the volume label is supported on the root directory only. @param label the new volume label @throws IllegalArgumentException if the label is too long @throws UnsupportedOperationException if this is not a root directory @see #isRoot()
[ "Sets", "the", "volume", "label", "that", "is", "stored", "in", "this", "directory", ".", "Setting", "the", "volume", "label", "is", "supported", "on", "the", "root", "directory", "only", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/AbstractDirectory.java#L357-L382
7,563
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/BootSector.java
BootSector.getFileSystemTypeLabel
public String getFileSystemTypeLabel() { final StringBuilder sb = new StringBuilder(FILE_SYSTEM_TYPE_LENGTH); for (int i=0; i < FILE_SYSTEM_TYPE_LENGTH; i++) { sb.append ((char) get8(getFileSystemTypeLabelOffset() + i)); } return sb.toString(); }
java
public String getFileSystemTypeLabel() { final StringBuilder sb = new StringBuilder(FILE_SYSTEM_TYPE_LENGTH); for (int i=0; i < FILE_SYSTEM_TYPE_LENGTH; i++) { sb.append ((char) get8(getFileSystemTypeLabelOffset() + i)); } return sb.toString(); }
[ "public", "String", "getFileSystemTypeLabel", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "FILE_SYSTEM_TYPE_LENGTH", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "FILE_SYSTEM_TYPE_LENGTH", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "(", "char", ")", "get8", "(", "getFileSystemTypeLabelOffset", "(", ")", "+", "i", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns the file system type label string. @return the file system type string @see #setFileSystemTypeLabel(java.lang.String) @see #getFileSystemTypeLabelOffset() @see #FILE_SYSTEM_TYPE_LENGTH
[ "Returns", "the", "file", "system", "type", "label", "string", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/BootSector.java#L234-L242
7,564
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/BootSector.java
BootSector.getOemName
public String getOemName() { StringBuilder b = new StringBuilder(8); for (int i = 0; i < 8; i++) { int v = get8(0x3 + i); if (v == 0) break; b.append((char) v); } return b.toString(); }
java
public String getOemName() { StringBuilder b = new StringBuilder(8); for (int i = 0; i < 8; i++) { int v = get8(0x3 + i); if (v == 0) break; b.append((char) v); } return b.toString(); }
[ "public", "String", "getOemName", "(", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", "8", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "int", "v", "=", "get8", "(", "0x3", "+", "i", ")", ";", "if", "(", "v", "==", "0", ")", "break", ";", "b", ".", "append", "(", "(", "char", ")", "v", ")", ";", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Gets the OEM name @return String
[ "Gets", "the", "OEM", "name" ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/BootSector.java#L289-L299
7,565
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/BootSector.java
BootSector.setOemName
public void setOemName(String name) { if (name.length() > 8) throw new IllegalArgumentException( "only 8 characters are allowed"); for (int i = 0; i < 8; i++) { char ch; if (i < name.length()) { ch = name.charAt(i); } else { ch = (char) 0; } set8(0x3 + i, ch); } }
java
public void setOemName(String name) { if (name.length() > 8) throw new IllegalArgumentException( "only 8 characters are allowed"); for (int i = 0; i < 8; i++) { char ch; if (i < name.length()) { ch = name.charAt(i); } else { ch = (char) 0; } set8(0x3 + i, ch); } }
[ "public", "void", "setOemName", "(", "String", "name", ")", "{", "if", "(", "name", ".", "length", "(", ")", ">", "8", ")", "throw", "new", "IllegalArgumentException", "(", "\"only 8 characters are allowed\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "char", "ch", ";", "if", "(", "i", "<", "name", ".", "length", "(", ")", ")", "{", "ch", "=", "name", ".", "charAt", "(", "i", ")", ";", "}", "else", "{", "ch", "=", "(", "char", ")", "0", ";", "}", "set8", "(", "0x3", "+", "i", ",", "ch", ")", ";", "}", "}" ]
Sets the OEM name, must be at most 8 characters long. @param name the new OEM name
[ "Sets", "the", "OEM", "name", "must", "be", "at", "most", "8", "characters", "long", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/BootSector.java#L307-L321
7,566
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/CommonUtils.java
CommonUtils.compare
public static int compare(String left, String right) { if (left == null) { if (right == null) { return 0; } else { return 1; // nulls last } } else if (right == null) { return -1; // nulls last } return left.compareTo(right); }
java
public static int compare(String left, String right) { if (left == null) { if (right == null) { return 0; } else { return 1; // nulls last } } else if (right == null) { return -1; // nulls last } return left.compareTo(right); }
[ "public", "static", "int", "compare", "(", "String", "left", ",", "String", "right", ")", "{", "if", "(", "left", "==", "null", ")", "{", "if", "(", "right", "==", "null", ")", "{", "return", "0", ";", "}", "else", "{", "return", "1", ";", "// nulls last", "}", "}", "else", "if", "(", "right", "==", "null", ")", "{", "return", "-", "1", ";", "// nulls last", "}", "return", "left", ".", "compareTo", "(", "right", ")", ";", "}" ]
0 if equals
[ "0", "if", "equals" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/CommonUtils.java#L32-L43
7,567
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/CommonUtils.java
CommonUtils.encodeToSafeAsciiFileNameString
public static String encodeToSafeAsciiFileNameString(String str, Charset strCharset) { if (str == null) { return str; } if (!SAFE_ASCII_PATTERN.matcher(str).matches()) { return calcSHA1Digest(str, strCharset); } // encode again since if str is SHA1 digest // it can easily conflict with the other encoded string if (SHA1_DIGEST_PATTERN.matcher(str).matches()) { return calcSHA1Digest(str, strCharset); } return str; }
java
public static String encodeToSafeAsciiFileNameString(String str, Charset strCharset) { if (str == null) { return str; } if (!SAFE_ASCII_PATTERN.matcher(str).matches()) { return calcSHA1Digest(str, strCharset); } // encode again since if str is SHA1 digest // it can easily conflict with the other encoded string if (SHA1_DIGEST_PATTERN.matcher(str).matches()) { return calcSHA1Digest(str, strCharset); } return str; }
[ "public", "static", "String", "encodeToSafeAsciiFileNameString", "(", "String", "str", ",", "Charset", "strCharset", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "str", ";", "}", "if", "(", "!", "SAFE_ASCII_PATTERN", ".", "matcher", "(", "str", ")", ".", "matches", "(", ")", ")", "{", "return", "calcSHA1Digest", "(", "str", ",", "strCharset", ")", ";", "}", "// encode again since if str is SHA1 digest", "// it can easily conflict with the other encoded string", "if", "(", "SHA1_DIGEST_PATTERN", ".", "matcher", "(", "str", ")", ".", "matches", "(", ")", ")", "{", "return", "calcSHA1Digest", "(", "str", ",", "strCharset", ")", ";", "}", "return", "str", ";", "}" ]
- character which will be encoded by URL encoding
[ "-", "character", "which", "will", "be", "encoded", "by", "URL", "encoding" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/CommonUtils.java#L139-L152
7,568
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/CommonUtils.java
CommonUtils.readManifestFromExternalJar
public static Manifest readManifestFromExternalJar(File jarFile) { if (!jarFile.getName().endsWith(".jar")) { throw new IllegalArgumentException("not jar file : " + jarFile); } InputStream in = null; String urlStr = "jar:file:" + jarFile.getAbsolutePath() + "!/META-INF/MANIFEST.MF"; try { URL inputURL = new URL(urlStr); JarURLConnection conn = (JarURLConnection) inputURL.openConnection(); in = conn.getInputStream(); return new Manifest(in); } catch (FileNotFoundException e) { return null; } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(in); } }
java
public static Manifest readManifestFromExternalJar(File jarFile) { if (!jarFile.getName().endsWith(".jar")) { throw new IllegalArgumentException("not jar file : " + jarFile); } InputStream in = null; String urlStr = "jar:file:" + jarFile.getAbsolutePath() + "!/META-INF/MANIFEST.MF"; try { URL inputURL = new URL(urlStr); JarURLConnection conn = (JarURLConnection) inputURL.openConnection(); in = conn.getInputStream(); return new Manifest(in); } catch (FileNotFoundException e) { return null; } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(in); } }
[ "public", "static", "Manifest", "readManifestFromExternalJar", "(", "File", "jarFile", ")", "{", "if", "(", "!", "jarFile", ".", "getName", "(", ")", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"not jar file : \"", "+", "jarFile", ")", ";", "}", "InputStream", "in", "=", "null", ";", "String", "urlStr", "=", "\"jar:file:\"", "+", "jarFile", ".", "getAbsolutePath", "(", ")", "+", "\"!/META-INF/MANIFEST.MF\"", ";", "try", "{", "URL", "inputURL", "=", "new", "URL", "(", "urlStr", ")", ";", "JarURLConnection", "conn", "=", "(", "JarURLConnection", ")", "inputURL", ".", "openConnection", "(", ")", ";", "in", "=", "conn", ".", "getInputStream", "(", ")", ";", "return", "new", "Manifest", "(", "in", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "return", "null", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "}" ]
returns null if no manifest found
[ "returns", "null", "if", "no", "manifest", "found" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/CommonUtils.java#L155-L173
7,569
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/CucumberReportingExtension.java
CucumberReportingExtension.afterScenario
@After public void afterScenario(Scenario scenario) throws InterruptedException { log.debug("Scenarion finished"); ScenarioGlobals scenarioGlobals = getCucumberManager().getCurrentScenarioGlobals(); TestEnvironment testNev = getSeleniumManager().getAssociatedTestEnvironment(); if (testNev != null && scenarioGlobals != null) { boolean scenarioUsedSelenium = testNev.isWebDriverAccessedSince(scenarioGlobals.getScenarioStart()); if (scenarioUsedSelenium) { if (scenario.isFailed()) { log.debug("Scenarion failed while using selenium, so capture screenshot"); TakesScreenshot seleniumDriver = (TakesScreenshot) SenBotContext.getSeleniumDriver(); byte[] screenshotAs = seleniumDriver.getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotAs, "image/png"); } } } getCucumberManager().stopNewScenario(); }
java
@After public void afterScenario(Scenario scenario) throws InterruptedException { log.debug("Scenarion finished"); ScenarioGlobals scenarioGlobals = getCucumberManager().getCurrentScenarioGlobals(); TestEnvironment testNev = getSeleniumManager().getAssociatedTestEnvironment(); if (testNev != null && scenarioGlobals != null) { boolean scenarioUsedSelenium = testNev.isWebDriverAccessedSince(scenarioGlobals.getScenarioStart()); if (scenarioUsedSelenium) { if (scenario.isFailed()) { log.debug("Scenarion failed while using selenium, so capture screenshot"); TakesScreenshot seleniumDriver = (TakesScreenshot) SenBotContext.getSeleniumDriver(); byte[] screenshotAs = seleniumDriver.getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotAs, "image/png"); } } } getCucumberManager().stopNewScenario(); }
[ "@", "After", "public", "void", "afterScenario", "(", "Scenario", "scenario", ")", "throws", "InterruptedException", "{", "log", ".", "debug", "(", "\"Scenarion finished\"", ")", ";", "ScenarioGlobals", "scenarioGlobals", "=", "getCucumberManager", "(", ")", ".", "getCurrentScenarioGlobals", "(", ")", ";", "TestEnvironment", "testNev", "=", "getSeleniumManager", "(", ")", ".", "getAssociatedTestEnvironment", "(", ")", ";", "if", "(", "testNev", "!=", "null", "&&", "scenarioGlobals", "!=", "null", ")", "{", "boolean", "scenarioUsedSelenium", "=", "testNev", ".", "isWebDriverAccessedSince", "(", "scenarioGlobals", ".", "getScenarioStart", "(", ")", ")", ";", "if", "(", "scenarioUsedSelenium", ")", "{", "if", "(", "scenario", ".", "isFailed", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Scenarion failed while using selenium, so capture screenshot\"", ")", ";", "TakesScreenshot", "seleniumDriver", "=", "(", "TakesScreenshot", ")", "SenBotContext", ".", "getSeleniumDriver", "(", ")", ";", "byte", "[", "]", "screenshotAs", "=", "seleniumDriver", ".", "getScreenshotAs", "(", "OutputType", ".", "BYTES", ")", ";", "scenario", ".", "embed", "(", "screenshotAs", ",", "\"image/png\"", ")", ";", "}", "}", "}", "getCucumberManager", "(", ")", ".", "stopNewScenario", "(", ")", ";", "}" ]
Capture a selenium screenshot when a test fails and add it to the Cucumber generated report if the scenario has accessed selenium in its lifetime @throws InterruptedException
[ "Capture", "a", "selenium", "screenshot", "when", "a", "test", "fails", "and", "add", "it", "to", "the", "Cucumber", "generated", "report", "if", "the", "scenario", "has", "accessed", "selenium", "in", "its", "lifetime" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/CucumberReportingExtension.java#L40-L57
7,570
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamEndpoint.java
WebcamEndpoint.getDefaultResolution
private Dimension getDefaultResolution() { if (getResolution() != null) { WebcamResolution res = WebcamResolution.valueOf(getResolution()); return res.getSize(); } else { return new Dimension(getWidth(), getHeight()); } }
java
private Dimension getDefaultResolution() { if (getResolution() != null) { WebcamResolution res = WebcamResolution.valueOf(getResolution()); return res.getSize(); } else { return new Dimension(getWidth(), getHeight()); } }
[ "private", "Dimension", "getDefaultResolution", "(", ")", "{", "if", "(", "getResolution", "(", ")", "!=", "null", ")", "{", "WebcamResolution", "res", "=", "WebcamResolution", ".", "valueOf", "(", "getResolution", "(", ")", ")", ";", "return", "res", ".", "getSize", "(", ")", ";", "}", "else", "{", "return", "new", "Dimension", "(", "getWidth", "(", ")", ",", "getHeight", "(", ")", ")", ";", "}", "}" ]
Returns the default resolution by name if provided, eg HD720, otherwise the width and height.
[ "Returns", "the", "default", "resolution", "by", "name", "if", "provided", "eg", "HD720", "otherwise", "the", "width", "and", "height", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamEndpoint.java#L100-L107
7,571
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java
WebcamHelper.createOutOnlyExchangeWithBodyAndHeaders
static Exchange createOutOnlyExchangeWithBodyAndHeaders(WebcamEndpoint endpoint, BufferedImage image) throws IOException { Exchange exchange = endpoint.createExchange(ExchangePattern.OutOnly); Message message = exchange.getIn(); try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { ImageIO.write(image, endpoint.getFormat(), output); message.setBody(new BufferedInputStream(new ByteArrayInputStream(output.toByteArray()))); message.setHeader(Exchange.FILE_NAME, message.getMessageId() + "" + endpoint.getFormat()); } return exchange; }
java
static Exchange createOutOnlyExchangeWithBodyAndHeaders(WebcamEndpoint endpoint, BufferedImage image) throws IOException { Exchange exchange = endpoint.createExchange(ExchangePattern.OutOnly); Message message = exchange.getIn(); try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { ImageIO.write(image, endpoint.getFormat(), output); message.setBody(new BufferedInputStream(new ByteArrayInputStream(output.toByteArray()))); message.setHeader(Exchange.FILE_NAME, message.getMessageId() + "" + endpoint.getFormat()); } return exchange; }
[ "static", "Exchange", "createOutOnlyExchangeWithBodyAndHeaders", "(", "WebcamEndpoint", "endpoint", ",", "BufferedImage", "image", ")", "throws", "IOException", "{", "Exchange", "exchange", "=", "endpoint", ".", "createExchange", "(", "ExchangePattern", ".", "OutOnly", ")", ";", "Message", "message", "=", "exchange", ".", "getIn", "(", ")", ";", "try", "(", "ByteArrayOutputStream", "output", "=", "new", "ByteArrayOutputStream", "(", ")", ")", "{", "ImageIO", ".", "write", "(", "image", ",", "endpoint", ".", "getFormat", "(", ")", ",", "output", ")", ";", "message", ".", "setBody", "(", "new", "BufferedInputStream", "(", "new", "ByteArrayInputStream", "(", "output", ".", "toByteArray", "(", ")", ")", ")", ")", ";", "message", ".", "setHeader", "(", "Exchange", ".", "FILE_NAME", ",", "message", ".", "getMessageId", "(", ")", "+", "\"\"", "+", "endpoint", ".", "getFormat", "(", ")", ")", ";", "}", "return", "exchange", ";", "}" ]
Creates an OutOnly exchange with the BufferedImage.
[ "Creates", "an", "OutOnly", "exchange", "with", "the", "BufferedImage", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java#L47-L57
7,572
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java
WebcamHelper.consumeBufferedImage
public static void consumeBufferedImage(BufferedImage image, Processor processor, WebcamEndpoint endpoint, ExceptionHandler exceptionHandler) { Validate.notNull(image); Validate.notNull(processor); Validate.notNull(endpoint); try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, image); processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
java
public static void consumeBufferedImage(BufferedImage image, Processor processor, WebcamEndpoint endpoint, ExceptionHandler exceptionHandler) { Validate.notNull(image); Validate.notNull(processor); Validate.notNull(endpoint); try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, image); processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
[ "public", "static", "void", "consumeBufferedImage", "(", "BufferedImage", "image", ",", "Processor", "processor", ",", "WebcamEndpoint", "endpoint", ",", "ExceptionHandler", "exceptionHandler", ")", "{", "Validate", ".", "notNull", "(", "image", ")", ";", "Validate", ".", "notNull", "(", "processor", ")", ";", "Validate", ".", "notNull", "(", "endpoint", ")", ";", "try", "{", "Exchange", "exchange", "=", "createOutOnlyExchangeWithBodyAndHeaders", "(", "endpoint", ",", "image", ")", ";", "processor", ".", "process", "(", "exchange", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "exceptionHandler", ".", "handleException", "(", "e", ")", ";", "}", "}" ]
Consume the java.awt.BufferedImage from the webcam, all params required. @param image The image to process. @param processor Processor that handles the exchange. @param endpoint WebcamEndpoint receiving the exchange.
[ "Consume", "the", "java", ".", "awt", ".", "BufferedImage", "from", "the", "webcam", "all", "params", "required", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java#L66-L77
7,573
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java
WebcamHelper.consumeWebcamMotionEvent
public static void consumeWebcamMotionEvent(WebcamMotionEvent motionEvent, Processor processor, WebcamEndpoint endpoint, ExceptionHandler exceptionHandler){ Validate.notNull(motionEvent); Validate.notNull(processor); Validate.notNull(endpoint); try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, motionEvent.getCurrentImage()); exchange.getIn().setHeader(WebcamConstants.WEBCAM_MOTION_EVENT_HEADER, motionEvent); processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
java
public static void consumeWebcamMotionEvent(WebcamMotionEvent motionEvent, Processor processor, WebcamEndpoint endpoint, ExceptionHandler exceptionHandler){ Validate.notNull(motionEvent); Validate.notNull(processor); Validate.notNull(endpoint); try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, motionEvent.getCurrentImage()); exchange.getIn().setHeader(WebcamConstants.WEBCAM_MOTION_EVENT_HEADER, motionEvent); processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
[ "public", "static", "void", "consumeWebcamMotionEvent", "(", "WebcamMotionEvent", "motionEvent", ",", "Processor", "processor", ",", "WebcamEndpoint", "endpoint", ",", "ExceptionHandler", "exceptionHandler", ")", "{", "Validate", ".", "notNull", "(", "motionEvent", ")", ";", "Validate", ".", "notNull", "(", "processor", ")", ";", "Validate", ".", "notNull", "(", "endpoint", ")", ";", "try", "{", "Exchange", "exchange", "=", "createOutOnlyExchangeWithBodyAndHeaders", "(", "endpoint", ",", "motionEvent", ".", "getCurrentImage", "(", ")", ")", ";", "exchange", ".", "getIn", "(", ")", ".", "setHeader", "(", "WebcamConstants", ".", "WEBCAM_MOTION_EVENT_HEADER", ",", "motionEvent", ")", ";", "processor", ".", "process", "(", "exchange", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "exceptionHandler", ".", "handleException", "(", "e", ")", ";", "}", "}" ]
Consume the motion event from the webcam, all params required. The event is stored in the header while the latest image is available as the body. @param motionEvent The motion event that triggered. @param processor Processor that handles the exchange. @param endpoint WebcamEndpoint receiving the exchange.
[ "Consume", "the", "motion", "event", "from", "the", "webcam", "all", "params", "required", ".", "The", "event", "is", "stored", "in", "the", "header", "while", "the", "latest", "image", "is", "available", "as", "the", "body", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java#L87-L99
7,574
rhiot/rhiot
gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java
WebcamHelper.isWebcamPresent
public static boolean isWebcamPresent(){ try { Webcam.getDefault(WebcamConstants.DEFAULT_WEBCAM_LOOKUP_TIMEOUT); return true; } catch (Throwable exception) { LOG.debug("Problem occurred when detecting the webcam. Returning false.", exception); return false; } }
java
public static boolean isWebcamPresent(){ try { Webcam.getDefault(WebcamConstants.DEFAULT_WEBCAM_LOOKUP_TIMEOUT); return true; } catch (Throwable exception) { LOG.debug("Problem occurred when detecting the webcam. Returning false.", exception); return false; } }
[ "public", "static", "boolean", "isWebcamPresent", "(", ")", "{", "try", "{", "Webcam", ".", "getDefault", "(", "WebcamConstants", ".", "DEFAULT_WEBCAM_LOOKUP_TIMEOUT", ")", ";", "return", "true", ";", "}", "catch", "(", "Throwable", "exception", ")", "{", "LOG", ".", "debug", "(", "\"Problem occurred when detecting the webcam. Returning false.\"", ",", "exception", ")", ";", "return", "false", ";", "}", "}" ]
Returns true if there's a webcam available, false otherwise.
[ "Returns", "true", "if", "there", "s", "a", "webcam", "available", "false", "otherwise", "." ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-webcam/src/main/java/io/rhiot/gateway/camel/webcam/WebcamHelper.java#L104-L112
7,575
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/ShortNameGenerator.java
ShortNameGenerator.generateShortName
public ShortName generateShortName(String longFullName) throws IllegalStateException { longFullName = stripLeadingPeriods(longFullName).toUpperCase(Locale.ROOT); final String longName; final String longExt; final int dotIdx = longFullName.lastIndexOf('.'); final boolean forceSuffix; if (dotIdx == -1) { /* no dot in the name */ forceSuffix = !cleanString(longFullName); longName = tidyString(longFullName); longExt = ""; /* so no extension */ } else { /* split at the dot */ forceSuffix = !cleanString(longFullName.substring( 0, dotIdx)); longName = tidyString(longFullName.substring(0, dotIdx)); longExt = tidyString(longFullName.substring(dotIdx + 1)); } final String shortExt = (longExt.length() > 3) ? longExt.substring(0, 3) : longExt; if (forceSuffix || (longName.length() > 8) || usedNames.contains(new ShortName(longName, shortExt). asSimpleString().toLowerCase(Locale.ROOT))) { /* we have to append the "~n" suffix */ final int maxLongIdx = Math.min(longName.length(), 8); for (int i=1; i < 99999; i++) { final String serial = "~" + i; //NOI18N final int serialLen = serial.length(); final String shortName = longName.substring( 0, Math.min(maxLongIdx, 8-serialLen)) + serial; final ShortName result = new ShortName(shortName, shortExt); if (!usedNames.contains( result.asSimpleString().toLowerCase(Locale.ROOT))) { return result; } } throw new IllegalStateException( "could not generate short name for \"" + longFullName + "\""); } return new ShortName(longName, shortExt); }
java
public ShortName generateShortName(String longFullName) throws IllegalStateException { longFullName = stripLeadingPeriods(longFullName).toUpperCase(Locale.ROOT); final String longName; final String longExt; final int dotIdx = longFullName.lastIndexOf('.'); final boolean forceSuffix; if (dotIdx == -1) { /* no dot in the name */ forceSuffix = !cleanString(longFullName); longName = tidyString(longFullName); longExt = ""; /* so no extension */ } else { /* split at the dot */ forceSuffix = !cleanString(longFullName.substring( 0, dotIdx)); longName = tidyString(longFullName.substring(0, dotIdx)); longExt = tidyString(longFullName.substring(dotIdx + 1)); } final String shortExt = (longExt.length() > 3) ? longExt.substring(0, 3) : longExt; if (forceSuffix || (longName.length() > 8) || usedNames.contains(new ShortName(longName, shortExt). asSimpleString().toLowerCase(Locale.ROOT))) { /* we have to append the "~n" suffix */ final int maxLongIdx = Math.min(longName.length(), 8); for (int i=1; i < 99999; i++) { final String serial = "~" + i; //NOI18N final int serialLen = serial.length(); final String shortName = longName.substring( 0, Math.min(maxLongIdx, 8-serialLen)) + serial; final ShortName result = new ShortName(shortName, shortExt); if (!usedNames.contains( result.asSimpleString().toLowerCase(Locale.ROOT))) { return result; } } throw new IllegalStateException( "could not generate short name for \"" + longFullName + "\""); } return new ShortName(longName, shortExt); }
[ "public", "ShortName", "generateShortName", "(", "String", "longFullName", ")", "throws", "IllegalStateException", "{", "longFullName", "=", "stripLeadingPeriods", "(", "longFullName", ")", ".", "toUpperCase", "(", "Locale", ".", "ROOT", ")", ";", "final", "String", "longName", ";", "final", "String", "longExt", ";", "final", "int", "dotIdx", "=", "longFullName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "final", "boolean", "forceSuffix", ";", "if", "(", "dotIdx", "==", "-", "1", ")", "{", "/* no dot in the name */", "forceSuffix", "=", "!", "cleanString", "(", "longFullName", ")", ";", "longName", "=", "tidyString", "(", "longFullName", ")", ";", "longExt", "=", "\"\"", ";", "/* so no extension */", "}", "else", "{", "/* split at the dot */", "forceSuffix", "=", "!", "cleanString", "(", "longFullName", ".", "substring", "(", "0", ",", "dotIdx", ")", ")", ";", "longName", "=", "tidyString", "(", "longFullName", ".", "substring", "(", "0", ",", "dotIdx", ")", ")", ";", "longExt", "=", "tidyString", "(", "longFullName", ".", "substring", "(", "dotIdx", "+", "1", ")", ")", ";", "}", "final", "String", "shortExt", "=", "(", "longExt", ".", "length", "(", ")", ">", "3", ")", "?", "longExt", ".", "substring", "(", "0", ",", "3", ")", ":", "longExt", ";", "if", "(", "forceSuffix", "||", "(", "longName", ".", "length", "(", ")", ">", "8", ")", "||", "usedNames", ".", "contains", "(", "new", "ShortName", "(", "longName", ",", "shortExt", ")", ".", "asSimpleString", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "ROOT", ")", ")", ")", "{", "/* we have to append the \"~n\" suffix */", "final", "int", "maxLongIdx", "=", "Math", ".", "min", "(", "longName", ".", "length", "(", ")", ",", "8", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "99999", ";", "i", "++", ")", "{", "final", "String", "serial", "=", "\"~\"", "+", "i", ";", "//NOI18N", "final", "int", "serialLen", "=", "serial", ".", "length", "(", ")", ";", "final", "String", "shortName", "=", "longName", ".", "substring", "(", "0", ",", "Math", ".", "min", "(", "maxLongIdx", ",", "8", "-", "serialLen", ")", ")", "+", "serial", ";", "final", "ShortName", "result", "=", "new", "ShortName", "(", "shortName", ",", "shortExt", ")", ";", "if", "(", "!", "usedNames", ".", "contains", "(", "result", ".", "asSimpleString", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "ROOT", ")", ")", ")", "{", "return", "result", ";", "}", "}", "throw", "new", "IllegalStateException", "(", "\"could not generate short name for \\\"\"", "+", "longFullName", "+", "\"\\\"\"", ")", ";", "}", "return", "new", "ShortName", "(", "longName", ",", "shortExt", ")", ";", "}" ]
Generates a new unique 8.3 file name that is not already contained in the set specified to the constructor. @param longFullName the long file name to generate the short name for @return the generated 8.3 file name @throws IllegalStateException if no unused short name could be found
[ "Generates", "a", "new", "unique", "8", ".", "3", "file", "name", "that", "is", "not", "already", "contained", "in", "the", "set", "specified", "to", "the", "constructor", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/ShortNameGenerator.java#L116-L171
7,576
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/context/CucumberManager.java
CucumberManager.stopNewScenario
public ScenarioGlobals stopNewScenario() { if(scenarioCreationHook != null) { scenarioCreationHook.scenarionShutdown(getCurrentScenarioGlobals()); } return scenarioGlobalsMap.remove(Thread.currentThread()); }
java
public ScenarioGlobals stopNewScenario() { if(scenarioCreationHook != null) { scenarioCreationHook.scenarionShutdown(getCurrentScenarioGlobals()); } return scenarioGlobalsMap.remove(Thread.currentThread()); }
[ "public", "ScenarioGlobals", "stopNewScenario", "(", ")", "{", "if", "(", "scenarioCreationHook", "!=", "null", ")", "{", "scenarioCreationHook", ".", "scenarionShutdown", "(", "getCurrentScenarioGlobals", "(", ")", ")", ";", "}", "return", "scenarioGlobalsMap", ".", "remove", "(", "Thread", ".", "currentThread", "(", ")", ")", ";", "}" ]
Called at the end of an scenario? @return {@link ScenarioGlobals}
[ "Called", "at", "the", "end", "of", "an", "scenario?" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/context/CucumberManager.java#L123-L128
7,577
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/impl/QueryResultImpl.java
QueryResultImpl.iterator
public Iterator<QueryBinding> iterator() { List<QueryBinding> iBindings = new ArrayList<QueryBinding>(); for(QueryBindingImpl b : bindings) { iBindings.add(b); } return iBindings.iterator(); }
java
public Iterator<QueryBinding> iterator() { List<QueryBinding> iBindings = new ArrayList<QueryBinding>(); for(QueryBindingImpl b : bindings) { iBindings.add(b); } return iBindings.iterator(); }
[ "public", "Iterator", "<", "QueryBinding", ">", "iterator", "(", ")", "{", "List", "<", "QueryBinding", ">", "iBindings", "=", "new", "ArrayList", "<", "QueryBinding", ">", "(", ")", ";", "for", "(", "QueryBindingImpl", "b", ":", "bindings", ")", "{", "iBindings", ".", "add", "(", "b", ")", ";", "}", "return", "iBindings", ".", "iterator", "(", ")", ";", "}" ]
An iterator over the result set. @return
[ "An", "iterator", "over", "the", "result", "set", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/impl/QueryResultImpl.java#L87-L94
7,578
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/QueryEngine.java
QueryEngine.create
public static QueryEngine create(OWLOntologyManager manager, OWLReasoner reasoner, boolean strict) { return new QueryEngineImpl(manager, reasoner, strict); }
java
public static QueryEngine create(OWLOntologyManager manager, OWLReasoner reasoner, boolean strict) { return new QueryEngineImpl(manager, reasoner, strict); }
[ "public", "static", "QueryEngine", "create", "(", "OWLOntologyManager", "manager", ",", "OWLReasoner", "reasoner", ",", "boolean", "strict", ")", "{", "return", "new", "QueryEngineImpl", "(", "manager", ",", "reasoner", ",", "strict", ")", ";", "}" ]
Factory method to create a QueryEngine instance. @param manager An OWLOntologyManager instance of OWLAPI v3 @param reasoner An OWLReasoner instance. @param strictMode If strict mode is enabled the query engine will throw a QueryEngineException if data types withing the query are not correct (e.g. Class(URI_OF_AN_INDIVIDUAL)) @return an instance of QueryEngine
[ "Factory", "method", "to", "create", "a", "QueryEngine", "instance", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/QueryEngine.java#L40-L43
7,579
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/HookMethodDef.java
HookMethodDef.initialize
public static void initialize(String configFilePath) { if (manager != null) { return; } logger.info("initialize"); final Config config; try { config = JavaConfig.generateFromYamlConfig(new File(configFilePath)); } catch (YamlConvertException e) { throw new RuntimeException(e); } // load srcTree from already dumped srcTree YAML final File srcTreeFile = CommonPath.srcTreeFile(config.getRootBaseRunOutputIntermediateDataDir()); SrcTree srcTree = new SrcTree(); try { srcTree.fromYamlObject(YamlUtils.load(srcTreeFile)); } catch (YamlConvertException e) { throw new RuntimeException(e); } try { srcTree.resolveKeyReference(); } catch (IllegalDataStructureException e) { throw new RuntimeException(e); } manager = new HookMethodManager(srcTree, config); if (!config.isRunTestOnly()) { // set up shutdown hook which generates HTML report Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { HtmlReport report = new HtmlReport(); try { report.generate(config.getRootBaseReportInputIntermediateDataDirs(), config.getRootBaseReportOutputDir()); } catch (IllegalDataStructureException | IllegalTestScriptException e) { throw new RuntimeException(e); } } }); } }
java
public static void initialize(String configFilePath) { if (manager != null) { return; } logger.info("initialize"); final Config config; try { config = JavaConfig.generateFromYamlConfig(new File(configFilePath)); } catch (YamlConvertException e) { throw new RuntimeException(e); } // load srcTree from already dumped srcTree YAML final File srcTreeFile = CommonPath.srcTreeFile(config.getRootBaseRunOutputIntermediateDataDir()); SrcTree srcTree = new SrcTree(); try { srcTree.fromYamlObject(YamlUtils.load(srcTreeFile)); } catch (YamlConvertException e) { throw new RuntimeException(e); } try { srcTree.resolveKeyReference(); } catch (IllegalDataStructureException e) { throw new RuntimeException(e); } manager = new HookMethodManager(srcTree, config); if (!config.isRunTestOnly()) { // set up shutdown hook which generates HTML report Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { HtmlReport report = new HtmlReport(); try { report.generate(config.getRootBaseReportInputIntermediateDataDirs(), config.getRootBaseReportOutputDir()); } catch (IllegalDataStructureException | IllegalTestScriptException e) { throw new RuntimeException(e); } } }); } }
[ "public", "static", "void", "initialize", "(", "String", "configFilePath", ")", "{", "if", "(", "manager", "!=", "null", ")", "{", "return", ";", "}", "logger", ".", "info", "(", "\"initialize\"", ")", ";", "final", "Config", "config", ";", "try", "{", "config", "=", "JavaConfig", ".", "generateFromYamlConfig", "(", "new", "File", "(", "configFilePath", ")", ")", ";", "}", "catch", "(", "YamlConvertException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "// load srcTree from already dumped srcTree YAML", "final", "File", "srcTreeFile", "=", "CommonPath", ".", "srcTreeFile", "(", "config", ".", "getRootBaseRunOutputIntermediateDataDir", "(", ")", ")", ";", "SrcTree", "srcTree", "=", "new", "SrcTree", "(", ")", ";", "try", "{", "srcTree", ".", "fromYamlObject", "(", "YamlUtils", ".", "load", "(", "srcTreeFile", ")", ")", ";", "}", "catch", "(", "YamlConvertException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "try", "{", "srcTree", ".", "resolveKeyReference", "(", ")", ";", "}", "catch", "(", "IllegalDataStructureException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "manager", "=", "new", "HookMethodManager", "(", "srcTree", ",", "config", ")", ";", "if", "(", "!", "config", ".", "isRunTestOnly", "(", ")", ")", "{", "// set up shutdown hook which generates HTML report", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "HtmlReport", "report", "=", "new", "HtmlReport", "(", ")", ";", "try", "{", "report", ".", "generate", "(", "config", ".", "getRootBaseReportInputIntermediateDataDirs", "(", ")", ",", "config", ".", "getRootBaseReportOutputDir", "(", ")", ")", ";", "}", "catch", "(", "IllegalDataStructureException", "|", "IllegalTestScriptException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "}", ")", ";", "}", "}" ]
if called multiple times, just ignored
[ "if", "called", "multiple", "times", "just", "ignored" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/HookMethodDef.java#L24-L69
7,580
rhiot/rhiot
cloudplatform/service/device-api/src/main/java/io/rhiot/cloudplatform/service/device/api/DeviceConstants.java
DeviceConstants.readDeviceMetric
public static String readDeviceMetric(String deviceId, String metric) { return format("%s.%s.%s", CHANNEL_DEVICE_METRICS_READ, deviceId, metric); }
java
public static String readDeviceMetric(String deviceId, String metric) { return format("%s.%s.%s", CHANNEL_DEVICE_METRICS_READ, deviceId, metric); }
[ "public", "static", "String", "readDeviceMetric", "(", "String", "deviceId", ",", "String", "metric", ")", "{", "return", "format", "(", "\"%s.%s.%s\"", ",", "CHANNEL_DEVICE_METRICS_READ", ",", "deviceId", ",", "metric", ")", ";", "}" ]
Device metrics channel helpers
[ "Device", "metrics", "channel", "helpers" ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/cloudplatform/service/device-api/src/main/java/io/rhiot/cloudplatform/service/device/api/DeviceConstants.java#L93-L95
7,581
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java
NavigationService.clickElementWithAttributeValue
public void clickElementWithAttributeValue(String attributeName, String attributeValue) { By xpath = By.xpath("//*[@" + attributeName + "='" + attributeValue + "']"); WebElement element = seleniumElementService.findExpectedElement(xpath); assertTrue("The element you are trying to click (" + xpath.toString() + ") is not displayed", element.isDisplayed()); element.click(); }
java
public void clickElementWithAttributeValue(String attributeName, String attributeValue) { By xpath = By.xpath("//*[@" + attributeName + "='" + attributeValue + "']"); WebElement element = seleniumElementService.findExpectedElement(xpath); assertTrue("The element you are trying to click (" + xpath.toString() + ") is not displayed", element.isDisplayed()); element.click(); }
[ "public", "void", "clickElementWithAttributeValue", "(", "String", "attributeName", ",", "String", "attributeValue", ")", "{", "By", "xpath", "=", "By", ".", "xpath", "(", "\"//*[@\"", "+", "attributeName", "+", "\"='\"", "+", "attributeValue", "+", "\"']\"", ")", ";", "WebElement", "element", "=", "seleniumElementService", ".", "findExpectedElement", "(", "xpath", ")", ";", "assertTrue", "(", "\"The element you are trying to click (\"", "+", "xpath", ".", "toString", "(", ")", "+", "\") is not displayed\"", ",", "element", ".", "isDisplayed", "(", ")", ")", ";", "element", ".", "click", "(", ")", ";", "}" ]
Find a Element that has a attribute with a certain value and click it @param attributeName @param attributeValue
[ "Find", "a", "Element", "that", "has", "a", "attribute", "with", "a", "certain", "value", "and", "click", "it" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java#L90-L95
7,582
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java
NavigationService.isInitialPageRequested
public boolean isInitialPageRequested() { String currentUrl = getWebDriver().getCurrentUrl(); if (StringUtils.isBlank(currentUrl) || ( !currentUrl.toLowerCase().startsWith("http") && !currentUrl.toLowerCase().startsWith("file") ) ) { return false; } else { return true; } }
java
public boolean isInitialPageRequested() { String currentUrl = getWebDriver().getCurrentUrl(); if (StringUtils.isBlank(currentUrl) || ( !currentUrl.toLowerCase().startsWith("http") && !currentUrl.toLowerCase().startsWith("file") ) ) { return false; } else { return true; } }
[ "public", "boolean", "isInitialPageRequested", "(", ")", "{", "String", "currentUrl", "=", "getWebDriver", "(", ")", ".", "getCurrentUrl", "(", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "currentUrl", ")", "||", "(", "!", "currentUrl", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"http\"", ")", "&&", "!", "currentUrl", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"file\"", ")", ")", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Has a page been requested for this selenium session. This method is available to prevent scripts for waiting for a cetrain condition if no url has been requested yet. If true you know you can just proceed and not check for any state as none exists @return {@link Boolean}
[ "Has", "a", "page", "been", "requested", "for", "this", "selenium", "session", ".", "This", "method", "is", "available", "to", "prevent", "scripts", "for", "waiting", "for", "a", "cetrain", "condition", "if", "no", "url", "has", "been", "requested", "yet", ".", "If", "true", "you", "know", "you", "can", "just", "proceed", "and", "not", "check", "for", "any", "state", "as", "none", "exists" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java#L123-L135
7,583
gfk-ba/senbot
SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java
NavigationService.mouseHoverOverElement
public void mouseHoverOverElement(By locator) { SynchronisationService synchronisationService = new SynchronisationService(); synchronisationService.waitAndAssertForExpectedCondition(ExpectedConditions.visibilityOfElementLocated(locator)); WebElement element = getWebDriver().findElement(locator); Actions builder = new Actions(getWebDriver()); Actions hoverOverRegistrar = builder.moveToElement(element); hoverOverRegistrar.perform(); }
java
public void mouseHoverOverElement(By locator) { SynchronisationService synchronisationService = new SynchronisationService(); synchronisationService.waitAndAssertForExpectedCondition(ExpectedConditions.visibilityOfElementLocated(locator)); WebElement element = getWebDriver().findElement(locator); Actions builder = new Actions(getWebDriver()); Actions hoverOverRegistrar = builder.moveToElement(element); hoverOverRegistrar.perform(); }
[ "public", "void", "mouseHoverOverElement", "(", "By", "locator", ")", "{", "SynchronisationService", "synchronisationService", "=", "new", "SynchronisationService", "(", ")", ";", "synchronisationService", ".", "waitAndAssertForExpectedCondition", "(", "ExpectedConditions", ".", "visibilityOfElementLocated", "(", "locator", ")", ")", ";", "WebElement", "element", "=", "getWebDriver", "(", ")", ".", "findElement", "(", "locator", ")", ";", "Actions", "builder", "=", "new", "Actions", "(", "getWebDriver", "(", ")", ")", ";", "Actions", "hoverOverRegistrar", "=", "builder", ".", "moveToElement", "(", "element", ")", ";", "hoverOverRegistrar", ".", "perform", "(", ")", ";", "}" ]
Hovers the mouse over the given element @param locator The element locator
[ "Hovers", "the", "mouse", "over", "the", "given", "element" ]
e9a152aa67be48b1bb13a4691655caf6d873b553
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/services/selenium/NavigationService.java#L141-L150
7,584
SahaginOrg/sahagin-java
src/main/java/org/sahagin/share/srctree/SrcTree.java
SrcTree.resolveKeyReference
public void resolveKeyReference() throws IllegalDataStructureException { for (TestClass testClass : rootClassTable.getTestClasses()) { resolveTestMethod(testClass); resolveTestField(testClass); resolveDelegateToTestClass(testClass); } for (TestClass testClass : subClassTable.getTestClasses()) { resolveTestMethod(testClass); resolveTestField(testClass); resolveDelegateToTestClass(testClass); } for (TestMethod testMethod : rootMethodTable.getTestMethods()) { resolveTestClass(testMethod); for (CodeLine codeLine : testMethod.getCodeBody()) { resolveKeyReferenceInCode(codeLine.getCode()); } } for (TestMethod testMethod : subMethodTable.getTestMethods()) { resolveTestClass(testMethod); for (CodeLine codeLine : testMethod.getCodeBody()) { resolveKeyReferenceInCode(codeLine.getCode()); } } for (TestField testField : fieldTable.getTestFields()) { resolveTestClass(testField); } }
java
public void resolveKeyReference() throws IllegalDataStructureException { for (TestClass testClass : rootClassTable.getTestClasses()) { resolveTestMethod(testClass); resolveTestField(testClass); resolveDelegateToTestClass(testClass); } for (TestClass testClass : subClassTable.getTestClasses()) { resolveTestMethod(testClass); resolveTestField(testClass); resolveDelegateToTestClass(testClass); } for (TestMethod testMethod : rootMethodTable.getTestMethods()) { resolveTestClass(testMethod); for (CodeLine codeLine : testMethod.getCodeBody()) { resolveKeyReferenceInCode(codeLine.getCode()); } } for (TestMethod testMethod : subMethodTable.getTestMethods()) { resolveTestClass(testMethod); for (CodeLine codeLine : testMethod.getCodeBody()) { resolveKeyReferenceInCode(codeLine.getCode()); } } for (TestField testField : fieldTable.getTestFields()) { resolveTestClass(testField); } }
[ "public", "void", "resolveKeyReference", "(", ")", "throws", "IllegalDataStructureException", "{", "for", "(", "TestClass", "testClass", ":", "rootClassTable", ".", "getTestClasses", "(", ")", ")", "{", "resolveTestMethod", "(", "testClass", ")", ";", "resolveTestField", "(", "testClass", ")", ";", "resolveDelegateToTestClass", "(", "testClass", ")", ";", "}", "for", "(", "TestClass", "testClass", ":", "subClassTable", ".", "getTestClasses", "(", ")", ")", "{", "resolveTestMethod", "(", "testClass", ")", ";", "resolveTestField", "(", "testClass", ")", ";", "resolveDelegateToTestClass", "(", "testClass", ")", ";", "}", "for", "(", "TestMethod", "testMethod", ":", "rootMethodTable", ".", "getTestMethods", "(", ")", ")", "{", "resolveTestClass", "(", "testMethod", ")", ";", "for", "(", "CodeLine", "codeLine", ":", "testMethod", ".", "getCodeBody", "(", ")", ")", "{", "resolveKeyReferenceInCode", "(", "codeLine", ".", "getCode", "(", ")", ")", ";", "}", "}", "for", "(", "TestMethod", "testMethod", ":", "subMethodTable", ".", "getTestMethods", "(", ")", ")", "{", "resolveTestClass", "(", "testMethod", ")", ";", "for", "(", "CodeLine", "codeLine", ":", "testMethod", ".", "getCodeBody", "(", ")", ")", "{", "resolveKeyReferenceInCode", "(", "codeLine", ".", "getCode", "(", ")", ")", ";", "}", "}", "for", "(", "TestField", "testField", ":", "fieldTable", ".", "getTestFields", "(", ")", ")", "{", "resolveTestClass", "(", "testField", ")", ";", "}", "}" ]
assume all keys have been set
[ "assume", "all", "keys", "have", "been", "set" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/srctree/SrcTree.java#L289-L315
7,585
SahaginOrg/sahagin-java
src/main/java/org/sahagin/report/HtmlReport.java
HtmlReport.addLineScreenCaptureForErrorEachStackLine
private void addLineScreenCaptureForErrorEachStackLine( List<LineScreenCapture> lineScreenCaptures, RunFailure runFailure) { if (runFailure == null) { return; // do nothing } List<StackLine> failureLines = runFailure.getStackLines(); int failureCaptureIndex = matchedLineScreenCaptureIndex( lineScreenCaptures, failureLines); if (failureCaptureIndex == -1) { return; // no failure capture } LineScreenCapture failureCapture = lineScreenCaptures.get(failureCaptureIndex); for (int i = 1; i < failureLines.size(); i++) { List<StackLine> errorEachStackLine = new ArrayList<>(failureLines.size() - i); for (int j = i; j < failureLines.size(); j++) { errorEachStackLine.add(failureLines.get(j)); } LineScreenCapture newCapture = new LineScreenCapture(); newCapture.setPath(failureCapture.getPath()); newCapture.addAllStackLines(errorEachStackLine); int errEachStackLineCaptureIndex = matchedLineScreenCaptureIndex(lineScreenCaptures, errorEachStackLine); if (errEachStackLineCaptureIndex == -1) { lineScreenCaptures.add(newCapture); } else { lineScreenCaptures.set(errEachStackLineCaptureIndex, newCapture); } } }
java
private void addLineScreenCaptureForErrorEachStackLine( List<LineScreenCapture> lineScreenCaptures, RunFailure runFailure) { if (runFailure == null) { return; // do nothing } List<StackLine> failureLines = runFailure.getStackLines(); int failureCaptureIndex = matchedLineScreenCaptureIndex( lineScreenCaptures, failureLines); if (failureCaptureIndex == -1) { return; // no failure capture } LineScreenCapture failureCapture = lineScreenCaptures.get(failureCaptureIndex); for (int i = 1; i < failureLines.size(); i++) { List<StackLine> errorEachStackLine = new ArrayList<>(failureLines.size() - i); for (int j = i; j < failureLines.size(); j++) { errorEachStackLine.add(failureLines.get(j)); } LineScreenCapture newCapture = new LineScreenCapture(); newCapture.setPath(failureCapture.getPath()); newCapture.addAllStackLines(errorEachStackLine); int errEachStackLineCaptureIndex = matchedLineScreenCaptureIndex(lineScreenCaptures, errorEachStackLine); if (errEachStackLineCaptureIndex == -1) { lineScreenCaptures.add(newCapture); } else { lineScreenCaptures.set(errEachStackLineCaptureIndex, newCapture); } } }
[ "private", "void", "addLineScreenCaptureForErrorEachStackLine", "(", "List", "<", "LineScreenCapture", ">", "lineScreenCaptures", ",", "RunFailure", "runFailure", ")", "{", "if", "(", "runFailure", "==", "null", ")", "{", "return", ";", "// do nothing", "}", "List", "<", "StackLine", ">", "failureLines", "=", "runFailure", ".", "getStackLines", "(", ")", ";", "int", "failureCaptureIndex", "=", "matchedLineScreenCaptureIndex", "(", "lineScreenCaptures", ",", "failureLines", ")", ";", "if", "(", "failureCaptureIndex", "==", "-", "1", ")", "{", "return", ";", "// no failure capture", "}", "LineScreenCapture", "failureCapture", "=", "lineScreenCaptures", ".", "get", "(", "failureCaptureIndex", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "failureLines", ".", "size", "(", ")", ";", "i", "++", ")", "{", "List", "<", "StackLine", ">", "errorEachStackLine", "=", "new", "ArrayList", "<>", "(", "failureLines", ".", "size", "(", ")", "-", "i", ")", ";", "for", "(", "int", "j", "=", "i", ";", "j", "<", "failureLines", ".", "size", "(", ")", ";", "j", "++", ")", "{", "errorEachStackLine", ".", "add", "(", "failureLines", ".", "get", "(", "j", ")", ")", ";", "}", "LineScreenCapture", "newCapture", "=", "new", "LineScreenCapture", "(", ")", ";", "newCapture", ".", "setPath", "(", "failureCapture", ".", "getPath", "(", ")", ")", ";", "newCapture", ".", "addAllStackLines", "(", "errorEachStackLine", ")", ";", "int", "errEachStackLineCaptureIndex", "=", "matchedLineScreenCaptureIndex", "(", "lineScreenCaptures", ",", "errorEachStackLine", ")", ";", "if", "(", "errEachStackLineCaptureIndex", "==", "-", "1", ")", "{", "lineScreenCaptures", ".", "add", "(", "newCapture", ")", ";", "}", "else", "{", "lineScreenCaptures", ".", "set", "(", "errEachStackLineCaptureIndex", ",", "newCapture", ")", ";", "}", "}", "}" ]
The same capture is used for the all StackLines.
[ "The", "same", "capture", "is", "used", "for", "the", "all", "StackLines", "." ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/report/HtmlReport.java#L83-L114
7,586
SahaginOrg/sahagin-java
src/main/java/org/sahagin/report/HtmlReport.java
HtmlReport.generateReportScreenCaptures
private List<ReportScreenCapture> generateReportScreenCaptures( List<LineScreenCapture> lineScreenCaptures, File inputCaptureRootDir, File reportOutputDir, File methodReportParentDir) { List<ReportScreenCapture> reportCaptures = new ArrayList<>(lineScreenCaptures.size()); // add noImage capture String noImageFilePath = new File(CommonUtils.relativize( CommonPath.htmlExternalResourceRootDir(reportOutputDir), methodReportParentDir), "images/noImage.png").getPath(); ReportScreenCapture noImageCapture = new ReportScreenCapture(); // URL separator is always slash regardless of OS type noImageCapture.setPath(FilenameUtils.separatorsToUnix(noImageFilePath)); noImageCapture.setImageId("noImage"); noImageCapture.setImageWidth(NO_IMAGE_WIDTH); noImageCapture.setImageHeight(NO_IMAGE_HEIGHT); reportCaptures.add(noImageCapture); // add each line screen capture for (LineScreenCapture lineScreenCapture : lineScreenCaptures) { ReportScreenCapture reportCapture = new ReportScreenCapture(); // replace special keyword for Sahagin internal test File actualPath = new File(lineScreenCapture.getPath().getPath().replace( "${inputCaptureRootDirForSahaginInternalTest}", inputCaptureRootDir.getPath())); File relInputCapturePath = CommonUtils.relativize(actualPath, inputCaptureRootDir); File absOutputCapturePath = new File( CommonPath.htmlReportCaptureRootDir(reportOutputDir), relInputCapturePath.getPath()); File relOutputCapturePath = CommonUtils.relativize(absOutputCapturePath, methodReportParentDir); // URL separator is always slash regardless of OS type reportCapture.setPath(FilenameUtils.separatorsToUnix(relOutputCapturePath.getPath())); // use ttId as imageId String ttId = generateTtId(lineScreenCapture.getStackLines()); reportCapture.setImageId(ttId); reportCapture.setImageSizeFromImageFile(lineScreenCapture.getPath()); reportCapture.setExecutionTime(lineScreenCapture.getExecutionTime()); reportCaptures.add(reportCapture); } return reportCaptures; }
java
private List<ReportScreenCapture> generateReportScreenCaptures( List<LineScreenCapture> lineScreenCaptures, File inputCaptureRootDir, File reportOutputDir, File methodReportParentDir) { List<ReportScreenCapture> reportCaptures = new ArrayList<>(lineScreenCaptures.size()); // add noImage capture String noImageFilePath = new File(CommonUtils.relativize( CommonPath.htmlExternalResourceRootDir(reportOutputDir), methodReportParentDir), "images/noImage.png").getPath(); ReportScreenCapture noImageCapture = new ReportScreenCapture(); // URL separator is always slash regardless of OS type noImageCapture.setPath(FilenameUtils.separatorsToUnix(noImageFilePath)); noImageCapture.setImageId("noImage"); noImageCapture.setImageWidth(NO_IMAGE_WIDTH); noImageCapture.setImageHeight(NO_IMAGE_HEIGHT); reportCaptures.add(noImageCapture); // add each line screen capture for (LineScreenCapture lineScreenCapture : lineScreenCaptures) { ReportScreenCapture reportCapture = new ReportScreenCapture(); // replace special keyword for Sahagin internal test File actualPath = new File(lineScreenCapture.getPath().getPath().replace( "${inputCaptureRootDirForSahaginInternalTest}", inputCaptureRootDir.getPath())); File relInputCapturePath = CommonUtils.relativize(actualPath, inputCaptureRootDir); File absOutputCapturePath = new File( CommonPath.htmlReportCaptureRootDir(reportOutputDir), relInputCapturePath.getPath()); File relOutputCapturePath = CommonUtils.relativize(absOutputCapturePath, methodReportParentDir); // URL separator is always slash regardless of OS type reportCapture.setPath(FilenameUtils.separatorsToUnix(relOutputCapturePath.getPath())); // use ttId as imageId String ttId = generateTtId(lineScreenCapture.getStackLines()); reportCapture.setImageId(ttId); reportCapture.setImageSizeFromImageFile(lineScreenCapture.getPath()); reportCapture.setExecutionTime(lineScreenCapture.getExecutionTime()); reportCaptures.add(reportCapture); } return reportCaptures; }
[ "private", "List", "<", "ReportScreenCapture", ">", "generateReportScreenCaptures", "(", "List", "<", "LineScreenCapture", ">", "lineScreenCaptures", ",", "File", "inputCaptureRootDir", ",", "File", "reportOutputDir", ",", "File", "methodReportParentDir", ")", "{", "List", "<", "ReportScreenCapture", ">", "reportCaptures", "=", "new", "ArrayList", "<>", "(", "lineScreenCaptures", ".", "size", "(", ")", ")", ";", "// add noImage capture", "String", "noImageFilePath", "=", "new", "File", "(", "CommonUtils", ".", "relativize", "(", "CommonPath", ".", "htmlExternalResourceRootDir", "(", "reportOutputDir", ")", ",", "methodReportParentDir", ")", ",", "\"images/noImage.png\"", ")", ".", "getPath", "(", ")", ";", "ReportScreenCapture", "noImageCapture", "=", "new", "ReportScreenCapture", "(", ")", ";", "// URL separator is always slash regardless of OS type", "noImageCapture", ".", "setPath", "(", "FilenameUtils", ".", "separatorsToUnix", "(", "noImageFilePath", ")", ")", ";", "noImageCapture", ".", "setImageId", "(", "\"noImage\"", ")", ";", "noImageCapture", ".", "setImageWidth", "(", "NO_IMAGE_WIDTH", ")", ";", "noImageCapture", ".", "setImageHeight", "(", "NO_IMAGE_HEIGHT", ")", ";", "reportCaptures", ".", "add", "(", "noImageCapture", ")", ";", "// add each line screen capture", "for", "(", "LineScreenCapture", "lineScreenCapture", ":", "lineScreenCaptures", ")", "{", "ReportScreenCapture", "reportCapture", "=", "new", "ReportScreenCapture", "(", ")", ";", "// replace special keyword for Sahagin internal test", "File", "actualPath", "=", "new", "File", "(", "lineScreenCapture", ".", "getPath", "(", ")", ".", "getPath", "(", ")", ".", "replace", "(", "\"${inputCaptureRootDirForSahaginInternalTest}\"", ",", "inputCaptureRootDir", ".", "getPath", "(", ")", ")", ")", ";", "File", "relInputCapturePath", "=", "CommonUtils", ".", "relativize", "(", "actualPath", ",", "inputCaptureRootDir", ")", ";", "File", "absOutputCapturePath", "=", "new", "File", "(", "CommonPath", ".", "htmlReportCaptureRootDir", "(", "reportOutputDir", ")", ",", "relInputCapturePath", ".", "getPath", "(", ")", ")", ";", "File", "relOutputCapturePath", "=", "CommonUtils", ".", "relativize", "(", "absOutputCapturePath", ",", "methodReportParentDir", ")", ";", "// URL separator is always slash regardless of OS type", "reportCapture", ".", "setPath", "(", "FilenameUtils", ".", "separatorsToUnix", "(", "relOutputCapturePath", ".", "getPath", "(", ")", ")", ")", ";", "// use ttId as imageId", "String", "ttId", "=", "generateTtId", "(", "lineScreenCapture", ".", "getStackLines", "(", ")", ")", ";", "reportCapture", ".", "setImageId", "(", "ttId", ")", ";", "reportCapture", ".", "setImageSizeFromImageFile", "(", "lineScreenCapture", ".", "getPath", "(", ")", ")", ";", "reportCapture", ".", "setExecutionTime", "(", "lineScreenCapture", ".", "getExecutionTime", "(", ")", ")", ";", "reportCaptures", ".", "add", "(", "reportCapture", ")", ";", "}", "return", "reportCaptures", ";", "}" ]
generate ResportScreenCapture list from lineScreenCaptures and
[ "generate", "ResportScreenCapture", "list", "from", "lineScreenCaptures", "and" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/report/HtmlReport.java#L117-L154
7,587
SahaginOrg/sahagin-java
src/main/java/org/sahagin/report/HtmlReport.java
HtmlReport.getRunFailure
private RunFailure getRunFailure(RootMethodRunResult runResult) { if (runResult == null || runResult.getRunFailures().size() == 0) { return null; // no failure } // multiple run failures in one test method are not supported yet return runResult.getRunFailures().get(0); }
java
private RunFailure getRunFailure(RootMethodRunResult runResult) { if (runResult == null || runResult.getRunFailures().size() == 0) { return null; // no failure } // multiple run failures in one test method are not supported yet return runResult.getRunFailures().get(0); }
[ "private", "RunFailure", "getRunFailure", "(", "RootMethodRunResult", "runResult", ")", "{", "if", "(", "runResult", "==", "null", "||", "runResult", ".", "getRunFailures", "(", ")", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "// no failure", "}", "// multiple run failures in one test method are not supported yet", "return", "runResult", ".", "getRunFailures", "(", ")", ".", "get", "(", "0", ")", ";", "}" ]
returns null if no failure
[ "returns", "null", "if", "no", "failure" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/report/HtmlReport.java#L157-L164
7,588
SahaginOrg/sahagin-java
src/main/java/org/sahagin/report/HtmlReport.java
HtmlReport.generateRunResultList
private List<RunResults> generateRunResultList(List<File> reportInputDataDirs, SrcTree srcTree) throws IllegalDataStructureException { List<RunResults> resultsList = new ArrayList<>(reportInputDataDirs.size()); for (File reportInputDataDir : reportInputDataDirs) { RunResults results = new RunResults(); Collection<File> runResultFiles; File runResultsRootDir = CommonPath.runResultRootDir(reportInputDataDir); if (runResultsRootDir.exists()) { runResultFiles = FileUtils.listFiles(runResultsRootDir, null, true); } else { runResultFiles = new ArrayList<>(0); } for (File runResultFile : runResultFiles) { Map<String, Object> runResultYamlObj = YamlUtils.load(runResultFile); RootMethodRunResult rootMethodRunResult = new RootMethodRunResult(); try { rootMethodRunResult.fromYamlObject(runResultYamlObj); } catch (YamlConvertException e) { throw new IllegalDataStructureException(e); } results.addRootMethodRunResults(rootMethodRunResult); } results.resolveKeyReference(srcTree); resultsList.add(results); } return resultsList; }
java
private List<RunResults> generateRunResultList(List<File> reportInputDataDirs, SrcTree srcTree) throws IllegalDataStructureException { List<RunResults> resultsList = new ArrayList<>(reportInputDataDirs.size()); for (File reportInputDataDir : reportInputDataDirs) { RunResults results = new RunResults(); Collection<File> runResultFiles; File runResultsRootDir = CommonPath.runResultRootDir(reportInputDataDir); if (runResultsRootDir.exists()) { runResultFiles = FileUtils.listFiles(runResultsRootDir, null, true); } else { runResultFiles = new ArrayList<>(0); } for (File runResultFile : runResultFiles) { Map<String, Object> runResultYamlObj = YamlUtils.load(runResultFile); RootMethodRunResult rootMethodRunResult = new RootMethodRunResult(); try { rootMethodRunResult.fromYamlObject(runResultYamlObj); } catch (YamlConvertException e) { throw new IllegalDataStructureException(e); } results.addRootMethodRunResults(rootMethodRunResult); } results.resolveKeyReference(srcTree); resultsList.add(results); } return resultsList; }
[ "private", "List", "<", "RunResults", ">", "generateRunResultList", "(", "List", "<", "File", ">", "reportInputDataDirs", ",", "SrcTree", "srcTree", ")", "throws", "IllegalDataStructureException", "{", "List", "<", "RunResults", ">", "resultsList", "=", "new", "ArrayList", "<>", "(", "reportInputDataDirs", ".", "size", "(", ")", ")", ";", "for", "(", "File", "reportInputDataDir", ":", "reportInputDataDirs", ")", "{", "RunResults", "results", "=", "new", "RunResults", "(", ")", ";", "Collection", "<", "File", ">", "runResultFiles", ";", "File", "runResultsRootDir", "=", "CommonPath", ".", "runResultRootDir", "(", "reportInputDataDir", ")", ";", "if", "(", "runResultsRootDir", ".", "exists", "(", ")", ")", "{", "runResultFiles", "=", "FileUtils", ".", "listFiles", "(", "runResultsRootDir", ",", "null", ",", "true", ")", ";", "}", "else", "{", "runResultFiles", "=", "new", "ArrayList", "<>", "(", "0", ")", ";", "}", "for", "(", "File", "runResultFile", ":", "runResultFiles", ")", "{", "Map", "<", "String", ",", "Object", ">", "runResultYamlObj", "=", "YamlUtils", ".", "load", "(", "runResultFile", ")", ";", "RootMethodRunResult", "rootMethodRunResult", "=", "new", "RootMethodRunResult", "(", ")", ";", "try", "{", "rootMethodRunResult", ".", "fromYamlObject", "(", "runResultYamlObj", ")", ";", "}", "catch", "(", "YamlConvertException", "e", ")", "{", "throw", "new", "IllegalDataStructureException", "(", "e", ")", ";", "}", "results", ".", "addRootMethodRunResults", "(", "rootMethodRunResult", ")", ";", "}", "results", ".", "resolveKeyReference", "(", "srcTree", ")", ";", "resultsList", ".", "add", "(", "results", ")", ";", "}", "return", "resultsList", ";", "}" ]
returns RunResults list for reportInputDataDirs
[ "returns", "RunResults", "list", "for", "reportInputDataDirs" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/report/HtmlReport.java#L391-L417
7,589
rhiot/rhiot
camel/vertx-proton/src/main/java/io/rhiot/camel/vertxproton/VertxProtonEndpoint.java
VertxProtonEndpoint.getVertx
public Vertx getVertx() { if(vertx != null) { return vertx; } if(getComponent().getVertx() != null) { vertx = getComponent().getVertx(); } else { vertx = Vertx.vertx(); } return vertx; }
java
public Vertx getVertx() { if(vertx != null) { return vertx; } if(getComponent().getVertx() != null) { vertx = getComponent().getVertx(); } else { vertx = Vertx.vertx(); } return vertx; }
[ "public", "Vertx", "getVertx", "(", ")", "{", "if", "(", "vertx", "!=", "null", ")", "{", "return", "vertx", ";", "}", "if", "(", "getComponent", "(", ")", ".", "getVertx", "(", ")", "!=", "null", ")", "{", "vertx", "=", "getComponent", "(", ")", ".", "getVertx", "(", ")", ";", "}", "else", "{", "vertx", "=", "Vertx", ".", "vertx", "(", ")", ";", "}", "return", "vertx", ";", "}" ]
Getters & setters
[ "Getters", "&", "setters" ]
82eac10e365f72bab9248b8c3bd0ec9a2fc0a721
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/camel/vertx-proton/src/main/java/io/rhiot/camel/vertxproton/VertxProtonEndpoint.java#L108-L119
7,590
jeslopalo/flash-messages
flash-messages-spring/src/main/java/es/sandbox/ui/messages/spring/config/annotation/FlashMessagesConfigurationSupport.java
FlashMessagesConfigurationSupport.configureMessagesExceptionArgumentResolvers
@PostConstruct private void configureMessagesExceptionArgumentResolvers() { this.handlerExceptionResolver = this.applicationContext.getBean("handlerExceptionResolver", HandlerExceptionResolver.class); for (final HandlerExceptionResolver resolver : ((HandlerExceptionResolverComposite) this.handlerExceptionResolver).getExceptionResolvers()) { if (resolver instanceof ExceptionHandlerExceptionResolver) { configureCustomHandlerMethodArgumentResolver((ExceptionHandlerExceptionResolver) resolver); } } }
java
@PostConstruct private void configureMessagesExceptionArgumentResolvers() { this.handlerExceptionResolver = this.applicationContext.getBean("handlerExceptionResolver", HandlerExceptionResolver.class); for (final HandlerExceptionResolver resolver : ((HandlerExceptionResolverComposite) this.handlerExceptionResolver).getExceptionResolvers()) { if (resolver instanceof ExceptionHandlerExceptionResolver) { configureCustomHandlerMethodArgumentResolver((ExceptionHandlerExceptionResolver) resolver); } } }
[ "@", "PostConstruct", "private", "void", "configureMessagesExceptionArgumentResolvers", "(", ")", "{", "this", ".", "handlerExceptionResolver", "=", "this", ".", "applicationContext", ".", "getBean", "(", "\"handlerExceptionResolver\"", ",", "HandlerExceptionResolver", ".", "class", ")", ";", "for", "(", "final", "HandlerExceptionResolver", "resolver", ":", "(", "(", "HandlerExceptionResolverComposite", ")", "this", ".", "handlerExceptionResolver", ")", ".", "getExceptionResolvers", "(", ")", ")", "{", "if", "(", "resolver", "instanceof", "ExceptionHandlerExceptionResolver", ")", "{", "configureCustomHandlerMethodArgumentResolver", "(", "(", "ExceptionHandlerExceptionResolver", ")", "resolver", ")", ";", "}", "}", "}" ]
adds a FlashMessagesMethodArgumentResolver to handlerExceptionResolver's argument resolvers
[ "adds", "a", "FlashMessagesMethodArgumentResolver", "to", "handlerExceptionResolver", "s", "argument", "resolvers" ]
2faf23b09a8f72803fb295f0e0fe1d57282224cf
https://github.com/jeslopalo/flash-messages/blob/2faf23b09a8f72803fb295f0e0fe1d57282224cf/flash-messages-spring/src/main/java/es/sandbox/ui/messages/spring/config/annotation/FlashMessagesConfigurationSupport.java#L59-L68
7,591
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java
Fat32BootSector.setVolumeLabel
public void setVolumeLabel(String label) { for (int i=0; i < 11; i++) { final byte c = (label == null) ? 0 : (label.length() > i) ? (byte) label.charAt(i) : 0x20; set8(0x47 + i, c); } }
java
public void setVolumeLabel(String label) { for (int i=0; i < 11; i++) { final byte c = (label == null) ? 0 : (label.length() > i) ? (byte) label.charAt(i) : 0x20; set8(0x47 + i, c); } }
[ "public", "void", "setVolumeLabel", "(", "String", "label", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "11", ";", "i", "++", ")", "{", "final", "byte", "c", "=", "(", "label", "==", "null", ")", "?", "0", ":", "(", "label", ".", "length", "(", ")", ">", "i", ")", "?", "(", "byte", ")", "label", ".", "charAt", "(", "i", ")", ":", "0x20", ";", "set8", "(", "0x47", "+", "i", ",", "c", ")", ";", "}", "}" ]
Sets the 11-byte volume label stored at offset 0x47. @param label the new volume label, may be {@code null}
[ "Sets", "the", "11", "-", "byte", "volume", "label", "stored", "at", "offset", "0x47", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java#L118-L126
7,592
waldheinz/fat32-lib
src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java
Fat32BootSector.writeCopy
public void writeCopy(BlockDevice device) throws IOException { if (getBootSectorCopySector() > 0) { final long offset = (long)getBootSectorCopySector() * SIZE; buffer.rewind(); buffer.limit(buffer.capacity()); device.write(offset, buffer); } }
java
public void writeCopy(BlockDevice device) throws IOException { if (getBootSectorCopySector() > 0) { final long offset = (long)getBootSectorCopySector() * SIZE; buffer.rewind(); buffer.limit(buffer.capacity()); device.write(offset, buffer); } }
[ "public", "void", "writeCopy", "(", "BlockDevice", "device", ")", "throws", "IOException", "{", "if", "(", "getBootSectorCopySector", "(", ")", ">", "0", ")", "{", "final", "long", "offset", "=", "(", "long", ")", "getBootSectorCopySector", "(", ")", "*", "SIZE", ";", "buffer", ".", "rewind", "(", ")", ";", "buffer", ".", "limit", "(", "buffer", ".", "capacity", "(", ")", ")", ";", "device", ".", "write", "(", "offset", ",", "buffer", ")", ";", "}", "}" ]
Writes a copy of this boot sector to the specified device, if a copy is requested. @param device the device to write the boot sector copy to @throws IOException on write error @see #getBootSectorCopySector()
[ "Writes", "a", "copy", "of", "this", "boot", "sector", "to", "the", "specified", "device", "if", "a", "copy", "is", "requested", "." ]
3d8f1a986339573576e02eb0b6ea49bfdc9cce26
https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java#L191-L198
7,593
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/impl/QueryBindingImpl.java
QueryBindingImpl.cloneAndFilter
public QueryBindingImpl cloneAndFilter(Set<QueryArgument> args) { QueryBindingImpl binding = new QueryBindingImpl(); for(QueryArgument arg : getBoundArgs()) { if(args.contains(arg)) { binding.set(arg, bindingMap.get(arg)); } } return binding; }
java
public QueryBindingImpl cloneAndFilter(Set<QueryArgument> args) { QueryBindingImpl binding = new QueryBindingImpl(); for(QueryArgument arg : getBoundArgs()) { if(args.contains(arg)) { binding.set(arg, bindingMap.get(arg)); } } return binding; }
[ "public", "QueryBindingImpl", "cloneAndFilter", "(", "Set", "<", "QueryArgument", ">", "args", ")", "{", "QueryBindingImpl", "binding", "=", "new", "QueryBindingImpl", "(", ")", ";", "for", "(", "QueryArgument", "arg", ":", "getBoundArgs", "(", ")", ")", "{", "if", "(", "args", ".", "contains", "(", "arg", ")", ")", "{", "binding", ".", "set", "(", "arg", ",", "bindingMap", ".", "get", "(", "arg", ")", ")", ";", "}", "}", "return", "binding", ";", "}" ]
Clone this instance of QueryBinding and filter the binding map given by args. Only query arguments within the set of args will be available in the result. Only the QueryBinding class itself will be cloned, but not the query arguments. @return
[ "Clone", "this", "instance", "of", "QueryBinding", "and", "filter", "the", "binding", "map", "given", "by", "args", ".", "Only", "query", "arguments", "within", "the", "set", "of", "args", "will", "be", "available", "in", "the", "result", ".", "Only", "the", "QueryBinding", "class", "itself", "will", "be", "cloned", "but", "not", "the", "query", "arguments", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/impl/QueryBindingImpl.java#L136-L145
7,594
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java
RunResultsGenerateHookSetter.isLineLastStament
private boolean isLineLastStament(TestMethod method, int codeLineIndex) { CodeLine codeLine = method.getCodeBody().get(codeLineIndex); if (codeLineIndex == method.getCodeBody().size() - 1) { return true; } CodeLine nextCodeLine = method.getCodeBody().get(codeLineIndex + 1); assert codeLine.getEndLine() <= nextCodeLine.getStartLine(); if (codeLine.getEndLine() == nextCodeLine.getStartLine()) { // if next statement exists in the same line, // this statement is not the last statement for the line return false; } return true; }
java
private boolean isLineLastStament(TestMethod method, int codeLineIndex) { CodeLine codeLine = method.getCodeBody().get(codeLineIndex); if (codeLineIndex == method.getCodeBody().size() - 1) { return true; } CodeLine nextCodeLine = method.getCodeBody().get(codeLineIndex + 1); assert codeLine.getEndLine() <= nextCodeLine.getStartLine(); if (codeLine.getEndLine() == nextCodeLine.getStartLine()) { // if next statement exists in the same line, // this statement is not the last statement for the line return false; } return true; }
[ "private", "boolean", "isLineLastStament", "(", "TestMethod", "method", ",", "int", "codeLineIndex", ")", "{", "CodeLine", "codeLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "codeLineIndex", ")", ";", "if", "(", "codeLineIndex", "==", "method", ".", "getCodeBody", "(", ")", ".", "size", "(", ")", "-", "1", ")", "{", "return", "true", ";", "}", "CodeLine", "nextCodeLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "codeLineIndex", "+", "1", ")", ";", "assert", "codeLine", ".", "getEndLine", "(", ")", "<=", "nextCodeLine", ".", "getStartLine", "(", ")", ";", "if", "(", "codeLine", ".", "getEndLine", "(", ")", "==", "nextCodeLine", ".", "getStartLine", "(", ")", ")", "{", "// if next statement exists in the same line,", "// this statement is not the last statement for the line", "return", "false", ";", "}", "return", "true", ";", "}" ]
This may return false since multiple statement can be found in a line.
[ "This", "may", "return", "false", "since", "multiple", "statement", "can", "be", "found", "in", "a", "line", "." ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java#L110-L124
7,595
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java
RunResultsGenerateHookSetter.beforeHookInsertLine
private int beforeHookInsertLine(TestMethod method, int codeLineIndex) { if (!isLineLastStament(method, codeLineIndex)) { // don't insert the beforeHook since afterHook does not inserted to this line return -1; } // so that not to insert the hook to the middle of the line, // search the line top statement and insert hook to the statement line for (int i = codeLineIndex; i > 0; i--) { CodeLine thisLine = method.getCodeBody().get(i); CodeLine prevLine = method.getCodeBody().get(i - 1); assert prevLine.getEndLine() <= thisLine.getEndLine(); if (prevLine.getEndLine() != thisLine.getStartLine()) { return thisLine.getStartLine(); } } return method.getCodeBody().get(0).getStartLine(); }
java
private int beforeHookInsertLine(TestMethod method, int codeLineIndex) { if (!isLineLastStament(method, codeLineIndex)) { // don't insert the beforeHook since afterHook does not inserted to this line return -1; } // so that not to insert the hook to the middle of the line, // search the line top statement and insert hook to the statement line for (int i = codeLineIndex; i > 0; i--) { CodeLine thisLine = method.getCodeBody().get(i); CodeLine prevLine = method.getCodeBody().get(i - 1); assert prevLine.getEndLine() <= thisLine.getEndLine(); if (prevLine.getEndLine() != thisLine.getStartLine()) { return thisLine.getStartLine(); } } return method.getCodeBody().get(0).getStartLine(); }
[ "private", "int", "beforeHookInsertLine", "(", "TestMethod", "method", ",", "int", "codeLineIndex", ")", "{", "if", "(", "!", "isLineLastStament", "(", "method", ",", "codeLineIndex", ")", ")", "{", "// don't insert the beforeHook since afterHook does not inserted to this line", "return", "-", "1", ";", "}", "// so that not to insert the hook to the middle of the line,", "// search the line top statement and insert hook to the statement line", "for", "(", "int", "i", "=", "codeLineIndex", ";", "i", ">", "0", ";", "i", "--", ")", "{", "CodeLine", "thisLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "i", ")", ";", "CodeLine", "prevLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "i", "-", "1", ")", ";", "assert", "prevLine", ".", "getEndLine", "(", ")", "<=", "thisLine", ".", "getEndLine", "(", ")", ";", "if", "(", "prevLine", ".", "getEndLine", "(", ")", "!=", "thisLine", ".", "getStartLine", "(", ")", ")", "{", "return", "thisLine", ".", "getStartLine", "(", ")", ";", "}", "}", "return", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "0", ")", ".", "getStartLine", "(", ")", ";", "}" ]
Returns -1 if beforeHook for the codeLineIndex should not be inserted
[ "Returns", "-", "1", "if", "beforeHook", "for", "the", "codeLineIndex", "should", "not", "be", "inserted" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java#L128-L145
7,596
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java
RunResultsGenerateHookSetter.afterHookInsertLine
private int afterHookInsertLine(TestMethod method, int codeLineIndex) { // if multiple statements exist in one line, afterHook is inserted only after the last statement, // since when multi-line statements are like: // method(1);method( // 2); // insertion to the middle of the statement causes problem if (!isLineLastStament(method, codeLineIndex)) { return -1; } // insert hook to the next line of the codeLine // since insertAt method inserts code just before the specified line CodeLine codeLine = method.getCodeBody().get(codeLineIndex); return codeLine.getEndLine() + 1; }
java
private int afterHookInsertLine(TestMethod method, int codeLineIndex) { // if multiple statements exist in one line, afterHook is inserted only after the last statement, // since when multi-line statements are like: // method(1);method( // 2); // insertion to the middle of the statement causes problem if (!isLineLastStament(method, codeLineIndex)) { return -1; } // insert hook to the next line of the codeLine // since insertAt method inserts code just before the specified line CodeLine codeLine = method.getCodeBody().get(codeLineIndex); return codeLine.getEndLine() + 1; }
[ "private", "int", "afterHookInsertLine", "(", "TestMethod", "method", ",", "int", "codeLineIndex", ")", "{", "// if multiple statements exist in one line, afterHook is inserted only after the last statement,", "// since when multi-line statements are like:", "// method(1);method(", "// 2);", "// insertion to the middle of the statement causes problem", "if", "(", "!", "isLineLastStament", "(", "method", ",", "codeLineIndex", ")", ")", "{", "return", "-", "1", ";", "}", "// insert hook to the next line of the codeLine", "// since insertAt method inserts code just before the specified line", "CodeLine", "codeLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "codeLineIndex", ")", ";", "return", "codeLine", ".", "getEndLine", "(", ")", "+", "1", ";", "}" ]
Returns -1 if afterHook for the codeLineIndex should not be inserted
[ "Returns", "-", "1", "if", "afterHook", "for", "the", "codeLineIndex", "should", "not", "be", "inserted" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java#L149-L162
7,597
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java
RunResultsGenerateHookSetter.insertCodeBodyHook
private boolean insertCodeBodyHook(TestMethod method, CtMethod ctMethod, String classQualifiedName, String methodSimpleName, String methodArgClassesStr) throws CannotCompileException { String hookClassName = HookMethodDef.class.getCanonicalName(); String initializeSrc = hookInitializeSrc(); boolean transformed = false; // iterate code body in the inverse order, // so that beforeHook is always inserted after the afterHook of the previous line // even if target line of these two hooks are the same for (int i = method.getCodeBody().size() - 1; i >= 0; i--) { int hookedLine = method.getCodeBody().get(i).getStartLine(); // insert afterHook first and beforeHook second in each iteration, // so that beforeHook is always inserted before the afterHook // even if actual inserted lines for these two hooks are the same int afterHookInsertedLine = afterHookInsertLine(method, i); if (afterHookInsertedLine != -1) { int actualAfterHookInsertedLine = ctMethod.insertAt(afterHookInsertedLine, false, null); ctMethod.insertAt(afterHookInsertedLine, String.format("%s%s.afterCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);", initializeSrc, hookClassName, classQualifiedName, methodSimpleName, methodSimpleName, methodArgClassesStr, hookedLine, actualAfterHookInsertedLine)); transformed = true; } int beforeHookInsertedLine = beforeHookInsertLine(method, i); if (beforeHookInsertedLine != -1) { int actualBeforeHookInsertedLine = ctMethod.insertAt(beforeHookInsertedLine, false, null); ctMethod.insertAt(beforeHookInsertedLine, String.format("%s%s.beforeCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);", initializeSrc, hookClassName, classQualifiedName, methodSimpleName, methodSimpleName, methodArgClassesStr, hookedLine, actualBeforeHookInsertedLine)); transformed = true; } } return transformed; }
java
private boolean insertCodeBodyHook(TestMethod method, CtMethod ctMethod, String classQualifiedName, String methodSimpleName, String methodArgClassesStr) throws CannotCompileException { String hookClassName = HookMethodDef.class.getCanonicalName(); String initializeSrc = hookInitializeSrc(); boolean transformed = false; // iterate code body in the inverse order, // so that beforeHook is always inserted after the afterHook of the previous line // even if target line of these two hooks are the same for (int i = method.getCodeBody().size() - 1; i >= 0; i--) { int hookedLine = method.getCodeBody().get(i).getStartLine(); // insert afterHook first and beforeHook second in each iteration, // so that beforeHook is always inserted before the afterHook // even if actual inserted lines for these two hooks are the same int afterHookInsertedLine = afterHookInsertLine(method, i); if (afterHookInsertedLine != -1) { int actualAfterHookInsertedLine = ctMethod.insertAt(afterHookInsertedLine, false, null); ctMethod.insertAt(afterHookInsertedLine, String.format("%s%s.afterCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);", initializeSrc, hookClassName, classQualifiedName, methodSimpleName, methodSimpleName, methodArgClassesStr, hookedLine, actualAfterHookInsertedLine)); transformed = true; } int beforeHookInsertedLine = beforeHookInsertLine(method, i); if (beforeHookInsertedLine != -1) { int actualBeforeHookInsertedLine = ctMethod.insertAt(beforeHookInsertedLine, false, null); ctMethod.insertAt(beforeHookInsertedLine, String.format("%s%s.beforeCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);", initializeSrc, hookClassName, classQualifiedName, methodSimpleName, methodSimpleName, methodArgClassesStr, hookedLine, actualBeforeHookInsertedLine)); transformed = true; } } return transformed; }
[ "private", "boolean", "insertCodeBodyHook", "(", "TestMethod", "method", ",", "CtMethod", "ctMethod", ",", "String", "classQualifiedName", ",", "String", "methodSimpleName", ",", "String", "methodArgClassesStr", ")", "throws", "CannotCompileException", "{", "String", "hookClassName", "=", "HookMethodDef", ".", "class", ".", "getCanonicalName", "(", ")", ";", "String", "initializeSrc", "=", "hookInitializeSrc", "(", ")", ";", "boolean", "transformed", "=", "false", ";", "// iterate code body in the inverse order,", "// so that beforeHook is always inserted after the afterHook of the previous line", "// even if target line of these two hooks are the same", "for", "(", "int", "i", "=", "method", ".", "getCodeBody", "(", ")", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "int", "hookedLine", "=", "method", ".", "getCodeBody", "(", ")", ".", "get", "(", "i", ")", ".", "getStartLine", "(", ")", ";", "// insert afterHook first and beforeHook second in each iteration,", "// so that beforeHook is always inserted before the afterHook", "// even if actual inserted lines for these two hooks are the same", "int", "afterHookInsertedLine", "=", "afterHookInsertLine", "(", "method", ",", "i", ")", ";", "if", "(", "afterHookInsertedLine", "!=", "-", "1", ")", "{", "int", "actualAfterHookInsertedLine", "=", "ctMethod", ".", "insertAt", "(", "afterHookInsertedLine", ",", "false", ",", "null", ")", ";", "ctMethod", ".", "insertAt", "(", "afterHookInsertedLine", ",", "String", ".", "format", "(", "\"%s%s.afterCodeLineHook(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",%d, %d);\"", ",", "initializeSrc", ",", "hookClassName", ",", "classQualifiedName", ",", "methodSimpleName", ",", "methodSimpleName", ",", "methodArgClassesStr", ",", "hookedLine", ",", "actualAfterHookInsertedLine", ")", ")", ";", "transformed", "=", "true", ";", "}", "int", "beforeHookInsertedLine", "=", "beforeHookInsertLine", "(", "method", ",", "i", ")", ";", "if", "(", "beforeHookInsertedLine", "!=", "-", "1", ")", "{", "int", "actualBeforeHookInsertedLine", "=", "ctMethod", ".", "insertAt", "(", "beforeHookInsertedLine", ",", "false", ",", "null", ")", ";", "ctMethod", ".", "insertAt", "(", "beforeHookInsertedLine", ",", "String", ".", "format", "(", "\"%s%s.beforeCodeLineHook(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",%d, %d);\"", ",", "initializeSrc", ",", "hookClassName", ",", "classQualifiedName", ",", "methodSimpleName", ",", "methodSimpleName", ",", "methodArgClassesStr", ",", "hookedLine", ",", "actualBeforeHookInsertedLine", ")", ")", ";", "transformed", "=", "true", ";", "}", "}", "return", "transformed", ";", "}" ]
- returns true this method actually transform ctMethod body
[ "-", "returns", "true", "this", "method", "actually", "transform", "ctMethod", "body" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/runresultsgen/RunResultsGenerateHookSetter.java#L166-L206
7,598
SahaginOrg/sahagin-java
src/main/java/org/sahagin/runlib/srctreegen/SrcTreeGenerator.java
SrcTreeGenerator.generate
public SrcTree generate(String[] srcFiles, Charset srcCharset, String[] classPathEntries) { // collect root class and method table without code body CollectRootRequestor rootRequestor = new CollectRootRequestor(); parseAST(srcFiles, srcCharset, classPathEntries, rootRequestor); // collect sub class and method table without code body CollectSubRequestor subRequestor = new CollectSubRequestor(rootRequestor.getRootClassTable()); parseAST(srcFiles, srcCharset, classPathEntries, subRequestor); // add additional TestDoc to the table AdditionalTestDocsSetter setter = new AdditionalTestDocsSetter( rootRequestor.getRootClassTable(), subRequestor.getSubClassTable(), rootRequestor.getRootMethodTable(), subRequestor.getSubMethodTable()); setter.set(additionalTestDocs); // collect code CollectCodeRequestor codeRequestor = new CollectCodeRequestor( subRequestor.getSubClassTable(), rootRequestor.getRootMethodTable(), subRequestor.getSubMethodTable(), subRequestor.getFieldTable()); parseAST(srcFiles, srcCharset, classPathEntries, codeRequestor); SrcTree result = new SrcTree(); result.setRootClassTable(rootRequestor.getRootClassTable()); result.setSubClassTable(subRequestor.getSubClassTable()); result.setRootMethodTable(rootRequestor.getRootMethodTable()); result.setSubMethodTable(subRequestor.getSubMethodTable()); result.setFieldTable(subRequestor.getFieldTable()); return result; }
java
public SrcTree generate(String[] srcFiles, Charset srcCharset, String[] classPathEntries) { // collect root class and method table without code body CollectRootRequestor rootRequestor = new CollectRootRequestor(); parseAST(srcFiles, srcCharset, classPathEntries, rootRequestor); // collect sub class and method table without code body CollectSubRequestor subRequestor = new CollectSubRequestor(rootRequestor.getRootClassTable()); parseAST(srcFiles, srcCharset, classPathEntries, subRequestor); // add additional TestDoc to the table AdditionalTestDocsSetter setter = new AdditionalTestDocsSetter( rootRequestor.getRootClassTable(), subRequestor.getSubClassTable(), rootRequestor.getRootMethodTable(), subRequestor.getSubMethodTable()); setter.set(additionalTestDocs); // collect code CollectCodeRequestor codeRequestor = new CollectCodeRequestor( subRequestor.getSubClassTable(), rootRequestor.getRootMethodTable(), subRequestor.getSubMethodTable(), subRequestor.getFieldTable()); parseAST(srcFiles, srcCharset, classPathEntries, codeRequestor); SrcTree result = new SrcTree(); result.setRootClassTable(rootRequestor.getRootClassTable()); result.setSubClassTable(subRequestor.getSubClassTable()); result.setRootMethodTable(rootRequestor.getRootMethodTable()); result.setSubMethodTable(subRequestor.getSubMethodTable()); result.setFieldTable(subRequestor.getFieldTable()); return result; }
[ "public", "SrcTree", "generate", "(", "String", "[", "]", "srcFiles", ",", "Charset", "srcCharset", ",", "String", "[", "]", "classPathEntries", ")", "{", "// collect root class and method table without code body", "CollectRootRequestor", "rootRequestor", "=", "new", "CollectRootRequestor", "(", ")", ";", "parseAST", "(", "srcFiles", ",", "srcCharset", ",", "classPathEntries", ",", "rootRequestor", ")", ";", "// collect sub class and method table without code body", "CollectSubRequestor", "subRequestor", "=", "new", "CollectSubRequestor", "(", "rootRequestor", ".", "getRootClassTable", "(", ")", ")", ";", "parseAST", "(", "srcFiles", ",", "srcCharset", ",", "classPathEntries", ",", "subRequestor", ")", ";", "// add additional TestDoc to the table", "AdditionalTestDocsSetter", "setter", "=", "new", "AdditionalTestDocsSetter", "(", "rootRequestor", ".", "getRootClassTable", "(", ")", ",", "subRequestor", ".", "getSubClassTable", "(", ")", ",", "rootRequestor", ".", "getRootMethodTable", "(", ")", ",", "subRequestor", ".", "getSubMethodTable", "(", ")", ")", ";", "setter", ".", "set", "(", "additionalTestDocs", ")", ";", "// collect code", "CollectCodeRequestor", "codeRequestor", "=", "new", "CollectCodeRequestor", "(", "subRequestor", ".", "getSubClassTable", "(", ")", ",", "rootRequestor", ".", "getRootMethodTable", "(", ")", ",", "subRequestor", ".", "getSubMethodTable", "(", ")", ",", "subRequestor", ".", "getFieldTable", "(", ")", ")", ";", "parseAST", "(", "srcFiles", ",", "srcCharset", ",", "classPathEntries", ",", "codeRequestor", ")", ";", "SrcTree", "result", "=", "new", "SrcTree", "(", ")", ";", "result", ".", "setRootClassTable", "(", "rootRequestor", ".", "getRootClassTable", "(", ")", ")", ";", "result", ".", "setSubClassTable", "(", "subRequestor", ".", "getSubClassTable", "(", ")", ")", ";", "result", ".", "setRootMethodTable", "(", "rootRequestor", ".", "getRootMethodTable", "(", ")", ")", ";", "result", ".", "setSubMethodTable", "(", "subRequestor", ".", "getSubMethodTable", "(", ")", ")", ";", "result", ".", "setFieldTable", "(", "subRequestor", ".", "getFieldTable", "(", ")", ")", ";", "return", "result", ";", "}" ]
all class containing sub directories even if the class is in a named package
[ "all", "class", "containing", "sub", "directories", "even", "if", "the", "class", "is", "in", "a", "named", "package" ]
7ace428adebe3466ceb5826bc9681f8e3d52be68
https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/runlib/srctreegen/SrcTreeGenerator.java#L871-L899
7,599
protegeproject/sparql-dl-api
src/main/java/de/derivo/sparqldlapi/QueryAtom.java
QueryAtom.bind
public QueryAtom bind(QueryBinding binding) { List<QueryArgument> args = new ArrayList<QueryArgument>(); for(QueryArgument arg : this.args) { if(binding.isBound(arg)) { args.add(binding.get(arg)); } else { args.add(arg); } } return new QueryAtom(type, args); }
java
public QueryAtom bind(QueryBinding binding) { List<QueryArgument> args = new ArrayList<QueryArgument>(); for(QueryArgument arg : this.args) { if(binding.isBound(arg)) { args.add(binding.get(arg)); } else { args.add(arg); } } return new QueryAtom(type, args); }
[ "public", "QueryAtom", "bind", "(", "QueryBinding", "binding", ")", "{", "List", "<", "QueryArgument", ">", "args", "=", "new", "ArrayList", "<", "QueryArgument", ">", "(", ")", ";", "for", "(", "QueryArgument", "arg", ":", "this", ".", "args", ")", "{", "if", "(", "binding", ".", "isBound", "(", "arg", ")", ")", "{", "args", ".", "add", "(", "binding", ".", "get", "(", "arg", ")", ")", ";", "}", "else", "{", "args", ".", "add", "(", "arg", ")", ";", "}", "}", "return", "new", "QueryAtom", "(", "type", ",", "args", ")", ";", "}" ]
A convenience method to clone the QueryAtom instance while inserting a new binding. @param binding @return
[ "A", "convenience", "method", "to", "clone", "the", "QueryAtom", "instance", "while", "inserting", "a", "new", "binding", "." ]
80d430d439e17a691d0111819af2d3613e28d625
https://github.com/protegeproject/sparql-dl-api/blob/80d430d439e17a691d0111819af2d3613e28d625/src/main/java/de/derivo/sparqldlapi/QueryAtom.java#L92-L105