repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
18
218
func_name
stringlengths
5
140
whole_func_string
stringlengths
79
3.99k
language
stringclasses
1 value
func_code_string
stringlengths
79
3.99k
func_code_tokens
listlengths
20
624
func_documentation_string
stringlengths
61
1.96k
func_documentation_tokens
listlengths
1
478
split_name
stringclasses
1 value
func_code_url
stringlengths
107
339
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPTimephasedBaselineWorkNormaliser.java
MPPTimephasedBaselineWorkNormaliser.mergeSameDay
@Override protected void mergeSameDay(ProjectCalendar calendar, LinkedList<TimephasedWork> list) { LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>(); TimephasedWork previousAssignment = null; for (TimephasedWork assignment : list) { if (previousAssignment == null) { assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } else { Date previousAssignmentStart = previousAssignment.getStart(); Date previousAssignmentStartDay = DateHelper.getDayStartDate(previousAssignmentStart); Date assignmentStart = assignment.getStart(); Date assignmentStartDay = DateHelper.getDayStartDate(assignmentStart); if (previousAssignmentStartDay.getTime() == assignmentStartDay.getTime()) { result.removeLast(); double work = previousAssignment.getTotalAmount().getDuration(); work += assignment.getTotalAmount().getDuration(); Duration totalWork = Duration.getInstance(work, TimeUnit.MINUTES); TimephasedWork merged = new TimephasedWork(); merged.setStart(previousAssignment.getStart()); merged.setFinish(assignment.getFinish()); merged.setTotalAmount(totalWork); assignment = merged; } assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } previousAssignment = assignment; } list.clear(); list.addAll(result); }
java
@Override protected void mergeSameDay(ProjectCalendar calendar, LinkedList<TimephasedWork> list) { LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>(); TimephasedWork previousAssignment = null; for (TimephasedWork assignment : list) { if (previousAssignment == null) { assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } else { Date previousAssignmentStart = previousAssignment.getStart(); Date previousAssignmentStartDay = DateHelper.getDayStartDate(previousAssignmentStart); Date assignmentStart = assignment.getStart(); Date assignmentStartDay = DateHelper.getDayStartDate(assignmentStart); if (previousAssignmentStartDay.getTime() == assignmentStartDay.getTime()) { result.removeLast(); double work = previousAssignment.getTotalAmount().getDuration(); work += assignment.getTotalAmount().getDuration(); Duration totalWork = Duration.getInstance(work, TimeUnit.MINUTES); TimephasedWork merged = new TimephasedWork(); merged.setStart(previousAssignment.getStart()); merged.setFinish(assignment.getFinish()); merged.setTotalAmount(totalWork); assignment = merged; } assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } previousAssignment = assignment; } list.clear(); list.addAll(result); }
[ "@", "Override", "protected", "void", "mergeSameDay", "(", "ProjectCalendar", "calendar", ",", "LinkedList", "<", "TimephasedWork", ">", "list", ")", "{", "LinkedList", "<", "TimephasedWork", ">", "result", "=", "new", "LinkedList", "<", "TimephasedWork", ">", "(", ")", ";", "TimephasedWork", "previousAssignment", "=", "null", ";", "for", "(", "TimephasedWork", "assignment", ":", "list", ")", "{", "if", "(", "previousAssignment", "==", "null", ")", "{", "assignment", ".", "setAmountPerDay", "(", "assignment", ".", "getTotalAmount", "(", ")", ")", ";", "result", ".", "add", "(", "assignment", ")", ";", "}", "else", "{", "Date", "previousAssignmentStart", "=", "previousAssignment", ".", "getStart", "(", ")", ";", "Date", "previousAssignmentStartDay", "=", "DateHelper", ".", "getDayStartDate", "(", "previousAssignmentStart", ")", ";", "Date", "assignmentStart", "=", "assignment", ".", "getStart", "(", ")", ";", "Date", "assignmentStartDay", "=", "DateHelper", ".", "getDayStartDate", "(", "assignmentStart", ")", ";", "if", "(", "previousAssignmentStartDay", ".", "getTime", "(", ")", "==", "assignmentStartDay", ".", "getTime", "(", ")", ")", "{", "result", ".", "removeLast", "(", ")", ";", "double", "work", "=", "previousAssignment", ".", "getTotalAmount", "(", ")", ".", "getDuration", "(", ")", ";", "work", "+=", "assignment", ".", "getTotalAmount", "(", ")", ".", "getDuration", "(", ")", ";", "Duration", "totalWork", "=", "Duration", ".", "getInstance", "(", "work", ",", "TimeUnit", ".", "MINUTES", ")", ";", "TimephasedWork", "merged", "=", "new", "TimephasedWork", "(", ")", ";", "merged", ".", "setStart", "(", "previousAssignment", ".", "getStart", "(", ")", ")", ";", "merged", ".", "setFinish", "(", "assignment", ".", "getFinish", "(", ")", ")", ";", "merged", ".", "setTotalAmount", "(", "totalWork", ")", ";", "assignment", "=", "merged", ";", "}", "assignment", ".", "setAmountPerDay", "(", "assignment", ".", "getTotalAmount", "(", ")", ")", ";", "result", ".", "add", "(", "assignment", ")", ";", "}", "previousAssignment", "=", "assignment", ";", "}", "list", ".", "clear", "(", ")", ";", "list", ".", "addAll", "(", "result", ")", ";", "}" ]
This method merges together assignment data for the same day. @param calendar current calendar @param list assignment data
[ "This", "method", "merges", "together", "assignment", "data", "for", "the", "same", "day", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPTimephasedBaselineWorkNormaliser.java#L46-L89
Whiley/WhileyCompiler
src/main/java/wyil/check/FlowTypeCheck.java
FlowTypeCheck.checkConstant
private SemanticType checkConstant(Expr.Constant expr, Environment env) { Value item = expr.getValue(); switch (item.getOpcode()) { case ITEM_null: return Type.Null; case ITEM_bool: return Type.Bool; case ITEM_int: return Type.Int; case ITEM_byte: return Type.Byte; case ITEM_utf8: // FIXME: this is not an optimal solution. The reason being that we // have lost nominal information regarding whether it is an instance // of std::ascii or std::utf8, for example. return new SemanticType.Array(Type.Int); default: return internalFailure("unknown constant encountered: " + expr, expr); } }
java
private SemanticType checkConstant(Expr.Constant expr, Environment env) { Value item = expr.getValue(); switch (item.getOpcode()) { case ITEM_null: return Type.Null; case ITEM_bool: return Type.Bool; case ITEM_int: return Type.Int; case ITEM_byte: return Type.Byte; case ITEM_utf8: // FIXME: this is not an optimal solution. The reason being that we // have lost nominal information regarding whether it is an instance // of std::ascii or std::utf8, for example. return new SemanticType.Array(Type.Int); default: return internalFailure("unknown constant encountered: " + expr, expr); } }
[ "private", "SemanticType", "checkConstant", "(", "Expr", ".", "Constant", "expr", ",", "Environment", "env", ")", "{", "Value", "item", "=", "expr", ".", "getValue", "(", ")", ";", "switch", "(", "item", ".", "getOpcode", "(", ")", ")", "{", "case", "ITEM_null", ":", "return", "Type", ".", "Null", ";", "case", "ITEM_bool", ":", "return", "Type", ".", "Bool", ";", "case", "ITEM_int", ":", "return", "Type", ".", "Int", ";", "case", "ITEM_byte", ":", "return", "Type", ".", "Byte", ";", "case", "ITEM_utf8", ":", "// FIXME: this is not an optimal solution. The reason being that we", "// have lost nominal information regarding whether it is an instance", "// of std::ascii or std::utf8, for example.", "return", "new", "SemanticType", ".", "Array", "(", "Type", ".", "Int", ")", ";", "default", ":", "return", "internalFailure", "(", "\"unknown constant encountered: \"", "+", "expr", ",", "expr", ")", ";", "}", "}" ]
Check the type of a given constant expression. This is straightforward since the determine is fully determined by the kind of constant we have. @param expr @return
[ "Check", "the", "type", "of", "a", "given", "constant", "expression", ".", "This", "is", "straightforward", "since", "the", "determine", "is", "fully", "determined", "by", "the", "kind", "of", "constant", "we", "have", "." ]
train
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L1451-L1470
pgjdbc/pgjdbc
pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java
EscapedFunctions2.areSameTsi
private static boolean areSameTsi(String a, String b) { return a.length() == b.length() && b.length() > SQL_TSI_ROOT.length() && a.regionMatches(true, SQL_TSI_ROOT.length(), b, SQL_TSI_ROOT.length(), b.length() - SQL_TSI_ROOT.length()); }
java
private static boolean areSameTsi(String a, String b) { return a.length() == b.length() && b.length() > SQL_TSI_ROOT.length() && a.regionMatches(true, SQL_TSI_ROOT.length(), b, SQL_TSI_ROOT.length(), b.length() - SQL_TSI_ROOT.length()); }
[ "private", "static", "boolean", "areSameTsi", "(", "String", "a", ",", "String", "b", ")", "{", "return", "a", ".", "length", "(", ")", "==", "b", ".", "length", "(", ")", "&&", "b", ".", "length", "(", ")", ">", "SQL_TSI_ROOT", ".", "length", "(", ")", "&&", "a", ".", "regionMatches", "(", "true", ",", "SQL_TSI_ROOT", ".", "length", "(", ")", ",", "b", ",", "SQL_TSI_ROOT", ".", "length", "(", ")", ",", "b", ".", "length", "(", ")", "-", "SQL_TSI_ROOT", ".", "length", "(", ")", ")", ";", "}" ]
Compares two TSI intervals. It is @param a first interval to compare @param b second interval to compare @return true when both intervals are equal (case insensitive)
[ "Compares", "two", "TSI", "intervals", ".", "It", "is" ]
train
https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L546-L549
sdl/odata
odata_api/src/main/java/com/sdl/odata/util/AnnotationsUtil.java
AnnotationsUtil.checkAnnotationPresent
public static <T extends Annotation> T checkAnnotationPresent(AnnotatedElement annotatedType, Class<T> annotationClass) { return getAnnotation(annotatedType, annotationClass); }
java
public static <T extends Annotation> T checkAnnotationPresent(AnnotatedElement annotatedType, Class<T> annotationClass) { return getAnnotation(annotatedType, annotationClass); }
[ "public", "static", "<", "T", "extends", "Annotation", ">", "T", "checkAnnotationPresent", "(", "AnnotatedElement", "annotatedType", ",", "Class", "<", "T", ">", "annotationClass", ")", "{", "return", "getAnnotation", "(", "annotatedType", ",", "annotationClass", ")", ";", "}" ]
Check if the annotation is present and if not throws an exception, this is just an overload for more clear naming. @param annotatedType The source type to tcheck the annotation on @param annotationClass The annotation to look for @param <T> The annotation subtype @return The annotation that was requested @throws ODataSystemException If unable to find the annotation or nullpointer in case null source was specified
[ "Check", "if", "the", "annotation", "is", "present", "and", "if", "not", "throws", "an", "exception", "this", "is", "just", "an", "overload", "for", "more", "clear", "naming", "." ]
train
https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/AnnotationsUtil.java#L43-L46
twilio/twilio-java
src/main/java/com/twilio/rest/fax/v1/fax/FaxMediaReader.java
FaxMediaReader.previousPage
@Override public Page<FaxMedia> previousPage(final Page<FaxMedia> page, final TwilioRestClient client) { Request request = new Request( HttpMethod.GET, page.getPreviousPageUrl( Domains.FAX.toString(), client.getRegion() ) ); return pageForRequest(client, request); }
java
@Override public Page<FaxMedia> previousPage(final Page<FaxMedia> page, final TwilioRestClient client) { Request request = new Request( HttpMethod.GET, page.getPreviousPageUrl( Domains.FAX.toString(), client.getRegion() ) ); return pageForRequest(client, request); }
[ "@", "Override", "public", "Page", "<", "FaxMedia", ">", "previousPage", "(", "final", "Page", "<", "FaxMedia", ">", "page", ",", "final", "TwilioRestClient", "client", ")", "{", "Request", "request", "=", "new", "Request", "(", "HttpMethod", ".", "GET", ",", "page", ".", "getPreviousPageUrl", "(", "Domains", ".", "FAX", ".", "toString", "(", ")", ",", "client", ".", "getRegion", "(", ")", ")", ")", ";", "return", "pageForRequest", "(", "client", ",", "request", ")", ";", "}" ]
Retrieve the previous page from the Twilio API. @param page current page @param client TwilioRestClient with which to make the request @return Previous Page
[ "Retrieve", "the", "previous", "page", "from", "the", "Twilio", "API", "." ]
train
https://github.com/twilio/twilio-java/blob/0318974c0a6a152994af167d430255684d5e9b9f/src/main/java/com/twilio/rest/fax/v1/fax/FaxMediaReader.java#L114-L125
sdl/Testy
src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java
GridPanel.getRowIndex
public int getRowIndex(String searchElement, int startRowIndex) { int index = -1; if (ready()) { String path = getGridCell(startRowIndex).getXPath(); WebLocator currentElement = new WebLocator().setElPath(path); while (currentElement.isElementPresent()) { String option = currentElement.getText(); //LOGGER.debug("row[" + i + "]" + option); if (option != null && option.contains(searchElement)) { LOGGER.debug("The '" + searchElement + "' element index is " + startRowIndex); index = startRowIndex; break; } startRowIndex++; path = getGridCell(startRowIndex).getXPath(); currentElement.setElPath(path); } if (index == -1) { LOGGER.warn("The element '" + searchElement + "' was not found."); } } else { LOGGER.warn("getRowIndex : grid is not ready for use: " + toString()); } return index; }
java
public int getRowIndex(String searchElement, int startRowIndex) { int index = -1; if (ready()) { String path = getGridCell(startRowIndex).getXPath(); WebLocator currentElement = new WebLocator().setElPath(path); while (currentElement.isElementPresent()) { String option = currentElement.getText(); //LOGGER.debug("row[" + i + "]" + option); if (option != null && option.contains(searchElement)) { LOGGER.debug("The '" + searchElement + "' element index is " + startRowIndex); index = startRowIndex; break; } startRowIndex++; path = getGridCell(startRowIndex).getXPath(); currentElement.setElPath(path); } if (index == -1) { LOGGER.warn("The element '" + searchElement + "' was not found."); } } else { LOGGER.warn("getRowIndex : grid is not ready for use: " + toString()); } return index; }
[ "public", "int", "getRowIndex", "(", "String", "searchElement", ",", "int", "startRowIndex", ")", "{", "int", "index", "=", "-", "1", ";", "if", "(", "ready", "(", ")", ")", "{", "String", "path", "=", "getGridCell", "(", "startRowIndex", ")", ".", "getXPath", "(", ")", ";", "WebLocator", "currentElement", "=", "new", "WebLocator", "(", ")", ".", "setElPath", "(", "path", ")", ";", "while", "(", "currentElement", ".", "isElementPresent", "(", ")", ")", "{", "String", "option", "=", "currentElement", ".", "getText", "(", ")", ";", "//LOGGER.debug(\"row[\" + i + \"]\" + option);", "if", "(", "option", "!=", "null", "&&", "option", ".", "contains", "(", "searchElement", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"The '\"", "+", "searchElement", "+", "\"' element index is \"", "+", "startRowIndex", ")", ";", "index", "=", "startRowIndex", ";", "break", ";", "}", "startRowIndex", "++", ";", "path", "=", "getGridCell", "(", "startRowIndex", ")", ".", "getXPath", "(", ")", ";", "currentElement", ".", "setElPath", "(", "path", ")", ";", "}", "if", "(", "index", "==", "-", "1", ")", "{", "LOGGER", ".", "warn", "(", "\"The element '\"", "+", "searchElement", "+", "\"' was not found.\"", ")", ";", "}", "}", "else", "{", "LOGGER", ".", "warn", "(", "\"getRowIndex : grid is not ready for use: \"", "+", "toString", "(", ")", ")", ";", "}", "return", "index", ";", "}" ]
this method is working only for normal grids (no buffer views), and first page if grid has buffer view
[ "this", "method", "is", "working", "only", "for", "normal", "grids", "(", "no", "buffer", "views", ")", "and", "first", "page", "if", "grid", "has", "buffer", "view" ]
train
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/grid/GridPanel.java#L394-L418
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationException.java
ApplicationException.withDetails
public ApplicationException withDetails(String key, Object value) { _details = _details != null ? _details : new StringValueMap(); _details.setAsObject(key, value); return this; }
java
public ApplicationException withDetails(String key, Object value) { _details = _details != null ? _details : new StringValueMap(); _details.setAsObject(key, value); return this; }
[ "public", "ApplicationException", "withDetails", "(", "String", "key", ",", "Object", "value", ")", "{", "_details", "=", "_details", "!=", "null", "?", "_details", ":", "new", "StringValueMap", "(", ")", ";", "_details", ".", "setAsObject", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a parameter for additional error details. This details can be used to restore error description in other languages. This method returns reference to this exception to implement Builder pattern to chain additional calls. @param key a details parameter name @param value a details parameter name @return this exception object
[ "Sets", "a", "parameter", "for", "additional", "error", "details", ".", "This", "details", "can", "be", "used", "to", "restore", "error", "description", "in", "other", "languages", "." ]
train
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L240-L244
joniles/mpxj
src/main/java/net/sf/mpxj/sample/MpxjFilter.java
MpxjFilter.processResourceFilter
private static void processResourceFilter(ProjectFile project, Filter filter) { for (Resource resource : project.getResources()) { if (filter.evaluate(resource, null)) { System.out.println(resource.getID() + "," + resource.getUniqueID() + "," + resource.getName()); } } }
java
private static void processResourceFilter(ProjectFile project, Filter filter) { for (Resource resource : project.getResources()) { if (filter.evaluate(resource, null)) { System.out.println(resource.getID() + "," + resource.getUniqueID() + "," + resource.getName()); } } }
[ "private", "static", "void", "processResourceFilter", "(", "ProjectFile", "project", ",", "Filter", "filter", ")", "{", "for", "(", "Resource", "resource", ":", "project", ".", "getResources", "(", ")", ")", "{", "if", "(", "filter", ".", "evaluate", "(", "resource", ",", "null", ")", ")", "{", "System", ".", "out", ".", "println", "(", "resource", ".", "getID", "(", ")", "+", "\",\"", "+", "resource", ".", "getUniqueID", "(", ")", "+", "\",\"", "+", "resource", ".", "getName", "(", ")", ")", ";", "}", "}", "}" ]
Apply a filter to the list of all resources, and show the results. @param project project file @param filter filter
[ "Apply", "a", "filter", "to", "the", "list", "of", "all", "resources", "and", "show", "the", "results", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/sample/MpxjFilter.java#L145-L154
couchbase/couchbase-java-client
src/main/java/com/couchbase/client/java/query/core/N1qlQueryExecutor.java
N1qlQueryExecutor.prepareAndExecute
protected Observable<AsyncN1qlQueryResult> prepareAndExecute(final N1qlQuery query, final CouchbaseEnvironment env, final long timeout, final TimeUnit timeUnit) { return prepare(query.statement()) .flatMap(new Func1<PreparedPayload, Observable<AsyncN1qlQueryResult>>() { @Override public Observable<AsyncN1qlQueryResult> call(PreparedPayload payload) { queryCache.put(query.statement().toString(), payload); return executePrepared(query, payload, env, timeout, timeUnit); } }); }
java
protected Observable<AsyncN1qlQueryResult> prepareAndExecute(final N1qlQuery query, final CouchbaseEnvironment env, final long timeout, final TimeUnit timeUnit) { return prepare(query.statement()) .flatMap(new Func1<PreparedPayload, Observable<AsyncN1qlQueryResult>>() { @Override public Observable<AsyncN1qlQueryResult> call(PreparedPayload payload) { queryCache.put(query.statement().toString(), payload); return executePrepared(query, payload, env, timeout, timeUnit); } }); }
[ "protected", "Observable", "<", "AsyncN1qlQueryResult", ">", "prepareAndExecute", "(", "final", "N1qlQuery", "query", ",", "final", "CouchbaseEnvironment", "env", ",", "final", "long", "timeout", ",", "final", "TimeUnit", "timeUnit", ")", "{", "return", "prepare", "(", "query", ".", "statement", "(", ")", ")", ".", "flatMap", "(", "new", "Func1", "<", "PreparedPayload", ",", "Observable", "<", "AsyncN1qlQueryResult", ">", ">", "(", ")", "{", "@", "Override", "public", "Observable", "<", "AsyncN1qlQueryResult", ">", "call", "(", "PreparedPayload", "payload", ")", "{", "queryCache", ".", "put", "(", "query", ".", "statement", "(", ")", ".", "toString", "(", ")", ",", "payload", ")", ";", "return", "executePrepared", "(", "query", ",", "payload", ",", "env", ",", "timeout", ",", "timeUnit", ")", ";", "}", "}", ")", ";", "}" ]
Issues a N1QL PREPARE, puts the plan in cache then EXECUTE it.
[ "Issues", "a", "N1QL", "PREPARE", "puts", "the", "plan", "in", "cache", "then", "EXECUTE", "it", "." ]
train
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/core/N1qlQueryExecutor.java#L396-L405
mapsforge/mapsforge
mapsforge-map/src/main/java/org/mapsforge/map/layer/download/TileDownloadLayer.java
TileDownloadLayer.isTileStale
@Override protected boolean isTileStale(Tile tile, TileBitmap bitmap) { if (bitmap.isExpired()) return true; return cacheTimeToLive != 0 && ((bitmap.getTimestamp() + cacheTimeToLive) < System.currentTimeMillis()); }
java
@Override protected boolean isTileStale(Tile tile, TileBitmap bitmap) { if (bitmap.isExpired()) return true; return cacheTimeToLive != 0 && ((bitmap.getTimestamp() + cacheTimeToLive) < System.currentTimeMillis()); }
[ "@", "Override", "protected", "boolean", "isTileStale", "(", "Tile", "tile", ",", "TileBitmap", "bitmap", ")", "{", "if", "(", "bitmap", ".", "isExpired", "(", ")", ")", "return", "true", ";", "return", "cacheTimeToLive", "!=", "0", "&&", "(", "(", "bitmap", ".", "getTimestamp", "(", ")", "+", "cacheTimeToLive", ")", "<", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "}" ]
Whether the tile is stale and should be refreshed. <p/> This method is called from {@link #draw(BoundingBox, byte, Canvas, Point)} to determine whether the tile needs to be refreshed. <p/> A tile is considered stale if one or more of the following two conditions apply: <ul> <li>The {@code bitmap}'s {@link org.mapsforge.core.graphics.TileBitmap#isExpired()} method returns {@code True}.</li> <li>The layer has a time-to-live (TTL) set ({@link #getCacheTimeToLive()} returns a nonzero value) and the sum of the {@code bitmap}'s {@link org.mapsforge.core.graphics.TileBitmap#getTimestamp()} and TTL is less than current time (as returned by {@link java.lang.System#currentTimeMillis()}).</li> </ul> <p/> When a tile has become stale, the layer will first display the tile referenced by {@code bitmap} and attempt to obtain a fresh copy in the background. When a fresh copy becomes available, the layer will replace it and update the cache. If a fresh copy cannot be obtained (e.g. because the tile is obtained from an online source which cannot be reached), the stale tile will continue to be used until another {@code #draw(BoundingBox, byte, Canvas, Point)} operation requests it again. @param tile A tile. This parameter is not used for a {@code TileDownloadLayer} and can be null. @param bitmap The bitmap for {@code tile} currently held in the layer's cache.
[ "Whether", "the", "tile", "is", "stale", "and", "should", "be", "refreshed", ".", "<p", "/", ">", "This", "method", "is", "called", "from", "{", "@link", "#draw", "(", "BoundingBox", "byte", "Canvas", "Point", ")", "}", "to", "determine", "whether", "the", "tile", "needs", "to", "be", "refreshed", ".", "<p", "/", ">", "A", "tile", "is", "considered", "stale", "if", "one", "or", "more", "of", "the", "following", "two", "conditions", "apply", ":", "<ul", ">", "<li", ">", "The", "{", "@code", "bitmap", "}", "s", "{", "@link", "org", ".", "mapsforge", ".", "core", ".", "graphics", ".", "TileBitmap#isExpired", "()", "}", "method", "returns", "{", "@code", "True", "}", ".", "<", "/", "li", ">", "<li", ">", "The", "layer", "has", "a", "time", "-", "to", "-", "live", "(", "TTL", ")", "set", "(", "{", "@link", "#getCacheTimeToLive", "()", "}", "returns", "a", "nonzero", "value", ")", "and", "the", "sum", "of", "the", "{", "@code", "bitmap", "}", "s", "{", "@link", "org", ".", "mapsforge", ".", "core", ".", "graphics", ".", "TileBitmap#getTimestamp", "()", "}", "and", "TTL", "is", "less", "than", "current", "time", "(", "as", "returned", "by", "{", "@link", "java", ".", "lang", ".", "System#currentTimeMillis", "()", "}", ")", ".", "<", "/", "li", ">", "<", "/", "ul", ">", "<p", "/", ">", "When", "a", "tile", "has", "become", "stale", "the", "layer", "will", "first", "display", "the", "tile", "referenced", "by", "{", "@code", "bitmap", "}", "and", "attempt", "to", "obtain", "a", "fresh", "copy", "in", "the", "background", ".", "When", "a", "fresh", "copy", "becomes", "available", "the", "layer", "will", "replace", "it", "and", "update", "the", "cache", ".", "If", "a", "fresh", "copy", "cannot", "be", "obtained", "(", "e", ".", "g", ".", "because", "the", "tile", "is", "obtained", "from", "an", "online", "source", "which", "cannot", "be", "reached", ")", "the", "stale", "tile", "will", "continue", "to", "be", "used", "until", "another", "{", "@code", "#draw", "(", "BoundingBox", "byte", "Canvas", "Point", ")", "}", "operation", "requests", "it", "again", "." ]
train
https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/download/TileDownloadLayer.java#L161-L166
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.computeNodeInfo
void computeNodeInfo(List<EllipseRotated_F64> ellipses , List<Node> cluster ) { // create an info object for each member inside of the cluster listInfo.reset(); for (int i = 0; i < cluster.size(); i++) { Node n = cluster.get(i); EllipseRotated_F64 t = ellipses.get( n.which ); NodeInfo info = listInfo.grow(); info.reset(); info.ellipse = t; } addEdgesToInfo(cluster); pruneNearlyIdenticalAngles(); findLargestAnglesForAllNodes(); }
java
void computeNodeInfo(List<EllipseRotated_F64> ellipses , List<Node> cluster ) { // create an info object for each member inside of the cluster listInfo.reset(); for (int i = 0; i < cluster.size(); i++) { Node n = cluster.get(i); EllipseRotated_F64 t = ellipses.get( n.which ); NodeInfo info = listInfo.grow(); info.reset(); info.ellipse = t; } addEdgesToInfo(cluster); pruneNearlyIdenticalAngles(); findLargestAnglesForAllNodes(); }
[ "void", "computeNodeInfo", "(", "List", "<", "EllipseRotated_F64", ">", "ellipses", ",", "List", "<", "Node", ">", "cluster", ")", "{", "// create an info object for each member inside of the cluster", "listInfo", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cluster", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Node", "n", "=", "cluster", ".", "get", "(", "i", ")", ";", "EllipseRotated_F64", "t", "=", "ellipses", ".", "get", "(", "n", ".", "which", ")", ";", "NodeInfo", "info", "=", "listInfo", ".", "grow", "(", ")", ";", "info", ".", "reset", "(", ")", ";", "info", ".", "ellipse", "=", "t", ";", "}", "addEdgesToInfo", "(", "cluster", ")", ";", "pruneNearlyIdenticalAngles", "(", ")", ";", "findLargestAnglesForAllNodes", "(", ")", ";", "}" ]
For each cluster create a {@link NodeInfo} and compute different properties
[ "For", "each", "cluster", "create", "a", "{" ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L267-L283
roskart/dropwizard-jaxws
dropwizard-jaxws/src/main/java/com/roskart/dropwizard/jaxws/JAXWSBundle.java
JAXWSBundle.publishEndpoint
public Endpoint publishEndpoint(String path, Object service, SessionFactory sessionFactory) { return this.publishEndpoint(path, service, null, sessionFactory); }
java
public Endpoint publishEndpoint(String path, Object service, SessionFactory sessionFactory) { return this.publishEndpoint(path, service, null, sessionFactory); }
[ "public", "Endpoint", "publishEndpoint", "(", "String", "path", ",", "Object", "service", ",", "SessionFactory", "sessionFactory", ")", "{", "return", "this", ".", "publishEndpoint", "(", "path", ",", "service", ",", "null", ",", "sessionFactory", ")", ";", "}" ]
Publish JAX-WS endpoint with Dropwizard Hibernate Bundle integration. Service is scanned for @UnitOfWork annotations. EndpointBuilder is published relative to the CXF servlet path. @param path Relative endpoint path. @param service Service implementation. @param sessionFactory Hibernate session factory. @return javax.xml.ws.Endpoint @deprecated Use the {@link #publishEndpoint(EndpointBuilder)} publishEndpoint} method instead.
[ "Publish", "JAX", "-", "WS", "endpoint", "with", "Dropwizard", "Hibernate", "Bundle", "integration", ".", "Service", "is", "scanned", "for", "@UnitOfWork", "annotations", ".", "EndpointBuilder", "is", "published", "relative", "to", "the", "CXF", "servlet", "path", ".", "@param", "path", "Relative", "endpoint", "path", ".", "@param", "service", "Service", "implementation", ".", "@param", "sessionFactory", "Hibernate", "session", "factory", ".", "@return", "javax", ".", "xml", ".", "ws", ".", "Endpoint" ]
train
https://github.com/roskart/dropwizard-jaxws/blob/972eb63ba9626f3282d4a1d6127dc2b60b28f2bc/dropwizard-jaxws/src/main/java/com/roskart/dropwizard/jaxws/JAXWSBundle.java#L110-L112
opencb/biodata
biodata-tools/src/main/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManager.java
VariantMetadataManager.removeCohort
public void removeCohort(Cohort cohort, String studyId) { // Sanity check if (cohort == null) { logger.error("Cohort is null."); return; } removeCohort(cohort.getId(), studyId); }
java
public void removeCohort(Cohort cohort, String studyId) { // Sanity check if (cohort == null) { logger.error("Cohort is null."); return; } removeCohort(cohort.getId(), studyId); }
[ "public", "void", "removeCohort", "(", "Cohort", "cohort", ",", "String", "studyId", ")", "{", "// Sanity check", "if", "(", "cohort", "==", "null", ")", "{", "logger", ".", "error", "(", "\"Cohort is null.\"", ")", ";", "return", ";", "}", "removeCohort", "(", "cohort", ".", "getId", "(", ")", ",", "studyId", ")", ";", "}" ]
Remove a cohort of a given variant study metadata (from study ID). @param cohort Cohort @param studyId Study ID
[ "Remove", "a", "cohort", "of", "a", "given", "variant", "study", "metadata", "(", "from", "study", "ID", ")", "." ]
train
https://github.com/opencb/biodata/blob/21b3d51d71f578efab908422aca4bab7a73097b1/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManager.java#L431-L438
aws/aws-sdk-java
aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/Get.java
Get.withKey
public Get withKey(java.util.Map<String, AttributeValue> key) { setKey(key); return this; }
java
public Get withKey(java.util.Map<String, AttributeValue> key) { setKey(key); return this; }
[ "public", "Get", "withKey", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "AttributeValue", ">", "key", ")", "{", "setKey", "(", "key", ")", ";", "return", "this", ";", "}" ]
<p> A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve. </p> @param key A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "A", "map", "of", "attribute", "names", "to", "<code", ">", "AttributeValue<", "/", "code", ">", "objects", "that", "specifies", "the", "primary", "key", "of", "the", "item", "to", "retrieve", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/Get.java#L99-L102
google/j2objc
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ForkJoinPool.java
ForkJoinPool.tryCreateExternalQueue
private void tryCreateExternalQueue(int index) { AuxState aux; if ((aux = auxState) != null && index >= 0) { WorkQueue q = new WorkQueue(this, null); q.config = index; q.scanState = ~UNSIGNALLED; q.qlock = 1; // lock queue boolean installed = false; aux.lock(); try { // lock pool to install WorkQueue[] ws; if ((ws = workQueues) != null && index < ws.length && ws[index] == null) { ws[index] = q; // else throw away installed = true; } } finally { aux.unlock(); } if (installed) { try { q.growArray(); } finally { q.qlock = 0; } } } }
java
private void tryCreateExternalQueue(int index) { AuxState aux; if ((aux = auxState) != null && index >= 0) { WorkQueue q = new WorkQueue(this, null); q.config = index; q.scanState = ~UNSIGNALLED; q.qlock = 1; // lock queue boolean installed = false; aux.lock(); try { // lock pool to install WorkQueue[] ws; if ((ws = workQueues) != null && index < ws.length && ws[index] == null) { ws[index] = q; // else throw away installed = true; } } finally { aux.unlock(); } if (installed) { try { q.growArray(); } finally { q.qlock = 0; } } } }
[ "private", "void", "tryCreateExternalQueue", "(", "int", "index", ")", "{", "AuxState", "aux", ";", "if", "(", "(", "aux", "=", "auxState", ")", "!=", "null", "&&", "index", ">=", "0", ")", "{", "WorkQueue", "q", "=", "new", "WorkQueue", "(", "this", ",", "null", ")", ";", "q", ".", "config", "=", "index", ";", "q", ".", "scanState", "=", "~", "UNSIGNALLED", ";", "q", ".", "qlock", "=", "1", ";", "// lock queue", "boolean", "installed", "=", "false", ";", "aux", ".", "lock", "(", ")", ";", "try", "{", "// lock pool to install", "WorkQueue", "[", "]", "ws", ";", "if", "(", "(", "ws", "=", "workQueues", ")", "!=", "null", "&&", "index", "<", "ws", ".", "length", "&&", "ws", "[", "index", "]", "==", "null", ")", "{", "ws", "[", "index", "]", "=", "q", ";", "// else throw away", "installed", "=", "true", ";", "}", "}", "finally", "{", "aux", ".", "unlock", "(", ")", ";", "}", "if", "(", "installed", ")", "{", "try", "{", "q", ".", "growArray", "(", ")", ";", "}", "finally", "{", "q", ".", "qlock", "=", "0", ";", "}", "}", "}", "}" ]
Constructs and tries to install a new external queue, failing if the workQueues array already has a queue at the given index. @param index the index of the new queue
[ "Constructs", "and", "tries", "to", "install", "a", "new", "external", "queue", "failing", "if", "the", "workQueues", "array", "already", "has", "a", "queue", "at", "the", "given", "index", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ForkJoinPool.java#L2487-L2514
UrielCh/ovh-java-sdk
ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java
ApiOvhXdsl.templateModem_name_GET
public OvhTemplateModem templateModem_name_GET(String name) throws IOException { String qPath = "/xdsl/templateModem/{name}"; StringBuilder sb = path(qPath, name); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhTemplateModem.class); }
java
public OvhTemplateModem templateModem_name_GET(String name) throws IOException { String qPath = "/xdsl/templateModem/{name}"; StringBuilder sb = path(qPath, name); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhTemplateModem.class); }
[ "public", "OvhTemplateModem", "templateModem_name_GET", "(", "String", "name", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/xdsl/templateModem/{name}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "name", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhTemplateModem", ".", "class", ")", ";", "}" ]
Get this object properties REST: GET /xdsl/templateModem/{name} @param name [required] Name of the Modem Template API beta
[ "Get", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L122-L127
apache/flink
flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
TableSchema.fromTypeInfo
public static TableSchema fromTypeInfo(TypeInformation<?> typeInfo) { if (typeInfo instanceof CompositeType<?>) { final CompositeType<?> compositeType = (CompositeType<?>) typeInfo; // get field names and types from composite type final String[] fieldNames = compositeType.getFieldNames(); final TypeInformation<?>[] fieldTypes = new TypeInformation[fieldNames.length]; for (int i = 0; i < fieldTypes.length; i++) { fieldTypes[i] = compositeType.getTypeAt(i); } return new TableSchema(fieldNames, fieldTypes); } else { // create table schema with a single field named "f0" of the given type. return new TableSchema( new String[]{ATOMIC_TYPE_FIELD_NAME}, new TypeInformation<?>[]{typeInfo}); } }
java
public static TableSchema fromTypeInfo(TypeInformation<?> typeInfo) { if (typeInfo instanceof CompositeType<?>) { final CompositeType<?> compositeType = (CompositeType<?>) typeInfo; // get field names and types from composite type final String[] fieldNames = compositeType.getFieldNames(); final TypeInformation<?>[] fieldTypes = new TypeInformation[fieldNames.length]; for (int i = 0; i < fieldTypes.length; i++) { fieldTypes[i] = compositeType.getTypeAt(i); } return new TableSchema(fieldNames, fieldTypes); } else { // create table schema with a single field named "f0" of the given type. return new TableSchema( new String[]{ATOMIC_TYPE_FIELD_NAME}, new TypeInformation<?>[]{typeInfo}); } }
[ "public", "static", "TableSchema", "fromTypeInfo", "(", "TypeInformation", "<", "?", ">", "typeInfo", ")", "{", "if", "(", "typeInfo", "instanceof", "CompositeType", "<", "?", ">", ")", "{", "final", "CompositeType", "<", "?", ">", "compositeType", "=", "(", "CompositeType", "<", "?", ">", ")", "typeInfo", ";", "// get field names and types from composite type", "final", "String", "[", "]", "fieldNames", "=", "compositeType", ".", "getFieldNames", "(", ")", ";", "final", "TypeInformation", "<", "?", ">", "[", "]", "fieldTypes", "=", "new", "TypeInformation", "[", "fieldNames", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fieldTypes", ".", "length", ";", "i", "++", ")", "{", "fieldTypes", "[", "i", "]", "=", "compositeType", ".", "getTypeAt", "(", "i", ")", ";", "}", "return", "new", "TableSchema", "(", "fieldNames", ",", "fieldTypes", ")", ";", "}", "else", "{", "// create table schema with a single field named \"f0\" of the given type.", "return", "new", "TableSchema", "(", "new", "String", "[", "]", "{", "ATOMIC_TYPE_FIELD_NAME", "}", ",", "new", "TypeInformation", "<", "?", ">", "[", "]", "{", "typeInfo", "}", ")", ";", "}", "}" ]
Creates a table schema from a {@link TypeInformation} instance. If the type information is a {@link CompositeType}, the field names and types for the composite type are used to construct the {@link TableSchema} instance. Otherwise, a table schema with a single field is created. The field name is "f0" and the field type the provided type. @param typeInfo The {@link TypeInformation} from which the table schema is generated. @return The table schema that was generated from the given {@link TypeInformation}.
[ "Creates", "a", "table", "schema", "from", "a", "{", "@link", "TypeInformation", "}", "instance", ".", "If", "the", "type", "information", "is", "a", "{", "@link", "CompositeType", "}", "the", "field", "names", "and", "types", "for", "the", "composite", "type", "are", "used", "to", "construct", "the", "{", "@link", "TableSchema", "}", "instance", ".", "Otherwise", "a", "table", "schema", "with", "a", "single", "field", "is", "created", ".", "The", "field", "name", "is", "f0", "and", "the", "field", "type", "the", "provided", "type", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java#L216-L232
javactic/javactic
src/main/java/com/github/javactic/Accumulation.java
Accumulation.when
@SuppressWarnings("unchecked") @SafeVarargs public static <G, ERR> Or<G, Every<ERR>> when(Or<? extends G, ? extends Every<? extends ERR>> or, Function<? super G, ? extends Validation<ERR>>... validations) { return when(or, Stream.of(validations)); }
java
@SuppressWarnings("unchecked") @SafeVarargs public static <G, ERR> Or<G, Every<ERR>> when(Or<? extends G, ? extends Every<? extends ERR>> or, Function<? super G, ? extends Validation<ERR>>... validations) { return when(or, Stream.of(validations)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "SafeVarargs", "public", "static", "<", "G", ",", "ERR", ">", "Or", "<", "G", ",", "Every", "<", "ERR", ">", ">", "when", "(", "Or", "<", "?", "extends", "G", ",", "?", "extends", "Every", "<", "?", "extends", "ERR", ">", ">", "or", ",", "Function", "<", "?", "super", "G", ",", "?", "extends", "Validation", "<", "ERR", ">", ">", "...", "validations", ")", "{", "return", "when", "(", "or", ",", "Stream", ".", "of", "(", "validations", ")", ")", ";", "}" ]
Enables further validation on an existing accumulating Or by passing validation functions. @param <G> the Good type of the argument Or @param <ERR> the type of the error message contained in the accumulating failure @param or the accumulating or @param validations the validation functions @return the original or if it passed all validations or a Bad with all failures
[ "Enables", "further", "validation", "on", "an", "existing", "accumulating", "Or", "by", "passing", "validation", "functions", "." ]
train
https://github.com/javactic/javactic/blob/dfa040062178c259c3067fd9b59cb4498022d8bc/src/main/java/com/github/javactic/Accumulation.java#L161-L166
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/tree/patricia/MutableNode.java
MutableNode.addRightChild
void addRightChild(final byte b, @NotNull final MutableNode child) { final ChildReference right = children.getRight(); if (right != null && (right.firstByte & 0xff) >= (b & 0xff)) { throw new IllegalArgumentException(); } children.putRight(new ChildReferenceMutable(b, child)); }
java
void addRightChild(final byte b, @NotNull final MutableNode child) { final ChildReference right = children.getRight(); if (right != null && (right.firstByte & 0xff) >= (b & 0xff)) { throw new IllegalArgumentException(); } children.putRight(new ChildReferenceMutable(b, child)); }
[ "void", "addRightChild", "(", "final", "byte", "b", ",", "@", "NotNull", "final", "MutableNode", "child", ")", "{", "final", "ChildReference", "right", "=", "children", ".", "getRight", "(", ")", ";", "if", "(", "right", "!=", "null", "&&", "(", "right", ".", "firstByte", "&", "0xff", ")", ">=", "(", "b", "&", "0xff", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "children", ".", "putRight", "(", "new", "ChildReferenceMutable", "(", "b", ",", "child", ")", ")", ";", "}" ]
Adds child which is greater (i.e. its next byte greater) than any other. @param b next byte of child suffix. @param child child node.
[ "Adds", "child", "which", "is", "greater", "(", "i", ".", "e", ".", "its", "next", "byte", "greater", ")", "than", "any", "other", "." ]
train
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/patricia/MutableNode.java#L176-L182
dustin/java-memcached-client
src/main/java/net/spy/memcached/internal/OperationFuture.java
OperationFuture.getCas
public Long getCas() { if (cas == null) { try { get(); } catch (InterruptedException e) { status = new OperationStatus(false, "Interrupted", StatusCode.INTERRUPTED); } catch (ExecutionException e) { getLogger().warn("Error getting cas of operation", e); } } if (cas == null && status.isSuccess()) { throw new UnsupportedOperationException("This operation doesn't return" + "a cas value."); } return cas; }
java
public Long getCas() { if (cas == null) { try { get(); } catch (InterruptedException e) { status = new OperationStatus(false, "Interrupted", StatusCode.INTERRUPTED); } catch (ExecutionException e) { getLogger().warn("Error getting cas of operation", e); } } if (cas == null && status.isSuccess()) { throw new UnsupportedOperationException("This operation doesn't return" + "a cas value."); } return cas; }
[ "public", "Long", "getCas", "(", ")", "{", "if", "(", "cas", "==", "null", ")", "{", "try", "{", "get", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "status", "=", "new", "OperationStatus", "(", "false", ",", "\"Interrupted\"", ",", "StatusCode", ".", "INTERRUPTED", ")", ";", "}", "catch", "(", "ExecutionException", "e", ")", "{", "getLogger", "(", ")", ".", "warn", "(", "\"Error getting cas of operation\"", ",", "e", ")", ";", "}", "}", "if", "(", "cas", "==", "null", "&&", "status", ".", "isSuccess", "(", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"This operation doesn't return\"", "+", "\"a cas value.\"", ")", ";", "}", "return", "cas", ";", "}" ]
Get the CAS for this operation. The interrupted status of the current thread is cleared by this method. Inspect the returned OperationStatus to check whether an interruption has taken place. @throws UnsupportedOperationException If this is for an ASCII protocol configured client. @return the CAS for this operation or null if unsuccessful.
[ "Get", "the", "CAS", "for", "this", "operation", "." ]
train
https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/internal/OperationFuture.java#L218-L233
OpenLiberty/open-liberty
dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java
ZipFileArtifactNotifier.registerListener
private boolean registerListener(String newPath, ArtifactListenerSelector newListener) { boolean updatedCoveringPaths = addCoveringPath(newPath); Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath); if ( listenersForPath == null ) { // Each listeners collection is expected to be small. listenersForPath = new LinkedList<ArtifactListenerSelector>(); listeners.put(newPath, listenersForPath); } listenersForPath.add(newListener); return ( updatedCoveringPaths ); }
java
private boolean registerListener(String newPath, ArtifactListenerSelector newListener) { boolean updatedCoveringPaths = addCoveringPath(newPath); Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath); if ( listenersForPath == null ) { // Each listeners collection is expected to be small. listenersForPath = new LinkedList<ArtifactListenerSelector>(); listeners.put(newPath, listenersForPath); } listenersForPath.add(newListener); return ( updatedCoveringPaths ); }
[ "private", "boolean", "registerListener", "(", "String", "newPath", ",", "ArtifactListenerSelector", "newListener", ")", "{", "boolean", "updatedCoveringPaths", "=", "addCoveringPath", "(", "newPath", ")", ";", "Collection", "<", "ArtifactListenerSelector", ">", "listenersForPath", "=", "listeners", ".", "get", "(", "newPath", ")", ";", "if", "(", "listenersForPath", "==", "null", ")", "{", "// Each listeners collection is expected to be small.", "listenersForPath", "=", "new", "LinkedList", "<", "ArtifactListenerSelector", ">", "(", ")", ";", "listeners", ".", "put", "(", "newPath", ",", "listenersForPath", ")", ";", "}", "listenersForPath", ".", "add", "(", "newListener", ")", ";", "return", "(", "updatedCoveringPaths", ")", ";", "}" ]
Register a listener to a specified path. Registration has two effects: The listener is put into a table which maps the listener to specified path. The path of the listener are added to the covering paths collection, possibly causing newly covered paths to be removed from the collection. If the new path is already covered, the covering paths collection is not changed. @param newPath The path to which to register the listener. @param newListener The listener which is to be registered. @return True or false telling if the uncovered paths collection was updated.
[ "Register", "a", "listener", "to", "a", "specified", "path", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L465-L477
hyperledger/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java
NetworkConfig.createAllPeers
private void createAllPeers() throws NetworkConfigurationException { // Sanity checks if (peers != null) { throw new NetworkConfigurationException("INTERNAL ERROR: peers has already been initialized!"); } peers = new HashMap<>(); // peers is a JSON object containing a nested object for each peer JsonObject jsonPeers = getJsonObject(jsonConfig, "peers"); //out("Peers: " + (jsonPeers == null ? "null" : jsonPeers.toString())); if (jsonPeers != null) { for (Entry<String, JsonValue> entry : jsonPeers.entrySet()) { String peerName = entry.getKey(); JsonObject jsonPeer = getJsonValueAsObject(entry.getValue()); if (jsonPeer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName)); } Node peer = createNode(peerName, jsonPeer, "url"); if (peer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName)); } peers.put(peerName, peer); } } }
java
private void createAllPeers() throws NetworkConfigurationException { // Sanity checks if (peers != null) { throw new NetworkConfigurationException("INTERNAL ERROR: peers has already been initialized!"); } peers = new HashMap<>(); // peers is a JSON object containing a nested object for each peer JsonObject jsonPeers = getJsonObject(jsonConfig, "peers"); //out("Peers: " + (jsonPeers == null ? "null" : jsonPeers.toString())); if (jsonPeers != null) { for (Entry<String, JsonValue> entry : jsonPeers.entrySet()) { String peerName = entry.getKey(); JsonObject jsonPeer = getJsonValueAsObject(entry.getValue()); if (jsonPeer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName)); } Node peer = createNode(peerName, jsonPeer, "url"); if (peer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName)); } peers.put(peerName, peer); } } }
[ "private", "void", "createAllPeers", "(", ")", "throws", "NetworkConfigurationException", "{", "// Sanity checks", "if", "(", "peers", "!=", "null", ")", "{", "throw", "new", "NetworkConfigurationException", "(", "\"INTERNAL ERROR: peers has already been initialized!\"", ")", ";", "}", "peers", "=", "new", "HashMap", "<>", "(", ")", ";", "// peers is a JSON object containing a nested object for each peer", "JsonObject", "jsonPeers", "=", "getJsonObject", "(", "jsonConfig", ",", "\"peers\"", ")", ";", "//out(\"Peers: \" + (jsonPeers == null ? \"null\" : jsonPeers.toString()));", "if", "(", "jsonPeers", "!=", "null", ")", "{", "for", "(", "Entry", "<", "String", ",", "JsonValue", ">", "entry", ":", "jsonPeers", ".", "entrySet", "(", ")", ")", "{", "String", "peerName", "=", "entry", ".", "getKey", "(", ")", ";", "JsonObject", "jsonPeer", "=", "getJsonValueAsObject", "(", "entry", ".", "getValue", "(", ")", ")", ";", "if", "(", "jsonPeer", "==", "null", ")", "{", "throw", "new", "NetworkConfigurationException", "(", "format", "(", "\"Error loading config. Invalid peer entry: %s\"", ",", "peerName", ")", ")", ";", "}", "Node", "peer", "=", "createNode", "(", "peerName", ",", "jsonPeer", ",", "\"url\"", ")", ";", "if", "(", "peer", "==", "null", ")", "{", "throw", "new", "NetworkConfigurationException", "(", "format", "(", "\"Error loading config. Invalid peer entry: %s\"", ",", "peerName", ")", ")", ";", "}", "peers", ".", "put", "(", "peerName", ",", "peer", ")", ";", "}", "}", "}" ]
Creates Node instances representing all the peers defined in the config file
[ "Creates", "Node", "instances", "representing", "all", "the", "peers", "defined", "in", "the", "config", "file" ]
train
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java#L534-L566
openengsb/openengsb
connector/userprojectsldap/src/main/java/org/openengsb/connector/userprojects/ldap/internal/ldap/Utils.java
Utils.extractAttributeValueNoEmptyCheck
public static String extractAttributeValueNoEmptyCheck(Entry entry, String attributeType) { Attribute attribute = entry.get(attributeType); if (attribute == null) { return null; } try { return attribute.getString(); } catch (LdapInvalidAttributeValueException e) { throw new LdapRuntimeException(e); } }
java
public static String extractAttributeValueNoEmptyCheck(Entry entry, String attributeType) { Attribute attribute = entry.get(attributeType); if (attribute == null) { return null; } try { return attribute.getString(); } catch (LdapInvalidAttributeValueException e) { throw new LdapRuntimeException(e); } }
[ "public", "static", "String", "extractAttributeValueNoEmptyCheck", "(", "Entry", "entry", ",", "String", "attributeType", ")", "{", "Attribute", "attribute", "=", "entry", ".", "get", "(", "attributeType", ")", ";", "if", "(", "attribute", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "return", "attribute", ".", "getString", "(", ")", ";", "}", "catch", "(", "LdapInvalidAttributeValueException", "e", ")", "{", "throw", "new", "LdapRuntimeException", "(", "e", ")", ";", "}", "}" ]
Returns the value of the attribute of attributeType from entry.
[ "Returns", "the", "value", "of", "the", "attribute", "of", "attributeType", "from", "entry", "." ]
train
https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/connector/userprojectsldap/src/main/java/org/openengsb/connector/userprojects/ldap/internal/ldap/Utils.java#L55-L65
hortonworks/dstream
dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java
DStreamExecutionGraphBuilder.doBuild
@SuppressWarnings("rawtypes") private DStreamExecutionGraph doBuild(boolean isDependent){ this.invocationPipeline.getInvocations().forEach(this::addInvocation); if (this.requiresInitialSetOfOperations()){ this.createDefaultExtractOperation(); } if (this.requiresPostShuffleOperation(isDependent)){ SerFunction loadFunc = this.determineUnmapFunction(this.currentStreamOperation.getLastOperationName()); this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++, this.currentStreamOperation); this.currentStreamOperation.addStreamOperationFunction(Ops.load.name(), loadFunc); } DStreamOperation parent = this.currentStreamOperation; List<DStreamOperation> operationList = new ArrayList<>(); do { operationList.add(parent); parent = parent.getParent(); } while (parent != null); Collections.reverse(operationList); // DStreamExecutionGraph operations = new DStreamExecutionGraph( this.invocationPipeline.getSourceElementType(), this.invocationPipeline.getSourceIdentifier(), Collections.unmodifiableList(operationList)); return operations; }
java
@SuppressWarnings("rawtypes") private DStreamExecutionGraph doBuild(boolean isDependent){ this.invocationPipeline.getInvocations().forEach(this::addInvocation); if (this.requiresInitialSetOfOperations()){ this.createDefaultExtractOperation(); } if (this.requiresPostShuffleOperation(isDependent)){ SerFunction loadFunc = this.determineUnmapFunction(this.currentStreamOperation.getLastOperationName()); this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++, this.currentStreamOperation); this.currentStreamOperation.addStreamOperationFunction(Ops.load.name(), loadFunc); } DStreamOperation parent = this.currentStreamOperation; List<DStreamOperation> operationList = new ArrayList<>(); do { operationList.add(parent); parent = parent.getParent(); } while (parent != null); Collections.reverse(operationList); // DStreamExecutionGraph operations = new DStreamExecutionGraph( this.invocationPipeline.getSourceElementType(), this.invocationPipeline.getSourceIdentifier(), Collections.unmodifiableList(operationList)); return operations; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "private", "DStreamExecutionGraph", "doBuild", "(", "boolean", "isDependent", ")", "{", "this", ".", "invocationPipeline", ".", "getInvocations", "(", ")", ".", "forEach", "(", "this", "::", "addInvocation", ")", ";", "if", "(", "this", ".", "requiresInitialSetOfOperations", "(", ")", ")", "{", "this", ".", "createDefaultExtractOperation", "(", ")", ";", "}", "if", "(", "this", ".", "requiresPostShuffleOperation", "(", "isDependent", ")", ")", "{", "SerFunction", "loadFunc", "=", "this", ".", "determineUnmapFunction", "(", "this", ".", "currentStreamOperation", ".", "getLastOperationName", "(", ")", ")", ";", "this", ".", "currentStreamOperation", "=", "new", "DStreamOperation", "(", "this", ".", "operationIdCounter", "++", ",", "this", ".", "currentStreamOperation", ")", ";", "this", ".", "currentStreamOperation", ".", "addStreamOperationFunction", "(", "Ops", ".", "load", ".", "name", "(", ")", ",", "loadFunc", ")", ";", "}", "DStreamOperation", "parent", "=", "this", ".", "currentStreamOperation", ";", "List", "<", "DStreamOperation", ">", "operationList", "=", "new", "ArrayList", "<>", "(", ")", ";", "do", "{", "operationList", ".", "add", "(", "parent", ")", ";", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "}", "while", "(", "parent", "!=", "null", ")", ";", "Collections", ".", "reverse", "(", "operationList", ")", ";", "//\t", "DStreamExecutionGraph", "operations", "=", "new", "DStreamExecutionGraph", "(", "this", ".", "invocationPipeline", ".", "getSourceElementType", "(", ")", ",", "this", ".", "invocationPipeline", ".", "getSourceIdentifier", "(", ")", ",", "Collections", ".", "unmodifiableList", "(", "operationList", ")", ")", ";", "return", "operations", ";", "}" ]
The 'dependentStream' attribute implies that the DStreamOperations the methid is about to build is a dependency of another DStreamOperations (e.g., for cases such as Join, union etc.) Basically, each process should have at least two operations - 'read -> write' with shuffle in between. For cases where we are building a dependent operations the second operation is actually implicit (the operation that does the join, union etc.).
[ "The", "dependentStream", "attribute", "implies", "that", "the", "DStreamOperations", "the", "methid", "is", "about", "to", "build", "is", "a", "dependency", "of", "another", "DStreamOperations", "(", "e", ".", "g", ".", "for", "cases", "such", "as", "Join", "union", "etc", ".", ")", "Basically", "each", "process", "should", "have", "at", "least", "two", "operations", "-", "read", "-", ">", "write", "with", "shuffle", "in", "between", ".", "For", "cases", "where", "we", "are", "building", "a", "dependent", "operations", "the", "second", "operation", "is", "actually", "implicit", "(", "the", "operation", "that", "does", "the", "join", "union", "etc", ".", ")", "." ]
train
https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java#L89-L117
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java
Configurations.getBoolean
public static boolean getBoolean(String name, boolean defaultVal){ if(getConfiguration().containsKey(name)){ return getConfiguration().getBoolean(name); } else { return defaultVal; } }
java
public static boolean getBoolean(String name, boolean defaultVal){ if(getConfiguration().containsKey(name)){ return getConfiguration().getBoolean(name); } else { return defaultVal; } }
[ "public", "static", "boolean", "getBoolean", "(", "String", "name", ",", "boolean", "defaultVal", ")", "{", "if", "(", "getConfiguration", "(", ")", ".", "containsKey", "(", "name", ")", ")", "{", "return", "getConfiguration", "(", ")", ".", "getBoolean", "(", "name", ")", ";", "}", "else", "{", "return", "defaultVal", ";", "}", "}" ]
Get the property object as Boolean, or return defaultVal if property is not defined. @param name property name. @param defaultVal default property value. @return property value as boolean, return defaultVal if property is undefined.
[ "Get", "the", "property", "object", "as", "Boolean", "or", "return", "defaultVal", "if", "property", "is", "not", "defined", "." ]
train
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L140-L146
Alluxio/alluxio
core/server/master/src/main/java/alluxio/master/file/meta/MountTable.java
MountTable.delete
public boolean delete(Supplier<JournalContext> journalContext, AlluxioURI uri) { String path = uri.getPath(); LOG.info("Unmounting {}", path); if (path.equals(ROOT)) { LOG.warn("Cannot unmount the root mount point."); return false; } try (LockResource r = new LockResource(mWriteLock)) { if (mState.getMountTable().containsKey(path)) { // check if the path contains another nested mount point for (String mountPath : mState.getMountTable().keySet()) { try { if (PathUtils.hasPrefix(mountPath, path) && (!path.equals(mountPath))) { LOG.warn("The path to unmount {} contains another nested mountpoint {}", path, mountPath); return false; } } catch (InvalidPathException e) { LOG.warn("Invalid path {} encountered when checking for nested mount point", path); } } mUfsManager.removeMount(mState.getMountTable().get(path).getMountId()); mState.applyAndJournal(journalContext, DeleteMountPointEntry.newBuilder().setAlluxioPath(path).build()); return true; } LOG.warn("Mount point {} does not exist.", path); return false; } }
java
public boolean delete(Supplier<JournalContext> journalContext, AlluxioURI uri) { String path = uri.getPath(); LOG.info("Unmounting {}", path); if (path.equals(ROOT)) { LOG.warn("Cannot unmount the root mount point."); return false; } try (LockResource r = new LockResource(mWriteLock)) { if (mState.getMountTable().containsKey(path)) { // check if the path contains another nested mount point for (String mountPath : mState.getMountTable().keySet()) { try { if (PathUtils.hasPrefix(mountPath, path) && (!path.equals(mountPath))) { LOG.warn("The path to unmount {} contains another nested mountpoint {}", path, mountPath); return false; } } catch (InvalidPathException e) { LOG.warn("Invalid path {} encountered when checking for nested mount point", path); } } mUfsManager.removeMount(mState.getMountTable().get(path).getMountId()); mState.applyAndJournal(journalContext, DeleteMountPointEntry.newBuilder().setAlluxioPath(path).build()); return true; } LOG.warn("Mount point {} does not exist.", path); return false; } }
[ "public", "boolean", "delete", "(", "Supplier", "<", "JournalContext", ">", "journalContext", ",", "AlluxioURI", "uri", ")", "{", "String", "path", "=", "uri", ".", "getPath", "(", ")", ";", "LOG", ".", "info", "(", "\"Unmounting {}\"", ",", "path", ")", ";", "if", "(", "path", ".", "equals", "(", "ROOT", ")", ")", "{", "LOG", ".", "warn", "(", "\"Cannot unmount the root mount point.\"", ")", ";", "return", "false", ";", "}", "try", "(", "LockResource", "r", "=", "new", "LockResource", "(", "mWriteLock", ")", ")", "{", "if", "(", "mState", ".", "getMountTable", "(", ")", ".", "containsKey", "(", "path", ")", ")", "{", "// check if the path contains another nested mount point", "for", "(", "String", "mountPath", ":", "mState", ".", "getMountTable", "(", ")", ".", "keySet", "(", ")", ")", "{", "try", "{", "if", "(", "PathUtils", ".", "hasPrefix", "(", "mountPath", ",", "path", ")", "&&", "(", "!", "path", ".", "equals", "(", "mountPath", ")", ")", ")", "{", "LOG", ".", "warn", "(", "\"The path to unmount {} contains another nested mountpoint {}\"", ",", "path", ",", "mountPath", ")", ";", "return", "false", ";", "}", "}", "catch", "(", "InvalidPathException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Invalid path {} encountered when checking for nested mount point\"", ",", "path", ")", ";", "}", "}", "mUfsManager", ".", "removeMount", "(", "mState", ".", "getMountTable", "(", ")", ".", "get", "(", "path", ")", ".", "getMountId", "(", ")", ")", ";", "mState", ".", "applyAndJournal", "(", "journalContext", ",", "DeleteMountPointEntry", ".", "newBuilder", "(", ")", ".", "setAlluxioPath", "(", "path", ")", ".", "build", "(", ")", ")", ";", "return", "true", ";", "}", "LOG", ".", "warn", "(", "\"Mount point {} does not exist.\"", ",", "path", ")", ";", "return", "false", ";", "}", "}" ]
Unmounts the given Alluxio path. The path should match an existing mount point. @param journalContext journal context @param uri an Alluxio path URI @return whether the operation succeeded or not
[ "Unmounts", "the", "given", "Alluxio", "path", ".", "The", "path", "should", "match", "an", "existing", "mount", "point", "." ]
train
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MountTable.java#L157-L187
orbisgis/h2gis
h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java
JDBCUtilities.createEmptyTable
public static void createEmptyTable(Connection connection, String tableReference) throws SQLException { try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE "+ tableReference+ " ()"); } }
java
public static void createEmptyTable(Connection connection, String tableReference) throws SQLException { try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE "+ tableReference+ " ()"); } }
[ "public", "static", "void", "createEmptyTable", "(", "Connection", "connection", ",", "String", "tableReference", ")", "throws", "SQLException", "{", "try", "(", "Statement", "statement", "=", "connection", ".", "createStatement", "(", ")", ")", "{", "statement", ".", "execute", "(", "\"CREATE TABLE \"", "+", "tableReference", "+", "\" ()\"", ")", ";", "}", "}" ]
A method to create an empty table (no columns) @param connection Connection @param tableReference Table name @throws java.sql.SQLException
[ "A", "method", "to", "create", "an", "empty", "table", "(", "no", "columns", ")" ]
train
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java#L387-L391
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/MyHTTPUtils.java
MyHTTPUtils.getContent
public static String getContent(String stringUrl, Map<String, String> parameters, Proxy proxy) throws IOException { URL url = new URL(stringUrl); URLConnection conn; if (proxy != null) { conn = url.openConnection(proxy); } else { conn = url.openConnection(); } conn.setConnectTimeout(5000); // set connect timeout to 5 seconds conn.setReadTimeout(60000); // set read timeout to 60 seconds if (parameters != null) { for (Entry<String, String> entry : parameters.entrySet()) { conn.addRequestProperty(entry.getKey(), entry.getValue()); } } InputStream is = conn.getInputStream(); if ("gzip".equals(conn.getContentEncoding())) { is = new GZIPInputStream(is); } return MyStreamUtils.readContent(is); }
java
public static String getContent(String stringUrl, Map<String, String> parameters, Proxy proxy) throws IOException { URL url = new URL(stringUrl); URLConnection conn; if (proxy != null) { conn = url.openConnection(proxy); } else { conn = url.openConnection(); } conn.setConnectTimeout(5000); // set connect timeout to 5 seconds conn.setReadTimeout(60000); // set read timeout to 60 seconds if (parameters != null) { for (Entry<String, String> entry : parameters.entrySet()) { conn.addRequestProperty(entry.getKey(), entry.getValue()); } } InputStream is = conn.getInputStream(); if ("gzip".equals(conn.getContentEncoding())) { is = new GZIPInputStream(is); } return MyStreamUtils.readContent(is); }
[ "public", "static", "String", "getContent", "(", "String", "stringUrl", ",", "Map", "<", "String", ",", "String", ">", "parameters", ",", "Proxy", "proxy", ")", "throws", "IOException", "{", "URL", "url", "=", "new", "URL", "(", "stringUrl", ")", ";", "URLConnection", "conn", ";", "if", "(", "proxy", "!=", "null", ")", "{", "conn", "=", "url", ".", "openConnection", "(", "proxy", ")", ";", "}", "else", "{", "conn", "=", "url", ".", "openConnection", "(", ")", ";", "}", "conn", ".", "setConnectTimeout", "(", "5000", ")", ";", "// set connect timeout to 5 seconds", "conn", ".", "setReadTimeout", "(", "60000", ")", ";", "// set read timeout to 60 seconds", "if", "(", "parameters", "!=", "null", ")", "{", "for", "(", "Entry", "<", "String", ",", "String", ">", "entry", ":", "parameters", ".", "entrySet", "(", ")", ")", "{", "conn", ".", "addRequestProperty", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "InputStream", "is", "=", "conn", ".", "getInputStream", "(", ")", ";", "if", "(", "\"gzip\"", ".", "equals", "(", "conn", ".", "getContentEncoding", "(", ")", ")", ")", "{", "is", "=", "new", "GZIPInputStream", "(", "is", ")", ";", "}", "return", "MyStreamUtils", ".", "readContent", "(", "is", ")", ";", "}" ]
Get content for url/parameters/proxy @param stringUrl the URL to get @param parameters HTTP parameters to pass @param proxy Proxy to use @return content the response content @throws IOException I/O error happened
[ "Get", "content", "for", "url", "/", "parameters", "/", "proxy" ]
train
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/MyHTTPUtils.java#L96-L122
aws/aws-sdk-java
aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationRequest.java
CreateIntegrationRequest.withRequestTemplates
public CreateIntegrationRequest withRequestTemplates(java.util.Map<String, String> requestTemplates) { setRequestTemplates(requestTemplates); return this; }
java
public CreateIntegrationRequest withRequestTemplates(java.util.Map<String, String> requestTemplates) { setRequestTemplates(requestTemplates); return this; }
[ "public", "CreateIntegrationRequest", "withRequestTemplates", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "requestTemplates", ")", "{", "setRequestTemplates", "(", "requestTemplates", ")", ";", "return", "this", ";", "}" ]
<p> Represents a map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client. The content type value is the key in this map, and the template (as a String) is the value. </p> @param requestTemplates Represents a map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client. The content type value is the key in this map, and the template (as a String) is the value. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "Represents", "a", "map", "of", "Velocity", "templates", "that", "are", "applied", "on", "the", "request", "payload", "based", "on", "the", "value", "of", "the", "Content", "-", "Type", "header", "sent", "by", "the", "client", ".", "The", "content", "type", "value", "is", "the", "key", "in", "this", "map", "and", "the", "template", "(", "as", "a", "String", ")", "is", "the", "value", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationRequest.java#L1161-L1164
alkacon/opencms-core
src-gwt/org/opencms/ade/galleries/client/preview/CmsImageResourcePreview.java
CmsImageResourcePreview.getImageInfo
private void getImageInfo(final String resourcePath, final I_CmsSimpleCallback<CmsImageInfoBean> callback) { CmsRpcAction<CmsImageInfoBean> action = new CmsRpcAction<CmsImageInfoBean>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { start(0, true); A_CmsResourcePreview.getService().getImageInfo(resourcePath, getLocale(), this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override protected void onResponse(CmsImageInfoBean result) { stop(false); callback.execute(result); } }; action.execute(); }
java
private void getImageInfo(final String resourcePath, final I_CmsSimpleCallback<CmsImageInfoBean> callback) { CmsRpcAction<CmsImageInfoBean> action = new CmsRpcAction<CmsImageInfoBean>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { start(0, true); A_CmsResourcePreview.getService().getImageInfo(resourcePath, getLocale(), this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override protected void onResponse(CmsImageInfoBean result) { stop(false); callback.execute(result); } }; action.execute(); }
[ "private", "void", "getImageInfo", "(", "final", "String", "resourcePath", ",", "final", "I_CmsSimpleCallback", "<", "CmsImageInfoBean", ">", "callback", ")", "{", "CmsRpcAction", "<", "CmsImageInfoBean", ">", "action", "=", "new", "CmsRpcAction", "<", "CmsImageInfoBean", ">", "(", ")", "{", "/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()\n */", "@", "Override", "public", "void", "execute", "(", ")", "{", "start", "(", "0", ",", "true", ")", ";", "A_CmsResourcePreview", ".", "getService", "(", ")", ".", "getImageInfo", "(", "resourcePath", ",", "getLocale", "(", ")", ",", "this", ")", ";", "}", "/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)\n */", "@", "Override", "protected", "void", "onResponse", "(", "CmsImageInfoBean", "result", ")", "{", "stop", "(", "false", ")", ";", "callback", ".", "execute", "(", "result", ")", ";", "}", "}", ";", "action", ".", "execute", "(", ")", ";", "}" ]
Returns the image info bean for the given resource.<p> @param resourcePath the resource path @param callback the calback to execute
[ "Returns", "the", "image", "info", "bean", "for", "the", "given", "resource", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/preview/CmsImageResourcePreview.java#L324-L350
uber/rides-java-sdk
uber-core-oauth-client-adapter/src/main/java/com/uber/sdk/core/auth/OAuth2Credentials.java
OAuth2Credentials.clearCredential
public void clearCredential(String userId) throws AuthException { try { authorizationCodeFlow.getCredentialDataStore().delete(userId); } catch (IOException e) { throw new AuthException("Unable to clear credential.", e); } }
java
public void clearCredential(String userId) throws AuthException { try { authorizationCodeFlow.getCredentialDataStore().delete(userId); } catch (IOException e) { throw new AuthException("Unable to clear credential.", e); } }
[ "public", "void", "clearCredential", "(", "String", "userId", ")", "throws", "AuthException", "{", "try", "{", "authorizationCodeFlow", ".", "getCredentialDataStore", "(", ")", ".", "delete", "(", "userId", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AuthException", "(", "\"Unable to clear credential.\"", ",", "e", ")", ";", "}", "}" ]
Clears the credential for the user in the underlying (@link DateStore}. @throws AuthException If the credential could not be cleared.
[ "Clears", "the", "credential", "for", "the", "user", "in", "the", "underlying", "(" ]
train
https://github.com/uber/rides-java-sdk/blob/6c75570ab7884f8ecafaad312ef471dd33f64c42/uber-core-oauth-client-adapter/src/main/java/com/uber/sdk/core/auth/OAuth2Credentials.java#L287-L293
netscaler/nitro
src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java
base_resource.resource_to_string
protected String resource_to_string(nitro_service service, String id, options option) { Boolean warning = service.get_warning(); String onerror = service.get_onerror(); String result = service.get_payload_formatter().resource_to_string(this, id, option, warning, onerror); return result; }
java
protected String resource_to_string(nitro_service service, String id, options option) { Boolean warning = service.get_warning(); String onerror = service.get_onerror(); String result = service.get_payload_formatter().resource_to_string(this, id, option, warning, onerror); return result; }
[ "protected", "String", "resource_to_string", "(", "nitro_service", "service", ",", "String", "id", ",", "options", "option", ")", "{", "Boolean", "warning", "=", "service", ".", "get_warning", "(", ")", ";", "String", "onerror", "=", "service", ".", "get_onerror", "(", ")", ";", "String", "result", "=", "service", ".", "get_payload_formatter", "(", ")", ".", "resource_to_string", "(", "this", ",", "id", ",", "option", ",", "warning", ",", "onerror", ")", ";", "return", "result", ";", "}" ]
Converts netscaler resource to Json string. @param service nitro_service object. @param id sessionId. @param option Options object. @return string in Json format.
[ "Converts", "netscaler", "resource", "to", "Json", "string", "." ]
train
https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java#L65-L71
kamcpp/avicenna
src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java
Avicenna.defineDependency
public static <T> void defineDependency(Class<T> clazz, T dependency) { defineDependency(clazz, null, dependency); }
java
public static <T> void defineDependency(Class<T> clazz, T dependency) { defineDependency(clazz, null, dependency); }
[ "public", "static", "<", "T", ">", "void", "defineDependency", "(", "Class", "<", "T", ">", "clazz", ",", "T", "dependency", ")", "{", "defineDependency", "(", "clazz", ",", "null", ",", "dependency", ")", ";", "}" ]
Adds a direct mapping between a type and an object. @param clazz Class type which should be injected. @param dependency Dependency reference which should be copied to injection targets.
[ "Adds", "a", "direct", "mapping", "between", "a", "type", "and", "an", "object", "." ]
train
https://github.com/kamcpp/avicenna/blob/0fc4eff447761140cd3799287427d99c63ea6e6e/src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java#L145-L147
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java
ArabicShaping.flipArray
private static int flipArray(char [] dest, int start, int e, int w){ int r; if (w > start) { // shift, assume small buffer size so don't use arraycopy r = w; w = start; while (r < e) { dest[w++] = dest[r++]; } } else { w = e; } return w; }
java
private static int flipArray(char [] dest, int start, int e, int w){ int r; if (w > start) { // shift, assume small buffer size so don't use arraycopy r = w; w = start; while (r < e) { dest[w++] = dest[r++]; } } else { w = e; } return w; }
[ "private", "static", "int", "flipArray", "(", "char", "[", "]", "dest", ",", "int", "start", ",", "int", "e", ",", "int", "w", ")", "{", "int", "r", ";", "if", "(", "w", ">", "start", ")", "{", "// shift, assume small buffer size so don't use arraycopy", "r", "=", "w", ";", "w", "=", "start", ";", "while", "(", "r", "<", "e", ")", "{", "dest", "[", "w", "++", "]", "=", "dest", "[", "r", "++", "]", ";", "}", "}", "else", "{", "w", "=", "e", ";", "}", "return", "w", ";", "}" ]
/* Name : flipArray Function: inverts array, so that start becomes end and vice versa
[ "/", "*", "Name", ":", "flipArray", "Function", ":", "inverts", "array", "so", "that", "start", "becomes", "end", "and", "vice", "versa" ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L1183-L1196
twitter/hraven
hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java
AppSummaryService.getTimestamp
long getTimestamp(long runId, AggregationConstants.AGGREGATION_TYPE aggType) { if (AggregationConstants.AGGREGATION_TYPE.DAILY.equals(aggType)) { // get top of the hour long dayTimestamp = runId - (runId % Constants.MILLIS_ONE_DAY); return dayTimestamp; } else if (AggregationConstants.AGGREGATION_TYPE.WEEKLY.equals(aggType)) { // get top of the hour Calendar c = Calendar.getInstance(); c.setTimeInMillis(runId); int d = c.get(Calendar.DAY_OF_WEEK); // get the first day of the week long weekTimestamp = runId - (d - 1) * Constants.MILLIS_ONE_DAY; // get the top of the day for that first day weekTimestamp = weekTimestamp - weekTimestamp % Constants.MILLIS_ONE_DAY; return weekTimestamp; } return 0L; }
java
long getTimestamp(long runId, AggregationConstants.AGGREGATION_TYPE aggType) { if (AggregationConstants.AGGREGATION_TYPE.DAILY.equals(aggType)) { // get top of the hour long dayTimestamp = runId - (runId % Constants.MILLIS_ONE_DAY); return dayTimestamp; } else if (AggregationConstants.AGGREGATION_TYPE.WEEKLY.equals(aggType)) { // get top of the hour Calendar c = Calendar.getInstance(); c.setTimeInMillis(runId); int d = c.get(Calendar.DAY_OF_WEEK); // get the first day of the week long weekTimestamp = runId - (d - 1) * Constants.MILLIS_ONE_DAY; // get the top of the day for that first day weekTimestamp = weekTimestamp - weekTimestamp % Constants.MILLIS_ONE_DAY; return weekTimestamp; } return 0L; }
[ "long", "getTimestamp", "(", "long", "runId", ",", "AggregationConstants", ".", "AGGREGATION_TYPE", "aggType", ")", "{", "if", "(", "AggregationConstants", ".", "AGGREGATION_TYPE", ".", "DAILY", ".", "equals", "(", "aggType", ")", ")", "{", "// get top of the hour", "long", "dayTimestamp", "=", "runId", "-", "(", "runId", "%", "Constants", ".", "MILLIS_ONE_DAY", ")", ";", "return", "dayTimestamp", ";", "}", "else", "if", "(", "AggregationConstants", ".", "AGGREGATION_TYPE", ".", "WEEKLY", ".", "equals", "(", "aggType", ")", ")", "{", "// get top of the hour", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTimeInMillis", "(", "runId", ")", ";", "int", "d", "=", "c", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", ";", "// get the first day of the week", "long", "weekTimestamp", "=", "runId", "-", "(", "d", "-", "1", ")", "*", "Constants", ".", "MILLIS_ONE_DAY", ";", "// get the top of the day for that first day", "weekTimestamp", "=", "weekTimestamp", "-", "weekTimestamp", "%", "Constants", ".", "MILLIS_ONE_DAY", ";", "return", "weekTimestamp", ";", "}", "return", "0L", ";", "}" ]
find out the top of the day/week timestamp @param runId @return top of the day/week timestamp
[ "find", "out", "the", "top", "of", "the", "day", "/", "week", "timestamp" ]
train
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L366-L383
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java
PixelDepthLinearMetric.depth2View
public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) { DMatrixRMaj R = fromAtoB.getR(); Vector3D_F64 T = fromAtoB.getT(); GeometryMath_F64.multCrossA(b, R, temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, T, temp2); return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z); }
java
public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) { DMatrixRMaj R = fromAtoB.getR(); Vector3D_F64 T = fromAtoB.getT(); GeometryMath_F64.multCrossA(b, R, temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, T, temp2); return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z); }
[ "public", "double", "depth2View", "(", "Point2D_F64", "a", ",", "Point2D_F64", "b", ",", "Se3_F64", "fromAtoB", ")", "{", "DMatrixRMaj", "R", "=", "fromAtoB", ".", "getR", "(", ")", ";", "Vector3D_F64", "T", "=", "fromAtoB", ".", "getT", "(", ")", ";", "GeometryMath_F64", ".", "multCrossA", "(", "b", ",", "R", ",", "temp0", ")", ";", "GeometryMath_F64", ".", "mult", "(", "temp0", ",", "a", ",", "temp1", ")", ";", "GeometryMath_F64", ".", "cross", "(", "b", ",", "T", ",", "temp2", ")", ";", "return", "-", "(", "temp2", ".", "x", "+", "temp2", ".", "y", "+", "temp2", ".", "z", ")", "/", "(", "temp1", ".", "x", "+", "temp1", ".", "y", "+", "temp1", ".", "z", ")", ";", "}" ]
Computes pixel depth in image 'a' from two observations. @param a Observation in first frame. In calibrated coordinates. Not modified. @param b Observation in second frame. In calibrated coordinates. Not modified. @param fromAtoB Transform from frame a to frame b. @return Pixel depth in first frame. In same units as T inside of fromAtoB.
[ "Computes", "pixel", "depth", "in", "image", "a", "from", "two", "observations", "." ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java#L101-L112
salesforce/Argus
ArgusCore/src/main/java/com/salesforce/dva/argus/entity/JPAEntity.java
JPAEntity.findByPrimaryKey
public static <E extends Identifiable> E findByPrimaryKey(EntityManager em, BigInteger id, Class<E> type) { requireArgument(em != null, "The entity manager cannot be null."); requireArgument(id != null && id.compareTo(ZERO) > 0, "ID cannot be null and must be positive and non-zero"); requireArgument(type != null, "The entity type cannot be null."); TypedQuery<E> query = em.createNamedQuery("JPAEntity.findByPrimaryKey", type); query.setHint("javax.persistence.cache.storeMode", "REFRESH"); try { query.setParameter("id", id); query.setParameter("deleted", false); return query.getSingleResult(); } catch (NoResultException ex) { return null; } }
java
public static <E extends Identifiable> E findByPrimaryKey(EntityManager em, BigInteger id, Class<E> type) { requireArgument(em != null, "The entity manager cannot be null."); requireArgument(id != null && id.compareTo(ZERO) > 0, "ID cannot be null and must be positive and non-zero"); requireArgument(type != null, "The entity type cannot be null."); TypedQuery<E> query = em.createNamedQuery("JPAEntity.findByPrimaryKey", type); query.setHint("javax.persistence.cache.storeMode", "REFRESH"); try { query.setParameter("id", id); query.setParameter("deleted", false); return query.getSingleResult(); } catch (NoResultException ex) { return null; } }
[ "public", "static", "<", "E", "extends", "Identifiable", ">", "E", "findByPrimaryKey", "(", "EntityManager", "em", ",", "BigInteger", "id", ",", "Class", "<", "E", ">", "type", ")", "{", "requireArgument", "(", "em", "!=", "null", ",", "\"The entity manager cannot be null.\"", ")", ";", "requireArgument", "(", "id", "!=", "null", "&&", "id", ".", "compareTo", "(", "ZERO", ")", ">", "0", ",", "\"ID cannot be null and must be positive and non-zero\"", ")", ";", "requireArgument", "(", "type", "!=", "null", ",", "\"The entity type cannot be null.\"", ")", ";", "TypedQuery", "<", "E", ">", "query", "=", "em", ".", "createNamedQuery", "(", "\"JPAEntity.findByPrimaryKey\"", ",", "type", ")", ";", "query", ".", "setHint", "(", "\"javax.persistence.cache.storeMode\"", ",", "\"REFRESH\"", ")", ";", "try", "{", "query", ".", "setParameter", "(", "\"id\"", ",", "id", ")", ";", "query", ".", "setParameter", "(", "\"deleted\"", ",", "false", ")", ";", "return", "query", ".", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NoResultException", "ex", ")", "{", "return", "null", ";", "}", "}" ]
Finds a JPA entity by its primary key. @param <E> The JPA entity type. @param em The entity manager to use. Cannot be null. @param id The ID of the entity to find. Must be a positive, non-zero integer. @param type The runtime type to cast the result value to. @return The corresponding entity or null if no entity exists.
[ "Finds", "a", "JPA", "entity", "by", "its", "primary", "key", "." ]
train
https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/entity/JPAEntity.java#L181-L196
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java
TmdbMovies.getSimilarMovies
public ResultList<MovieInfo> getSimilarMovies(int movieId, Integer page, String language) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, movieId); parameters.add(Param.LANGUAGE, language); parameters.add(Param.PAGE, page); URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR).buildUrl(parameters); WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "similar movies"); return wrapper.getResultsList(); }
java
public ResultList<MovieInfo> getSimilarMovies(int movieId, Integer page, String language) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, movieId); parameters.add(Param.LANGUAGE, language); parameters.add(Param.PAGE, page); URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR).buildUrl(parameters); WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "similar movies"); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "MovieInfo", ">", "getSimilarMovies", "(", "int", "movieId", ",", "Integer", "page", ",", "String", "language", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "movieId", ")", ";", "parameters", ".", "add", "(", "Param", ".", "LANGUAGE", ",", "language", ")", ";", "parameters", ".", "add", "(", "Param", ".", "PAGE", ",", "page", ")", ";", "URL", "url", "=", "new", "ApiUrl", "(", "apiKey", ",", "MethodBase", ".", "MOVIE", ")", ".", "subMethod", "(", "MethodSub", ".", "SIMILAR", ")", ".", "buildUrl", "(", "parameters", ")", ";", "WrapperGenericList", "<", "MovieInfo", ">", "wrapper", "=", "processWrapper", "(", "getTypeReference", "(", "MovieInfo", ".", "class", ")", ",", "url", ",", "\"similar movies\"", ")", ";", "return", "wrapper", ".", "getResultsList", "(", ")", ";", "}" ]
The similar movies method will let you retrieve the similar movies for a particular movie. This data is created dynamically but with the help of users votes on TMDb. The data is much better with movies that have more keywords @param movieId @param language @param page @return @throws MovieDbException
[ "The", "similar", "movies", "method", "will", "let", "you", "retrieve", "the", "similar", "movies", "for", "a", "particular", "movie", "." ]
train
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java#L392-L401
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java
UrlEncoded.decodeTo
public static void decodeTo(String content, MultiMap<String> map, String charset) { decodeTo(content, map, charset == null ? null : Charset.forName(charset)); }
java
public static void decodeTo(String content, MultiMap<String> map, String charset) { decodeTo(content, map, charset == null ? null : Charset.forName(charset)); }
[ "public", "static", "void", "decodeTo", "(", "String", "content", ",", "MultiMap", "<", "String", ">", "map", ",", "String", "charset", ")", "{", "decodeTo", "(", "content", ",", "map", ",", "charset", "==", "null", "?", "null", ":", "Charset", ".", "forName", "(", "charset", ")", ")", ";", "}" ]
Decoded parameters to Map. @param content the string containing the encoded parameters @param map the MultiMap to put parsed query parameters into @param charset the charset to use for decoding
[ "Decoded", "parameters", "to", "Map", "." ]
train
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java#L175-L177
alkacon/opencms-core
src-modules/org/opencms/workplace/tools/content/CmsMergePages.java
CmsMergePages.reportList
private void reportList(List collected, boolean doReport) { int size = collected.size(); // now loop through all collected resources m_report.println( Messages.get().container(Messages.RPT_NUM_PAGES_1, new Integer(size)), I_CmsReport.FORMAT_HEADLINE); if (doReport) { int count = 1; Iterator i = collected.iterator(); while (i.hasNext()) { String resName = (String)i.next(); m_report.print( org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_SUCCESSION_2, String.valueOf(count++), String.valueOf(size)), I_CmsReport.FORMAT_NOTE); m_report.println(Messages.get().container(Messages.RPT_PROCESS_1, resName), I_CmsReport.FORMAT_NOTE); } } m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_END_0), I_CmsReport.FORMAT_HEADLINE); }
java
private void reportList(List collected, boolean doReport) { int size = collected.size(); // now loop through all collected resources m_report.println( Messages.get().container(Messages.RPT_NUM_PAGES_1, new Integer(size)), I_CmsReport.FORMAT_HEADLINE); if (doReport) { int count = 1; Iterator i = collected.iterator(); while (i.hasNext()) { String resName = (String)i.next(); m_report.print( org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_SUCCESSION_2, String.valueOf(count++), String.valueOf(size)), I_CmsReport.FORMAT_NOTE); m_report.println(Messages.get().container(Messages.RPT_PROCESS_1, resName), I_CmsReport.FORMAT_NOTE); } } m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_END_0), I_CmsReport.FORMAT_HEADLINE); }
[ "private", "void", "reportList", "(", "List", "collected", ",", "boolean", "doReport", ")", "{", "int", "size", "=", "collected", ".", "size", "(", ")", ";", "// now loop through all collected resources", "m_report", ".", "println", "(", "Messages", ".", "get", "(", ")", ".", "container", "(", "Messages", ".", "RPT_NUM_PAGES_1", ",", "new", "Integer", "(", "size", ")", ")", ",", "I_CmsReport", ".", "FORMAT_HEADLINE", ")", ";", "if", "(", "doReport", ")", "{", "int", "count", "=", "1", ";", "Iterator", "i", "=", "collected", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "String", "resName", "=", "(", "String", ")", "i", ".", "next", "(", ")", ";", "m_report", ".", "print", "(", "org", ".", "opencms", ".", "report", ".", "Messages", ".", "get", "(", ")", ".", "container", "(", "org", ".", "opencms", ".", "report", ".", "Messages", ".", "RPT_SUCCESSION_2", ",", "String", ".", "valueOf", "(", "count", "++", ")", ",", "String", ".", "valueOf", "(", "size", ")", ")", ",", "I_CmsReport", ".", "FORMAT_NOTE", ")", ";", "m_report", ".", "println", "(", "Messages", ".", "get", "(", ")", ".", "container", "(", "Messages", ".", "RPT_PROCESS_1", ",", "resName", ")", ",", "I_CmsReport", ".", "FORMAT_NOTE", ")", ";", "}", "}", "m_report", ".", "println", "(", "Messages", ".", "get", "(", ")", ".", "container", "(", "Messages", ".", "RPT_MERGE_PAGES_END_0", ")", ",", "I_CmsReport", ".", "FORMAT_HEADLINE", ")", ";", "}" ]
Creates a report list of all resources in one of the collected lists.<p> @param collected the list to create the output from @param doReport flag to enable detailed report
[ "Creates", "a", "report", "list", "of", "all", "resources", "in", "one", "of", "the", "collected", "lists", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/content/CmsMergePages.java#L751-L774
js-lib-com/dom
src/main/java/js/dom/w3c/DocumentBuilderImpl.java
DocumentBuilderImpl.getDocumentBuilder
private static javax.xml.parsers.DocumentBuilder getDocumentBuilder(Schema schema, boolean useNamespace) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringComments(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setCoalescing(true); if (schema != null) { // because schema is used throws fatal error if XML document contains DOCTYPE declaration dbf.setFeature(FEAT_DOCTYPE_DECL, true); // excerpt from document builder factory api: // Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, // it essentially just controls the DTD validation. // To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser // to be a non-validating parser by leaving the setValidating(boolean) method false, then use the setSchema(Schema) // method to associate a schema to a parser. dbf.setValidating(false); // XML schema validation requires namespace support dbf.setFeature(FEAT_SCHEMA_VALIDATION, true); dbf.setNamespaceAware(true); dbf.setSchema(schema); } else { // disable parser XML schema support; it is enabled by default dbf.setFeature(FEAT_SCHEMA_VALIDATION, false); dbf.setValidating(false); dbf.setNamespaceAware(useNamespace); } javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new EntityResolverImpl()); db.setErrorHandler(new ErrorHandlerImpl()); return db; }
java
private static javax.xml.parsers.DocumentBuilder getDocumentBuilder(Schema schema, boolean useNamespace) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringComments(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setCoalescing(true); if (schema != null) { // because schema is used throws fatal error if XML document contains DOCTYPE declaration dbf.setFeature(FEAT_DOCTYPE_DECL, true); // excerpt from document builder factory api: // Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, // it essentially just controls the DTD validation. // To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser // to be a non-validating parser by leaving the setValidating(boolean) method false, then use the setSchema(Schema) // method to associate a schema to a parser. dbf.setValidating(false); // XML schema validation requires namespace support dbf.setFeature(FEAT_SCHEMA_VALIDATION, true); dbf.setNamespaceAware(true); dbf.setSchema(schema); } else { // disable parser XML schema support; it is enabled by default dbf.setFeature(FEAT_SCHEMA_VALIDATION, false); dbf.setValidating(false); dbf.setNamespaceAware(useNamespace); } javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new EntityResolverImpl()); db.setErrorHandler(new ErrorHandlerImpl()); return db; }
[ "private", "static", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilder", "getDocumentBuilder", "(", "Schema", "schema", ",", "boolean", "useNamespace", ")", "throws", "ParserConfigurationException", "{", "DocumentBuilderFactory", "dbf", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "dbf", ".", "setIgnoringComments", "(", "true", ")", ";", "dbf", ".", "setIgnoringElementContentWhitespace", "(", "true", ")", ";", "dbf", ".", "setCoalescing", "(", "true", ")", ";", "if", "(", "schema", "!=", "null", ")", "{", "// because schema is used throws fatal error if XML document contains DOCTYPE declaration\r", "dbf", ".", "setFeature", "(", "FEAT_DOCTYPE_DECL", ",", "true", ")", ";", "// excerpt from document builder factory api:\r", "// Note that \"the validation\" here means a validating parser as defined in the XML recommendation. In other words,\r", "// it essentially just controls the DTD validation.\r", "// To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser\r", "// to be a non-validating parser by leaving the setValidating(boolean) method false, then use the setSchema(Schema)\r", "// method to associate a schema to a parser.\r", "dbf", ".", "setValidating", "(", "false", ")", ";", "// XML schema validation requires namespace support\r", "dbf", ".", "setFeature", "(", "FEAT_SCHEMA_VALIDATION", ",", "true", ")", ";", "dbf", ".", "setNamespaceAware", "(", "true", ")", ";", "dbf", ".", "setSchema", "(", "schema", ")", ";", "}", "else", "{", "// disable parser XML schema support; it is enabled by default\r", "dbf", ".", "setFeature", "(", "FEAT_SCHEMA_VALIDATION", ",", "false", ")", ";", "dbf", ".", "setValidating", "(", "false", ")", ";", "dbf", ".", "setNamespaceAware", "(", "useNamespace", ")", ";", "}", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilder", "db", "=", "dbf", ".", "newDocumentBuilder", "(", ")", ";", "db", ".", "setEntityResolver", "(", "new", "EntityResolverImpl", "(", ")", ")", ";", "db", ".", "setErrorHandler", "(", "new", "ErrorHandlerImpl", "(", ")", ")", ";", "return", "db", ";", "}" ]
Get XML document builder. @param schema XML schema, @param useNamespace flag to use name space. @return XML document builder. @throws ParserConfigurationException if document builder factory feature set fail.
[ "Get", "XML", "document", "builder", "." ]
train
https://github.com/js-lib-com/dom/blob/8c7cd7c802977f210674dec7c2a8f61e8de05b63/src/main/java/js/dom/w3c/DocumentBuilderImpl.java#L453-L486
carewebframework/carewebframework-core
org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/action/ActionUtil.java
ActionUtil.addAction
public static ActionListener addAction(BaseComponent component, IAction action) { return addAction(component, action, ClickEvent.TYPE); }
java
public static ActionListener addAction(BaseComponent component, IAction action) { return addAction(component, action, ClickEvent.TYPE); }
[ "public", "static", "ActionListener", "addAction", "(", "BaseComponent", "component", ",", "IAction", "action", ")", "{", "return", "addAction", "(", "component", ",", "action", ",", "ClickEvent", ".", "TYPE", ")", ";", "}" ]
Adds/removes an action listener to/from a component using the default click trigger event. @param component Component to be associated with the action. @param action Action to invoke when listener event is triggered. If null, dissociates the event listener from the component. @return The newly created action listener.
[ "Adds", "/", "removes", "an", "action", "listener", "to", "/", "from", "a", "component", "using", "the", "default", "click", "trigger", "event", "." ]
train
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/action/ActionUtil.java#L84-L86
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/WaveData.java
WaveData.convertAudioBytes
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.LITTLE_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) dest.put(src.get()); } dest.rewind(); return dest; }
java
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.LITTLE_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) dest.put(src.get()); } dest.rewind(); return dest; }
[ "private", "static", "ByteBuffer", "convertAudioBytes", "(", "byte", "[", "]", "audio_bytes", ",", "boolean", "two_bytes_data", ")", "{", "ByteBuffer", "dest", "=", "ByteBuffer", ".", "allocateDirect", "(", "audio_bytes", ".", "length", ")", ";", "dest", ".", "order", "(", "ByteOrder", ".", "nativeOrder", "(", ")", ")", ";", "ByteBuffer", "src", "=", "ByteBuffer", ".", "wrap", "(", "audio_bytes", ")", ";", "src", ".", "order", "(", "ByteOrder", ".", "LITTLE_ENDIAN", ")", ";", "if", "(", "two_bytes_data", ")", "{", "ShortBuffer", "dest_short", "=", "dest", ".", "asShortBuffer", "(", ")", ";", "ShortBuffer", "src_short", "=", "src", ".", "asShortBuffer", "(", ")", ";", "while", "(", "src_short", ".", "hasRemaining", "(", ")", ")", "dest_short", ".", "put", "(", "src_short", ".", "get", "(", ")", ")", ";", "}", "else", "{", "while", "(", "src", ".", "hasRemaining", "(", ")", ")", "dest", ".", "put", "(", "src", ".", "get", "(", ")", ")", ";", "}", "dest", ".", "rewind", "(", ")", ";", "return", "dest", ";", "}" ]
Convert the audio bytes into the stream @param audio_bytes The audio byts @param two_bytes_data True if we using double byte data @return The byte bufer of data
[ "Convert", "the", "audio", "bytes", "into", "the", "stream" ]
train
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/WaveData.java#L248-L264
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/RelationalJMapper.java
RelationalJMapper.addClasses
private void addClasses(Class<?>[] classes, HashSet<Class<?>> result){ if(isNull(classes) || classes.length==0) Error.globalClassesAbsent(configuredClass); for (Class<?> classe : classes) result.add(classe); }
java
private void addClasses(Class<?>[] classes, HashSet<Class<?>> result){ if(isNull(classes) || classes.length==0) Error.globalClassesAbsent(configuredClass); for (Class<?> classe : classes) result.add(classe); }
[ "private", "void", "addClasses", "(", "Class", "<", "?", ">", "[", "]", "classes", ",", "HashSet", "<", "Class", "<", "?", ">", ">", "result", ")", "{", "if", "(", "isNull", "(", "classes", ")", "||", "classes", ".", "length", "==", "0", ")", "Error", ".", "globalClassesAbsent", "(", "configuredClass", ")", ";", "for", "(", "Class", "<", "?", ">", "classe", ":", "classes", ")", "result", ".", "(", "classe", ")", ";", "}" ]
Adds to the result parameter all classes that aren't present in it @param classes classes to control @param result List to enrich
[ "Adds", "to", "the", "result", "parameter", "all", "classes", "that", "aren", "t", "present", "in", "it" ]
train
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/RelationalJMapper.java#L291-L297
jbundle/jbundle
base/db/client/src/main/java/org/jbundle/base/db/client/ClientTable.java
ClientTable.fieldsToData
public void fieldsToData(Rec record) throws DBException { try { int iFieldTypes = BaseBuffer.PHYSICAL_FIELDS; if (!((Record)record).isAllSelected()) iFieldTypes = BaseBuffer.DATA_FIELDS; //SELECTED_FIELDS; (Selected and physical) m_dataSource = new VectorBuffer(null, iFieldTypes); //x new StringBuff(); ((BaseBuffer)m_dataSource).fieldsToBuffer((FieldList)record); } catch (Exception ex) { throw DatabaseException.toDatabaseException(ex); } }
java
public void fieldsToData(Rec record) throws DBException { try { int iFieldTypes = BaseBuffer.PHYSICAL_FIELDS; if (!((Record)record).isAllSelected()) iFieldTypes = BaseBuffer.DATA_FIELDS; //SELECTED_FIELDS; (Selected and physical) m_dataSource = new VectorBuffer(null, iFieldTypes); //x new StringBuff(); ((BaseBuffer)m_dataSource).fieldsToBuffer((FieldList)record); } catch (Exception ex) { throw DatabaseException.toDatabaseException(ex); } }
[ "public", "void", "fieldsToData", "(", "Rec", "record", ")", "throws", "DBException", "{", "try", "{", "int", "iFieldTypes", "=", "BaseBuffer", ".", "PHYSICAL_FIELDS", ";", "if", "(", "!", "(", "(", "Record", ")", "record", ")", ".", "isAllSelected", "(", ")", ")", "iFieldTypes", "=", "BaseBuffer", ".", "DATA_FIELDS", ";", "//SELECTED_FIELDS; (Selected and physical)", "m_dataSource", "=", "new", "VectorBuffer", "(", "null", ",", "iFieldTypes", ")", ";", "//x new StringBuff();", "(", "(", "BaseBuffer", ")", "m_dataSource", ")", ".", "fieldsToBuffer", "(", "(", "FieldList", ")", "record", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "DatabaseException", ".", "toDatabaseException", "(", "ex", ")", ";", "}", "}" ]
Move all the fields to the output buffer. In this implementation, create a new VectorBuffer and move the fielddata to it. @exception DBException File exception.
[ "Move", "all", "the", "fields", "to", "the", "output", "buffer", ".", "In", "this", "implementation", "create", "a", "new", "VectorBuffer", "and", "move", "the", "fielddata", "to", "it", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/db/client/src/main/java/org/jbundle/base/db/client/ClientTable.java#L561-L572
ocelotds/ocelot
ocelot-processor/src/main/java/org/ocelotds/processors/visitors/AbstractDataServiceVisitor.java
AbstractDataServiceVisitor.browseAndWriteMethods
void browseAndWriteMethods(List<ExecutableElement> methodElements, String classname, Writer writer) throws IOException { Collection<String> methodProceeds = new ArrayList<>(); boolean first = true; for (ExecutableElement methodElement : methodElements) { if (isConsiderateMethod(methodProceeds, methodElement)) { if(!first) { writer.append(COMMA).append(CR); } visitMethodElement(classname, methodElement, writer); first = false; } } }
java
void browseAndWriteMethods(List<ExecutableElement> methodElements, String classname, Writer writer) throws IOException { Collection<String> methodProceeds = new ArrayList<>(); boolean first = true; for (ExecutableElement methodElement : methodElements) { if (isConsiderateMethod(methodProceeds, methodElement)) { if(!first) { writer.append(COMMA).append(CR); } visitMethodElement(classname, methodElement, writer); first = false; } } }
[ "void", "browseAndWriteMethods", "(", "List", "<", "ExecutableElement", ">", "methodElements", ",", "String", "classname", ",", "Writer", "writer", ")", "throws", "IOException", "{", "Collection", "<", "String", ">", "methodProceeds", "=", "new", "ArrayList", "<>", "(", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "ExecutableElement", "methodElement", ":", "methodElements", ")", "{", "if", "(", "isConsiderateMethod", "(", "methodProceeds", ",", "methodElement", ")", ")", "{", "if", "(", "!", "first", ")", "{", "writer", ".", "append", "(", "COMMA", ")", ".", "append", "(", "CR", ")", ";", "}", "visitMethodElement", "(", "classname", ",", "methodElement", ",", "writer", ")", ";", "first", "=", "false", ";", "}", "}", "}" ]
browse valid methods and write equivalent js methods in writer @param methodElements @param classname @param writer @return @throws IOException
[ "browse", "valid", "methods", "and", "write", "equivalent", "js", "methods", "in", "writer" ]
train
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/processors/visitors/AbstractDataServiceVisitor.java#L133-L145
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_bluecatvpx_image.java
xen_bluecatvpx_image.get_nitro_bulk_response
protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception { xen_bluecatvpx_image_responses result = (xen_bluecatvpx_image_responses) service.get_payload_formatter().string_to_resource(xen_bluecatvpx_image_responses.class, response); if(result.errorcode != 0) { if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session(); throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_bluecatvpx_image_response_array); } xen_bluecatvpx_image[] result_xen_bluecatvpx_image = new xen_bluecatvpx_image[result.xen_bluecatvpx_image_response_array.length]; for(int i = 0; i < result.xen_bluecatvpx_image_response_array.length; i++) { result_xen_bluecatvpx_image[i] = result.xen_bluecatvpx_image_response_array[i].xen_bluecatvpx_image[0]; } return result_xen_bluecatvpx_image; }
java
protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception { xen_bluecatvpx_image_responses result = (xen_bluecatvpx_image_responses) service.get_payload_formatter().string_to_resource(xen_bluecatvpx_image_responses.class, response); if(result.errorcode != 0) { if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session(); throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_bluecatvpx_image_response_array); } xen_bluecatvpx_image[] result_xen_bluecatvpx_image = new xen_bluecatvpx_image[result.xen_bluecatvpx_image_response_array.length]; for(int i = 0; i < result.xen_bluecatvpx_image_response_array.length; i++) { result_xen_bluecatvpx_image[i] = result.xen_bluecatvpx_image_response_array[i].xen_bluecatvpx_image[0]; } return result_xen_bluecatvpx_image; }
[ "protected", "base_resource", "[", "]", "get_nitro_bulk_response", "(", "nitro_service", "service", ",", "String", "response", ")", "throws", "Exception", "{", "xen_bluecatvpx_image_responses", "result", "=", "(", "xen_bluecatvpx_image_responses", ")", "service", ".", "get_payload_formatter", "(", ")", ".", "string_to_resource", "(", "xen_bluecatvpx_image_responses", ".", "class", ",", "response", ")", ";", "if", "(", "result", ".", "errorcode", "!=", "0", ")", "{", "if", "(", "result", ".", "errorcode", "==", "SESSION_NOT_EXISTS", ")", "service", ".", "clear_session", "(", ")", ";", "throw", "new", "nitro_exception", "(", "result", ".", "message", ",", "result", ".", "errorcode", ",", "(", "base_response", "[", "]", ")", "result", ".", "xen_bluecatvpx_image_response_array", ")", ";", "}", "xen_bluecatvpx_image", "[", "]", "result_xen_bluecatvpx_image", "=", "new", "xen_bluecatvpx_image", "[", "result", ".", "xen_bluecatvpx_image_response_array", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "xen_bluecatvpx_image_response_array", ".", "length", ";", "i", "++", ")", "{", "result_xen_bluecatvpx_image", "[", "i", "]", "=", "result", ".", "xen_bluecatvpx_image_response_array", "[", "i", "]", ".", "xen_bluecatvpx_image", "[", "0", "]", ";", "}", "return", "result_xen_bluecatvpx_image", ";", "}" ]
<pre> Converts API response of bulk operation into object and returns the object array in case of get request. </pre>
[ "<pre", ">", "Converts", "API", "response", "of", "bulk", "operation", "into", "object", "and", "returns", "the", "object", "array", "in", "case", "of", "get", "request", ".", "<", "/", "pre", ">" ]
train
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_bluecatvpx_image.java#L264-L281
josesamuel/remoter
remoter/src/main/java/remoter/compiler/builder/BindingManager.java
BindingManager.getClassBuilder
private ClassBuilder getClassBuilder(Element element) { ClassBuilder classBuilder = new ClassBuilder(messager, element); classBuilder.setBindingManager(this); return classBuilder; }
java
private ClassBuilder getClassBuilder(Element element) { ClassBuilder classBuilder = new ClassBuilder(messager, element); classBuilder.setBindingManager(this); return classBuilder; }
[ "private", "ClassBuilder", "getClassBuilder", "(", "Element", "element", ")", "{", "ClassBuilder", "classBuilder", "=", "new", "ClassBuilder", "(", "messager", ",", "element", ")", ";", "classBuilder", ".", "setBindingManager", "(", "this", ")", ";", "return", "classBuilder", ";", "}" ]
Returns the {@link ClassBuilder} that generates the Builder for the Proxy and Stub classes
[ "Returns", "the", "{" ]
train
https://github.com/josesamuel/remoter/blob/007401868c319740d40134ebc07c3406988f9a86/remoter/src/main/java/remoter/compiler/builder/BindingManager.java#L112-L116
osglworks/java-tool
src/main/java/org/osgl/util/E.java
E.invalidRangeIfNot
public static void invalidRangeIfNot(boolean tester, String msg, Object... args) { if (!tester) { throw new InvalidRangeException(msg, args); } }
java
public static void invalidRangeIfNot(boolean tester, String msg, Object... args) { if (!tester) { throw new InvalidRangeException(msg, args); } }
[ "public", "static", "void", "invalidRangeIfNot", "(", "boolean", "tester", ",", "String", "msg", ",", "Object", "...", "args", ")", "{", "if", "(", "!", "tester", ")", "{", "throw", "new", "InvalidRangeException", "(", "msg", ",", "args", ")", ";", "}", "}" ]
Throws out an {@link InvalidRangeException} with error message specified when `tester` is `false`. @param tester when `false` then throw out the exception @param msg the error message format pattern. @param args the error message format arguments.
[ "Throws", "out", "an", "{", "@link", "InvalidRangeException", "}", "with", "error", "message", "specified", "when", "tester", "is", "false", "." ]
train
https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/util/E.java#L498-L502
alkacon/opencms-core
src/org/opencms/ade/configuration/CmsADEConfigData.java
CmsADEConfigData.getFormattersFromSchema
protected CmsFormatterConfiguration getFormattersFromSchema(CmsObject cms, CmsResource res) { try { return OpenCms.getResourceManager().getResourceType(res.getTypeId()).getFormattersForResource(cms, res); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); return CmsFormatterConfiguration.EMPTY_CONFIGURATION; } }
java
protected CmsFormatterConfiguration getFormattersFromSchema(CmsObject cms, CmsResource res) { try { return OpenCms.getResourceManager().getResourceType(res.getTypeId()).getFormattersForResource(cms, res); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); return CmsFormatterConfiguration.EMPTY_CONFIGURATION; } }
[ "protected", "CmsFormatterConfiguration", "getFormattersFromSchema", "(", "CmsObject", "cms", ",", "CmsResource", "res", ")", "{", "try", "{", "return", "OpenCms", ".", "getResourceManager", "(", ")", ".", "getResourceType", "(", "res", ".", "getTypeId", "(", ")", ")", ".", "getFormattersForResource", "(", "cms", ",", "res", ")", ";", "}", "catch", "(", "CmsException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "return", "CmsFormatterConfiguration", ".", "EMPTY_CONFIGURATION", ";", "}", "}" ]
Gets the formatters from the schema.<p> @param cms the current CMS context @param res the resource for which the formatters should be retrieved @return the formatters from the schema
[ "Gets", "the", "formatters", "from", "the", "schema", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEConfigData.java#L1116-L1124
OpenLiberty/open-liberty
dev/com.ibm.ws.anno/src/com/ibm/ws/anno/info/internal/ClassInfoCache.java
ClassInfoCache.getArrayClassInfo
public ArrayClassInfo getArrayClassInfo(String typeClassName, Type arrayType) { ClassInfoImpl elementClassInfo = getDelayableClassInfo(arrayType.getElementType()); return new ArrayClassInfo(typeClassName, elementClassInfo); }
java
public ArrayClassInfo getArrayClassInfo(String typeClassName, Type arrayType) { ClassInfoImpl elementClassInfo = getDelayableClassInfo(arrayType.getElementType()); return new ArrayClassInfo(typeClassName, elementClassInfo); }
[ "public", "ArrayClassInfo", "getArrayClassInfo", "(", "String", "typeClassName", ",", "Type", "arrayType", ")", "{", "ClassInfoImpl", "elementClassInfo", "=", "getDelayableClassInfo", "(", "arrayType", ".", "getElementType", "(", ")", ")", ";", "return", "new", "ArrayClassInfo", "(", "typeClassName", ",", "elementClassInfo", ")", ";", "}" ]
Note that this will recurse as long as the element type is still an array type.
[ "Note", "that", "this", "will", "recurse", "as", "long", "as", "the", "element", "type", "is", "still", "an", "array", "type", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.anno/src/com/ibm/ws/anno/info/internal/ClassInfoCache.java#L394-L398
Codearte/catch-exception
catch-throwable/src/main/java/com/googlecode/catchexception/throwable/CatchThrowable.java
CatchThrowable.catchThrowable
public static void catchThrowable(ThrowingCallable actor, Class<? extends Throwable> clazz) { validateArguments(actor, clazz); catchThrowable(actor, clazz, false); }
java
public static void catchThrowable(ThrowingCallable actor, Class<? extends Throwable> clazz) { validateArguments(actor, clazz); catchThrowable(actor, clazz, false); }
[ "public", "static", "void", "catchThrowable", "(", "ThrowingCallable", "actor", ",", "Class", "<", "?", "extends", "Throwable", ">", "clazz", ")", "{", "validateArguments", "(", "actor", ",", "clazz", ")", ";", "catchThrowable", "(", "actor", ",", "clazz", ",", "false", ")", ";", "}" ]
Use it to catch an throwable of a specific type and to get access to the thrown throwable (for further verifications). In the following example you catch throwables of type MyThrowable that are thrown by obj.doX(): <code>catchThrowable(obj, MyThrowable.class).doX(); // catch if (caughtThrowable() != null) { assert "foobar".equals(caughtThrowable().getMessage()); // further analysis }</code> If <code>doX()</code> throws a <code>MyThrowable</code>, then {@link #caughtThrowable()} will return the caught throwable. If <code>doX()</code> does not throw a <code>MyThrowable</code>, then {@link #caughtThrowable()} will return <code>null</code>. If <code>doX()</code> throws an throwable of another type, i.e. not a subclass but another class, then this throwable is not thrown and {@link #caughtThrowable()} will return <code>null</code>. @param actor The instance that shall be proxied. Must not be <code>null</code>. @param clazz The type of the throwable that shall be caught. Must not be <code>null</code>.
[ "Use", "it", "to", "catch", "an", "throwable", "of", "a", "specific", "type", "and", "to", "get", "access", "to", "the", "thrown", "throwable", "(", "for", "further", "verifications", ")", "." ]
train
https://github.com/Codearte/catch-exception/blob/8cfb1c0a68661ef622011484ff0061b41796b165/catch-throwable/src/main/java/com/googlecode/catchexception/throwable/CatchThrowable.java#L121-L124
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.incrementCounter
public void incrementCounter(BugChecker bugChecker, String key, int count) { statisticsCollector.incrementCounter(statsKey(bugChecker.canonicalName() + "-" + key), count); }
java
public void incrementCounter(BugChecker bugChecker, String key, int count) { statisticsCollector.incrementCounter(statsKey(bugChecker.canonicalName() + "-" + key), count); }
[ "public", "void", "incrementCounter", "(", "BugChecker", "bugChecker", ",", "String", "key", ",", "int", "count", ")", "{", "statisticsCollector", ".", "incrementCounter", "(", "statsKey", "(", "bugChecker", ".", "canonicalName", "(", ")", "+", "\"-\"", "+", "key", ")", ",", "count", ")", ";", "}" ]
Increment the counter for a combination of {@code bugChecker}'s canonical name and {@code key} by {@code count}. <p>e.g.: a key of {@code foo} becomes {@code FooChecker-foo}.
[ "Increment", "the", "counter", "for", "a", "combination", "of", "{", "@code", "bugChecker", "}", "s", "canonical", "name", "and", "{", "@code", "key", "}", "by", "{", "@code", "count", "}", "." ]
train
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L305-L307
gosu-lang/gosu-lang
gosu-core-api/src/main/java/gw/lang/init/ModuleFileUtil.java
ModuleFileUtil.createPathEntryForModuleFile
public static GosuPathEntry createPathEntryForModuleFile(IFile moduleFile) { try { InputStream is = moduleFile.openInputStream(); try { SimpleXmlNode moduleNode = SimpleXmlNode.parse(is); IDirectory rootDir = moduleFile.getParent(); List<IDirectory> sourceDirs = new ArrayList<IDirectory>(); for (String child : new String[] { "gsrc", "gtest" }) { IDirectory dir = rootDir.dir(child); if (dir.exists()) { sourceDirs.add(dir); } } return new GosuPathEntry(rootDir, sourceDirs); } finally { is.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
java
public static GosuPathEntry createPathEntryForModuleFile(IFile moduleFile) { try { InputStream is = moduleFile.openInputStream(); try { SimpleXmlNode moduleNode = SimpleXmlNode.parse(is); IDirectory rootDir = moduleFile.getParent(); List<IDirectory> sourceDirs = new ArrayList<IDirectory>(); for (String child : new String[] { "gsrc", "gtest" }) { IDirectory dir = rootDir.dir(child); if (dir.exists()) { sourceDirs.add(dir); } } return new GosuPathEntry(rootDir, sourceDirs); } finally { is.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "GosuPathEntry", "createPathEntryForModuleFile", "(", "IFile", "moduleFile", ")", "{", "try", "{", "InputStream", "is", "=", "moduleFile", ".", "openInputStream", "(", ")", ";", "try", "{", "SimpleXmlNode", "moduleNode", "=", "SimpleXmlNode", ".", "parse", "(", "is", ")", ";", "IDirectory", "rootDir", "=", "moduleFile", ".", "getParent", "(", ")", ";", "List", "<", "IDirectory", ">", "sourceDirs", "=", "new", "ArrayList", "<", "IDirectory", ">", "(", ")", ";", "for", "(", "String", "child", ":", "new", "String", "[", "]", "{", "\"gsrc\"", ",", "\"gtest\"", "}", ")", "{", "IDirectory", "dir", "=", "rootDir", ".", "dir", "(", "child", ")", ";", "if", "(", "dir", ".", "exists", "(", ")", ")", "{", "sourceDirs", ".", "add", "(", "dir", ")", ";", "}", "}", "return", "new", "GosuPathEntry", "(", "rootDir", ",", "sourceDirs", ")", ";", "}", "finally", "{", "is", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Reads a pom.xml file into a GosuPathEntry object @param moduleFile the pom.xml file to convert to GosuPathEntry @return an ordered list of GosuPathEntries created based on the algorithm described above
[ "Reads", "a", "pom", ".", "xml", "file", "into", "a", "GosuPathEntry", "object" ]
train
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/init/ModuleFileUtil.java#L26-L47
jenkinsci/jenkins
core/src/main/java/hudson/model/Descriptor.java
Descriptor.calcFillSettings
public void calcFillSettings(String field, Map<String,Object> attributes) { String capitalizedFieldName = StringUtils.capitalize(field); String methodName = "doFill" + capitalizedFieldName + "Items"; Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName); if(method==null) throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName)); // build query parameter line by figuring out what should be submitted List<String> depends = buildFillDependencies(method, new ArrayList<>()); if (!depends.isEmpty()) attributes.put("fillDependsOn",Util.join(depends," ")); attributes.put("fillUrl", String.format("%s/%s/fill%sItems", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName)); }
java
public void calcFillSettings(String field, Map<String,Object> attributes) { String capitalizedFieldName = StringUtils.capitalize(field); String methodName = "doFill" + capitalizedFieldName + "Items"; Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName); if(method==null) throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName)); // build query parameter line by figuring out what should be submitted List<String> depends = buildFillDependencies(method, new ArrayList<>()); if (!depends.isEmpty()) attributes.put("fillDependsOn",Util.join(depends," ")); attributes.put("fillUrl", String.format("%s/%s/fill%sItems", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName)); }
[ "public", "void", "calcFillSettings", "(", "String", "field", ",", "Map", "<", "String", ",", "Object", ">", "attributes", ")", "{", "String", "capitalizedFieldName", "=", "StringUtils", ".", "capitalize", "(", "field", ")", ";", "String", "methodName", "=", "\"doFill\"", "+", "capitalizedFieldName", "+", "\"Items\"", ";", "Method", "method", "=", "ReflectionUtils", ".", "getPublicMethodNamed", "(", "getClass", "(", ")", ",", "methodName", ")", ";", "if", "(", "method", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"%s doesn't have the %s method for filling a drop-down list\"", ",", "getClass", "(", ")", ",", "methodName", ")", ")", ";", "// build query parameter line by figuring out what should be submitted", "List", "<", "String", ">", "depends", "=", "buildFillDependencies", "(", "method", ",", "new", "ArrayList", "<>", "(", ")", ")", ";", "if", "(", "!", "depends", ".", "isEmpty", "(", ")", ")", "attributes", ".", "put", "(", "\"fillDependsOn\"", ",", "Util", ".", "join", "(", "depends", ",", "\" \"", ")", ")", ";", "attributes", ".", "put", "(", "\"fillUrl\"", ",", "String", ".", "format", "(", "\"%s/%s/fill%sItems\"", ",", "getCurrentDescriptorByNameUrl", "(", ")", ",", "getDescriptorUrl", "(", ")", ",", "capitalizedFieldName", ")", ")", ";", "}" ]
Computes the list of other form fields that the given field depends on, via the doFillXyzItems method, and sets that as the 'fillDependsOn' attribute. Also computes the URL of the doFillXyzItems and sets that as the 'fillUrl' attribute.
[ "Computes", "the", "list", "of", "other", "form", "fields", "that", "the", "given", "field", "depends", "on", "via", "the", "doFillXyzItems", "method", "and", "sets", "that", "as", "the", "fillDependsOn", "attribute", ".", "Also", "computes", "the", "URL", "of", "the", "doFillXyzItems", "and", "sets", "that", "as", "the", "fillUrl", "attribute", "." ]
train
https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/Descriptor.java#L411-L424
abel533/Mapper
core/src/main/java/tk/mybatis/mapper/genid/GenIdUtil.java
GenIdUtil.genId
public static void genId(Object target, String property, Class<? extends GenId> genClass, String table, String column) throws MapperException { try { GenId genId; if (CACHE.containsKey(genClass)) { genId = CACHE.get(genClass); } else { LOCK.lock(); try { if (!CACHE.containsKey(genClass)) { CACHE.put(genClass, genClass.newInstance()); } genId = CACHE.get(genClass); } finally { LOCK.unlock(); } } MetaObject metaObject = MetaObjectUtil.forObject(target); if (metaObject.getValue(property) == null) { Object id = genId.genId(table, column); metaObject.setValue(property, id); } } catch (Exception e) { throw new MapperException("生成 ID 失败!", e); } }
java
public static void genId(Object target, String property, Class<? extends GenId> genClass, String table, String column) throws MapperException { try { GenId genId; if (CACHE.containsKey(genClass)) { genId = CACHE.get(genClass); } else { LOCK.lock(); try { if (!CACHE.containsKey(genClass)) { CACHE.put(genClass, genClass.newInstance()); } genId = CACHE.get(genClass); } finally { LOCK.unlock(); } } MetaObject metaObject = MetaObjectUtil.forObject(target); if (metaObject.getValue(property) == null) { Object id = genId.genId(table, column); metaObject.setValue(property, id); } } catch (Exception e) { throw new MapperException("生成 ID 失败!", e); } }
[ "public", "static", "void", "genId", "(", "Object", "target", ",", "String", "property", ",", "Class", "<", "?", "extends", "GenId", ">", "genClass", ",", "String", "table", ",", "String", "column", ")", "throws", "MapperException", "{", "try", "{", "GenId", "genId", ";", "if", "(", "CACHE", ".", "containsKey", "(", "genClass", ")", ")", "{", "genId", "=", "CACHE", ".", "get", "(", "genClass", ")", ";", "}", "else", "{", "LOCK", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "!", "CACHE", ".", "containsKey", "(", "genClass", ")", ")", "{", "CACHE", ".", "put", "(", "genClass", ",", "genClass", ".", "newInstance", "(", ")", ")", ";", "}", "genId", "=", "CACHE", ".", "get", "(", "genClass", ")", ";", "}", "finally", "{", "LOCK", ".", "unlock", "(", ")", ";", "}", "}", "MetaObject", "metaObject", "=", "MetaObjectUtil", ".", "forObject", "(", "target", ")", ";", "if", "(", "metaObject", ".", "getValue", "(", "property", ")", "==", "null", ")", "{", "Object", "id", "=", "genId", ".", "genId", "(", "table", ",", "column", ")", ";", "metaObject", ".", "setValue", "(", "property", ",", "id", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MapperException", "(", "\"生成 ID 失败!\", e);", "", "", "", "", "}", "}" ]
生成 Id @param target @param property @param genClass @param table @param column @throws MapperException
[ "生成", "Id" ]
train
https://github.com/abel533/Mapper/blob/45c3d716583cba3680e03f1f6790fab5e1f4f668/core/src/main/java/tk/mybatis/mapper/genid/GenIdUtil.java#L55-L79
ziccardi/jnrpe
jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java
PluginRepositoryUtil.getAttributeValue
private static String getAttributeValue(final Element element, final String attributeName, final boolean mandatory) throws PluginConfigurationException { String returnValue = element.attributeValue(attributeName); if (mandatory) { if (StringUtils.isBlank(returnValue)) { throw new PluginConfigurationException("Error loading plugin package : mandatory attribute " + attributeName + " not found"); } } return returnValue; }
java
private static String getAttributeValue(final Element element, final String attributeName, final boolean mandatory) throws PluginConfigurationException { String returnValue = element.attributeValue(attributeName); if (mandatory) { if (StringUtils.isBlank(returnValue)) { throw new PluginConfigurationException("Error loading plugin package : mandatory attribute " + attributeName + " not found"); } } return returnValue; }
[ "private", "static", "String", "getAttributeValue", "(", "final", "Element", "element", ",", "final", "String", "attributeName", ",", "final", "boolean", "mandatory", ")", "throws", "PluginConfigurationException", "{", "String", "returnValue", "=", "element", ".", "attributeValue", "(", "attributeName", ")", ";", "if", "(", "mandatory", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "returnValue", ")", ")", "{", "throw", "new", "PluginConfigurationException", "(", "\"Error loading plugin package : mandatory attribute \"", "+", "attributeName", "+", "\" not found\"", ")", ";", "}", "}", "return", "returnValue", ";", "}" ]
Returns the value of the given attribute name of element. If mandatory is <code>true</code> and the attribute is blank or null, an exception is thrown. @param element The element whose attribute must be read @param attributeName The attribute name @param mandatory <code>true</code> if the attribute is mandatory @return the attribute value * @throws PluginConfigurationException if the attribute can't be found or is blank
[ "Returns", "the", "value", "of", "the", "given", "attribute", "name", "of", "element", ".", "If", "mandatory", "is", "<code", ">", "true<", "/", "code", ">", "and", "the", "attribute", "is", "blank", "or", "null", "an", "exception", "is", "thrown", "." ]
train
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L162-L174
OpenLiberty/open-liberty
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java
CacheOnDisk.writeDependencyEntry
public int writeDependencyEntry(Object id, Object entry) { // SKS-O int returnCode = htod.writeDependencyEntry(id, entry); if (returnCode == HTODDynacache.DISK_EXCEPTION) { stopOnError(this.htod.diskCacheException); } return returnCode; }
java
public int writeDependencyEntry(Object id, Object entry) { // SKS-O int returnCode = htod.writeDependencyEntry(id, entry); if (returnCode == HTODDynacache.DISK_EXCEPTION) { stopOnError(this.htod.diskCacheException); } return returnCode; }
[ "public", "int", "writeDependencyEntry", "(", "Object", "id", ",", "Object", "entry", ")", "{", "// SKS-O", "int", "returnCode", "=", "htod", ".", "writeDependencyEntry", "(", "id", ",", "entry", ")", ";", "if", "(", "returnCode", "==", "HTODDynacache", ".", "DISK_EXCEPTION", ")", "{", "stopOnError", "(", "this", ".", "htod", ".", "diskCacheException", ")", ";", "}", "return", "returnCode", ";", "}" ]
Call this method to add a cache id for a specified dependency id to the disk. @param id - dependency id. @param entry - cache id.
[ "Call", "this", "method", "to", "add", "a", "cache", "id", "for", "a", "specified", "dependency", "id", "to", "the", "disk", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1596-L1602
korpling/ANNIS
annis-visualizers/src/main/java/annis/visualizers/component/rst/RSTImpl.java
RSTImpl.sortChildren
private void sortChildren(JSONObject root) throws JSONException { JSONArray children = root.getJSONArray("children"); List<JSONObject> childrenSorted = new ArrayList<JSONObject>(children. length()); for (int i = 0; i < children.length(); i++) { childrenSorted.add(children.getJSONObject(i)); } Collections.sort(childrenSorted, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { int o1IdxLeft = 0; int o1IdxRight = 0; int o2IdxLeft = 0; int o2IdxRight = 0; try { o1IdxLeft = ((JSONObject) o1).getJSONObject("data").getInt( SENTENCE_LEFT); o1IdxRight = ((JSONObject) o1).getJSONObject("data").getInt( SENTENCE_RIGHT); o2IdxLeft = ((JSONObject) o2).getJSONObject("data").getInt( SENTENCE_LEFT); o2IdxRight = ((JSONObject) o2).getJSONObject("data").getInt( SENTENCE_RIGHT); } catch (JSONException ex) { log.error("Could not compare sentence indizes.", ex); } if (o1IdxLeft + o1IdxRight > o2IdxLeft + o2IdxRight) { return 1; } if (o1IdxLeft + o1IdxRight == o2IdxLeft + o2IdxRight) { return 0; } else { return -1; } } }); children = new JSONArray(childrenSorted); root.put("children", children); }
java
private void sortChildren(JSONObject root) throws JSONException { JSONArray children = root.getJSONArray("children"); List<JSONObject> childrenSorted = new ArrayList<JSONObject>(children. length()); for (int i = 0; i < children.length(); i++) { childrenSorted.add(children.getJSONObject(i)); } Collections.sort(childrenSorted, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { int o1IdxLeft = 0; int o1IdxRight = 0; int o2IdxLeft = 0; int o2IdxRight = 0; try { o1IdxLeft = ((JSONObject) o1).getJSONObject("data").getInt( SENTENCE_LEFT); o1IdxRight = ((JSONObject) o1).getJSONObject("data").getInt( SENTENCE_RIGHT); o2IdxLeft = ((JSONObject) o2).getJSONObject("data").getInt( SENTENCE_LEFT); o2IdxRight = ((JSONObject) o2).getJSONObject("data").getInt( SENTENCE_RIGHT); } catch (JSONException ex) { log.error("Could not compare sentence indizes.", ex); } if (o1IdxLeft + o1IdxRight > o2IdxLeft + o2IdxRight) { return 1; } if (o1IdxLeft + o1IdxRight == o2IdxLeft + o2IdxRight) { return 0; } else { return -1; } } }); children = new JSONArray(childrenSorted); root.put("children", children); }
[ "private", "void", "sortChildren", "(", "JSONObject", "root", ")", "throws", "JSONException", "{", "JSONArray", "children", "=", "root", ".", "getJSONArray", "(", "\"children\"", ")", ";", "List", "<", "JSONObject", ">", "childrenSorted", "=", "new", "ArrayList", "<", "JSONObject", ">", "(", "children", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ".", "length", "(", ")", ";", "i", "++", ")", "{", "childrenSorted", ".", "add", "(", "children", ".", "getJSONObject", "(", "i", ")", ")", ";", "}", "Collections", ".", "sort", "(", "childrenSorted", ",", "new", "Comparator", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "Object", "o1", ",", "Object", "o2", ")", "{", "int", "o1IdxLeft", "=", "0", ";", "int", "o1IdxRight", "=", "0", ";", "int", "o2IdxLeft", "=", "0", ";", "int", "o2IdxRight", "=", "0", ";", "try", "{", "o1IdxLeft", "=", "(", "(", "JSONObject", ")", "o1", ")", ".", "getJSONObject", "(", "\"data\"", ")", ".", "getInt", "(", "SENTENCE_LEFT", ")", ";", "o1IdxRight", "=", "(", "(", "JSONObject", ")", "o1", ")", ".", "getJSONObject", "(", "\"data\"", ")", ".", "getInt", "(", "SENTENCE_RIGHT", ")", ";", "o2IdxLeft", "=", "(", "(", "JSONObject", ")", "o2", ")", ".", "getJSONObject", "(", "\"data\"", ")", ".", "getInt", "(", "SENTENCE_LEFT", ")", ";", "o2IdxRight", "=", "(", "(", "JSONObject", ")", "o2", ")", ".", "getJSONObject", "(", "\"data\"", ")", ".", "getInt", "(", "SENTENCE_RIGHT", ")", ";", "}", "catch", "(", "JSONException", "ex", ")", "{", "log", ".", "error", "(", "\"Could not compare sentence indizes.\"", ",", "ex", ")", ";", "}", "if", "(", "o1IdxLeft", "+", "o1IdxRight", ">", "o2IdxLeft", "+", "o2IdxRight", ")", "{", "return", "1", ";", "}", "if", "(", "o1IdxLeft", "+", "o1IdxRight", "==", "o2IdxLeft", "+", "o2IdxRight", ")", "{", "return", "0", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "}", ")", ";", "children", "=", "new", "JSONArray", "(", "childrenSorted", ")", ";", "root", ".", "put", "(", "\"children\"", ",", "children", ")", ";", "}" ]
Sorts the children of root by the the sentence indizes. Since the sentence indizes are based on the token indizes, some sentences have no sentences indizes, because sometimes token nodes are out of context. A kind of insertion sort would be better than the used mergesort. And it is a pity that the {@link JSONArray} has no interface to sort the underlying {@link Array}.
[ "Sorts", "the", "children", "of", "root", "by", "the", "the", "sentence", "indizes", ".", "Since", "the", "sentence", "indizes", "are", "based", "on", "the", "token", "indizes", "some", "sentences", "have", "no", "sentences", "indizes", "because", "sometimes", "token", "nodes", "are", "out", "of", "context", "." ]
train
https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-visualizers/src/main/java/annis/visualizers/component/rst/RSTImpl.java#L679-L722
intendia-oss/rxjava-gwt
src/main/modified/io/reactivex/super/io/reactivex/Maybe.java
Maybe.flatMapSingle
@CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <R> Single<R> flatMapSingle(final Function<? super T, ? extends SingleSource<? extends R>> mapper) { ObjectHelper.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new MaybeFlatMapSingle<T, R>(this, mapper)); }
java
@CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <R> Single<R> flatMapSingle(final Function<? super T, ? extends SingleSource<? extends R>> mapper) { ObjectHelper.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new MaybeFlatMapSingle<T, R>(this, mapper)); }
[ "@", "CheckReturnValue", "@", "SchedulerSupport", "(", "SchedulerSupport", ".", "NONE", ")", "public", "final", "<", "R", ">", "Single", "<", "R", ">", "flatMapSingle", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "SingleSource", "<", "?", "extends", "R", ">", ">", "mapper", ")", "{", "ObjectHelper", ".", "requireNonNull", "(", "mapper", ",", "\"mapper is null\"", ")", ";", "return", "RxJavaPlugins", ".", "onAssembly", "(", "new", "MaybeFlatMapSingle", "<", "T", ",", "R", ">", "(", "this", ",", "mapper", ")", ")", ";", "}" ]
Returns a {@link Single} based on applying a specified function to the item emitted by the source {@link Maybe}, where that function returns a {@link Single}. When this Maybe completes a {@link NoSuchElementException} will be thrown. <p> <img width="640" height="356" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMapSingle.png" alt=""> <dl> <dt><b>Scheduler:</b></dt> <dd>{@code flatMapSingle} does not operate by default on a particular {@link Scheduler}.</dd> </dl> @param <R> the result value type @param mapper a function that, when applied to the item emitted by the source Maybe, returns a Single @return the Single returned from {@code mapper} when applied to the item emitted by the source Maybe @see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a>
[ "Returns", "a", "{", "@link", "Single", "}", "based", "on", "applying", "a", "specified", "function", "to", "the", "item", "emitted", "by", "the", "source", "{", "@link", "Maybe", "}", "where", "that", "function", "returns", "a", "{", "@link", "Single", "}", ".", "When", "this", "Maybe", "completes", "a", "{", "@link", "NoSuchElementException", "}", "will", "be", "thrown", ".", "<p", ">", "<img", "width", "=", "640", "height", "=", "356", "src", "=", "https", ":", "//", "raw", ".", "github", ".", "com", "/", "wiki", "/", "ReactiveX", "/", "RxJava", "/", "images", "/", "rx", "-", "operators", "/", "Maybe", ".", "flatMapSingle", ".", "png", "alt", "=", ">", "<dl", ">", "<dt", ">", "<b", ">", "Scheduler", ":", "<", "/", "b", ">", "<", "/", "dt", ">", "<dd", ">", "{", "@code", "flatMapSingle", "}", "does", "not", "operate", "by", "default", "on", "a", "particular", "{", "@link", "Scheduler", "}", ".", "<", "/", "dd", ">", "<", "/", "dl", ">" ]
train
https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L3091-L3096
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java
Constraints.gteProperty
public PropertyConstraint gteProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, GreaterThanEqualTo.instance(), otherPropertyName); }
java
public PropertyConstraint gteProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, GreaterThanEqualTo.instance(), otherPropertyName); }
[ "public", "PropertyConstraint", "gteProperty", "(", "String", "propertyName", ",", "String", "otherPropertyName", ")", "{", "return", "valueProperties", "(", "propertyName", ",", "GreaterThanEqualTo", ".", "instance", "(", ")", ",", "otherPropertyName", ")", ";", "}" ]
Apply a "greater than or equal to" constraint to two properties. @param propertyName The first property @param otherPropertyName The other property @return The constraint
[ "Apply", "a", "greater", "than", "or", "equal", "to", "constraint", "to", "two", "properties", "." ]
train
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java#L864-L866
albfernandez/itext2
src/main/java/com/lowagie/text/pdf/PRAcroForm.java
PRAcroForm.mergeAttrib
protected PdfDictionary mergeAttrib(PdfDictionary parent, PdfDictionary child) { PdfDictionary targ = new PdfDictionary(); if (parent != null) targ.putAll(parent); for (Iterator it = child.getKeys().iterator(); it.hasNext();) { PdfName key = (PdfName) it.next(); if (key.equals(PdfName.DR) || key.equals(PdfName.DA) || key.equals(PdfName.Q) || key.equals(PdfName.FF) || key.equals(PdfName.DV) || key.equals(PdfName.V) || key.equals(PdfName.FT) || key.equals(PdfName.F)) { targ.put(key,child.get(key)); } } return targ; }
java
protected PdfDictionary mergeAttrib(PdfDictionary parent, PdfDictionary child) { PdfDictionary targ = new PdfDictionary(); if (parent != null) targ.putAll(parent); for (Iterator it = child.getKeys().iterator(); it.hasNext();) { PdfName key = (PdfName) it.next(); if (key.equals(PdfName.DR) || key.equals(PdfName.DA) || key.equals(PdfName.Q) || key.equals(PdfName.FF) || key.equals(PdfName.DV) || key.equals(PdfName.V) || key.equals(PdfName.FT) || key.equals(PdfName.F)) { targ.put(key,child.get(key)); } } return targ; }
[ "protected", "PdfDictionary", "mergeAttrib", "(", "PdfDictionary", "parent", ",", "PdfDictionary", "child", ")", "{", "PdfDictionary", "targ", "=", "new", "PdfDictionary", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "targ", ".", "putAll", "(", "parent", ")", ";", "for", "(", "Iterator", "it", "=", "child", ".", "getKeys", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "PdfName", "key", "=", "(", "PdfName", ")", "it", ".", "next", "(", ")", ";", "if", "(", "key", ".", "equals", "(", "PdfName", ".", "DR", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "DA", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "Q", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "FF", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "DV", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "V", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "FT", ")", "||", "key", ".", "equals", "(", "PdfName", ".", "F", ")", ")", "{", "targ", ".", "put", "(", "key", ",", "child", ".", "get", "(", "key", ")", ")", ";", "}", "}", "return", "targ", ";", "}" ]
merge field attributes from two dictionaries @param parent one dictionary @param child the other dictionary @return a merged dictionary
[ "merge", "field", "attributes", "from", "two", "dictionaries" ]
train
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PRAcroForm.java#L184-L199
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedIndexReader.java
SharedIndexReader.getParent
public DocId getParent(int n, BitSet deleted) throws IOException { return getBase().getParent(n, deleted); }
java
public DocId getParent(int n, BitSet deleted) throws IOException { return getBase().getParent(n, deleted); }
[ "public", "DocId", "getParent", "(", "int", "n", ",", "BitSet", "deleted", ")", "throws", "IOException", "{", "return", "getBase", "(", ")", ".", "getParent", "(", "n", ",", "deleted", ")", ";", "}" ]
Returns the <code>DocId</code> of the parent of <code>n</code> or {@link DocId#NULL} if <code>n</code> does not have a parent (<code>n</code> is the root node). @param n the document number. @param deleted the documents that should be regarded as deleted. @return the <code>DocId</code> of <code>n</code>'s parent. @throws IOException if an error occurs while reading from the index.
[ "Returns", "the", "<code", ">", "DocId<", "/", "code", ">", "of", "the", "parent", "of", "<code", ">", "n<", "/", "code", ">", "or", "{", "@link", "DocId#NULL", "}", "if", "<code", ">", "n<", "/", "code", ">", "does", "not", "have", "a", "parent", "(", "<code", ">", "n<", "/", "code", ">", "is", "the", "root", "node", ")", "." ]
train
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedIndexReader.java#L61-L63
threerings/playn
java/src/playn/java/JavaGraphics.java
JavaGraphics.registerFont
public void registerFont(String name, String path) { try { _fonts.put(name, ((JavaAssets) assets()).requireResource(path).createFont()); } catch (Exception e) { platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e); } }
java
public void registerFont(String name, String path) { try { _fonts.put(name, ((JavaAssets) assets()).requireResource(path).createFont()); } catch (Exception e) { platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e); } }
[ "public", "void", "registerFont", "(", "String", "name", ",", "String", "path", ")", "{", "try", "{", "_fonts", ".", "put", "(", "name", ",", "(", "(", "JavaAssets", ")", "assets", "(", ")", ")", ".", "requireResource", "(", "path", ")", ".", "createFont", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "platform", ".", "reportError", "(", "\"Failed to load font [name=\"", "+", "name", "+", "\", path=\"", "+", "path", "+", "\"]\"", ",", "e", ")", ";", "}", "}" ]
Registers a font with the graphics system. @param name the name under which to register the font. @param path the path to the font resource (relative to the asset manager's path prefix). Currently only TrueType ({@code .ttf}) fonts are supported.
[ "Registers", "a", "font", "with", "the", "graphics", "system", "." ]
train
https://github.com/threerings/playn/blob/c266eeb39188dcada4b00992a0d1199759e03d42/java/src/playn/java/JavaGraphics.java#L83-L89
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroData.java
SynchroData.readTable
private void readTable(InputStream is, SynchroTable table) throws IOException { int skip = table.getOffset() - m_offset; if (skip != 0) { StreamHelper.skip(is, skip); m_offset += skip; } String tableName = DatatypeConverter.getString(is); int tableNameLength = 2 + tableName.length(); m_offset += tableNameLength; int dataLength; if (table.getLength() == -1) { dataLength = is.available(); } else { dataLength = table.getLength() - tableNameLength; } SynchroLogger.log("READ", tableName); byte[] compressedTableData = new byte[dataLength]; is.read(compressedTableData); m_offset += dataLength; Inflater inflater = new Inflater(); inflater.setInput(compressedTableData); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressedTableData.length); byte[] buffer = new byte[1024]; while (!inflater.finished()) { int count; try { count = inflater.inflate(buffer); } catch (DataFormatException ex) { throw new IOException(ex); } outputStream.write(buffer, 0, count); } outputStream.close(); byte[] uncompressedTableData = outputStream.toByteArray(); SynchroLogger.log(uncompressedTableData); m_tableData.put(table.getName(), uncompressedTableData); }
java
private void readTable(InputStream is, SynchroTable table) throws IOException { int skip = table.getOffset() - m_offset; if (skip != 0) { StreamHelper.skip(is, skip); m_offset += skip; } String tableName = DatatypeConverter.getString(is); int tableNameLength = 2 + tableName.length(); m_offset += tableNameLength; int dataLength; if (table.getLength() == -1) { dataLength = is.available(); } else { dataLength = table.getLength() - tableNameLength; } SynchroLogger.log("READ", tableName); byte[] compressedTableData = new byte[dataLength]; is.read(compressedTableData); m_offset += dataLength; Inflater inflater = new Inflater(); inflater.setInput(compressedTableData); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressedTableData.length); byte[] buffer = new byte[1024]; while (!inflater.finished()) { int count; try { count = inflater.inflate(buffer); } catch (DataFormatException ex) { throw new IOException(ex); } outputStream.write(buffer, 0, count); } outputStream.close(); byte[] uncompressedTableData = outputStream.toByteArray(); SynchroLogger.log(uncompressedTableData); m_tableData.put(table.getName(), uncompressedTableData); }
[ "private", "void", "readTable", "(", "InputStream", "is", ",", "SynchroTable", "table", ")", "throws", "IOException", "{", "int", "skip", "=", "table", ".", "getOffset", "(", ")", "-", "m_offset", ";", "if", "(", "skip", "!=", "0", ")", "{", "StreamHelper", ".", "skip", "(", "is", ",", "skip", ")", ";", "m_offset", "+=", "skip", ";", "}", "String", "tableName", "=", "DatatypeConverter", ".", "getString", "(", "is", ")", ";", "int", "tableNameLength", "=", "2", "+", "tableName", ".", "length", "(", ")", ";", "m_offset", "+=", "tableNameLength", ";", "int", "dataLength", ";", "if", "(", "table", ".", "getLength", "(", ")", "==", "-", "1", ")", "{", "dataLength", "=", "is", ".", "available", "(", ")", ";", "}", "else", "{", "dataLength", "=", "table", ".", "getLength", "(", ")", "-", "tableNameLength", ";", "}", "SynchroLogger", ".", "log", "(", "\"READ\"", ",", "tableName", ")", ";", "byte", "[", "]", "compressedTableData", "=", "new", "byte", "[", "dataLength", "]", ";", "is", ".", "read", "(", "compressedTableData", ")", ";", "m_offset", "+=", "dataLength", ";", "Inflater", "inflater", "=", "new", "Inflater", "(", ")", ";", "inflater", ".", "setInput", "(", "compressedTableData", ")", ";", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", "compressedTableData", ".", "length", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "while", "(", "!", "inflater", ".", "finished", "(", ")", ")", "{", "int", "count", ";", "try", "{", "count", "=", "inflater", ".", "inflate", "(", "buffer", ")", ";", "}", "catch", "(", "DataFormatException", "ex", ")", "{", "throw", "new", "IOException", "(", "ex", ")", ";", "}", "outputStream", ".", "write", "(", "buffer", ",", "0", ",", "count", ")", ";", "}", "outputStream", ".", "close", "(", ")", ";", "byte", "[", "]", "uncompressedTableData", "=", "outputStream", ".", "toByteArray", "(", ")", ";", "SynchroLogger", ".", "log", "(", "uncompressedTableData", ")", ";", "m_tableData", ".", "put", "(", "table", ".", "getName", "(", ")", ",", "uncompressedTableData", ")", ";", "}" ]
Read data for a single table and store it. @param is input stream @param table table header
[ "Read", "data", "for", "a", "single", "table", "and", "store", "it", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroData.java#L175-L228
OpenLiberty/open-liberty
dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/viewer/LogViewer.java
LogViewer.execute
public int execute(String[] args) { Map<String, LevelDetails> levels = readLevels(System.getProperty("logviewer.custom.levels")); String[] header = readHeader(System.getProperty("logviewer.custom.header")); return execute(args, levels, header); }
java
public int execute(String[] args) { Map<String, LevelDetails> levels = readLevels(System.getProperty("logviewer.custom.levels")); String[] header = readHeader(System.getProperty("logviewer.custom.header")); return execute(args, levels, header); }
[ "public", "int", "execute", "(", "String", "[", "]", "args", ")", "{", "Map", "<", "String", ",", "LevelDetails", ">", "levels", "=", "readLevels", "(", "System", ".", "getProperty", "(", "\"logviewer.custom.levels\"", ")", ")", ";", "String", "[", "]", "header", "=", "readHeader", "(", "System", ".", "getProperty", "(", "\"logviewer.custom.header\"", ")", ")", ";", "return", "execute", "(", "args", ",", "levels", ",", "header", ")", ";", "}" ]
Runs LogViewer using values in System Properties to find custom levels and header. @param args - command line arguments to LogViewer @return code indicating status of the execution: 0 on success, 1 otherwise.
[ "Runs", "LogViewer", "using", "values", "in", "System", "Properties", "to", "find", "custom", "levels", "and", "header", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/viewer/LogViewer.java#L271-L276
Graylog2/graylog2-server
graylog2-server/src/main/java/org/graylog2/plugin/Tools.java
Tools.silenceUncaughtExceptionsInThisThread
public static void silenceUncaughtExceptionsInThisThread() { Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread ignored, Throwable ignored1) { } }); }
java
public static void silenceUncaughtExceptionsInThisThread() { Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread ignored, Throwable ignored1) { } }); }
[ "public", "static", "void", "silenceUncaughtExceptionsInThisThread", "(", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "setUncaughtExceptionHandler", "(", "new", "Thread", ".", "UncaughtExceptionHandler", "(", ")", "{", "@", "Override", "public", "void", "uncaughtException", "(", "Thread", "ignored", ",", "Throwable", "ignored1", ")", "{", "}", "}", ")", ";", "}" ]
The default uncaught exception handler will print to STDERR, which we don't always want for threads. Using this utility method you can avoid writing to STDERR on a per-thread basis
[ "The", "default", "uncaught", "exception", "handler", "will", "print", "to", "STDERR", "which", "we", "don", "t", "always", "want", "for", "threads", ".", "Using", "this", "utility", "method", "you", "can", "avoid", "writing", "to", "STDERR", "on", "a", "per", "-", "thread", "basis" ]
train
https://github.com/Graylog2/graylog2-server/blob/50b565dcead6e0a372236d5c2f8530dc5726fa9b/graylog2-server/src/main/java/org/graylog2/plugin/Tools.java#L622-L628
io7m/jaffirm
com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java
Preconditions.checkPrecondition
public static <T> T checkPrecondition( final T value, final boolean condition, final Function<T, String> describer) { return innerCheck(value, condition, describer); }
java
public static <T> T checkPrecondition( final T value, final boolean condition, final Function<T, String> describer) { return innerCheck(value, condition, describer); }
[ "public", "static", "<", "T", ">", "T", "checkPrecondition", "(", "final", "T", "value", ",", "final", "boolean", "condition", ",", "final", "Function", "<", "T", ",", "String", ">", "describer", ")", "{", "return", "innerCheck", "(", "value", ",", "condition", ",", "describer", ")", ";", "}" ]
<p>Evaluate the given {@code predicate} using {@code value} as input.</p> <p>The function throws {@link PreconditionViolationException} if the predicate is false.</p> @param value The value @param condition The predicate @param describer A describer for the predicate @param <T> The type of values @return value @throws PreconditionViolationException If the predicate is false
[ "<p", ">", "Evaluate", "the", "given", "{", "@code", "predicate", "}", "using", "{", "@code", "value", "}", "as", "input", ".", "<", "/", "p", ">" ]
train
https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java#L235-L241
gwtplus/google-gin
src/main/java/com/google/gwt/inject/rebind/util/SourceSnippets.java
SourceSnippets.asMethod
public static InjectorMethod asMethod(boolean isNative, String signature, String pkg, final SourceSnippet body) { return new AbstractInjectorMethod(isNative, signature, pkg) { public String getMethodBody(InjectorWriteContext writeContext) { return body.getSource(writeContext); } }; }
java
public static InjectorMethod asMethod(boolean isNative, String signature, String pkg, final SourceSnippet body) { return new AbstractInjectorMethod(isNative, signature, pkg) { public String getMethodBody(InjectorWriteContext writeContext) { return body.getSource(writeContext); } }; }
[ "public", "static", "InjectorMethod", "asMethod", "(", "boolean", "isNative", ",", "String", "signature", ",", "String", "pkg", ",", "final", "SourceSnippet", "body", ")", "{", "return", "new", "AbstractInjectorMethod", "(", "isNative", ",", "signature", ",", "pkg", ")", "{", "public", "String", "getMethodBody", "(", "InjectorWriteContext", "writeContext", ")", "{", "return", "body", ".", "getSource", "(", "writeContext", ")", ";", "}", "}", ";", "}" ]
Creates an {@link InjectorMethod} using the given {@link SourceSnippet} as its body. @param isNative whether the returned method is a native method @param signature the signature of the returned method @param pkg the package in which the returned method should be created @param body the body text of the new method
[ "Creates", "an", "{", "@link", "InjectorMethod", "}", "using", "the", "given", "{", "@link", "SourceSnippet", "}", "as", "its", "body", "." ]
train
https://github.com/gwtplus/google-gin/blob/595e61ee0d2fa508815c016e924ec0e5cea2a2aa/src/main/java/com/google/gwt/inject/rebind/util/SourceSnippets.java#L132-L139
xsonorg/xson
src/main/java/org/xson/core/asm/MethodWriter.java
MethodWriter.writeShort
static void writeShort(final byte[] b, final int index, final int s) { b[index] = (byte) (s >>> 8); b[index + 1] = (byte) s; }
java
static void writeShort(final byte[] b, final int index, final int s) { b[index] = (byte) (s >>> 8); b[index + 1] = (byte) s; }
[ "static", "void", "writeShort", "(", "final", "byte", "[", "]", "b", ",", "final", "int", "index", ",", "final", "int", "s", ")", "{", "b", "[", "index", "]", "=", "(", "byte", ")", "(", "s", ">>>", "8", ")", ";", "b", "[", "index", "+", "1", "]", "=", "(", "byte", ")", "s", ";", "}" ]
Writes a short value in the given byte array. @param b a byte array. @param index where the first byte of the short value must be written. @param s the value to be written in the given byte array.
[ "Writes", "a", "short", "value", "in", "the", "given", "byte", "array", "." ]
train
https://github.com/xsonorg/xson/blob/ce1e197ec4ef9be448ed6ca96513e886151f83a9/src/main/java/org/xson/core/asm/MethodWriter.java#L2530-L2533
nmdp-bioinformatics/ngs
variant/src/main/java/org/nmdp/ngs/variant/vcf/VcfWriter.java
VcfWriter.writeColumnHeader
public static void writeColumnHeader(final List<VcfSample> samples, final PrintWriter writer) { checkNotNull(samples); checkNotNull(writer); StringBuilder sb = new StringBuilder("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"); if (!samples.isEmpty()) { sb.append("\tFORMAT"); } for (VcfSample sample : samples) { sb.append("\t"); sb.append(sample.getId()); } writer.println(sb.toString()); }
java
public static void writeColumnHeader(final List<VcfSample> samples, final PrintWriter writer) { checkNotNull(samples); checkNotNull(writer); StringBuilder sb = new StringBuilder("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"); if (!samples.isEmpty()) { sb.append("\tFORMAT"); } for (VcfSample sample : samples) { sb.append("\t"); sb.append(sample.getId()); } writer.println(sb.toString()); }
[ "public", "static", "void", "writeColumnHeader", "(", "final", "List", "<", "VcfSample", ">", "samples", ",", "final", "PrintWriter", "writer", ")", "{", "checkNotNull", "(", "samples", ")", ";", "checkNotNull", "(", "writer", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"#CHROM\\tPOS\\tID\\tREF\\tALT\\tQUAL\\tFILTER\\tINFO\"", ")", ";", "if", "(", "!", "samples", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\"\\tFORMAT\"", ")", ";", "}", "for", "(", "VcfSample", "sample", ":", "samples", ")", "{", "sb", ".", "append", "(", "\"\\t\"", ")", ";", "sb", ".", "append", "(", "sample", ".", "getId", "(", ")", ")", ";", "}", "writer", ".", "println", "(", "sb", ".", "toString", "(", ")", ")", ";", "}" ]
Write VCF column header with the specified print writer. @param samples zero or more VCF samples, must not be null @param writer print writer to write VCF with, must not be null
[ "Write", "VCF", "column", "header", "with", "the", "specified", "print", "writer", "." ]
train
https://github.com/nmdp-bioinformatics/ngs/blob/277627e4311313a80f5dc110b3185b0d7af32bd0/variant/src/main/java/org/nmdp/ngs/variant/vcf/VcfWriter.java#L86-L99
spring-projects/spring-android
spring-android-auth/src/main/java/org/springframework/security/crypto/encrypt/AndroidEncryptors.java
AndroidEncryptors.queryableText
public static TextEncryptor queryableText(CharSequence password, CharSequence salt) { return new HexEncodingTextEncryptor(new AndroidAesBytesEncryptor(password.toString(), salt, AndroidKeyGenerators.shared(16))); }
java
public static TextEncryptor queryableText(CharSequence password, CharSequence salt) { return new HexEncodingTextEncryptor(new AndroidAesBytesEncryptor(password.toString(), salt, AndroidKeyGenerators.shared(16))); }
[ "public", "static", "TextEncryptor", "queryableText", "(", "CharSequence", "password", ",", "CharSequence", "salt", ")", "{", "return", "new", "HexEncodingTextEncryptor", "(", "new", "AndroidAesBytesEncryptor", "(", "password", ".", "toString", "(", ")", ",", "salt", ",", "AndroidKeyGenerators", ".", "shared", "(", "16", ")", ")", ")", ";", "}" ]
Creates an encryptor for queryable text strings that uses standard password-based encryption. Uses a shared, or constant 16 byte initialization vector so encrypting the same data results in the same encryption result. This is done to allow encrypted data to be queried against. Encrypted text is hex-encoded. @param password the password used to generate the encryptor's secret key; should not be shared @param salt a hex-encoded, random, site-global salt value to use to generate the secret key
[ "Creates", "an", "encryptor", "for", "queryable", "text", "strings", "that", "uses", "standard", "password", "-", "based", "encryption", ".", "Uses", "a", "shared", "or", "constant", "16", "byte", "initialization", "vector", "so", "encrypting", "the", "same", "data", "results", "in", "the", "same", "encryption", "result", ".", "This", "is", "done", "to", "allow", "encrypted", "data", "to", "be", "queried", "against", ".", "Encrypted", "text", "is", "hex", "-", "encoded", "." ]
train
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-auth/src/main/java/org/springframework/security/crypto/encrypt/AndroidEncryptors.java#L63-L65
gmessner/gitlab4j-api
src/main/java/org/gitlab4j/api/AbstractApi.java
AbstractApi.addFormParam
protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException { if (value == null) { if (required) { throw new IllegalArgumentException(name + " cannot be empty or null"); } return; } String stringValue = value.toString(); if (required && stringValue.trim().length() == 0) { throw new IllegalArgumentException(name + " cannot be empty or null"); } formData.param(name, stringValue); }
java
protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException { if (value == null) { if (required) { throw new IllegalArgumentException(name + " cannot be empty or null"); } return; } String stringValue = value.toString(); if (required && stringValue.trim().length() == 0) { throw new IllegalArgumentException(name + " cannot be empty or null"); } formData.param(name, stringValue); }
[ "protected", "void", "addFormParam", "(", "Form", "formData", ",", "String", "name", ",", "Object", "value", ",", "boolean", "required", ")", "throws", "IllegalArgumentException", "{", "if", "(", "value", "==", "null", ")", "{", "if", "(", "required", ")", "{", "throw", "new", "IllegalArgumentException", "(", "name", "+", "\" cannot be empty or null\"", ")", ";", "}", "return", ";", "}", "String", "stringValue", "=", "value", ".", "toString", "(", ")", ";", "if", "(", "required", "&&", "stringValue", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "name", "+", "\" cannot be empty or null\"", ")", ";", "}", "formData", ".", "param", "(", "name", ",", "stringValue", ")", ";", "}" ]
Convenience method for adding query and form parameters to a get() or post() call. If required is true and value is null, will throw an IllegalArgumentException. @param formData the Form containing the name/value pairs @param name the name of the field/attribute to add @param value the value of the field/attribute to add @param required the field is required flag @throws IllegalArgumentException if a required parameter is null or empty
[ "Convenience", "method", "for", "adding", "query", "and", "form", "parameters", "to", "a", "get", "()", "or", "post", "()", "call", ".", "If", "required", "is", "true", "and", "value", "is", "null", "will", "throw", "an", "IllegalArgumentException", "." ]
train
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/AbstractApi.java#L555-L572
UrielCh/ovh-java-sdk
ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java
ApiOvhDedicatedCloud.serviceName_vmEncryption_kms_kmsId_changeProperties_POST
public OvhTask serviceName_vmEncryption_kms_kmsId_changeProperties_POST(String serviceName, Long kmsId, String description, String sslThumbprint) throws IOException { String qPath = "/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties"; StringBuilder sb = path(qPath, serviceName, kmsId); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "description", description); addBody(o, "sslThumbprint", sslThumbprint); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
java
public OvhTask serviceName_vmEncryption_kms_kmsId_changeProperties_POST(String serviceName, Long kmsId, String description, String sslThumbprint) throws IOException { String qPath = "/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties"; StringBuilder sb = path(qPath, serviceName, kmsId); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "description", description); addBody(o, "sslThumbprint", sslThumbprint); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
[ "public", "OvhTask", "serviceName_vmEncryption_kms_kmsId_changeProperties_POST", "(", "String", "serviceName", ",", "Long", "kmsId", ",", "String", "description", ",", "String", "sslThumbprint", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "kmsId", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"description\"", ",", "description", ")", ";", "addBody", "(", "o", ",", "\"sslThumbprint\"", ",", "sslThumbprint", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhTask", ".", "class", ")", ";", "}" ]
Change option user access properties REST: POST /dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties @param sslThumbprint [required] SSL thumbprint of the remote service, e.g. A7:61:68:...:61:91:2F @param description [required] Description of your option access network @param serviceName [required] Domain of the service @param kmsId [required] Id of the VM Encryption KMS
[ "Change", "option", "user", "access", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L590-L598
rhuss/jolokia
agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanAccessChecker.java
MBeanAccessChecker.extractMbeanConfiguration
private void extractMbeanConfiguration(NodeList pNodes,MBeanPolicyConfig pConfig) throws MalformedObjectNameException { for (int i = 0;i< pNodes.getLength();i++) { Node node = pNodes.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } extractPolicyConfig(pConfig, node.getChildNodes()); } }
java
private void extractMbeanConfiguration(NodeList pNodes,MBeanPolicyConfig pConfig) throws MalformedObjectNameException { for (int i = 0;i< pNodes.getLength();i++) { Node node = pNodes.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } extractPolicyConfig(pConfig, node.getChildNodes()); } }
[ "private", "void", "extractMbeanConfiguration", "(", "NodeList", "pNodes", ",", "MBeanPolicyConfig", "pConfig", ")", "throws", "MalformedObjectNameException", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pNodes", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "pNodes", ".", "item", "(", "i", ")", ";", "if", "(", "node", ".", "getNodeType", "(", ")", "!=", "Node", ".", "ELEMENT_NODE", ")", "{", "continue", ";", "}", "extractPolicyConfig", "(", "pConfig", ",", "node", ".", "getChildNodes", "(", ")", ")", ";", "}", "}" ]
Extract configuration and put it into a given MBeanPolicyConfig
[ "Extract", "configuration", "and", "put", "it", "into", "a", "given", "MBeanPolicyConfig" ]
train
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanAccessChecker.java#L103-L111
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/CatalogMetadataBuilder.java
CatalogMetadataBuilder.withOptions
@TimerJ public CatalogMetadataBuilder withOptions(Map<Selector, Selector> opts) { options = new HashMap<Selector, Selector>(opts); return this; }
java
@TimerJ public CatalogMetadataBuilder withOptions(Map<Selector, Selector> opts) { options = new HashMap<Selector, Selector>(opts); return this; }
[ "@", "TimerJ", "public", "CatalogMetadataBuilder", "withOptions", "(", "Map", "<", "Selector", ",", "Selector", ">", "opts", ")", "{", "options", "=", "new", "HashMap", "<", "Selector", ",", "Selector", ">", "(", "opts", ")", ";", "return", "this", ";", "}" ]
Set the options. Any options previously created are removed. @param opts the opts @return the catalog metadata builder
[ "Set", "the", "options", ".", "Any", "options", "previously", "created", "are", "removed", "." ]
train
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/CatalogMetadataBuilder.java#L82-L86
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/eme/element/ExplicitMessageEncryptionElement.java
ExplicitMessageEncryptionElement.hasProtocol
public static boolean hasProtocol(Message message, String protocolNamespace) { List<ExtensionElement> extensionElements = message.getExtensions( ExplicitMessageEncryptionElement.ELEMENT, ExplicitMessageEncryptionElement.NAMESPACE); for (ExtensionElement extensionElement : extensionElements) { ExplicitMessageEncryptionElement e = (ExplicitMessageEncryptionElement) extensionElement; if (e.getEncryptionNamespace().equals(protocolNamespace)) { return true; } } return false; }
java
public static boolean hasProtocol(Message message, String protocolNamespace) { List<ExtensionElement> extensionElements = message.getExtensions( ExplicitMessageEncryptionElement.ELEMENT, ExplicitMessageEncryptionElement.NAMESPACE); for (ExtensionElement extensionElement : extensionElements) { ExplicitMessageEncryptionElement e = (ExplicitMessageEncryptionElement) extensionElement; if (e.getEncryptionNamespace().equals(protocolNamespace)) { return true; } } return false; }
[ "public", "static", "boolean", "hasProtocol", "(", "Message", "message", ",", "String", "protocolNamespace", ")", "{", "List", "<", "ExtensionElement", ">", "extensionElements", "=", "message", ".", "getExtensions", "(", "ExplicitMessageEncryptionElement", ".", "ELEMENT", ",", "ExplicitMessageEncryptionElement", ".", "NAMESPACE", ")", ";", "for", "(", "ExtensionElement", "extensionElement", ":", "extensionElements", ")", "{", "ExplicitMessageEncryptionElement", "e", "=", "(", "ExplicitMessageEncryptionElement", ")", "extensionElement", ";", "if", "(", "e", ".", "getEncryptionNamespace", "(", ")", ".", "equals", "(", "protocolNamespace", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return true, if the {@code message} already contains an EME element with the specified {@code protocolNamespace}. @param message message @param protocolNamespace namespace @return true if message has EME element for that namespace, otherwise false
[ "Return", "true", "if", "the", "{", "@code", "message", "}", "already", "contains", "an", "EME", "element", "with", "the", "specified", "{", "@code", "protocolNamespace", "}", "." ]
train
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/eme/element/ExplicitMessageEncryptionElement.java#L157-L170
aws/aws-sdk-java
aws-java-sdk-servicediscovery/src/main/java/com/amazonaws/services/servicediscovery/model/Operation.java
Operation.withTargets
public Operation withTargets(java.util.Map<String, String> targets) { setTargets(targets); return this; }
java
public Operation withTargets(java.util.Map<String, String> targets) { setTargets(targets); return this; }
[ "public", "Operation", "withTargets", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "targets", ")", "{", "setTargets", "(", "targets", ")", ";", "return", "this", ";", "}" ]
<p> The name of the target entity that is associated with the operation: </p> <ul> <li> <p> <b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property. </p> </li> <li> <p> <b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property. </p> </li> <li> <p> <b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property. </p> </li> </ul> @param targets The name of the target entity that is associated with the operation:</p> <ul> <li> <p> <b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property. </p> </li> <li> <p> <b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property. </p> </li> <li> <p> <b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property. </p> </li> @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "The", "name", "of", "the", "target", "entity", "that", "is", "associated", "with", "the", "operation", ":", "<", "/", "p", ">", "<ul", ">", "<li", ">", "<p", ">", "<b", ">", "NAMESPACE<", "/", "b", ">", ":", "The", "namespace", "ID", "is", "returned", "in", "the", "<code", ">", "ResourceId<", "/", "code", ">", "property", ".", "<", "/", "p", ">", "<", "/", "li", ">", "<li", ">", "<p", ">", "<b", ">", "SERVICE<", "/", "b", ">", ":", "The", "service", "ID", "is", "returned", "in", "the", "<code", ">", "ResourceId<", "/", "code", ">", "property", ".", "<", "/", "p", ">", "<", "/", "li", ">", "<li", ">", "<p", ">", "<b", ">", "INSTANCE<", "/", "b", ">", ":", "The", "instance", "ID", "is", "returned", "in", "the", "<code", ">", "ResourceId<", "/", "code", ">", "property", ".", "<", "/", "p", ">", "<", "/", "li", ">", "<", "/", "ul", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-servicediscovery/src/main/java/com/amazonaws/services/servicediscovery/model/Operation.java#L1033-L1036
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java
SASLMechanism.authenticate
public void authenticate(String host, DomainBareJid serviceName, CallbackHandler cbh, EntityBareJid authzid, SSLSession sslSession) throws SmackSaslException, NotConnectedException, InterruptedException { this.host = host; this.serviceName = serviceName; this.authorizationId = authzid; this.sslSession = sslSession; assert (authorizationId == null || authzidSupported()); authenticateInternal(cbh); authenticate(); }
java
public void authenticate(String host, DomainBareJid serviceName, CallbackHandler cbh, EntityBareJid authzid, SSLSession sslSession) throws SmackSaslException, NotConnectedException, InterruptedException { this.host = host; this.serviceName = serviceName; this.authorizationId = authzid; this.sslSession = sslSession; assert (authorizationId == null || authzidSupported()); authenticateInternal(cbh); authenticate(); }
[ "public", "void", "authenticate", "(", "String", "host", ",", "DomainBareJid", "serviceName", ",", "CallbackHandler", "cbh", ",", "EntityBareJid", "authzid", ",", "SSLSession", "sslSession", ")", "throws", "SmackSaslException", ",", "NotConnectedException", ",", "InterruptedException", "{", "this", ".", "host", "=", "host", ";", "this", ".", "serviceName", "=", "serviceName", ";", "this", ".", "authorizationId", "=", "authzid", ";", "this", ".", "sslSession", "=", "sslSession", ";", "assert", "(", "authorizationId", "==", "null", "||", "authzidSupported", "(", ")", ")", ";", "authenticateInternal", "(", "cbh", ")", ";", "authenticate", "(", ")", ";", "}" ]
Builds and sends the <tt>auth</tt> stanza to the server. The callback handler will handle any additional information, such as the authentication ID or realm, if it is needed. @param host the hostname where the user account resides. @param serviceName the xmpp service location @param cbh the CallbackHandler to obtain user information. @param authzid the optional authorization identity. @param sslSession the optional SSL/TLS session (if one was established) @throws SmackSaslException if a SASL related error occurs. @throws NotConnectedException @throws InterruptedException
[ "Builds", "and", "sends", "the", "<tt", ">", "auth<", "/", "tt", ">", "stanza", "to", "the", "server", ".", "The", "callback", "handler", "will", "handle", "any", "additional", "information", "such", "as", "the", "authentication", "ID", "or", "realm", "if", "it", "is", "needed", "." ]
train
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java#L176-L185
iipc/openwayback
wayback-core/src/main/java/org/archive/wayback/resourceindex/updater/LocalResourceIndexUpdater.java
LocalResourceIndexUpdater.init
public void init() throws ConfigurationException { if(index == null) { throw new ConfigurationException("No index target"); } if(!index.isUpdatable()) { throw new ConfigurationException("ResourceIndex is not updatable"); } if(incoming == null) { throw new ConfigurationException("No incoming"); } if(runInterval > 0) { thread = new UpdateThread(this,runInterval); thread.start(); } }
java
public void init() throws ConfigurationException { if(index == null) { throw new ConfigurationException("No index target"); } if(!index.isUpdatable()) { throw new ConfigurationException("ResourceIndex is not updatable"); } if(incoming == null) { throw new ConfigurationException("No incoming"); } if(runInterval > 0) { thread = new UpdateThread(this,runInterval); thread.start(); } }
[ "public", "void", "init", "(", ")", "throws", "ConfigurationException", "{", "if", "(", "index", "==", "null", ")", "{", "throw", "new", "ConfigurationException", "(", "\"No index target\"", ")", ";", "}", "if", "(", "!", "index", ".", "isUpdatable", "(", ")", ")", "{", "throw", "new", "ConfigurationException", "(", "\"ResourceIndex is not updatable\"", ")", ";", "}", "if", "(", "incoming", "==", "null", ")", "{", "throw", "new", "ConfigurationException", "(", "\"No incoming\"", ")", ";", "}", "if", "(", "runInterval", ">", "0", ")", "{", "thread", "=", "new", "UpdateThread", "(", "this", ",", "runInterval", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "}" ]
start the background index merging thread @throws ConfigurationException
[ "start", "the", "background", "index", "merging", "thread" ]
train
https://github.com/iipc/openwayback/blob/da74c3a59a5b5a5c365bd4702dcb45d263535794/wayback-core/src/main/java/org/archive/wayback/resourceindex/updater/LocalResourceIndexUpdater.java#L76-L90
Mozu/mozu-java
mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/storefront/ProductUrl.java
ProductUrl.getProductInventoryUrl
public static MozuUrl getProductInventoryUrl(String locationCodes, String productCode, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/storefront/products/{productCode}/locationinventory?locationCodes={locationCodes}&responseFields={responseFields}"); formatter.formatUrl("locationCodes", locationCodes); formatter.formatUrl("productCode", productCode); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
java
public static MozuUrl getProductInventoryUrl(String locationCodes, String productCode, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/storefront/products/{productCode}/locationinventory?locationCodes={locationCodes}&responseFields={responseFields}"); formatter.formatUrl("locationCodes", locationCodes); formatter.formatUrl("productCode", productCode); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
[ "public", "static", "MozuUrl", "getProductInventoryUrl", "(", "String", "locationCodes", ",", "String", "productCode", ",", "String", "responseFields", ")", "{", "UrlFormatter", "formatter", "=", "new", "UrlFormatter", "(", "\"/api/commerce/catalog/storefront/products/{productCode}/locationinventory?locationCodes={locationCodes}&responseFields={responseFields}\"", ")", ";", "formatter", ".", "formatUrl", "(", "\"locationCodes\"", ",", "locationCodes", ")", ";", "formatter", ".", "formatUrl", "(", "\"productCode\"", ",", "productCode", ")", ";", "formatter", ".", "formatUrl", "(", "\"responseFields\"", ",", "responseFields", ")", ";", "return", "new", "MozuUrl", "(", "formatter", ".", "getResourceUrl", "(", ")", ",", "MozuUrl", ".", "UrlLocation", ".", "TENANT_POD", ")", ";", "}" ]
Get Resource Url for GetProductInventory @param locationCodes Array of location codes for which to retrieve product inventory information. @param productCode The unique, user-defined product code of a product, used throughout to reference and associate to a product. @param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss. @return String Resource Url
[ "Get", "Resource", "Url", "for", "GetProductInventory" ]
train
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/storefront/ProductUrl.java#L49-L56
UrielCh/ovh-java-sdk
ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java
ApiOvhMe.payment_thod_POST
public OvhValidationResult payment_thod_POST(Long billingContactId, OvhCallbackUrl callbackUrl, Boolean _default, String description, Long orderId, String paymentType, Boolean register) throws IOException { String qPath = "/me/payment/method"; StringBuilder sb = path(qPath); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "billingContactId", billingContactId); addBody(o, "callbackUrl", callbackUrl); addBody(o, "default", _default); addBody(o, "description", description); addBody(o, "orderId", orderId); addBody(o, "paymentType", paymentType); addBody(o, "register", register); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhValidationResult.class); }
java
public OvhValidationResult payment_thod_POST(Long billingContactId, OvhCallbackUrl callbackUrl, Boolean _default, String description, Long orderId, String paymentType, Boolean register) throws IOException { String qPath = "/me/payment/method"; StringBuilder sb = path(qPath); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "billingContactId", billingContactId); addBody(o, "callbackUrl", callbackUrl); addBody(o, "default", _default); addBody(o, "description", description); addBody(o, "orderId", orderId); addBody(o, "paymentType", paymentType); addBody(o, "register", register); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhValidationResult.class); }
[ "public", "OvhValidationResult", "payment_thod_POST", "(", "Long", "billingContactId", ",", "OvhCallbackUrl", "callbackUrl", ",", "Boolean", "_default", ",", "String", "description", ",", "Long", "orderId", ",", "String", "paymentType", ",", "Boolean", "register", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/me/payment/method\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"billingContactId\"", ",", "billingContactId", ")", ";", "addBody", "(", "o", ",", "\"callbackUrl\"", ",", "callbackUrl", ")", ";", "addBody", "(", "o", ",", "\"default\"", ",", "_default", ")", ";", "addBody", "(", "o", ",", "\"description\"", ",", "description", ")", ";", "addBody", "(", "o", ",", "\"orderId\"", ",", "orderId", ")", ";", "addBody", "(", "o", ",", "\"paymentType\"", ",", "paymentType", ")", ";", "addBody", "(", "o", ",", "\"register\"", ",", "register", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhValidationResult", ".", "class", ")", ";", "}" ]
Pay an order and register a new payment method if necessary REST: POST /me/payment/method @param billingContactId [required] Billing contact id @param callbackUrl [required] URL's necessary to register @param _default [required] Is this payment method set as the default one @param description [required] Customer personalized description @param orderId [required] The ID of one order to pay it @param paymentType [required] Payment type @param register [required] Register this payment method if it's possible (by default it's false and do a oneshot transaction) API beta
[ "Pay", "an", "order", "and", "register", "a", "new", "payment", "method", "if", "necessary" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L1034-L1047
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/network/Network.java
Network.newSwitch
public Switch newSwitch(int id, int capacity) { Switch s = swBuilder.newSwitch(id, capacity); switches.add(s); return s; }
java
public Switch newSwitch(int id, int capacity) { Switch s = swBuilder.newSwitch(id, capacity); switches.add(s); return s; }
[ "public", "Switch", "newSwitch", "(", "int", "id", ",", "int", "capacity", ")", "{", "Switch", "s", "=", "swBuilder", ".", "newSwitch", "(", "id", ",", "capacity", ")", ";", "switches", ".", "add", "(", "s", ")", ";", "return", "s", ";", "}" ]
Create a new switch with a specific identifier and a given maximal capacity @param id the switch identifier @param capacity the switch maximal capacity (put a nul or negative number for non-blocking switch) @return the switch
[ "Create", "a", "new", "switch", "with", "a", "specific", "identifier", "and", "a", "given", "maximal", "capacity" ]
train
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/network/Network.java#L140-L144
phax/ph-masterdata
ph-masterdata/src/main/java/com/helger/masterdata/swift/IBANCountryData.java
IBANCountryData.createFromString
@Nonnull public static IBANCountryData createFromString (@Nonnull @Nonempty final String sCountryCode, @Nonnegative final int nExpectedLength, @Nullable final String sLayout, @Nullable final String sFixedCheckDigits, @Nullable final LocalDate aValidFrom, @Nullable final LocalDate aValidTo, @Nonnull final String sDesc) { ValueEnforcer.notEmpty (sDesc, "Desc"); if (sDesc.length () < 4) throw new IllegalArgumentException ("Cannot converted passed string because it is too short!"); final ICommonsList <IBANElement> aList = _parseElements (sDesc); final Pattern aPattern = _parseLayout (sCountryCode, nExpectedLength, sFixedCheckDigits, sLayout); // And we're done try { return new IBANCountryData (nExpectedLength, aPattern, sFixedCheckDigits, aValidFrom, aValidTo, aList); } catch (final IllegalArgumentException ex) { throw new IllegalArgumentException ("Failed to parse '" + sDesc + "': " + ex.getMessage ()); } }
java
@Nonnull public static IBANCountryData createFromString (@Nonnull @Nonempty final String sCountryCode, @Nonnegative final int nExpectedLength, @Nullable final String sLayout, @Nullable final String sFixedCheckDigits, @Nullable final LocalDate aValidFrom, @Nullable final LocalDate aValidTo, @Nonnull final String sDesc) { ValueEnforcer.notEmpty (sDesc, "Desc"); if (sDesc.length () < 4) throw new IllegalArgumentException ("Cannot converted passed string because it is too short!"); final ICommonsList <IBANElement> aList = _parseElements (sDesc); final Pattern aPattern = _parseLayout (sCountryCode, nExpectedLength, sFixedCheckDigits, sLayout); // And we're done try { return new IBANCountryData (nExpectedLength, aPattern, sFixedCheckDigits, aValidFrom, aValidTo, aList); } catch (final IllegalArgumentException ex) { throw new IllegalArgumentException ("Failed to parse '" + sDesc + "': " + ex.getMessage ()); } }
[ "@", "Nonnull", "public", "static", "IBANCountryData", "createFromString", "(", "@", "Nonnull", "@", "Nonempty", "final", "String", "sCountryCode", ",", "@", "Nonnegative", "final", "int", "nExpectedLength", ",", "@", "Nullable", "final", "String", "sLayout", ",", "@", "Nullable", "final", "String", "sFixedCheckDigits", ",", "@", "Nullable", "final", "LocalDate", "aValidFrom", ",", "@", "Nullable", "final", "LocalDate", "aValidTo", ",", "@", "Nonnull", "final", "String", "sDesc", ")", "{", "ValueEnforcer", ".", "notEmpty", "(", "sDesc", ",", "\"Desc\"", ")", ";", "if", "(", "sDesc", ".", "length", "(", ")", "<", "4", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot converted passed string because it is too short!\"", ")", ";", "final", "ICommonsList", "<", "IBANElement", ">", "aList", "=", "_parseElements", "(", "sDesc", ")", ";", "final", "Pattern", "aPattern", "=", "_parseLayout", "(", "sCountryCode", ",", "nExpectedLength", ",", "sFixedCheckDigits", ",", "sLayout", ")", ";", "// And we're done", "try", "{", "return", "new", "IBANCountryData", "(", "nExpectedLength", ",", "aPattern", ",", "sFixedCheckDigits", ",", "aValidFrom", ",", "aValidTo", ",", "aList", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "ex", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Failed to parse '\"", "+", "sDesc", "+", "\"': \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
This method is used to create an instance of this class from a string representation. @param sCountryCode Country code to use. Neither <code>null</code> nor empty. @param nExpectedLength The expected length having only validation purpose. @param sLayout <code>null</code> or the layout descriptor @param sFixedCheckDigits <code>null</code> or fixed check digits (of length 2) @param aValidFrom Validity start date. May be <code>null</code>. @param aValidTo Validity end date. May be <code>null</code>. @param sDesc The string description of this country data. May not be <code>null</code>. @return The parsed county data.
[ "This", "method", "is", "used", "to", "create", "an", "instance", "of", "this", "class", "from", "a", "string", "representation", "." ]
train
https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/swift/IBANCountryData.java#L319-L345
febit/wit
wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java
AbstractLoader.concat
@Override public String concat(final String parent, final String name) { return parent != null ? FileNameUtil.concat(FileNameUtil.getPath(parent), name) : name; }
java
@Override public String concat(final String parent, final String name) { return parent != null ? FileNameUtil.concat(FileNameUtil.getPath(parent), name) : name; }
[ "@", "Override", "public", "String", "concat", "(", "final", "String", "parent", ",", "final", "String", "name", ")", "{", "return", "parent", "!=", "null", "?", "FileNameUtil", ".", "concat", "(", "FileNameUtil", ".", "getPath", "(", "parent", ")", ",", "name", ")", ":", "name", ";", "}" ]
get child template name by parent template name and relative name. <pre> example: /path/to/tmpl1.wit , tmpl2.wit =&gt; /path/to/tmpl2.wit /path/to/tmpl1.wit , /tmpl2.wit =&gt; /tmpl2.wit /path/to/tmpl1.wit , ./tmpl2.wit =&gt; /path/to/tmpl2.wit /path/to/tmpl1.wit , ../tmpl2.wit =&gt; /path/tmpl2.wit </pre> @param parent parent template's name @param name relative name @return child template's name
[ "get", "child", "template", "name", "by", "parent", "template", "name", "and", "relative", "name", "." ]
train
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java#L43-L48
ansell/restlet-utils
src/main/java/com/github/ansell/restletutils/FixedRedirectCookieAuthenticator.java
FixedRedirectCookieAuthenticator.isLoggingOut
protected boolean isLoggingOut(final Request request, final Response response) { return this.isInterceptingLogout() && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false)) && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod())); }
java
protected boolean isLoggingOut(final Request request, final Response response) { return this.isInterceptingLogout() && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false)) && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod())); }
[ "protected", "boolean", "isLoggingOut", "(", "final", "Request", "request", ",", "final", "Response", "response", ")", "{", "return", "this", ".", "isInterceptingLogout", "(", ")", "&&", "this", ".", "getLogoutPath", "(", ")", ".", "equals", "(", "request", ".", "getResourceRef", "(", ")", ".", "getRemainingPart", "(", "false", ",", "false", ")", ")", "&&", "(", "Method", ".", "GET", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ")", "||", "Method", ".", "POST", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ")", ")", ";", "}" ]
Indicates if the request is an attempt to log out and should be intercepted. @param request The current request. @param response The current response. @return True if the request is an attempt to log out and should be intercepted.
[ "Indicates", "if", "the", "request", "is", "an", "attempt", "to", "log", "out", "and", "should", "be", "intercepted", "." ]
train
https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/FixedRedirectCookieAuthenticator.java#L608-L613
deeplearning4j/deeplearning4j
datavec/datavec-spark/src/main/java/org/datavec/spark/transform/AnalyzeSpark.java
AnalyzeSpark.analyzeQualitySequence
public static DataQualityAnalysis analyzeQualitySequence(Schema schema, JavaRDD<List<List<Writable>>> data) { JavaRDD<List<Writable>> fmSeq = data.flatMap(new SequenceFlatMapFunction()); return analyzeQuality(schema, fmSeq); }
java
public static DataQualityAnalysis analyzeQualitySequence(Schema schema, JavaRDD<List<List<Writable>>> data) { JavaRDD<List<Writable>> fmSeq = data.flatMap(new SequenceFlatMapFunction()); return analyzeQuality(schema, fmSeq); }
[ "public", "static", "DataQualityAnalysis", "analyzeQualitySequence", "(", "Schema", "schema", ",", "JavaRDD", "<", "List", "<", "List", "<", "Writable", ">", ">", ">", "data", ")", "{", "JavaRDD", "<", "List", "<", "Writable", ">>", "fmSeq", "=", "data", ".", "flatMap", "(", "new", "SequenceFlatMapFunction", "(", ")", ")", ";", "return", "analyzeQuality", "(", "schema", ",", "fmSeq", ")", ";", "}" ]
Analyze the data quality of sequence data - provides a report on missing values, values that don't comply with schema, etc @param schema Schema for data @param data Data to analyze @return DataQualityAnalysis object
[ "Analyze", "the", "data", "quality", "of", "sequence", "data", "-", "provides", "a", "report", "on", "missing", "values", "values", "that", "don", "t", "comply", "with", "schema", "etc" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/transform/AnalyzeSpark.java#L277-L280
Azure/azure-sdk-for-java
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
KeyVaultClientBaseImpl.getCertificateOperationAsync
public Observable<CertificateOperation> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1<ServiceResponse<CertificateOperation>, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse<CertificateOperation> response) { return response.body(); } }); }
java
public Observable<CertificateOperation> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1<ServiceResponse<CertificateOperation>, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse<CertificateOperation> response) { return response.body(); } }); }
[ "public", "Observable", "<", "CertificateOperation", ">", "getCertificateOperationAsync", "(", "String", "vaultBaseUrl", ",", "String", "certificateName", ")", "{", "return", "getCertificateOperationWithServiceResponseAsync", "(", "vaultBaseUrl", ",", "certificateName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "CertificateOperation", ">", ",", "CertificateOperation", ">", "(", ")", "{", "@", "Override", "public", "CertificateOperation", "call", "(", "ServiceResponse", "<", "CertificateOperation", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Gets the creation operation of a certificate. Gets the creation operation associated with a specified certificate. This operation requires the certificates/get permission. @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. @param certificateName The name of the certificate. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the CertificateOperation object
[ "Gets", "the", "creation", "operation", "of", "a", "certificate", ".", "Gets", "the", "creation", "operation", "associated", "with", "a", "specified", "certificate", ".", "This", "operation", "requires", "the", "certificates", "/", "get", "permission", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L7761-L7768
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
SpiceServiceListenerNotifier.notifyObserversOfRequestAggregated
public void notifyObserversOfRequestAggregated(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAggregatedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
java
public void notifyObserversOfRequestAggregated(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAggregatedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
[ "public", "void", "notifyObserversOfRequestAggregated", "(", "CachedSpiceRequest", "<", "?", ">", "request", ",", "Set", "<", "RequestListener", "<", "?", ">", ">", "requestListeners", ")", "{", "RequestProcessingContext", "requestProcessingContext", "=", "new", "RequestProcessingContext", "(", ")", ";", "requestProcessingContext", ".", "setExecutionThread", "(", "Thread", ".", "currentThread", "(", ")", ")", ";", "requestProcessingContext", ".", "setRequestListeners", "(", "requestListeners", ")", ";", "post", "(", "new", "RequestAggregatedNotifier", "(", "request", ",", "spiceServiceListenerList", ",", "requestProcessingContext", ")", ")", ";", "}" ]
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that has been aggregated.
[ "Inform", "the", "observers", "of", "a", "request", ".", "The", "observers", "can", "optionally", "observe", "the", "new", "request", "if", "required", "." ]
train
https://github.com/stephanenicolas/robospice/blob/8bffde88b3534a961a13cab72a8f07a755f0a0fe/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java#L79-L84
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/Cluster.java
Cluster.writeToText
@Override public void writeToText(TextWriterStream out, String label) { String name = getNameAutomatic(); if(name != null) { out.commentPrintLn("Cluster name: " + name); } out.commentPrintLn("Cluster noise flag: " + isNoise()); out.commentPrintLn("Cluster size: " + ids.size()); // also print model, if any and printable if(getModel() != null && (getModel() instanceof TextWriteable)) { ((TextWriteable) getModel()).writeToText(out, label); } }
java
@Override public void writeToText(TextWriterStream out, String label) { String name = getNameAutomatic(); if(name != null) { out.commentPrintLn("Cluster name: " + name); } out.commentPrintLn("Cluster noise flag: " + isNoise()); out.commentPrintLn("Cluster size: " + ids.size()); // also print model, if any and printable if(getModel() != null && (getModel() instanceof TextWriteable)) { ((TextWriteable) getModel()).writeToText(out, label); } }
[ "@", "Override", "public", "void", "writeToText", "(", "TextWriterStream", "out", ",", "String", "label", ")", "{", "String", "name", "=", "getNameAutomatic", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "out", ".", "commentPrintLn", "(", "\"Cluster name: \"", "+", "name", ")", ";", "}", "out", ".", "commentPrintLn", "(", "\"Cluster noise flag: \"", "+", "isNoise", "(", ")", ")", ";", "out", ".", "commentPrintLn", "(", "\"Cluster size: \"", "+", "ids", ".", "size", "(", ")", ")", ";", "// also print model, if any and printable", "if", "(", "getModel", "(", ")", "!=", "null", "&&", "(", "getModel", "(", ")", "instanceof", "TextWriteable", ")", ")", "{", "(", "(", "TextWriteable", ")", "getModel", "(", ")", ")", ".", "writeToText", "(", "out", ",", "label", ")", ";", "}", "}" ]
Write to a textual representation. Writing the actual group data will be handled by the caller, this is only meant to write the meta information. @param out output writer stream @param label Label to prefix
[ "Write", "to", "a", "textual", "representation", ".", "Writing", "the", "actual", "group", "data", "will", "be", "handled", "by", "the", "caller", "this", "is", "only", "meant", "to", "write", "the", "meta", "information", "." ]
train
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/Cluster.java#L247-L259
OpenLiberty/open-liberty
dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAEMPool.java
JPAEMPool.createEntityManager
@Override public EntityManager createEntityManager() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "createEntityManager : " + this); EntityManager em = getEntityManager(false, false); JPAPooledEntityManager pem = new JPAPooledEntityManager(this, em, ivAbstractJpaComponent, true); return pem; }
java
@Override public EntityManager createEntityManager() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "createEntityManager : " + this); EntityManager em = getEntityManager(false, false); JPAPooledEntityManager pem = new JPAPooledEntityManager(this, em, ivAbstractJpaComponent, true); return pem; }
[ "@", "Override", "public", "EntityManager", "createEntityManager", "(", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"createEntityManager : \"", "+", "this", ")", ";", "EntityManager", "em", "=", "getEntityManager", "(", "false", ",", "false", ")", ";", "JPAPooledEntityManager", "pem", "=", "new", "JPAPooledEntityManager", "(", "this", ",", "em", ",", "ivAbstractJpaComponent", ",", "true", ")", ";", "return", "pem", ";", "}" ]
Gets entity manager from pool and wraps it in an invocation type aware, enlistment capable em.
[ "Gets", "entity", "manager", "from", "pool", "and", "wraps", "it", "in", "an", "invocation", "type", "aware", "enlistment", "capable", "em", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAEMPool.java#L262-L271
alexvasilkov/AndroidCommons
library/src/main/java/com/alexvasilkov/android/commons/prefs/PreferencesHelper.java
PreferencesHelper.getJson
@Nullable public static <T> T getJson(@NonNull SharedPreferences prefs, @NonNull String key, @NonNull Class<T> clazz) { return getJson(prefs, key, (Type) clazz); }
java
@Nullable public static <T> T getJson(@NonNull SharedPreferences prefs, @NonNull String key, @NonNull Class<T> clazz) { return getJson(prefs, key, (Type) clazz); }
[ "@", "Nullable", "public", "static", "<", "T", ">", "T", "getJson", "(", "@", "NonNull", "SharedPreferences", "prefs", ",", "@", "NonNull", "String", "key", ",", "@", "NonNull", "Class", "<", "T", ">", "clazz", ")", "{", "return", "getJson", "(", "prefs", ",", "key", ",", "(", "Type", ")", "clazz", ")", ";", "}" ]
Retrieves object stored as json encoded string. Gson library should be available in classpath.
[ "Retrieves", "object", "stored", "as", "json", "encoded", "string", ".", "Gson", "library", "should", "be", "available", "in", "classpath", "." ]
train
https://github.com/alexvasilkov/AndroidCommons/blob/aca9f6d5acfc6bd3694984b7f89956e1a0146ddb/library/src/main/java/com/alexvasilkov/android/commons/prefs/PreferencesHelper.java#L140-L144
Domo42/saga-lib
saga-lib-guice/src/main/java/com/codebullets/sagalib/guice/SagaLibModule.java
SagaLibModule.bindIfNotNull
private <T> void bindIfNotNull(final Class<T> interfaceType, @Nullable final Class<? extends T> implementationType) { if (implementationType != null) { bind(interfaceType).to(implementationType); } }
java
private <T> void bindIfNotNull(final Class<T> interfaceType, @Nullable final Class<? extends T> implementationType) { if (implementationType != null) { bind(interfaceType).to(implementationType); } }
[ "private", "<", "T", ">", "void", "bindIfNotNull", "(", "final", "Class", "<", "T", ">", "interfaceType", ",", "@", "Nullable", "final", "Class", "<", "?", "extends", "T", ">", "implementationType", ")", "{", "if", "(", "implementationType", "!=", "null", ")", "{", "bind", "(", "interfaceType", ")", ".", "to", "(", "implementationType", ")", ";", "}", "}" ]
Perform binding to interface only if implementation type is not null.
[ "Perform", "binding", "to", "interface", "only", "if", "implementation", "type", "is", "not", "null", "." ]
train
https://github.com/Domo42/saga-lib/blob/c8f232e2a51fcb6a3fe0082cfbf105c1e6bf90ef/saga-lib-guice/src/main/java/com/codebullets/sagalib/guice/SagaLibModule.java#L155-L159
strator-dev/greenpepper
greenpepper-open/greenpepper-maven-runner/src/main/java/com/greenpepper/maven/runner/util/ReflectionUtils.java
ReflectionUtils.setSystemOutputs
public static void setSystemOutputs(ClassLoader classLoader, PrintStream out, PrintStream err) throws Exception { Class<?> systemClass = classLoader.loadClass("java.lang.System"); Method setSystemOutMethod = systemClass.getMethod("setOut", PrintStream.class); setSystemOutMethod.invoke(null, out); Method setSystemErrMethod = systemClass.getMethod("setErr", PrintStream.class); setSystemErrMethod.invoke(null, err); }
java
public static void setSystemOutputs(ClassLoader classLoader, PrintStream out, PrintStream err) throws Exception { Class<?> systemClass = classLoader.loadClass("java.lang.System"); Method setSystemOutMethod = systemClass.getMethod("setOut", PrintStream.class); setSystemOutMethod.invoke(null, out); Method setSystemErrMethod = systemClass.getMethod("setErr", PrintStream.class); setSystemErrMethod.invoke(null, err); }
[ "public", "static", "void", "setSystemOutputs", "(", "ClassLoader", "classLoader", ",", "PrintStream", "out", ",", "PrintStream", "err", ")", "throws", "Exception", "{", "Class", "<", "?", ">", "systemClass", "=", "classLoader", ".", "loadClass", "(", "\"java.lang.System\"", ")", ";", "Method", "setSystemOutMethod", "=", "systemClass", ".", "getMethod", "(", "\"setOut\"", ",", "PrintStream", ".", "class", ")", ";", "setSystemOutMethod", ".", "invoke", "(", "null", ",", "out", ")", ";", "Method", "setSystemErrMethod", "=", "systemClass", ".", "getMethod", "(", "\"setErr\"", ",", "PrintStream", ".", "class", ")", ";", "setSystemErrMethod", ".", "invoke", "(", "null", ",", "err", ")", ";", "}" ]
<p>setSystemOutputs.</p> @param classLoader a {@link java.lang.ClassLoader} object. @param out a {@link java.io.PrintStream} object. @param err a {@link java.io.PrintStream} object. @throws java.lang.Exception if any.
[ "<p", ">", "setSystemOutputs", ".", "<", "/", "p", ">" ]
train
https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper-open/greenpepper-maven-runner/src/main/java/com/greenpepper/maven/runner/util/ReflectionUtils.java#L89-L97
intuit/QuickBooks-V3-Java-SDK
ipp-v3-java-devkit/src/main/java/com/intuit/ipp/interceptors/PrepareRequestInterceptor.java
PrepareRequestInterceptor.getUri
private <T extends IEntity> String getUri(Boolean platformService, String action, Context context, Map<String, String> requestParameters, Boolean entitlementService) throws FMSException { String uri = null; if (!platformService) { ServiceType serviceType = context.getIntuitServiceType(); if (entitlementService) { uri = prepareEntitlementUri(context); } else if (ServiceType.QBO == serviceType) { uri = prepareQBOUri(action, context, requestParameters); } else if (ServiceType.QBOPremier == serviceType) { uri = prepareQBOPremierUri(action, context, requestParameters); } else { throw new FMSException("SDK doesn't support for the service type : " + serviceType); } } else { uri = prepareIPSUri(action, context); } return uri; }
java
private <T extends IEntity> String getUri(Boolean platformService, String action, Context context, Map<String, String> requestParameters, Boolean entitlementService) throws FMSException { String uri = null; if (!platformService) { ServiceType serviceType = context.getIntuitServiceType(); if (entitlementService) { uri = prepareEntitlementUri(context); } else if (ServiceType.QBO == serviceType) { uri = prepareQBOUri(action, context, requestParameters); } else if (ServiceType.QBOPremier == serviceType) { uri = prepareQBOPremierUri(action, context, requestParameters); } else { throw new FMSException("SDK doesn't support for the service type : " + serviceType); } } else { uri = prepareIPSUri(action, context); } return uri; }
[ "private", "<", "T", "extends", "IEntity", ">", "String", "getUri", "(", "Boolean", "platformService", ",", "String", "action", ",", "Context", "context", ",", "Map", "<", "String", ",", "String", ">", "requestParameters", ",", "Boolean", "entitlementService", ")", "throws", "FMSException", "{", "String", "uri", "=", "null", ";", "if", "(", "!", "platformService", ")", "{", "ServiceType", "serviceType", "=", "context", ".", "getIntuitServiceType", "(", ")", ";", "if", "(", "entitlementService", ")", "{", "uri", "=", "prepareEntitlementUri", "(", "context", ")", ";", "}", "else", "if", "(", "ServiceType", ".", "QBO", "==", "serviceType", ")", "{", "uri", "=", "prepareQBOUri", "(", "action", ",", "context", ",", "requestParameters", ")", ";", "}", "else", "if", "(", "ServiceType", ".", "QBOPremier", "==", "serviceType", ")", "{", "uri", "=", "prepareQBOPremierUri", "(", "action", ",", "context", ",", "requestParameters", ")", ";", "}", "else", "{", "throw", "new", "FMSException", "(", "\"SDK doesn't support for the service type : \"", "+", "serviceType", ")", ";", "}", "}", "else", "{", "uri", "=", "prepareIPSUri", "(", "action", ",", "context", ")", ";", "}", "return", "uri", ";", "}" ]
Method to construct the URI @param action the entity name @param context the context @param requestParameters the request params @return returns URI
[ "Method", "to", "construct", "the", "URI" ]
train
https://github.com/intuit/QuickBooks-V3-Java-SDK/blob/59f988d0776d46620d0b34711c411b2b5b1da06b/ipp-v3-java-devkit/src/main/java/com/intuit/ipp/interceptors/PrepareRequestInterceptor.java#L229-L250
OpenLiberty/open-liberty
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/util/MessageDigestUtility.java
MessageDigestUtility.processMessageDigestForData
public static String processMessageDigestForData(MessageDigest messageDigest, byte[] data) { String output = ""; //$NON-NLS-1$ if (messageDigest != null) { // Get the digest for the given data messageDigest.update(data); byte[] digest = messageDigest.digest(); output = Base64Coder.encode(digest); } return output; }
java
public static String processMessageDigestForData(MessageDigest messageDigest, byte[] data) { String output = ""; //$NON-NLS-1$ if (messageDigest != null) { // Get the digest for the given data messageDigest.update(data); byte[] digest = messageDigest.digest(); output = Base64Coder.encode(digest); } return output; }
[ "public", "static", "String", "processMessageDigestForData", "(", "MessageDigest", "messageDigest", ",", "byte", "[", "]", "data", ")", "{", "String", "output", "=", "\"\"", ";", "//$NON-NLS-1$", "if", "(", "messageDigest", "!=", "null", ")", "{", "// Get the digest for the given data", "messageDigest", ".", "update", "(", "data", ")", ";", "byte", "[", "]", "digest", "=", "messageDigest", ".", "digest", "(", ")", ";", "output", "=", "Base64Coder", ".", "encode", "(", "digest", ")", ";", "}", "return", "output", ";", "}" ]
Calculate the digest specified by byte array of data @param messageDigest @param data @return digest in string with base64 encoding.
[ "Calculate", "the", "digest", "specified", "by", "byte", "array", "of", "data" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/util/MessageDigestUtility.java#L42-L51
ogaclejapan/SmartTabLayout
library/src/main/java/com/ogaclejapan/smarttablayout/SmartTabStrip.java
SmartTabStrip.setColorAlpha
private static int setColorAlpha(int color, byte alpha) { return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); }
java
private static int setColorAlpha(int color, byte alpha) { return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); }
[ "private", "static", "int", "setColorAlpha", "(", "int", "color", ",", "byte", "alpha", ")", "{", "return", "Color", ".", "argb", "(", "alpha", ",", "Color", ".", "red", "(", "color", ")", ",", "Color", ".", "green", "(", "color", ")", ",", "Color", ".", "blue", "(", "color", ")", ")", ";", "}" ]
Set the alpha value of the {@code color} to be the given {@code alpha} value.
[ "Set", "the", "alpha", "value", "of", "the", "{" ]
train
https://github.com/ogaclejapan/SmartTabLayout/blob/712e81a92f1e12a3c33dcbda03d813e0162e8589/library/src/main/java/com/ogaclejapan/smarttablayout/SmartTabStrip.java#L193-L195
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLAC_ConsoleFileEncoder.java
FLAC_ConsoleFileEncoder.getInt
int getInt(String[] args, int index) { int result = -1; if(index >= 0 && index < args.length) { try { result = Integer.parseInt(args[index]); }catch(NumberFormatException e) { result = -1; } } return result; }
java
int getInt(String[] args, int index) { int result = -1; if(index >= 0 && index < args.length) { try { result = Integer.parseInt(args[index]); }catch(NumberFormatException e) { result = -1; } } return result; }
[ "int", "getInt", "(", "String", "[", "]", "args", ",", "int", "index", ")", "{", "int", "result", "=", "-", "1", ";", "if", "(", "index", ">=", "0", "&&", "index", "<", "args", ".", "length", ")", "{", "try", "{", "result", "=", "Integer", ".", "parseInt", "(", "args", "[", "index", "]", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "result", "=", "-", "1", ";", "}", "}", "return", "result", ";", "}" ]
Utility function to parse a positive integer argument out of a String array at the given index. @param args String array containing element to find. @param index Index of array element to parse integer from. @return Integer parsed, or -1 if error.
[ "Utility", "function", "to", "parse", "a", "positive", "integer", "argument", "out", "of", "a", "String", "array", "at", "the", "given", "index", "." ]
train
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLAC_ConsoleFileEncoder.java#L328-L338
JodaOrg/joda-time
src/main/java/org/joda/time/convert/ReadableIntervalConverter.java
ReadableIntervalConverter.setInto
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableInterval interval = (ReadableInterval) object; chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval)); long start = interval.getStartMillis(); long end = interval.getEndMillis(); int[] values = chrono.get(writablePeriod, start, end); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
java
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableInterval interval = (ReadableInterval) object; chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval)); long start = interval.getStartMillis(); long end = interval.getEndMillis(); int[] values = chrono.get(writablePeriod, start, end); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
[ "public", "void", "setInto", "(", "ReadWritablePeriod", "writablePeriod", ",", "Object", "object", ",", "Chronology", "chrono", ")", "{", "ReadableInterval", "interval", "=", "(", "ReadableInterval", ")", "object", ";", "chrono", "=", "(", "chrono", "!=", "null", "?", "chrono", ":", "DateTimeUtils", ".", "getIntervalChronology", "(", "interval", ")", ")", ";", "long", "start", "=", "interval", ".", "getStartMillis", "(", ")", ";", "long", "end", "=", "interval", ".", "getEndMillis", "(", ")", ";", "int", "[", "]", "values", "=", "chrono", ".", "get", "(", "writablePeriod", ",", "start", ",", "end", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "writablePeriod", ".", "setValue", "(", "i", ",", "values", "[", "i", "]", ")", ";", "}", "}" ]
Sets the values of the mutable duration from the specified interval. @param writablePeriod the period to modify @param object the interval to set from @param chrono the chronology to use
[ "Sets", "the", "values", "of", "the", "mutable", "duration", "from", "the", "specified", "interval", "." ]
train
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadableIntervalConverter.java#L63-L72
highsource/jaxb2-basics
tools/src/main/java/org/jvnet/jaxb2_commons/plugin/AbstractParameterizablePlugin.java
AbstractParameterizablePlugin.parseArgument
public int parseArgument(Options opt, String[] args, int start) throws BadCommandLineException, IOException { int consumed = 0; final String optionPrefix = "-" + getOptionName() + "-"; final int optionPrefixLength = optionPrefix.length(); final String arg = args[start]; final int equalsPosition = arg.indexOf('='); if (arg.startsWith(optionPrefix) && equalsPosition > optionPrefixLength) { final String propertyName = arg.substring(optionPrefixLength, equalsPosition); final String value = arg.substring(equalsPosition + 1); consumed++; try { BeanUtils.setProperty(this, propertyName, value); } catch (Exception ex) { ex.printStackTrace(); throw new BadCommandLineException("Error setting property [" + propertyName + "], value [" + value + "]."); } } return consumed; }
java
public int parseArgument(Options opt, String[] args, int start) throws BadCommandLineException, IOException { int consumed = 0; final String optionPrefix = "-" + getOptionName() + "-"; final int optionPrefixLength = optionPrefix.length(); final String arg = args[start]; final int equalsPosition = arg.indexOf('='); if (arg.startsWith(optionPrefix) && equalsPosition > optionPrefixLength) { final String propertyName = arg.substring(optionPrefixLength, equalsPosition); final String value = arg.substring(equalsPosition + 1); consumed++; try { BeanUtils.setProperty(this, propertyName, value); } catch (Exception ex) { ex.printStackTrace(); throw new BadCommandLineException("Error setting property [" + propertyName + "], value [" + value + "]."); } } return consumed; }
[ "public", "int", "parseArgument", "(", "Options", "opt", ",", "String", "[", "]", "args", ",", "int", "start", ")", "throws", "BadCommandLineException", ",", "IOException", "{", "int", "consumed", "=", "0", ";", "final", "String", "optionPrefix", "=", "\"-\"", "+", "getOptionName", "(", ")", "+", "\"-\"", ";", "final", "int", "optionPrefixLength", "=", "optionPrefix", ".", "length", "(", ")", ";", "final", "String", "arg", "=", "args", "[", "start", "]", ";", "final", "int", "equalsPosition", "=", "arg", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "arg", ".", "startsWith", "(", "optionPrefix", ")", "&&", "equalsPosition", ">", "optionPrefixLength", ")", "{", "final", "String", "propertyName", "=", "arg", ".", "substring", "(", "optionPrefixLength", ",", "equalsPosition", ")", ";", "final", "String", "value", "=", "arg", ".", "substring", "(", "equalsPosition", "+", "1", ")", ";", "consumed", "++", ";", "try", "{", "BeanUtils", ".", "setProperty", "(", "this", ",", "propertyName", ",", "value", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "throw", "new", "BadCommandLineException", "(", "\"Error setting property [\"", "+", "propertyName", "+", "\"], value [\"", "+", "value", "+", "\"].\"", ")", ";", "}", "}", "return", "consumed", ";", "}" ]
Parses the arguments and injects values into the beans via properties.
[ "Parses", "the", "arguments", "and", "injects", "values", "into", "the", "beans", "via", "properties", "." ]
train
https://github.com/highsource/jaxb2-basics/blob/571cca0ce58a75d984324d33d8af453bf5862e75/tools/src/main/java/org/jvnet/jaxb2_commons/plugin/AbstractParameterizablePlugin.java#L29-L54