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
144,400
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java
MaterialUtils.findIndexPageDocument
public static LocalDocument findIndexPageDocument(Delfoi delfoi, Locale locale) { String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage()); return findLocalDocumentByParentAndUrlName(delfoi.getRootFolder(), urlName); }
java
public static LocalDocument findIndexPageDocument(Delfoi delfoi, Locale locale) { String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage()); return findLocalDocumentByParentAndUrlName(delfoi.getRootFolder(), urlName); }
[ "public", "static", "LocalDocument", "findIndexPageDocument", "(", "Delfoi", "delfoi", ",", "Locale", "locale", ")", "{", "String", "urlName", "=", "String", ".", "format", "(", "\"%s-%s\"", ",", "INDEX_PAGE_URLNAME", ",", "locale", ".", "getLanguage", "(", ")", ")", ";", "return", "findLocalDocumentByParentAndUrlName", "(", "delfoi", ".", "getRootFolder", "(", ")", ",", "urlName", ")", ";", "}" ]
Finds delfoi index page document @param delfoi delfoi @param locale document locale @return index page document or null if not defined
[ "Finds", "delfoi", "index", "page", "document" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java#L83-L86
144,401
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java
MaterialUtils.createIndexPageDocument
public static LocalDocument createIndexPageDocument(Delfoi delfoi, Locale locale, User user) { LocalDocumentDAO localDocumentDAO = new LocalDocumentDAO(); String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage()); return localDocumentDAO.create(urlName, urlName, delfoi.getRootFolder(), user, 0); }
java
public static LocalDocument createIndexPageDocument(Delfoi delfoi, Locale locale, User user) { LocalDocumentDAO localDocumentDAO = new LocalDocumentDAO(); String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage()); return localDocumentDAO.create(urlName, urlName, delfoi.getRootFolder(), user, 0); }
[ "public", "static", "LocalDocument", "createIndexPageDocument", "(", "Delfoi", "delfoi", ",", "Locale", "locale", ",", "User", "user", ")", "{", "LocalDocumentDAO", "localDocumentDAO", "=", "new", "LocalDocumentDAO", "(", ")", ";", "String", "urlName", "=", "String", ".", "format", "(", "\"%s-%s\"", ",", "INDEX_PAGE_URLNAME", ",", "locale", ".", "getLanguage", "(", ")", ")", ";", "return", "localDocumentDAO", ".", "create", "(", "urlName", ",", "urlName", ",", "delfoi", ".", "getRootFolder", "(", ")", ",", "user", ",", "0", ")", ";", "}" ]
Creates index page document @param delfoi delfoi @param locale locale @param user logged user @return created document
[ "Creates", "index", "page", "document" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java#L96-L100
144,402
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java
MaterialUtils.findLocalDocumentByParentAndUrlName
public static LocalDocument findLocalDocumentByParentAndUrlName(Folder parentFolder, String urlName) { ResourceDAO resourceDAO = new ResourceDAO(); Resource resource = resourceDAO.findByUrlNameAndParentFolder(urlName, parentFolder); if (resource instanceof LocalDocument) { return (LocalDocument) resource; } return null; }
java
public static LocalDocument findLocalDocumentByParentAndUrlName(Folder parentFolder, String urlName) { ResourceDAO resourceDAO = new ResourceDAO(); Resource resource = resourceDAO.findByUrlNameAndParentFolder(urlName, parentFolder); if (resource instanceof LocalDocument) { return (LocalDocument) resource; } return null; }
[ "public", "static", "LocalDocument", "findLocalDocumentByParentAndUrlName", "(", "Folder", "parentFolder", ",", "String", "urlName", ")", "{", "ResourceDAO", "resourceDAO", "=", "new", "ResourceDAO", "(", ")", ";", "Resource", "resource", "=", "resourceDAO", ".", "findByUrlNameAndParentFolder", "(", "urlName", ",", "parentFolder", ")", ";", "if", "(", "resource", "instanceof", "LocalDocument", ")", "{", "return", "(", "LocalDocument", ")", "resource", ";", "}", "return", "null", ";", "}" ]
Returns local document by parent folder and URL name @param parentFolder parent folder @param urlName URL name @return Document or null if not found
[ "Returns", "local", "document", "by", "parent", "folder", "and", "URL", "name" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java#L109-L118
144,403
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/translate/AbstractTranslator.java
AbstractTranslator.translateDate
protected OffsetDateTime translateDate(Date date) { if (date == null) { return null; } return OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); }
java
protected OffsetDateTime translateDate(Date date) { if (date == null) { return null; } return OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); }
[ "protected", "OffsetDateTime", "translateDate", "(", "Date", "date", ")", "{", "if", "(", "date", "==", "null", ")", "{", "return", "null", ";", "}", "return", "OffsetDateTime", ".", "ofInstant", "(", "date", ".", "toInstant", "(", ")", ",", "ZoneId", ".", "systemDefault", "(", ")", ")", ";", "}" ]
Translates date into offset date time @param date @return offset date time
[ "Translates", "date", "into", "offset", "date", "time" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/translate/AbstractTranslator.java#L40-L46
144,404
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/translate/AbstractTranslator.java
AbstractTranslator.translateUserId
protected UUID translateUserId(User user) { if (user == null) { return null; } return userController.getUserKeycloakId(user); }
java
protected UUID translateUserId(User user) { if (user == null) { return null; } return userController.getUserKeycloakId(user); }
[ "protected", "UUID", "translateUserId", "(", "User", "user", ")", "{", "if", "(", "user", "==", "null", ")", "{", "return", "null", ";", "}", "return", "userController", ".", "getUserKeycloakId", "(", "user", ")", ";", "}" ]
Translates user into user id @param user user @return user id
[ "Translates", "user", "into", "user", "id" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/translate/AbstractTranslator.java#L54-L60
144,405
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java
AbstractReportPageCommentProcessor.getCommentLabel
public String getCommentLabel(Long id) { Map<String, String> valueMap = answers.get(id); if (valueMap != null && !valueMap.isEmpty()) { Set<Entry<String,String>> entrySet = valueMap.entrySet(); List<String> labels = entrySet.stream() .map(entry -> String.format("%s / %s", entry.getKey(), entry.getValue())) .collect(Collectors.toList()); return StringUtils.join(labels, " - "); } return null; }
java
public String getCommentLabel(Long id) { Map<String, String> valueMap = answers.get(id); if (valueMap != null && !valueMap.isEmpty()) { Set<Entry<String,String>> entrySet = valueMap.entrySet(); List<String> labels = entrySet.stream() .map(entry -> String.format("%s / %s", entry.getKey(), entry.getValue())) .collect(Collectors.toList()); return StringUtils.join(labels, " - "); } return null; }
[ "public", "String", "getCommentLabel", "(", "Long", "id", ")", "{", "Map", "<", "String", ",", "String", ">", "valueMap", "=", "answers", ".", "get", "(", "id", ")", ";", "if", "(", "valueMap", "!=", "null", "&&", "!", "valueMap", ".", "isEmpty", "(", ")", ")", "{", "Set", "<", "Entry", "<", "String", ",", "String", ">", ">", "entrySet", "=", "valueMap", ".", "entrySet", "(", ")", ";", "List", "<", "String", ">", "labels", "=", "entrySet", ".", "stream", "(", ")", ".", "map", "(", "entry", "->", "String", ".", "format", "(", "\"%s / %s\"", ",", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "return", "StringUtils", ".", "join", "(", "labels", ",", "\" - \"", ")", ";", "}", "return", "null", ";", "}" ]
Returns comment label as string @param id comment id @return comment label as string
[ "Returns", "comment", "label", "as", "string" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java#L71-L83
144,406
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java
AbstractReportPageCommentProcessor.setCommentLabel
protected void setCommentLabel(Long id, String caption, String value) { Map<String, String> valueMap = answers.get(id); if (valueMap == null) { valueMap = new LinkedHashMap<>(); } valueMap.put(caption, value); answers.put(id, valueMap); }
java
protected void setCommentLabel(Long id, String caption, String value) { Map<String, String> valueMap = answers.get(id); if (valueMap == null) { valueMap = new LinkedHashMap<>(); } valueMap.put(caption, value); answers.put(id, valueMap); }
[ "protected", "void", "setCommentLabel", "(", "Long", "id", ",", "String", "caption", ",", "String", "value", ")", "{", "Map", "<", "String", ",", "String", ">", "valueMap", "=", "answers", ".", "get", "(", "id", ")", ";", "if", "(", "valueMap", "==", "null", ")", "{", "valueMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "}", "valueMap", ".", "put", "(", "caption", ",", "value", ")", ";", "answers", ".", "put", "(", "id", ",", "valueMap", ")", ";", "}" ]
Sets a label for a specified comment @param id comment id @param caption caption @param value value
[ "Sets", "a", "label", "for", "a", "specified", "comment" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java#L101-L109
144,407
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java
AbstractReportPageCommentProcessor.listRootComments
private List<QueryQuestionComment> listRootComments() { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); return queryQuestionCommentDAO.listRootCommentsByQueryPageAndStampOrderByCreated(queryPage, panelStamp); }
java
private List<QueryQuestionComment> listRootComments() { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); return queryQuestionCommentDAO.listRootCommentsByQueryPageAndStampOrderByCreated(queryPage, panelStamp); }
[ "private", "List", "<", "QueryQuestionComment", ">", "listRootComments", "(", ")", "{", "QueryQuestionCommentDAO", "queryQuestionCommentDAO", "=", "new", "QueryQuestionCommentDAO", "(", ")", ";", "return", "queryQuestionCommentDAO", ".", "listRootCommentsByQueryPageAndStampOrderByCreated", "(", "queryPage", ",", "panelStamp", ")", ";", "}" ]
Lists page's root comments @return page's root comments
[ "Lists", "page", "s", "root", "comments" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java#L116-L119
144,408
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java
FixInvitations.isPanelUser
private boolean isPanelUser(JdbcConnection connection, Long panelId, String email) throws CustomChangeException { try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)")) { statement.setLong(1, panelId); statement.setString(2, email); try (ResultSet resultSet = statement.executeQuery()) { return resultSet.next(); } } catch (Exception e) { throw new CustomChangeException(e); } }
java
private boolean isPanelUser(JdbcConnection connection, Long panelId, String email) throws CustomChangeException { try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)")) { statement.setLong(1, panelId); statement.setString(2, email); try (ResultSet resultSet = statement.executeQuery()) { return resultSet.next(); } } catch (Exception e) { throw new CustomChangeException(e); } }
[ "private", "boolean", "isPanelUser", "(", "JdbcConnection", "connection", ",", "Long", "panelId", ",", "String", "email", ")", "throws", "CustomChangeException", "{", "try", "(", "PreparedStatement", "statement", "=", "connection", ".", "prepareStatement", "(", "\"SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)\"", ")", ")", "{", "statement", ".", "setLong", "(", "1", ",", "panelId", ")", ";", "statement", ".", "setString", "(", "2", ",", "email", ")", ";", "try", "(", "ResultSet", "resultSet", "=", "statement", ".", "executeQuery", "(", ")", ")", "{", "return", "resultSet", ".", "next", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "CustomChangeException", "(", "e", ")", ";", "}", "}" ]
Returns whether user by email is a PanelUser or not @param connection connection @param panelId panel id @param email email @return whether user by email is a PanelUser or not @throws CustomChangeException on error
[ "Returns", "whether", "user", "by", "email", "is", "a", "PanelUser", "or", "not" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java#L48-L59
144,409
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java
FixInvitations.deleteInvitation
private void deleteInvitation(JdbcConnection connection, Long id) throws CustomChangeException { try (PreparedStatement statement = connection.prepareStatement("DELETE FROM PANELINVITATION WHERE id = ?")) { statement.setLong(1, id); statement.execute(); } catch (Exception e) { throw new CustomChangeException(e); } }
java
private void deleteInvitation(JdbcConnection connection, Long id) throws CustomChangeException { try (PreparedStatement statement = connection.prepareStatement("DELETE FROM PANELINVITATION WHERE id = ?")) { statement.setLong(1, id); statement.execute(); } catch (Exception e) { throw new CustomChangeException(e); } }
[ "private", "void", "deleteInvitation", "(", "JdbcConnection", "connection", ",", "Long", "id", ")", "throws", "CustomChangeException", "{", "try", "(", "PreparedStatement", "statement", "=", "connection", ".", "prepareStatement", "(", "\"DELETE FROM PANELINVITATION WHERE id = ?\"", ")", ")", "{", "statement", ".", "setLong", "(", "1", ",", "id", ")", ";", "statement", ".", "execute", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "CustomChangeException", "(", "e", ")", ";", "}", "}" ]
Deletes an invitation @param connection connection @param id invitation id @throws CustomChangeException on error
[ "Deletes", "an", "invitation" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java#L68-L75
144,410
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/QueryFieldDataStatistics.java
QueryFieldDataStatistics.getQuantile
public Double getQuantile(int quantile, int base) { if (getCount() == 0) return null; if ((quantile > base) || (quantile <= 0) || (base <= 0)) throw new IllegalArgumentException("Incorrect quantile/base specified."); double quantileFraq = (double) quantile / base; int index = (int) Math.round(quantileFraq * (getCount() - 1)); return (double) data.get(index) + shift; }
java
public Double getQuantile(int quantile, int base) { if (getCount() == 0) return null; if ((quantile > base) || (quantile <= 0) || (base <= 0)) throw new IllegalArgumentException("Incorrect quantile/base specified."); double quantileFraq = (double) quantile / base; int index = (int) Math.round(quantileFraq * (getCount() - 1)); return (double) data.get(index) + shift; }
[ "public", "Double", "getQuantile", "(", "int", "quantile", ",", "int", "base", ")", "{", "if", "(", "getCount", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "(", "quantile", ">", "base", ")", "||", "(", "quantile", "<=", "0", ")", "||", "(", "base", "<=", "0", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Incorrect quantile/base specified.\"", ")", ";", "double", "quantileFraq", "=", "(", "double", ")", "quantile", "/", "base", ";", "int", "index", "=", "(", "int", ")", "Math", ".", "round", "(", "quantileFraq", "*", "(", "getCount", "(", ")", "-", "1", ")", ")", ";", "return", "(", "double", ")", "data", ".", "get", "(", "index", ")", "+", "shift", ";", "}" ]
Returns quantile over base value. @param quantile quantile index @param base quantile base @return quantile over base value.
[ "Returns", "quantile", "over", "base", "value", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/QueryFieldDataStatistics.java#L110-L122
144,411
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/thesis/ThesisTimelineQueryReportPage.java
ThesisTimelineQueryReportPage.createStatistics
private QueryFieldDataStatistics createStatistics(List<Double> data, double min, double max, double step) { Map<Double, String> dataNames = new HashMap<>(); for (double d = min; d <= max; d += step) { String caption = step % 1 == 0 ? Long.toString(Math.round(d)) : Double.toString(d); dataNames.put(d, caption); } return ReportUtils.getStatistics(data, dataNames); }
java
private QueryFieldDataStatistics createStatistics(List<Double> data, double min, double max, double step) { Map<Double, String> dataNames = new HashMap<>(); for (double d = min; d <= max; d += step) { String caption = step % 1 == 0 ? Long.toString(Math.round(d)) : Double.toString(d); dataNames.put(d, caption); } return ReportUtils.getStatistics(data, dataNames); }
[ "private", "QueryFieldDataStatistics", "createStatistics", "(", "List", "<", "Double", ">", "data", ",", "double", "min", ",", "double", "max", ",", "double", "step", ")", "{", "Map", "<", "Double", ",", "String", ">", "dataNames", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "double", "d", "=", "min", ";", "d", "<=", "max", ";", "d", "+=", "step", ")", "{", "String", "caption", "=", "step", "%", "1", "==", "0", "?", "Long", ".", "toString", "(", "Math", ".", "round", "(", "d", ")", ")", ":", "Double", ".", "toString", "(", "d", ")", ";", "dataNames", ".", "put", "(", "d", ",", "caption", ")", ";", "}", "return", "ReportUtils", ".", "getStatistics", "(", "data", ",", "dataNames", ")", ";", "}" ]
Creates statistics object @param data data @param min min @param max max @param step step @return statistics object
[ "Creates", "statistics", "object" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/thesis/ThesisTimelineQueryReportPage.java#L142-L151
144,412
blackdoor/blackdoor
src/main/java/black/door/util/CommandLineParser.java
CommandLineParser.getParsedArgs
@Deprecated public List<List<String>> getParsedArgs(String[] args) throws InvalidFormatException { for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { if (this.params.size() > 0) { List<String> option = new ArrayList<String>(); option.add(this.params.get(0).longOption); this.params.remove(0); option.add(args[i]); sortedArgs.add(option); } else { throw new InvalidFormatException( "Expected command line option, found " + args[i] + " instead."); } } else { for (Argument option : this.args) { if (option.matchesFlag(args[i])) { List<String> command = new ArrayList<String>(); command.add(noDashes(args[i])); if (option.takesValue) { try { if (args[i + 1].startsWith("-")) { if (option.valueRequired) throw new InvalidFormatException( "Invalid command line format: -" + option.option + " or --" + option.longOption + " requires a parameter, found " + args[i + 1] + " instead."); } else { command.add(args[++i]); } } catch (ArrayIndexOutOfBoundsException e) { } } sortedArgs.add(command); break; } } } } return sortedArgs; }
java
@Deprecated public List<List<String>> getParsedArgs(String[] args) throws InvalidFormatException { for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { if (this.params.size() > 0) { List<String> option = new ArrayList<String>(); option.add(this.params.get(0).longOption); this.params.remove(0); option.add(args[i]); sortedArgs.add(option); } else { throw new InvalidFormatException( "Expected command line option, found " + args[i] + " instead."); } } else { for (Argument option : this.args) { if (option.matchesFlag(args[i])) { List<String> command = new ArrayList<String>(); command.add(noDashes(args[i])); if (option.takesValue) { try { if (args[i + 1].startsWith("-")) { if (option.valueRequired) throw new InvalidFormatException( "Invalid command line format: -" + option.option + " or --" + option.longOption + " requires a parameter, found " + args[i + 1] + " instead."); } else { command.add(args[++i]); } } catch (ArrayIndexOutOfBoundsException e) { } } sortedArgs.add(command); break; } } } } return sortedArgs; }
[ "@", "Deprecated", "public", "List", "<", "List", "<", "String", ">", ">", "getParsedArgs", "(", "String", "[", "]", "args", ")", "throws", "InvalidFormatException", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "args", "[", "i", "]", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "if", "(", "this", ".", "params", ".", "size", "(", ")", ">", "0", ")", "{", "List", "<", "String", ">", "option", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "option", ".", "add", "(", "this", ".", "params", ".", "get", "(", "0", ")", ".", "longOption", ")", ";", "this", ".", "params", ".", "remove", "(", "0", ")", ";", "option", ".", "add", "(", "args", "[", "i", "]", ")", ";", "sortedArgs", ".", "add", "(", "option", ")", ";", "}", "else", "{", "throw", "new", "InvalidFormatException", "(", "\"Expected command line option, found \"", "+", "args", "[", "i", "]", "+", "\" instead.\"", ")", ";", "}", "}", "else", "{", "for", "(", "Argument", "option", ":", "this", ".", "args", ")", "{", "if", "(", "option", ".", "matchesFlag", "(", "args", "[", "i", "]", ")", ")", "{", "List", "<", "String", ">", "command", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "command", ".", "add", "(", "noDashes", "(", "args", "[", "i", "]", ")", ")", ";", "if", "(", "option", ".", "takesValue", ")", "{", "try", "{", "if", "(", "args", "[", "i", "+", "1", "]", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "if", "(", "option", ".", "valueRequired", ")", "throw", "new", "InvalidFormatException", "(", "\"Invalid command line format: -\"", "+", "option", ".", "option", "+", "\" or --\"", "+", "option", ".", "longOption", "+", "\" requires a parameter, found \"", "+", "args", "[", "i", "+", "1", "]", "+", "\" instead.\"", ")", ";", "}", "else", "{", "command", ".", "add", "(", "args", "[", "++", "i", "]", ")", ";", "}", "}", "catch", "(", "ArrayIndexOutOfBoundsException", "e", ")", "{", "}", "}", "sortedArgs", ".", "add", "(", "command", ")", ";", "break", ";", "}", "}", "}", "}", "return", "sortedArgs", ";", "}" ]
Get the parsed and checked command line arguments for this parser @param args - The command line arguments to add. These can be passed straight from the parameter of main(String[]) <p> @return A list of strings, the first([0]) element in each list is the command line option, if the second([1]) element exists it is the parameter for that option. <p> Returns null if parseArgs(String[]) has not been called. @throws InvalidFormatException
[ "Get", "the", "parsed", "and", "checked", "command", "line", "arguments", "for", "this", "parser" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/util/CommandLineParser.java#L75-L123
144,413
blackdoor/blackdoor
src/main/java/black/door/util/CommandLineParser.java
CommandLineParser.addArguments
@Deprecated public void addArguments(String[] argList) throws DuplicateOptionException, InvalidFormatException { for (String arg : argList) { Argument f = new Argument(); String[] breakdown = arg.split(","); for (String s : breakdown) { s = s.trim(); if (s.startsWith("--")) { f.longOption = noDashes(s); } else if (s.startsWith("-h")) { f.helpText = s.substring(2); } else if (s.startsWith("-")) { f.option = noDashes(s); } else if (s.equals("+")) { f.takesValue = true; f.valueRequired = true; } else if (s.equals("?")) { f.isParam = true; f.takesValue = true; params.add(f); } else if (s.equals("*")) { f.takesValue = true; } else { throw new InvalidFormatException(s + " in " + arg + " is not formatted correctly."); } } addArgument(f); } }
java
@Deprecated public void addArguments(String[] argList) throws DuplicateOptionException, InvalidFormatException { for (String arg : argList) { Argument f = new Argument(); String[] breakdown = arg.split(","); for (String s : breakdown) { s = s.trim(); if (s.startsWith("--")) { f.longOption = noDashes(s); } else if (s.startsWith("-h")) { f.helpText = s.substring(2); } else if (s.startsWith("-")) { f.option = noDashes(s); } else if (s.equals("+")) { f.takesValue = true; f.valueRequired = true; } else if (s.equals("?")) { f.isParam = true; f.takesValue = true; params.add(f); } else if (s.equals("*")) { f.takesValue = true; } else { throw new InvalidFormatException(s + " in " + arg + " is not formatted correctly."); } } addArgument(f); } }
[ "@", "Deprecated", "public", "void", "addArguments", "(", "String", "[", "]", "argList", ")", "throws", "DuplicateOptionException", ",", "InvalidFormatException", "{", "for", "(", "String", "arg", ":", "argList", ")", "{", "Argument", "f", "=", "new", "Argument", "(", ")", ";", "String", "[", "]", "breakdown", "=", "arg", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "s", ":", "breakdown", ")", "{", "s", "=", "s", ".", "trim", "(", ")", ";", "if", "(", "s", ".", "startsWith", "(", "\"--\"", ")", ")", "{", "f", ".", "longOption", "=", "noDashes", "(", "s", ")", ";", "}", "else", "if", "(", "s", ".", "startsWith", "(", "\"-h\"", ")", ")", "{", "f", ".", "helpText", "=", "s", ".", "substring", "(", "2", ")", ";", "}", "else", "if", "(", "s", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "f", ".", "option", "=", "noDashes", "(", "s", ")", ";", "}", "else", "if", "(", "s", ".", "equals", "(", "\"+\"", ")", ")", "{", "f", ".", "takesValue", "=", "true", ";", "f", ".", "valueRequired", "=", "true", ";", "}", "else", "if", "(", "s", ".", "equals", "(", "\"?\"", ")", ")", "{", "f", ".", "isParam", "=", "true", ";", "f", ".", "takesValue", "=", "true", ";", "params", ".", "add", "(", "f", ")", ";", "}", "else", "if", "(", "s", ".", "equals", "(", "\"*\"", ")", ")", "{", "f", ".", "takesValue", "=", "true", ";", "}", "else", "{", "throw", "new", "InvalidFormatException", "(", "s", "+", "\" in \"", "+", "arg", "+", "\" is not formatted correctly.\"", ")", ";", "}", "}", "addArgument", "(", "f", ")", ";", "}", "}" ]
adds options for this command line parser @param argList a list of Strings of options in a comma separated format <p> single char options should be prepended with a single "-" <p> string options should be prepended with "--" <p> non-option parameters should add a "?" to the string. non-option parameters should define the string (long/--) form option. <p> ie. parameters that would not have an explicit option before them <p> eg. cp source.txt dest.txt <p> to add helptext for this option, add -h followed by the help text <p> if there MUST be a parameter after this command line option then add a "+" to the string. alternatively if there MAY be a parameter after this command line option then add a "*" to the string <p> eg. "-r,--readonly" or "--file,-f,+" or "*, -f, --flag, -h this is helptext" or "--source, ?" @throws DuplicateOptionException @throws InvalidFormatException
[ "adds", "options", "for", "this", "command", "line", "parser" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/util/CommandLineParser.java#L449-L479
144,414
blackdoor/blackdoor
src/main/java/black/door/util/CommandLineParser.java
CommandLineParser.addArgument
@Deprecated public void addArgument(char shortForm, String longForm, String helpText, boolean isParameter, boolean takesValue, boolean valueRequired) throws DuplicateOptionException { Argument f = new Argument(); f.option = "" + shortForm; f.longOption = longForm; f.takesValue = takesValue; f.valueRequired = valueRequired; f.helpText = helpText; f.isParam = isParameter; if (isParameter) params.add(f); addArgument(f); }
java
@Deprecated public void addArgument(char shortForm, String longForm, String helpText, boolean isParameter, boolean takesValue, boolean valueRequired) throws DuplicateOptionException { Argument f = new Argument(); f.option = "" + shortForm; f.longOption = longForm; f.takesValue = takesValue; f.valueRequired = valueRequired; f.helpText = helpText; f.isParam = isParameter; if (isParameter) params.add(f); addArgument(f); }
[ "@", "Deprecated", "public", "void", "addArgument", "(", "char", "shortForm", ",", "String", "longForm", ",", "String", "helpText", ",", "boolean", "isParameter", ",", "boolean", "takesValue", ",", "boolean", "valueRequired", ")", "throws", "DuplicateOptionException", "{", "Argument", "f", "=", "new", "Argument", "(", ")", ";", "f", ".", "option", "=", "\"\"", "+", "shortForm", ";", "f", ".", "longOption", "=", "longForm", ";", "f", ".", "takesValue", "=", "takesValue", ";", "f", ".", "valueRequired", "=", "valueRequired", ";", "f", ".", "helpText", "=", "helpText", ";", "f", ".", "isParam", "=", "isParameter", ";", "if", "(", "isParameter", ")", "params", ".", "add", "(", "f", ")", ";", "addArgument", "(", "f", ")", ";", "}" ]
Add an argument for this command line parser. Options should not be prepended by dashes. @param shortForm Single character command line option @param longForm String command line option @param helpText Help text to show after the short and long form in getHelpText() @param isParameter True if this argument is a parameter and will not be preceded by an option @param valueRequired True if the user MUST enter a value for this argument. @param takesValue Should be true if this option may followed by a value when called from the command line. @throws DuplicateOptionException Thrown if this parser already has an option with the same short or long form.
[ "Add", "an", "argument", "for", "this", "command", "line", "parser", ".", "Options", "should", "not", "be", "prepended", "by", "dashes", "." ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/util/CommandLineParser.java#L520-L534
144,415
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.add
public void add(JDesktopPaneLayout child, Object constraints, int index) { if (child.parent != this) { throw new IllegalArgumentException( "Layout is not a child of this layout"); } container.add(child.container, constraints, index); }
java
public void add(JDesktopPaneLayout child, Object constraints, int index) { if (child.parent != this) { throw new IllegalArgumentException( "Layout is not a child of this layout"); } container.add(child.container, constraints, index); }
[ "public", "void", "add", "(", "JDesktopPaneLayout", "child", ",", "Object", "constraints", ",", "int", "index", ")", "{", "if", "(", "child", ".", "parent", "!=", "this", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Layout is not a child of this layout\"", ")", ";", "}", "container", ".", "add", "(", "child", ".", "container", ",", "constraints", ",", "index", ")", ";", "}" ]
Add the given desktop pane layout as a child to this one @param child The child to add @param constraints The constraints. See {@link Container#add(Component, Object)} @param index The index. See {@link Container#add(Component, Object, int)} @throws IllegalArgumentException If the given child was not created by calling {@link #createChild()} on this layout
[ "Add", "the", "given", "desktop", "pane", "layout", "as", "a", "child", "to", "this", "one" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L271-L279
144,416
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.remove
public void remove(JDesktopPaneLayout child) { if (child.parent != this) { throw new IllegalArgumentException( "Layout is not a child of this layout"); } container.remove(child.container); }
java
public void remove(JDesktopPaneLayout child) { if (child.parent != this) { throw new IllegalArgumentException( "Layout is not a child of this layout"); } container.remove(child.container); }
[ "public", "void", "remove", "(", "JDesktopPaneLayout", "child", ")", "{", "if", "(", "child", ".", "parent", "!=", "this", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Layout is not a child of this layout\"", ")", ";", "}", "container", ".", "remove", "(", "child", ".", "container", ")", ";", "}" ]
Remove the given child layout @param child The child to remove @throws IllegalArgumentException If the given child was not created by calling {@link #createChild()} on this layout
[ "Remove", "the", "given", "child", "layout" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L288-L296
144,417
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.validate
public void validate() { Dimension size = desktopPane.getSize(); size.height -= computeDesktopIconsSpace(); layoutInternalFrames(size); }
java
public void validate() { Dimension size = desktopPane.getSize(); size.height -= computeDesktopIconsSpace(); layoutInternalFrames(size); }
[ "public", "void", "validate", "(", ")", "{", "Dimension", "size", "=", "desktopPane", ".", "getSize", "(", ")", ";", "size", ".", "height", "-=", "computeDesktopIconsSpace", "(", ")", ";", "layoutInternalFrames", "(", "size", ")", ";", "}" ]
Validate the layout after internal frames have been added or removed
[ "Validate", "the", "layout", "after", "internal", "frames", "have", "been", "added", "or", "removed" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L379-L384
144,418
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.computeDesktopIconsSpace
private int computeDesktopIconsSpace() { for (JInternalFrame f : frameToComponent.keySet()) { if (f.isIcon()) { JDesktopIcon desktopIcon = f.getDesktopIcon(); return desktopIcon.getPreferredSize().height; } } return 0; }
java
private int computeDesktopIconsSpace() { for (JInternalFrame f : frameToComponent.keySet()) { if (f.isIcon()) { JDesktopIcon desktopIcon = f.getDesktopIcon(); return desktopIcon.getPreferredSize().height; } } return 0; }
[ "private", "int", "computeDesktopIconsSpace", "(", ")", "{", "for", "(", "JInternalFrame", "f", ":", "frameToComponent", ".", "keySet", "(", ")", ")", "{", "if", "(", "f", ".", "isIcon", "(", ")", ")", "{", "JDesktopIcon", "desktopIcon", "=", "f", ".", "getDesktopIcon", "(", ")", ";", "return", "desktopIcon", ".", "getPreferredSize", "(", ")", ".", "height", ";", "}", "}", "return", "0", ";", "}" ]
Compute the space for iconified desktop icons @return The space
[ "Compute", "the", "space", "for", "iconified", "desktop", "icons" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L391-L402
144,419
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.callDoLayout
private void callDoLayout(Container container) { container.doLayout(); int n = container.getComponentCount(); for (int i=0; i<n; i++) { Component component = container.getComponent(i); if (component instanceof Container) { Container subContainer = (Container)component; callDoLayout(subContainer); } } }
java
private void callDoLayout(Container container) { container.doLayout(); int n = container.getComponentCount(); for (int i=0; i<n; i++) { Component component = container.getComponent(i); if (component instanceof Container) { Container subContainer = (Container)component; callDoLayout(subContainer); } } }
[ "private", "void", "callDoLayout", "(", "Container", "container", ")", "{", "container", ".", "doLayout", "(", ")", ";", "int", "n", "=", "container", ".", "getComponentCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "Component", "component", "=", "container", ".", "getComponent", "(", "i", ")", ";", "if", "(", "component", "instanceof", "Container", ")", "{", "Container", "subContainer", "=", "(", "Container", ")", "component", ";", "callDoLayout", "(", "subContainer", ")", ";", "}", "}", "}" ]
Recursively call doLayout on the container and all its sub-containers @param container The container
[ "Recursively", "call", "doLayout", "on", "the", "container", "and", "all", "its", "sub", "-", "containers" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L422-L435
144,420
javagl/CommonUI
src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java
JDesktopPaneLayout.applyLayout
private void applyLayout() { int n = container.getComponentCount(); for (int i=0; i<n; i++) { Component component = container.getComponent(i); if (component instanceof FrameComponent) { FrameComponent frameComponent = (FrameComponent)component; JInternalFrame internalFrame = frameComponent.getInternalFrame(); Rectangle bounds = SwingUtilities.convertRectangle( container, component.getBounds(), rootContainer); //System.out.println( // "Set bounds of "+internalFrame.getTitle()+" to "+bounds); internalFrame.setBounds(bounds); } else { LayoutContainer childLayoutContainer = (LayoutContainer)component; //System.out.println( // "Child with "+childLayoutContainer.getLayout()); childLayoutContainer.owner.applyLayout(); } } }
java
private void applyLayout() { int n = container.getComponentCount(); for (int i=0; i<n; i++) { Component component = container.getComponent(i); if (component instanceof FrameComponent) { FrameComponent frameComponent = (FrameComponent)component; JInternalFrame internalFrame = frameComponent.getInternalFrame(); Rectangle bounds = SwingUtilities.convertRectangle( container, component.getBounds(), rootContainer); //System.out.println( // "Set bounds of "+internalFrame.getTitle()+" to "+bounds); internalFrame.setBounds(bounds); } else { LayoutContainer childLayoutContainer = (LayoutContainer)component; //System.out.println( // "Child with "+childLayoutContainer.getLayout()); childLayoutContainer.owner.applyLayout(); } } }
[ "private", "void", "applyLayout", "(", ")", "{", "int", "n", "=", "container", ".", "getComponentCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "Component", "component", "=", "container", ".", "getComponent", "(", "i", ")", ";", "if", "(", "component", "instanceof", "FrameComponent", ")", "{", "FrameComponent", "frameComponent", "=", "(", "FrameComponent", ")", "component", ";", "JInternalFrame", "internalFrame", "=", "frameComponent", ".", "getInternalFrame", "(", ")", ";", "Rectangle", "bounds", "=", "SwingUtilities", ".", "convertRectangle", "(", "container", ",", "component", ".", "getBounds", "(", ")", ",", "rootContainer", ")", ";", "//System.out.println(\r", "// \"Set bounds of \"+internalFrame.getTitle()+\" to \"+bounds);\r", "internalFrame", ".", "setBounds", "(", "bounds", ")", ";", "}", "else", "{", "LayoutContainer", "childLayoutContainer", "=", "(", "LayoutContainer", ")", "component", ";", "//System.out.println(\r", "// \"Child with \"+childLayoutContainer.getLayout());\r", "childLayoutContainer", ".", "owner", ".", "applyLayout", "(", ")", ";", "}", "}", "}" ]
Apply the current layout to the internal frames
[ "Apply", "the", "current", "layout", "to", "the", "internal", "frames" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/utils/desktop/JDesktopPaneLayout.java#L441-L467
144,421
sebastiangraf/perfidix
src/main/java/org/perfidix/result/BenchmarkResult.java
BenchmarkResult.addData
public void addData(final BenchmarkMethod meth, final AbstractMeter meter, final double data) { final Class<?> clazz = meth.getMethodToBench().getDeclaringClass(); if (!elements.containsKey(clazz)) { elements.put(clazz, new ClassResult(clazz)); } final ClassResult clazzResult = elements.get(clazz); if (!clazzResult.elements.containsKey(meth)) { clazzResult.elements.put(meth, new MethodResult(meth)); } final MethodResult methodResult = clazzResult.elements.get(meth); methodResult.addData(meter, data); clazzResult.addData(meter, data); this.addData(meter, data); for (final AbstractOutput output : outputs) { output.listenToResultSet(meth, meter, data); } }
java
public void addData(final BenchmarkMethod meth, final AbstractMeter meter, final double data) { final Class<?> clazz = meth.getMethodToBench().getDeclaringClass(); if (!elements.containsKey(clazz)) { elements.put(clazz, new ClassResult(clazz)); } final ClassResult clazzResult = elements.get(clazz); if (!clazzResult.elements.containsKey(meth)) { clazzResult.elements.put(meth, new MethodResult(meth)); } final MethodResult methodResult = clazzResult.elements.get(meth); methodResult.addData(meter, data); clazzResult.addData(meter, data); this.addData(meter, data); for (final AbstractOutput output : outputs) { output.listenToResultSet(meth, meter, data); } }
[ "public", "void", "addData", "(", "final", "BenchmarkMethod", "meth", ",", "final", "AbstractMeter", "meter", ",", "final", "double", "data", ")", "{", "final", "Class", "<", "?", ">", "clazz", "=", "meth", ".", "getMethodToBench", "(", ")", ".", "getDeclaringClass", "(", ")", ";", "if", "(", "!", "elements", ".", "containsKey", "(", "clazz", ")", ")", "{", "elements", ".", "put", "(", "clazz", ",", "new", "ClassResult", "(", "clazz", ")", ")", ";", "}", "final", "ClassResult", "clazzResult", "=", "elements", ".", "get", "(", "clazz", ")", ";", "if", "(", "!", "clazzResult", ".", "elements", ".", "containsKey", "(", "meth", ")", ")", "{", "clazzResult", ".", "elements", ".", "put", "(", "meth", ",", "new", "MethodResult", "(", "meth", ")", ")", ";", "}", "final", "MethodResult", "methodResult", "=", "clazzResult", ".", "elements", ".", "get", "(", "meth", ")", ";", "methodResult", ".", "addData", "(", "meter", ",", "data", ")", ";", "clazzResult", ".", "addData", "(", "meter", ",", "data", ")", ";", "this", ".", "addData", "(", "meter", ",", "data", ")", ";", "for", "(", "final", "AbstractOutput", "output", ":", "outputs", ")", "{", "output", ".", "listenToResultSet", "(", "meth", ",", "meter", ",", "data", ")", ";", "}", "}" ]
Adding a dataset to a given meter and adapting the underlaying result model. @param meth where the result is corresponding to @param meter where the result is corresponding to @param data the data itself
[ "Adding", "a", "dataset", "to", "a", "given", "meter", "and", "adapting", "the", "underlaying", "result", "model", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/BenchmarkResult.java#L79-L101
144,422
sebastiangraf/perfidix
src/main/java/org/perfidix/result/BenchmarkResult.java
BenchmarkResult.addException
public void addException(final AbstractPerfidixMethodException exec) { this.getExceptions().add(exec); for (final AbstractOutput output : outputs) { output.listenToException(exec); } }
java
public void addException(final AbstractPerfidixMethodException exec) { this.getExceptions().add(exec); for (final AbstractOutput output : outputs) { output.listenToException(exec); } }
[ "public", "void", "addException", "(", "final", "AbstractPerfidixMethodException", "exec", ")", "{", "this", ".", "getExceptions", "(", ")", ".", "add", "(", "exec", ")", ";", "for", "(", "final", "AbstractOutput", "output", ":", "outputs", ")", "{", "output", ".", "listenToException", "(", "exec", ")", ";", "}", "}" ]
Adding an exception to this result. @param exec the exception stored to this result
[ "Adding", "an", "exception", "to", "this", "result", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/BenchmarkResult.java#L108-L113
144,423
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/Actions.java
Actions.create
static Action create(Runnable command) { Objects.requireNonNull(command, "The command may not be null"); return new AbstractAction() { /** * Serial UID */ private static final long serialVersionUID = 8693271079128413874L; @Override public void actionPerformed(ActionEvent e) { command.run(); } }; }
java
static Action create(Runnable command) { Objects.requireNonNull(command, "The command may not be null"); return new AbstractAction() { /** * Serial UID */ private static final long serialVersionUID = 8693271079128413874L; @Override public void actionPerformed(ActionEvent e) { command.run(); } }; }
[ "static", "Action", "create", "(", "Runnable", "command", ")", "{", "Objects", ".", "requireNonNull", "(", "command", ",", "\"The command may not be null\"", ")", ";", "return", "new", "AbstractAction", "(", ")", "{", "/**\r\n * Serial UID\r\n */", "private", "static", "final", "long", "serialVersionUID", "=", "8693271079128413874L", ";", "@", "Override", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "command", ".", "run", "(", ")", ";", "}", "}", ";", "}" ]
Create a new action that simply executes the given command @param command The command @return The action
[ "Create", "a", "new", "action", "that", "simply", "executes", "the", "given", "command" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/Actions.java#L46-L62
144,424
blackdoor/blackdoor
src/main/java/black/door/crypto/Crypto.java
Crypto.doAESEncryption
public void doAESEncryption() throws Exception{ if(!initAESDone) initAES(); cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); //System.out.println(secretKey.getEncoded()); cipher.init(Cipher.ENCRYPT_MODE, secretKey); AlgorithmParameters params = cipher.getParameters(); iv = params.getParameterSpec(IvParameterSpec.class).getIV(); secretCipher = cipher.doFinal(secretPlain); clearPlain(); }
java
public void doAESEncryption() throws Exception{ if(!initAESDone) initAES(); cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); //System.out.println(secretKey.getEncoded()); cipher.init(Cipher.ENCRYPT_MODE, secretKey); AlgorithmParameters params = cipher.getParameters(); iv = params.getParameterSpec(IvParameterSpec.class).getIV(); secretCipher = cipher.doFinal(secretPlain); clearPlain(); }
[ "public", "void", "doAESEncryption", "(", ")", "throws", "Exception", "{", "if", "(", "!", "initAESDone", ")", "initAES", "(", ")", ";", "cipher", "=", "Cipher", ".", "getInstance", "(", "\"AES/CBC/PKCS5Padding\"", ")", ";", "//System.out.println(secretKey.getEncoded());", "cipher", ".", "init", "(", "Cipher", ".", "ENCRYPT_MODE", ",", "secretKey", ")", ";", "AlgorithmParameters", "params", "=", "cipher", ".", "getParameters", "(", ")", ";", "iv", "=", "params", ".", "getParameterSpec", "(", "IvParameterSpec", ".", "class", ")", ".", "getIV", "(", ")", ";", "secretCipher", "=", "cipher", ".", "doFinal", "(", "secretPlain", ")", ";", "clearPlain", "(", ")", ";", "}" ]
clears all plaintext passwords and secrets. password, secret and initAES must all be set before re-using @throws Exception
[ "clears", "all", "plaintext", "passwords", "and", "secrets", ".", "password", "secret", "and", "initAES", "must", "all", "be", "set", "before", "re", "-", "using" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/crypto/Crypto.java#L174-L184
144,425
javagl/CommonUI
src/main/java/de/javagl/common/ui/GuiUtils.java
GuiUtils.wrapTitled
public static JPanel wrapTitled(String title, JComponent component) { JPanel p = new JPanel(new GridLayout(1,1)); p.setBorder(BorderFactory.createTitledBorder(title)); p.add(component); return p; }
java
public static JPanel wrapTitled(String title, JComponent component) { JPanel p = new JPanel(new GridLayout(1,1)); p.setBorder(BorderFactory.createTitledBorder(title)); p.add(component); return p; }
[ "public", "static", "JPanel", "wrapTitled", "(", "String", "title", ",", "JComponent", "component", ")", "{", "JPanel", "p", "=", "new", "JPanel", "(", "new", "GridLayout", "(", "1", ",", "1", ")", ")", ";", "p", ".", "setBorder", "(", "BorderFactory", ".", "createTitledBorder", "(", "title", ")", ")", ";", "p", ".", "add", "(", "component", ")", ";", "return", "p", ";", "}" ]
Wrap the given component into a panel with a titled border with the given title @param title The title @param component The component @return The panel
[ "Wrap", "the", "given", "component", "into", "a", "panel", "with", "a", "titled", "border", "with", "the", "given", "title" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/GuiUtils.java#L72-L78
144,426
javagl/CommonUI
src/main/java/de/javagl/common/ui/GuiUtils.java
GuiUtils.wrapFlow
public static JPanel wrapFlow(JComponent component) { JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); p.add(component); return p; }
java
public static JPanel wrapFlow(JComponent component) { JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); p.add(component); return p; }
[ "public", "static", "JPanel", "wrapFlow", "(", "JComponent", "component", ")", "{", "JPanel", "p", "=", "new", "JPanel", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "CENTER", ",", "0", ",", "0", ")", ")", ";", "p", ".", "add", "(", "component", ")", ";", "return", "p", ";", "}" ]
Wrap the given component into a panel with flow layout @param component The component @return The panel
[ "Wrap", "the", "given", "component", "into", "a", "panel", "with", "flow", "layout" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/GuiUtils.java#L86-L91
144,427
javagl/CommonUI
src/main/java/de/javagl/common/ui/GuiUtils.java
GuiUtils.setDeepEnabled
public static void setDeepEnabled(Component component, boolean enabled) { component.setEnabled(enabled); if (component instanceof Container) { Container container = (Container)component; for (Component c : container.getComponents()) { setDeepEnabled(c, enabled); } } }
java
public static void setDeepEnabled(Component component, boolean enabled) { component.setEnabled(enabled); if (component instanceof Container) { Container container = (Container)component; for (Component c : container.getComponents()) { setDeepEnabled(c, enabled); } } }
[ "public", "static", "void", "setDeepEnabled", "(", "Component", "component", ",", "boolean", "enabled", ")", "{", "component", ".", "setEnabled", "(", "enabled", ")", ";", "if", "(", "component", "instanceof", "Container", ")", "{", "Container", "container", "=", "(", "Container", ")", "component", ";", "for", "(", "Component", "c", ":", "container", ".", "getComponents", "(", ")", ")", "{", "setDeepEnabled", "(", "c", ",", "enabled", ")", ";", "}", "}", "}" ]
Enables or disables the given component and all its children recursively @param component The component @param enabled Whether the component tree should be enabled
[ "Enables", "or", "disables", "the", "given", "component", "and", "all", "its", "children", "recursively" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/GuiUtils.java#L100-L111
144,428
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/StringUtils.java
StringUtils.indexOf
static int indexOf(String source, String target, int startIndex, boolean ignoreCase) { if (ignoreCase) { return indexOf(source, target, startIndex, IGNORING_CASE); } return indexOf(source, target, startIndex, (c0, c1) -> Integer.compare(c0, c1)); }
java
static int indexOf(String source, String target, int startIndex, boolean ignoreCase) { if (ignoreCase) { return indexOf(source, target, startIndex, IGNORING_CASE); } return indexOf(source, target, startIndex, (c0, c1) -> Integer.compare(c0, c1)); }
[ "static", "int", "indexOf", "(", "String", "source", ",", "String", "target", ",", "int", "startIndex", ",", "boolean", "ignoreCase", ")", "{", "if", "(", "ignoreCase", ")", "{", "return", "indexOf", "(", "source", ",", "target", ",", "startIndex", ",", "IGNORING_CASE", ")", ";", "}", "return", "indexOf", "(", "source", ",", "target", ",", "startIndex", ",", "(", "c0", ",", "c1", ")", "->", "Integer", ".", "compare", "(", "c0", ",", "c1", ")", ")", ";", "}" ]
Returns the index of the first appearance of the given target in the given source, starting at the given index. Returns -1 if the target string is not found. @param source The source string @param target The target string @param startIndex The start index @param ignoreCase Whether the case should be ignored @return The index
[ "Returns", "the", "index", "of", "the", "first", "appearance", "of", "the", "given", "target", "in", "the", "given", "source", "starting", "at", "the", "given", "index", ".", "Returns", "-", "1", "if", "the", "target", "string", "is", "not", "found", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/StringUtils.java#L66-L75
144,429
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/StringUtils.java
StringUtils.indexOf
private static int indexOf(String source, String target, int startIndex, IntBinaryOperator comparator) { return indexOf( source, 0, source.length(), target, 0, target.length(), startIndex, comparator); }
java
private static int indexOf(String source, String target, int startIndex, IntBinaryOperator comparator) { return indexOf( source, 0, source.length(), target, 0, target.length(), startIndex, comparator); }
[ "private", "static", "int", "indexOf", "(", "String", "source", ",", "String", "target", ",", "int", "startIndex", ",", "IntBinaryOperator", "comparator", ")", "{", "return", "indexOf", "(", "source", ",", "0", ",", "source", ".", "length", "(", ")", ",", "target", ",", "0", ",", "target", ".", "length", "(", ")", ",", "startIndex", ",", "comparator", ")", ";", "}" ]
Returns the index of the first appearance of the given target in the given source, starting at the given index, using the given comparator for characters. Returns -1 if the target string is not found. @param source The source string @param target The target string @param startIndex The start index @param comparator The comparator @return The index
[ "Returns", "the", "index", "of", "the", "first", "appearance", "of", "the", "given", "target", "in", "the", "given", "source", "starting", "at", "the", "given", "index", "using", "the", "given", "comparator", "for", "characters", ".", "Returns", "-", "1", "if", "the", "target", "string", "is", "not", "found", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/StringUtils.java#L89-L96
144,430
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/StringUtils.java
StringUtils.indexOf
private static int indexOf( String source, int sourceOffset, int sourceCount, String target, int targetOffset, int targetCount, int startIndex, IntBinaryOperator comparator) { int fromIndex = startIndex; // Adapted from String#indexOf if (fromIndex >= sourceCount) { return (targetCount == 0 ? sourceCount : -1); } if (fromIndex < 0) { fromIndex = 0; } if (targetCount == 0) { return fromIndex; } char first = target.charAt(targetOffset); int max = sourceOffset + (sourceCount - targetCount); for (int i = sourceOffset + fromIndex; i <= max; i++) { if (comparator.applyAsInt(source.charAt(i), first) != 0) { while (++i <= max && comparator.applyAsInt(source.charAt(i), first) != 0) { // Empty } } if (i <= max) { int j = i + 1; int end = j + targetCount - 1; for (int k = targetOffset + 1; j < end && comparator.applyAsInt(source.charAt(j), target.charAt(k)) == 0; j++, k++) { // Empty } if (j == end) { return i - sourceOffset; } } } return -1; }
java
private static int indexOf( String source, int sourceOffset, int sourceCount, String target, int targetOffset, int targetCount, int startIndex, IntBinaryOperator comparator) { int fromIndex = startIndex; // Adapted from String#indexOf if (fromIndex >= sourceCount) { return (targetCount == 0 ? sourceCount : -1); } if (fromIndex < 0) { fromIndex = 0; } if (targetCount == 0) { return fromIndex; } char first = target.charAt(targetOffset); int max = sourceOffset + (sourceCount - targetCount); for (int i = sourceOffset + fromIndex; i <= max; i++) { if (comparator.applyAsInt(source.charAt(i), first) != 0) { while (++i <= max && comparator.applyAsInt(source.charAt(i), first) != 0) { // Empty } } if (i <= max) { int j = i + 1; int end = j + targetCount - 1; for (int k = targetOffset + 1; j < end && comparator.applyAsInt(source.charAt(j), target.charAt(k)) == 0; j++, k++) { // Empty } if (j == end) { return i - sourceOffset; } } } return -1; }
[ "private", "static", "int", "indexOf", "(", "String", "source", ",", "int", "sourceOffset", ",", "int", "sourceCount", ",", "String", "target", ",", "int", "targetOffset", ",", "int", "targetCount", ",", "int", "startIndex", ",", "IntBinaryOperator", "comparator", ")", "{", "int", "fromIndex", "=", "startIndex", ";", "// Adapted from String#indexOf\r", "if", "(", "fromIndex", ">=", "sourceCount", ")", "{", "return", "(", "targetCount", "==", "0", "?", "sourceCount", ":", "-", "1", ")", ";", "}", "if", "(", "fromIndex", "<", "0", ")", "{", "fromIndex", "=", "0", ";", "}", "if", "(", "targetCount", "==", "0", ")", "{", "return", "fromIndex", ";", "}", "char", "first", "=", "target", ".", "charAt", "(", "targetOffset", ")", ";", "int", "max", "=", "sourceOffset", "+", "(", "sourceCount", "-", "targetCount", ")", ";", "for", "(", "int", "i", "=", "sourceOffset", "+", "fromIndex", ";", "i", "<=", "max", ";", "i", "++", ")", "{", "if", "(", "comparator", ".", "applyAsInt", "(", "source", ".", "charAt", "(", "i", ")", ",", "first", ")", "!=", "0", ")", "{", "while", "(", "++", "i", "<=", "max", "&&", "comparator", ".", "applyAsInt", "(", "source", ".", "charAt", "(", "i", ")", ",", "first", ")", "!=", "0", ")", "{", "// Empty \r", "}", "}", "if", "(", "i", "<=", "max", ")", "{", "int", "j", "=", "i", "+", "1", ";", "int", "end", "=", "j", "+", "targetCount", "-", "1", ";", "for", "(", "int", "k", "=", "targetOffset", "+", "1", ";", "j", "<", "end", "&&", "comparator", ".", "applyAsInt", "(", "source", ".", "charAt", "(", "j", ")", ",", "target", ".", "charAt", "(", "k", ")", ")", "==", "0", ";", "j", "++", ",", "k", "++", ")", "{", "// Empty \r", "}", "if", "(", "j", "==", "end", ")", "{", "return", "i", "-", "sourceOffset", ";", "}", "}", "}", "return", "-", "1", ";", "}" ]
Returns the index of the first appearance of the given range of the target in the given range of the source, source, starting at the given index, using the given comparator for characters. Returns -1 if the target string is not found. @param source The source string @param sourceOffset The source offset @param sourceCount The source length @param target The target string @param targetOffset The target offset @param targetCount The target length @param startIndex The start index @param comparator The comparator @return The index
[ "Returns", "the", "index", "of", "the", "first", "appearance", "of", "the", "given", "range", "of", "the", "target", "in", "the", "given", "range", "of", "the", "source", "source", "starting", "at", "the", "given", "index", "using", "the", "given", "comparator", "for", "characters", ".", "Returns", "-", "1", "if", "the", "target", "string", "is", "not", "found", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/StringUtils.java#L114-L165
144,431
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/StringUtils.java
StringUtils.lastIndexOf
private static int lastIndexOf(String source, String target, int startIndex, IntBinaryOperator comparator) { return lastIndexOf( source, 0, source.length(), target, 0, target.length(), startIndex, comparator); }
java
private static int lastIndexOf(String source, String target, int startIndex, IntBinaryOperator comparator) { return lastIndexOf( source, 0, source.length(), target, 0, target.length(), startIndex, comparator); }
[ "private", "static", "int", "lastIndexOf", "(", "String", "source", ",", "String", "target", ",", "int", "startIndex", ",", "IntBinaryOperator", "comparator", ")", "{", "return", "lastIndexOf", "(", "source", ",", "0", ",", "source", ".", "length", "(", ")", ",", "target", ",", "0", ",", "target", ".", "length", "(", ")", ",", "startIndex", ",", "comparator", ")", ";", "}" ]
Returns the index of the previous appearance of the given target in the given source, starting at the given index, using the given comparator for characters. Returns -1 if the target string is not found. @param source The source string @param target The target string @param startIndex The start index @param comparator The comparator @return The index
[ "Returns", "the", "index", "of", "the", "previous", "appearance", "of", "the", "given", "target", "in", "the", "given", "source", "starting", "at", "the", "given", "index", "using", "the", "given", "comparator", "for", "characters", ".", "Returns", "-", "1", "if", "the", "target", "string", "is", "not", "found", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/StringUtils.java#L201-L208
144,432
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/StringUtils.java
StringUtils.lastIndexOf
static int lastIndexOf( String source, int sourceOffset, int sourceCount, String target, int targetOffset, int targetCount, int startIndex, IntBinaryOperator comparator) { int fromIndex = startIndex; // Adapted from String#lastIndexOf int rightIndex = sourceCount - targetCount; if (fromIndex < 0) { return -1; } if (fromIndex > rightIndex) { fromIndex = rightIndex; } if (targetCount == 0) { return fromIndex; } int strLastIndex = targetOffset + targetCount - 1; char strLastChar = target.charAt(strLastIndex); int min = sourceOffset + targetCount - 1; int i = min + fromIndex; startSearchForLastChar: while (true) { while (i >= min && comparator.applyAsInt(source.charAt(i), strLastChar) != 0) { i--; } if (i < min) { return -1; } int j = i - 1; int start = j - (targetCount - 1); int k = strLastIndex - 1; while (j > start) { if (comparator.applyAsInt( source.charAt(j--), target.charAt(k--)) != 0) { i--; continue startSearchForLastChar; } } return start - sourceOffset + 1; } }
java
static int lastIndexOf( String source, int sourceOffset, int sourceCount, String target, int targetOffset, int targetCount, int startIndex, IntBinaryOperator comparator) { int fromIndex = startIndex; // Adapted from String#lastIndexOf int rightIndex = sourceCount - targetCount; if (fromIndex < 0) { return -1; } if (fromIndex > rightIndex) { fromIndex = rightIndex; } if (targetCount == 0) { return fromIndex; } int strLastIndex = targetOffset + targetCount - 1; char strLastChar = target.charAt(strLastIndex); int min = sourceOffset + targetCount - 1; int i = min + fromIndex; startSearchForLastChar: while (true) { while (i >= min && comparator.applyAsInt(source.charAt(i), strLastChar) != 0) { i--; } if (i < min) { return -1; } int j = i - 1; int start = j - (targetCount - 1); int k = strLastIndex - 1; while (j > start) { if (comparator.applyAsInt( source.charAt(j--), target.charAt(k--)) != 0) { i--; continue startSearchForLastChar; } } return start - sourceOffset + 1; } }
[ "static", "int", "lastIndexOf", "(", "String", "source", ",", "int", "sourceOffset", ",", "int", "sourceCount", ",", "String", "target", ",", "int", "targetOffset", ",", "int", "targetCount", ",", "int", "startIndex", ",", "IntBinaryOperator", "comparator", ")", "{", "int", "fromIndex", "=", "startIndex", ";", "// Adapted from String#lastIndexOf\r", "int", "rightIndex", "=", "sourceCount", "-", "targetCount", ";", "if", "(", "fromIndex", "<", "0", ")", "{", "return", "-", "1", ";", "}", "if", "(", "fromIndex", ">", "rightIndex", ")", "{", "fromIndex", "=", "rightIndex", ";", "}", "if", "(", "targetCount", "==", "0", ")", "{", "return", "fromIndex", ";", "}", "int", "strLastIndex", "=", "targetOffset", "+", "targetCount", "-", "1", ";", "char", "strLastChar", "=", "target", ".", "charAt", "(", "strLastIndex", ")", ";", "int", "min", "=", "sourceOffset", "+", "targetCount", "-", "1", ";", "int", "i", "=", "min", "+", "fromIndex", ";", "startSearchForLastChar", ":", "while", "(", "true", ")", "{", "while", "(", "i", ">=", "min", "&&", "comparator", ".", "applyAsInt", "(", "source", ".", "charAt", "(", "i", ")", ",", "strLastChar", ")", "!=", "0", ")", "{", "i", "--", ";", "}", "if", "(", "i", "<", "min", ")", "{", "return", "-", "1", ";", "}", "int", "j", "=", "i", "-", "1", ";", "int", "start", "=", "j", "-", "(", "targetCount", "-", "1", ")", ";", "int", "k", "=", "strLastIndex", "-", "1", ";", "while", "(", "j", ">", "start", ")", "{", "if", "(", "comparator", ".", "applyAsInt", "(", "source", ".", "charAt", "(", "j", "--", ")", ",", "target", ".", "charAt", "(", "k", "--", ")", ")", "!=", "0", ")", "{", "i", "--", ";", "continue", "startSearchForLastChar", ";", "}", "}", "return", "start", "-", "sourceOffset", "+", "1", ";", "}", "}" ]
Returns the index of the previous appearance of the given range of the target in the given range of the source, source, starting at the given index, using the given comparator for characters. Returns -1 if the target string is not found. @param source The source string @param sourceOffset The source offset @param sourceCount The source length @param target The target string @param targetOffset The target offset @param targetCount The target length @param startIndex The start index @param comparator The comparator @return The index
[ "Returns", "the", "index", "of", "the", "previous", "appearance", "of", "the", "given", "range", "of", "the", "target", "in", "the", "given", "range", "of", "the", "source", "source", "starting", "at", "the", "given", "index", "using", "the", "given", "comparator", "for", "characters", ".", "Returns", "-", "1", "if", "the", "target", "string", "is", "not", "found", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/StringUtils.java#L226-L279
144,433
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java
ServiceApiWrapper.doQueryMessages
Observable<ComapiResult<MessagesQueryResponse>> doQueryMessages(@NonNull final String token, @NonNull final String conversationId, final Long from, @NonNull final Integer limit) { return wrapObservable(service.queryMessages(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId, from, limit).map(mapToComapiResult()), log, "Querying messages in " + conversationId); }
java
Observable<ComapiResult<MessagesQueryResponse>> doQueryMessages(@NonNull final String token, @NonNull final String conversationId, final Long from, @NonNull final Integer limit) { return wrapObservable(service.queryMessages(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId, from, limit).map(mapToComapiResult()), log, "Querying messages in " + conversationId); }
[ "Observable", "<", "ComapiResult", "<", "MessagesQueryResponse", ">", ">", "doQueryMessages", "(", "@", "NonNull", "final", "String", "token", ",", "@", "NonNull", "final", "String", "conversationId", ",", "final", "Long", "from", ",", "@", "NonNull", "final", "Integer", "limit", ")", "{", "return", "wrapObservable", "(", "service", ".", "queryMessages", "(", "AuthManager", ".", "addAuthPrefix", "(", "token", ")", ",", "apiSpaceId", ",", "conversationId", ",", "from", ",", "limit", ")", ".", "map", "(", "mapToComapiResult", "(", ")", ")", ",", "log", ",", "\"Querying messages in \"", "+", "conversationId", ")", ";", "}" ]
Query messages in a conversation. @param token Comapi access token. @param conversationId Id of the conversation. @param from Event id to start from when agregating messages. @param limit Limit of messages send in query response. @return Observable to get messages in a conversation.
[ "Query", "messages", "in", "a", "conversation", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java#L307-L309
144,434
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java
ServiceApiWrapper.doIsTyping
Observable<ComapiResult<Void>> doIsTyping(@NonNull final String token, @NonNull final String conversationId, final boolean isTyping) { if (isTyping) { return wrapObservable(service.isTyping(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId).map(mapToComapiResult()), log, "Sending is typing."); } else { return wrapObservable(service.isNotTyping(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId).map(mapToComapiResult()), log, "Sending is not typing"); } }
java
Observable<ComapiResult<Void>> doIsTyping(@NonNull final String token, @NonNull final String conversationId, final boolean isTyping) { if (isTyping) { return wrapObservable(service.isTyping(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId).map(mapToComapiResult()), log, "Sending is typing."); } else { return wrapObservable(service.isNotTyping(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId).map(mapToComapiResult()), log, "Sending is not typing"); } }
[ "Observable", "<", "ComapiResult", "<", "Void", ">", ">", "doIsTyping", "(", "@", "NonNull", "final", "String", "token", ",", "@", "NonNull", "final", "String", "conversationId", ",", "final", "boolean", "isTyping", ")", "{", "if", "(", "isTyping", ")", "{", "return", "wrapObservable", "(", "service", ".", "isTyping", "(", "AuthManager", ".", "addAuthPrefix", "(", "token", ")", ",", "apiSpaceId", ",", "conversationId", ")", ".", "map", "(", "mapToComapiResult", "(", ")", ")", ",", "log", ",", "\"Sending is typing.\"", ")", ";", "}", "else", "{", "return", "wrapObservable", "(", "service", ".", "isNotTyping", "(", "AuthManager", ".", "addAuthPrefix", "(", "token", ")", ",", "apiSpaceId", ",", "conversationId", ")", ".", "map", "(", "mapToComapiResult", "(", ")", ")", ",", "log", ",", "\"Sending is not typing\"", ")", ";", "}", "}" ]
Send information if user started or stopped typing message in a conversation. @param token Comapi access token. @param conversationId Id of the conversation. @return Observable to send 'is typing' notification.
[ "Send", "information", "if", "user", "started", "or", "stopped", "typing", "message", "in", "a", "conversation", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java#L328-L334
144,435
blackdoor/blackdoor
src/main/java/black/door/crypto/SHECipher.java
SHECipher.init
@Override public void init(Key key, IvParameterSpec iv) throws InvalidKeyException { if(!(key instanceof SecretKey)) throw new InvalidKeyException(); int ivLength = iv.getIV().length; if(key.getEncoded().length < MIN_KEY_SIZE || key.getEncoded().length < ivLength) throw new InvalidKeyException("Key must be longer than " + MIN_KEY_SIZE + " bytes and key must be longer than IV."); this.key = key.getEncoded(); this.iv = iv; prehash = Misc.XORintoA(this.key.length == ivLength ? iv.getIV() : Arrays.copyOf(iv.getIV(), this.key.length), this.key); blockNo = 0; buffer = new ByteQueue(getBlockSize()*2); buffer.setResizable(true); cfg = true; }
java
@Override public void init(Key key, IvParameterSpec iv) throws InvalidKeyException { if(!(key instanceof SecretKey)) throw new InvalidKeyException(); int ivLength = iv.getIV().length; if(key.getEncoded().length < MIN_KEY_SIZE || key.getEncoded().length < ivLength) throw new InvalidKeyException("Key must be longer than " + MIN_KEY_SIZE + " bytes and key must be longer than IV."); this.key = key.getEncoded(); this.iv = iv; prehash = Misc.XORintoA(this.key.length == ivLength ? iv.getIV() : Arrays.copyOf(iv.getIV(), this.key.length), this.key); blockNo = 0; buffer = new ByteQueue(getBlockSize()*2); buffer.setResizable(true); cfg = true; }
[ "@", "Override", "public", "void", "init", "(", "Key", "key", ",", "IvParameterSpec", "iv", ")", "throws", "InvalidKeyException", "{", "if", "(", "!", "(", "key", "instanceof", "SecretKey", ")", ")", "throw", "new", "InvalidKeyException", "(", ")", ";", "int", "ivLength", "=", "iv", ".", "getIV", "(", ")", ".", "length", ";", "if", "(", "key", ".", "getEncoded", "(", ")", ".", "length", "<", "MIN_KEY_SIZE", "||", "key", ".", "getEncoded", "(", ")", ".", "length", "<", "ivLength", ")", "throw", "new", "InvalidKeyException", "(", "\"Key must be longer than \"", "+", "MIN_KEY_SIZE", "+", "\" bytes and key must be longer than IV.\"", ")", ";", "this", ".", "key", "=", "key", ".", "getEncoded", "(", ")", ";", "this", ".", "iv", "=", "iv", ";", "prehash", "=", "Misc", ".", "XORintoA", "(", "this", ".", "key", ".", "length", "==", "ivLength", "?", "iv", ".", "getIV", "(", ")", ":", "Arrays", ".", "copyOf", "(", "iv", ".", "getIV", "(", ")", ",", "this", ".", "key", ".", "length", ")", ",", "this", ".", "key", ")", ";", "blockNo", "=", "0", ";", "buffer", "=", "new", "ByteQueue", "(", "getBlockSize", "(", ")", "*", "2", ")", ";", "buffer", ".", "setResizable", "(", "true", ")", ";", "cfg", "=", "true", ";", "}" ]
Initializes the cipher with key and iv @param iv An initialization vector to use for the cipher. @param key A key to encrypt with. @throws InvalidKeyException
[ "Initializes", "the", "cipher", "with", "key", "and", "iv" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/crypto/SHECipher.java#L84-L98
144,436
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onParticipantIsTyping
private void onParticipantIsTyping(ParticipantTypingEvent event) { handler.post(() -> listener.onParticipantIsTyping(event)); log("Event published " + event.toString()); }
java
private void onParticipantIsTyping(ParticipantTypingEvent event) { handler.post(() -> listener.onParticipantIsTyping(event)); log("Event published " + event.toString()); }
[ "private", "void", "onParticipantIsTyping", "(", "ParticipantTypingEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onParticipantIsTyping", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation participant is typing event. @param event Event to dispatch.
[ "Dispatch", "conversation", "participant", "is", "typing", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L135-L138
144,437
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onParticipantTypingOff
private void onParticipantTypingOff(ParticipantTypingOffEvent event) { handler.post(() -> listener.onParticipantTypingOff(event)); log("Event published " + event.toString()); }
java
private void onParticipantTypingOff(ParticipantTypingOffEvent event) { handler.post(() -> listener.onParticipantTypingOff(event)); log("Event published " + event.toString()); }
[ "private", "void", "onParticipantTypingOff", "(", "ParticipantTypingOffEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onParticipantTypingOff", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation participant stopped typing event. @param event Event to dispatch.
[ "Dispatch", "conversation", "participant", "stopped", "typing", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L145-L148
144,438
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onProfileUpdate
private void onProfileUpdate(ProfileUpdateEvent event) { handler.post(() -> listener.onProfileUpdate(event)); log("Event published " + event.toString()); }
java
private void onProfileUpdate(ProfileUpdateEvent event) { handler.post(() -> listener.onProfileUpdate(event)); log("Event published " + event.toString()); }
[ "private", "void", "onProfileUpdate", "(", "ProfileUpdateEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onProfileUpdate", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch profile update event. @param event Event to dispatch.
[ "Dispatch", "profile", "update", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L155-L158
144,439
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onMessageSent
private void onMessageSent(MessageSentEvent event) { handler.post(() -> listener.onMessageSent(event)); log("Event published " + event.toString()); }
java
private void onMessageSent(MessageSentEvent event) { handler.post(() -> listener.onMessageSent(event)); log("Event published " + event.toString()); }
[ "private", "void", "onMessageSent", "(", "MessageSentEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onMessageSent", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation message event. @param event Event to dispatch.
[ "Dispatch", "conversation", "message", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L165-L168
144,440
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onSocketStarted
private void onSocketStarted(SocketStartEvent event) { handler.post(() -> listener.onSocketStarted(event)); log("Event published " + event.toString()); }
java
private void onSocketStarted(SocketStartEvent event) { handler.post(() -> listener.onSocketStarted(event)); log("Event published " + event.toString()); }
[ "private", "void", "onSocketStarted", "(", "SocketStartEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onSocketStarted", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch socket info event. @param event Event to dispatch.
[ "Dispatch", "socket", "info", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L195-L198
144,441
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onParticipantAdded
private void onParticipantAdded(ParticipantAddedEvent event) { handler.post(() -> listener.onParticipantAdded(event)); log("Event published " + event.toString()); }
java
private void onParticipantAdded(ParticipantAddedEvent event) { handler.post(() -> listener.onParticipantAdded(event)); log("Event published " + event.toString()); }
[ "private", "void", "onParticipantAdded", "(", "ParticipantAddedEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onParticipantAdded", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch participant added to a conversation event. @param event Event to dispatch.
[ "Dispatch", "participant", "added", "to", "a", "conversation", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L205-L208
144,442
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onParticipantUpdated
private void onParticipantUpdated(ParticipantUpdatedEvent event) { handler.post(() -> listener.onParticipantUpdated(event)); log("Event published " + event.toString()); }
java
private void onParticipantUpdated(ParticipantUpdatedEvent event) { handler.post(() -> listener.onParticipantUpdated(event)); log("Event published " + event.toString()); }
[ "private", "void", "onParticipantUpdated", "(", "ParticipantUpdatedEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onParticipantUpdated", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch participant updated event. @param event Event to dispatch.
[ "Dispatch", "participant", "updated", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L215-L218
144,443
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onParticipantRemoved
private void onParticipantRemoved(ParticipantRemovedEvent event) { handler.post(() -> listener.onParticipantRemoved(event)); log("Event published " + event.toString()); }
java
private void onParticipantRemoved(ParticipantRemovedEvent event) { handler.post(() -> listener.onParticipantRemoved(event)); log("Event published " + event.toString()); }
[ "private", "void", "onParticipantRemoved", "(", "ParticipantRemovedEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onParticipantRemoved", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch participant removed event. @param event Event to dispatch.
[ "Dispatch", "participant", "removed", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L225-L228
144,444
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onConversationUpdated
private void onConversationUpdated(ConversationUpdateEvent event) { handler.post(() -> listener.onConversationUpdated(event)); log("Event published " + event.toString()); }
java
private void onConversationUpdated(ConversationUpdateEvent event) { handler.post(() -> listener.onConversationUpdated(event)); log("Event published " + event.toString()); }
[ "private", "void", "onConversationUpdated", "(", "ConversationUpdateEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onConversationUpdated", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation updated event. @param event Event to dispatch.
[ "Dispatch", "conversation", "updated", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L235-L238
144,445
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onConversationDeleted
private void onConversationDeleted(ConversationDeleteEvent event) { handler.post(() -> listener.onConversationDeleted(event)); log("Event published " + event.toString()); }
java
private void onConversationDeleted(ConversationDeleteEvent event) { handler.post(() -> listener.onConversationDeleted(event)); log("Event published " + event.toString()); }
[ "private", "void", "onConversationDeleted", "(", "ConversationDeleteEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onConversationDeleted", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation deleted event. @param event Event to dispatch.
[ "Dispatch", "conversation", "deleted", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L245-L248
144,446
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java
SocketEventDispatcher.onConversationUndeleted
private void onConversationUndeleted(ConversationUndeleteEvent event) { handler.post(() -> listener.onConversationUndeleted(event)); log("Event published " + event.toString()); }
java
private void onConversationUndeleted(ConversationUndeleteEvent event) { handler.post(() -> listener.onConversationUndeleted(event)); log("Event published " + event.toString()); }
[ "private", "void", "onConversationUndeleted", "(", "ConversationUndeleteEvent", "event", ")", "{", "handler", ".", "post", "(", "(", ")", "->", "listener", ".", "onConversationUndeleted", "(", "event", ")", ")", ";", "log", "(", "\"Event published \"", "+", "event", ".", "toString", "(", ")", ")", ";", "}" ]
Dispatch conversation restored event. @param event Event to dispatch.
[ "Dispatch", "conversation", "restored", "event", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketEventDispatcher.java#L255-L258
144,447
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceQueue.java
ServiceQueue.getToken
protected String getToken() { return dataMgr.getSessionDAO().session() != null ? dataMgr.getSessionDAO().session().getAccessToken() : null; }
java
protected String getToken() { return dataMgr.getSessionDAO().session() != null ? dataMgr.getSessionDAO().session().getAccessToken() : null; }
[ "protected", "String", "getToken", "(", ")", "{", "return", "dataMgr", ".", "getSessionDAO", "(", ")", ".", "session", "(", ")", "!=", "null", "?", "dataMgr", ".", "getSessionDAO", "(", ")", ".", "session", "(", ")", ".", "getAccessToken", "(", ")", ":", "null", ";", "}" ]
Gets session access token. @return Session access token.
[ "Gets", "session", "access", "token", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceQueue.java#L83-L85
144,448
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/DataManager.java
DataManager.init
public void init(@NonNull final Context context, @Nullable final String suffix, @NonNull final Logger log) { deviceDAO = new DeviceDAO(context, suffix); onetimeDeviceSetup(context); logInfo(log); sessionDAO = new SessionDAO(context, suffix); }
java
public void init(@NonNull final Context context, @Nullable final String suffix, @NonNull final Logger log) { deviceDAO = new DeviceDAO(context, suffix); onetimeDeviceSetup(context); logInfo(log); sessionDAO = new SessionDAO(context, suffix); }
[ "public", "void", "init", "(", "@", "NonNull", "final", "Context", "context", ",", "@", "Nullable", "final", "String", "suffix", ",", "@", "NonNull", "final", "Logger", "log", ")", "{", "deviceDAO", "=", "new", "DeviceDAO", "(", "context", ",", "suffix", ")", ";", "onetimeDeviceSetup", "(", "context", ")", ";", "logInfo", "(", "log", ")", ";", "sessionDAO", "=", "new", "SessionDAO", "(", "context", ",", "suffix", ")", ";", "}" ]
Initialise Session Manager. @param context Application context. @param suffix Log tag suffix to extend the SDK details in a tag with any additional SDK module details. @param log Logger instance for logging output.
[ "Initialise", "Session", "Manager", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/DataManager.java#L52-L57
144,449
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/DataManager.java
DataManager.logInfo
private void logInfo(@NonNull final Logger log) { log.i("App ver. = " + deviceDAO.device().getAppVer()); log.i("Comapi device ID = " + deviceDAO.device().getDeviceId()); log.d("Firebase ID = " + deviceDAO.device().getInstanceId()); }
java
private void logInfo(@NonNull final Logger log) { log.i("App ver. = " + deviceDAO.device().getAppVer()); log.i("Comapi device ID = " + deviceDAO.device().getDeviceId()); log.d("Firebase ID = " + deviceDAO.device().getInstanceId()); }
[ "private", "void", "logInfo", "(", "@", "NonNull", "final", "Logger", "log", ")", "{", "log", ".", "i", "(", "\"App ver. = \"", "+", "deviceDAO", ".", "device", "(", ")", ".", "getAppVer", "(", ")", ")", ";", "log", ".", "i", "(", "\"Comapi device ID = \"", "+", "deviceDAO", ".", "device", "(", ")", ".", "getDeviceId", "(", ")", ")", ";", "log", ".", "d", "(", "\"Firebase ID = \"", "+", "deviceDAO", ".", "device", "(", ")", ".", "getInstanceId", "(", ")", ")", ";", "}" ]
Log basic information about initialisation environment.
[ "Log", "basic", "information", "about", "initialisation", "environment", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/DataManager.java#L95-L99
144,450
javagl/CommonUI
src/main/java/de/javagl/common/ui/tree/filtered/FilteredTreeNode.java
FilteredTreeNode.enumerationAsStream
private static <T> Stream<T> enumerationAsStream(Enumeration<? extends T> e) { Iterator<T> iterator = new Iterator<T>() { @Override public T next() { return e.nextElement(); } @Override public boolean hasNext() { return e.hasMoreElements(); } }; return StreamSupport.stream( Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED), false); }
java
private static <T> Stream<T> enumerationAsStream(Enumeration<? extends T> e) { Iterator<T> iterator = new Iterator<T>() { @Override public T next() { return e.nextElement(); } @Override public boolean hasNext() { return e.hasMoreElements(); } }; return StreamSupport.stream( Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED), false); }
[ "private", "static", "<", "T", ">", "Stream", "<", "T", ">", "enumerationAsStream", "(", "Enumeration", "<", "?", "extends", "T", ">", "e", ")", "{", "Iterator", "<", "T", ">", "iterator", "=", "new", "Iterator", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "next", "(", ")", "{", "return", "e", ".", "nextElement", "(", ")", ";", "}", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "return", "e", ".", "hasMoreElements", "(", ")", ";", "}", "}", ";", "return", "StreamSupport", ".", "stream", "(", "Spliterators", ".", "spliteratorUnknownSize", "(", "iterator", ",", "Spliterator", ".", "ORDERED", ")", ",", "false", ")", ";", "}" ]
Returns a new stream that has the same contents as the given enumeration @param e The enumeration @return The stream
[ "Returns", "a", "new", "stream", "that", "has", "the", "same", "contents", "as", "the", "given", "enumeration" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/filtered/FilteredTreeNode.java#L219-L238
144,451
sebastiangraf/perfidix
src/main/java/org/perfidix/ouput/asciitable/Row.java
Row.getRowWidth
public int getRowWidth() { int overallWidth = 0; for (int i = 0; i < data.length; i++) { overallWidth += getTable().getColumnWidth(i); } return overallWidth; }
java
public int getRowWidth() { int overallWidth = 0; for (int i = 0; i < data.length; i++) { overallWidth += getTable().getColumnWidth(i); } return overallWidth; }
[ "public", "int", "getRowWidth", "(", ")", "{", "int", "overallWidth", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "overallWidth", "+=", "getTable", "(", ")", ".", "getColumnWidth", "(", "i", ")", ";", "}", "return", "overallWidth", ";", "}" ]
Returns the row's total width. @return the width of the row.
[ "Returns", "the", "row", "s", "total", "width", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Row.java#L54-L61
144,452
blackdoor/blackdoor
src/main/java/black/door/crypto/Hash.java
Hash.shuffle
public static byte[] shuffle(byte[] input){ for(int i=0; i<input.length; i++){ int i2 = input[i]; if(i2 < 0) i2 = 127 + Math.abs(i2); input[i] = shuffle[i2]; //result of more shuffles could just be mapped to the first // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle2[i2]; // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle3[i2]; } return input; }
java
public static byte[] shuffle(byte[] input){ for(int i=0; i<input.length; i++){ int i2 = input[i]; if(i2 < 0) i2 = 127 + Math.abs(i2); input[i] = shuffle[i2]; //result of more shuffles could just be mapped to the first // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle2[i2]; // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle3[i2]; } return input; }
[ "public", "static", "byte", "[", "]", "shuffle", "(", "byte", "[", "]", "input", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "input", ".", "length", ";", "i", "++", ")", "{", "int", "i2", "=", "input", "[", "i", "]", ";", "if", "(", "i2", "<", "0", ")", "i2", "=", "127", "+", "Math", ".", "abs", "(", "i2", ")", ";", "input", "[", "i", "]", "=", "shuffle", "[", "i2", "]", ";", "//result of more shuffles could just be mapped to the first", "//\t\t\ti2 = input[i];", "//\t\t\tif(i2 < 0)", "//\t\t\t\ti2 = 127 + Math.abs(i2);", "//\t\t\tinput[i] = (byte) shuffle2[i2];", "//\t\t\ti2 = input[i];", "//\t\t\tif(i2 < 0)", "//\t\t\t\ti2 = 127 + Math.abs(i2);", "//\t\t\tinput[i] = (byte) shuffle3[i2];", "}", "return", "input", ";", "}" ]
a minimal perfect hash function for a 32 byte input @param input @return
[ "a", "minimal", "perfect", "hash", "function", "for", "a", "32", "byte", "input" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/crypto/Hash.java#L60-L77
144,453
blackdoor/blackdoor
src/main/java/black/door/crypto/Hash.java
Hash.getSHA256
public static byte[] getSHA256(byte[] input, boolean asSingleton){ if(SHA256_INSTANCE == null){ if(asSingleton){ try { SHA256_INSTANCE = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }else{ return getHash("SHA-256", input); } } return SHA256_INSTANCE.digest(input); }
java
public static byte[] getSHA256(byte[] input, boolean asSingleton){ if(SHA256_INSTANCE == null){ if(asSingleton){ try { SHA256_INSTANCE = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }else{ return getHash("SHA-256", input); } } return SHA256_INSTANCE.digest(input); }
[ "public", "static", "byte", "[", "]", "getSHA256", "(", "byte", "[", "]", "input", ",", "boolean", "asSingleton", ")", "{", "if", "(", "SHA256_INSTANCE", "==", "null", ")", "{", "if", "(", "asSingleton", ")", "{", "try", "{", "SHA256_INSTANCE", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA-256\"", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "else", "{", "return", "getHash", "(", "\"SHA-256\"", ",", "input", ")", ";", "}", "}", "return", "SHA256_INSTANCE", ".", "digest", "(", "input", ")", ";", "}" ]
Get the SHA256 Hash of input @param input - the bytes to hash @param asSingleton if true use a singleton MessageDigest instance, else create and destroy a MD instance just for this call. @return 32 bytes that represent the SHA256 hash of input;
[ "Get", "the", "SHA256", "Hash", "of", "input" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/crypto/Hash.java#L120-L133
144,454
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketFactory.java
SocketFactory.createSocket
SocketInterface createSocket(@NonNull final String token, @NonNull final WeakReference<SocketStateListener> stateListenerWeakReference) { WebSocket socket = null; WebSocketFactory factory = new WebSocketFactory(); // Configure proxy if provided if (proxyAddress != null) { ProxySettings settings = factory.getProxySettings(); settings.setServer(proxyAddress); } try { socket = factory.createSocket(uri, TIMEOUT); } catch (IOException e) { log.f("Creating socket failed", e); } if (socket != null) { String header = AuthManager.AUTH_PREFIX + token; socket.addHeader("Authorization", header); socket.addListener(createWebSocketAdapter(stateListenerWeakReference)); socket.setPingInterval(PING_INTERVAL); return new SocketWrapperImpl(socket); } return null; }
java
SocketInterface createSocket(@NonNull final String token, @NonNull final WeakReference<SocketStateListener> stateListenerWeakReference) { WebSocket socket = null; WebSocketFactory factory = new WebSocketFactory(); // Configure proxy if provided if (proxyAddress != null) { ProxySettings settings = factory.getProxySettings(); settings.setServer(proxyAddress); } try { socket = factory.createSocket(uri, TIMEOUT); } catch (IOException e) { log.f("Creating socket failed", e); } if (socket != null) { String header = AuthManager.AUTH_PREFIX + token; socket.addHeader("Authorization", header); socket.addListener(createWebSocketAdapter(stateListenerWeakReference)); socket.setPingInterval(PING_INTERVAL); return new SocketWrapperImpl(socket); } return null; }
[ "SocketInterface", "createSocket", "(", "@", "NonNull", "final", "String", "token", ",", "@", "NonNull", "final", "WeakReference", "<", "SocketStateListener", ">", "stateListenerWeakReference", ")", "{", "WebSocket", "socket", "=", "null", ";", "WebSocketFactory", "factory", "=", "new", "WebSocketFactory", "(", ")", ";", "// Configure proxy if provided", "if", "(", "proxyAddress", "!=", "null", ")", "{", "ProxySettings", "settings", "=", "factory", ".", "getProxySettings", "(", ")", ";", "settings", ".", "setServer", "(", "proxyAddress", ")", ";", "}", "try", "{", "socket", "=", "factory", ".", "createSocket", "(", "uri", ",", "TIMEOUT", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "f", "(", "\"Creating socket failed\"", ",", "e", ")", ";", "}", "if", "(", "socket", "!=", "null", ")", "{", "String", "header", "=", "AuthManager", ".", "AUTH_PREFIX", "+", "token", ";", "socket", ".", "addHeader", "(", "\"Authorization\"", ",", "header", ")", ";", "socket", ".", "addListener", "(", "createWebSocketAdapter", "(", "stateListenerWeakReference", ")", ")", ";", "socket", ".", "setPingInterval", "(", "PING_INTERVAL", ")", ";", "return", "new", "SocketWrapperImpl", "(", "socket", ")", ";", "}", "return", "null", ";", "}" ]
Creates and configures web socket instance. @param token Authentication token. @param stateListenerWeakReference Weak reference to socket connection state callbacks.
[ "Creates", "and", "configures", "web", "socket", "instance", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketFactory.java#L97-L128
144,455
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketFactory.java
SocketFactory.createWebSocketAdapter
protected WebSocketAdapter createWebSocketAdapter(@NonNull final WeakReference<SocketStateListener> stateListenerWeakReference) { return new WebSocketAdapter() { @Override public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception { super.onConnected(websocket, headers); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onConnected(); } } @Override public void onConnectError(WebSocket websocket, WebSocketException exception) throws Exception { super.onConnectError(websocket, exception); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onError(uri.getRawPath(), proxyAddress, exception); } } @Override public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception { super.onDisconnected(websocket, serverCloseFrame, clientCloseFrame, closedByServer); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onDisconnected(); } } @Override public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, text); log.d("Socket message received = " + text); messageListener.onMessage(text); } @Override public void onBinaryMessage(WebSocket websocket, byte[] binary) throws Exception { super.onBinaryMessage(websocket, binary); log.d("Socket binary message received."); } }; }
java
protected WebSocketAdapter createWebSocketAdapter(@NonNull final WeakReference<SocketStateListener> stateListenerWeakReference) { return new WebSocketAdapter() { @Override public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception { super.onConnected(websocket, headers); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onConnected(); } } @Override public void onConnectError(WebSocket websocket, WebSocketException exception) throws Exception { super.onConnectError(websocket, exception); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onError(uri.getRawPath(), proxyAddress, exception); } } @Override public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception { super.onDisconnected(websocket, serverCloseFrame, clientCloseFrame, closedByServer); final SocketStateListener stateListener = stateListenerWeakReference.get(); if (stateListener != null) { stateListener.onDisconnected(); } } @Override public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, text); log.d("Socket message received = " + text); messageListener.onMessage(text); } @Override public void onBinaryMessage(WebSocket websocket, byte[] binary) throws Exception { super.onBinaryMessage(websocket, binary); log.d("Socket binary message received."); } }; }
[ "protected", "WebSocketAdapter", "createWebSocketAdapter", "(", "@", "NonNull", "final", "WeakReference", "<", "SocketStateListener", ">", "stateListenerWeakReference", ")", "{", "return", "new", "WebSocketAdapter", "(", ")", "{", "@", "Override", "public", "void", "onConnected", "(", "WebSocket", "websocket", ",", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "headers", ")", "throws", "Exception", "{", "super", ".", "onConnected", "(", "websocket", ",", "headers", ")", ";", "final", "SocketStateListener", "stateListener", "=", "stateListenerWeakReference", ".", "get", "(", ")", ";", "if", "(", "stateListener", "!=", "null", ")", "{", "stateListener", ".", "onConnected", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "onConnectError", "(", "WebSocket", "websocket", ",", "WebSocketException", "exception", ")", "throws", "Exception", "{", "super", ".", "onConnectError", "(", "websocket", ",", "exception", ")", ";", "final", "SocketStateListener", "stateListener", "=", "stateListenerWeakReference", ".", "get", "(", ")", ";", "if", "(", "stateListener", "!=", "null", ")", "{", "stateListener", ".", "onError", "(", "uri", ".", "getRawPath", "(", ")", ",", "proxyAddress", ",", "exception", ")", ";", "}", "}", "@", "Override", "public", "void", "onDisconnected", "(", "WebSocket", "websocket", ",", "WebSocketFrame", "serverCloseFrame", ",", "WebSocketFrame", "clientCloseFrame", ",", "boolean", "closedByServer", ")", "throws", "Exception", "{", "super", ".", "onDisconnected", "(", "websocket", ",", "serverCloseFrame", ",", "clientCloseFrame", ",", "closedByServer", ")", ";", "final", "SocketStateListener", "stateListener", "=", "stateListenerWeakReference", ".", "get", "(", ")", ";", "if", "(", "stateListener", "!=", "null", ")", "{", "stateListener", ".", "onDisconnected", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "onTextMessage", "(", "WebSocket", "websocket", ",", "String", "text", ")", "throws", "Exception", "{", "super", ".", "onTextMessage", "(", "websocket", ",", "text", ")", ";", "log", ".", "d", "(", "\"Socket message received = \"", "+", "text", ")", ";", "messageListener", ".", "onMessage", "(", "text", ")", ";", "}", "@", "Override", "public", "void", "onBinaryMessage", "(", "WebSocket", "websocket", ",", "byte", "[", "]", "binary", ")", "throws", "Exception", "{", "super", ".", "onBinaryMessage", "(", "websocket", ",", "binary", ")", ";", "log", ".", "d", "(", "\"Socket binary message received.\"", ")", ";", "}", "}", ";", "}" ]
Create adapter for websocket library events. @param stateListenerWeakReference Listener for socket state changes. @return Adapter for websocket library events.
[ "Create", "adapter", "for", "websocket", "library", "events", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketFactory.java#L136-L180
144,456
sebastiangraf/perfidix
src/main/java/org/perfidix/element/BenchmarkMethod.java
BenchmarkMethod.getNumberOfAnnotatedRuns
public static int getNumberOfAnnotatedRuns(final Method meth) { if (!isBenchmarkable(meth)) { throw new IllegalArgumentException("Method " + meth + " must be a benchmarkable method."); } final Bench benchAnno = meth.getAnnotation(Bench.class); final BenchClass benchClassAnno = meth.getDeclaringClass() .getAnnotation(BenchClass.class); int returnVal; if (benchAnno == null) { returnVal = benchClassAnno.runs(); } else { returnVal = benchAnno.runs(); // use runs from @BenchClass if none is set on method (issue #4) if ((returnVal == Bench.NONE_RUN) && (benchClassAnno != null)) { returnVal = benchClassAnno.runs(); } } return returnVal; }
java
public static int getNumberOfAnnotatedRuns(final Method meth) { if (!isBenchmarkable(meth)) { throw new IllegalArgumentException("Method " + meth + " must be a benchmarkable method."); } final Bench benchAnno = meth.getAnnotation(Bench.class); final BenchClass benchClassAnno = meth.getDeclaringClass() .getAnnotation(BenchClass.class); int returnVal; if (benchAnno == null) { returnVal = benchClassAnno.runs(); } else { returnVal = benchAnno.runs(); // use runs from @BenchClass if none is set on method (issue #4) if ((returnVal == Bench.NONE_RUN) && (benchClassAnno != null)) { returnVal = benchClassAnno.runs(); } } return returnVal; }
[ "public", "static", "int", "getNumberOfAnnotatedRuns", "(", "final", "Method", "meth", ")", "{", "if", "(", "!", "isBenchmarkable", "(", "meth", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Method \"", "+", "meth", "+", "\" must be a benchmarkable method.\"", ")", ";", "}", "final", "Bench", "benchAnno", "=", "meth", ".", "getAnnotation", "(", "Bench", ".", "class", ")", ";", "final", "BenchClass", "benchClassAnno", "=", "meth", ".", "getDeclaringClass", "(", ")", ".", "getAnnotation", "(", "BenchClass", ".", "class", ")", ";", "int", "returnVal", ";", "if", "(", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "benchClassAnno", ".", "runs", "(", ")", ";", "}", "else", "{", "returnVal", "=", "benchAnno", ".", "runs", "(", ")", ";", "// use runs from @BenchClass if none is set on method (issue #4)", "if", "(", "(", "returnVal", "==", "Bench", ".", "NONE_RUN", ")", "&&", "(", "benchClassAnno", "!=", "null", ")", ")", "{", "returnVal", "=", "benchClassAnno", ".", "runs", "(", ")", ";", "}", "}", "return", "returnVal", ";", "}" ]
Getting the number of runs corresponding to a given method. The method MUST be a benchmarkable method, otherwise an IllegalStateException exception arises. The number of runs of an annotated method is more powerful than the number of runs as denoted by the benchclass annotation. @param meth to be checked @return the number of runs of this benchmarkable-method
[ "Getting", "the", "number", "of", "runs", "corresponding", "to", "a", "given", "method", ".", "The", "method", "MUST", "be", "a", "benchmarkable", "method", "otherwise", "an", "IllegalStateException", "exception", "arises", ".", "The", "number", "of", "runs", "of", "an", "annotated", "method", "is", "more", "powerful", "than", "the", "number", "of", "runs", "as", "denoted", "by", "the", "benchclass", "annotation", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkMethod.java#L83-L102
144,457
sebastiangraf/perfidix
src/main/java/org/perfidix/element/BenchmarkMethod.java
BenchmarkMethod.findAndCheckAnyMethodByAnnotation
public static Method findAndCheckAnyMethodByAnnotation( final Class<?> clazz, final Class<? extends Annotation> anno) throws PerfidixMethodCheckException { // needed variables, one for check for duplicates Method anyMethod = null; // Scanning all methods final Method[] possAnnoMethods = clazz.getDeclaredMethods(); for (final Method meth : possAnnoMethods) { if (meth.getAnnotation(anno) != null) { // Check if there are multiple annotated methods, throwing // IllegalAccessException otherwise. if (anyMethod == null) { // Check if method is valid (no param, no returnval, // etc.), throwing IllegalAccessException otherwise. if (isReflectedExecutable(meth, anno)) { anyMethod = meth; } else { throw new PerfidixMethodCheckException( new IllegalAccessException(anno.toString() + "-annotated method " + meth + " is not executable."), meth, anno); } } else { throw new PerfidixMethodCheckException( new IllegalAccessException("Please use only one " + anno.toString() + "-annotation in one class."), meth, anno); } } } return anyMethod; }
java
public static Method findAndCheckAnyMethodByAnnotation( final Class<?> clazz, final Class<? extends Annotation> anno) throws PerfidixMethodCheckException { // needed variables, one for check for duplicates Method anyMethod = null; // Scanning all methods final Method[] possAnnoMethods = clazz.getDeclaredMethods(); for (final Method meth : possAnnoMethods) { if (meth.getAnnotation(anno) != null) { // Check if there are multiple annotated methods, throwing // IllegalAccessException otherwise. if (anyMethod == null) { // Check if method is valid (no param, no returnval, // etc.), throwing IllegalAccessException otherwise. if (isReflectedExecutable(meth, anno)) { anyMethod = meth; } else { throw new PerfidixMethodCheckException( new IllegalAccessException(anno.toString() + "-annotated method " + meth + " is not executable."), meth, anno); } } else { throw new PerfidixMethodCheckException( new IllegalAccessException("Please use only one " + anno.toString() + "-annotation in one class."), meth, anno); } } } return anyMethod; }
[ "public", "static", "Method", "findAndCheckAnyMethodByAnnotation", "(", "final", "Class", "<", "?", ">", "clazz", ",", "final", "Class", "<", "?", "extends", "Annotation", ">", "anno", ")", "throws", "PerfidixMethodCheckException", "{", "// needed variables, one for check for duplicates", "Method", "anyMethod", "=", "null", ";", "// Scanning all methods", "final", "Method", "[", "]", "possAnnoMethods", "=", "clazz", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "final", "Method", "meth", ":", "possAnnoMethods", ")", "{", "if", "(", "meth", ".", "getAnnotation", "(", "anno", ")", "!=", "null", ")", "{", "// Check if there are multiple annotated methods, throwing", "// IllegalAccessException otherwise.", "if", "(", "anyMethod", "==", "null", ")", "{", "// Check if method is valid (no param, no returnval,", "// etc.), throwing IllegalAccessException otherwise.", "if", "(", "isReflectedExecutable", "(", "meth", ",", "anno", ")", ")", "{", "anyMethod", "=", "meth", ";", "}", "else", "{", "throw", "new", "PerfidixMethodCheckException", "(", "new", "IllegalAccessException", "(", "anno", ".", "toString", "(", ")", "+", "\"-annotated method \"", "+", "meth", "+", "\" is not executable.\"", ")", ",", "meth", ",", "anno", ")", ";", "}", "}", "else", "{", "throw", "new", "PerfidixMethodCheckException", "(", "new", "IllegalAccessException", "(", "\"Please use only one \"", "+", "anno", ".", "toString", "(", ")", "+", "\"-annotation in one class.\"", ")", ",", "meth", ",", "anno", ")", ";", "}", "}", "}", "return", "anyMethod", ";", "}" ]
This class finds any method with a given annotation. The method is allowed to occur only once in the class and should match the requirements for Perfidix for an execution by reflection. @param anno of the method to be found @param clazz class to be searched @return a method annotated by the annotation given. The method occurs only once in the class and matched the requirements of perfidix-reflective-invocation. @throws PerfidixMethodCheckException if these integrity checks fail
[ "This", "class", "finds", "any", "method", "with", "a", "given", "annotation", ".", "The", "method", "is", "allowed", "to", "occur", "only", "once", "in", "the", "class", "and", "should", "match", "the", "requirements", "for", "Perfidix", "for", "an", "execution", "by", "reflection", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkMethod.java#L119-L152
144,458
sebastiangraf/perfidix
src/main/java/org/perfidix/element/BenchmarkMethod.java
BenchmarkMethod.isBenchmarkable
public static boolean isBenchmarkable(final Method meth) { boolean returnVal = true; // Check if bench-anno is given. For testing purposes against // before/after annos final Bench benchAnno = meth.getAnnotation(Bench.class); // if method is annotated with SkipBench, the method is never // benchmarkable. final SkipBench skipBenchAnno = meth.getAnnotation(SkipBench.class); if (skipBenchAnno != null) { returnVal = false; } // Check if method is defined as beforeClass, beforeFirstRun, // beforeEachRun, afterEachRun, afterLastRun, afterClass. A method can // either be a before/after class or afterwards be benchmarkable through // the BenchClass annotation. final BeforeBenchClass beforeClass = meth .getAnnotation(BeforeBenchClass.class); if (beforeClass != null && benchAnno == null) { returnVal = false; } final BeforeFirstRun beforeFirstRun = meth .getAnnotation(BeforeFirstRun.class); if (beforeFirstRun != null && benchAnno == null) { returnVal = false; } final BeforeEachRun beforeEachRun = meth .getAnnotation(BeforeEachRun.class); if (beforeEachRun != null && benchAnno == null) { returnVal = false; } final AfterEachRun afterEachRun = meth .getAnnotation(AfterEachRun.class); if (afterEachRun != null && benchAnno == null) { returnVal = false; } final AfterLastRun afterLastRun = meth .getAnnotation(AfterLastRun.class); if (afterLastRun != null && benchAnno == null) { returnVal = false; } final AfterBenchClass afterClass = meth .getAnnotation(AfterBenchClass.class); if (afterClass != null && benchAnno == null) { returnVal = false; } // if method is not annotated with Bench and class is not annotated with // BenchClass, the method is never benchmarkable. final BenchClass classBenchAnno = meth.getDeclaringClass() .getAnnotation(BenchClass.class); if (benchAnno == null && classBenchAnno == null) { returnVal = false; } // check if method is executable for perfidix purposes. if (!isReflectedExecutable(meth, Bench.class)) { returnVal = false; } return returnVal; }
java
public static boolean isBenchmarkable(final Method meth) { boolean returnVal = true; // Check if bench-anno is given. For testing purposes against // before/after annos final Bench benchAnno = meth.getAnnotation(Bench.class); // if method is annotated with SkipBench, the method is never // benchmarkable. final SkipBench skipBenchAnno = meth.getAnnotation(SkipBench.class); if (skipBenchAnno != null) { returnVal = false; } // Check if method is defined as beforeClass, beforeFirstRun, // beforeEachRun, afterEachRun, afterLastRun, afterClass. A method can // either be a before/after class or afterwards be benchmarkable through // the BenchClass annotation. final BeforeBenchClass beforeClass = meth .getAnnotation(BeforeBenchClass.class); if (beforeClass != null && benchAnno == null) { returnVal = false; } final BeforeFirstRun beforeFirstRun = meth .getAnnotation(BeforeFirstRun.class); if (beforeFirstRun != null && benchAnno == null) { returnVal = false; } final BeforeEachRun beforeEachRun = meth .getAnnotation(BeforeEachRun.class); if (beforeEachRun != null && benchAnno == null) { returnVal = false; } final AfterEachRun afterEachRun = meth .getAnnotation(AfterEachRun.class); if (afterEachRun != null && benchAnno == null) { returnVal = false; } final AfterLastRun afterLastRun = meth .getAnnotation(AfterLastRun.class); if (afterLastRun != null && benchAnno == null) { returnVal = false; } final AfterBenchClass afterClass = meth .getAnnotation(AfterBenchClass.class); if (afterClass != null && benchAnno == null) { returnVal = false; } // if method is not annotated with Bench and class is not annotated with // BenchClass, the method is never benchmarkable. final BenchClass classBenchAnno = meth.getDeclaringClass() .getAnnotation(BenchClass.class); if (benchAnno == null && classBenchAnno == null) { returnVal = false; } // check if method is executable for perfidix purposes. if (!isReflectedExecutable(meth, Bench.class)) { returnVal = false; } return returnVal; }
[ "public", "static", "boolean", "isBenchmarkable", "(", "final", "Method", "meth", ")", "{", "boolean", "returnVal", "=", "true", ";", "// Check if bench-anno is given. For testing purposes against", "// before/after annos", "final", "Bench", "benchAnno", "=", "meth", ".", "getAnnotation", "(", "Bench", ".", "class", ")", ";", "// if method is annotated with SkipBench, the method is never", "// benchmarkable.", "final", "SkipBench", "skipBenchAnno", "=", "meth", ".", "getAnnotation", "(", "SkipBench", ".", "class", ")", ";", "if", "(", "skipBenchAnno", "!=", "null", ")", "{", "returnVal", "=", "false", ";", "}", "// Check if method is defined as beforeClass, beforeFirstRun,", "// beforeEachRun, afterEachRun, afterLastRun, afterClass. A method can", "// either be a before/after class or afterwards be benchmarkable through", "// the BenchClass annotation.", "final", "BeforeBenchClass", "beforeClass", "=", "meth", ".", "getAnnotation", "(", "BeforeBenchClass", ".", "class", ")", ";", "if", "(", "beforeClass", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "final", "BeforeFirstRun", "beforeFirstRun", "=", "meth", ".", "getAnnotation", "(", "BeforeFirstRun", ".", "class", ")", ";", "if", "(", "beforeFirstRun", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "final", "BeforeEachRun", "beforeEachRun", "=", "meth", ".", "getAnnotation", "(", "BeforeEachRun", ".", "class", ")", ";", "if", "(", "beforeEachRun", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "final", "AfterEachRun", "afterEachRun", "=", "meth", ".", "getAnnotation", "(", "AfterEachRun", ".", "class", ")", ";", "if", "(", "afterEachRun", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "final", "AfterLastRun", "afterLastRun", "=", "meth", ".", "getAnnotation", "(", "AfterLastRun", ".", "class", ")", ";", "if", "(", "afterLastRun", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "final", "AfterBenchClass", "afterClass", "=", "meth", ".", "getAnnotation", "(", "AfterBenchClass", ".", "class", ")", ";", "if", "(", "afterClass", "!=", "null", "&&", "benchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "// if method is not annotated with Bench and class is not annotated with", "// BenchClass, the method is never benchmarkable.", "final", "BenchClass", "classBenchAnno", "=", "meth", ".", "getDeclaringClass", "(", ")", ".", "getAnnotation", "(", "BenchClass", ".", "class", ")", ";", "if", "(", "benchAnno", "==", "null", "&&", "classBenchAnno", "==", "null", ")", "{", "returnVal", "=", "false", ";", "}", "// check if method is executable for perfidix purposes.", "if", "(", "!", "isReflectedExecutable", "(", "meth", ",", "Bench", ".", "class", ")", ")", "{", "returnVal", "=", "false", ";", "}", "return", "returnVal", ";", "}" ]
This method should act as a check to guarantee that only specific Benchmarkables are used for benching. @param meth method to be checked. @return true if an instance of this interface is benchmarkable, false otherwise.
[ "This", "method", "should", "act", "as", "a", "check", "to", "guarantee", "that", "only", "specific", "Benchmarkables", "are", "used", "for", "benching", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkMethod.java#L163-L230
144,459
sebastiangraf/perfidix
src/main/java/org/perfidix/element/BenchmarkMethod.java
BenchmarkMethod.isReflectedExecutable
public static boolean isReflectedExecutable(final Method meth, final Class<? extends Annotation> anno) { boolean returnVal = true; // Check if DataProvider is valid if set. if (anno.equals(DataProvider.class) && !meth.getReturnType().isAssignableFrom(Object[][].class)) { returnVal = false; } // for all other methods, the return type must be void if (!anno.equals(DataProvider.class) && !meth.getGenericReturnType().equals(Void.TYPE)) { returnVal = false; } // if method is static, the method is not benchmarkable if (!(anno.equals(BeforeBenchClass.class)) && Modifier.isStatic(meth.getModifiers())) { returnVal = false; } // if method is not public, the method is not benchmarkable if (!Modifier.isPublic(meth.getModifiers())) { returnVal = false; } return returnVal; }
java
public static boolean isReflectedExecutable(final Method meth, final Class<? extends Annotation> anno) { boolean returnVal = true; // Check if DataProvider is valid if set. if (anno.equals(DataProvider.class) && !meth.getReturnType().isAssignableFrom(Object[][].class)) { returnVal = false; } // for all other methods, the return type must be void if (!anno.equals(DataProvider.class) && !meth.getGenericReturnType().equals(Void.TYPE)) { returnVal = false; } // if method is static, the method is not benchmarkable if (!(anno.equals(BeforeBenchClass.class)) && Modifier.isStatic(meth.getModifiers())) { returnVal = false; } // if method is not public, the method is not benchmarkable if (!Modifier.isPublic(meth.getModifiers())) { returnVal = false; } return returnVal; }
[ "public", "static", "boolean", "isReflectedExecutable", "(", "final", "Method", "meth", ",", "final", "Class", "<", "?", "extends", "Annotation", ">", "anno", ")", "{", "boolean", "returnVal", "=", "true", ";", "// Check if DataProvider is valid if set.", "if", "(", "anno", ".", "equals", "(", "DataProvider", ".", "class", ")", "&&", "!", "meth", ".", "getReturnType", "(", ")", ".", "isAssignableFrom", "(", "Object", "[", "]", "[", "]", ".", "class", ")", ")", "{", "returnVal", "=", "false", ";", "}", "// for all other methods, the return type must be void", "if", "(", "!", "anno", ".", "equals", "(", "DataProvider", ".", "class", ")", "&&", "!", "meth", ".", "getGenericReturnType", "(", ")", ".", "equals", "(", "Void", ".", "TYPE", ")", ")", "{", "returnVal", "=", "false", ";", "}", "// if method is static, the method is not benchmarkable", "if", "(", "!", "(", "anno", ".", "equals", "(", "BeforeBenchClass", ".", "class", ")", ")", "&&", "Modifier", ".", "isStatic", "(", "meth", ".", "getModifiers", "(", ")", ")", ")", "{", "returnVal", "=", "false", ";", "}", "// if method is not public, the method is not benchmarkable", "if", "(", "!", "Modifier", ".", "isPublic", "(", "meth", ".", "getModifiers", "(", ")", ")", ")", "{", "returnVal", "=", "false", ";", "}", "return", "returnVal", ";", "}" ]
Checks if this method is executable via reflection for perfidix purposes. That means that the method has no parameters (except for , no return-value, is non-static, is public and throws no exceptions. @param meth method to be checked @param anno anno for method to be check, necessary since different attributes are possible depending on the anno @return true if method matches requirements.
[ "Checks", "if", "this", "method", "is", "executable", "via", "reflection", "for", "perfidix", "purposes", ".", "That", "means", "that", "the", "method", "has", "no", "parameters", "(", "except", "for", "no", "return", "-", "value", "is", "non", "-", "static", "is", "public", "and", "throws", "no", "exceptions", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkMethod.java#L244-L269
144,460
sebastiangraf/perfidix
src/main/java/org/perfidix/element/BenchmarkMethod.java
BenchmarkMethod.findDataProvider
private Method findDataProvider() throws PerfidixMethodCheckException { final Bench benchAnno = getMethodToBench().getAnnotation(Bench.class); Method dataProvider = null; if (benchAnno != null && !benchAnno.dataProvider().equals("")) { try { // Getting the String name for the dataProvider final String dataProviderIdentifier = benchAnno.dataProvider(); // Check if there is a Dataprovider with the name as identifier for (final Method eachMeth : getMethodToBench() .getDeclaringClass().getMethods()) { DataProvider anno = eachMeth .getAnnotation(DataProvider.class); if (anno != null && anno.name().equals(dataProviderIdentifier)) { if (dataProvider == null) { dataProvider = eachMeth; } else { throw new PerfidixMethodCheckException( new RuntimeException( "Only one Dataprovider allowed, but found " + dataProvider + " and " + eachMeth), eachMeth, DataProvider.class); } } } // if not, try to find a method with the name if (dataProvider == null) { dataProvider = getMethodToBench().getDeclaringClass() .getDeclaredMethod(dataProviderIdentifier); } // perform the checks same as testng: two dimensional array for // return val, parameter is mapping of // class, array of instances. // checking return types of dataprovider method final Class<?> returnType = dataProvider.getReturnType(); // final Class<?>[] parameters = meth.getParameterTypes(); if (Object[][].class.isAssignableFrom(returnType)) { // checking input types of bench method against the return // types of the parameter // Class<Object[][]> castedReturnType = (Class<Object[][]>) // returnType; // TODO implement check } } catch (NoSuchMethodException | SecurityException e) { // no data provider method, will be returned as false anyhow } } return dataProvider; }
java
private Method findDataProvider() throws PerfidixMethodCheckException { final Bench benchAnno = getMethodToBench().getAnnotation(Bench.class); Method dataProvider = null; if (benchAnno != null && !benchAnno.dataProvider().equals("")) { try { // Getting the String name for the dataProvider final String dataProviderIdentifier = benchAnno.dataProvider(); // Check if there is a Dataprovider with the name as identifier for (final Method eachMeth : getMethodToBench() .getDeclaringClass().getMethods()) { DataProvider anno = eachMeth .getAnnotation(DataProvider.class); if (anno != null && anno.name().equals(dataProviderIdentifier)) { if (dataProvider == null) { dataProvider = eachMeth; } else { throw new PerfidixMethodCheckException( new RuntimeException( "Only one Dataprovider allowed, but found " + dataProvider + " and " + eachMeth), eachMeth, DataProvider.class); } } } // if not, try to find a method with the name if (dataProvider == null) { dataProvider = getMethodToBench().getDeclaringClass() .getDeclaredMethod(dataProviderIdentifier); } // perform the checks same as testng: two dimensional array for // return val, parameter is mapping of // class, array of instances. // checking return types of dataprovider method final Class<?> returnType = dataProvider.getReturnType(); // final Class<?>[] parameters = meth.getParameterTypes(); if (Object[][].class.isAssignableFrom(returnType)) { // checking input types of bench method against the return // types of the parameter // Class<Object[][]> castedReturnType = (Class<Object[][]>) // returnType; // TODO implement check } } catch (NoSuchMethodException | SecurityException e) { // no data provider method, will be returned as false anyhow } } return dataProvider; }
[ "private", "Method", "findDataProvider", "(", ")", "throws", "PerfidixMethodCheckException", "{", "final", "Bench", "benchAnno", "=", "getMethodToBench", "(", ")", ".", "getAnnotation", "(", "Bench", ".", "class", ")", ";", "Method", "dataProvider", "=", "null", ";", "if", "(", "benchAnno", "!=", "null", "&&", "!", "benchAnno", ".", "dataProvider", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "try", "{", "// Getting the String name for the dataProvider", "final", "String", "dataProviderIdentifier", "=", "benchAnno", ".", "dataProvider", "(", ")", ";", "// Check if there is a Dataprovider with the name as identifier", "for", "(", "final", "Method", "eachMeth", ":", "getMethodToBench", "(", ")", ".", "getDeclaringClass", "(", ")", ".", "getMethods", "(", ")", ")", "{", "DataProvider", "anno", "=", "eachMeth", ".", "getAnnotation", "(", "DataProvider", ".", "class", ")", ";", "if", "(", "anno", "!=", "null", "&&", "anno", ".", "name", "(", ")", ".", "equals", "(", "dataProviderIdentifier", ")", ")", "{", "if", "(", "dataProvider", "==", "null", ")", "{", "dataProvider", "=", "eachMeth", ";", "}", "else", "{", "throw", "new", "PerfidixMethodCheckException", "(", "new", "RuntimeException", "(", "\"Only one Dataprovider allowed, but found \"", "+", "dataProvider", "+", "\" and \"", "+", "eachMeth", ")", ",", "eachMeth", ",", "DataProvider", ".", "class", ")", ";", "}", "}", "}", "// if not, try to find a method with the name", "if", "(", "dataProvider", "==", "null", ")", "{", "dataProvider", "=", "getMethodToBench", "(", ")", ".", "getDeclaringClass", "(", ")", ".", "getDeclaredMethod", "(", "dataProviderIdentifier", ")", ";", "}", "// perform the checks same as testng: two dimensional array for", "// return val, parameter is mapping of", "// class, array of instances.", "// checking return types of dataprovider method", "final", "Class", "<", "?", ">", "returnType", "=", "dataProvider", ".", "getReturnType", "(", ")", ";", "// final Class<?>[] parameters = meth.getParameterTypes();", "if", "(", "Object", "[", "]", "[", "]", ".", "class", ".", "isAssignableFrom", "(", "returnType", ")", ")", "{", "// checking input types of bench method against the return", "// types of the parameter", "// Class<Object[][]> castedReturnType = (Class<Object[][]>)", "// returnType;", "// TODO implement check", "}", "}", "catch", "(", "NoSuchMethodException", "|", "SecurityException", "e", ")", "{", "// no data provider method, will be returned as false anyhow", "}", "}", "return", "dataProvider", ";", "}" ]
This method checks whether a method uses a data provider for dynamic input @return true if method is parameterized, false otherwise @throws PerfidixMethodCheckException
[ "This", "method", "checks", "whether", "a", "method", "uses", "a", "data", "provider", "for", "dynamic", "input" ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkMethod.java#L543-L594
144,461
javagl/CommonUI
src/main/java/de/javagl/common/ui/JSplitPanes.java
JSplitPanes.setDividerLocation
public static void setDividerLocation( final JSplitPane splitPane, final double location) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { splitPane.setDividerLocation(location); splitPane.validate(); } }); }
java
public static void setDividerLocation( final JSplitPane splitPane, final double location) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { splitPane.setDividerLocation(location); splitPane.validate(); } }); }
[ "public", "static", "void", "setDividerLocation", "(", "final", "JSplitPane", "splitPane", ",", "final", "double", "location", ")", "{", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "splitPane", ".", "setDividerLocation", "(", "location", ")", ";", "splitPane", ".", "validate", "(", ")", ";", "}", "}", ")", ";", "}" ]
Set the location of the the given split pane to the given value later on the EDT, and validate the split pane @param splitPane The split pane @param location The location
[ "Set", "the", "location", "of", "the", "the", "given", "split", "pane", "to", "the", "given", "value", "later", "on", "the", "EDT", "and", "validate", "the", "split", "pane" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JSplitPanes.java#L44-L56
144,462
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java
SessionDAO.loadSession
private SessionData loadSession() { synchronized (sharedLock) { SharedPreferences sharedPreferences = getSharedPreferences(); String id = sharedPreferences.getString(KEY_PROFILE_ID, null); if (!TextUtils.isEmpty(id)) { sharedLock.notifyAll(); return new SessionData() .setProfileId(id) .setSessionId(sharedPreferences.getString(KEY_SESSION_ID, null)) .setAccessToken(sharedPreferences.getString(KEY_ACCESS_TOKEN, null)) .setExpiresOn(sharedPreferences.getLong(KEY_EXPIRES_ON, 0)); } sharedLock.notifyAll(); } return null; }
java
private SessionData loadSession() { synchronized (sharedLock) { SharedPreferences sharedPreferences = getSharedPreferences(); String id = sharedPreferences.getString(KEY_PROFILE_ID, null); if (!TextUtils.isEmpty(id)) { sharedLock.notifyAll(); return new SessionData() .setProfileId(id) .setSessionId(sharedPreferences.getString(KEY_SESSION_ID, null)) .setAccessToken(sharedPreferences.getString(KEY_ACCESS_TOKEN, null)) .setExpiresOn(sharedPreferences.getLong(KEY_EXPIRES_ON, 0)); } sharedLock.notifyAll(); } return null; }
[ "private", "SessionData", "loadSession", "(", ")", "{", "synchronized", "(", "sharedLock", ")", "{", "SharedPreferences", "sharedPreferences", "=", "getSharedPreferences", "(", ")", ";", "String", "id", "=", "sharedPreferences", ".", "getString", "(", "KEY_PROFILE_ID", ",", "null", ")", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "id", ")", ")", "{", "sharedLock", ".", "notifyAll", "(", ")", ";", "return", "new", "SessionData", "(", ")", ".", "setProfileId", "(", "id", ")", ".", "setSessionId", "(", "sharedPreferences", ".", "getString", "(", "KEY_SESSION_ID", ",", "null", ")", ")", ".", "setAccessToken", "(", "sharedPreferences", ".", "getString", "(", "KEY_ACCESS_TOKEN", ",", "null", ")", ")", ".", "setExpiresOn", "(", "sharedPreferences", ".", "getLong", "(", "KEY_EXPIRES_ON", ",", "0", ")", ")", ";", "}", "sharedLock", ".", "notifyAll", "(", ")", ";", "}", "return", "null", ";", "}" ]
Loads active session details from internal storage. @return Loaded session details.
[ "Loads", "active", "session", "details", "from", "internal", "storage", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java#L61-L78
144,463
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java
SessionDAO.clearSession
public String clearSession() { synchronized (sharedLock) { SessionData session = loadSession(); String id = session != null ? session.getSessionId() : null; clearAll(); sharedLock.notifyAll(); return id; } }
java
public String clearSession() { synchronized (sharedLock) { SessionData session = loadSession(); String id = session != null ? session.getSessionId() : null; clearAll(); sharedLock.notifyAll(); return id; } }
[ "public", "String", "clearSession", "(", ")", "{", "synchronized", "(", "sharedLock", ")", "{", "SessionData", "session", "=", "loadSession", "(", ")", ";", "String", "id", "=", "session", "!=", "null", "?", "session", ".", "getSessionId", "(", ")", ":", "null", ";", "clearAll", "(", ")", ";", "sharedLock", ".", "notifyAll", "(", ")", ";", "return", "id", ";", "}", "}" ]
Deletes currently saved session. @return SessionId for the deleted session or null if no session was active.
[ "Deletes", "currently", "saved", "session", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java#L94-L103
144,464
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java
SessionDAO.startSession
public boolean startSession() { synchronized (sharedLock) { SessionData session = loadSession(); if (isSessionActive(session)) { sharedLock.notifyAll(); return false; } else { clearAll(); } sharedLock.notifyAll(); } return true; }
java
public boolean startSession() { synchronized (sharedLock) { SessionData session = loadSession(); if (isSessionActive(session)) { sharedLock.notifyAll(); return false; } else { clearAll(); } sharedLock.notifyAll(); } return true; }
[ "public", "boolean", "startSession", "(", ")", "{", "synchronized", "(", "sharedLock", ")", "{", "SessionData", "session", "=", "loadSession", "(", ")", ";", "if", "(", "isSessionActive", "(", "session", ")", ")", "{", "sharedLock", ".", "notifyAll", "(", ")", ";", "return", "false", ";", "}", "else", "{", "clearAll", "(", ")", ";", "}", "sharedLock", ".", "notifyAll", "(", ")", ";", "}", "return", "true", ";", "}" ]
Creates session if no session is active. @return True if session was created. If false there is a opened session already. End this session first.
[ "Creates", "session", "if", "no", "session", "is", "active", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java#L110-L124
144,465
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java
SessionDAO.updateSessionDetails
public boolean updateSessionDetails(final SessionData session) { synchronized (sharedLock) { if (session != null) { SharedPreferences.Editor editor = getSharedPreferences().edit(); editor.putString(KEY_PROFILE_ID, session.getProfileId()); editor.putString(KEY_SESSION_ID, session.getSessionId()); editor.putString(KEY_ACCESS_TOKEN, session.getAccessToken()); editor.putLong(KEY_EXPIRES_ON, session.getExpiresOn()); boolean isUpdated = editor.commit(); sharedLock.notifyAll(); return isUpdated; } sharedLock.notifyAll(); } return false; }
java
public boolean updateSessionDetails(final SessionData session) { synchronized (sharedLock) { if (session != null) { SharedPreferences.Editor editor = getSharedPreferences().edit(); editor.putString(KEY_PROFILE_ID, session.getProfileId()); editor.putString(KEY_SESSION_ID, session.getSessionId()); editor.putString(KEY_ACCESS_TOKEN, session.getAccessToken()); editor.putLong(KEY_EXPIRES_ON, session.getExpiresOn()); boolean isUpdated = editor.commit(); sharedLock.notifyAll(); return isUpdated; } sharedLock.notifyAll(); } return false; }
[ "public", "boolean", "updateSessionDetails", "(", "final", "SessionData", "session", ")", "{", "synchronized", "(", "sharedLock", ")", "{", "if", "(", "session", "!=", "null", ")", "{", "SharedPreferences", ".", "Editor", "editor", "=", "getSharedPreferences", "(", ")", ".", "edit", "(", ")", ";", "editor", ".", "putString", "(", "KEY_PROFILE_ID", ",", "session", ".", "getProfileId", "(", ")", ")", ";", "editor", ".", "putString", "(", "KEY_SESSION_ID", ",", "session", ".", "getSessionId", "(", ")", ")", ";", "editor", ".", "putString", "(", "KEY_ACCESS_TOKEN", ",", "session", ".", "getAccessToken", "(", ")", ")", ";", "editor", ".", "putLong", "(", "KEY_EXPIRES_ON", ",", "session", ".", "getExpiresOn", "(", ")", ")", ";", "boolean", "isUpdated", "=", "editor", ".", "commit", "(", ")", ";", "sharedLock", ".", "notifyAll", "(", ")", ";", "return", "isUpdated", ";", "}", "sharedLock", ".", "notifyAll", "(", ")", ";", "}", "return", "false", ";", "}" ]
Updates session details obtained frm the services. @return True if session was updated. If false the update is for a different user or session is not started.
[ "Updates", "session", "details", "obtained", "frm", "the", "services", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/data/SessionDAO.java#L143-L160
144,466
blackdoor/blackdoor
src/main/java/black/door/json/Derulo.java
Derulo.fromJSON
public static Object fromJSON(String jsonString){ List<Token> tokens = Derulo.toTokens(jsonString); return fromJSON(tokens); }
java
public static Object fromJSON(String jsonString){ List<Token> tokens = Derulo.toTokens(jsonString); return fromJSON(tokens); }
[ "public", "static", "Object", "fromJSON", "(", "String", "jsonString", ")", "{", "List", "<", "Token", ">", "tokens", "=", "Derulo", ".", "toTokens", "(", "jsonString", ")", ";", "return", "fromJSON", "(", "tokens", ")", ";", "}" ]
Get a java object from a JSON value @param jsonString a JSON value in string form @return a Number, Boolean, JsonObject, JsonArray or JsonNull @throws JsonException
[ "Get", "a", "java", "object", "from", "a", "JSON", "value" ]
060c7a71dfafb85e10e8717736e6d3160262e96b
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/json/Derulo.java#L90-L93
144,467
sebastiangraf/perfidix
src/main/java/org/perfidix/example/list/IntList.java
IntList.add
final void add(final int e) { if (size == list.length) list = Arrays.copyOf(list, newSize()); list[size++] = e; }
java
final void add(final int e) { if (size == list.length) list = Arrays.copyOf(list, newSize()); list[size++] = e; }
[ "final", "void", "add", "(", "final", "int", "e", ")", "{", "if", "(", "size", "==", "list", ".", "length", ")", "list", "=", "Arrays", ".", "copyOf", "(", "list", ",", "newSize", "(", ")", ")", ";", "list", "[", "size", "++", "]", "=", "e", ";", "}" ]
Adds an entry to the array. @param e entry to be added
[ "Adds", "an", "entry", "to", "the", "array", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/example/list/IntList.java#L78-L81
144,468
sebastiangraf/perfidix
src/main/java/org/perfidix/example/list/IntList.java
IntList.contains
public final boolean contains(final int e) { for (int i = 0; i < size; ++i) if (list[i] == e) return true; return false; }
java
public final boolean contains(final int e) { for (int i = 0; i < size; ++i) if (list[i] == e) return true; return false; }
[ "public", "final", "boolean", "contains", "(", "final", "int", "e", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "++", "i", ")", "if", "(", "list", "[", "i", "]", "==", "e", ")", "return", "true", ";", "return", "false", ";", "}" ]
Checks if the specified element is found in the list. @param e element to be found @return result of check
[ "Checks", "if", "the", "specified", "element", "is", "found", "in", "the", "list", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/example/list/IntList.java#L111-L115
144,469
sebastiangraf/perfidix
src/main/java/org/perfidix/example/list/IntList.java
IntList.insert
public final void insert(final int i, final int[] e) { final int l = e.length; if (l == 0) return; if (size + l > list.length) list = Arrays.copyOf(list, newSize(size + l)); Array.move(list, i, l, size - i); System.arraycopy(e, 0, list, i, l); size += l; }
java
public final void insert(final int i, final int[] e) { final int l = e.length; if (l == 0) return; if (size + l > list.length) list = Arrays.copyOf(list, newSize(size + l)); Array.move(list, i, l, size - i); System.arraycopy(e, 0, list, i, l); size += l; }
[ "public", "final", "void", "insert", "(", "final", "int", "i", ",", "final", "int", "[", "]", "e", ")", "{", "final", "int", "l", "=", "e", ".", "length", ";", "if", "(", "l", "==", "0", ")", "return", ";", "if", "(", "size", "+", "l", ">", "list", ".", "length", ")", "list", "=", "Arrays", ".", "copyOf", "(", "list", ",", "newSize", "(", "size", "+", "l", ")", ")", ";", "Array", ".", "move", "(", "list", ",", "i", ",", "l", ",", "size", "-", "i", ")", ";", "System", ".", "arraycopy", "(", "e", ",", "0", ",", "list", ",", "i", ",", "l", ")", ";", "size", "+=", "l", ";", "}" ]
Inserts elements at the specified index position. @param i index @param e elements to be inserted
[ "Inserts", "elements", "at", "the", "specified", "index", "position", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/example/list/IntList.java#L123-L130
144,470
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.expandAllFixedHeight
public static void expandAllFixedHeight(JTree tree) { // Determine a suitable row height for the tree, based on the // size of the component that is used for rendering the root TreeCellRenderer cellRenderer = tree.getCellRenderer(); Component treeCellRendererComponent = cellRenderer.getTreeCellRendererComponent( tree, tree.getModel().getRoot(), false, false, false, 1, false); int rowHeight = treeCellRendererComponent.getPreferredSize().height + 2; tree.setRowHeight(rowHeight); // Temporarily remove all listeners that would otherwise // be flooded with TreeExpansionEvents List<TreeExpansionListener> expansionListeners = Arrays.asList(tree.getTreeExpansionListeners()); for (TreeExpansionListener expansionListener : expansionListeners) { tree.removeTreeExpansionListener(expansionListener); } // Recursively expand all nodes of the tree TreePath rootPath = new TreePath(tree.getModel().getRoot()); expandAllRecursively(tree, rootPath); // Restore the listeners that the tree originally had for (TreeExpansionListener expansionListener : expansionListeners) { tree.addTreeExpansionListener(expansionListener); } // Trigger an update for the TreeExpansionListeners tree.collapsePath(rootPath); tree.expandPath(rootPath); }
java
public static void expandAllFixedHeight(JTree tree) { // Determine a suitable row height for the tree, based on the // size of the component that is used for rendering the root TreeCellRenderer cellRenderer = tree.getCellRenderer(); Component treeCellRendererComponent = cellRenderer.getTreeCellRendererComponent( tree, tree.getModel().getRoot(), false, false, false, 1, false); int rowHeight = treeCellRendererComponent.getPreferredSize().height + 2; tree.setRowHeight(rowHeight); // Temporarily remove all listeners that would otherwise // be flooded with TreeExpansionEvents List<TreeExpansionListener> expansionListeners = Arrays.asList(tree.getTreeExpansionListeners()); for (TreeExpansionListener expansionListener : expansionListeners) { tree.removeTreeExpansionListener(expansionListener); } // Recursively expand all nodes of the tree TreePath rootPath = new TreePath(tree.getModel().getRoot()); expandAllRecursively(tree, rootPath); // Restore the listeners that the tree originally had for (TreeExpansionListener expansionListener : expansionListeners) { tree.addTreeExpansionListener(expansionListener); } // Trigger an update for the TreeExpansionListeners tree.collapsePath(rootPath); tree.expandPath(rootPath); }
[ "public", "static", "void", "expandAllFixedHeight", "(", "JTree", "tree", ")", "{", "// Determine a suitable row height for the tree, based on the \r", "// size of the component that is used for rendering the root \r", "TreeCellRenderer", "cellRenderer", "=", "tree", ".", "getCellRenderer", "(", ")", ";", "Component", "treeCellRendererComponent", "=", "cellRenderer", ".", "getTreeCellRendererComponent", "(", "tree", ",", "tree", ".", "getModel", "(", ")", ".", "getRoot", "(", ")", ",", "false", ",", "false", ",", "false", ",", "1", ",", "false", ")", ";", "int", "rowHeight", "=", "treeCellRendererComponent", ".", "getPreferredSize", "(", ")", ".", "height", "+", "2", ";", "tree", ".", "setRowHeight", "(", "rowHeight", ")", ";", "// Temporarily remove all listeners that would otherwise\r", "// be flooded with TreeExpansionEvents\r", "List", "<", "TreeExpansionListener", ">", "expansionListeners", "=", "Arrays", ".", "asList", "(", "tree", ".", "getTreeExpansionListeners", "(", ")", ")", ";", "for", "(", "TreeExpansionListener", "expansionListener", ":", "expansionListeners", ")", "{", "tree", ".", "removeTreeExpansionListener", "(", "expansionListener", ")", ";", "}", "// Recursively expand all nodes of the tree\r", "TreePath", "rootPath", "=", "new", "TreePath", "(", "tree", ".", "getModel", "(", ")", ".", "getRoot", "(", ")", ")", ";", "expandAllRecursively", "(", "tree", ",", "rootPath", ")", ";", "// Restore the listeners that the tree originally had\r", "for", "(", "TreeExpansionListener", "expansionListener", ":", "expansionListeners", ")", "{", "tree", ".", "addTreeExpansionListener", "(", "expansionListener", ")", ";", "}", "// Trigger an update for the TreeExpansionListeners\r", "tree", ".", "collapsePath", "(", "rootPath", ")", ";", "tree", ".", "expandPath", "(", "rootPath", ")", ";", "}" ]
Expand all rows of the given tree, assuming a fixed height for the rows. @param tree The tree
[ "Expand", "all", "rows", "of", "the", "given", "tree", "assuming", "a", "fixed", "height", "for", "the", "rows", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L84-L117
144,471
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.expandAllRecursively
private static void expandAllRecursively(JTree tree, TreePath treePath) { TreeModel model = tree.getModel(); Object lastPathComponent = treePath.getLastPathComponent(); int childCount = model.getChildCount(lastPathComponent); if (childCount == 0) { return; } tree.expandPath(treePath); for (int i=0; i<childCount; i++) { Object child = model.getChild(lastPathComponent, i); int grandChildCount = model.getChildCount(child); if (grandChildCount > 0) { class LocalTreePath extends TreePath { private static final long serialVersionUID = 0; public LocalTreePath( TreePath parent, Object lastPathComponent) { super(parent, lastPathComponent); } } TreePath nextTreePath = new LocalTreePath(treePath, child); expandAllRecursively(tree, nextTreePath); } } }
java
private static void expandAllRecursively(JTree tree, TreePath treePath) { TreeModel model = tree.getModel(); Object lastPathComponent = treePath.getLastPathComponent(); int childCount = model.getChildCount(lastPathComponent); if (childCount == 0) { return; } tree.expandPath(treePath); for (int i=0; i<childCount; i++) { Object child = model.getChild(lastPathComponent, i); int grandChildCount = model.getChildCount(child); if (grandChildCount > 0) { class LocalTreePath extends TreePath { private static final long serialVersionUID = 0; public LocalTreePath( TreePath parent, Object lastPathComponent) { super(parent, lastPathComponent); } } TreePath nextTreePath = new LocalTreePath(treePath, child); expandAllRecursively(tree, nextTreePath); } } }
[ "private", "static", "void", "expandAllRecursively", "(", "JTree", "tree", ",", "TreePath", "treePath", ")", "{", "TreeModel", "model", "=", "tree", ".", "getModel", "(", ")", ";", "Object", "lastPathComponent", "=", "treePath", ".", "getLastPathComponent", "(", ")", ";", "int", "childCount", "=", "model", ".", "getChildCount", "(", "lastPathComponent", ")", ";", "if", "(", "childCount", "==", "0", ")", "{", "return", ";", "}", "tree", ".", "expandPath", "(", "treePath", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "Object", "child", "=", "model", ".", "getChild", "(", "lastPathComponent", ",", "i", ")", ";", "int", "grandChildCount", "=", "model", ".", "getChildCount", "(", "child", ")", ";", "if", "(", "grandChildCount", ">", "0", ")", "{", "class", "LocalTreePath", "extends", "TreePath", "{", "private", "static", "final", "long", "serialVersionUID", "=", "0", ";", "public", "LocalTreePath", "(", "TreePath", "parent", ",", "Object", "lastPathComponent", ")", "{", "super", "(", "parent", ",", "lastPathComponent", ")", ";", "}", "}", "TreePath", "nextTreePath", "=", "new", "LocalTreePath", "(", "treePath", ",", "child", ")", ";", "expandAllRecursively", "(", "tree", ",", "nextTreePath", ")", ";", "}", "}", "}" ]
Recursively expand all paths in the given tree, starting with the given path @param tree The tree @param treePath The current tree path
[ "Recursively", "expand", "all", "paths", "in", "the", "given", "tree", "starting", "with", "the", "given", "path" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L126-L155
144,472
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.collapseAll
public static void collapseAll(JTree tree, boolean omitRoot) { int rows = tree.getRowCount(); int limit = (omitRoot ? 1 : 0); for (int i = rows - 1; i >= limit; i--) { tree.collapseRow(i); } }
java
public static void collapseAll(JTree tree, boolean omitRoot) { int rows = tree.getRowCount(); int limit = (omitRoot ? 1 : 0); for (int i = rows - 1; i >= limit; i--) { tree.collapseRow(i); } }
[ "public", "static", "void", "collapseAll", "(", "JTree", "tree", ",", "boolean", "omitRoot", ")", "{", "int", "rows", "=", "tree", ".", "getRowCount", "(", ")", ";", "int", "limit", "=", "(", "omitRoot", "?", "1", ":", "0", ")", ";", "for", "(", "int", "i", "=", "rows", "-", "1", ";", "i", ">=", "limit", ";", "i", "--", ")", "{", "tree", ".", "collapseRow", "(", "i", ")", ";", "}", "}" ]
Collapse all rows of the given tree @param tree The tree @param omitRoot Whether the root node should not be collapsed
[ "Collapse", "all", "rows", "of", "the", "given", "tree" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L163-L171
144,473
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.countNodes
private static int countNodes(TreeModel treeModel, Object node) { int sum = 1; int n = treeModel.getChildCount(node); for (int i=0; i<n; i++) { sum += countNodes(treeModel, treeModel.getChild(node, i)); } return sum; }
java
private static int countNodes(TreeModel treeModel, Object node) { int sum = 1; int n = treeModel.getChildCount(node); for (int i=0; i<n; i++) { sum += countNodes(treeModel, treeModel.getChild(node, i)); } return sum; }
[ "private", "static", "int", "countNodes", "(", "TreeModel", "treeModel", ",", "Object", "node", ")", "{", "int", "sum", "=", "1", ";", "int", "n", "=", "treeModel", ".", "getChildCount", "(", "node", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "sum", "+=", "countNodes", "(", "treeModel", ",", "treeModel", ".", "getChild", "(", "node", ",", "i", ")", ")", ";", "}", "return", "sum", ";", "}" ]
Recursively count the number of nodes in the given tree model, starting with the given node @param treeModel The tree model @param node The node @return The number of nodes
[ "Recursively", "count", "the", "number", "of", "nodes", "in", "the", "given", "tree", "model", "starting", "with", "the", "given", "node" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L192-L201
144,474
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getChildren
public static List<Object> getChildren(TreeModel treeModel, Object node) { List<Object> children = new ArrayList<Object>(); int n = treeModel.getChildCount(node); for (int i=0; i<n; i++) { Object child = treeModel.getChild(node, i); children.add(child); } return children; }
java
public static List<Object> getChildren(TreeModel treeModel, Object node) { List<Object> children = new ArrayList<Object>(); int n = treeModel.getChildCount(node); for (int i=0; i<n; i++) { Object child = treeModel.getChild(node, i); children.add(child); } return children; }
[ "public", "static", "List", "<", "Object", ">", "getChildren", "(", "TreeModel", "treeModel", ",", "Object", "node", ")", "{", "List", "<", "Object", ">", "children", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "int", "n", "=", "treeModel", ".", "getChildCount", "(", "node", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "Object", "child", "=", "treeModel", ".", "getChild", "(", "node", ",", "i", ")", ";", "children", ".", "add", "(", "child", ")", ";", "}", "return", "children", ";", "}" ]
Returns the children of the given node in the given tree model @param treeModel The tree model @param node The node @return The children
[ "Returns", "the", "children", "of", "the", "given", "node", "in", "the", "given", "tree", "model" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L265-L275
144,475
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getAllNodes
public static List<Object> getAllNodes(TreeModel treeModel) { List<Object> result = new ArrayList<Object>(); getAllDescendants(treeModel, treeModel.getRoot(), result); result.add(0, treeModel.getRoot()); return result; }
java
public static List<Object> getAllNodes(TreeModel treeModel) { List<Object> result = new ArrayList<Object>(); getAllDescendants(treeModel, treeModel.getRoot(), result); result.add(0, treeModel.getRoot()); return result; }
[ "public", "static", "List", "<", "Object", ">", "getAllNodes", "(", "TreeModel", "treeModel", ")", "{", "List", "<", "Object", ">", "result", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "getAllDescendants", "(", "treeModel", ",", "treeModel", ".", "getRoot", "(", ")", ",", "result", ")", ";", "result", ".", "add", "(", "0", ",", "treeModel", ".", "getRoot", "(", ")", ")", ";", "return", "result", ";", "}" ]
Return all nodes of the given tree model @param treeModel The tree model @return The nodes
[ "Return", "all", "nodes", "of", "the", "given", "tree", "model" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L326-L332
144,476
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getAllDescendants
private static void getAllDescendants( TreeModel treeModel, Object node, List<Object> result) { if (node == null) { return; } result.add(node); List<Object> children = getChildren(treeModel, node); for (Object child : children) { getAllDescendants(treeModel, child, result); } }
java
private static void getAllDescendants( TreeModel treeModel, Object node, List<Object> result) { if (node == null) { return; } result.add(node); List<Object> children = getChildren(treeModel, node); for (Object child : children) { getAllDescendants(treeModel, child, result); } }
[ "private", "static", "void", "getAllDescendants", "(", "TreeModel", "treeModel", ",", "Object", "node", ",", "List", "<", "Object", ">", "result", ")", "{", "if", "(", "node", "==", "null", ")", "{", "return", ";", "}", "result", ".", "add", "(", "node", ")", ";", "List", "<", "Object", ">", "children", "=", "getChildren", "(", "treeModel", ",", "node", ")", ";", "for", "(", "Object", "child", ":", "children", ")", "{", "getAllDescendants", "(", "treeModel", ",", "child", ",", "result", ")", ";", "}", "}" ]
Compute all descendants of the given node in the given tree model @param treeModel The tree model @param node The node @param result The descendants
[ "Compute", "all", "descendants", "of", "the", "given", "node", "in", "the", "given", "tree", "model" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L358-L371
144,477
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getLeafNodes
public static List<Object> getLeafNodes(TreeModel treeModel, Object node) { List<Object> leafNodes = new ArrayList<Object>(); getLeafNodes(treeModel, node, leafNodes); return leafNodes; }
java
public static List<Object> getLeafNodes(TreeModel treeModel, Object node) { List<Object> leafNodes = new ArrayList<Object>(); getLeafNodes(treeModel, node, leafNodes); return leafNodes; }
[ "public", "static", "List", "<", "Object", ">", "getLeafNodes", "(", "TreeModel", "treeModel", ",", "Object", "node", ")", "{", "List", "<", "Object", ">", "leafNodes", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "getLeafNodes", "(", "treeModel", ",", "node", ",", "leafNodes", ")", ";", "return", "leafNodes", ";", "}" ]
Returns a list containing all leaf nodes from the given tree model that are descendants of the given node. These are the nodes that have 0 children. @param treeModel The tree model @param node The node to start the search from @return The leaf nodes
[ "Returns", "a", "list", "containing", "all", "leaf", "nodes", "from", "the", "given", "tree", "model", "that", "are", "descendants", "of", "the", "given", "node", ".", "These", "are", "the", "nodes", "that", "have", "0", "children", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L394-L399
144,478
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getLeafNodes
private static void getLeafNodes( TreeModel treeModel, Object node, Collection<Object> leafNodes) { if (node == null) { return; } int childCount = treeModel.getChildCount(node); if (childCount == 0) { leafNodes.add(node); } else { for (int i = 0; i < childCount; i++) { Object child = treeModel.getChild(node, i); getLeafNodes(treeModel, child, leafNodes); } } }
java
private static void getLeafNodes( TreeModel treeModel, Object node, Collection<Object> leafNodes) { if (node == null) { return; } int childCount = treeModel.getChildCount(node); if (childCount == 0) { leafNodes.add(node); } else { for (int i = 0; i < childCount; i++) { Object child = treeModel.getChild(node, i); getLeafNodes(treeModel, child, leafNodes); } } }
[ "private", "static", "void", "getLeafNodes", "(", "TreeModel", "treeModel", ",", "Object", "node", ",", "Collection", "<", "Object", ">", "leafNodes", ")", "{", "if", "(", "node", "==", "null", ")", "{", "return", ";", "}", "int", "childCount", "=", "treeModel", ".", "getChildCount", "(", "node", ")", ";", "if", "(", "childCount", "==", "0", ")", "{", "leafNodes", ".", "add", "(", "node", ")", ";", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "Object", "child", "=", "treeModel", ".", "getChild", "(", "node", ",", "i", ")", ";", "getLeafNodes", "(", "treeModel", ",", "child", ",", "leafNodes", ")", ";", "}", "}", "}" ]
Recursively collect all leaf nodes in the given tree model that are descendants of the given node. @param treeModel The tree model @param node The node to start the search from @param leafNodes The leaf nodes
[ "Recursively", "collect", "all", "leaf", "nodes", "in", "the", "given", "tree", "model", "that", "are", "descendants", "of", "the", "given", "node", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L409-L429
144,479
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.createTreePathToRoot
public static TreePath createTreePathToRoot( TreeModel treeModel, Object node) { List<Object> nodes = new ArrayList<Object>(); nodes.add(node); Object current = node; while (true) { Object parent = getParent(treeModel, current); if (parent == null) { break; } nodes.add(0, parent); current = parent; } TreePath treePath = new TreePath(nodes.toArray()); return treePath; }
java
public static TreePath createTreePathToRoot( TreeModel treeModel, Object node) { List<Object> nodes = new ArrayList<Object>(); nodes.add(node); Object current = node; while (true) { Object parent = getParent(treeModel, current); if (parent == null) { break; } nodes.add(0, parent); current = parent; } TreePath treePath = new TreePath(nodes.toArray()); return treePath; }
[ "public", "static", "TreePath", "createTreePathToRoot", "(", "TreeModel", "treeModel", ",", "Object", "node", ")", "{", "List", "<", "Object", ">", "nodes", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "nodes", ".", "add", "(", "node", ")", ";", "Object", "current", "=", "node", ";", "while", "(", "true", ")", "{", "Object", "parent", "=", "getParent", "(", "treeModel", ",", "current", ")", ";", "if", "(", "parent", "==", "null", ")", "{", "break", ";", "}", "nodes", ".", "add", "(", "0", ",", "parent", ")", ";", "current", "=", "parent", ";", "}", "TreePath", "treePath", "=", "new", "TreePath", "(", "nodes", ".", "toArray", "(", ")", ")", ";", "return", "treePath", ";", "}" ]
Returns the tree path from the given node to the root in the given tree model @param treeModel The tree model @param node The node @return The tree path
[ "Returns", "the", "tree", "path", "from", "the", "given", "node", "to", "the", "root", "in", "the", "given", "tree", "model" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L440-L458
144,480
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.computeExpandedPaths
public static List<TreePath> computeExpandedPaths(JTree tree) { List<TreePath> treePaths = new ArrayList<TreePath>(); int rows = tree.getRowCount(); for (int i = 0; i < rows; i++) { TreePath treePath = tree.getPathForRow(i); treePaths.add(treePath); } return treePaths; }
java
public static List<TreePath> computeExpandedPaths(JTree tree) { List<TreePath> treePaths = new ArrayList<TreePath>(); int rows = tree.getRowCount(); for (int i = 0; i < rows; i++) { TreePath treePath = tree.getPathForRow(i); treePaths.add(treePath); } return treePaths; }
[ "public", "static", "List", "<", "TreePath", ">", "computeExpandedPaths", "(", "JTree", "tree", ")", "{", "List", "<", "TreePath", ">", "treePaths", "=", "new", "ArrayList", "<", "TreePath", ">", "(", ")", ";", "int", "rows", "=", "tree", ".", "getRowCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "TreePath", "treePath", "=", "tree", ".", "getPathForRow", "(", "i", ")", ";", "treePaths", ".", "add", "(", "treePath", ")", ";", "}", "return", "treePaths", ";", "}" ]
Compute the list of all tree paths in the given tree that are currently expanded @param tree The tree @return The expanded paths
[ "Compute", "the", "list", "of", "all", "tree", "paths", "in", "the", "given", "tree", "that", "are", "currently", "expanded" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L467-L477
144,481
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.translatePath
public static TreePath translatePath( TreeModel newTreeModel, TreePath oldPath) { return translatePath(newTreeModel, oldPath, Objects::equals); }
java
public static TreePath translatePath( TreeModel newTreeModel, TreePath oldPath) { return translatePath(newTreeModel, oldPath, Objects::equals); }
[ "public", "static", "TreePath", "translatePath", "(", "TreeModel", "newTreeModel", ",", "TreePath", "oldPath", ")", "{", "return", "translatePath", "(", "newTreeModel", ",", "oldPath", ",", "Objects", "::", "equals", ")", ";", "}" ]
Translates one TreePath to a new TreeModel. This methods assumes DefaultMutableTreeNodes. @param newTreeModel The new tree model @param oldPath The old tree path @return The new tree path, or <code>null</code> if there is no corresponding path in the new tree model
[ "Translates", "one", "TreePath", "to", "a", "new", "TreeModel", ".", "This", "methods", "assumes", "DefaultMutableTreeNodes", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L489-L493
144,482
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.translatePath
public static TreePath translatePath( TreeModel newTreeModel, TreePath oldPath, BiPredicate<Object, Object> equality) { Object newRoot = newTreeModel.getRoot(); List<Object> newPath = new ArrayList<Object>(); newPath.add(newRoot); Object newPreviousElement = newRoot; for (int i=1; i<oldPath.getPathCount(); i++) { Object oldElement = oldPath.getPathComponent(i); Object oldUserObject = getUserObjectFromTreeNode(oldElement); Object newElement = getChildWith(newPreviousElement, oldUserObject, equality); if (newElement == null) { return null; } newPath.add(newElement); newPreviousElement = newElement; } return new TreePath(newPath.toArray()); }
java
public static TreePath translatePath( TreeModel newTreeModel, TreePath oldPath, BiPredicate<Object, Object> equality) { Object newRoot = newTreeModel.getRoot(); List<Object> newPath = new ArrayList<Object>(); newPath.add(newRoot); Object newPreviousElement = newRoot; for (int i=1; i<oldPath.getPathCount(); i++) { Object oldElement = oldPath.getPathComponent(i); Object oldUserObject = getUserObjectFromTreeNode(oldElement); Object newElement = getChildWith(newPreviousElement, oldUserObject, equality); if (newElement == null) { return null; } newPath.add(newElement); newPreviousElement = newElement; } return new TreePath(newPath.toArray()); }
[ "public", "static", "TreePath", "translatePath", "(", "TreeModel", "newTreeModel", ",", "TreePath", "oldPath", ",", "BiPredicate", "<", "Object", ",", "Object", ">", "equality", ")", "{", "Object", "newRoot", "=", "newTreeModel", ".", "getRoot", "(", ")", ";", "List", "<", "Object", ">", "newPath", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "newPath", ".", "add", "(", "newRoot", ")", ";", "Object", "newPreviousElement", "=", "newRoot", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "oldPath", ".", "getPathCount", "(", ")", ";", "i", "++", ")", "{", "Object", "oldElement", "=", "oldPath", ".", "getPathComponent", "(", "i", ")", ";", "Object", "oldUserObject", "=", "getUserObjectFromTreeNode", "(", "oldElement", ")", ";", "Object", "newElement", "=", "getChildWith", "(", "newPreviousElement", ",", "oldUserObject", ",", "equality", ")", ";", "if", "(", "newElement", "==", "null", ")", "{", "return", "null", ";", "}", "newPath", ".", "add", "(", "newElement", ")", ";", "newPreviousElement", "=", "newElement", ";", "}", "return", "new", "TreePath", "(", "newPath", ".", "toArray", "(", ")", ")", ";", "}" ]
Translates one TreePath to a new TreeModel. This methods assumes DefaultMutableTreeNodes, and identifies the path based on the equality of user objects using the given equality predicate. @param newTreeModel The new tree model @param oldPath The old tree path @param equality The equality predicate @return The new tree path, or <code>null</code> if there is no corresponding path in the new tree model
[ "Translates", "one", "TreePath", "to", "a", "new", "TreeModel", ".", "This", "methods", "assumes", "DefaultMutableTreeNodes", "and", "identifies", "the", "path", "based", "on", "the", "equality", "of", "user", "objects", "using", "the", "given", "equality", "predicate", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L506-L528
144,483
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.getChildWith
private static Object getChildWith(Object node, Object userObject, BiPredicate<Object, Object> equality) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node; for (int j=0; j<treeNode.getChildCount(); j++) { TreeNode child = treeNode.getChildAt(j); Object childUserObject = getUserObjectFromTreeNode(child); if (equality.test(userObject, childUserObject)) { return child; } } return null; }
java
private static Object getChildWith(Object node, Object userObject, BiPredicate<Object, Object> equality) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node; for (int j=0; j<treeNode.getChildCount(); j++) { TreeNode child = treeNode.getChildAt(j); Object childUserObject = getUserObjectFromTreeNode(child); if (equality.test(userObject, childUserObject)) { return child; } } return null; }
[ "private", "static", "Object", "getChildWith", "(", "Object", "node", ",", "Object", "userObject", ",", "BiPredicate", "<", "Object", ",", "Object", ">", "equality", ")", "{", "DefaultMutableTreeNode", "treeNode", "=", "(", "DefaultMutableTreeNode", ")", "node", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "treeNode", ".", "getChildCount", "(", ")", ";", "j", "++", ")", "{", "TreeNode", "child", "=", "treeNode", ".", "getChildAt", "(", "j", ")", ";", "Object", "childUserObject", "=", "getUserObjectFromTreeNode", "(", "child", ")", ";", "if", "(", "equality", ".", "test", "(", "userObject", ",", "childUserObject", ")", ")", "{", "return", "child", ";", "}", "}", "return", "null", ";", "}" ]
Returns the child of the given tree node that has a user object that is equal to the given one, based on the given equality predicate. Assumes DefaultMutableTreeNodes. @param node The node @param userObject The user object @param equality The equality predicate @return The child with the given user object, or <code>null</code> if no such child can be found.
[ "Returns", "the", "child", "of", "the", "given", "tree", "node", "that", "has", "a", "user", "object", "that", "is", "equal", "to", "the", "given", "one", "based", "on", "the", "given", "equality", "predicate", ".", "Assumes", "DefaultMutableTreeNodes", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L542-L556
144,484
javagl/CommonUI
src/main/java/de/javagl/common/ui/JTrees.java
JTrees.computeIndexInParent
public static int computeIndexInParent(Object nodeObject) { if (nodeObject instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodeObject; TreeNode parent = node.getParent(); if (parent == null) { return -1; } int childCount = parent.getChildCount(); for (int i=0; i<childCount; i++) { TreeNode child = parent.getChildAt(i); if (child == nodeObject) { return i; } } } return -1; }
java
public static int computeIndexInParent(Object nodeObject) { if (nodeObject instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodeObject; TreeNode parent = node.getParent(); if (parent == null) { return -1; } int childCount = parent.getChildCount(); for (int i=0; i<childCount; i++) { TreeNode child = parent.getChildAt(i); if (child == nodeObject) { return i; } } } return -1; }
[ "public", "static", "int", "computeIndexInParent", "(", "Object", "nodeObject", ")", "{", "if", "(", "nodeObject", "instanceof", "DefaultMutableTreeNode", ")", "{", "DefaultMutableTreeNode", "node", "=", "(", "DefaultMutableTreeNode", ")", "nodeObject", ";", "TreeNode", "parent", "=", "node", ".", "getParent", "(", ")", ";", "if", "(", "parent", "==", "null", ")", "{", "return", "-", "1", ";", "}", "int", "childCount", "=", "parent", ".", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "TreeNode", "child", "=", "parent", ".", "getChildAt", "(", "i", ")", ";", "if", "(", "child", "==", "nodeObject", ")", "{", "return", "i", ";", "}", "}", "}", "return", "-", "1", ";", "}" ]
Computes the index that the given node has in its parent node. Returns -1 if the given node does not have a parent, or the node is not a DefaultMutableTreeNode. @param nodeObject The node @return The index of the node in its parent
[ "Computes", "the", "index", "that", "the", "given", "node", "has", "in", "its", "parent", "node", ".", "Returns", "-", "1", "if", "the", "given", "node", "does", "not", "have", "a", "parent", "or", "the", "node", "is", "not", "a", "DefaultMutableTreeNode", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JTrees.java#L609-L631
144,485
javagl/CommonUI
src/main/java/de/javagl/common/ui/layout/AspectLayout.java
AspectLayout.layoutChild
private void layoutChild( Component component, int cellX, int cellY, int cellSizeX, int cellSizeY) { int maxAspectW = (int)(cellSizeY * aspect); int maxAspectH = (int)(cellSizeX / aspect); if (maxAspectW > cellSizeX) { int w = cellSizeX; int h = maxAspectH; int space = cellSizeY - h; int offset = (int)(alignment * space); component.setBounds(cellX, cellY + offset, w, h); } else { int w = maxAspectW; int h = cellSizeY; int space = cellSizeX - w; int offset = (int)(alignment * space); component.setBounds(cellX + offset, cellY, w, h); } }
java
private void layoutChild( Component component, int cellX, int cellY, int cellSizeX, int cellSizeY) { int maxAspectW = (int)(cellSizeY * aspect); int maxAspectH = (int)(cellSizeX / aspect); if (maxAspectW > cellSizeX) { int w = cellSizeX; int h = maxAspectH; int space = cellSizeY - h; int offset = (int)(alignment * space); component.setBounds(cellX, cellY + offset, w, h); } else { int w = maxAspectW; int h = cellSizeY; int space = cellSizeX - w; int offset = (int)(alignment * space); component.setBounds(cellX + offset, cellY, w, h); } }
[ "private", "void", "layoutChild", "(", "Component", "component", ",", "int", "cellX", ",", "int", "cellY", ",", "int", "cellSizeX", ",", "int", "cellSizeY", ")", "{", "int", "maxAspectW", "=", "(", "int", ")", "(", "cellSizeY", "*", "aspect", ")", ";", "int", "maxAspectH", "=", "(", "int", ")", "(", "cellSizeX", "/", "aspect", ")", ";", "if", "(", "maxAspectW", ">", "cellSizeX", ")", "{", "int", "w", "=", "cellSizeX", ";", "int", "h", "=", "maxAspectH", ";", "int", "space", "=", "cellSizeY", "-", "h", ";", "int", "offset", "=", "(", "int", ")", "(", "alignment", "*", "space", ")", ";", "component", ".", "setBounds", "(", "cellX", ",", "cellY", "+", "offset", ",", "w", ",", "h", ")", ";", "}", "else", "{", "int", "w", "=", "maxAspectW", ";", "int", "h", "=", "cellSizeY", ";", "int", "space", "=", "cellSizeX", "-", "w", ";", "int", "offset", "=", "(", "int", ")", "(", "alignment", "*", "space", ")", ";", "component", ".", "setBounds", "(", "cellX", "+", "offset", ",", "cellY", ",", "w", ",", "h", ")", ";", "}", "}" ]
Lay out the given child component inside its parent, obeying the aspect ratio and alignment constraints of this layout. @param component The child component @param cellX The (pixel) x-coordinate of the cell inside the parent @param cellY The (pixel) y-coordinate of the cell inside the parent @param cellSizeX The cell size in x-direction, in pixels @param cellSizeY The cell size in y-direction, in pixels
[ "Lay", "out", "the", "given", "child", "component", "inside", "its", "parent", "obeying", "the", "aspect", "ratio", "and", "alignment", "constraints", "of", "this", "layout", "." ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/layout/AspectLayout.java#L140-L162
144,486
javagl/CommonUI
src/main/java/de/javagl/common/ui/layout/AspectLayout.java
AspectLayout.computeWastedSpace
private static double computeWastedSpace( double maxSizeX, double maxSizeY, double aspect) { int maxAspectX = (int) (maxSizeY * aspect); int maxAspectY = (int) (maxSizeX / aspect); if (maxAspectX > maxSizeX) { double sizeX = maxSizeX; double sizeY = maxAspectY; double waste = maxSizeY - sizeY; return waste * sizeX; } double sizeX = maxAspectX; double sizeY = maxSizeY; double waste = maxSizeX - sizeX; return waste * sizeY; }
java
private static double computeWastedSpace( double maxSizeX, double maxSizeY, double aspect) { int maxAspectX = (int) (maxSizeY * aspect); int maxAspectY = (int) (maxSizeX / aspect); if (maxAspectX > maxSizeX) { double sizeX = maxSizeX; double sizeY = maxAspectY; double waste = maxSizeY - sizeY; return waste * sizeX; } double sizeX = maxAspectX; double sizeY = maxSizeY; double waste = maxSizeX - sizeX; return waste * sizeY; }
[ "private", "static", "double", "computeWastedSpace", "(", "double", "maxSizeX", ",", "double", "maxSizeY", ",", "double", "aspect", ")", "{", "int", "maxAspectX", "=", "(", "int", ")", "(", "maxSizeY", "*", "aspect", ")", ";", "int", "maxAspectY", "=", "(", "int", ")", "(", "maxSizeX", "/", "aspect", ")", ";", "if", "(", "maxAspectX", ">", "maxSizeX", ")", "{", "double", "sizeX", "=", "maxSizeX", ";", "double", "sizeY", "=", "maxAspectY", ";", "double", "waste", "=", "maxSizeY", "-", "sizeY", ";", "return", "waste", "*", "sizeX", ";", "}", "double", "sizeX", "=", "maxAspectX", ";", "double", "sizeY", "=", "maxSizeY", ";", "double", "waste", "=", "maxSizeX", "-", "sizeX", ";", "return", "waste", "*", "sizeY", ";", "}" ]
Compute the wasted space that is implied by the specified layout @param maxSizeX The maximum size in x-direction @param maxSizeY The maximum size in y-direction @param aspect The aspect ratio @return The wasted space
[ "Compute", "the", "wasted", "space", "that", "is", "implied", "by", "the", "specified", "layout" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/layout/AspectLayout.java#L217-L233
144,487
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterFileLog.java
FormatterFileLog.formatMessage
String formatMessage(int msgLogLevel, String tag, String msg, Throwable exception) { if (exception != null) { return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n" + getStackTrace(exception) + "\n"; } else { return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n"; } }
java
String formatMessage(int msgLogLevel, String tag, String msg, Throwable exception) { if (exception != null) { return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n" + getStackTrace(exception) + "\n"; } else { return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n"; } }
[ "String", "formatMessage", "(", "int", "msgLogLevel", ",", "String", "tag", ",", "String", "msg", ",", "Throwable", "exception", ")", "{", "if", "(", "exception", "!=", "null", ")", "{", "return", "DateHelper", ".", "getUTC", "(", "System", ".", "currentTimeMillis", "(", ")", ")", "+", "\"/\"", "+", "getLevelTag", "(", "msgLogLevel", ")", "+", "tag", "+", "\": \"", "+", "msg", "+", "\"\\n\"", "+", "getStackTrace", "(", "exception", ")", "+", "\"\\n\"", ";", "}", "else", "{", "return", "DateHelper", ".", "getUTC", "(", "System", ".", "currentTimeMillis", "(", ")", ")", "+", "\"/\"", "+", "getLevelTag", "(", "msgLogLevel", ")", "+", "tag", "+", "\": \"", "+", "msg", "+", "\"\\n\"", ";", "}", "}" ]
Format log data into a log entry String. @param msgLogLevel Log level of an entry. @param tag Tag with SDK and version details. @param msg Log message. @param exception Exception with a stach @return Formatted log entry.
[ "Format", "log", "data", "into", "a", "log", "entry", "String", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterFileLog.java#L42-L48
144,488
comapi/comapi-sdk-android
COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterFileLog.java
FormatterFileLog.getStackTrace
private String getStackTrace(final Throwable exception) { if (exception != null) { StringBuilder sb = new StringBuilder(); StackTraceElement[] stackTrace = exception.getStackTrace(); for (StackTraceElement element : stackTrace) { sb.append(element.toString()); sb.append('\n'); } if (exception.getCause() != null) { StackTraceElement[] stackTraceCause = exception.getCause().getStackTrace(); for (StackTraceElement element : stackTraceCause) { sb.append(element.toString()); sb.append('\n'); } } return sb.toString(); } return null; }
java
private String getStackTrace(final Throwable exception) { if (exception != null) { StringBuilder sb = new StringBuilder(); StackTraceElement[] stackTrace = exception.getStackTrace(); for (StackTraceElement element : stackTrace) { sb.append(element.toString()); sb.append('\n'); } if (exception.getCause() != null) { StackTraceElement[] stackTraceCause = exception.getCause().getStackTrace(); for (StackTraceElement element : stackTraceCause) { sb.append(element.toString()); sb.append('\n'); } } return sb.toString(); } return null; }
[ "private", "String", "getStackTrace", "(", "final", "Throwable", "exception", ")", "{", "if", "(", "exception", "!=", "null", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "StackTraceElement", "[", "]", "stackTrace", "=", "exception", ".", "getStackTrace", "(", ")", ";", "for", "(", "StackTraceElement", "element", ":", "stackTrace", ")", "{", "sb", ".", "append", "(", "element", ".", "toString", "(", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "exception", ".", "getCause", "(", ")", "!=", "null", ")", "{", "StackTraceElement", "[", "]", "stackTraceCause", "=", "exception", ".", "getCause", "(", ")", ".", "getStackTrace", "(", ")", ";", "for", "(", "StackTraceElement", "element", ":", "stackTraceCause", ")", "{", "sb", ".", "append", "(", "element", ".", "toString", "(", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "return", "null", ";", "}" ]
Gets stacktrace as a String. @param exception Exception for which the stacktrace should be returned. @return Stacktrace as a String.
[ "Gets", "stacktrace", "as", "a", "String", "." ]
53140a58d5a62afe196047ccc5120bfe090ef211
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterFileLog.java#L56-L82
144,489
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.doSearch
private void doSearch() { setSearchPanelVisible(true); String selectedText = textComponent.getSelectedText(); if (selectedText != null) { searchPanel.setQuery(selectedText); } searchPanel.requestFocusForTextField(); }
java
private void doSearch() { setSearchPanelVisible(true); String selectedText = textComponent.getSelectedText(); if (selectedText != null) { searchPanel.setQuery(selectedText); } searchPanel.requestFocusForTextField(); }
[ "private", "void", "doSearch", "(", ")", "{", "setSearchPanelVisible", "(", "true", ")", ";", "String", "selectedText", "=", "textComponent", ".", "getSelectedText", "(", ")", ";", "if", "(", "selectedText", "!=", "null", ")", "{", "searchPanel", ".", "setQuery", "(", "selectedText", ")", ";", "}", "searchPanel", ".", "requestFocusForTextField", "(", ")", ";", "}" ]
Called to initiate the search. Will show the search panel, and set the currently selected text as the query
[ "Called", "to", "initiate", "the", "search", ".", "Will", "show", "the", "search", "panel", "and", "set", "the", "currently", "selected", "text", "as", "the", "query" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L170-L179
144,490
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.setSearchPanelVisible
void setSearchPanelVisible(boolean b) { if (!searchPanelVisible && b) { add(searchPanel, BorderLayout.NORTH); revalidate(); } else if (searchPanelVisible && !b) { remove(searchPanel); revalidate(); } searchPanelVisible = b; }
java
void setSearchPanelVisible(boolean b) { if (!searchPanelVisible && b) { add(searchPanel, BorderLayout.NORTH); revalidate(); } else if (searchPanelVisible && !b) { remove(searchPanel); revalidate(); } searchPanelVisible = b; }
[ "void", "setSearchPanelVisible", "(", "boolean", "b", ")", "{", "if", "(", "!", "searchPanelVisible", "&&", "b", ")", "{", "add", "(", "searchPanel", ",", "BorderLayout", ".", "NORTH", ")", ";", "revalidate", "(", ")", ";", "}", "else", "if", "(", "searchPanelVisible", "&&", "!", "b", ")", "{", "remove", "(", "searchPanel", ")", ";", "revalidate", "(", ")", ";", "}", "searchPanelVisible", "=", "b", ";", "}" ]
Set whether the search panel is currently visible @param b The state
[ "Set", "whether", "the", "search", "panel", "is", "currently", "visible" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L186-L199
144,491
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.doFindNext
void doFindNext() { String query = searchPanel.getQuery(); if (query.isEmpty()) { return; } String text = getDocumentText(); boolean ignoreCase = !searchPanel.isCaseSensitive(); int caretPosition = textComponent.getCaretPosition(); int textLength = text.length(); int newCaretPosition = (caretPosition + 1) % textLength; Point match = JTextComponents.findNext( text, query, newCaretPosition, ignoreCase); if (match == null) { match = JTextComponents.findNext( text, query, 0, ignoreCase); } handleMatch(match); }
java
void doFindNext() { String query = searchPanel.getQuery(); if (query.isEmpty()) { return; } String text = getDocumentText(); boolean ignoreCase = !searchPanel.isCaseSensitive(); int caretPosition = textComponent.getCaretPosition(); int textLength = text.length(); int newCaretPosition = (caretPosition + 1) % textLength; Point match = JTextComponents.findNext( text, query, newCaretPosition, ignoreCase); if (match == null) { match = JTextComponents.findNext( text, query, 0, ignoreCase); } handleMatch(match); }
[ "void", "doFindNext", "(", ")", "{", "String", "query", "=", "searchPanel", ".", "getQuery", "(", ")", ";", "if", "(", "query", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "String", "text", "=", "getDocumentText", "(", ")", ";", "boolean", "ignoreCase", "=", "!", "searchPanel", ".", "isCaseSensitive", "(", ")", ";", "int", "caretPosition", "=", "textComponent", ".", "getCaretPosition", "(", ")", ";", "int", "textLength", "=", "text", ".", "length", "(", ")", ";", "int", "newCaretPosition", "=", "(", "caretPosition", "+", "1", ")", "%", "textLength", ";", "Point", "match", "=", "JTextComponents", ".", "findNext", "(", "text", ",", "query", ",", "newCaretPosition", ",", "ignoreCase", ")", ";", "if", "(", "match", "==", "null", ")", "{", "match", "=", "JTextComponents", ".", "findNext", "(", "text", ",", "query", ",", "0", ",", "ignoreCase", ")", ";", "}", "handleMatch", "(", "match", ")", ";", "}" ]
Find the next appearance of the search panel query
[ "Find", "the", "next", "appearance", "of", "the", "search", "panel", "query" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L204-L226
144,492
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.getDocumentText
private String getDocumentText() { try { Document document = textComponent.getDocument(); String text = document.getText(0, document.getLength()); return text; } catch (BadLocationException e) { logger.warning(e.toString()); return textComponent.getText(); } }
java
private String getDocumentText() { try { Document document = textComponent.getDocument(); String text = document.getText(0, document.getLength()); return text; } catch (BadLocationException e) { logger.warning(e.toString()); return textComponent.getText(); } }
[ "private", "String", "getDocumentText", "(", ")", "{", "try", "{", "Document", "document", "=", "textComponent", ".", "getDocument", "(", ")", ";", "String", "text", "=", "document", ".", "getText", "(", "0", ",", "document", ".", "getLength", "(", ")", ")", ";", "return", "text", ";", "}", "catch", "(", "BadLocationException", "e", ")", "{", "logger", ".", "warning", "(", "e", ".", "toString", "(", ")", ")", ";", "return", "textComponent", ".", "getText", "(", ")", ";", "}", "}" ]
Return the text of the document of the text component @return The text
[ "Return", "the", "text", "of", "the", "document", "of", "the", "text", "component" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L264-L277
144,493
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.addHighlights
private void addHighlights(Collection<? extends Point> points, Color color) { removeHighlights(points); Map<Point, Object> newHighlights = JTextComponents.addHighlights(textComponent, points, color); highlights.putAll(newHighlights); }
java
private void addHighlights(Collection<? extends Point> points, Color color) { removeHighlights(points); Map<Point, Object> newHighlights = JTextComponents.addHighlights(textComponent, points, color); highlights.putAll(newHighlights); }
[ "private", "void", "addHighlights", "(", "Collection", "<", "?", "extends", "Point", ">", "points", ",", "Color", "color", ")", "{", "removeHighlights", "(", "points", ")", ";", "Map", "<", "Point", ",", "Object", ">", "newHighlights", "=", "JTextComponents", ".", "addHighlights", "(", "textComponent", ",", "points", ",", "color", ")", ";", "highlights", ".", "putAll", "(", "newHighlights", ")", ";", "}" ]
Add highlights with the given color to the text component for all the given points @param points The points, containing start and end indices @param color The color
[ "Add", "highlights", "with", "the", "given", "color", "to", "the", "text", "component", "for", "all", "the", "given", "points" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L375-L381
144,494
javagl/CommonUI
src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java
SearchableTextComponent.removeHighlights
private void removeHighlights(Collection<? extends Point> points) { Set<Object> highlightsToRemove = new LinkedHashSet<Object>(); for (Point point : points) { Object oldHighlight = highlights.remove(point); if (oldHighlight != null) { highlightsToRemove.add(oldHighlight); } } JTextComponents.removeHighlights(textComponent, highlightsToRemove); }
java
private void removeHighlights(Collection<? extends Point> points) { Set<Object> highlightsToRemove = new LinkedHashSet<Object>(); for (Point point : points) { Object oldHighlight = highlights.remove(point); if (oldHighlight != null) { highlightsToRemove.add(oldHighlight); } } JTextComponents.removeHighlights(textComponent, highlightsToRemove); }
[ "private", "void", "removeHighlights", "(", "Collection", "<", "?", "extends", "Point", ">", "points", ")", "{", "Set", "<", "Object", ">", "highlightsToRemove", "=", "new", "LinkedHashSet", "<", "Object", ">", "(", ")", ";", "for", "(", "Point", "point", ":", "points", ")", "{", "Object", "oldHighlight", "=", "highlights", ".", "remove", "(", "point", ")", ";", "if", "(", "oldHighlight", "!=", "null", ")", "{", "highlightsToRemove", ".", "add", "(", "oldHighlight", ")", ";", "}", "}", "JTextComponents", ".", "removeHighlights", "(", "textComponent", ",", "highlightsToRemove", ")", ";", "}" ]
Remove the highlights that are associated with the given points @param points The points
[ "Remove", "the", "highlights", "that", "are", "associated", "with", "the", "given", "points" ]
b2c7a7637d4e288271392ba148dc17e4c9780255
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/SearchableTextComponent.java#L388-L400
144,495
sebastiangraf/perfidix
src/main/java/org/perfidix/result/AbstractResult.java
AbstractResult.getResultSet
public final Collection<Double> getResultSet(final AbstractMeter meter) { checkIfMeterExists(meter); return this.meterResults.get(meter); }
java
public final Collection<Double> getResultSet(final AbstractMeter meter) { checkIfMeterExists(meter); return this.meterResults.get(meter); }
[ "public", "final", "Collection", "<", "Double", ">", "getResultSet", "(", "final", "AbstractMeter", "meter", ")", "{", "checkIfMeterExists", "(", "meter", ")", ";", "return", "this", ".", "meterResults", ".", "get", "(", "meter", ")", ";", "}" ]
an array of all data items in the structure. @param meter for the results wanted @return the result set.
[ "an", "array", "of", "all", "data", "items", "in", "the", "structure", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L79-L82
144,496
sebastiangraf/perfidix
src/main/java/org/perfidix/result/AbstractResult.java
AbstractResult.squareSum
public final double squareSum(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic sqrSum = new SumOfSquares(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return sqrSum.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
java
public final double squareSum(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic sqrSum = new SumOfSquares(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return sqrSum.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
[ "public", "final", "double", "squareSum", "(", "final", "AbstractMeter", "meter", ")", "{", "checkIfMeterExists", "(", "meter", ")", ";", "final", "AbstractUnivariateStatistic", "sqrSum", "=", "new", "SumOfSquares", "(", ")", ";", "final", "CollectionDoubleCollection", "doubleColl", "=", "new", "CollectionDoubleCollection", "(", "this", ".", "meterResults", ".", "get", "(", "meter", ")", ")", ";", "return", "sqrSum", ".", "evaluate", "(", "doubleColl", ".", "toArray", "(", ")", ",", "0", ",", "doubleColl", ".", "toArray", "(", ")", ".", "length", ")", ";", "}" ]
Computes the square sum of the elements. @param meter the meter of the mean @return the square sum.
[ "Computes", "the", "square", "sum", "of", "the", "elements", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L112-L117
144,497
sebastiangraf/perfidix
src/main/java/org/perfidix/result/AbstractResult.java
AbstractResult.getStandardDeviation
public final double getStandardDeviation(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic stdDev = new StandardDeviation(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return stdDev.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
java
public final double getStandardDeviation(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic stdDev = new StandardDeviation(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return stdDev.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
[ "public", "final", "double", "getStandardDeviation", "(", "final", "AbstractMeter", "meter", ")", "{", "checkIfMeterExists", "(", "meter", ")", ";", "final", "AbstractUnivariateStatistic", "stdDev", "=", "new", "StandardDeviation", "(", ")", ";", "final", "CollectionDoubleCollection", "doubleColl", "=", "new", "CollectionDoubleCollection", "(", "this", ".", "meterResults", ".", "get", "(", "meter", ")", ")", ";", "return", "stdDev", ".", "evaluate", "(", "doubleColl", ".", "toArray", "(", ")", ",", "0", ",", "doubleColl", ".", "toArray", "(", ")", ".", "length", ")", ";", "}" ]
Computes the standard deviation. @param meter the meter of the mean @return the standard deviation
[ "Computes", "the", "standard", "deviation", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L125-L130
144,498
sebastiangraf/perfidix
src/main/java/org/perfidix/result/AbstractResult.java
AbstractResult.sum
public final double sum(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic sum = new Sum(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return sum.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
java
public final double sum(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic sum = new Sum(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return sum.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
[ "public", "final", "double", "sum", "(", "final", "AbstractMeter", "meter", ")", "{", "checkIfMeterExists", "(", "meter", ")", ";", "final", "AbstractUnivariateStatistic", "sum", "=", "new", "Sum", "(", ")", ";", "final", "CollectionDoubleCollection", "doubleColl", "=", "new", "CollectionDoubleCollection", "(", "this", ".", "meterResults", ".", "get", "(", "meter", ")", ")", ";", "return", "sum", ".", "evaluate", "(", "doubleColl", ".", "toArray", "(", ")", ",", "0", ",", "doubleColl", ".", "toArray", "(", ")", ".", "length", ")", ";", "}" ]
Computes the sum over all data items. @param meter the meter of the mean @return the sum of all runs.
[ "Computes", "the", "sum", "over", "all", "data", "items", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L138-L143
144,499
sebastiangraf/perfidix
src/main/java/org/perfidix/result/AbstractResult.java
AbstractResult.min
public final double min(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic min = new Min(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return min.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
java
public final double min(final AbstractMeter meter) { checkIfMeterExists(meter); final AbstractUnivariateStatistic min = new Min(); final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection(this.meterResults.get(meter)); return min.evaluate(doubleColl.toArray(), 0, doubleColl.toArray().length); }
[ "public", "final", "double", "min", "(", "final", "AbstractMeter", "meter", ")", "{", "checkIfMeterExists", "(", "meter", ")", ";", "final", "AbstractUnivariateStatistic", "min", "=", "new", "Min", "(", ")", ";", "final", "CollectionDoubleCollection", "doubleColl", "=", "new", "CollectionDoubleCollection", "(", "this", ".", "meterResults", ".", "get", "(", "meter", ")", ")", ";", "return", "min", ".", "evaluate", "(", "doubleColl", ".", "toArray", "(", ")", ",", "0", ",", "doubleColl", ".", "toArray", "(", ")", ".", "length", ")", ";", "}" ]
Computes the minimum. @param meter the meter of the mean @return the minimum result value.
[ "Computes", "the", "minimum", "." ]
f13aa793b6a3055215ed4edbb946c1bb5d564886
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L151-L156