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
148,700
versionone/VersionOne.SDK.Java.ObjectModel
src/main/java/com/versionone/om/Project.java
Project.getTotalDone
public Double getTotalDone(WorkitemFilter filter, boolean includeChildProjects) { filter = (filter != null) ? filter : new WorkitemFilter(); return getRollup("Workitems", "Actuals.Value", filter, includeChildProjects); }
java
public Double getTotalDone(WorkitemFilter filter, boolean includeChildProjects) { filter = (filter != null) ? filter : new WorkitemFilter(); return getRollup("Workitems", "Actuals.Value", filter, includeChildProjects); }
[ "public", "Double", "getTotalDone", "(", "WorkitemFilter", "filter", ",", "boolean", "includeChildProjects", ")", "{", "filter", "=", "(", "filter", "!=", "null", ")", "?", "filter", ":", "new", "WorkitemFilter", "(", ")", ";", "return", "getRollup", "(", "\"Workitems\"", ",", "\"Actuals.Value\"", ",", "filter", ",", "includeChildProjects", ")", ";", "}" ]
Retrieves the total done for all workitems in this project optionally filtered. @param filter Criteria to filter workitems on. @param includeChildProjects If true, include open sub projects, otherwise only include this project. @return total done for selected workitems.
[ "Retrieves", "the", "total", "done", "for", "all", "workitems", "in", "this", "project", "optionally", "filtered", "." ]
59d35b67c849299631bca45ee94143237eb2ae1a
https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Project.java#L1155-L1160
148,701
agmip/ace-core
src/main/java/org/agmip/ace/AceComponent.java
AceComponent.keySet
public Set<String> keySet() throws IOException { Set<String> ret = new HashSet<>(); JsonParser p = this.getParser(); JsonToken t; t = p.nextToken(); while (t != null) { if (t == JsonToken.FIELD_NAME) { ret.add(p.getCurrentName()); } t = p.nextToken(); } p.close(); return ret; }
java
public Set<String> keySet() throws IOException { Set<String> ret = new HashSet<>(); JsonParser p = this.getParser(); JsonToken t; t = p.nextToken(); while (t != null) { if (t == JsonToken.FIELD_NAME) { ret.add(p.getCurrentName()); } t = p.nextToken(); } p.close(); return ret; }
[ "public", "Set", "<", "String", ">", "keySet", "(", ")", "throws", "IOException", "{", "Set", "<", "String", ">", "ret", "=", "new", "HashSet", "<>", "(", ")", ";", "JsonParser", "p", "=", "this", ".", "getParser", "(", ")", ";", "JsonToken", "t", ";", "t", "=", "p", ".", "nextToken", "(", ")", ";", "while", "(", "t", "!=", "null", ")", "{", "if", "(", "t", "==", "JsonToken", ".", "FIELD_NAME", ")", "{", "ret", ".", "add", "(", "p", ".", "getCurrentName", "(", ")", ")", ";", "}", "t", "=", "p", ".", "nextToken", "(", ")", ";", "}", "p", ".", "close", "(", ")", ";", "return", "ret", ";", "}" ]
Return a set of all key names in the component @return the set of key names @throws IOException if there is an I/O error
[ "Return", "a", "set", "of", "all", "key", "names", "in", "the", "component" ]
51957e79b4567d0083c52d0720f4a268c3a02f44
https://github.com/agmip/ace-core/blob/51957e79b4567d0083c52d0720f4a268c3a02f44/src/main/java/org/agmip/ace/AceComponent.java#L175-L190
148,702
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/FileKeyValStore.java
FileKeyValStore.getValue
public String getValue(String name) { Properties properties = loadProperties(); return (String) properties.getProperty(name); }
java
public String getValue(String name) { Properties properties = loadProperties(); return (String) properties.getProperty(name); }
[ "public", "String", "getValue", "(", "String", "name", ")", "{", "Properties", "properties", "=", "loadProperties", "(", ")", ";", "return", "(", "String", ")", "properties", ".", "getProperty", "(", "name", ")", ";", "}" ]
Get the value associated with name. @param name @return value associated with the name
[ "Get", "the", "value", "associated", "with", "name", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/FileKeyValStore.java#L46-L49
148,703
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/FileKeyValStore.java
FileKeyValStore.setValue
public void setValue(String name, String value) { Properties properties = loadProperties(); try ( OutputStream output = new FileOutputStream(file); ) { properties.setProperty(name, value); properties.store(output, ""); output.close(); } catch(IOException e) { logger.warn(String.format("Could not save the keyvalue store, reason:%s", e.getMessage())); } }
java
public void setValue(String name, String value) { Properties properties = loadProperties(); try ( OutputStream output = new FileOutputStream(file); ) { properties.setProperty(name, value); properties.store(output, ""); output.close(); } catch(IOException e) { logger.warn(String.format("Could not save the keyvalue store, reason:%s", e.getMessage())); } }
[ "public", "void", "setValue", "(", "String", "name", ",", "String", "value", ")", "{", "Properties", "properties", "=", "loadProperties", "(", ")", ";", "try", "(", "OutputStream", "output", "=", "new", "FileOutputStream", "(", "file", ")", ";", ")", "{", "properties", ".", "setProperty", "(", "name", ",", "value", ")", ";", "properties", ".", "store", "(", "output", ",", "\"\"", ")", ";", "output", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "warn", "(", "String", ".", "format", "(", "\"Could not save the keyvalue store, reason:%s\"", ",", "e", ".", "getMessage", "(", ")", ")", ")", ";", "}", "}" ]
Set the value associated with name. @param name @param value
[ "Set", "the", "value", "associated", "with", "name", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/FileKeyValStore.java#L71-L83
148,704
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.markIsTransaction
public synchronized boolean markIsTransaction(String uuid, boolean isTransaction) { if (this.isTransaction == null) { return false; } this.isTransaction.put(uuid, isTransaction); return true; }
java
public synchronized boolean markIsTransaction(String uuid, boolean isTransaction) { if (this.isTransaction == null) { return false; } this.isTransaction.put(uuid, isTransaction); return true; }
[ "public", "synchronized", "boolean", "markIsTransaction", "(", "String", "uuid", ",", "boolean", "isTransaction", ")", "{", "if", "(", "this", ".", "isTransaction", "==", "null", ")", "{", "return", "false", ";", "}", "this", ".", "isTransaction", ".", "put", "(", "uuid", ",", "isTransaction", ")", ";", "return", "true", ";", "}" ]
Marks a UUID as either a transaction or a query @param uuid ID to be marked @param isTransaction true for transaction, false for query @return whether or not the UUID was successfully marked
[ "Marks", "a", "UUID", "as", "either", "a", "transaction", "or", "a", "query" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L168-L175
148,705
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.enterInitState
public void enterInitState(Event event) { logger.debug(String.format("Entered state %s", fsm.current())); ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]Received %s, initializing chaincode", shortID(message), message.getType().toString())); if (message.getType() == INIT) { // Call the chaincode's Run function to initialize try { handleInit(message); } catch (InvalidTransactionException e) { e.printStackTrace(); } } }
java
public void enterInitState(Event event) { logger.debug(String.format("Entered state %s", fsm.current())); ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]Received %s, initializing chaincode", shortID(message), message.getType().toString())); if (message.getType() == INIT) { // Call the chaincode's Run function to initialize try { handleInit(message); } catch (InvalidTransactionException e) { e.printStackTrace(); } } }
[ "public", "void", "enterInitState", "(", "Event", "event", ")", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"Entered state %s\"", ",", "fsm", ".", "current", "(", ")", ")", ")", ";", "ChaincodeMessage", "message", "=", "messageHelper", "(", "event", ")", ";", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Received %s, initializing chaincode\"", ",", "shortID", "(", "message", ")", ",", "message", ".", "getType", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "if", "(", "message", ".", "getType", "(", ")", "==", "INIT", ")", "{", "// Call the chaincode's Run function to initialize", "try", "{", "handleInit", "(", "message", ")", ";", "}", "catch", "(", "InvalidTransactionException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}" ]
enterInitState will initialize the chaincode if entering init from established.
[ "enterInitState", "will", "initialize", "the", "chaincode", "if", "entering", "init", "from", "established", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L267-L280
148,706
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.handleTransaction
public void handleTransaction(ChaincodeMessage message) { // The defer followed by triggering a go routine dance is needed to ensure that the previous state transition // is completed before the next one is triggered. The previous state transition is deemed complete only when // the beforeInit function is exited. Interesting bug fix!! Runnable task = () -> { //better not be nil ChaincodeMessage nextStatemessage = null; boolean send = true; //Defer try { // Get the function and args from Payload ChaincodeInput input; try { input = ChaincodeInput.parseFrom(message.getPayload()); } catch (Exception e) { logger.debug(String.format("[%s]Incorrect payload format. Sending %s", shortID(message), ERROR)); // Send ERROR message to chaincode support and change state nextStatemessage = ChaincodeMessage.newBuilder() .setType(ERROR) .setPayload(message.getPayload()) .setTxid(message.getTxid()) .build(); return; } // Mark as a transaction (allow put/del state) markIsTransaction(message.getTxid(), true); // Create the ChaincodeStub which the chaincode can use to callback ChaincodeStub stub = new ChaincodeStub(message.getTxid(), this, message.getSecurityContext()); // Call chaincode's Run ByteString response; try { response = chaincode.runHelper(stub, getFunction(input.getArgsList()), getParameters(input.getArgsList())); } catch (Exception e) { e.printStackTrace(); System.err.flush(); // Send ERROR message to chaincode support and change state logger.error(String.format("[%s]Error running chaincode. Transaction execution failed. Sending %s", shortID(message), ERROR)); nextStatemessage = ChaincodeMessage.newBuilder() .setType(ERROR) .setPayload(message.getPayload()) .setTxid(message.getTxid()) .build(); return; } finally { deleteIsTransaction(message.getTxid()); } logger.debug(String.format("[%s]Transaction completed. Sending %s", shortID(message), COMPLETED)); // Send COMPLETED message to chaincode support and change state Builder builder = ChaincodeMessage.newBuilder() .setType(COMPLETED) .setTxid(message.getTxid()); if (response != null) builder.setPayload(response); nextStatemessage = builder.build(); } finally { triggerNextState(nextStatemessage, send); } }; new Thread(task).start(); }
java
public void handleTransaction(ChaincodeMessage message) { // The defer followed by triggering a go routine dance is needed to ensure that the previous state transition // is completed before the next one is triggered. The previous state transition is deemed complete only when // the beforeInit function is exited. Interesting bug fix!! Runnable task = () -> { //better not be nil ChaincodeMessage nextStatemessage = null; boolean send = true; //Defer try { // Get the function and args from Payload ChaincodeInput input; try { input = ChaincodeInput.parseFrom(message.getPayload()); } catch (Exception e) { logger.debug(String.format("[%s]Incorrect payload format. Sending %s", shortID(message), ERROR)); // Send ERROR message to chaincode support and change state nextStatemessage = ChaincodeMessage.newBuilder() .setType(ERROR) .setPayload(message.getPayload()) .setTxid(message.getTxid()) .build(); return; } // Mark as a transaction (allow put/del state) markIsTransaction(message.getTxid(), true); // Create the ChaincodeStub which the chaincode can use to callback ChaincodeStub stub = new ChaincodeStub(message.getTxid(), this, message.getSecurityContext()); // Call chaincode's Run ByteString response; try { response = chaincode.runHelper(stub, getFunction(input.getArgsList()), getParameters(input.getArgsList())); } catch (Exception e) { e.printStackTrace(); System.err.flush(); // Send ERROR message to chaincode support and change state logger.error(String.format("[%s]Error running chaincode. Transaction execution failed. Sending %s", shortID(message), ERROR)); nextStatemessage = ChaincodeMessage.newBuilder() .setType(ERROR) .setPayload(message.getPayload()) .setTxid(message.getTxid()) .build(); return; } finally { deleteIsTransaction(message.getTxid()); } logger.debug(String.format("[%s]Transaction completed. Sending %s", shortID(message), COMPLETED)); // Send COMPLETED message to chaincode support and change state Builder builder = ChaincodeMessage.newBuilder() .setType(COMPLETED) .setTxid(message.getTxid()); if (response != null) builder.setPayload(response); nextStatemessage = builder.build(); } finally { triggerNextState(nextStatemessage, send); } }; new Thread(task).start(); }
[ "public", "void", "handleTransaction", "(", "ChaincodeMessage", "message", ")", "{", "// The defer followed by triggering a go routine dance is needed to ensure that the previous state transition", "// is completed before the next one is triggered. The previous state transition is deemed complete only when", "// the beforeInit function is exited. Interesting bug fix!!", "Runnable", "task", "=", "(", ")", "->", "{", "//better not be nil", "ChaincodeMessage", "nextStatemessage", "=", "null", ";", "boolean", "send", "=", "true", ";", "//Defer", "try", "{", "// Get the function and args from Payload", "ChaincodeInput", "input", ";", "try", "{", "input", "=", "ChaincodeInput", ".", "parseFrom", "(", "message", ".", "getPayload", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Incorrect payload format. Sending %s\"", ",", "shortID", "(", "message", ")", ",", "ERROR", ")", ")", ";", "// Send ERROR message to chaincode support and change state", "nextStatemessage", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "ERROR", ")", ".", "setPayload", "(", "message", ".", "getPayload", "(", ")", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ".", "build", "(", ")", ";", "return", ";", "}", "// Mark as a transaction (allow put/del state)", "markIsTransaction", "(", "message", ".", "getTxid", "(", ")", ",", "true", ")", ";", "// Create the ChaincodeStub which the chaincode can use to callback", "ChaincodeStub", "stub", "=", "new", "ChaincodeStub", "(", "message", ".", "getTxid", "(", ")", ",", "this", ",", "message", ".", "getSecurityContext", "(", ")", ")", ";", "// Call chaincode's Run", "ByteString", "response", ";", "try", "{", "response", "=", "chaincode", ".", "runHelper", "(", "stub", ",", "getFunction", "(", "input", ".", "getArgsList", "(", ")", ")", ",", "getParameters", "(", "input", ".", "getArgsList", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "System", ".", "err", ".", "flush", "(", ")", ";", "// Send ERROR message to chaincode support and change state", "logger", ".", "error", "(", "String", ".", "format", "(", "\"[%s]Error running chaincode. Transaction execution failed. Sending %s\"", ",", "shortID", "(", "message", ")", ",", "ERROR", ")", ")", ";", "nextStatemessage", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "ERROR", ")", ".", "setPayload", "(", "message", ".", "getPayload", "(", ")", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ".", "build", "(", ")", ";", "return", ";", "}", "finally", "{", "deleteIsTransaction", "(", "message", ".", "getTxid", "(", ")", ")", ";", "}", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Transaction completed. Sending %s\"", ",", "shortID", "(", "message", ")", ",", "COMPLETED", ")", ")", ";", "// Send COMPLETED message to chaincode support and change state", "Builder", "builder", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "COMPLETED", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ";", "if", "(", "response", "!=", "null", ")", "builder", ".", "setPayload", "(", "response", ")", ";", "nextStatemessage", "=", "builder", ".", "build", "(", ")", ";", "}", "finally", "{", "triggerNextState", "(", "nextStatemessage", ",", "send", ")", ";", "}", "}", ";", "new", "Thread", "(", "task", ")", ".", "start", "(", ")", ";", "}" ]
handleTransaction Handles request to execute a transaction.
[ "handleTransaction", "Handles", "request", "to", "execute", "a", "transaction", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L284-L351
148,707
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.handleQuery
public void handleQuery(ChaincodeMessage message) { // Query does not transition state. It can happen anytime after Ready Runnable task = () -> { ChaincodeMessage serialSendMessage = null; try { // Get the function and args from Payload ChaincodeInput input; try { input = ChaincodeInput.parseFrom(message.getPayload()); } catch (Exception e) { // Send ERROR message to chaincode support and change state logger.debug(String.format("[%s]Incorrect payload format. Sending %s", shortID(message), QUERY_ERROR)); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_ERROR) .setPayload(ByteString.copyFromUtf8(e.getMessage())) .setTxid(message.getTxid()) .build(); return; } // Mark as a query (do not allow put/del state) markIsTransaction(message.getTxid(), false); // Call chaincode's Query // Create the ChaincodeStub which the chaincode can use to callback ChaincodeStub stub = new ChaincodeStub(message.getTxid(), this, message.getSecurityContext()); ByteString response; try { response = chaincode.queryHelper(stub, getFunction(input.getArgsList()), getParameters(input.getArgsList())); } catch (Exception e) { // Send ERROR message to chaincode support and change state logger.debug(String.format("[%s]Query execution failed. Sending %s", shortID(message), QUERY_ERROR)); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_ERROR) .setPayload(ByteString.copyFromUtf8(e.getMessage())) .setTxid(message.getTxid()) .build(); return; } finally { deleteIsTransaction(message.getTxid()); } // Send COMPLETED message to chaincode support logger.debug("["+ shortID(message)+"]Query completed. Sending "+ QUERY_COMPLETED); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_COMPLETED) .setPayload(response) .setTxid(message.getTxid()) .build(); } finally { serialSend(serialSendMessage); } }; new Thread(task).start(); }
java
public void handleQuery(ChaincodeMessage message) { // Query does not transition state. It can happen anytime after Ready Runnable task = () -> { ChaincodeMessage serialSendMessage = null; try { // Get the function and args from Payload ChaincodeInput input; try { input = ChaincodeInput.parseFrom(message.getPayload()); } catch (Exception e) { // Send ERROR message to chaincode support and change state logger.debug(String.format("[%s]Incorrect payload format. Sending %s", shortID(message), QUERY_ERROR)); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_ERROR) .setPayload(ByteString.copyFromUtf8(e.getMessage())) .setTxid(message.getTxid()) .build(); return; } // Mark as a query (do not allow put/del state) markIsTransaction(message.getTxid(), false); // Call chaincode's Query // Create the ChaincodeStub which the chaincode can use to callback ChaincodeStub stub = new ChaincodeStub(message.getTxid(), this, message.getSecurityContext()); ByteString response; try { response = chaincode.queryHelper(stub, getFunction(input.getArgsList()), getParameters(input.getArgsList())); } catch (Exception e) { // Send ERROR message to chaincode support and change state logger.debug(String.format("[%s]Query execution failed. Sending %s", shortID(message), QUERY_ERROR)); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_ERROR) .setPayload(ByteString.copyFromUtf8(e.getMessage())) .setTxid(message.getTxid()) .build(); return; } finally { deleteIsTransaction(message.getTxid()); } // Send COMPLETED message to chaincode support logger.debug("["+ shortID(message)+"]Query completed. Sending "+ QUERY_COMPLETED); serialSendMessage = ChaincodeMessage.newBuilder() .setType(QUERY_COMPLETED) .setPayload(response) .setTxid(message.getTxid()) .build(); } finally { serialSend(serialSendMessage); } }; new Thread(task).start(); }
[ "public", "void", "handleQuery", "(", "ChaincodeMessage", "message", ")", "{", "// Query does not transition state. It can happen anytime after Ready", "Runnable", "task", "=", "(", ")", "->", "{", "ChaincodeMessage", "serialSendMessage", "=", "null", ";", "try", "{", "// Get the function and args from Payload", "ChaincodeInput", "input", ";", "try", "{", "input", "=", "ChaincodeInput", ".", "parseFrom", "(", "message", ".", "getPayload", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Send ERROR message to chaincode support and change state", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Incorrect payload format. Sending %s\"", ",", "shortID", "(", "message", ")", ",", "QUERY_ERROR", ")", ")", ";", "serialSendMessage", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "QUERY_ERROR", ")", ".", "setPayload", "(", "ByteString", ".", "copyFromUtf8", "(", "e", ".", "getMessage", "(", ")", ")", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ".", "build", "(", ")", ";", "return", ";", "}", "// Mark as a query (do not allow put/del state)", "markIsTransaction", "(", "message", ".", "getTxid", "(", ")", ",", "false", ")", ";", "// Call chaincode's Query", "// Create the ChaincodeStub which the chaincode can use to callback", "ChaincodeStub", "stub", "=", "new", "ChaincodeStub", "(", "message", ".", "getTxid", "(", ")", ",", "this", ",", "message", ".", "getSecurityContext", "(", ")", ")", ";", "ByteString", "response", ";", "try", "{", "response", "=", "chaincode", ".", "queryHelper", "(", "stub", ",", "getFunction", "(", "input", ".", "getArgsList", "(", ")", ")", ",", "getParameters", "(", "input", ".", "getArgsList", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Send ERROR message to chaincode support and change state", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Query execution failed. Sending %s\"", ",", "shortID", "(", "message", ")", ",", "QUERY_ERROR", ")", ")", ";", "serialSendMessage", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "QUERY_ERROR", ")", ".", "setPayload", "(", "ByteString", ".", "copyFromUtf8", "(", "e", ".", "getMessage", "(", ")", ")", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ".", "build", "(", ")", ";", "return", ";", "}", "finally", "{", "deleteIsTransaction", "(", "message", ".", "getTxid", "(", ")", ")", ";", "}", "// Send COMPLETED message to chaincode support", "logger", ".", "debug", "(", "\"[\"", "+", "shortID", "(", "message", ")", "+", "\"]Query completed. Sending \"", "+", "QUERY_COMPLETED", ")", ";", "serialSendMessage", "=", "ChaincodeMessage", ".", "newBuilder", "(", ")", ".", "setType", "(", "QUERY_COMPLETED", ")", ".", "setPayload", "(", "response", ")", ".", "setTxid", "(", "message", ".", "getTxid", "(", ")", ")", ".", "build", "(", ")", ";", "}", "finally", "{", "serialSend", "(", "serialSendMessage", ")", ";", "}", "}", ";", "new", "Thread", "(", "task", ")", ".", "start", "(", ")", ";", "}" ]
handleQuery handles request to execute a query.
[ "handleQuery", "handles", "request", "to", "execute", "a", "query", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L354-L411
148,708
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.enterTransactionState
public void enterTransactionState(Event event) { ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]Received %s, invoking transaction on chaincode(src:%s, dst:%s)", shortID(message), message.getType().toString(), event.src, event.dst)); if (message.getType() == TRANSACTION) { // Call the chaincode's Run function to invoke transaction handleTransaction(message); } }
java
public void enterTransactionState(Event event) { ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]Received %s, invoking transaction on chaincode(src:%s, dst:%s)", shortID(message), message.getType().toString(), event.src, event.dst)); if (message.getType() == TRANSACTION) { // Call the chaincode's Run function to invoke transaction handleTransaction(message); } }
[ "public", "void", "enterTransactionState", "(", "Event", "event", ")", "{", "ChaincodeMessage", "message", "=", "messageHelper", "(", "event", ")", ";", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Received %s, invoking transaction on chaincode(src:%s, dst:%s)\"", ",", "shortID", "(", "message", ")", ",", "message", ".", "getType", "(", ")", ".", "toString", "(", ")", ",", "event", ".", "src", ",", "event", ".", "dst", ")", ")", ";", "if", "(", "message", ".", "getType", "(", ")", "==", "TRANSACTION", ")", "{", "// Call the chaincode's Run function to invoke transaction", "handleTransaction", "(", "message", ")", ";", "}", "}" ]
enterTransactionState will execute chaincode's Run if coming from a TRANSACTION event.
[ "enterTransactionState", "will", "execute", "chaincode", "s", "Run", "if", "coming", "from", "a", "TRANSACTION", "event", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L414-L422
148,709
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.afterCompleted
public void afterCompleted(Event event) { ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]sending COMPLETED to validator for tid", shortID(message))); try { serialSend(message); } catch (Exception e) { event.cancel(new Exception("send COMPLETED failed %s", e)); } }
java
public void afterCompleted(Event event) { ChaincodeMessage message = messageHelper(event); logger.debug(String.format("[%s]sending COMPLETED to validator for tid", shortID(message))); try { serialSend(message); } catch (Exception e) { event.cancel(new Exception("send COMPLETED failed %s", e)); } }
[ "public", "void", "afterCompleted", "(", "Event", "event", ")", "{", "ChaincodeMessage", "message", "=", "messageHelper", "(", "event", ")", ";", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]sending COMPLETED to validator for tid\"", ",", "shortID", "(", "message", ")", ")", ")", ";", "try", "{", "serialSend", "(", "message", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "event", ".", "cancel", "(", "new", "Exception", "(", "\"send COMPLETED failed %s\"", ",", "e", ")", ")", ";", "}", "}" ]
afterCompleted will need to handle COMPLETED event by sending message to the peer
[ "afterCompleted", "will", "need", "to", "handle", "COMPLETED", "event", "by", "sending", "message", "to", "the", "peer" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L425-L433
148,710
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java
Handler.afterResponse
public void afterResponse(Event event) { ChaincodeMessage message = messageHelper(event); try { sendChannel(message); logger.debug(String.format("[%s]Received %s, communicated (state:%s)", shortID(message), message.getType(), fsm.current())); } catch (Exception e) { logger.error(String.format("[%s]error sending %s (state:%s): %s", shortID(message), message.getType(), fsm.current(), e)); } }
java
public void afterResponse(Event event) { ChaincodeMessage message = messageHelper(event); try { sendChannel(message); logger.debug(String.format("[%s]Received %s, communicated (state:%s)", shortID(message), message.getType(), fsm.current())); } catch (Exception e) { logger.error(String.format("[%s]error sending %s (state:%s): %s", shortID(message), message.getType(), fsm.current(), e)); } }
[ "public", "void", "afterResponse", "(", "Event", "event", ")", "{", "ChaincodeMessage", "message", "=", "messageHelper", "(", "event", ")", ";", "try", "{", "sendChannel", "(", "message", ")", ";", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"[%s]Received %s, communicated (state:%s)\"", ",", "shortID", "(", "message", ")", ",", "message", ".", "getType", "(", ")", ",", "fsm", ".", "current", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "String", ".", "format", "(", "\"[%s]error sending %s (state:%s): %s\"", ",", "shortID", "(", "message", ")", ",", "message", ".", "getType", "(", ")", ",", "fsm", ".", "current", "(", ")", ",", "e", ")", ")", ";", "}", "}" ]
afterResponse is called to deliver a response or error to the chaincode stub.
[ "afterResponse", "is", "called", "to", "deliver", "a", "response", "or", "error", "to", "the", "chaincode", "stub", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/Handler.java#L442-L452
148,711
iipc/openwayback-access-control
access-control/src/main/java/org/archive/accesscontrol/robotstxt/CachingRobotClient.java
CachingRobotClient.prepare
public void prepare(Collection<String> urls, String userAgent) { List<String> safeUrls = new ArrayList<String>(urls); FetchThread threads[] = new FetchThread[PREPARE_THREAD_COUNT ]; for (int i = 0; i < PREPARE_THREAD_COUNT ; i++) { threads[i] = new FetchThread(safeUrls, userAgent); threads[i].start(); } for (int i = 0; i < PREPARE_THREAD_COUNT ; i++) { try { threads[i].join(); } catch (InterruptedException e) { } } }
java
public void prepare(Collection<String> urls, String userAgent) { List<String> safeUrls = new ArrayList<String>(urls); FetchThread threads[] = new FetchThread[PREPARE_THREAD_COUNT ]; for (int i = 0; i < PREPARE_THREAD_COUNT ; i++) { threads[i] = new FetchThread(safeUrls, userAgent); threads[i].start(); } for (int i = 0; i < PREPARE_THREAD_COUNT ; i++) { try { threads[i].join(); } catch (InterruptedException e) { } } }
[ "public", "void", "prepare", "(", "Collection", "<", "String", ">", "urls", ",", "String", "userAgent", ")", "{", "List", "<", "String", ">", "safeUrls", "=", "new", "ArrayList", "<", "String", ">", "(", "urls", ")", ";", "FetchThread", "threads", "[", "]", "=", "new", "FetchThread", "[", "PREPARE_THREAD_COUNT", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "PREPARE_THREAD_COUNT", ";", "i", "++", ")", "{", "threads", "[", "i", "]", "=", "new", "FetchThread", "(", "safeUrls", ",", "userAgent", ")", ";", "threads", "[", "i", "]", ".", "start", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "PREPARE_THREAD_COUNT", ";", "i", "++", ")", "{", "try", "{", "threads", "[", "i", "]", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}" ]
Prepare the cache to lookup info for a given set of urls. The fetches happen in parallel so this also makes a good option for speeding up bulk lookups.
[ "Prepare", "the", "cache", "to", "lookup", "info", "for", "a", "given", "set", "of", "urls", ".", "The", "fetches", "happen", "in", "parallel", "so", "this", "also", "makes", "a", "good", "option", "for", "speeding", "up", "bulk", "lookups", "." ]
4a0f70f200fd8d7b6e313624b7628656d834bf31
https://github.com/iipc/openwayback-access-control/blob/4a0f70f200fd8d7b6e313624b7628656d834bf31/access-control/src/main/java/org/archive/accesscontrol/robotstxt/CachingRobotClient.java#L97-L110
148,712
diirt/util
src/main/java/org/epics/util/stats/StatisticsUtil.java
StatisticsUtil.statisticsOf
public static Statistics statisticsOf(CollectionNumber data) { IteratorNumber iterator = data.iterator(); if (!iterator.hasNext()) { return null; } int count = 0; double min = iterator.nextDouble(); while (Double.isNaN(min)) { if (!iterator.hasNext()) { return null; } else { min = iterator.nextDouble(); } } double max = min; double total = min; double totalSquare = min*min; count++; while (iterator.hasNext()) { double value = iterator.nextDouble(); if (!Double.isNaN(value)) { if (value > max) max = value; if (value < min) min = value; total += value; totalSquare += value*value; count++; } } double average = total/count; double stdDev = Math.sqrt(totalSquare / count - average * average); return new StatisticsImpl(count, min, max, average, stdDev); }
java
public static Statistics statisticsOf(CollectionNumber data) { IteratorNumber iterator = data.iterator(); if (!iterator.hasNext()) { return null; } int count = 0; double min = iterator.nextDouble(); while (Double.isNaN(min)) { if (!iterator.hasNext()) { return null; } else { min = iterator.nextDouble(); } } double max = min; double total = min; double totalSquare = min*min; count++; while (iterator.hasNext()) { double value = iterator.nextDouble(); if (!Double.isNaN(value)) { if (value > max) max = value; if (value < min) min = value; total += value; totalSquare += value*value; count++; } } double average = total/count; double stdDev = Math.sqrt(totalSquare / count - average * average); return new StatisticsImpl(count, min, max, average, stdDev); }
[ "public", "static", "Statistics", "statisticsOf", "(", "CollectionNumber", "data", ")", "{", "IteratorNumber", "iterator", "=", "data", ".", "iterator", "(", ")", ";", "if", "(", "!", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "null", ";", "}", "int", "count", "=", "0", ";", "double", "min", "=", "iterator", ".", "nextDouble", "(", ")", ";", "while", "(", "Double", ".", "isNaN", "(", "min", ")", ")", "{", "if", "(", "!", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "min", "=", "iterator", ".", "nextDouble", "(", ")", ";", "}", "}", "double", "max", "=", "min", ";", "double", "total", "=", "min", ";", "double", "totalSquare", "=", "min", "*", "min", ";", "count", "++", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "double", "value", "=", "iterator", ".", "nextDouble", "(", ")", ";", "if", "(", "!", "Double", ".", "isNaN", "(", "value", ")", ")", "{", "if", "(", "value", ">", "max", ")", "max", "=", "value", ";", "if", "(", "value", "<", "min", ")", "min", "=", "value", ";", "total", "+=", "value", ";", "totalSquare", "+=", "value", "*", "value", ";", "count", "++", ";", "}", "}", "double", "average", "=", "total", "/", "count", ";", "double", "stdDev", "=", "Math", ".", "sqrt", "(", "totalSquare", "/", "count", "-", "average", "*", "average", ")", ";", "return", "new", "StatisticsImpl", "(", "count", ",", "min", ",", "max", ",", "average", ",", "stdDev", ")", ";", "}" ]
Calculates data statistics, excluding NaN values. @param data the data @return the calculated statistics
[ "Calculates", "data", "statistics", "excluding", "NaN", "values", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/StatisticsUtil.java#L68-L104
148,713
diirt/util
src/main/java/org/epics/util/stats/StatisticsUtil.java
StatisticsUtil.statisticsOf
public static Statistics statisticsOf(List<Statistics> data) { if (data.isEmpty()) return null; Iterator<Statistics> iterator = data.iterator(); if (!iterator.hasNext()) { return null; } Statistics first = null; while (first == null && iterator.hasNext()) { first = iterator.next(); } if (first == null) return null; int count = first.getCount(); double min = first.getMinimum().doubleValue(); double max = first.getMaximum().doubleValue(); double total = first.getAverage() * first.getCount(); double totalSquare = (first.getStdDev() * first.getStdDev() + first.getAverage() * first.getAverage()) * first.getCount(); while (iterator.hasNext()) { Statistics stats = iterator.next(); if (stats.getMaximum().doubleValue() > max) max = stats.getMaximum().doubleValue(); if (stats.getMinimum().doubleValue() < min) min = stats.getMinimum().doubleValue(); total += stats.getAverage() * stats.getCount(); totalSquare += ( stats.getStdDev() * stats.getStdDev() + stats.getAverage() * stats.getAverage() ) * stats.getCount(); count += stats.getCount(); } double average = total/count; double stdDev = Math.sqrt(totalSquare / count - average * average); return new StatisticsImpl(count, min, max, average, stdDev); }
java
public static Statistics statisticsOf(List<Statistics> data) { if (data.isEmpty()) return null; Iterator<Statistics> iterator = data.iterator(); if (!iterator.hasNext()) { return null; } Statistics first = null; while (first == null && iterator.hasNext()) { first = iterator.next(); } if (first == null) return null; int count = first.getCount(); double min = first.getMinimum().doubleValue(); double max = first.getMaximum().doubleValue(); double total = first.getAverage() * first.getCount(); double totalSquare = (first.getStdDev() * first.getStdDev() + first.getAverage() * first.getAverage()) * first.getCount(); while (iterator.hasNext()) { Statistics stats = iterator.next(); if (stats.getMaximum().doubleValue() > max) max = stats.getMaximum().doubleValue(); if (stats.getMinimum().doubleValue() < min) min = stats.getMinimum().doubleValue(); total += stats.getAverage() * stats.getCount(); totalSquare += ( stats.getStdDev() * stats.getStdDev() + stats.getAverage() * stats.getAverage() ) * stats.getCount(); count += stats.getCount(); } double average = total/count; double stdDev = Math.sqrt(totalSquare / count - average * average); return new StatisticsImpl(count, min, max, average, stdDev); }
[ "public", "static", "Statistics", "statisticsOf", "(", "List", "<", "Statistics", ">", "data", ")", "{", "if", "(", "data", ".", "isEmpty", "(", ")", ")", "return", "null", ";", "Iterator", "<", "Statistics", ">", "iterator", "=", "data", ".", "iterator", "(", ")", ";", "if", "(", "!", "iterator", ".", "hasNext", "(", ")", ")", "{", "return", "null", ";", "}", "Statistics", "first", "=", "null", ";", "while", "(", "first", "==", "null", "&&", "iterator", ".", "hasNext", "(", ")", ")", "{", "first", "=", "iterator", ".", "next", "(", ")", ";", "}", "if", "(", "first", "==", "null", ")", "return", "null", ";", "int", "count", "=", "first", ".", "getCount", "(", ")", ";", "double", "min", "=", "first", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ";", "double", "max", "=", "first", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ";", "double", "total", "=", "first", ".", "getAverage", "(", ")", "*", "first", ".", "getCount", "(", ")", ";", "double", "totalSquare", "=", "(", "first", ".", "getStdDev", "(", ")", "*", "first", ".", "getStdDev", "(", ")", "+", "first", ".", "getAverage", "(", ")", "*", "first", ".", "getAverage", "(", ")", ")", "*", "first", ".", "getCount", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "Statistics", "stats", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "stats", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ">", "max", ")", "max", "=", "stats", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ";", "if", "(", "stats", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", "<", "min", ")", "min", "=", "stats", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ";", "total", "+=", "stats", ".", "getAverage", "(", ")", "*", "stats", ".", "getCount", "(", ")", ";", "totalSquare", "+=", "(", "stats", ".", "getStdDev", "(", ")", "*", "stats", ".", "getStdDev", "(", ")", "+", "stats", ".", "getAverage", "(", ")", "*", "stats", ".", "getAverage", "(", ")", ")", "*", "stats", ".", "getCount", "(", ")", ";", "count", "+=", "stats", ".", "getCount", "(", ")", ";", "}", "double", "average", "=", "total", "/", "count", ";", "double", "stdDev", "=", "Math", ".", "sqrt", "(", "totalSquare", "/", "count", "-", "average", "*", "average", ")", ";", "return", "new", "StatisticsImpl", "(", "count", ",", "min", ",", "max", ",", "average", ",", "stdDev", ")", ";", "}" ]
Aggregates statistical information. @param data a list of statistical information @return the aggregate of all
[ "Aggregates", "statistical", "information", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/StatisticsUtil.java#L112-L148
148,714
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/shim/ChaincodeBase.java
ChaincodeBase.start
public void start(String[] args) { Options options = new Options(); options.addOption("a", "peerAddress", true, "Address of peer to connect to"); options.addOption("s", "securityEnabled", false, "Present if security is enabled"); options.addOption("i", "id", true, "Identity of chaincode"); options.addOption("o", "hostNameOverride", true, "Hostname override for server certificate"); try { CommandLine cl = new DefaultParser().parse(options, args); if (cl.hasOption('a')) { host = cl.getOptionValue('a'); port = new Integer(host.split(":")[1]); host = host.split(":")[0]; } if (cl.hasOption('s')) { tlsEnabled = true; logger.debug("TLS enabled"); if (cl.hasOption('o')){ hostOverrideAuthority = cl.getOptionValue('o'); logger.debug("server host override given " + hostOverrideAuthority); } } if (cl.hasOption('i')) { id = cl.getOptionValue('i'); } } catch (ParseException e) { logger.warn("cli parsing failed with exception",e); } Runnable chaincode = () -> { logger.trace("chaincode started"); ManagedChannel connection = newPeerClientConnection(); logger.trace("connection created"); chatWithPeer(connection); logger.trace("chatWithPeer DONE"); }; new Thread(chaincode).start(); }
java
public void start(String[] args) { Options options = new Options(); options.addOption("a", "peerAddress", true, "Address of peer to connect to"); options.addOption("s", "securityEnabled", false, "Present if security is enabled"); options.addOption("i", "id", true, "Identity of chaincode"); options.addOption("o", "hostNameOverride", true, "Hostname override for server certificate"); try { CommandLine cl = new DefaultParser().parse(options, args); if (cl.hasOption('a')) { host = cl.getOptionValue('a'); port = new Integer(host.split(":")[1]); host = host.split(":")[0]; } if (cl.hasOption('s')) { tlsEnabled = true; logger.debug("TLS enabled"); if (cl.hasOption('o')){ hostOverrideAuthority = cl.getOptionValue('o'); logger.debug("server host override given " + hostOverrideAuthority); } } if (cl.hasOption('i')) { id = cl.getOptionValue('i'); } } catch (ParseException e) { logger.warn("cli parsing failed with exception",e); } Runnable chaincode = () -> { logger.trace("chaincode started"); ManagedChannel connection = newPeerClientConnection(); logger.trace("connection created"); chatWithPeer(connection); logger.trace("chatWithPeer DONE"); }; new Thread(chaincode).start(); }
[ "public", "void", "start", "(", "String", "[", "]", "args", ")", "{", "Options", "options", "=", "new", "Options", "(", ")", ";", "options", ".", "addOption", "(", "\"a\"", ",", "\"peerAddress\"", ",", "true", ",", "\"Address of peer to connect to\"", ")", ";", "options", ".", "addOption", "(", "\"s\"", ",", "\"securityEnabled\"", ",", "false", ",", "\"Present if security is enabled\"", ")", ";", "options", ".", "addOption", "(", "\"i\"", ",", "\"id\"", ",", "true", ",", "\"Identity of chaincode\"", ")", ";", "options", ".", "addOption", "(", "\"o\"", ",", "\"hostNameOverride\"", ",", "true", ",", "\"Hostname override for server certificate\"", ")", ";", "try", "{", "CommandLine", "cl", "=", "new", "DefaultParser", "(", ")", ".", "parse", "(", "options", ",", "args", ")", ";", "if", "(", "cl", ".", "hasOption", "(", "'", "'", ")", ")", "{", "host", "=", "cl", ".", "getOptionValue", "(", "'", "'", ")", ";", "port", "=", "new", "Integer", "(", "host", ".", "split", "(", "\":\"", ")", "[", "1", "]", ")", ";", "host", "=", "host", ".", "split", "(", "\":\"", ")", "[", "0", "]", ";", "}", "if", "(", "cl", ".", "hasOption", "(", "'", "'", ")", ")", "{", "tlsEnabled", "=", "true", ";", "logger", ".", "debug", "(", "\"TLS enabled\"", ")", ";", "if", "(", "cl", ".", "hasOption", "(", "'", "'", ")", ")", "{", "hostOverrideAuthority", "=", "cl", ".", "getOptionValue", "(", "'", "'", ")", ";", "logger", ".", "debug", "(", "\"server host override given \"", "+", "hostOverrideAuthority", ")", ";", "}", "}", "if", "(", "cl", ".", "hasOption", "(", "'", "'", ")", ")", "{", "id", "=", "cl", ".", "getOptionValue", "(", "'", "'", ")", ";", "}", "}", "catch", "(", "ParseException", "e", ")", "{", "logger", ".", "warn", "(", "\"cli parsing failed with exception\"", ",", "e", ")", ";", "}", "Runnable", "chaincode", "=", "(", ")", "->", "{", "logger", ".", "trace", "(", "\"chaincode started\"", ")", ";", "ManagedChannel", "connection", "=", "newPeerClientConnection", "(", ")", ";", "logger", ".", "trace", "(", "\"connection created\"", ")", ";", "chatWithPeer", "(", "connection", ")", ";", "logger", ".", "trace", "(", "\"chatWithPeer DONE\"", ")", ";", "}", ";", "new", "Thread", "(", "chaincode", ")", ".", "start", "(", ")", ";", "}" ]
Start entry point for chaincodes bootstrap.
[ "Start", "entry", "point", "for", "chaincodes", "bootstrap", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/shim/ChaincodeBase.java#L62-L99
148,715
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.range
public static Range range(final double minValue, final double maxValue) { if (minValue > maxValue) { throw new IllegalArgumentException("minValue should be less then or equal to maxValue (" + minValue+ ", " + maxValue + ")"); } return new Range() { @Override public Number getMinimum() { return minValue; } @Override public Number getMaximum() { return maxValue; } @Override public String toString() { return Ranges.toString(this); } }; }
java
public static Range range(final double minValue, final double maxValue) { if (minValue > maxValue) { throw new IllegalArgumentException("minValue should be less then or equal to maxValue (" + minValue+ ", " + maxValue + ")"); } return new Range() { @Override public Number getMinimum() { return minValue; } @Override public Number getMaximum() { return maxValue; } @Override public String toString() { return Ranges.toString(this); } }; }
[ "public", "static", "Range", "range", "(", "final", "double", "minValue", ",", "final", "double", "maxValue", ")", "{", "if", "(", "minValue", ">", "maxValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"minValue should be less then or equal to maxValue (\"", "+", "minValue", "+", "\", \"", "+", "maxValue", "+", "\")\"", ")", ";", "}", "return", "new", "Range", "(", ")", "{", "@", "Override", "public", "Number", "getMinimum", "(", ")", "{", "return", "minValue", ";", "}", "@", "Override", "public", "Number", "getMaximum", "(", ")", "{", "return", "maxValue", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "Ranges", ".", "toString", "(", "this", ")", ";", "}", "}", ";", "}" ]
Range from given min and max. @param minValue minimum value @param maxValue maximum value @return the range
[ "Range", "from", "given", "min", "and", "max", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L39-L61
148,716
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.contains
public static boolean contains(Range range, Range subrange) { return range.getMinimum().doubleValue() <= subrange.getMinimum().doubleValue() && range.getMaximum().doubleValue() >= subrange.getMaximum().doubleValue(); }
java
public static boolean contains(Range range, Range subrange) { return range.getMinimum().doubleValue() <= subrange.getMinimum().doubleValue() && range.getMaximum().doubleValue() >= subrange.getMaximum().doubleValue(); }
[ "public", "static", "boolean", "contains", "(", "Range", "range", ",", "Range", "subrange", ")", "{", "return", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", "<=", "subrange", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", "&&", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ">=", "subrange", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ";", "}" ]
Determines whether the subrange is contained in the range or not. @param range a range @param subrange a possible subrange @return true if subrange is contained in range
[ "Determines", "whether", "the", "subrange", "is", "contained", "in", "the", "range", "or", "not", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L70-L74
148,717
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.sum
public static Range sum(Range range1, Range range2) { if (range1.getMinimum().doubleValue() <= range2.getMinimum().doubleValue()) { if (range1.getMaximum().doubleValue() >= range2.getMaximum().doubleValue()) { return range1; } else { return range(range1.getMinimum().doubleValue(), range2.getMaximum().doubleValue()); } } else { if (range1.getMaximum().doubleValue() >= range2.getMaximum().doubleValue()) { return range(range2.getMinimum().doubleValue(), range1.getMaximum().doubleValue()); } else { return range2; } } }
java
public static Range sum(Range range1, Range range2) { if (range1.getMinimum().doubleValue() <= range2.getMinimum().doubleValue()) { if (range1.getMaximum().doubleValue() >= range2.getMaximum().doubleValue()) { return range1; } else { return range(range1.getMinimum().doubleValue(), range2.getMaximum().doubleValue()); } } else { if (range1.getMaximum().doubleValue() >= range2.getMaximum().doubleValue()) { return range(range2.getMinimum().doubleValue(), range1.getMaximum().doubleValue()); } else { return range2; } } }
[ "public", "static", "Range", "sum", "(", "Range", "range1", ",", "Range", "range2", ")", "{", "if", "(", "range1", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", "<=", "range2", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ")", "{", "if", "(", "range1", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ">=", "range2", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", "{", "return", "range1", ";", "}", "else", "{", "return", "range", "(", "range1", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ",", "range2", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "range1", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ">=", "range2", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", "{", "return", "range", "(", "range2", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ",", "range1", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "{", "return", "range2", ";", "}", "}", "}" ]
Determines the range that can contain both ranges. If one of the ranges in contained in the other, the bigger range is returned. @param range1 a range @param range2 another range @return the bigger range
[ "Determines", "the", "range", "that", "can", "contain", "both", "ranges", ".", "If", "one", "of", "the", "ranges", "in", "contained", "in", "the", "other", "the", "bigger", "range", "is", "returned", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L84-L99
148,718
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.normalize
public static double normalize(Range range, double value) { return normalize(value, range.getMinimum().doubleValue(), range.getMaximum().doubleValue()); }
java
public static double normalize(Range range, double value) { return normalize(value, range.getMinimum().doubleValue(), range.getMaximum().doubleValue()); }
[ "public", "static", "double", "normalize", "(", "Range", "range", ",", "double", "value", ")", "{", "return", "normalize", "(", "value", ",", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ",", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "}" ]
Returns the value normalized within the range. It performs a linear transformation where the minimum value of the range becomes 0 while the maximum becomes 1. @param range a range @param value a value @return the value transformed based on the range
[ "Returns", "the", "value", "normalized", "within", "the", "range", ".", "It", "performs", "a", "linear", "transformation", "where", "the", "minimum", "value", "of", "the", "range", "becomes", "0", "while", "the", "maximum", "becomes", "1", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L120-L122
148,719
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.contains
public static boolean contains(Range range, double value) { return value >= range.getMinimum().doubleValue() && value <= range.getMaximum().doubleValue(); }
java
public static boolean contains(Range range, double value) { return value >= range.getMinimum().doubleValue() && value <= range.getMaximum().doubleValue(); }
[ "public", "static", "boolean", "contains", "(", "Range", "range", ",", "double", "value", ")", "{", "return", "value", ">=", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", "&&", "value", "<=", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ";", "}" ]
Determines whether the value is contained by the range or not. @param range a range @param value a value @return true if the value is within the range
[ "Determines", "whether", "the", "value", "is", "contained", "by", "the", "range", "or", "not", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L135-L137
148,720
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.overlap
public static double overlap(Range range, Range otherRange) { double minOverlap = Math.max(range.getMinimum().doubleValue(), otherRange.getMinimum().doubleValue()); double maxOverlap = Math.min(range.getMaximum().doubleValue(), otherRange.getMaximum().doubleValue()); double overlapWidth = maxOverlap - minOverlap; double rangeWidth = range.getMaximum().doubleValue() - range.getMinimum().doubleValue(); double fraction = Math.max(0.0, overlapWidth / rangeWidth); return fraction; }
java
public static double overlap(Range range, Range otherRange) { double minOverlap = Math.max(range.getMinimum().doubleValue(), otherRange.getMinimum().doubleValue()); double maxOverlap = Math.min(range.getMaximum().doubleValue(), otherRange.getMaximum().doubleValue()); double overlapWidth = maxOverlap - minOverlap; double rangeWidth = range.getMaximum().doubleValue() - range.getMinimum().doubleValue(); double fraction = Math.max(0.0, overlapWidth / rangeWidth); return fraction; }
[ "public", "static", "double", "overlap", "(", "Range", "range", ",", "Range", "otherRange", ")", "{", "double", "minOverlap", "=", "Math", ".", "max", "(", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ",", "otherRange", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "double", "maxOverlap", "=", "Math", ".", "min", "(", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ",", "otherRange", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "double", "overlapWidth", "=", "maxOverlap", "-", "minOverlap", ";", "double", "rangeWidth", "=", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", "-", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ";", "double", "fraction", "=", "Math", ".", "max", "(", "0.0", ",", "overlapWidth", "/", "rangeWidth", ")", ";", "return", "fraction", ";", "}" ]
Percentage, from 0 to 1, of the first range that is contained by the second range. @param range the range to be contained by the second @param otherRange the range that has to contain the first @return from 0 (if there is no intersection) to 1 (if the ranges are the same)
[ "Percentage", "from", "0", "to", "1", "of", "the", "first", "range", "that", "is", "contained", "by", "the", "second", "range", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L166-L173
148,721
diirt/util
src/main/java/org/epics/util/stats/Ranges.java
Ranges.isValid
public static boolean isValid(Range range) { if (range == null) { return false; } double min = range.getMinimum().doubleValue(); double max = range.getMaximum().doubleValue(); return min != max && !Double.isNaN(min) && !Double.isInfinite(min) && !Double.isNaN(max) && !Double.isInfinite(max); }
java
public static boolean isValid(Range range) { if (range == null) { return false; } double min = range.getMinimum().doubleValue(); double max = range.getMaximum().doubleValue(); return min != max && !Double.isNaN(min) && !Double.isInfinite(min) && !Double.isNaN(max) && !Double.isInfinite(max); }
[ "public", "static", "boolean", "isValid", "(", "Range", "range", ")", "{", "if", "(", "range", "==", "null", ")", "{", "return", "false", ";", "}", "double", "min", "=", "range", ".", "getMinimum", "(", ")", ".", "doubleValue", "(", ")", ";", "double", "max", "=", "range", ".", "getMaximum", "(", ")", ".", "doubleValue", "(", ")", ";", "return", "min", "!=", "max", "&&", "!", "Double", ".", "isNaN", "(", "min", ")", "&&", "!", "Double", ".", "isInfinite", "(", "min", ")", "&&", "!", "Double", ".", "isNaN", "(", "max", ")", "&&", "!", "Double", ".", "isInfinite", "(", "max", ")", ";", "}" ]
Checks whether the range is of non-zero size and the boundaries are neither NaN or Infinity. @param range the range @return true if range is of finite, non-zero size
[ "Checks", "whether", "the", "range", "is", "of", "non", "-", "zero", "size", "and", "the", "boundaries", "are", "neither", "NaN", "or", "Infinity", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/stats/Ranges.java#L182-L192
148,722
eurekaclinical/cas
src/main/java/edu/emory/cci/aiw/cvrg/eureka/cas/AbstractProperties.java
AbstractProperties.loadDefaultConfig
private void loadDefaultConfig() { this.configDir = System.getProperty(CONFIG_DIR_SYS_PROP); if (this.configDir == null) { this.configDir = getDefaultConfigDir(); } if (this.configDir == null) { throw new AssertionError("eureka.config.dir not specified in " + FALLBACK_CONFIG_FILE); } File configFile = new File(this.configDir, PROPERTIES_FILENAME); if (configFile.exists()) { LOGGER.info("Trying to load default configuration from {}", configFile.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(configFile); this.properties.load(inputStream); inputStream.close(); inputStream = null; } catch (IOException ex) { LOGGER.error("Error reading application.properties file {}: {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want.", configFile.getAbsolutePath(), ex.getMessage()); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ignore) { } } } } else { LOGGER.warn("No configuration file found at {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want.", configFile.getAbsolutePath()); } }
java
private void loadDefaultConfig() { this.configDir = System.getProperty(CONFIG_DIR_SYS_PROP); if (this.configDir == null) { this.configDir = getDefaultConfigDir(); } if (this.configDir == null) { throw new AssertionError("eureka.config.dir not specified in " + FALLBACK_CONFIG_FILE); } File configFile = new File(this.configDir, PROPERTIES_FILENAME); if (configFile.exists()) { LOGGER.info("Trying to load default configuration from {}", configFile.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(configFile); this.properties.load(inputStream); inputStream.close(); inputStream = null; } catch (IOException ex) { LOGGER.error("Error reading application.properties file {}: {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want.", configFile.getAbsolutePath(), ex.getMessage()); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ignore) { } } } } else { LOGGER.warn("No configuration file found at {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want.", configFile.getAbsolutePath()); } }
[ "private", "void", "loadDefaultConfig", "(", ")", "{", "this", ".", "configDir", "=", "System", ".", "getProperty", "(", "CONFIG_DIR_SYS_PROP", ")", ";", "if", "(", "this", ".", "configDir", "==", "null", ")", "{", "this", ".", "configDir", "=", "getDefaultConfigDir", "(", ")", ";", "}", "if", "(", "this", ".", "configDir", "==", "null", ")", "{", "throw", "new", "AssertionError", "(", "\"eureka.config.dir not specified in \"", "+", "FALLBACK_CONFIG_FILE", ")", ";", "}", "File", "configFile", "=", "new", "File", "(", "this", ".", "configDir", ",", "PROPERTIES_FILENAME", ")", ";", "if", "(", "configFile", ".", "exists", "(", ")", ")", "{", "LOGGER", ".", "info", "(", "\"Trying to load default configuration from {}\"", ",", "configFile", ".", "getAbsolutePath", "(", ")", ")", ";", "InputStream", "inputStream", "=", "null", ";", "try", "{", "inputStream", "=", "new", "FileInputStream", "(", "configFile", ")", ";", "this", ".", "properties", ".", "load", "(", "inputStream", ")", ";", "inputStream", ".", "close", "(", ")", ";", "inputStream", "=", "null", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOGGER", ".", "error", "(", "\"Error reading application.properties file {}: {}. \"", "+", "\"Built-in defaults will be used, some \"", "+", "\"of which are unlikely to be what you want.\"", ",", "configFile", ".", "getAbsolutePath", "(", ")", ",", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "finally", "{", "if", "(", "inputStream", "!=", "null", ")", "{", "try", "{", "inputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignore", ")", "{", "}", "}", "}", "}", "else", "{", "LOGGER", ".", "warn", "(", "\"No configuration file found at {}. \"", "+", "\"Built-in defaults will be used, some \"", "+", "\"of which are unlikely to be what you want.\"", ",", "configFile", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}" ]
Loads the application configuration. There are two potential sources of application configuration. The fallback configuration should always be there. The default configuration directory, <code>/etc/ec-cas-server</code>, may optionally have an application.properties file within it that overrides the fallback configuration for each configuration property that is specified. The <code>eureka.config.dir</code> system property allows specifying an alternative configuration directory.
[ "Loads", "the", "application", "configuration", "." ]
c3138c42285773523df8b4428d623ce6785ac6a8
https://github.com/eurekaclinical/cas/blob/c3138c42285773523df8b4428d623ce6785ac6a8/src/main/java/edu/emory/cci/aiw/cvrg/eureka/cas/AbstractProperties.java#L86-L123
148,723
versionone/VersionOne.SDK.Java.ObjectModel
src/main/java/com/versionone/om/Retrospective.java
Retrospective.getIdentifiedStories
public Collection<Story> getIdentifiedStories(StoryFilter filter) { filter = (filter != null) ? filter : new StoryFilter(); filter.identifiedIn.clear(); filter.identifiedIn.add(this); return getInstance().get().story(filter); }
java
public Collection<Story> getIdentifiedStories(StoryFilter filter) { filter = (filter != null) ? filter : new StoryFilter(); filter.identifiedIn.clear(); filter.identifiedIn.add(this); return getInstance().get().story(filter); }
[ "public", "Collection", "<", "Story", ">", "getIdentifiedStories", "(", "StoryFilter", "filter", ")", "{", "filter", "=", "(", "filter", "!=", "null", ")", "?", "filter", ":", "new", "StoryFilter", "(", ")", ";", "filter", ".", "identifiedIn", ".", "clear", "(", ")", ";", "filter", ".", "identifiedIn", ".", "add", "(", "this", ")", ";", "return", "getInstance", "(", ")", ".", "get", "(", ")", ".", "story", "(", "filter", ")", ";", "}" ]
A read-only collection of Stories Identified in the Retrospective. @param filter filter for getting list of stories. @return collection of Stories Identified in the Retrospective.
[ "A", "read", "-", "only", "collection", "of", "Stories", "Identified", "in", "the", "Retrospective", "." ]
59d35b67c849299631bca45ee94143237eb2ae1a
https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Retrospective.java#L56-L62
148,724
sinetja/sinetja
src/main/java/sinetja/Response.java
Response.respondEventSource
public ChannelFuture respondEventSource(Object data, String event) throws Exception { if (!nonChunkedResponseOrFirstChunkSent) { HttpUtil.setTransferEncodingChunked(response, true); response.headers().set(CONTENT_TYPE, "text/event-stream; charset=UTF-8"); return respondText("\r\n"); // Send a new line prelude, due to a bug in Opera } return respondText(renderEventSource(data, event)); }
java
public ChannelFuture respondEventSource(Object data, String event) throws Exception { if (!nonChunkedResponseOrFirstChunkSent) { HttpUtil.setTransferEncodingChunked(response, true); response.headers().set(CONTENT_TYPE, "text/event-stream; charset=UTF-8"); return respondText("\r\n"); // Send a new line prelude, due to a bug in Opera } return respondText(renderEventSource(data, event)); }
[ "public", "ChannelFuture", "respondEventSource", "(", "Object", "data", ",", "String", "event", ")", "throws", "Exception", "{", "if", "(", "!", "nonChunkedResponseOrFirstChunkSent", ")", "{", "HttpUtil", ".", "setTransferEncodingChunked", "(", "response", ",", "true", ")", ";", "response", ".", "headers", "(", ")", ".", "set", "(", "CONTENT_TYPE", ",", "\"text/event-stream; charset=UTF-8\"", ")", ";", "return", "respondText", "(", "\"\\r\\n\"", ")", ";", "// Send a new line prelude, due to a bug in Opera", "}", "return", "respondText", "(", "renderEventSource", "(", "data", ",", "event", ")", ")", ";", "}" ]
To respond event source, call this method as many time as you want. <p>Event Source response is a special kind of chunked response, data must be UTF-8. See: - http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-94 - http://dev.w3.org/html5/eventsource/ <p>No need to call setChunked() before calling this method.
[ "To", "respond", "event", "source", "call", "this", "method", "as", "many", "time", "as", "you", "want", "." ]
eec94dba55ec28263e3503fcdb33532282134775
https://github.com/sinetja/sinetja/blob/eec94dba55ec28263e3503fcdb33532282134775/src/main/java/sinetja/Response.java#L336-L343
148,725
socialsensor/socialsensor-framework-common
src/main/java/eu/socialsensor/framework/common/repositories/InfluentialContributorSet.java
InfluentialContributorSet.isTwitterJsonStringRelatedTo
public boolean isTwitterJsonStringRelatedTo(String tweet, boolean sender,boolean userMentions, boolean retweetOrigin) { StatusRepresentation s = new StatusRepresentation(); s.init(null, tweet); boolean matches = s.isRelatedTo(this, true, true, true); return matches; }
java
public boolean isTwitterJsonStringRelatedTo(String tweet, boolean sender,boolean userMentions, boolean retweetOrigin) { StatusRepresentation s = new StatusRepresentation(); s.init(null, tweet); boolean matches = s.isRelatedTo(this, true, true, true); return matches; }
[ "public", "boolean", "isTwitterJsonStringRelatedTo", "(", "String", "tweet", ",", "boolean", "sender", ",", "boolean", "userMentions", ",", "boolean", "retweetOrigin", ")", "{", "StatusRepresentation", "s", "=", "new", "StatusRepresentation", "(", ")", ";", "s", ".", "init", "(", "null", ",", "tweet", ")", ";", "boolean", "matches", "=", "s", ".", "isRelatedTo", "(", "this", ",", "true", ",", "true", ",", "true", ")", ";", "return", "matches", ";", "}" ]
Determines whether the Twitter status is related to one of the users in the set of influential contributors. @param sender if the person who created the status is in the ids set, return true @param userMentions if the status contains a user mention that is contained in the ids set, return true @param retweetOrigin if the status is a retweet that was originated by a user in the ids set, return true @returns true if one of the ids in the input parameter matches an id found in the tweet
[ "Determines", "whether", "the", "Twitter", "status", "is", "related", "to", "one", "of", "the", "users", "in", "the", "set", "of", "influential", "contributors", "." ]
b69e7c47f3e0a9062c373aaec7cb2ba1e19c6ce0
https://github.com/socialsensor/socialsensor-framework-common/blob/b69e7c47f3e0a9062c373aaec7cb2ba1e19c6ce0/src/main/java/eu/socialsensor/framework/common/repositories/InfluentialContributorSet.java#L89-L94
148,726
groundupworks/wings
wings/src/main/java/com/groundupworks/wings/core/WingsDbHelper.java
WingsDbHelper.purge
public synchronized int purge() { int recordsRemaining = -1; SQLiteDatabase db = null; Cursor cursor = null; try { db = getWritableDatabase(); // Purge records. long earliestValidTime = System.currentTimeMillis() - RECORD_EXPIRY_TIME; int recordsDeleted = db.delete(ShareRequestTable.NAME, WHERE_CLAUSE_PURGE_POLICY, new String[]{String.valueOf(earliestValidTime), String.valueOf(ShareRequest.STATE_PROCESSED), String.valueOf(RECORD_MAX_FAILS)} ); // Check number of records remaining in the table. cursor = db.query(ShareRequestTable.NAME, new String[]{ShareRequestTable.COLUMN_ID}, null, null, null, null, null); if (cursor != null) { recordsRemaining = cursor.getCount(); } sLogger.log(WingsDbHelper.class, "purge", "recordsDeleted=" + recordsDeleted + " recordsRemaining=" + recordsRemaining); } catch (SQLException e) { // Do nothing. } finally { if (cursor != null) { cursor.close(); } db.close(); } return recordsRemaining; }
java
public synchronized int purge() { int recordsRemaining = -1; SQLiteDatabase db = null; Cursor cursor = null; try { db = getWritableDatabase(); // Purge records. long earliestValidTime = System.currentTimeMillis() - RECORD_EXPIRY_TIME; int recordsDeleted = db.delete(ShareRequestTable.NAME, WHERE_CLAUSE_PURGE_POLICY, new String[]{String.valueOf(earliestValidTime), String.valueOf(ShareRequest.STATE_PROCESSED), String.valueOf(RECORD_MAX_FAILS)} ); // Check number of records remaining in the table. cursor = db.query(ShareRequestTable.NAME, new String[]{ShareRequestTable.COLUMN_ID}, null, null, null, null, null); if (cursor != null) { recordsRemaining = cursor.getCount(); } sLogger.log(WingsDbHelper.class, "purge", "recordsDeleted=" + recordsDeleted + " recordsRemaining=" + recordsRemaining); } catch (SQLException e) { // Do nothing. } finally { if (cursor != null) { cursor.close(); } db.close(); } return recordsRemaining; }
[ "public", "synchronized", "int", "purge", "(", ")", "{", "int", "recordsRemaining", "=", "-", "1", ";", "SQLiteDatabase", "db", "=", "null", ";", "Cursor", "cursor", "=", "null", ";", "try", "{", "db", "=", "getWritableDatabase", "(", ")", ";", "// Purge records.", "long", "earliestValidTime", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "RECORD_EXPIRY_TIME", ";", "int", "recordsDeleted", "=", "db", ".", "delete", "(", "ShareRequestTable", ".", "NAME", ",", "WHERE_CLAUSE_PURGE_POLICY", ",", "new", "String", "[", "]", "{", "String", ".", "valueOf", "(", "earliestValidTime", ")", ",", "String", ".", "valueOf", "(", "ShareRequest", ".", "STATE_PROCESSED", ")", ",", "String", ".", "valueOf", "(", "RECORD_MAX_FAILS", ")", "}", ")", ";", "// Check number of records remaining in the table.", "cursor", "=", "db", ".", "query", "(", "ShareRequestTable", ".", "NAME", ",", "new", "String", "[", "]", "{", "ShareRequestTable", ".", "COLUMN_ID", "}", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "if", "(", "cursor", "!=", "null", ")", "{", "recordsRemaining", "=", "cursor", ".", "getCount", "(", ")", ";", "}", "sLogger", ".", "log", "(", "WingsDbHelper", ".", "class", ",", "\"purge\"", ",", "\"recordsDeleted=\"", "+", "recordsDeleted", "+", "\" recordsRemaining=\"", "+", "recordsRemaining", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "// Do nothing.", "}", "finally", "{", "if", "(", "cursor", "!=", "null", ")", "{", "cursor", ".", "close", "(", ")", ";", "}", "db", ".", "close", "(", ")", ";", "}", "return", "recordsRemaining", ";", "}" ]
Purges the database based on the purge policy. @return the number of records remaining after the purge; or -1 if an error occurred.
[ "Purges", "the", "database", "based", "on", "the", "purge", "policy", "." ]
03d2827c30ef55f2db4e23f7500e016c7771fa39
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/core/WingsDbHelper.java#L343-L376
148,727
groundupworks/wings
wings/src/main/java/com/groundupworks/wings/core/WingsDbHelper.java
WingsDbHelper.resetProcessingShareRequests
public synchronized void resetProcessingShareRequests() { SQLiteDatabase db = null; try { db = getWritableDatabase(); // Update state back to pending. ContentValues values = new ContentValues(); values.put(ShareRequestTable.COLUMN_STATE, ShareRequest.STATE_PENDING); int recordsUpdated = db.update(ShareRequestTable.NAME, values, WHERE_CLAUSE_BY_STATE, new String[]{String.valueOf(ShareRequest.STATE_PROCESSING)}); sLogger.log(WingsDbHelper.class, "resetProcessingShareRequests", "recordsUpdated=" + recordsUpdated); } catch (SQLException e) { // Do nothing. } finally { db.close(); } }
java
public synchronized void resetProcessingShareRequests() { SQLiteDatabase db = null; try { db = getWritableDatabase(); // Update state back to pending. ContentValues values = new ContentValues(); values.put(ShareRequestTable.COLUMN_STATE, ShareRequest.STATE_PENDING); int recordsUpdated = db.update(ShareRequestTable.NAME, values, WHERE_CLAUSE_BY_STATE, new String[]{String.valueOf(ShareRequest.STATE_PROCESSING)}); sLogger.log(WingsDbHelper.class, "resetProcessingShareRequests", "recordsUpdated=" + recordsUpdated); } catch (SQLException e) { // Do nothing. } finally { db.close(); } }
[ "public", "synchronized", "void", "resetProcessingShareRequests", "(", ")", "{", "SQLiteDatabase", "db", "=", "null", ";", "try", "{", "db", "=", "getWritableDatabase", "(", ")", ";", "// Update state back to pending.", "ContentValues", "values", "=", "new", "ContentValues", "(", ")", ";", "values", ".", "put", "(", "ShareRequestTable", ".", "COLUMN_STATE", ",", "ShareRequest", ".", "STATE_PENDING", ")", ";", "int", "recordsUpdated", "=", "db", ".", "update", "(", "ShareRequestTable", ".", "NAME", ",", "values", ",", "WHERE_CLAUSE_BY_STATE", ",", "new", "String", "[", "]", "{", "String", ".", "valueOf", "(", "ShareRequest", ".", "STATE_PROCESSING", ")", "}", ")", ";", "sLogger", ".", "log", "(", "WingsDbHelper", ".", "class", ",", "\"resetProcessingShareRequests\"", ",", "\"recordsUpdated=\"", "+", "recordsUpdated", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "// Do nothing.", "}", "finally", "{", "db", ".", "close", "(", ")", ";", "}", "}" ]
Reset all records that somehow got stuck in a processing state.
[ "Reset", "all", "records", "that", "somehow", "got", "stuck", "in", "a", "processing", "state", "." ]
03d2827c30ef55f2db4e23f7500e016c7771fa39
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/core/WingsDbHelper.java#L381-L399
148,728
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java
TransactionContext.deploy
public ChainCodeResponse deploy(DeployRequest deployRequest) throws ChainCodeException, NoAvailableTCertException, CryptoException, IOException { logger.debug(String.format("Received deploy request: %s", deployRequest)); if (null == getMyTCert() && getChain().isSecurityEnabled()) { logger.debug("Failed getting a new TCert"); throw new NoAvailableTCertException("Failed getting a new TCert"); } logger.debug("Got a TCert successfully, continue..."); Transaction transaction = DeployTransactionBuilder.newBuilder().context(this).request(deployRequest).build(); Fabric.Response response = execute(transaction); if (response.getStatus() == StatusCode.FAILURE) { throw new ChainCodeException(response.getMsg().toStringUtf8(), null); } return new ChainCodeResponse( transaction.getTxBuilder().getTxid(), transaction.getChaincodeID(), Status.UNDEFINED, response.getMsg().toStringUtf8()); }
java
public ChainCodeResponse deploy(DeployRequest deployRequest) throws ChainCodeException, NoAvailableTCertException, CryptoException, IOException { logger.debug(String.format("Received deploy request: %s", deployRequest)); if (null == getMyTCert() && getChain().isSecurityEnabled()) { logger.debug("Failed getting a new TCert"); throw new NoAvailableTCertException("Failed getting a new TCert"); } logger.debug("Got a TCert successfully, continue..."); Transaction transaction = DeployTransactionBuilder.newBuilder().context(this).request(deployRequest).build(); Fabric.Response response = execute(transaction); if (response.getStatus() == StatusCode.FAILURE) { throw new ChainCodeException(response.getMsg().toStringUtf8(), null); } return new ChainCodeResponse( transaction.getTxBuilder().getTxid(), transaction.getChaincodeID(), Status.UNDEFINED, response.getMsg().toStringUtf8()); }
[ "public", "ChainCodeResponse", "deploy", "(", "DeployRequest", "deployRequest", ")", "throws", "ChainCodeException", ",", "NoAvailableTCertException", ",", "CryptoException", ",", "IOException", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"Received deploy request: %s\"", ",", "deployRequest", ")", ")", ";", "if", "(", "null", "==", "getMyTCert", "(", ")", "&&", "getChain", "(", ")", ".", "isSecurityEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Failed getting a new TCert\"", ")", ";", "throw", "new", "NoAvailableTCertException", "(", "\"Failed getting a new TCert\"", ")", ";", "}", "logger", ".", "debug", "(", "\"Got a TCert successfully, continue...\"", ")", ";", "Transaction", "transaction", "=", "DeployTransactionBuilder", ".", "newBuilder", "(", ")", ".", "context", "(", "this", ")", ".", "request", "(", "deployRequest", ")", ".", "build", "(", ")", ";", "Fabric", ".", "Response", "response", "=", "execute", "(", "transaction", ")", ";", "if", "(", "response", ".", "getStatus", "(", ")", "==", "StatusCode", ".", "FAILURE", ")", "{", "throw", "new", "ChainCodeException", "(", "response", ".", "getMsg", "(", ")", ".", "toStringUtf8", "(", ")", ",", "null", ")", ";", "}", "return", "new", "ChainCodeResponse", "(", "transaction", ".", "getTxBuilder", "(", ")", ".", "getTxid", "(", ")", ",", "transaction", ".", "getChaincodeID", "(", ")", ",", "Status", ".", "UNDEFINED", ",", "response", ".", "getMsg", "(", ")", ".", "toStringUtf8", "(", ")", ")", ";", "}" ]
Issue a deploy transaction @param deployRequest {@link DeployRequest} A deploy request @return {@link ChainCodeResponse} response of deploy transaction
[ "Issue", "a", "deploy", "transaction" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java#L138-L159
148,729
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java
TransactionContext.invoke
public ChainCodeResponse invoke(InvokeRequest invokeRequest) throws ChainCodeException, NoAvailableTCertException, CryptoException, IOException { logger.debug(String.format("Received invoke request: %s", invokeRequest)); // Get a TCert to use in the invoke transaction setAttrs(invokeRequest.getAttributes()); if (null == getMyTCert() && getChain().isSecurityEnabled()) { logger.debug("Failed getting a new TCert"); throw new NoAvailableTCertException("Failed getting a new TCert"); } logger.debug("Got a TCert successfully, continue..."); Transaction transaction = InvocationTransactionBuilder.newBuilder().context(this).request(invokeRequest).build(); Fabric.Response response = execute(transaction); if (response.getStatus() == StatusCode.FAILURE) { throw new ChainCodeException(response.getMsg().toStringUtf8(), null); } return new ChainCodeResponse( transaction.getTxBuilder().getTxid(), transaction.getChaincodeID(), Status.SUCCESS, response.getMsg().toStringUtf8()); }
java
public ChainCodeResponse invoke(InvokeRequest invokeRequest) throws ChainCodeException, NoAvailableTCertException, CryptoException, IOException { logger.debug(String.format("Received invoke request: %s", invokeRequest)); // Get a TCert to use in the invoke transaction setAttrs(invokeRequest.getAttributes()); if (null == getMyTCert() && getChain().isSecurityEnabled()) { logger.debug("Failed getting a new TCert"); throw new NoAvailableTCertException("Failed getting a new TCert"); } logger.debug("Got a TCert successfully, continue..."); Transaction transaction = InvocationTransactionBuilder.newBuilder().context(this).request(invokeRequest).build(); Fabric.Response response = execute(transaction); if (response.getStatus() == StatusCode.FAILURE) { throw new ChainCodeException(response.getMsg().toStringUtf8(), null); } return new ChainCodeResponse( transaction.getTxBuilder().getTxid(), transaction.getChaincodeID(), Status.SUCCESS, response.getMsg().toStringUtf8()); }
[ "public", "ChainCodeResponse", "invoke", "(", "InvokeRequest", "invokeRequest", ")", "throws", "ChainCodeException", ",", "NoAvailableTCertException", ",", "CryptoException", ",", "IOException", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"Received invoke request: %s\"", ",", "invokeRequest", ")", ")", ";", "// Get a TCert to use in the invoke transaction", "setAttrs", "(", "invokeRequest", ".", "getAttributes", "(", ")", ")", ";", "if", "(", "null", "==", "getMyTCert", "(", ")", "&&", "getChain", "(", ")", ".", "isSecurityEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Failed getting a new TCert\"", ")", ";", "throw", "new", "NoAvailableTCertException", "(", "\"Failed getting a new TCert\"", ")", ";", "}", "logger", ".", "debug", "(", "\"Got a TCert successfully, continue...\"", ")", ";", "Transaction", "transaction", "=", "InvocationTransactionBuilder", ".", "newBuilder", "(", ")", ".", "context", "(", "this", ")", ".", "request", "(", "invokeRequest", ")", ".", "build", "(", ")", ";", "Fabric", ".", "Response", "response", "=", "execute", "(", "transaction", ")", ";", "if", "(", "response", ".", "getStatus", "(", ")", "==", "StatusCode", ".", "FAILURE", ")", "{", "throw", "new", "ChainCodeException", "(", "response", ".", "getMsg", "(", ")", ".", "toStringUtf8", "(", ")", ",", "null", ")", ";", "}", "return", "new", "ChainCodeResponse", "(", "transaction", ".", "getTxBuilder", "(", ")", ".", "getTxid", "(", ")", ",", "transaction", ".", "getChaincodeID", "(", ")", ",", "Status", ".", "SUCCESS", ",", "response", ".", "getMsg", "(", ")", ".", "toStringUtf8", "(", ")", ")", ";", "}" ]
Issue an invoke on chaincode @param invokeRequest {@link InvokeRequest} An invoke request @throws ChainCodeException
[ "Issue", "an", "invoke", "on", "chaincode" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java#L166-L191
148,730
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java
TransactionContext.execute
private Fabric.Response execute(Transaction tx) throws CryptoException, IOException { logger.debug(String.format("Executing transaction [%s]", tx)); // Set nonce tx.getTxBuilder().setNonce(ByteString.copyFrom(this.nonce)); // Process confidentiality logger.debug("Process Confidentiality..."); this.processConfidentiality(tx); logger.debug("Sign transaction..."); if (getChain().isSecurityEnabled()) { // Add the tcert tx.getTxBuilder().setCert(ByteString.copyFrom(tcert.getCert())); // sign the transaction bytes byte[] txBytes = tx.getTxBuilder().buildPartial().toByteArray(); BigInteger[] signature = this.chain.getCryptoPrimitives().ecdsaSign(tcert.getPrivateKey(), txBytes); byte[] derSignature = this.chain.getCryptoPrimitives().toDER( new byte[][]{signature[0].toByteArray(), signature[1].toByteArray()}); tx.getTxBuilder().setSignature(ByteString.copyFrom(derSignature)); } logger.debug("Send transaction..."); logger.debug("Confidentiality: " + tx.getTxBuilder().getConfidentialityLevel()); if (tx.getTxBuilder().getConfidentialityLevel() == Chaincode.ConfidentialityLevel.CONFIDENTIAL && tx.getTxBuilder().getType() == Fabric.Transaction.Type.CHAINCODE_QUERY) { Fabric.Response response = this.getChain().sendTransaction(tx); if (response.getStatus() == StatusCode.SUCCESS) { byte[] message = decryptResult(response.getMsg().toByteArray()); return Fabric.Response.newBuilder() .setStatus(StatusCode.SUCCESS) .setMsg(ByteString.copyFrom(message)) .build(); } else { return response; } } else { return this.getChain().sendTransaction(tx); } }
java
private Fabric.Response execute(Transaction tx) throws CryptoException, IOException { logger.debug(String.format("Executing transaction [%s]", tx)); // Set nonce tx.getTxBuilder().setNonce(ByteString.copyFrom(this.nonce)); // Process confidentiality logger.debug("Process Confidentiality..."); this.processConfidentiality(tx); logger.debug("Sign transaction..."); if (getChain().isSecurityEnabled()) { // Add the tcert tx.getTxBuilder().setCert(ByteString.copyFrom(tcert.getCert())); // sign the transaction bytes byte[] txBytes = tx.getTxBuilder().buildPartial().toByteArray(); BigInteger[] signature = this.chain.getCryptoPrimitives().ecdsaSign(tcert.getPrivateKey(), txBytes); byte[] derSignature = this.chain.getCryptoPrimitives().toDER( new byte[][]{signature[0].toByteArray(), signature[1].toByteArray()}); tx.getTxBuilder().setSignature(ByteString.copyFrom(derSignature)); } logger.debug("Send transaction..."); logger.debug("Confidentiality: " + tx.getTxBuilder().getConfidentialityLevel()); if (tx.getTxBuilder().getConfidentialityLevel() == Chaincode.ConfidentialityLevel.CONFIDENTIAL && tx.getTxBuilder().getType() == Fabric.Transaction.Type.CHAINCODE_QUERY) { Fabric.Response response = this.getChain().sendTransaction(tx); if (response.getStatus() == StatusCode.SUCCESS) { byte[] message = decryptResult(response.getMsg().toByteArray()); return Fabric.Response.newBuilder() .setStatus(StatusCode.SUCCESS) .setMsg(ByteString.copyFrom(message)) .build(); } else { return response; } } else { return this.getChain().sendTransaction(tx); } }
[ "private", "Fabric", ".", "Response", "execute", "(", "Transaction", "tx", ")", "throws", "CryptoException", ",", "IOException", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"Executing transaction [%s]\"", ",", "tx", ")", ")", ";", "// Set nonce", "tx", ".", "getTxBuilder", "(", ")", ".", "setNonce", "(", "ByteString", ".", "copyFrom", "(", "this", ".", "nonce", ")", ")", ";", "// Process confidentiality", "logger", ".", "debug", "(", "\"Process Confidentiality...\"", ")", ";", "this", ".", "processConfidentiality", "(", "tx", ")", ";", "logger", ".", "debug", "(", "\"Sign transaction...\"", ")", ";", "if", "(", "getChain", "(", ")", ".", "isSecurityEnabled", "(", ")", ")", "{", "// Add the tcert", "tx", ".", "getTxBuilder", "(", ")", ".", "setCert", "(", "ByteString", ".", "copyFrom", "(", "tcert", ".", "getCert", "(", ")", ")", ")", ";", "// sign the transaction bytes", "byte", "[", "]", "txBytes", "=", "tx", ".", "getTxBuilder", "(", ")", ".", "buildPartial", "(", ")", ".", "toByteArray", "(", ")", ";", "BigInteger", "[", "]", "signature", "=", "this", ".", "chain", ".", "getCryptoPrimitives", "(", ")", ".", "ecdsaSign", "(", "tcert", ".", "getPrivateKey", "(", ")", ",", "txBytes", ")", ";", "byte", "[", "]", "derSignature", "=", "this", ".", "chain", ".", "getCryptoPrimitives", "(", ")", ".", "toDER", "(", "new", "byte", "[", "]", "[", "]", "{", "signature", "[", "0", "]", ".", "toByteArray", "(", ")", ",", "signature", "[", "1", "]", ".", "toByteArray", "(", ")", "}", ")", ";", "tx", ".", "getTxBuilder", "(", ")", ".", "setSignature", "(", "ByteString", ".", "copyFrom", "(", "derSignature", ")", ")", ";", "}", "logger", ".", "debug", "(", "\"Send transaction...\"", ")", ";", "logger", ".", "debug", "(", "\"Confidentiality: \"", "+", "tx", ".", "getTxBuilder", "(", ")", ".", "getConfidentialityLevel", "(", ")", ")", ";", "if", "(", "tx", ".", "getTxBuilder", "(", ")", ".", "getConfidentialityLevel", "(", ")", "==", "Chaincode", ".", "ConfidentialityLevel", ".", "CONFIDENTIAL", "&&", "tx", ".", "getTxBuilder", "(", ")", ".", "getType", "(", ")", "==", "Fabric", ".", "Transaction", ".", "Type", ".", "CHAINCODE_QUERY", ")", "{", "Fabric", ".", "Response", "response", "=", "this", ".", "getChain", "(", ")", ".", "sendTransaction", "(", "tx", ")", ";", "if", "(", "response", ".", "getStatus", "(", ")", "==", "StatusCode", ".", "SUCCESS", ")", "{", "byte", "[", "]", "message", "=", "decryptResult", "(", "response", ".", "getMsg", "(", ")", ".", "toByteArray", "(", ")", ")", ";", "return", "Fabric", ".", "Response", ".", "newBuilder", "(", ")", ".", "setStatus", "(", "StatusCode", ".", "SUCCESS", ")", ".", "setMsg", "(", "ByteString", ".", "copyFrom", "(", "message", ")", ")", ".", "build", "(", ")", ";", "}", "else", "{", "return", "response", ";", "}", "}", "else", "{", "return", "this", ".", "getChain", "(", ")", ".", "sendTransaction", "(", "tx", ")", ";", "}", "}" ]
Execute a transaction @param tx {Transaction} The transaction.
[ "Execute", "a", "transaction" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/transaction/TransactionContext.java#L242-L285
148,731
diirt/util
src/main/java/org/epics/util/array/CollectionNumbers.java
CollectionNumbers.wrappedArray
public static Object wrappedArray(CollectionNumber coll) { Object data = wrappedFloatArray(coll); if (data != null) { return data; } data = wrappedDoubleArray(coll); if (data != null) { return data; } data = wrappedByteArray(coll); if (data != null) { return data; } data = wrappedShortArray(coll); if (data != null) { return data; } data = wrappedIntArray(coll); if (data != null) { return data; } data = wrappedLongArray(coll); if (data != null) { return data; } return null; }
java
public static Object wrappedArray(CollectionNumber coll) { Object data = wrappedFloatArray(coll); if (data != null) { return data; } data = wrappedDoubleArray(coll); if (data != null) { return data; } data = wrappedByteArray(coll); if (data != null) { return data; } data = wrappedShortArray(coll); if (data != null) { return data; } data = wrappedIntArray(coll); if (data != null) { return data; } data = wrappedLongArray(coll); if (data != null) { return data; } return null; }
[ "public", "static", "Object", "wrappedArray", "(", "CollectionNumber", "coll", ")", "{", "Object", "data", "=", "wrappedFloatArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "wrappedDoubleArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "wrappedByteArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "wrappedShortArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "wrappedIntArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "wrappedLongArray", "(", "coll", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "return", "null", ";", "}" ]
If available, return the array wrapped by the collection - USE WITH CAUTION AS IT EXPOSES THE INTERNAL STATE OF THE COLLECTION. This is provided in case an external routine for computation requires you to use array, and you want to avoid the copy for performance reason. @param coll the collection @return the array or null
[ "If", "available", "return", "the", "array", "wrapped", "by", "the", "collection", "-", "USE", "WITH", "CAUTION", "AS", "IT", "EXPOSES", "THE", "INTERNAL", "STATE", "OF", "THE", "COLLECTION", ".", "This", "is", "provided", "in", "case", "an", "external", "routine", "for", "computation", "requires", "you", "to", "use", "array", "and", "you", "want", "to", "avoid", "the", "copy", "for", "performance", "reason", "." ]
24aca0a173a635aaf0b78d213a3fee8d4f91c077
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/array/CollectionNumbers.java#L28-L54
148,732
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java
SDKUtil.generateParameterHash
public static String generateParameterHash(String path, String func, List<String> args) { logger.debug(String.format("GenerateParameterHash : path=%s, func=%s, args=%s", path, func, args)); // Append the arguments StringBuilder param = new StringBuilder(path); param.append(func); args.forEach(param::append); // Compute the hash String strHash = Hex.toHexString(hash(param.toString().getBytes(), new SHA3Digest())); return strHash; }
java
public static String generateParameterHash(String path, String func, List<String> args) { logger.debug(String.format("GenerateParameterHash : path=%s, func=%s, args=%s", path, func, args)); // Append the arguments StringBuilder param = new StringBuilder(path); param.append(func); args.forEach(param::append); // Compute the hash String strHash = Hex.toHexString(hash(param.toString().getBytes(), new SHA3Digest())); return strHash; }
[ "public", "static", "String", "generateParameterHash", "(", "String", "path", ",", "String", "func", ",", "List", "<", "String", ">", "args", ")", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"GenerateParameterHash : path=%s, func=%s, args=%s\"", ",", "path", ",", "func", ",", "args", ")", ")", ";", "// Append the arguments", "StringBuilder", "param", "=", "new", "StringBuilder", "(", "path", ")", ";", "param", ".", "append", "(", "func", ")", ";", "args", ".", "forEach", "(", "param", "::", "append", ")", ";", "// Compute the hash", "String", "strHash", "=", "Hex", ".", "toHexString", "(", "hash", "(", "param", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ",", "new", "SHA3Digest", "(", ")", ")", ")", ";", "return", "strHash", ";", "}" ]
Generate parameter hash for the given chain code path,func and args @param path Chain code path @param func Chain code function name @param args List of arguments @return hash of path, func and args
[ "Generate", "parameter", "hash", "for", "the", "given", "chain", "code", "path", "func", "and", "args" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java#L59-L71
148,733
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java
SDKUtil.generateTarGz
public static void generateTarGz(String src, String target) throws IOException { File sourceDirectory = new File(src); File destinationArchive = new File(target); String sourcePath = sourceDirectory.getAbsolutePath(); FileOutputStream destinationOutputStream = new FileOutputStream(destinationArchive); TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream(new GzipCompressorOutputStream(new BufferedOutputStream(destinationOutputStream))); archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); try { Collection<File> childrenFiles = org.apache.commons.io.FileUtils.listFiles(sourceDirectory, null, true); childrenFiles.remove(destinationArchive); ArchiveEntry archiveEntry; FileInputStream fileInputStream; for (File childFile : childrenFiles) { String childPath = childFile.getAbsolutePath(); String relativePath = childPath.substring((sourcePath.length() + 1), childPath.length()); relativePath = FilenameUtils.separatorsToUnix(relativePath); archiveEntry = new TarArchiveEntry(childFile, relativePath); fileInputStream = new FileInputStream(childFile); archiveOutputStream.putArchiveEntry(archiveEntry); try { IOUtils.copy(fileInputStream, archiveOutputStream); } finally { IOUtils.closeQuietly(fileInputStream); archiveOutputStream.closeArchiveEntry(); } } } finally { IOUtils.closeQuietly(archiveOutputStream); } }
java
public static void generateTarGz(String src, String target) throws IOException { File sourceDirectory = new File(src); File destinationArchive = new File(target); String sourcePath = sourceDirectory.getAbsolutePath(); FileOutputStream destinationOutputStream = new FileOutputStream(destinationArchive); TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream(new GzipCompressorOutputStream(new BufferedOutputStream(destinationOutputStream))); archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); try { Collection<File> childrenFiles = org.apache.commons.io.FileUtils.listFiles(sourceDirectory, null, true); childrenFiles.remove(destinationArchive); ArchiveEntry archiveEntry; FileInputStream fileInputStream; for (File childFile : childrenFiles) { String childPath = childFile.getAbsolutePath(); String relativePath = childPath.substring((sourcePath.length() + 1), childPath.length()); relativePath = FilenameUtils.separatorsToUnix(relativePath); archiveEntry = new TarArchiveEntry(childFile, relativePath); fileInputStream = new FileInputStream(childFile); archiveOutputStream.putArchiveEntry(archiveEntry); try { IOUtils.copy(fileInputStream, archiveOutputStream); } finally { IOUtils.closeQuietly(fileInputStream); archiveOutputStream.closeArchiveEntry(); } } } finally { IOUtils.closeQuietly(archiveOutputStream); } }
[ "public", "static", "void", "generateTarGz", "(", "String", "src", ",", "String", "target", ")", "throws", "IOException", "{", "File", "sourceDirectory", "=", "new", "File", "(", "src", ")", ";", "File", "destinationArchive", "=", "new", "File", "(", "target", ")", ";", "String", "sourcePath", "=", "sourceDirectory", ".", "getAbsolutePath", "(", ")", ";", "FileOutputStream", "destinationOutputStream", "=", "new", "FileOutputStream", "(", "destinationArchive", ")", ";", "TarArchiveOutputStream", "archiveOutputStream", "=", "new", "TarArchiveOutputStream", "(", "new", "GzipCompressorOutputStream", "(", "new", "BufferedOutputStream", "(", "destinationOutputStream", ")", ")", ")", ";", "archiveOutputStream", ".", "setLongFileMode", "(", "TarArchiveOutputStream", ".", "LONGFILE_GNU", ")", ";", "try", "{", "Collection", "<", "File", ">", "childrenFiles", "=", "org", ".", "apache", ".", "commons", ".", "io", ".", "FileUtils", ".", "listFiles", "(", "sourceDirectory", ",", "null", ",", "true", ")", ";", "childrenFiles", ".", "remove", "(", "destinationArchive", ")", ";", "ArchiveEntry", "archiveEntry", ";", "FileInputStream", "fileInputStream", ";", "for", "(", "File", "childFile", ":", "childrenFiles", ")", "{", "String", "childPath", "=", "childFile", ".", "getAbsolutePath", "(", ")", ";", "String", "relativePath", "=", "childPath", ".", "substring", "(", "(", "sourcePath", ".", "length", "(", ")", "+", "1", ")", ",", "childPath", ".", "length", "(", ")", ")", ";", "relativePath", "=", "FilenameUtils", ".", "separatorsToUnix", "(", "relativePath", ")", ";", "archiveEntry", "=", "new", "TarArchiveEntry", "(", "childFile", ",", "relativePath", ")", ";", "fileInputStream", "=", "new", "FileInputStream", "(", "childFile", ")", ";", "archiveOutputStream", ".", "putArchiveEntry", "(", "archiveEntry", ")", ";", "try", "{", "IOUtils", ".", "copy", "(", "fileInputStream", ",", "archiveOutputStream", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "fileInputStream", ")", ";", "archiveOutputStream", ".", "closeArchiveEntry", "(", ")", ";", "}", "}", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "archiveOutputStream", ")", ";", "}", "}" ]
Compress the given directory src to target tar.gz file @param src The source directory @param target The target tar.gz file @throws IOException
[ "Compress", "the", "given", "directory", "src", "to", "target", "tar", ".", "gz", "file" ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java#L124-L159
148,734
iipc/openwayback-access-control
oracle/src/main/java/org/archive/accesscontrol/oracle/AutoFormatView.java
AutoFormatView.viewByContentType
public View viewByContentType(String contentType) { for (View view: views.values()) { if (view.getContentType().equals(contentType)) { return view; } } return null; }
java
public View viewByContentType(String contentType) { for (View view: views.values()) { if (view.getContentType().equals(contentType)) { return view; } } return null; }
[ "public", "View", "viewByContentType", "(", "String", "contentType", ")", "{", "for", "(", "View", "view", ":", "views", ".", "values", "(", ")", ")", "{", "if", "(", "view", ".", "getContentType", "(", ")", ".", "equals", "(", "contentType", ")", ")", "{", "return", "view", ";", "}", "}", "return", "null", ";", "}" ]
Return the first view with the given content type. @param contentType @return
[ "Return", "the", "first", "view", "with", "the", "given", "content", "type", "." ]
4a0f70f200fd8d7b6e313624b7628656d834bf31
https://github.com/iipc/openwayback-access-control/blob/4a0f70f200fd8d7b6e313624b7628656d834bf31/oracle/src/main/java/org/archive/accesscontrol/oracle/AutoFormatView.java#L82-L89
148,735
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/MemberServicesImpl.java
MemberServicesImpl.register
public String register(RegistrationRequest req, Member registrar) throws RegistrationException { if (StringUtil.isNullOrEmpty(req.getEnrollmentID())) { throw new IllegalArgumentException("EntrollmentID cannot be null or empty"); } if (registrar == null) { throw new IllegalArgumentException("Registrar should be a valid member"); } Registrar reg = Registrar.newBuilder() .setId( Identity.newBuilder() .setId(registrar.getName()) .build()) .build(); //TODO: set Roles and Delegate Roles RegisterUserReq.Builder regReqBuilder = RegisterUserReq.newBuilder(); regReqBuilder.setId( Identity.newBuilder() .setId(req.getEnrollmentID()) .build()); regReqBuilder.setRoleValue(rolesToMask(req.getRoles())); regReqBuilder.setAffiliation(req.getAffiliation()); regReqBuilder.setRegistrar(reg); RegisterUserReq registerReq = regReqBuilder.build(); byte[] buffer = registerReq.toByteArray(); try { java.security.PrivateKey signKey = cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(registrar.getEnrollment().getKey())); logger.debug("Retreived private key"); BigInteger[] signature = cryptoPrimitives.ecdsaSign(signKey, buffer); logger.debug("Signed the request with key"); Signature sig = Signature.newBuilder().setType(CryptoType.ECDSA).setR(ByteString.copyFrom(signature[0].toString().getBytes())).setS(ByteString.copyFrom(signature[1].toString().getBytes())).build(); regReqBuilder.setSig(sig); logger.debug("Now sendingt register request"); Token token = this.ecaaClient.registerUser(regReqBuilder.build()); return token.getTok().toStringUtf8(); } catch (Exception e) { throw new RegistrationException("Error while registering the user", e); } }
java
public String register(RegistrationRequest req, Member registrar) throws RegistrationException { if (StringUtil.isNullOrEmpty(req.getEnrollmentID())) { throw new IllegalArgumentException("EntrollmentID cannot be null or empty"); } if (registrar == null) { throw new IllegalArgumentException("Registrar should be a valid member"); } Registrar reg = Registrar.newBuilder() .setId( Identity.newBuilder() .setId(registrar.getName()) .build()) .build(); //TODO: set Roles and Delegate Roles RegisterUserReq.Builder regReqBuilder = RegisterUserReq.newBuilder(); regReqBuilder.setId( Identity.newBuilder() .setId(req.getEnrollmentID()) .build()); regReqBuilder.setRoleValue(rolesToMask(req.getRoles())); regReqBuilder.setAffiliation(req.getAffiliation()); regReqBuilder.setRegistrar(reg); RegisterUserReq registerReq = regReqBuilder.build(); byte[] buffer = registerReq.toByteArray(); try { java.security.PrivateKey signKey = cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(registrar.getEnrollment().getKey())); logger.debug("Retreived private key"); BigInteger[] signature = cryptoPrimitives.ecdsaSign(signKey, buffer); logger.debug("Signed the request with key"); Signature sig = Signature.newBuilder().setType(CryptoType.ECDSA).setR(ByteString.copyFrom(signature[0].toString().getBytes())).setS(ByteString.copyFrom(signature[1].toString().getBytes())).build(); regReqBuilder.setSig(sig); logger.debug("Now sendingt register request"); Token token = this.ecaaClient.registerUser(regReqBuilder.build()); return token.getTok().toStringUtf8(); } catch (Exception e) { throw new RegistrationException("Error while registering the user", e); } }
[ "public", "String", "register", "(", "RegistrationRequest", "req", ",", "Member", "registrar", ")", "throws", "RegistrationException", "{", "if", "(", "StringUtil", ".", "isNullOrEmpty", "(", "req", ".", "getEnrollmentID", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"EntrollmentID cannot be null or empty\"", ")", ";", "}", "if", "(", "registrar", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Registrar should be a valid member\"", ")", ";", "}", "Registrar", "reg", "=", "Registrar", ".", "newBuilder", "(", ")", ".", "setId", "(", "Identity", ".", "newBuilder", "(", ")", ".", "setId", "(", "registrar", ".", "getName", "(", ")", ")", ".", "build", "(", ")", ")", ".", "build", "(", ")", ";", "//TODO: set Roles and Delegate Roles", "RegisterUserReq", ".", "Builder", "regReqBuilder", "=", "RegisterUserReq", ".", "newBuilder", "(", ")", ";", "regReqBuilder", ".", "setId", "(", "Identity", ".", "newBuilder", "(", ")", ".", "setId", "(", "req", ".", "getEnrollmentID", "(", ")", ")", ".", "build", "(", ")", ")", ";", "regReqBuilder", ".", "setRoleValue", "(", "rolesToMask", "(", "req", ".", "getRoles", "(", ")", ")", ")", ";", "regReqBuilder", ".", "setAffiliation", "(", "req", ".", "getAffiliation", "(", ")", ")", ";", "regReqBuilder", ".", "setRegistrar", "(", "reg", ")", ";", "RegisterUserReq", "registerReq", "=", "regReqBuilder", ".", "build", "(", ")", ";", "byte", "[", "]", "buffer", "=", "registerReq", ".", "toByteArray", "(", ")", ";", "try", "{", "java", ".", "security", ".", "PrivateKey", "signKey", "=", "cryptoPrimitives", ".", "ecdsaKeyFromPrivate", "(", "Hex", ".", "decode", "(", "registrar", ".", "getEnrollment", "(", ")", ".", "getKey", "(", ")", ")", ")", ";", "logger", ".", "debug", "(", "\"Retreived private key\"", ")", ";", "BigInteger", "[", "]", "signature", "=", "cryptoPrimitives", ".", "ecdsaSign", "(", "signKey", ",", "buffer", ")", ";", "logger", ".", "debug", "(", "\"Signed the request with key\"", ")", ";", "Signature", "sig", "=", "Signature", ".", "newBuilder", "(", ")", ".", "setType", "(", "CryptoType", ".", "ECDSA", ")", ".", "setR", "(", "ByteString", ".", "copyFrom", "(", "signature", "[", "0", "]", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ")", ")", ".", "setS", "(", "ByteString", ".", "copyFrom", "(", "signature", "[", "1", "]", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ")", ")", ".", "build", "(", ")", ";", "regReqBuilder", ".", "setSig", "(", "sig", ")", ";", "logger", ".", "debug", "(", "\"Now sendingt register request\"", ")", ";", "Token", "token", "=", "this", ".", "ecaaClient", ".", "registerUser", "(", "regReqBuilder", ".", "build", "(", ")", ")", ";", "return", "token", ".", "getTok", "(", ")", ".", "toStringUtf8", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RegistrationException", "(", "\"Error while registering the user\"", ",", "e", ")", ";", "}", "}" ]
Register the member and return an enrollment secret. @param req Registration request with the following fields: name, role @param registrar The identity of the registrar (i.e. who is performing the registration)
[ "Register", "the", "member", "and", "return", "an", "enrollment", "secret", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/MemberServicesImpl.java#L130-L174
148,736
zamrokk/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/MemberServicesImpl.java
MemberServicesImpl.processTCertBatch
private List<TCert> processTCertBatch(GetTCertBatchRequest req, TCertCreateSetResp resp) throws NoSuchPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, CryptoException, IOException { String enrollKey = req.getEnrollment().getKey(); byte[] tCertOwnerKDFKey = resp.getCerts().getKey().toByteArray(); List<Ca.TCert> tCerts = resp.getCerts().getCertsList(); byte[] byte1 = new byte[]{1}; byte[] byte2 = new byte[]{2}; byte[] tCertOwnerEncryptKey = Arrays.copyOfRange(cryptoPrimitives.calculateMac(tCertOwnerKDFKey, byte1), 0, 32); byte[] expansionKey = cryptoPrimitives.calculateMac(tCertOwnerKDFKey, byte2); List<TCert> tCertBatch = new ArrayList<>(tCerts.size()); // Loop through certs and extract private keys for (Ca.TCert tCert : tCerts) { X509Certificate x509Certificate; try { CertificateFactory cf = CertificateFactory.getInstance("X.509"); x509Certificate = (X509Certificate)cf.generateCertificate(tCert.getCert().newInput()); } catch (Exception ex) { logger.debug("Warning: problem parsing certificate bytes; retrying ... ", ex); continue; } // extract the encrypted bytes from extension attribute byte[] tCertIndexCT = fromDer(x509Certificate.getExtensionValue(TCERT_ENC_TCERT_INDEX)); byte[] tCertIndex = cryptoPrimitives.aesCBCPKCS7Decrypt(tCertOwnerEncryptKey, tCertIndexCT); byte[] expansionValue = cryptoPrimitives.calculateMac(expansionKey, tCertIndex); // compute the private key BigInteger k = new BigInteger(1, expansionValue); BigInteger n = ((ECPrivateKey)cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))) .getParameters().getN().subtract(BigInteger.ONE); k = k.mod(n).add(BigInteger.ONE); BigInteger D = ((ECPrivateKey) cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))).getD().add(k); D = D.mod(((ECPrivateKey)cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))).getParameters().getN()); // Put private and public key in returned tcert TCert tcert = new TCert(tCert.getCert().toByteArray(), cryptoPrimitives.ecdsaKeyFromBigInt(D)); tCertBatch.add(tcert); } if (tCertBatch.size() == 0) { throw new RuntimeException("Failed fetching TCertBatch. No valid TCert received."); } return tCertBatch; }
java
private List<TCert> processTCertBatch(GetTCertBatchRequest req, TCertCreateSetResp resp) throws NoSuchPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, CryptoException, IOException { String enrollKey = req.getEnrollment().getKey(); byte[] tCertOwnerKDFKey = resp.getCerts().getKey().toByteArray(); List<Ca.TCert> tCerts = resp.getCerts().getCertsList(); byte[] byte1 = new byte[]{1}; byte[] byte2 = new byte[]{2}; byte[] tCertOwnerEncryptKey = Arrays.copyOfRange(cryptoPrimitives.calculateMac(tCertOwnerKDFKey, byte1), 0, 32); byte[] expansionKey = cryptoPrimitives.calculateMac(tCertOwnerKDFKey, byte2); List<TCert> tCertBatch = new ArrayList<>(tCerts.size()); // Loop through certs and extract private keys for (Ca.TCert tCert : tCerts) { X509Certificate x509Certificate; try { CertificateFactory cf = CertificateFactory.getInstance("X.509"); x509Certificate = (X509Certificate)cf.generateCertificate(tCert.getCert().newInput()); } catch (Exception ex) { logger.debug("Warning: problem parsing certificate bytes; retrying ... ", ex); continue; } // extract the encrypted bytes from extension attribute byte[] tCertIndexCT = fromDer(x509Certificate.getExtensionValue(TCERT_ENC_TCERT_INDEX)); byte[] tCertIndex = cryptoPrimitives.aesCBCPKCS7Decrypt(tCertOwnerEncryptKey, tCertIndexCT); byte[] expansionValue = cryptoPrimitives.calculateMac(expansionKey, tCertIndex); // compute the private key BigInteger k = new BigInteger(1, expansionValue); BigInteger n = ((ECPrivateKey)cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))) .getParameters().getN().subtract(BigInteger.ONE); k = k.mod(n).add(BigInteger.ONE); BigInteger D = ((ECPrivateKey) cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))).getD().add(k); D = D.mod(((ECPrivateKey)cryptoPrimitives.ecdsaKeyFromPrivate(Hex.decode(enrollKey))).getParameters().getN()); // Put private and public key in returned tcert TCert tcert = new TCert(tCert.getCert().toByteArray(), cryptoPrimitives.ecdsaKeyFromBigInt(D)); tCertBatch.add(tcert); } if (tCertBatch.size() == 0) { throw new RuntimeException("Failed fetching TCertBatch. No valid TCert received."); } return tCertBatch; }
[ "private", "List", "<", "TCert", ">", "processTCertBatch", "(", "GetTCertBatchRequest", "req", ",", "TCertCreateSetResp", "resp", ")", "throws", "NoSuchPaddingException", ",", "InvalidKeyException", ",", "NoSuchAlgorithmException", ",", "IllegalBlockSizeException", ",", "BadPaddingException", ",", "InvalidAlgorithmParameterException", ",", "CryptoException", ",", "IOException", "{", "String", "enrollKey", "=", "req", ".", "getEnrollment", "(", ")", ".", "getKey", "(", ")", ";", "byte", "[", "]", "tCertOwnerKDFKey", "=", "resp", ".", "getCerts", "(", ")", ".", "getKey", "(", ")", ".", "toByteArray", "(", ")", ";", "List", "<", "Ca", ".", "TCert", ">", "tCerts", "=", "resp", ".", "getCerts", "(", ")", ".", "getCertsList", "(", ")", ";", "byte", "[", "]", "byte1", "=", "new", "byte", "[", "]", "{", "1", "}", ";", "byte", "[", "]", "byte2", "=", "new", "byte", "[", "]", "{", "2", "}", ";", "byte", "[", "]", "tCertOwnerEncryptKey", "=", "Arrays", ".", "copyOfRange", "(", "cryptoPrimitives", ".", "calculateMac", "(", "tCertOwnerKDFKey", ",", "byte1", ")", ",", "0", ",", "32", ")", ";", "byte", "[", "]", "expansionKey", "=", "cryptoPrimitives", ".", "calculateMac", "(", "tCertOwnerKDFKey", ",", "byte2", ")", ";", "List", "<", "TCert", ">", "tCertBatch", "=", "new", "ArrayList", "<>", "(", "tCerts", ".", "size", "(", ")", ")", ";", "// Loop through certs and extract private keys", "for", "(", "Ca", ".", "TCert", "tCert", ":", "tCerts", ")", "{", "X509Certificate", "x509Certificate", ";", "try", "{", "CertificateFactory", "cf", "=", "CertificateFactory", ".", "getInstance", "(", "\"X.509\"", ")", ";", "x509Certificate", "=", "(", "X509Certificate", ")", "cf", ".", "generateCertificate", "(", "tCert", ".", "getCert", "(", ")", ".", "newInput", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "debug", "(", "\"Warning: problem parsing certificate bytes; retrying ... \"", ",", "ex", ")", ";", "continue", ";", "}", "// extract the encrypted bytes from extension attribute", "byte", "[", "]", "tCertIndexCT", "=", "fromDer", "(", "x509Certificate", ".", "getExtensionValue", "(", "TCERT_ENC_TCERT_INDEX", ")", ")", ";", "byte", "[", "]", "tCertIndex", "=", "cryptoPrimitives", ".", "aesCBCPKCS7Decrypt", "(", "tCertOwnerEncryptKey", ",", "tCertIndexCT", ")", ";", "byte", "[", "]", "expansionValue", "=", "cryptoPrimitives", ".", "calculateMac", "(", "expansionKey", ",", "tCertIndex", ")", ";", "// compute the private key", "BigInteger", "k", "=", "new", "BigInteger", "(", "1", ",", "expansionValue", ")", ";", "BigInteger", "n", "=", "(", "(", "ECPrivateKey", ")", "cryptoPrimitives", ".", "ecdsaKeyFromPrivate", "(", "Hex", ".", "decode", "(", "enrollKey", ")", ")", ")", ".", "getParameters", "(", ")", ".", "getN", "(", ")", ".", "subtract", "(", "BigInteger", ".", "ONE", ")", ";", "k", "=", "k", ".", "mod", "(", "n", ")", ".", "add", "(", "BigInteger", ".", "ONE", ")", ";", "BigInteger", "D", "=", "(", "(", "ECPrivateKey", ")", "cryptoPrimitives", ".", "ecdsaKeyFromPrivate", "(", "Hex", ".", "decode", "(", "enrollKey", ")", ")", ")", ".", "getD", "(", ")", ".", "add", "(", "k", ")", ";", "D", "=", "D", ".", "mod", "(", "(", "(", "ECPrivateKey", ")", "cryptoPrimitives", ".", "ecdsaKeyFromPrivate", "(", "Hex", ".", "decode", "(", "enrollKey", ")", ")", ")", ".", "getParameters", "(", ")", ".", "getN", "(", ")", ")", ";", "// Put private and public key in returned tcert", "TCert", "tcert", "=", "new", "TCert", "(", "tCert", ".", "getCert", "(", ")", ".", "toByteArray", "(", ")", ",", "cryptoPrimitives", ".", "ecdsaKeyFromBigInt", "(", "D", ")", ")", ";", "tCertBatch", ".", "add", "(", "tcert", ")", ";", "}", "if", "(", "tCertBatch", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed fetching TCertBatch. No valid TCert received.\"", ")", ";", "}", "return", "tCertBatch", ";", "}" ]
Process a batch of tcerts after having retrieved them from the TCA.
[ "Process", "a", "batch", "of", "tcerts", "after", "having", "retrieved", "them", "from", "the", "TCA", "." ]
d4993ca602f72d412cd682e1b92e805e48b27afa
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/MemberServicesImpl.java#L281-L333
148,737
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/stats/RegressionLine.java
RegressionLine.getRMSError
public double getRMSError() { double r = covarCalc.getSumSquaredDeviations() / Math.sqrt(varCalcX.getSumSquaredDeviations() * varCalcY.getSumSquaredDeviations()); return Math.sqrt(1 - r) * varCalcX.getStdDev(); }
java
public double getRMSError() { double r = covarCalc.getSumSquaredDeviations() / Math.sqrt(varCalcX.getSumSquaredDeviations() * varCalcY.getSumSquaredDeviations()); return Math.sqrt(1 - r) * varCalcX.getStdDev(); }
[ "public", "double", "getRMSError", "(", ")", "{", "double", "r", "=", "covarCalc", ".", "getSumSquaredDeviations", "(", ")", "/", "Math", ".", "sqrt", "(", "varCalcX", ".", "getSumSquaredDeviations", "(", ")", "*", "varCalcY", ".", "getSumSquaredDeviations", "(", ")", ")", ";", "return", "Math", ".", "sqrt", "(", "1", "-", "r", ")", "*", "varCalcX", ".", "getStdDev", "(", ")", ";", "}" ]
Returns the r.m.s. error of this regression line. @return the r.m.s. error of this regression line.
[ "Returns", "the", "r", ".", "m", ".", "s", ".", "error", "of", "this", "regression", "line", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/stats/RegressionLine.java#L105-L110
148,738
vtatai/srec
core/src/main/java/com/github/srec/command/ExecutionContext.java
ExecutionContext.isSymbolNull
public boolean isSymbolNull(String name) { CommandSymbol s = findSymbol(name); if (s == null) return true; if (s instanceof VarCommand) { VarCommand var = (VarCommand) s; Value v = var.getValue(this); if (v == null || v.get() == null || v instanceof NilValue) return true; } return false; }
java
public boolean isSymbolNull(String name) { CommandSymbol s = findSymbol(name); if (s == null) return true; if (s instanceof VarCommand) { VarCommand var = (VarCommand) s; Value v = var.getValue(this); if (v == null || v.get() == null || v instanceof NilValue) return true; } return false; }
[ "public", "boolean", "isSymbolNull", "(", "String", "name", ")", "{", "CommandSymbol", "s", "=", "findSymbol", "(", "name", ")", ";", "if", "(", "s", "==", "null", ")", "return", "true", ";", "if", "(", "s", "instanceof", "VarCommand", ")", "{", "VarCommand", "var", "=", "(", "VarCommand", ")", "s", ";", "Value", "v", "=", "var", ".", "getValue", "(", "this", ")", ";", "if", "(", "v", "==", "null", "||", "v", ".", "get", "(", ")", "==", "null", "||", "v", "instanceof", "NilValue", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the symbol is null or has not been defined. @param name The symbol's name @return true if null
[ "Returns", "true", "if", "the", "symbol", "is", "null", "or", "has", "not", "been", "defined", "." ]
87fa6754a6a5f8569ef628db4d149eea04062568
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/ExecutionContext.java#L92-L101
148,739
jboss/jboss-common-beans
src/main/java/org/jboss/common/beans/property/token/ArrayTokenizer.java
ArrayTokenizer.tokenize
public final String[] tokenize(String value) { StringTokenizer stringTokenizer = new StringTokenizer(value, getDelimiters()); String[] broken = new String[stringTokenizer.countTokens()]; for(int index = 0; index< broken.length;index++){ broken[index] = stringTokenizer.nextToken(); } return broken; }
java
public final String[] tokenize(String value) { StringTokenizer stringTokenizer = new StringTokenizer(value, getDelimiters()); String[] broken = new String[stringTokenizer.countTokens()]; for(int index = 0; index< broken.length;index++){ broken[index] = stringTokenizer.nextToken(); } return broken; }
[ "public", "final", "String", "[", "]", "tokenize", "(", "String", "value", ")", "{", "StringTokenizer", "stringTokenizer", "=", "new", "StringTokenizer", "(", "value", ",", "getDelimiters", "(", ")", ")", ";", "String", "[", "]", "broken", "=", "new", "String", "[", "stringTokenizer", ".", "countTokens", "(", ")", "]", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "broken", ".", "length", ";", "index", "++", ")", "{", "broken", "[", "index", "]", "=", "stringTokenizer", ".", "nextToken", "(", ")", ";", "}", "return", "broken", ";", "}" ]
Implementation of this method breaks down passed string into tokens. @param value @return
[ "Implementation", "of", "this", "method", "breaks", "down", "passed", "string", "into", "tokens", "." ]
ffb48b1719762534bf92d762eadf91d1815f6748
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/token/ArrayTokenizer.java#L42-L49
148,740
neilboyd/SendLog
sendlog-library/src/main/java/org/l6n/sendlog/library/SendLogActivityBase.java
SendLogActivityBase.getLogFormat
protected String getLogFormat() { final String[] formats = getResources().getStringArray(R.array.format_list); if (mFormat >= 0 && mFormat < formats.length) { return formats[mFormat]; } return formats[FORMAT_DEFAULT]; }
java
protected String getLogFormat() { final String[] formats = getResources().getStringArray(R.array.format_list); if (mFormat >= 0 && mFormat < formats.length) { return formats[mFormat]; } return formats[FORMAT_DEFAULT]; }
[ "protected", "String", "getLogFormat", "(", ")", "{", "final", "String", "[", "]", "formats", "=", "getResources", "(", ")", ".", "getStringArray", "(", "R", ".", "array", ".", "format_list", ")", ";", "if", "(", "mFormat", ">=", "0", "&&", "mFormat", "<", "formats", ".", "length", ")", "{", "return", "formats", "[", "mFormat", "]", ";", "}", "return", "formats", "[", "FORMAT_DEFAULT", "]", ";", "}" ]
The log format to use. Default is "time". Override to use a different format. Return null to prompt for format.
[ "The", "log", "format", "to", "use", ".", "Default", "is", "time", ".", "Override", "to", "use", "a", "different", "format", ".", "Return", "null", "to", "prompt", "for", "format", "." ]
5be734165e48047c53c40149554e52eb88b9598c
https://github.com/neilboyd/SendLog/blob/5be734165e48047c53c40149554e52eb88b9598c/sendlog-library/src/main/java/org/l6n/sendlog/library/SendLogActivityBase.java#L71-L77
148,741
neilboyd/SendLog
sendlog-library/src/main/java/org/l6n/sendlog/library/SendLogActivityBase.java
SendLogActivityBase.getMessageText
protected String getMessageText(final File pZipFile, final PackageManager pPackageManager) { String version = ""; try { final PackageInfo pi = pPackageManager.getPackageInfo(getPackageName(), 0); version = " " + pi.versionName; } catch (final PackageManager.NameNotFoundException e) { Log.e(TAG, "Version name not found", e); } return getString(R.string.email_text, version, Build.MODEL, Build.DEVICE, Build.VERSION.RELEASE, Build.ID, pZipFile.getName(), (pZipFile.length() + 512) / 1024); }
java
protected String getMessageText(final File pZipFile, final PackageManager pPackageManager) { String version = ""; try { final PackageInfo pi = pPackageManager.getPackageInfo(getPackageName(), 0); version = " " + pi.versionName; } catch (final PackageManager.NameNotFoundException e) { Log.e(TAG, "Version name not found", e); } return getString(R.string.email_text, version, Build.MODEL, Build.DEVICE, Build.VERSION.RELEASE, Build.ID, pZipFile.getName(), (pZipFile.length() + 512) / 1024); }
[ "protected", "String", "getMessageText", "(", "final", "File", "pZipFile", ",", "final", "PackageManager", "pPackageManager", ")", "{", "String", "version", "=", "\"\"", ";", "try", "{", "final", "PackageInfo", "pi", "=", "pPackageManager", ".", "getPackageInfo", "(", "getPackageName", "(", ")", ",", "0", ")", ";", "version", "=", "\" \"", "+", "pi", ".", "versionName", ";", "}", "catch", "(", "final", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"Version name not found\"", ",", "e", ")", ";", "}", "return", "getString", "(", "R", ".", "string", ".", "email_text", ",", "version", ",", "Build", ".", "MODEL", ",", "Build", ".", "DEVICE", ",", "Build", ".", "VERSION", ".", "RELEASE", ",", "Build", ".", "ID", ",", "pZipFile", ".", "getName", "(", ")", ",", "(", "pZipFile", ".", "length", "(", ")", "+", "512", ")", "/", "1024", ")", ";", "}" ]
The text of the email. Override to use different text. @param pZipFile the file containing the zipped log @param pPackageManager the package manager @return the message text
[ "The", "text", "of", "the", "email", ".", "Override", "to", "use", "different", "text", "." ]
5be734165e48047c53c40149554e52eb88b9598c
https://github.com/neilboyd/SendLog/blob/5be734165e48047c53c40149554e52eb88b9598c/sendlog-library/src/main/java/org/l6n/sendlog/library/SendLogActivityBase.java#L89-L100
148,742
openbase/jul
extension/type/util/src/main/java/org/openbase/jul/extension/type/util/TransactionSynchronizationFuture.java
TransactionSynchronizationFuture.beforeWaitForSynchronization
@Override protected void beforeWaitForSynchronization(final T message) throws CouldNotPerformException { transactionIdField = ProtoBufFieldProcessor.getFieldDescriptor(message, TransactionIdProvider.TRANSACTION_ID_FIELD_NAME); if (transactionIdField == null) { throw new NotAvailableException("transaction id field for message[" + message.getClass().getSimpleName() + "]"); } if (transactionIdField.getType() != Type.UINT64) { throw new CouldNotPerformException("Transaction id field of message[" + message.getClass().getSimpleName() + "] has an unexpected type[" + transactionIdField.getType().name() + "]"); } }
java
@Override protected void beforeWaitForSynchronization(final T message) throws CouldNotPerformException { transactionIdField = ProtoBufFieldProcessor.getFieldDescriptor(message, TransactionIdProvider.TRANSACTION_ID_FIELD_NAME); if (transactionIdField == null) { throw new NotAvailableException("transaction id field for message[" + message.getClass().getSimpleName() + "]"); } if (transactionIdField.getType() != Type.UINT64) { throw new CouldNotPerformException("Transaction id field of message[" + message.getClass().getSimpleName() + "] has an unexpected type[" + transactionIdField.getType().name() + "]"); } }
[ "@", "Override", "protected", "void", "beforeWaitForSynchronization", "(", "final", "T", "message", ")", "throws", "CouldNotPerformException", "{", "transactionIdField", "=", "ProtoBufFieldProcessor", ".", "getFieldDescriptor", "(", "message", ",", "TransactionIdProvider", ".", "TRANSACTION_ID_FIELD_NAME", ")", ";", "if", "(", "transactionIdField", "==", "null", ")", "{", "throw", "new", "NotAvailableException", "(", "\"transaction id field for message[\"", "+", "message", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\"]\"", ")", ";", "}", "if", "(", "transactionIdField", ".", "getType", "(", ")", "!=", "Type", ".", "UINT64", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Transaction id field of message[\"", "+", "message", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\"] has an unexpected type[\"", "+", "transactionIdField", ".", "getType", "(", ")", ".", "name", "(", ")", "+", "\"]\"", ")", ";", "}", "}" ]
Verify that the internal future has a transaction id field and that this field is of type long. @param message the returned message from the internal future @throws CouldNotPerformException if the message does not have a transaction id field
[ "Verify", "that", "the", "internal", "future", "has", "a", "transaction", "id", "field", "and", "that", "this", "field", "is", "of", "type", "long", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/util/src/main/java/org/openbase/jul/extension/type/util/TransactionSynchronizationFuture.java#L67-L77
148,743
openbase/jul
extension/type/util/src/main/java/org/openbase/jul/extension/type/util/TransactionSynchronizationFuture.java
TransactionSynchronizationFuture.check
@Override protected boolean check(T message) throws CouldNotPerformException { // get transaction id from message final long transactionId = (long) message.getField(transactionIdField); // to work with older versions where no transaction id has been accept empty ids and print a warning if (!message.hasField(transactionIdField) || transactionId == 0) { logger.warn("Received return value without transactionId"); return true; } // logger.warn("Check {} - {} of {}", transactionId, dataProvider.getTransactionId(), dataProvider.toString()); // check that the received transaction id has been reached by the provider return dataProvider.getTransactionId() >= transactionId; }
java
@Override protected boolean check(T message) throws CouldNotPerformException { // get transaction id from message final long transactionId = (long) message.getField(transactionIdField); // to work with older versions where no transaction id has been accept empty ids and print a warning if (!message.hasField(transactionIdField) || transactionId == 0) { logger.warn("Received return value without transactionId"); return true; } // logger.warn("Check {} - {} of {}", transactionId, dataProvider.getTransactionId(), dataProvider.toString()); // check that the received transaction id has been reached by the provider return dataProvider.getTransactionId() >= transactionId; }
[ "@", "Override", "protected", "boolean", "check", "(", "T", "message", ")", "throws", "CouldNotPerformException", "{", "// get transaction id from message", "final", "long", "transactionId", "=", "(", "long", ")", "message", ".", "getField", "(", "transactionIdField", ")", ";", "// to work with older versions where no transaction id has been accept empty ids and print a warning", "if", "(", "!", "message", ".", "hasField", "(", "transactionIdField", ")", "||", "transactionId", "==", "0", ")", "{", "logger", ".", "warn", "(", "\"Received return value without transactionId\"", ")", ";", "return", "true", ";", "}", "// logger.warn(\"Check {} - {} of {}\", transactionId, dataProvider.getTransactionId(), dataProvider.toString());", "// check that the received transaction id has been reached by the provider", "return", "dataProvider", ".", "getTransactionId", "(", ")", ">=", "transactionId", ";", "}" ]
Verify that the transaction id of the data provider is greater or equal to the transaction id in the given message. @param message the return value of the internal future @return true if the transaction id of the data provider is greater or equal than the one in the internal message @throws CouldNotPerformException if the transaction id of the data provider is not available
[ "Verify", "that", "the", "transaction", "id", "of", "the", "data", "provider", "is", "greater", "or", "equal", "to", "the", "transaction", "id", "in", "the", "given", "message", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/util/src/main/java/org/openbase/jul/extension/type/util/TransactionSynchronizationFuture.java#L89-L103
148,744
openbase/jul
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/animation/Animations.java
Animations.createFadeTransition
public static FadeTransition createFadeTransition(final Node node, final double fromValue, final double toValue, final int cycleCount, final double duration) { assert node != null; final FadeTransition fadeTransition = new FadeTransition(Duration.millis(duration), node); fadeTransition.setFromValue(fromValue); fadeTransition.setToValue(toValue); fadeTransition.setCycleCount(cycleCount); fadeTransition.setAutoReverse(true); return fadeTransition; }
java
public static FadeTransition createFadeTransition(final Node node, final double fromValue, final double toValue, final int cycleCount, final double duration) { assert node != null; final FadeTransition fadeTransition = new FadeTransition(Duration.millis(duration), node); fadeTransition.setFromValue(fromValue); fadeTransition.setToValue(toValue); fadeTransition.setCycleCount(cycleCount); fadeTransition.setAutoReverse(true); return fadeTransition; }
[ "public", "static", "FadeTransition", "createFadeTransition", "(", "final", "Node", "node", ",", "final", "double", "fromValue", ",", "final", "double", "toValue", ",", "final", "int", "cycleCount", ",", "final", "double", "duration", ")", "{", "assert", "node", "!=", "null", ";", "final", "FadeTransition", "fadeTransition", "=", "new", "FadeTransition", "(", "Duration", ".", "millis", "(", "duration", ")", ",", "node", ")", ";", "fadeTransition", ".", "setFromValue", "(", "fromValue", ")", ";", "fadeTransition", ".", "setToValue", "(", "toValue", ")", ";", "fadeTransition", ".", "setCycleCount", "(", "cycleCount", ")", ";", "fadeTransition", ".", "setAutoReverse", "(", "true", ")", ";", "return", "fadeTransition", ";", "}" ]
Method to create a FadeTransition with several parameters. @param node the node to which the transition should be applied @param fromValue the opacity value from which the transition should start @param toValue the opacity value where the transition should end @param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless) @param duration the duration which one animation cycle should take @return an instance of the created FadeTransition
[ "Method", "to", "create", "a", "FadeTransition", "with", "several", "parameters", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/animation/Animations.java#L65-L74
148,745
openbase/jul
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/animation/Animations.java
Animations.createRotateTransition
public static RotateTransition createRotateTransition(final Node node, final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) { assert node != null; final RotateTransition rotateTransition = new RotateTransition(Duration.millis(duration), node); rotateTransition.setFromAngle(fromAngle); rotateTransition.setToAngle(toAngle); rotateTransition.setCycleCount(cycleCount); rotateTransition.setAutoReverse(autoReverse); rotateTransition.setInterpolator(interpolator); return rotateTransition; }
java
public static RotateTransition createRotateTransition(final Node node, final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) { assert node != null; final RotateTransition rotateTransition = new RotateTransition(Duration.millis(duration), node); rotateTransition.setFromAngle(fromAngle); rotateTransition.setToAngle(toAngle); rotateTransition.setCycleCount(cycleCount); rotateTransition.setAutoReverse(autoReverse); rotateTransition.setInterpolator(interpolator); return rotateTransition; }
[ "public", "static", "RotateTransition", "createRotateTransition", "(", "final", "Node", "node", ",", "final", "double", "fromAngle", ",", "final", "double", "toAngle", ",", "final", "int", "cycleCount", ",", "final", "double", "duration", ",", "final", "Interpolator", "interpolator", ",", "final", "boolean", "autoReverse", ")", "{", "assert", "node", "!=", "null", ";", "final", "RotateTransition", "rotateTransition", "=", "new", "RotateTransition", "(", "Duration", ".", "millis", "(", "duration", ")", ",", "node", ")", ";", "rotateTransition", ".", "setFromAngle", "(", "fromAngle", ")", ";", "rotateTransition", ".", "setToAngle", "(", "toAngle", ")", ";", "rotateTransition", ".", "setCycleCount", "(", "cycleCount", ")", ";", "rotateTransition", ".", "setAutoReverse", "(", "autoReverse", ")", ";", "rotateTransition", ".", "setInterpolator", "(", "interpolator", ")", ";", "return", "rotateTransition", ";", "}" ]
Method to create a RotateTransition with several parameters. @param node the node to which the transition should be applied. @param fromAngle the rotation angle where the transition should start. @param toAngle the rotation angle where the transition should end. @param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless). @param duration the duration which one animation cycle should take. @param interpolator defines the rotation value interpolation between {@code fromAngle} and {@code toAngle}. @param autoReverse defines if the animation should be reversed at the end. @return an instance of the created FadeTransition.
[ "Method", "to", "create", "a", "RotateTransition", "with", "several", "parameters", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/animation/Animations.java#L89-L99
148,746
f2prateek/ln
ln/src/main/java/com/f2prateek/ln/DebugLn.java
DebugLn.println
protected void println(int priority, String msg) { Log.println(priority, processTag(packageName), processMessage(msg)); }
java
protected void println(int priority, String msg) { Log.println(priority, processTag(packageName), processMessage(msg)); }
[ "protected", "void", "println", "(", "int", "priority", ",", "String", "msg", ")", "{", "Log", ".", "println", "(", "priority", ",", "processTag", "(", "packageName", ")", ",", "processMessage", "(", "msg", ")", ")", ";", "}" ]
Print the message. This method simply prints to {@link android.util.Log}. Override this to use the log level feature and post to your endpoint. @param priority The message priority to print. @param msg The message to print.
[ "Print", "the", "message", "." ]
a84d1a7a4d8fc3c46f6917b0e19862282b878378
https://github.com/f2prateek/ln/blob/a84d1a7a4d8fc3c46f6917b0e19862282b878378/ln/src/main/java/com/f2prateek/ln/DebugLn.java#L220-L222
148,747
f2prateek/ln
ln/src/main/java/com/f2prateek/ln/DebugLn.java
DebugLn.processMessage
protected String processMessage(String msg) { return String.format(MSG_FORMAT, Thread.currentThread().getName(), msg); }
java
protected String processMessage(String msg) { return String.format(MSG_FORMAT, Thread.currentThread().getName(), msg); }
[ "protected", "String", "processMessage", "(", "String", "msg", ")", "{", "return", "String", ".", "format", "(", "MSG_FORMAT", ",", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", ",", "msg", ")", ";", "}" ]
Provide a message for logging. This prepends the current thread to the message. Override this if you want to filter sensitive information, or add extra information to each message before dispatching. @param msg The message evaluated from the format, arguments and exceptions. @return The message that is logged
[ "Provide", "a", "message", "for", "logging", ".", "This", "prepends", "the", "current", "thread", "to", "the", "message", ".", "Override", "this", "if", "you", "want", "to", "filter", "sensitive", "information", "or", "add", "extra", "information", "to", "each", "message", "before", "dispatching", "." ]
a84d1a7a4d8fc3c46f6917b0e19862282b878378
https://github.com/f2prateek/ln/blob/a84d1a7a4d8fc3c46f6917b0e19862282b878378/ln/src/main/java/com/f2prateek/ln/DebugLn.java#L232-L234
148,748
f2prateek/ln
ln/src/main/java/com/f2prateek/ln/DebugLn.java
DebugLn.processTag
protected String processTag(String packageName) { final int skipDepth = 6; // skip 6 stackframes to find the location where this was called final Thread thread = Thread.currentThread(); final StackTraceElement trace = thread.getStackTrace()[skipDepth]; return String.format(TAG_FORMAT, packageName, trace.getFileName(), trace.getLineNumber()); }
java
protected String processTag(String packageName) { final int skipDepth = 6; // skip 6 stackframes to find the location where this was called final Thread thread = Thread.currentThread(); final StackTraceElement trace = thread.getStackTrace()[skipDepth]; return String.format(TAG_FORMAT, packageName, trace.getFileName(), trace.getLineNumber()); }
[ "protected", "String", "processTag", "(", "String", "packageName", ")", "{", "final", "int", "skipDepth", "=", "6", ";", "// skip 6 stackframes to find the location where this was called", "final", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "final", "StackTraceElement", "trace", "=", "thread", ".", "getStackTrace", "(", ")", "[", "skipDepth", "]", ";", "return", "String", ".", "format", "(", "TAG_FORMAT", ",", "packageName", ",", "trace", ".", "getFileName", "(", ")", ",", "trace", ".", "getLineNumber", "(", ")", ")", ";", "}" ]
Provide a tag for logging. By default this returns a tag with the package name, file name, and line number of the calling function. Override this to show different information in the tag. @param packageName the packageName of the app @return the tag to log with
[ "Provide", "a", "tag", "for", "logging", ".", "By", "default", "this", "returns", "a", "tag", "with", "the", "package", "name", "file", "name", "and", "line", "number", "of", "the", "calling", "function", ".", "Override", "this", "to", "show", "different", "information", "in", "the", "tag", "." ]
a84d1a7a4d8fc3c46f6917b0e19862282b878378
https://github.com/f2prateek/ln/blob/a84d1a7a4d8fc3c46f6917b0e19862282b878378/ln/src/main/java/com/f2prateek/ln/DebugLn.java#L244-L249
148,749
openbase/jul
storage/src/main/java/org/openbase/jul/storage/registry/RemoteRegistry.java
RemoteRegistry.waitForData
public void waitForData() throws InterruptedException { try { if (registryRemote == null) { waitForValue(); return; } getRegistryRemote().waitForData(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not wait until " + getName() + " is ready!", ex, logger); } }
java
public void waitForData() throws InterruptedException { try { if (registryRemote == null) { waitForValue(); return; } getRegistryRemote().waitForData(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not wait until " + getName() + " is ready!", ex, logger); } }
[ "public", "void", "waitForData", "(", ")", "throws", "InterruptedException", "{", "try", "{", "if", "(", "registryRemote", "==", "null", ")", "{", "waitForValue", "(", ")", ";", "return", ";", "}", "getRegistryRemote", "(", ")", ".", "waitForData", "(", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"Could not wait until \"", "+", "getName", "(", ")", "+", "\" is ready!\"", ",", "ex", ",", "logger", ")", ";", "}", "}" ]
Method blocks until the remote registry is synchronized. @throws InterruptedException is thrown in case the thread is externally interrupted.
[ "Method", "blocks", "until", "the", "remote", "registry", "is", "synchronized", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/storage/src/main/java/org/openbase/jul/storage/registry/RemoteRegistry.java#L270-L280
148,750
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/validation/BaseConfiguration.java
BaseConfiguration.configurationChanged
@Override public void configurationChanged() { HashSet<Param> changedParams = new HashSet(); // read dynamic parameters for (Param param : parameters) { if (! param.isStatic()) { // preserve current value Object oldValue = param.getValue(); // read new value readAndValidateParameter(param); // get if parameter value had changed if (! ConfigUtil.equalValues(oldValue, param.getValue())) { changedParams.add(param); } } } // invoke listeners for all changed parameters if (! changedParams.isEmpty()) { for (ConfigChangeListener listener : configChangeListeners) { listener.configurationChanged(changedParams); } } }
java
@Override public void configurationChanged() { HashSet<Param> changedParams = new HashSet(); // read dynamic parameters for (Param param : parameters) { if (! param.isStatic()) { // preserve current value Object oldValue = param.getValue(); // read new value readAndValidateParameter(param); // get if parameter value had changed if (! ConfigUtil.equalValues(oldValue, param.getValue())) { changedParams.add(param); } } } // invoke listeners for all changed parameters if (! changedParams.isEmpty()) { for (ConfigChangeListener listener : configChangeListeners) { listener.configurationChanged(changedParams); } } }
[ "@", "Override", "public", "void", "configurationChanged", "(", ")", "{", "HashSet", "<", "Param", ">", "changedParams", "=", "new", "HashSet", "(", ")", ";", "// read dynamic parameters", "for", "(", "Param", "param", ":", "parameters", ")", "{", "if", "(", "!", "param", ".", "isStatic", "(", ")", ")", "{", "// preserve current value", "Object", "oldValue", "=", "param", ".", "getValue", "(", ")", ";", "// read new value", "readAndValidateParameter", "(", "param", ")", ";", "// get if parameter value had changed", "if", "(", "!", "ConfigUtil", ".", "equalValues", "(", "oldValue", ",", "param", ".", "getValue", "(", ")", ")", ")", "{", "changedParams", ".", "add", "(", "param", ")", ";", "}", "}", "}", "// invoke listeners for all changed parameters", "if", "(", "!", "changedParams", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "ConfigChangeListener", "listener", ":", "configChangeListeners", ")", "{", "listener", ".", "configurationChanged", "(", "changedParams", ")", ";", "}", "}", "}" ]
notified on reload configuration event
[ "notified", "on", "reload", "configuration", "event" ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/validation/BaseConfiguration.java#L115-L148
148,751
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/system/NativeLibraryLoader.java
NativeLibraryLoader.loadLib
private Throwable loadLib(String _lib) { try { System.load(_lib); return null; } catch (Throwable _ex) { return _ex; } }
java
private Throwable loadLib(String _lib) { try { System.load(_lib); return null; } catch (Throwable _ex) { return _ex; } }
[ "private", "Throwable", "loadLib", "(", "String", "_lib", ")", "{", "try", "{", "System", ".", "load", "(", "_lib", ")", ";", "return", "null", ";", "}", "catch", "(", "Throwable", "_ex", ")", "{", "return", "_ex", ";", "}", "}" ]
Tries to load a library from the given path. Will catches exceptions and return them to the caller. Will return null if no exception has been thrown. @param _lib library @return null on success, {@link Throwable} otherwise
[ "Tries", "to", "load", "a", "library", "from", "the", "given", "path", ".", "Will", "catches", "exceptions", "and", "return", "them", "to", "the", "caller", ".", "Will", "return", "null", "if", "no", "exception", "has", "been", "thrown", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/system/NativeLibraryLoader.java#L179-L186
148,752
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/system/NativeLibraryLoader.java
NativeLibraryLoader.extractToTemp
private File extractToTemp(InputStream _fileToExtract, String _tmpName, String _fileSuffix) throws IOException { if (_fileToExtract == null) { throw new IOException("Null stream"); } File tempFile = File.createTempFile(_tmpName, _fileSuffix); tempFile.deleteOnExit(); if (!tempFile.exists()) { throw new FileNotFoundException("File " + tempFile.getAbsolutePath() + " could not be created"); } byte[] buffer = new byte[1024]; int readBytes; OutputStream os = new FileOutputStream(tempFile); try { while ((readBytes = _fileToExtract.read(buffer)) != -1) { os.write(buffer, 0, readBytes); } } finally { os.close(); _fileToExtract.close(); } return tempFile; }
java
private File extractToTemp(InputStream _fileToExtract, String _tmpName, String _fileSuffix) throws IOException { if (_fileToExtract == null) { throw new IOException("Null stream"); } File tempFile = File.createTempFile(_tmpName, _fileSuffix); tempFile.deleteOnExit(); if (!tempFile.exists()) { throw new FileNotFoundException("File " + tempFile.getAbsolutePath() + " could not be created"); } byte[] buffer = new byte[1024]; int readBytes; OutputStream os = new FileOutputStream(tempFile); try { while ((readBytes = _fileToExtract.read(buffer)) != -1) { os.write(buffer, 0, readBytes); } } finally { os.close(); _fileToExtract.close(); } return tempFile; }
[ "private", "File", "extractToTemp", "(", "InputStream", "_fileToExtract", ",", "String", "_tmpName", ",", "String", "_fileSuffix", ")", "throws", "IOException", "{", "if", "(", "_fileToExtract", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"Null stream\"", ")", ";", "}", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "_tmpName", ",", "_fileSuffix", ")", ";", "tempFile", ".", "deleteOnExit", "(", ")", ";", "if", "(", "!", "tempFile", ".", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"File \"", "+", "tempFile", ".", "getAbsolutePath", "(", ")", "+", "\" could not be created\"", ")", ";", "}", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "int", "readBytes", ";", "OutputStream", "os", "=", "new", "FileOutputStream", "(", "tempFile", ")", ";", "try", "{", "while", "(", "(", "readBytes", "=", "_fileToExtract", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "os", ".", "write", "(", "buffer", ",", "0", ",", "readBytes", ")", ";", "}", "}", "finally", "{", "os", ".", "close", "(", ")", ";", "_fileToExtract", ".", "close", "(", ")", ";", "}", "return", "tempFile", ";", "}" ]
Extract the file behind InputStream _fileToExtract to the tmp-folder. @param _fileToExtract InputStream with file to extract @param _tmpName temp file name @param _fileSuffix temp file suffix @return temp file object @throws IOException on any error
[ "Extract", "the", "file", "behind", "InputStream", "_fileToExtract", "to", "the", "tmp", "-", "folder", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/system/NativeLibraryLoader.java#L235-L259
148,753
kevoree/kevoree-library
toys/src/main/java/com/rendion/jchrome/JChromeTabbedPane.java
JChromeTabbedPane.mouseReleased
public void mouseReleased(MouseEvent e) { if (!hasFocus) { return; } boolean repaint = tabRowPainter.mouseReleased(e); if (!repaint) { repaint = toolbarPainter.mouseReleased(e); } }
java
public void mouseReleased(MouseEvent e) { if (!hasFocus) { return; } boolean repaint = tabRowPainter.mouseReleased(e); if (!repaint) { repaint = toolbarPainter.mouseReleased(e); } }
[ "public", "void", "mouseReleased", "(", "MouseEvent", "e", ")", "{", "if", "(", "!", "hasFocus", ")", "{", "return", ";", "}", "boolean", "repaint", "=", "tabRowPainter", ".", "mouseReleased", "(", "e", ")", ";", "if", "(", "!", "repaint", ")", "{", "repaint", "=", "toolbarPainter", ".", "mouseReleased", "(", "e", ")", ";", "}", "}" ]
the event was consumed - DO NOT PAINT
[ "the", "event", "was", "consumed", "-", "DO", "NOT", "PAINT" ]
617460e6c5881902ebc488a31ecdea179024d8f1
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/toys/src/main/java/com/rendion/jchrome/JChromeTabbedPane.java#L270-L281
148,754
ops4j/org.ops4j.pax.wicket
service/src/main/java/org/ops4j/pax/wicket/internal/servlet/ServletCallInterceptor.java
ServletCallInterceptor.isProxied
private boolean isProxied(HttpServletRequest httpServletRequest) { if (Proxy.isProxyClass(httpServletRequest.getClass())) { InvocationHandler handler = Proxy.getInvocationHandler(httpServletRequest); return handler instanceof ServletRequestInvocationHandler; } return false; }
java
private boolean isProxied(HttpServletRequest httpServletRequest) { if (Proxy.isProxyClass(httpServletRequest.getClass())) { InvocationHandler handler = Proxy.getInvocationHandler(httpServletRequest); return handler instanceof ServletRequestInvocationHandler; } return false; }
[ "private", "boolean", "isProxied", "(", "HttpServletRequest", "httpServletRequest", ")", "{", "if", "(", "Proxy", ".", "isProxyClass", "(", "httpServletRequest", ".", "getClass", "(", ")", ")", ")", "{", "InvocationHandler", "handler", "=", "Proxy", ".", "getInvocationHandler", "(", "httpServletRequest", ")", ";", "return", "handler", "instanceof", "ServletRequestInvocationHandler", ";", "}", "return", "false", ";", "}" ]
Check if this request is already proxied by pax wicket @param httpServletRequest @return true if the instance is a proxy and invocationhandler is a {@link ServletRequestInvocationHandler}
[ "Check", "if", "this", "request", "is", "already", "proxied", "by", "pax", "wicket" ]
ef7cb4bdf918e9e61ec69789b9c690567616faa9
https://github.com/ops4j/org.ops4j.pax.wicket/blob/ef7cb4bdf918e9e61ec69789b9c690567616faa9/service/src/main/java/org/ops4j/pax/wicket/internal/servlet/ServletCallInterceptor.java#L194-L200
148,755
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/interval/Relation.java
Relation.hasRelation
public boolean hasRelation(Interval interval1, Interval interval2) { if (interval1 == null || interval2 == null) { return false; } Long minStart1 = interval1.getMinimumStart(); Long maxStart1 = interval1.getMaximumStart(); Long minFinish1 = interval1.getMinimumFinish(); Long maxFinish1 = interval1.getMaximumFinish(); Long minStart2 = interval2.getMinimumStart(); Long maxStart2 = interval2.getMaximumStart(); Long minFinish2 = interval2.getMinimumFinish(); Long maxFinish2 = interval2.getMaximumFinish(); return evenHasRelationCheck(0, minStart1, minStart2) && oddHasRelationCheck(1, maxStart1, maxStart2) && evenHasRelationCheck(2, minStart1, minFinish2) && oddHasRelationCheck(3, maxStart1, maxFinish2) && evenHasRelationCheck(4, minFinish1, minStart2) && oddHasRelationCheck(5, maxFinish1, maxStart2) && evenHasRelationCheck(6, minFinish1, minFinish2) && oddHasRelationCheck(7, maxFinish1, maxFinish2); }
java
public boolean hasRelation(Interval interval1, Interval interval2) { if (interval1 == null || interval2 == null) { return false; } Long minStart1 = interval1.getMinimumStart(); Long maxStart1 = interval1.getMaximumStart(); Long minFinish1 = interval1.getMinimumFinish(); Long maxFinish1 = interval1.getMaximumFinish(); Long minStart2 = interval2.getMinimumStart(); Long maxStart2 = interval2.getMaximumStart(); Long minFinish2 = interval2.getMinimumFinish(); Long maxFinish2 = interval2.getMaximumFinish(); return evenHasRelationCheck(0, minStart1, minStart2) && oddHasRelationCheck(1, maxStart1, maxStart2) && evenHasRelationCheck(2, minStart1, minFinish2) && oddHasRelationCheck(3, maxStart1, maxFinish2) && evenHasRelationCheck(4, minFinish1, minStart2) && oddHasRelationCheck(5, maxFinish1, maxStart2) && evenHasRelationCheck(6, minFinish1, minFinish2) && oddHasRelationCheck(7, maxFinish1, maxFinish2); }
[ "public", "boolean", "hasRelation", "(", "Interval", "interval1", ",", "Interval", "interval2", ")", "{", "if", "(", "interval1", "==", "null", "||", "interval2", "==", "null", ")", "{", "return", "false", ";", "}", "Long", "minStart1", "=", "interval1", ".", "getMinimumStart", "(", ")", ";", "Long", "maxStart1", "=", "interval1", ".", "getMaximumStart", "(", ")", ";", "Long", "minFinish1", "=", "interval1", ".", "getMinimumFinish", "(", ")", ";", "Long", "maxFinish1", "=", "interval1", ".", "getMaximumFinish", "(", ")", ";", "Long", "minStart2", "=", "interval2", ".", "getMinimumStart", "(", ")", ";", "Long", "maxStart2", "=", "interval2", ".", "getMaximumStart", "(", ")", ";", "Long", "minFinish2", "=", "interval2", ".", "getMinimumFinish", "(", ")", ";", "Long", "maxFinish2", "=", "interval2", ".", "getMaximumFinish", "(", ")", ";", "return", "evenHasRelationCheck", "(", "0", ",", "minStart1", ",", "minStart2", ")", "&&", "oddHasRelationCheck", "(", "1", ",", "maxStart1", ",", "maxStart2", ")", "&&", "evenHasRelationCheck", "(", "2", ",", "minStart1", ",", "minFinish2", ")", "&&", "oddHasRelationCheck", "(", "3", ",", "maxStart1", ",", "maxFinish2", ")", "&&", "evenHasRelationCheck", "(", "4", ",", "minFinish1", ",", "minStart2", ")", "&&", "oddHasRelationCheck", "(", "5", ",", "maxFinish1", ",", "maxStart2", ")", "&&", "evenHasRelationCheck", "(", "6", ",", "minFinish1", ",", "minFinish2", ")", "&&", "oddHasRelationCheck", "(", "7", ",", "maxFinish1", ",", "maxFinish2", ")", ";", "}" ]
Determines whether the given intervals have this relation. @param interval1 the left-hand-side {@link Interval}. @param interval2 the right-hand-side {@link Interval}. @return <code>true</code> if the intervals have this relation, <code>false</code> otherwise. Returns <code>false</code> if any <code>null</code> arguments are given.
[ "Determines", "whether", "the", "given", "intervals", "have", "this", "relation", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/interval/Relation.java#L288-L308
148,756
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java
InputStreamTransform.transform
public byte[] transform(String className, File file) throws IOException, IllegalClassFormatException { try { return transform(className, new FileInputStream(file)); } catch (FileNotFoundException e){ throw new RuntimeException(e); } }
java
public byte[] transform(String className, File file) throws IOException, IllegalClassFormatException { try { return transform(className, new FileInputStream(file)); } catch (FileNotFoundException e){ throw new RuntimeException(e); } }
[ "public", "byte", "[", "]", "transform", "(", "String", "className", ",", "File", "file", ")", "throws", "IOException", ",", "IllegalClassFormatException", "{", "try", "{", "return", "transform", "(", "className", ",", "new", "FileInputStream", "(", "file", ")", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Transform a file.
[ "Transform", "a", "file", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java#L39-L46
148,757
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java
InputStreamTransform.transform
public byte[] transform(String className, InputStream is) throws IOException, IllegalClassFormatException { try { byte[] classBytes = readBytes(is); return transformer.transform(classLoader, className, null, null, classBytes); } finally { if (is != null){ is.close(); } } }
java
public byte[] transform(String className, InputStream is) throws IOException, IllegalClassFormatException { try { byte[] classBytes = readBytes(is); return transformer.transform(classLoader, className, null, null, classBytes); } finally { if (is != null){ is.close(); } } }
[ "public", "byte", "[", "]", "transform", "(", "String", "className", ",", "InputStream", "is", ")", "throws", "IOException", ",", "IllegalClassFormatException", "{", "try", "{", "byte", "[", "]", "classBytes", "=", "readBytes", "(", "is", ")", ";", "return", "transformer", ".", "transform", "(", "classLoader", ",", "className", ",", "null", ",", "null", ",", "classBytes", ")", ";", "}", "finally", "{", "if", "(", "is", "!=", "null", ")", "{", "is", ".", "close", "(", ")", ";", "}", "}", "}" ]
Transform a input stream.
[ "Transform", "a", "input", "stream", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java#L51-L64
148,758
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java
InputStreamTransform.writeBytes
public static void writeBytes(byte[] bytes, OutputStream os) throws IOException { BufferedOutputStream bos = new BufferedOutputStream(os); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); byte[] buf = new byte[1028]; int len; while ((len = bis.read(buf, 0, buf.length)) > -1){ bos.write(buf, 0, len); } bos.flush(); bos.close(); bis.close(); }
java
public static void writeBytes(byte[] bytes, OutputStream os) throws IOException { BufferedOutputStream bos = new BufferedOutputStream(os); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); byte[] buf = new byte[1028]; int len; while ((len = bis.read(buf, 0, buf.length)) > -1){ bos.write(buf, 0, len); } bos.flush(); bos.close(); bis.close(); }
[ "public", "static", "void", "writeBytes", "(", "byte", "[", "]", "bytes", ",", "OutputStream", "os", ")", "throws", "IOException", "{", "BufferedOutputStream", "bos", "=", "new", "BufferedOutputStream", "(", "os", ")", ";", "ByteArrayInputStream", "bis", "=", "new", "ByteArrayInputStream", "(", "bytes", ")", ";", "byte", "[", "]", "buf", "=", "new", "byte", "[", "1028", "]", ";", "int", "len", ";", "while", "(", "(", "len", "=", "bis", ".", "read", "(", "buf", ",", "0", ",", "buf", ".", "length", ")", ")", ">", "-", "1", ")", "{", "bos", ".", "write", "(", "buf", ",", "0", ",", "len", ")", ";", "}", "bos", ".", "flush", "(", ")", ";", "bos", ".", "close", "(", ")", ";", "bis", ".", "close", "(", ")", ";", "}" ]
Helper method to write bytes to a OutputStream.
[ "Helper", "method", "to", "write", "bytes", "to", "a", "OutputStream", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/offline/InputStreamTransform.java#L76-L93
148,759
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.init
@Override public void init(final String scope) throws InitializationException, InterruptedException { try { init(ScopeProcessor.generateScope(scope)); } catch (CouldNotPerformException | NullPointerException ex) { throw new InitializationException(this, ex); } }
java
@Override public void init(final String scope) throws InitializationException, InterruptedException { try { init(ScopeProcessor.generateScope(scope)); } catch (CouldNotPerformException | NullPointerException ex) { throw new InitializationException(this, ex); } }
[ "@", "Override", "public", "void", "init", "(", "final", "String", "scope", ")", "throws", "InitializationException", ",", "InterruptedException", "{", "try", "{", "init", "(", "ScopeProcessor", ".", "generateScope", "(", "scope", ")", ")", ";", "}", "catch", "(", "CouldNotPerformException", "|", "NullPointerException", "ex", ")", "{", "throw", "new", "InitializationException", "(", "this", ",", "ex", ")", ";", "}", "}" ]
Initialize the remote on a scope. @param scope the scope where the remote communicates @throws InitializationException if the initialization fails @throws InterruptedException if the initialization is interrupted
[ "Initialize", "the", "remote", "on", "a", "scope", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L167-L174
148,760
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.unlock
@Override public void unlock(final Object maintainer) throws CouldNotPerformException { synchronized (maintainerLock) { if (this.maintainer != null && this.maintainer != maintainer) { throw new CouldNotPerformException("Could not unlock remote because it is locked by another instance!"); } this.maintainer = null; } }
java
@Override public void unlock(final Object maintainer) throws CouldNotPerformException { synchronized (maintainerLock) { if (this.maintainer != null && this.maintainer != maintainer) { throw new CouldNotPerformException("Could not unlock remote because it is locked by another instance!"); } this.maintainer = null; } }
[ "@", "Override", "public", "void", "unlock", "(", "final", "Object", "maintainer", ")", "throws", "CouldNotPerformException", "{", "synchronized", "(", "maintainerLock", ")", "{", "if", "(", "this", ".", "maintainer", "!=", "null", "&&", "this", ".", "maintainer", "!=", "maintainer", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Could not unlock remote because it is locked by another instance!\"", ")", ";", "}", "this", ".", "maintainer", "=", "null", ";", "}", "}" ]
Method unlocks this instance. @param maintainer the instance which currently holds the lock. @throws CouldNotPerformException is thrown if the instance could not be unlocked.
[ "Method", "unlocks", "this", "instance", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L329-L337
148,761
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.addHandler
public void addHandler(final Handler handler, final boolean wait) throws InterruptedException, CouldNotPerformException { try { listener.addHandler(handler, wait); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not register Handler!", ex); } }
java
public void addHandler(final Handler handler, final boolean wait) throws InterruptedException, CouldNotPerformException { try { listener.addHandler(handler, wait); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not register Handler!", ex); } }
[ "public", "void", "addHandler", "(", "final", "Handler", "handler", ",", "final", "boolean", "wait", ")", "throws", "InterruptedException", ",", "CouldNotPerformException", "{", "try", "{", "listener", ".", "addHandler", "(", "handler", ",", "wait", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Could not register Handler!\"", ",", "ex", ")", ";", "}", "}" ]
Method adds an handler to the internal rsb listener. @param handler @param wait @throws InterruptedException @throws CouldNotPerformException
[ "Method", "adds", "an", "handler", "to", "the", "internal", "rsb", "listener", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L358-L364
148,762
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.deactivate
public void deactivate(final Object maintainer) throws InterruptedException, CouldNotPerformException, VerificationFailedException { if (this.maintainer.equals(maintainer)) { synchronized (maintainerLock) { unlock(maintainer); deactivate(); lock(maintainer); } } else { throw new VerificationFailedException("[" + maintainer + "] is not the current maintainer of this remote"); } }
java
public void deactivate(final Object maintainer) throws InterruptedException, CouldNotPerformException, VerificationFailedException { if (this.maintainer.equals(maintainer)) { synchronized (maintainerLock) { unlock(maintainer); deactivate(); lock(maintainer); } } else { throw new VerificationFailedException("[" + maintainer + "] is not the current maintainer of this remote"); } }
[ "public", "void", "deactivate", "(", "final", "Object", "maintainer", ")", "throws", "InterruptedException", ",", "CouldNotPerformException", ",", "VerificationFailedException", "{", "if", "(", "this", ".", "maintainer", ".", "equals", "(", "maintainer", ")", ")", "{", "synchronized", "(", "maintainerLock", ")", "{", "unlock", "(", "maintainer", ")", ";", "deactivate", "(", ")", ";", "lock", "(", "maintainer", ")", ";", "}", "}", "else", "{", "throw", "new", "VerificationFailedException", "(", "\"[\"", "+", "maintainer", "+", "\"] is not the current maintainer of this remote\"", ")", ";", "}", "}" ]
Atomic deactivate which makes sure that the maintainer stays the same. @param maintainer the current maintainer of this remote @throws InterruptedException if deactivation is interrupted @throws CouldNotPerformException if deactivation fails @throws VerificationFailedException is thrown if the given maintainer does not match the current one
[ "Atomic", "deactivate", "which", "makes", "sure", "that", "the", "maintainer", "stays", "the", "same", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L441-L451
148,763
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.sync
private Future<M> sync() { logger.debug("Synchronization of Remote[" + this + "] triggered..."); try { validateInitialization(); try { SyncTaskCallable syncCallable = new SyncTaskCallable(); final Future<M> currentSyncTask = GlobalCachedExecutorService.submit(syncCallable); syncCallable.setRelatedFuture(currentSyncTask); return currentSyncTask; } catch (java.util.concurrent.RejectedExecutionException | NullPointerException ex) { throw new CouldNotPerformException("Could not request the current status.", ex); } } catch (CouldNotPerformException ex) { return FutureProcessor.canceledFuture(ex); } }
java
private Future<M> sync() { logger.debug("Synchronization of Remote[" + this + "] triggered..."); try { validateInitialization(); try { SyncTaskCallable syncCallable = new SyncTaskCallable(); final Future<M> currentSyncTask = GlobalCachedExecutorService.submit(syncCallable); syncCallable.setRelatedFuture(currentSyncTask); return currentSyncTask; } catch (java.util.concurrent.RejectedExecutionException | NullPointerException ex) { throw new CouldNotPerformException("Could not request the current status.", ex); } } catch (CouldNotPerformException ex) { return FutureProcessor.canceledFuture(ex); } }
[ "private", "Future", "<", "M", ">", "sync", "(", ")", "{", "logger", ".", "debug", "(", "\"Synchronization of Remote[\"", "+", "this", "+", "\"] triggered...\"", ")", ";", "try", "{", "validateInitialization", "(", ")", ";", "try", "{", "SyncTaskCallable", "syncCallable", "=", "new", "SyncTaskCallable", "(", ")", ";", "final", "Future", "<", "M", ">", "currentSyncTask", "=", "GlobalCachedExecutorService", ".", "submit", "(", "syncCallable", ")", ";", "syncCallable", ".", "setRelatedFuture", "(", "currentSyncTask", ")", ";", "return", "currentSyncTask", ";", "}", "catch", "(", "java", ".", "util", ".", "concurrent", ".", "RejectedExecutionException", "|", "NullPointerException", "ex", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Could not request the current status.\"", ",", "ex", ")", ";", "}", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "return", "FutureProcessor", ".", "canceledFuture", "(", "ex", ")", ";", "}", "}" ]
Method forces a server - remote data sync and returns the new acquired data. Can be useful for initial data sync or data sync after reconnection. @return fresh synchronized data object.
[ "Method", "forces", "a", "server", "-", "remote", "data", "sync", "and", "returns", "the", "new", "acquired", "data", ".", "Can", "be", "useful", "for", "initial", "data", "sync", "or", "data", "sync", "after", "reconnection", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L983-L999
148,764
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.shutdown
@Override public void shutdown() { try { verifyMaintainability(); } catch (VerificationFailedException ex) { throw new RuntimeException("Can not shutdown " + this + "!", ex); } this.shutdownInitiated = true; try { dataObservable.shutdown(); } finally { try { deactivate(); } catch (CouldNotPerformException | InterruptedException ex) { ExceptionPrinter.printHistory("Could not shutdown " + this + "!", ex, logger); } } }
java
@Override public void shutdown() { try { verifyMaintainability(); } catch (VerificationFailedException ex) { throw new RuntimeException("Can not shutdown " + this + "!", ex); } this.shutdownInitiated = true; try { dataObservable.shutdown(); } finally { try { deactivate(); } catch (CouldNotPerformException | InterruptedException ex) { ExceptionPrinter.printHistory("Could not shutdown " + this + "!", ex, logger); } } }
[ "@", "Override", "public", "void", "shutdown", "(", ")", "{", "try", "{", "verifyMaintainability", "(", ")", ";", "}", "catch", "(", "VerificationFailedException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Can not shutdown \"", "+", "this", "+", "\"!\"", ",", "ex", ")", ";", "}", "this", ".", "shutdownInitiated", "=", "true", ";", "try", "{", "dataObservable", ".", "shutdown", "(", ")", ";", "}", "finally", "{", "try", "{", "deactivate", "(", ")", ";", "}", "catch", "(", "CouldNotPerformException", "|", "InterruptedException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"Could not shutdown \"", "+", "this", "+", "\"!\"", ",", "ex", ",", "logger", ")", ";", "}", "}", "}" ]
This method deactivates the remote and cleans all resources.
[ "This", "method", "deactivates", "the", "remote", "and", "cleans", "all", "resources", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1079-L1097
148,765
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.notifyPrioritizedObservers
private void notifyPrioritizedObservers(final M data) throws CouldNotPerformException { try { internalPrioritizedDataObservable.notifyObservers(data); } catch (CouldNotPerformException ex) { throw ex; } finally { long newTransactionId = (Long) getDataField(TransactionIdProvider.TRANSACTION_ID_FIELD_NAME); // warn if the transaction id is outdated, additionally the 0 transaction is accepted which is broadcast during the controller startup after. if (newTransactionId < transactionId && transactionId != 0) { logger.warn("RemoteService {} received a data object with an older transaction id {} than {}", this, newTransactionId, transactionId); } transactionId = newTransactionId; } }
java
private void notifyPrioritizedObservers(final M data) throws CouldNotPerformException { try { internalPrioritizedDataObservable.notifyObservers(data); } catch (CouldNotPerformException ex) { throw ex; } finally { long newTransactionId = (Long) getDataField(TransactionIdProvider.TRANSACTION_ID_FIELD_NAME); // warn if the transaction id is outdated, additionally the 0 transaction is accepted which is broadcast during the controller startup after. if (newTransactionId < transactionId && transactionId != 0) { logger.warn("RemoteService {} received a data object with an older transaction id {} than {}", this, newTransactionId, transactionId); } transactionId = newTransactionId; } }
[ "private", "void", "notifyPrioritizedObservers", "(", "final", "M", "data", ")", "throws", "CouldNotPerformException", "{", "try", "{", "internalPrioritizedDataObservable", ".", "notifyObservers", "(", "data", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "long", "newTransactionId", "=", "(", "Long", ")", "getDataField", "(", "TransactionIdProvider", ".", "TRANSACTION_ID_FIELD_NAME", ")", ";", "// warn if the transaction id is outdated, additionally the 0 transaction is accepted which is broadcast during the controller startup after.", "if", "(", "newTransactionId", "<", "transactionId", "&&", "transactionId", "!=", "0", ")", "{", "logger", ".", "warn", "(", "\"RemoteService {} received a data object with an older transaction id {} than {}\"", ",", "this", ",", "newTransactionId", ",", "transactionId", ")", ";", "}", "transactionId", "=", "newTransactionId", ";", "}", "}" ]
Notify all observers registered on the prioritized observable and retrieve the new transaction id. The transaction id is updated here to guarantee that the prioritized observables have been notified before transaction sync futures return. @param data the data type notified. @throws CouldNotPerformException if notification fails or no transaction id could be extracted.
[ "Notify", "all", "observers", "registered", "on", "the", "prioritized", "observable", "and", "retrieve", "the", "new", "transaction", "id", ".", "The", "transaction", "id", "is", "updated", "here", "to", "guarantee", "that", "the", "prioritized", "observables", "have", "been", "notified", "before", "transaction", "sync", "futures", "return", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1140-L1154
148,766
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.waitForConnectionState
@Override public void waitForConnectionState(final ConnectionState.State connectionState, long timeout) throws InterruptedException, TimeoutException, CouldNotPerformException { synchronized (connectionMonitor) { boolean delayDetected = false; while (!Thread.currentThread().isInterrupted()) { // check if requested connection state is reached. if (this.connectionState.equals(connectionState)) { if (delayDetected) { logger.info("Continue processing because " + getClass().getSimpleName().replace("Remote", "") + "[" + getScopeStringRep() + "] is now " + this.connectionState.name().toLowerCase() + "."); } return; } failOnShutdown("Waiting for connectionState[" + connectionState.name() + "] in connectionState[" + this.connectionState.name() + "] on shutdown"); // detect delay for long term wait if (timeout == 0) { connectionMonitor.wait(15000); if (!this.connectionState.equals(connectionState)) { failOnShutdown("Waiting for connectionState[" + connectionState.name() + "] in connectionState[" + this.connectionState.name() + "] on shutdown"); delayDetected = true; logger.info("Wait for " + this.connectionState.name().toLowerCase() + " " + getClass().getSimpleName().replace("Remote", "") + "[" + getScopeStringRep() + "] to be " + connectionState.name().toLowerCase() + "..."); connectionMonitor.wait(); } continue; } // wait till timeout connectionMonitor.wait(timeout); if (timeout != 0 && !this.connectionState.equals(connectionState)) { throw new TimeoutException("Timeout expired!"); } } } }
java
@Override public void waitForConnectionState(final ConnectionState.State connectionState, long timeout) throws InterruptedException, TimeoutException, CouldNotPerformException { synchronized (connectionMonitor) { boolean delayDetected = false; while (!Thread.currentThread().isInterrupted()) { // check if requested connection state is reached. if (this.connectionState.equals(connectionState)) { if (delayDetected) { logger.info("Continue processing because " + getClass().getSimpleName().replace("Remote", "") + "[" + getScopeStringRep() + "] is now " + this.connectionState.name().toLowerCase() + "."); } return; } failOnShutdown("Waiting for connectionState[" + connectionState.name() + "] in connectionState[" + this.connectionState.name() + "] on shutdown"); // detect delay for long term wait if (timeout == 0) { connectionMonitor.wait(15000); if (!this.connectionState.equals(connectionState)) { failOnShutdown("Waiting for connectionState[" + connectionState.name() + "] in connectionState[" + this.connectionState.name() + "] on shutdown"); delayDetected = true; logger.info("Wait for " + this.connectionState.name().toLowerCase() + " " + getClass().getSimpleName().replace("Remote", "") + "[" + getScopeStringRep() + "] to be " + connectionState.name().toLowerCase() + "..."); connectionMonitor.wait(); } continue; } // wait till timeout connectionMonitor.wait(timeout); if (timeout != 0 && !this.connectionState.equals(connectionState)) { throw new TimeoutException("Timeout expired!"); } } } }
[ "@", "Override", "public", "void", "waitForConnectionState", "(", "final", "ConnectionState", ".", "State", "connectionState", ",", "long", "timeout", ")", "throws", "InterruptedException", ",", "TimeoutException", ",", "CouldNotPerformException", "{", "synchronized", "(", "connectionMonitor", ")", "{", "boolean", "delayDetected", "=", "false", ";", "while", "(", "!", "Thread", ".", "currentThread", "(", ")", ".", "isInterrupted", "(", ")", ")", "{", "// check if requested connection state is reached.", "if", "(", "this", ".", "connectionState", ".", "equals", "(", "connectionState", ")", ")", "{", "if", "(", "delayDetected", ")", "{", "logger", ".", "info", "(", "\"Continue processing because \"", "+", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ".", "replace", "(", "\"Remote\"", ",", "\"\"", ")", "+", "\"[\"", "+", "getScopeStringRep", "(", ")", "+", "\"] is now \"", "+", "this", ".", "connectionState", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", "+", "\".\"", ")", ";", "}", "return", ";", "}", "failOnShutdown", "(", "\"Waiting for connectionState[\"", "+", "connectionState", ".", "name", "(", ")", "+", "\"] in connectionState[\"", "+", "this", ".", "connectionState", ".", "name", "(", ")", "+", "\"] on shutdown\"", ")", ";", "// detect delay for long term wait", "if", "(", "timeout", "==", "0", ")", "{", "connectionMonitor", ".", "wait", "(", "15000", ")", ";", "if", "(", "!", "this", ".", "connectionState", ".", "equals", "(", "connectionState", ")", ")", "{", "failOnShutdown", "(", "\"Waiting for connectionState[\"", "+", "connectionState", ".", "name", "(", ")", "+", "\"] in connectionState[\"", "+", "this", ".", "connectionState", ".", "name", "(", ")", "+", "\"] on shutdown\"", ")", ";", "delayDetected", "=", "true", ";", "logger", ".", "info", "(", "\"Wait for \"", "+", "this", ".", "connectionState", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", "+", "\" \"", "+", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ".", "replace", "(", "\"Remote\"", ",", "\"\"", ")", "+", "\"[\"", "+", "getScopeStringRep", "(", ")", "+", "\"] to be \"", "+", "connectionState", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", "+", "\"...\"", ")", ";", "connectionMonitor", ".", "wait", "(", ")", ";", "}", "continue", ";", "}", "// wait till timeout", "connectionMonitor", ".", "wait", "(", "timeout", ")", ";", "if", "(", "timeout", "!=", "0", "&&", "!", "this", ".", "connectionState", ".", "equals", "(", "connectionState", ")", ")", "{", "throw", "new", "TimeoutException", "(", "\"Timeout expired!\"", ")", ";", "}", "}", "}", "}" ]
Method blocks until the remote reaches the desired connection state. In case the timeout is expired an TimeoutException will be thrown. @param connectionState the desired connection state @param timeout the timeout in milliseconds until the method throw a TimeoutException in case the connection state was not reached. @throws InterruptedException is thrown in case the thread is externally interrupted. @throws org.openbase.jul.exception.TimeoutException is thrown in case the timeout is expired without reaching the connection state. @throws org.openbase.jul.exception.CouldNotPerformException is thrown in case the connection state does not match and the shutdown of this remote has been initialized
[ "Method", "blocks", "until", "the", "remote", "reaches", "the", "desired", "connection", "state", ".", "In", "case", "the", "timeout", "is", "expired", "an", "TimeoutException", "will", "be", "thrown", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1321-L1356
148,767
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.waitForConnectionState
public void waitForConnectionState(final ConnectionState.State connectionState) throws InterruptedException, CouldNotPerformException { try { waitForConnectionState(connectionState, 0); } catch (TimeoutException ex) { assert false; } }
java
public void waitForConnectionState(final ConnectionState.State connectionState) throws InterruptedException, CouldNotPerformException { try { waitForConnectionState(connectionState, 0); } catch (TimeoutException ex) { assert false; } }
[ "public", "void", "waitForConnectionState", "(", "final", "ConnectionState", ".", "State", "connectionState", ")", "throws", "InterruptedException", ",", "CouldNotPerformException", "{", "try", "{", "waitForConnectionState", "(", "connectionState", ",", "0", ")", ";", "}", "catch", "(", "TimeoutException", "ex", ")", "{", "assert", "false", ";", "}", "}" ]
Method blocks until the remote reaches the desired connection state. @param connectionState the desired connection state @throws InterruptedException is thrown in case the thread is externally interrupted. @throws org.openbase.jul.exception.CouldNotPerformException is thrown in case the the remote is not active and the waiting condition is based on ConnectionState.State CONNECTED or CONNECTING.
[ "Method", "blocks", "until", "the", "remote", "reaches", "the", "desired", "connection", "state", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1382-L1388
148,768
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
AbstractRemoteClient.applyDataUpdate
private void applyDataUpdate(final M data) { this.data = data; CompletableFutureLite<M> currentSyncFuture = null; Future<M> currentSyncTask = null; // Check if sync is in process. synchronized (syncMonitor) { if (syncFuture != null) { currentSyncFuture = syncFuture; currentSyncTask = syncTask; syncFuture = null; syncTask = null; } } if (currentSyncFuture != null) { currentSyncFuture.complete(data); } if (currentSyncTask != null && !currentSyncTask.isDone()) { currentSyncTask.cancel(false); } setConnectionState(CONNECTED); // Notify data update try { notifyPrioritizedObservers(data); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update!", ex), logger); } try { dataObservable.notifyObservers(data); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update to all observer!", ex), logger); } }
java
private void applyDataUpdate(final M data) { this.data = data; CompletableFutureLite<M> currentSyncFuture = null; Future<M> currentSyncTask = null; // Check if sync is in process. synchronized (syncMonitor) { if (syncFuture != null) { currentSyncFuture = syncFuture; currentSyncTask = syncTask; syncFuture = null; syncTask = null; } } if (currentSyncFuture != null) { currentSyncFuture.complete(data); } if (currentSyncTask != null && !currentSyncTask.isDone()) { currentSyncTask.cancel(false); } setConnectionState(CONNECTED); // Notify data update try { notifyPrioritizedObservers(data); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update!", ex), logger); } try { dataObservable.notifyObservers(data); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update to all observer!", ex), logger); } }
[ "private", "void", "applyDataUpdate", "(", "final", "M", "data", ")", "{", "this", ".", "data", "=", "data", ";", "CompletableFutureLite", "<", "M", ">", "currentSyncFuture", "=", "null", ";", "Future", "<", "M", ">", "currentSyncTask", "=", "null", ";", "// Check if sync is in process.", "synchronized", "(", "syncMonitor", ")", "{", "if", "(", "syncFuture", "!=", "null", ")", "{", "currentSyncFuture", "=", "syncFuture", ";", "currentSyncTask", "=", "syncTask", ";", "syncFuture", "=", "null", ";", "syncTask", "=", "null", ";", "}", "}", "if", "(", "currentSyncFuture", "!=", "null", ")", "{", "currentSyncFuture", ".", "complete", "(", "data", ")", ";", "}", "if", "(", "currentSyncTask", "!=", "null", "&&", "!", "currentSyncTask", ".", "isDone", "(", ")", ")", "{", "currentSyncTask", ".", "cancel", "(", "false", ")", ";", "}", "setConnectionState", "(", "CONNECTED", ")", ";", "// Notify data update", "try", "{", "notifyPrioritizedObservers", "(", "data", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Could not notify data update!\"", ",", "ex", ")", ",", "logger", ")", ";", "}", "try", "{", "dataObservable", ".", "notifyObservers", "(", "data", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Could not notify data update to all observer!\"", ",", "ex", ")", ",", "logger", ")", ";", "}", "}" ]
Method is used to internally update the data object. @param data
[ "Method", "is", "used", "to", "internally", "update", "the", "data", "object", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java#L1410-L1447
148,769
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java
ValueSet.isInValueSet
public boolean isInValueSet(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } boolean result = true; if (!this.valuesKeySet.isEmpty()) { result = this.valuesKeySet.contains(value); } else if (this.lowerBound != null || this.upperBound != null) { if (this.lowerBound != null && !ValueComparator.GREATER_THAN_OR_EQUAL_TO.compare( value, this.lowerBound)) { result = false; } if (this.upperBound != null && !ValueComparator.LESS_THAN_OR_EQUAL_TO.compare( value, this.upperBound)) { result = false; } } return result; }
java
public boolean isInValueSet(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } boolean result = true; if (!this.valuesKeySet.isEmpty()) { result = this.valuesKeySet.contains(value); } else if (this.lowerBound != null || this.upperBound != null) { if (this.lowerBound != null && !ValueComparator.GREATER_THAN_OR_EQUAL_TO.compare( value, this.lowerBound)) { result = false; } if (this.upperBound != null && !ValueComparator.LESS_THAN_OR_EQUAL_TO.compare( value, this.upperBound)) { result = false; } } return result; }
[ "public", "boolean", "isInValueSet", "(", "Value", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"value cannot be null\"", ")", ";", "}", "boolean", "result", "=", "true", ";", "if", "(", "!", "this", ".", "valuesKeySet", ".", "isEmpty", "(", ")", ")", "{", "result", "=", "this", ".", "valuesKeySet", ".", "contains", "(", "value", ")", ";", "}", "else", "if", "(", "this", ".", "lowerBound", "!=", "null", "||", "this", ".", "upperBound", "!=", "null", ")", "{", "if", "(", "this", ".", "lowerBound", "!=", "null", "&&", "!", "ValueComparator", ".", "GREATER_THAN_OR_EQUAL_TO", ".", "compare", "(", "value", ",", "this", ".", "lowerBound", ")", ")", "{", "result", "=", "false", ";", "}", "if", "(", "this", ".", "upperBound", "!=", "null", "&&", "!", "ValueComparator", ".", "LESS_THAN_OR_EQUAL_TO", ".", "compare", "(", "value", ",", "this", ".", "upperBound", ")", ")", "{", "result", "=", "false", ";", "}", "}", "return", "result", ";", "}" ]
Returns whether the specified value is in the value set. @param value a {@link Value}. Cannot be <code>null</code>. @return <code>true</code> or <code>false</code>.
[ "Returns", "whether", "the", "specified", "value", "is", "in", "the", "value", "set", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java#L187-L208
148,770
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java
ValueSet.displayName
public String displayName(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } ValueSetElement vse = this.values.get(value); if (vse != null) { return vse.getDisplayName(); } else { return ""; } }
java
public String displayName(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } ValueSetElement vse = this.values.get(value); if (vse != null) { return vse.getDisplayName(); } else { return ""; } }
[ "public", "String", "displayName", "(", "Value", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"value cannot be null\"", ")", ";", "}", "ValueSetElement", "vse", "=", "this", ".", "values", ".", "get", "(", "value", ")", ";", "if", "(", "vse", "!=", "null", ")", "{", "return", "vse", ".", "getDisplayName", "(", ")", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Returns a display name for the specified value, if one is defined. @param value a {@link Value}. Cannot be <code>null</code>. @return a {@link String}.
[ "Returns", "a", "display", "name", "for", "the", "specified", "value", "if", "one", "is", "defined", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java#L216-L227
148,771
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java
ValueSet.abbrevDisplayName
public String abbrevDisplayName(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } ValueSetElement vse = this.values.get(value); if (vse != null) { return vse.getAbbrevDisplayName(); } else { return ""; } }
java
public String abbrevDisplayName(Value value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } ValueSetElement vse = this.values.get(value); if (vse != null) { return vse.getAbbrevDisplayName(); } else { return ""; } }
[ "public", "String", "abbrevDisplayName", "(", "Value", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"value cannot be null\"", ")", ";", "}", "ValueSetElement", "vse", "=", "this", ".", "values", ".", "get", "(", "value", ")", ";", "if", "(", "vse", "!=", "null", ")", "{", "return", "vse", ".", "getAbbrevDisplayName", "(", ")", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Returns an abbreviated display name for the specified value, if one is defined. @param value a {@link Value}. Cannot be <code>null</code>. @return a {@link String}.
[ "Returns", "an", "abbreviated", "display", "name", "for", "the", "specified", "value", "if", "one", "is", "defined", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/valueset/ValueSet.java#L236-L247
148,772
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.isAnyNull
public static boolean isAnyNull(Object... _objects) { if (_objects == null) { return true; } for (Object obj : _objects) { if (obj == null) { return true; } } return false; }
java
public static boolean isAnyNull(Object... _objects) { if (_objects == null) { return true; } for (Object obj : _objects) { if (obj == null) { return true; } } return false; }
[ "public", "static", "boolean", "isAnyNull", "(", "Object", "...", "_objects", ")", "{", "if", "(", "_objects", "==", "null", ")", "{", "return", "true", ";", "}", "for", "(", "Object", "obj", ":", "_objects", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if any of the passed in objects is null. @param _objects array of objects, may be null @return true if null found, false otherwise
[ "Checks", "if", "any", "of", "the", "passed", "in", "objects", "is", "null", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L21-L31
148,773
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.isAnyFileMissing
public static String isAnyFileMissing(File... _files) { if (_files == null) { return "null"; } for (File obj : _files) { if (obj != null && !obj.exists()) { return obj.toString(); } else if (obj == null) { return null; } } return null; }
java
public static String isAnyFileMissing(File... _files) { if (_files == null) { return "null"; } for (File obj : _files) { if (obj != null && !obj.exists()) { return obj.toString(); } else if (obj == null) { return null; } } return null; }
[ "public", "static", "String", "isAnyFileMissing", "(", "File", "...", "_files", ")", "{", "if", "(", "_files", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "for", "(", "File", "obj", ":", "_files", ")", "{", "if", "(", "obj", "!=", "null", "&&", "!", "obj", ".", "exists", "(", ")", ")", "{", "return", "obj", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "obj", "==", "null", ")", "{", "return", "null", ";", "}", "}", "return", "null", ";", "}" ]
Checks if any of the passed in files are non-existing. @param _files array of files @return the filename of the missing file, otherwise returns null.
[ "Checks", "if", "any", "of", "the", "passed", "in", "files", "are", "non", "-", "existing", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L50-L62
148,774
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.equalsOne
public static boolean equalsOne(Object _obj, Object... _arrObj) { if (_obj == null || _arrObj == null) { return false; } for (Object o : _arrObj) { if (o != null && _obj.equals(o)) { return true; } } return false; }
java
public static boolean equalsOne(Object _obj, Object... _arrObj) { if (_obj == null || _arrObj == null) { return false; } for (Object o : _arrObj) { if (o != null && _obj.equals(o)) { return true; } } return false; }
[ "public", "static", "boolean", "equalsOne", "(", "Object", "_obj", ",", "Object", "...", "_arrObj", ")", "{", "if", "(", "_obj", "==", "null", "||", "_arrObj", "==", "null", ")", "{", "return", "false", ";", "}", "for", "(", "Object", "o", ":", "_arrObj", ")", "{", "if", "(", "o", "!=", "null", "&&", "_obj", ".", "equals", "(", "o", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the specified object equals at least one of the specified other objects. @param _obj object @param _arrObj array of objects to compare to @return true if equal, false otherwise or if either parameter is null
[ "Returns", "true", "if", "the", "specified", "object", "equals", "at", "least", "one", "of", "the", "specified", "other", "objects", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L96-L106
148,775
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.mapContainsKeys
public static boolean mapContainsKeys(Map<?, ?> _map, Object... _keys) { if (_map == null) { return false; } else if (_keys == null) { return true; } for (Object key : _keys) { if (key != null && !_map.containsKey(key)) { return false; } } return true; }
java
public static boolean mapContainsKeys(Map<?, ?> _map, Object... _keys) { if (_map == null) { return false; } else if (_keys == null) { return true; } for (Object key : _keys) { if (key != null && !_map.containsKey(key)) { return false; } } return true; }
[ "public", "static", "boolean", "mapContainsKeys", "(", "Map", "<", "?", ",", "?", ">", "_map", ",", "Object", "...", "_keys", ")", "{", "if", "(", "_map", "==", "null", ")", "{", "return", "false", ";", "}", "else", "if", "(", "_keys", "==", "null", ")", "{", "return", "true", ";", "}", "for", "(", "Object", "key", ":", "_keys", ")", "{", "if", "(", "key", "!=", "null", "&&", "!", "_map", ".", "containsKey", "(", "key", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks whether a map contains all of the specified keys. @param _map map @param _keys one or more keys @return true if all keys found in map, false otherwise
[ "Checks", "whether", "a", "map", "contains", "all", "of", "the", "specified", "keys", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L114-L126
148,776
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.startsWithAny
public static boolean startsWithAny(String _str, String... _startStrings) { if (_str == null || _startStrings == null || _startStrings.length == 0) { return false; } for (String start : _startStrings) { if (_str.startsWith(start)) { return true; } } return false; }
java
public static boolean startsWithAny(String _str, String... _startStrings) { if (_str == null || _startStrings == null || _startStrings.length == 0) { return false; } for (String start : _startStrings) { if (_str.startsWith(start)) { return true; } } return false; }
[ "public", "static", "boolean", "startsWithAny", "(", "String", "_str", ",", "String", "...", "_startStrings", ")", "{", "if", "(", "_str", "==", "null", "||", "_startStrings", "==", "null", "||", "_startStrings", ".", "length", "==", "0", ")", "{", "return", "false", ";", "}", "for", "(", "String", "start", ":", "_startStrings", ")", "{", "if", "(", "_str", ".", "startsWith", "(", "start", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if given String starts with any of the other given parameters. @param _str string to check @param _startStrings start strings to compare @return true if any match, false otherwise
[ "Checks", "if", "given", "String", "starts", "with", "any", "of", "the", "other", "given", "parameters", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L135-L147
148,777
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/AbstractPropositionDefinition.java
AbstractPropositionDefinition.setInverseIsA
public void setInverseIsA(String... inverseIsA) { ProtempaUtil.checkArrayForNullElement(inverseIsA, "inverseIsA"); ProtempaUtil.checkArrayForDuplicates(inverseIsA, "inverseIsA"); this.inverseIsA = inverseIsA.clone(); recalculateChildren(); }
java
public void setInverseIsA(String... inverseIsA) { ProtempaUtil.checkArrayForNullElement(inverseIsA, "inverseIsA"); ProtempaUtil.checkArrayForDuplicates(inverseIsA, "inverseIsA"); this.inverseIsA = inverseIsA.clone(); recalculateChildren(); }
[ "public", "void", "setInverseIsA", "(", "String", "...", "inverseIsA", ")", "{", "ProtempaUtil", ".", "checkArrayForNullElement", "(", "inverseIsA", ",", "\"inverseIsA\"", ")", ";", "ProtempaUtil", ".", "checkArrayForDuplicates", "(", "inverseIsA", ",", "\"inverseIsA\"", ")", ";", "this", ".", "inverseIsA", "=", "inverseIsA", ".", "clone", "(", ")", ";", "recalculateChildren", "(", ")", ";", "}" ]
Sets the children of this proposition definition. @param inverseIsA a {@link String[]} of proposition definition ids. No <code>null</code> or duplicate elements allowed.
[ "Sets", "the", "children", "of", "this", "proposition", "definition", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/AbstractPropositionDefinition.java#L188-L193
148,778
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/AbstractPropositionDefinition.java
AbstractPropositionDefinition.reset
public void reset() { setDisplayName(null); setAbbreviatedDisplayName(null); setDescription(null); setInverseIsA(ArrayUtils.EMPTY_STRING_ARRAY); setTermIds(ArrayUtils.EMPTY_STRING_ARRAY); setPropertyDefinitions(new PropertyDefinition[]{}); setReferenceDefinitions(new ReferenceDefinition[]{}); setInDataSource(false); setAccessed(null); setCreated(null); setUpdated(null); }
java
public void reset() { setDisplayName(null); setAbbreviatedDisplayName(null); setDescription(null); setInverseIsA(ArrayUtils.EMPTY_STRING_ARRAY); setTermIds(ArrayUtils.EMPTY_STRING_ARRAY); setPropertyDefinitions(new PropertyDefinition[]{}); setReferenceDefinitions(new ReferenceDefinition[]{}); setInDataSource(false); setAccessed(null); setCreated(null); setUpdated(null); }
[ "public", "void", "reset", "(", ")", "{", "setDisplayName", "(", "null", ")", ";", "setAbbreviatedDisplayName", "(", "null", ")", ";", "setDescription", "(", "null", ")", ";", "setInverseIsA", "(", "ArrayUtils", ".", "EMPTY_STRING_ARRAY", ")", ";", "setTermIds", "(", "ArrayUtils", ".", "EMPTY_STRING_ARRAY", ")", ";", "setPropertyDefinitions", "(", "new", "PropertyDefinition", "[", "]", "{", "}", ")", ";", "setReferenceDefinitions", "(", "new", "ReferenceDefinition", "[", "]", "{", "}", ")", ";", "setInDataSource", "(", "false", ")", ";", "setAccessed", "(", "null", ")", ";", "setCreated", "(", "null", ")", ";", "setUpdated", "(", "null", ")", ";", "}" ]
Resets this proposition definition to default values.
[ "Resets", "this", "proposition", "definition", "to", "default", "values", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/AbstractPropositionDefinition.java#L361-L373
148,779
udoprog/tiny-serializer-java
tiny-serializer-processor/src/main/java/eu/toolchain/serializer/processor/ClassProcessor.java
ClassProcessor.getKinds
Set<ElementKind> getKinds(Element element) { final ImmutableSet.Builder<ElementKind> kinds = ImmutableSet.builder(); if (element.getKind() == ElementKind.INTERFACE) { kinds.add(ElementKind.METHOD); } if (element.getKind() == ElementKind.CLASS) { kinds.add(ElementKind.FIELD); if (element.getModifiers().contains(Modifier.ABSTRACT)) { kinds.add(ElementKind.METHOD); } } return kinds.build(); }
java
Set<ElementKind> getKinds(Element element) { final ImmutableSet.Builder<ElementKind> kinds = ImmutableSet.builder(); if (element.getKind() == ElementKind.INTERFACE) { kinds.add(ElementKind.METHOD); } if (element.getKind() == ElementKind.CLASS) { kinds.add(ElementKind.FIELD); if (element.getModifiers().contains(Modifier.ABSTRACT)) { kinds.add(ElementKind.METHOD); } } return kinds.build(); }
[ "Set", "<", "ElementKind", ">", "getKinds", "(", "Element", "element", ")", "{", "final", "ImmutableSet", ".", "Builder", "<", "ElementKind", ">", "kinds", "=", "ImmutableSet", ".", "builder", "(", ")", ";", "if", "(", "element", ".", "getKind", "(", ")", "==", "ElementKind", ".", "INTERFACE", ")", "{", "kinds", ".", "add", "(", "ElementKind", ".", "METHOD", ")", ";", "}", "if", "(", "element", ".", "getKind", "(", ")", "==", "ElementKind", ".", "CLASS", ")", "{", "kinds", ".", "add", "(", "ElementKind", ".", "FIELD", ")", ";", "if", "(", "element", ".", "getModifiers", "(", ")", ".", "contains", "(", "Modifier", ".", "ABSTRACT", ")", ")", "{", "kinds", ".", "add", "(", "ElementKind", ".", "METHOD", ")", ";", "}", "}", "return", "kinds", ".", "build", "(", ")", ";", "}" ]
Get the set of supported element kinds that make up the total set of fields for this type. @param element @return
[ "Get", "the", "set", "of", "supported", "element", "kinds", "that", "make", "up", "the", "total", "set", "of", "fields", "for", "this", "type", "." ]
e2a7d9e7eb9125a51a17ba3abad0b291a97f9c6f
https://github.com/udoprog/tiny-serializer-java/blob/e2a7d9e7eb9125a51a17ba3abad0b291a97f9c6f/tiny-serializer-processor/src/main/java/eu/toolchain/serializer/processor/ClassProcessor.java#L109-L125
148,780
eurekaclinical/protempa
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/oracle/OjdbcOracleInClause.java
Ojdbc6OracleInClause.generateClause
@Override public String generateClause() { StringBuilder wherePart = new StringBuilder(); wherePart.append(referenceIndices.generateColumnReference(columnSpec)); if (not) { wherePart.append(" NOT"); } wherePart.append(" IN ("); for (int k = 0; k < elements.length; k++) { Object val = elements[k]; wherePart.append(SqlGeneratorUtil.prepareValue(val)); if (k + 1 < elements.length) { if ((k + 1) % 1000 == 0) { wherePart.append(") OR "); wherePart.append(referenceIndices.generateColumnReference(columnSpec)); wherePart.append(" IN ("); } else { wherePart.append(','); } } } wherePart.append(')'); return wherePart.toString(); }
java
@Override public String generateClause() { StringBuilder wherePart = new StringBuilder(); wherePart.append(referenceIndices.generateColumnReference(columnSpec)); if (not) { wherePart.append(" NOT"); } wherePart.append(" IN ("); for (int k = 0; k < elements.length; k++) { Object val = elements[k]; wherePart.append(SqlGeneratorUtil.prepareValue(val)); if (k + 1 < elements.length) { if ((k + 1) % 1000 == 0) { wherePart.append(") OR "); wherePart.append(referenceIndices.generateColumnReference(columnSpec)); wherePart.append(" IN ("); } else { wherePart.append(','); } } } wherePart.append(')'); return wherePart.toString(); }
[ "@", "Override", "public", "String", "generateClause", "(", ")", "{", "StringBuilder", "wherePart", "=", "new", "StringBuilder", "(", ")", ";", "wherePart", ".", "append", "(", "referenceIndices", ".", "generateColumnReference", "(", "columnSpec", ")", ")", ";", "if", "(", "not", ")", "{", "wherePart", ".", "append", "(", "\" NOT\"", ")", ";", "}", "wherePart", ".", "append", "(", "\" IN (\"", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "elements", ".", "length", ";", "k", "++", ")", "{", "Object", "val", "=", "elements", "[", "k", "]", ";", "wherePart", ".", "append", "(", "SqlGeneratorUtil", ".", "prepareValue", "(", "val", ")", ")", ";", "if", "(", "k", "+", "1", "<", "elements", ".", "length", ")", "{", "if", "(", "(", "k", "+", "1", ")", "%", "1000", "==", "0", ")", "{", "wherePart", ".", "append", "(", "\") OR \"", ")", ";", "wherePart", ".", "append", "(", "referenceIndices", ".", "generateColumnReference", "(", "columnSpec", ")", ")", ";", "wherePart", ".", "append", "(", "\" IN (\"", ")", ";", "}", "else", "{", "wherePart", ".", "append", "(", "'", "'", ")", ";", "}", "}", "}", "wherePart", ".", "append", "(", "'", "'", ")", ";", "return", "wherePart", ".", "toString", "(", ")", ";", "}" ]
Oracle doesn't allow more than 1000 elements in an IN clause, so if we want more than 1000 we create multiple IN clauses chained together by OR.
[ "Oracle", "doesn", "t", "allow", "more", "than", "1000", "elements", "in", "an", "IN", "clause", "so", "if", "we", "want", "more", "than", "1000", "we", "create", "multiple", "IN", "clauses", "chained", "together", "by", "OR", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/oracle/OjdbcOracleInClause.java#L49-L73
148,781
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/backend/dsb/filter/AbstractFilter.java
AbstractFilter.filterChainToArray
@Override public Filter[] filterChainToArray() { int length = chainLength(); Filter[] array = new Filter[length]; Filter thisFilter = this; for (int i = 0; i < length; i++) { array[i] = thisFilter; thisFilter = thisFilter.getAnd(); } return array; }
java
@Override public Filter[] filterChainToArray() { int length = chainLength(); Filter[] array = new Filter[length]; Filter thisFilter = this; for (int i = 0; i < length; i++) { array[i] = thisFilter; thisFilter = thisFilter.getAnd(); } return array; }
[ "@", "Override", "public", "Filter", "[", "]", "filterChainToArray", "(", ")", "{", "int", "length", "=", "chainLength", "(", ")", ";", "Filter", "[", "]", "array", "=", "new", "Filter", "[", "length", "]", ";", "Filter", "thisFilter", "=", "this", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "array", "[", "i", "]", "=", "thisFilter", ";", "thisFilter", "=", "thisFilter", ".", "getAnd", "(", ")", ";", "}", "return", "array", ";", "}" ]
Return an array that contains all of the filters in the chain.
[ "Return", "an", "array", "that", "contains", "all", "of", "the", "filters", "in", "the", "chain", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/backend/dsb/filter/AbstractFilter.java#L143-L153
148,782
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/dest/proplist/PropositionListQueryResultsHandler.java
PropositionListQueryResultsHandler.handleQueryResult
@Override public void handleQueryResult(String key, List<Proposition> propositions, Map<Proposition, Set<Proposition>> forwardDerivations, Map<Proposition, Set<Proposition>> backwardDerivations, Map<UniqueId, Proposition> references) throws QueryResultsHandlerProcessingException { Set<Proposition> propositionsAsSet = new HashSet<>(); addDerived(propositions, forwardDerivations, backwardDerivations, propositionsAsSet); List<Proposition> propositionsCopy = new ArrayList<>(propositionsAsSet); for (Comparator<Proposition> c : this.comparator) { Collections.sort(propositionsCopy, c); } this.visitor.setKeyId(key); try { this.visitor.visit(propositionsCopy); } catch (TabDelimHandlerProtempaException pe) { throw new QueryResultsHandlerProcessingException(pe); } catch (ProtempaException pe) { throw new AssertionError(pe); } }
java
@Override public void handleQueryResult(String key, List<Proposition> propositions, Map<Proposition, Set<Proposition>> forwardDerivations, Map<Proposition, Set<Proposition>> backwardDerivations, Map<UniqueId, Proposition> references) throws QueryResultsHandlerProcessingException { Set<Proposition> propositionsAsSet = new HashSet<>(); addDerived(propositions, forwardDerivations, backwardDerivations, propositionsAsSet); List<Proposition> propositionsCopy = new ArrayList<>(propositionsAsSet); for (Comparator<Proposition> c : this.comparator) { Collections.sort(propositionsCopy, c); } this.visitor.setKeyId(key); try { this.visitor.visit(propositionsCopy); } catch (TabDelimHandlerProtempaException pe) { throw new QueryResultsHandlerProcessingException(pe); } catch (ProtempaException pe) { throw new AssertionError(pe); } }
[ "@", "Override", "public", "void", "handleQueryResult", "(", "String", "key", ",", "List", "<", "Proposition", ">", "propositions", ",", "Map", "<", "Proposition", ",", "Set", "<", "Proposition", ">", ">", "forwardDerivations", ",", "Map", "<", "Proposition", ",", "Set", "<", "Proposition", ">", ">", "backwardDerivations", ",", "Map", "<", "UniqueId", ",", "Proposition", ">", "references", ")", "throws", "QueryResultsHandlerProcessingException", "{", "Set", "<", "Proposition", ">", "propositionsAsSet", "=", "new", "HashSet", "<>", "(", ")", ";", "addDerived", "(", "propositions", ",", "forwardDerivations", ",", "backwardDerivations", ",", "propositionsAsSet", ")", ";", "List", "<", "Proposition", ">", "propositionsCopy", "=", "new", "ArrayList", "<>", "(", "propositionsAsSet", ")", ";", "for", "(", "Comparator", "<", "Proposition", ">", "c", ":", "this", ".", "comparator", ")", "{", "Collections", ".", "sort", "(", "propositionsCopy", ",", "c", ")", ";", "}", "this", ".", "visitor", ".", "setKeyId", "(", "key", ")", ";", "try", "{", "this", ".", "visitor", ".", "visit", "(", "propositionsCopy", ")", ";", "}", "catch", "(", "TabDelimHandlerProtempaException", "pe", ")", "{", "throw", "new", "QueryResultsHandlerProcessingException", "(", "pe", ")", ";", "}", "catch", "(", "ProtempaException", "pe", ")", "{", "throw", "new", "AssertionError", "(", "pe", ")", ";", "}", "}" ]
Writes a keys worth of data in tab delimited format optionally sorted. @param key a key id {@link String}. @param propositions a {@link List<Proposition>}. @throws QueryResultsHandlerProcessingException if an error occurred writing to the specified file, output stream or writer.
[ "Writes", "a", "keys", "worth", "of", "data", "in", "tab", "delimited", "format", "optionally", "sorted", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/dest/proplist/PropositionListQueryResultsHandler.java#L110-L129
148,783
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/LowLevelAbstractionDefinition.java
LowLevelAbstractionDefinition.addPrimitiveParameterId
public boolean addPrimitiveParameterId(String paramId) { boolean result = this.paramIds.add(paramId); if (result) { recalculateChildren(); } return result; }
java
public boolean addPrimitiveParameterId(String paramId) { boolean result = this.paramIds.add(paramId); if (result) { recalculateChildren(); } return result; }
[ "public", "boolean", "addPrimitiveParameterId", "(", "String", "paramId", ")", "{", "boolean", "result", "=", "this", ".", "paramIds", ".", "add", "(", "paramId", ")", ";", "if", "(", "result", ")", "{", "recalculateChildren", "(", ")", ";", "}", "return", "result", ";", "}" ]
Adds a primitive parameter from which this abstraction is inferred. @param paramId a primitive parameter id <code>String</code>. @return <code>true</code> if adding the parameter id was successful, <code>false</code> otherwise (e.g., <code>paramId</code> was <code>null</code>).
[ "Adds", "a", "primitive", "parameter", "from", "which", "this", "abstraction", "is", "inferred", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/LowLevelAbstractionDefinition.java#L386-L392
148,784
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/LowLevelAbstractionDefinition.java
LowLevelAbstractionDefinition.removePrimitiveParameterId
public boolean removePrimitiveParameterId(String paramId) { boolean result = this.paramIds.remove(paramId); if (result) { recalculateChildren(); } return result; }
java
public boolean removePrimitiveParameterId(String paramId) { boolean result = this.paramIds.remove(paramId); if (result) { recalculateChildren(); } return result; }
[ "public", "boolean", "removePrimitiveParameterId", "(", "String", "paramId", ")", "{", "boolean", "result", "=", "this", ".", "paramIds", ".", "remove", "(", "paramId", ")", ";", "if", "(", "result", ")", "{", "recalculateChildren", "(", ")", ";", "}", "return", "result", ";", "}" ]
Removes a primitive parameter from which this abstraction is inferred. @param paramId a primitive parameter id <code>String</code>. @return <code>true</code> if removingg the parameter id was successful, <code>false</code> otherwise (e.g., <code>paramId</code> was <code>null</code> or not previously added to this abstraction definition).
[ "Removes", "a", "primitive", "parameter", "from", "which", "this", "abstraction", "is", "inferred", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/LowLevelAbstractionDefinition.java#L404-L410
148,785
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/AlgorithmSourceImpl.java
AlgorithmSourceImpl.readAlgorithm
@Override public Algorithm readAlgorithm(String id) throws AlgorithmSourceReadException { Algorithm result = null; if (id != null) { if (algorithms != null) { result = algorithms.getAlgorithm(id); } if (result == null) { initializeIfNeeded(); for (AlgorithmSourceBackend backend : getBackends()) { result = backend.readAlgorithm(id, algorithms); if (result != null) { break; } } } } return result; }
java
@Override public Algorithm readAlgorithm(String id) throws AlgorithmSourceReadException { Algorithm result = null; if (id != null) { if (algorithms != null) { result = algorithms.getAlgorithm(id); } if (result == null) { initializeIfNeeded(); for (AlgorithmSourceBackend backend : getBackends()) { result = backend.readAlgorithm(id, algorithms); if (result != null) { break; } } } } return result; }
[ "@", "Override", "public", "Algorithm", "readAlgorithm", "(", "String", "id", ")", "throws", "AlgorithmSourceReadException", "{", "Algorithm", "result", "=", "null", ";", "if", "(", "id", "!=", "null", ")", "{", "if", "(", "algorithms", "!=", "null", ")", "{", "result", "=", "algorithms", ".", "getAlgorithm", "(", "id", ")", ";", "}", "if", "(", "result", "==", "null", ")", "{", "initializeIfNeeded", "(", ")", ";", "for", "(", "AlgorithmSourceBackend", "backend", ":", "getBackends", "(", ")", ")", "{", "result", "=", "backend", ".", "readAlgorithm", "(", "id", ",", "algorithms", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "break", ";", "}", "}", "}", "}", "return", "result", ";", "}" ]
Read an algorithm with the given id. @param id an algorithm id {@link String}. @return an {@link Algorithm} object, or <code>null</code> if no algorithm with the specified id exists. If a <code>null</code> id is * specified, <code>null</code> is returned. @throws AlgorithmSourceReadException when an error occurs in a backend reading the specified algorithm.
[ "Read", "an", "algorithm", "with", "the", "given", "id", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/AlgorithmSourceImpl.java#L73-L92
148,786
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/AlgorithmSourceImpl.java
AlgorithmSourceImpl.readAlgorithms
@Override public Set<Algorithm> readAlgorithms() throws AlgorithmSourceReadException { initializeIfNeeded(); if (algorithms != null) { if (!readAlgorithmsCalled && getBackends() != null) { for (AlgorithmSourceBackend backend : getBackends()) { backend.readAlgorithms(algorithms); } readAlgorithmsCalled = true; } return algorithms.getAlgorithms(); } return Collections.emptySet(); }
java
@Override public Set<Algorithm> readAlgorithms() throws AlgorithmSourceReadException { initializeIfNeeded(); if (algorithms != null) { if (!readAlgorithmsCalled && getBackends() != null) { for (AlgorithmSourceBackend backend : getBackends()) { backend.readAlgorithms(algorithms); } readAlgorithmsCalled = true; } return algorithms.getAlgorithms(); } return Collections.emptySet(); }
[ "@", "Override", "public", "Set", "<", "Algorithm", ">", "readAlgorithms", "(", ")", "throws", "AlgorithmSourceReadException", "{", "initializeIfNeeded", "(", ")", ";", "if", "(", "algorithms", "!=", "null", ")", "{", "if", "(", "!", "readAlgorithmsCalled", "&&", "getBackends", "(", ")", "!=", "null", ")", "{", "for", "(", "AlgorithmSourceBackend", "backend", ":", "getBackends", "(", ")", ")", "{", "backend", ".", "readAlgorithms", "(", "algorithms", ")", ";", "}", "readAlgorithmsCalled", "=", "true", ";", "}", "return", "algorithms", ".", "getAlgorithms", "(", ")", ";", "}", "return", "Collections", ".", "emptySet", "(", ")", ";", "}" ]
Reads all algorithms in this algorithm source. @return an unmodifiable <code>Set</code> of <code>Algorithm</code> objects. Guaranteed not to return <code>null</code>. @throws AlgorithmSourceReadException when an error occurs in a backend reading an algorithm.
[ "Reads", "all", "algorithms", "in", "this", "algorithm", "source", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/AlgorithmSourceImpl.java#L103-L116
148,787
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java
ConfigUtil.getHierarchicalConfiguration
public static HierarchicalConfiguration getHierarchicalConfiguration(final Configuration configuration) { if (configuration instanceof CompositeConfiguration) { final CompositeConfiguration compositeConfig = (CompositeConfiguration) configuration; for (int i = 0; i < compositeConfig.getNumberOfConfigurations(); i++) { if (compositeConfig.getConfiguration(i) instanceof HierarchicalConfiguration) { return (HierarchicalConfiguration) compositeConfig.getConfiguration(i); } } } // maybe I need to send a runtime exception ?? // throw new // ConfigurationRuntimeException("no hierarchical configuration was defined"); return null; }
java
public static HierarchicalConfiguration getHierarchicalConfiguration(final Configuration configuration) { if (configuration instanceof CompositeConfiguration) { final CompositeConfiguration compositeConfig = (CompositeConfiguration) configuration; for (int i = 0; i < compositeConfig.getNumberOfConfigurations(); i++) { if (compositeConfig.getConfiguration(i) instanceof HierarchicalConfiguration) { return (HierarchicalConfiguration) compositeConfig.getConfiguration(i); } } } // maybe I need to send a runtime exception ?? // throw new // ConfigurationRuntimeException("no hierarchical configuration was defined"); return null; }
[ "public", "static", "HierarchicalConfiguration", "getHierarchicalConfiguration", "(", "final", "Configuration", "configuration", ")", "{", "if", "(", "configuration", "instanceof", "CompositeConfiguration", ")", "{", "final", "CompositeConfiguration", "compositeConfig", "=", "(", "CompositeConfiguration", ")", "configuration", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "compositeConfig", ".", "getNumberOfConfigurations", "(", ")", ";", "i", "++", ")", "{", "if", "(", "compositeConfig", ".", "getConfiguration", "(", "i", ")", "instanceof", "HierarchicalConfiguration", ")", "{", "return", "(", "HierarchicalConfiguration", ")", "compositeConfig", ".", "getConfiguration", "(", "i", ")", ";", "}", "}", "}", "// maybe I need to send a runtime exception ??", "// throw new", "// ConfigurationRuntimeException(\"no hierarchical configuration was defined\");", "return", "null", ";", "}" ]
returns the hierarchical part of a configuration @param configuration the given configuration @return the hierarchical configuration or null if not found in the given configuration object.
[ "returns", "the", "hierarchical", "part", "of", "a", "configuration" ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java#L60-L73
148,788
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java
ConfigUtil.createCompositeConfiguration
public static Configuration createCompositeConfiguration(final Class<?> clazz, final Configuration configuration) { final CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); final Configuration defaultConfiguration = ConfigurationFactory.getDefaultConfiguration(); if (configuration != null) { compositeConfiguration.addConfiguration(configuration); } compositeConfiguration.addConfiguration(defaultConfiguration); return compositeConfiguration; }
java
public static Configuration createCompositeConfiguration(final Class<?> clazz, final Configuration configuration) { final CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); final Configuration defaultConfiguration = ConfigurationFactory.getDefaultConfiguration(); if (configuration != null) { compositeConfiguration.addConfiguration(configuration); } compositeConfiguration.addConfiguration(defaultConfiguration); return compositeConfiguration; }
[ "public", "static", "Configuration", "createCompositeConfiguration", "(", "final", "Class", "<", "?", ">", "clazz", ",", "final", "Configuration", "configuration", ")", "{", "final", "CompositeConfiguration", "compositeConfiguration", "=", "new", "CompositeConfiguration", "(", ")", ";", "final", "Configuration", "defaultConfiguration", "=", "ConfigurationFactory", ".", "getDefaultConfiguration", "(", ")", ";", "if", "(", "configuration", "!=", "null", ")", "{", "compositeConfiguration", ".", "addConfiguration", "(", "configuration", ")", ";", "}", "compositeConfiguration", ".", "addConfiguration", "(", "defaultConfiguration", ")", ";", "return", "compositeConfiguration", ";", "}" ]
create a composite configuration that wraps the configuration sent by the user. this util will also load the "defaultConfig.properties" file loaded relative to the given "clazz" parameter @param clazz - the class that acts as referenced location of "defaultConfig.properties". @param configuration - the configuration supplied by the user that may override values in "defaultConfig.properties". If null is ignored. @return the created compsite configuration.
[ "create", "a", "composite", "configuration", "that", "wraps", "the", "configuration", "sent", "by", "the", "user", ".", "this", "util", "will", "also", "load", "the", "defaultConfig", ".", "properties", "file", "loaded", "relative", "to", "the", "given", "clazz", "parameter" ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java#L88-L96
148,789
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java
ConfigUtil.getInnerMapKey
private static String getInnerMapKey(final String key) { final int index = key.indexOf("."); return key.substring(index + 1); }
java
private static String getInnerMapKey(final String key) { final int index = key.indexOf("."); return key.substring(index + 1); }
[ "private", "static", "String", "getInnerMapKey", "(", "final", "String", "key", ")", "{", "final", "int", "index", "=", "key", ".", "indexOf", "(", "\".\"", ")", ";", "return", "key", ".", "substring", "(", "index", "+", "1", ")", ";", "}" ]
create inner key map by taking what ever is after the first dot. @param key @return
[ "create", "inner", "key", "map", "by", "taking", "what", "ever", "is", "after", "the", "first", "dot", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java#L226-L229
148,790
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java
ConfigUtil.stripKey
private static String stripKey(final String key) { int index = key.indexOf("."); if (index > 0) { return key.substring(0, index); } return null; }
java
private static String stripKey(final String key) { int index = key.indexOf("."); if (index > 0) { return key.substring(0, index); } return null; }
[ "private", "static", "String", "stripKey", "(", "final", "String", "key", ")", "{", "int", "index", "=", "key", ".", "indexOf", "(", "\".\"", ")", ";", "if", "(", "index", ">", "0", ")", "{", "return", "key", ".", "substring", "(", "0", ",", "index", ")", ";", "}", "return", "null", ";", "}" ]
strip the original key by taking every thing from the start of the original key to the first dot. @param key @return
[ "strip", "the", "original", "key", "by", "taking", "every", "thing", "from", "the", "start", "of", "the", "original", "key", "to", "the", "first", "dot", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java#L238-L244
148,791
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java
ConfigUtil.isHexadecimal
public static boolean isHexadecimal(String value) { if (value == null || value.length() == 0) { return false; } // validate string is hexadecimal value if (! HEX_REGEX_PATTERN.matcher(value).matches()) { return false; } return true; }
java
public static boolean isHexadecimal(String value) { if (value == null || value.length() == 0) { return false; } // validate string is hexadecimal value if (! HEX_REGEX_PATTERN.matcher(value).matches()) { return false; } return true; }
[ "public", "static", "boolean", "isHexadecimal", "(", "String", "value", ")", "{", "if", "(", "value", "==", "null", "||", "value", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "// validate string is hexadecimal value", "if", "(", "!", "HEX_REGEX_PATTERN", ".", "matcher", "(", "value", ")", ".", "matches", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
return if the given string is a valid hexadecimal string
[ "return", "if", "the", "given", "string", "is", "a", "valid", "hexadecimal", "string" ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/ConfigUtil.java#L323-L335
148,792
vtatai/srec
core/src/main/java/com/github/srec/command/base/IfCommand.java
IfCommand.evaluateCondition
public boolean evaluateCondition(ExecutionContext context) { Value v = condition.getValue(context); return !(v instanceof NilValue || (v instanceof BooleanValue && !((BooleanValue) v).get())); }
java
public boolean evaluateCondition(ExecutionContext context) { Value v = condition.getValue(context); return !(v instanceof NilValue || (v instanceof BooleanValue && !((BooleanValue) v).get())); }
[ "public", "boolean", "evaluateCondition", "(", "ExecutionContext", "context", ")", "{", "Value", "v", "=", "condition", ".", "getValue", "(", "context", ")", ";", "return", "!", "(", "v", "instanceof", "NilValue", "||", "(", "v", "instanceof", "BooleanValue", "&&", "!", "(", "(", "BooleanValue", ")", "v", ")", ".", "get", "(", ")", ")", ")", ";", "}" ]
Evaluates the elsif condition. @param context The EC @return true if this block should run, false otherwise
[ "Evaluates", "the", "elsif", "condition", "." ]
87fa6754a6a5f8569ef628db4d149eea04062568
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/base/IfCommand.java#L81-L84
148,793
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/PropositionCopier.java
PropositionCopier.grab
void grab(KnowledgeHelper kh) { assert kh != null : "kh cannot be null"; assert this.kh == null : "The previous user of this copier forgot to call release!"; if (this.kh != null) { LOGGER.log(Level.WARNING, "The previous user of this copier forgot to call release. This causes a memory leak!"); } this.kh = kh; this.uniqueIdProvider = new ProviderBasedUniqueIdFactory(new JBossRulesDerivedLocalUniqueIdValuesProvider(this.kh.getWorkingMemory(), this.propId)); }
java
void grab(KnowledgeHelper kh) { assert kh != null : "kh cannot be null"; assert this.kh == null : "The previous user of this copier forgot to call release!"; if (this.kh != null) { LOGGER.log(Level.WARNING, "The previous user of this copier forgot to call release. This causes a memory leak!"); } this.kh = kh; this.uniqueIdProvider = new ProviderBasedUniqueIdFactory(new JBossRulesDerivedLocalUniqueIdValuesProvider(this.kh.getWorkingMemory(), this.propId)); }
[ "void", "grab", "(", "KnowledgeHelper", "kh", ")", "{", "assert", "kh", "!=", "null", ":", "\"kh cannot be null\"", ";", "assert", "this", ".", "kh", "==", "null", ":", "\"The previous user of this copier forgot to call release!\"", ";", "if", "(", "this", ".", "kh", "!=", "null", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"The previous user of this copier forgot to call release. This causes a memory leak!\"", ")", ";", "}", "this", ".", "kh", "=", "kh", ";", "this", ".", "uniqueIdProvider", "=", "new", "ProviderBasedUniqueIdFactory", "(", "new", "JBossRulesDerivedLocalUniqueIdValuesProvider", "(", "this", ".", "kh", ".", "getWorkingMemory", "(", ")", ",", "this", ".", "propId", ")", ")", ";", "}" ]
Grabs this copier for use by a Drools consequence. @param workingMemory the consequence's {@link WorkingMemory}. Cannot be <code>null</code>.
[ "Grabs", "this", "copier", "for", "use", "by", "a", "Drools", "consequence", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/PropositionCopier.java#L88-L99
148,794
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/Distill.java
Distill.parsePackages
static String[] parsePackages(String packages) { if (packages == null || packages.trim().length() == 0) { return new String[0]; } String[] commaSplit = packages.split(","); String[] processPackages = new String[commaSplit.length]; for (int i = 0; i < commaSplit.length; i++) { processPackages[i] = convert(commaSplit[i]); } return processPackages; }
java
static String[] parsePackages(String packages) { if (packages == null || packages.trim().length() == 0) { return new String[0]; } String[] commaSplit = packages.split(","); String[] processPackages = new String[commaSplit.length]; for (int i = 0; i < commaSplit.length; i++) { processPackages[i] = convert(commaSplit[i]); } return processPackages; }
[ "static", "String", "[", "]", "parsePackages", "(", "String", "packages", ")", "{", "if", "(", "packages", "==", "null", "||", "packages", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "return", "new", "String", "[", "0", "]", ";", "}", "String", "[", "]", "commaSplit", "=", "packages", ".", "split", "(", "\",\"", ")", ";", "String", "[", "]", "processPackages", "=", "new", "String", "[", "commaSplit", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "commaSplit", ".", "length", ";", "i", "++", ")", "{", "processPackages", "[", "i", "]", "=", "convert", "(", "commaSplit", "[", "i", "]", ")", ";", "}", "return", "processPackages", ";", "}" ]
Split using delimiter and convert to slash notation.
[ "Split", "using", "delimiter", "and", "convert", "to", "slash", "notation", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/Distill.java#L13-L24
148,795
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/Distill.java
Distill.convert
static DetectQueryBean convert(Collection<String> packages) { String[] asArray = packages.toArray(new String[packages.size()]); for (int i = 0; i < asArray.length; i++) { asArray[i] = convert(asArray[i]); } return new DetectQueryBean(asArray); }
java
static DetectQueryBean convert(Collection<String> packages) { String[] asArray = packages.toArray(new String[packages.size()]); for (int i = 0; i < asArray.length; i++) { asArray[i] = convert(asArray[i]); } return new DetectQueryBean(asArray); }
[ "static", "DetectQueryBean", "convert", "(", "Collection", "<", "String", ">", "packages", ")", "{", "String", "[", "]", "asArray", "=", "packages", ".", "toArray", "(", "new", "String", "[", "packages", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "asArray", ".", "length", ";", "i", "++", ")", "{", "asArray", "[", "i", "]", "=", "convert", "(", "asArray", "[", "i", "]", ")", ";", "}", "return", "new", "DetectQueryBean", "(", "asArray", ")", ";", "}" ]
Convert the dot notation entity bean packages to slash notation. @param packages entity bean packages
[ "Convert", "the", "dot", "notation", "entity", "bean", "packages", "to", "slash", "notation", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/Distill.java#L41-L48
148,796
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/Distill.java
Distill.convert
private static String convert(String pkg) { pkg = pkg.trim(); if (pkg.endsWith("*")) { pkg = pkg.substring(0, pkg.length() - 1); } if (pkg.endsWith(".query")) { // always work with entity bean packages so trim pkg = pkg.substring(0, pkg.length() - 6); } pkg = pkg.replace('.', '/'); return pkg.endsWith("/") ? pkg : pkg + "/"; }
java
private static String convert(String pkg) { pkg = pkg.trim(); if (pkg.endsWith("*")) { pkg = pkg.substring(0, pkg.length() - 1); } if (pkg.endsWith(".query")) { // always work with entity bean packages so trim pkg = pkg.substring(0, pkg.length() - 6); } pkg = pkg.replace('.', '/'); return pkg.endsWith("/") ? pkg : pkg + "/"; }
[ "private", "static", "String", "convert", "(", "String", "pkg", ")", "{", "pkg", "=", "pkg", ".", "trim", "(", ")", ";", "if", "(", "pkg", ".", "endsWith", "(", "\"*\"", ")", ")", "{", "pkg", "=", "pkg", ".", "substring", "(", "0", ",", "pkg", ".", "length", "(", ")", "-", "1", ")", ";", "}", "if", "(", "pkg", ".", "endsWith", "(", "\".query\"", ")", ")", "{", "// always work with entity bean packages so trim", "pkg", "=", "pkg", ".", "substring", "(", "0", ",", "pkg", ".", "length", "(", ")", "-", "6", ")", ";", "}", "pkg", "=", "pkg", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "pkg", ".", "endsWith", "(", "\"/\"", ")", "?", "pkg", ":", "pkg", "+", "\"/\"", ";", "}" ]
Concert package to slash notation taking into account trailing wildcard.
[ "Concert", "package", "to", "slash", "notation", "taking", "into", "account", "trailing", "wildcard", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/Distill.java#L53-L65
148,797
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java
AbstractControllerServer.getManageLock
protected CloseableLockProvider getManageLock() { return new CloseableLockProvider() { @Override public CloseableReadLockWrapper getCloseableReadLock(final Object consumer) { return getManageReadLock(consumer); } @Override public CloseableWriteLockWrapper getCloseableWriteLock(final Object consumer) { return getManageWriteLock(consumer); } }; }
java
protected CloseableLockProvider getManageLock() { return new CloseableLockProvider() { @Override public CloseableReadLockWrapper getCloseableReadLock(final Object consumer) { return getManageReadLock(consumer); } @Override public CloseableWriteLockWrapper getCloseableWriteLock(final Object consumer) { return getManageWriteLock(consumer); } }; }
[ "protected", "CloseableLockProvider", "getManageLock", "(", ")", "{", "return", "new", "CloseableLockProvider", "(", ")", "{", "@", "Override", "public", "CloseableReadLockWrapper", "getCloseableReadLock", "(", "final", "Object", "consumer", ")", "{", "return", "getManageReadLock", "(", "consumer", ")", ";", "}", "@", "Override", "public", "CloseableWriteLockWrapper", "getCloseableWriteLock", "(", "final", "Object", "consumer", ")", "{", "return", "getManageWriteLock", "(", "consumer", ")", ";", "}", "}", ";", "}" ]
This method generates a closable lock provider. Be informed that the controller and all its services are directly locked and internal builder operations are queued. Therefore please release the locks after usage, otherwise the overall processing pipeline is delayed. Note: Be aware that your access is time limited an the lock will auto released if locked in longer term. This is a recovering feature but should never be used by design! @return a provider to access the manage read and write lock.
[ "This", "method", "generates", "a", "closable", "lock", "provider", ".", "Be", "informed", "that", "the", "controller", "and", "all", "its", "services", "are", "directly", "locked", "and", "internal", "builder", "operations", "are", "queued", ".", "Therefore", "please", "release", "the", "locks", "after", "usage", "otherwise", "the", "overall", "processing", "pipeline", "is", "delayed", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java#L618-L631
148,798
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java
AbstractControllerServer.notifyChange
@Override public void notifyChange() throws CouldNotPerformException, InterruptedException { logger.debug("Notify data change of " + this); // synchronized by manageable lock to prevent reinit between validateInitialization and publish M newData; manageLock.lockWrite(this); try { try { validateInitialization(); } catch (final NotInitializedException ex) { // only forward if instance was not destroyed before otherwise skip notification. if (destroyed) { return; } throw ex; } // update the current data builder before updating to allow implementations to change data beforehand newData = updateDataToPublish(cloneDataBuilder()); Event event = new Event(informer.getScope(), newData.getClass(), newData); event.getMetaData().setUserTime(RPCHelper.USER_TIME_KEY, System.nanoTime()); if (isActive()) { try { waitForMiddleware(NOTIFICATILONG_TIMEOUT, TimeUnit.MILLISECONDS); informer.publish(event); } catch (TimeoutException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Skip data update notification because middleware is not ready since "+TimeUnit.MILLISECONDS.toSeconds(NOTIFICATILONG_TIMEOUT)+" seconds of " + this + "!", ex), logger, LogLevel.WARN); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not inform about data change of " + this + "!", ex), logger); } } } finally { manageLock.unlockWrite(this); } // Notify data update try { notifyDataUpdate(newData); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update!", ex), logger); } dataObserver.notifyObservers(newData); }
java
@Override public void notifyChange() throws CouldNotPerformException, InterruptedException { logger.debug("Notify data change of " + this); // synchronized by manageable lock to prevent reinit between validateInitialization and publish M newData; manageLock.lockWrite(this); try { try { validateInitialization(); } catch (final NotInitializedException ex) { // only forward if instance was not destroyed before otherwise skip notification. if (destroyed) { return; } throw ex; } // update the current data builder before updating to allow implementations to change data beforehand newData = updateDataToPublish(cloneDataBuilder()); Event event = new Event(informer.getScope(), newData.getClass(), newData); event.getMetaData().setUserTime(RPCHelper.USER_TIME_KEY, System.nanoTime()); if (isActive()) { try { waitForMiddleware(NOTIFICATILONG_TIMEOUT, TimeUnit.MILLISECONDS); informer.publish(event); } catch (TimeoutException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Skip data update notification because middleware is not ready since "+TimeUnit.MILLISECONDS.toSeconds(NOTIFICATILONG_TIMEOUT)+" seconds of " + this + "!", ex), logger, LogLevel.WARN); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not inform about data change of " + this + "!", ex), logger); } } } finally { manageLock.unlockWrite(this); } // Notify data update try { notifyDataUpdate(newData); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify data update!", ex), logger); } dataObserver.notifyObservers(newData); }
[ "@", "Override", "public", "void", "notifyChange", "(", ")", "throws", "CouldNotPerformException", ",", "InterruptedException", "{", "logger", ".", "debug", "(", "\"Notify data change of \"", "+", "this", ")", ";", "// synchronized by manageable lock to prevent reinit between validateInitialization and publish", "M", "newData", ";", "manageLock", ".", "lockWrite", "(", "this", ")", ";", "try", "{", "try", "{", "validateInitialization", "(", ")", ";", "}", "catch", "(", "final", "NotInitializedException", "ex", ")", "{", "// only forward if instance was not destroyed before otherwise skip notification.", "if", "(", "destroyed", ")", "{", "return", ";", "}", "throw", "ex", ";", "}", "// update the current data builder before updating to allow implementations to change data beforehand", "newData", "=", "updateDataToPublish", "(", "cloneDataBuilder", "(", ")", ")", ";", "Event", "event", "=", "new", "Event", "(", "informer", ".", "getScope", "(", ")", ",", "newData", ".", "getClass", "(", ")", ",", "newData", ")", ";", "event", ".", "getMetaData", "(", ")", ".", "setUserTime", "(", "RPCHelper", ".", "USER_TIME_KEY", ",", "System", ".", "nanoTime", "(", ")", ")", ";", "if", "(", "isActive", "(", ")", ")", "{", "try", "{", "waitForMiddleware", "(", "NOTIFICATILONG_TIMEOUT", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "informer", ".", "publish", "(", "event", ")", ";", "}", "catch", "(", "TimeoutException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Skip data update notification because middleware is not ready since \"", "+", "TimeUnit", ".", "MILLISECONDS", ".", "toSeconds", "(", "NOTIFICATILONG_TIMEOUT", ")", "+", "\" seconds of \"", "+", "this", "+", "\"!\"", ",", "ex", ")", ",", "logger", ",", "LogLevel", ".", "WARN", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Could not inform about data change of \"", "+", "this", "+", "\"!\"", ",", "ex", ")", ",", "logger", ")", ";", "}", "}", "}", "finally", "{", "manageLock", ".", "unlockWrite", "(", "this", ")", ";", "}", "// Notify data update", "try", "{", "notifyDataUpdate", "(", "newData", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Could not notify data update!\"", ",", "ex", ")", ",", "logger", ")", ";", "}", "dataObserver", ".", "notifyObservers", "(", "newData", ")", ";", "}" ]
Synchronize all registered remote instances about a data change. @throws CouldNotPerformException @throws java.lang.InterruptedException
[ "Synchronize", "all", "registered", "remote", "instances", "about", "a", "data", "change", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java#L654-L698
148,799
openbase/jul
communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java
AbstractControllerServer.isReady
@Override public Boolean isReady() { try { validateInitialization(); validateActivation(); validateMiddleware(); return true; } catch (InvalidStateException e) { return false; } }
java
@Override public Boolean isReady() { try { validateInitialization(); validateActivation(); validateMiddleware(); return true; } catch (InvalidStateException e) { return false; } }
[ "@", "Override", "public", "Boolean", "isReady", "(", ")", "{", "try", "{", "validateInitialization", "(", ")", ";", "validateActivation", "(", ")", ";", "validateMiddleware", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "InvalidStateException", "e", ")", "{", "return", "false", ";", "}", "}" ]
Method returns true if this instance was initialized, activated and is successfully connected to the middleware. @return returns true if this instance is ready otherwise false.
[ "Method", "returns", "true", "if", "this", "instance", "was", "initialized", "activated", "and", "is", "successfully", "connected", "to", "the", "middleware", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java#L970-L980