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
pryzach/midao
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java
BaseMetadataHandler.processProcedureName
private String processProcedureName(String dbProductName, String procedureName) { String result = null; if (procedureName != null) { if ("Microsoft SQL Server".equals(dbProductName) == true || "Sybase".equals(dbProductName) == true) { if ("Microsoft SQL Server".equals(dbProductName) == true && procedureName.indexOf(";") > 1) { result = procedureName.substring(0, procedureName.indexOf(";")).toUpperCase(); } else if (procedureName.length() > 1 && procedureName.startsWith("@") == true) { result = procedureName.substring(1).toUpperCase(); } else { result = procedureName.toUpperCase(); } } else if ("PostgreSQL".equals(dbProductName) == true) { result = procedureName.toLowerCase(); } else { result = procedureName.toUpperCase(); } } return result; }
java
private String processProcedureName(String dbProductName, String procedureName) { String result = null; if (procedureName != null) { if ("Microsoft SQL Server".equals(dbProductName) == true || "Sybase".equals(dbProductName) == true) { if ("Microsoft SQL Server".equals(dbProductName) == true && procedureName.indexOf(";") > 1) { result = procedureName.substring(0, procedureName.indexOf(";")).toUpperCase(); } else if (procedureName.length() > 1 && procedureName.startsWith("@") == true) { result = procedureName.substring(1).toUpperCase(); } else { result = procedureName.toUpperCase(); } } else if ("PostgreSQL".equals(dbProductName) == true) { result = procedureName.toLowerCase(); } else { result = procedureName.toUpperCase(); } } return result; }
[ "private", "String", "processProcedureName", "(", "String", "dbProductName", ",", "String", "procedureName", ")", "{", "String", "result", "=", "null", ";", "if", "(", "procedureName", "!=", "null", ")", "{", "if", "(", "\"Microsoft SQL Server\"", ".", "equals", "(", "dbProductName", ")", "==", "true", "||", "\"Sybase\"", ".", "equals", "(", "dbProductName", ")", "==", "true", ")", "{", "if", "(", "\"Microsoft SQL Server\"", ".", "equals", "(", "dbProductName", ")", "==", "true", "&&", "procedureName", ".", "indexOf", "(", "\";\"", ")", ">", "1", ")", "{", "result", "=", "procedureName", ".", "substring", "(", "0", ",", "procedureName", ".", "indexOf", "(", "\";\"", ")", ")", ".", "toUpperCase", "(", ")", ";", "}", "else", "if", "(", "procedureName", ".", "length", "(", ")", ">", "1", "&&", "procedureName", ".", "startsWith", "(", "\"@\"", ")", "==", "true", ")", "{", "result", "=", "procedureName", ".", "substring", "(", "1", ")", ".", "toUpperCase", "(", ")", ";", "}", "else", "{", "result", "=", "procedureName", ".", "toUpperCase", "(", ")", ";", "}", "}", "else", "if", "(", "\"PostgreSQL\"", ".", "equals", "(", "dbProductName", ")", "==", "true", ")", "{", "result", "=", "procedureName", ".", "toLowerCase", "(", ")", ";", "}", "else", "{", "result", "=", "procedureName", ".", "toUpperCase", "(", ")", ";", "}", "}", "return", "result", ";", "}" ]
Processes Procedure/Function name so it would be compatible with database Also is responsible for cleaning procedure name returned by DatabaseMetadata @param dbProductName short database name @param procedureName Stored Procedure/Function @return processed Procedure/Function name
[ "Processes", "Procedure", "/", "Function", "name", "so", "it", "would", "be", "compatible", "with", "database", "Also", "is", "responsible", "for", "cleaning", "procedure", "name", "returned", "by", "DatabaseMetadata" ]
train
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java#L279-L299
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/Qualifier.java
Qualifier.asString
public static String asString(String namespace, String action) { return DELIMITER + namespace + DELIMITER + action; }
java
public static String asString(String namespace, String action) { return DELIMITER + namespace + DELIMITER + action; }
[ "public", "static", "String", "asString", "(", "String", "namespace", ",", "String", "action", ")", "{", "return", "DELIMITER", "+", "namespace", "+", "DELIMITER", "+", "action", ";", "}" ]
Builds qualifier string out of given namespace and action. @param namespace qualifier namespace. @param action qualifier action. @return constructed qualifier.
[ "Builds", "qualifier", "string", "out", "of", "given", "namespace", "and", "action", "." ]
train
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/Qualifier.java#L27-L29
UrielCh/ovh-java-sdk
ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java
ApiOvhXdsl.serviceName_modem_reset_POST
public OvhTask serviceName_modem_reset_POST(String serviceName, Boolean resetOvhConfig) throws IOException { String qPath = "/xdsl/{serviceName}/modem/reset"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "resetOvhConfig", resetOvhConfig); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
java
public OvhTask serviceName_modem_reset_POST(String serviceName, Boolean resetOvhConfig) throws IOException { String qPath = "/xdsl/{serviceName}/modem/reset"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "resetOvhConfig", resetOvhConfig); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
[ "public", "OvhTask", "serviceName_modem_reset_POST", "(", "String", "serviceName", ",", "Boolean", "resetOvhConfig", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/xdsl/{serviceName}/modem/reset\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"resetOvhConfig\"", ",", "resetOvhConfig", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhTask", ".", "class", ")", ";", "}" ]
Reset the modem to its default configuration REST: POST /xdsl/{serviceName}/modem/reset @param resetOvhConfig [required] Reset configuration stored in OVH databases @param serviceName [required] The internal name of your XDSL offer
[ "Reset", "the", "modem", "to", "its", "default", "configuration" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L1257-L1264
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/SwingUtils.java
SwingUtils.getDescendantNamed
public static Component getDescendantNamed(String name, Component parent) { Assert.notNull(name, "name"); Assert.notNull(parent, "parent"); if (name.equals(parent.getName())) { // Base case return parent; } else if (parent instanceof Container) { // Recursive case for (final Component component : ((Container) parent).getComponents()) { final Component foundComponent = SwingUtils.getDescendantNamed(name, component); if (foundComponent != null) { return foundComponent; } } } return null; }
java
public static Component getDescendantNamed(String name, Component parent) { Assert.notNull(name, "name"); Assert.notNull(parent, "parent"); if (name.equals(parent.getName())) { // Base case return parent; } else if (parent instanceof Container) { // Recursive case for (final Component component : ((Container) parent).getComponents()) { final Component foundComponent = SwingUtils.getDescendantNamed(name, component); if (foundComponent != null) { return foundComponent; } } } return null; }
[ "public", "static", "Component", "getDescendantNamed", "(", "String", "name", ",", "Component", "parent", ")", "{", "Assert", ".", "notNull", "(", "name", ",", "\"name\"", ")", ";", "Assert", ".", "notNull", "(", "parent", ",", "\"parent\"", ")", ";", "if", "(", "name", ".", "equals", "(", "parent", ".", "getName", "(", ")", ")", ")", "{", "// Base case", "return", "parent", ";", "}", "else", "if", "(", "parent", "instanceof", "Container", ")", "{", "// Recursive case", "for", "(", "final", "Component", "component", ":", "(", "(", "Container", ")", "parent", ")", ".", "getComponents", "(", ")", ")", "{", "final", "Component", "foundComponent", "=", "SwingUtils", ".", "getDescendantNamed", "(", "name", ",", "component", ")", ";", "if", "(", "foundComponent", "!=", "null", ")", "{", "return", "foundComponent", ";", "}", "}", "}", "return", "null", ";", "}" ]
Does a pre-order search of a component with a given name. @param name the name. @param parent the root component in hierarchy. @return the found component (may be null).
[ "Does", "a", "pre", "-", "order", "search", "of", "a", "component", "with", "a", "given", "name", "." ]
train
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/SwingUtils.java#L90-L109
Azure/azure-sdk-for-java
notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java
NotificationHubsInner.getPnsCredentials
public PnsCredentialsResourceInner getPnsCredentials(String resourceGroupName, String namespaceName, String notificationHubName) { return getPnsCredentialsWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName).toBlocking().single().body(); }
java
public PnsCredentialsResourceInner getPnsCredentials(String resourceGroupName, String namespaceName, String notificationHubName) { return getPnsCredentialsWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName).toBlocking().single().body(); }
[ "public", "PnsCredentialsResourceInner", "getPnsCredentials", "(", "String", "resourceGroupName", ",", "String", "namespaceName", ",", "String", "notificationHubName", ")", "{", "return", "getPnsCredentialsWithServiceResponseAsync", "(", "resourceGroupName", ",", "namespaceName", ",", "notificationHubName", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Lists the PNS Credentials associated with a notification hub . @param resourceGroupName The name of the resource group. @param namespaceName The namespace name. @param notificationHubName The notification hub name. @throws IllegalArgumentException thrown if parameters fail the validation @throws CloudException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @return the PnsCredentialsResourceInner object if successful.
[ "Lists", "the", "PNS", "Credentials", "associated", "with", "a", "notification", "hub", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java#L1765-L1767
duracloud/duracloud
durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java
SpaceRest.getSpaceACLs
@Path("/acl/{spaceID}") @HEAD public Response getSpaceACLs(@PathParam("spaceID") String spaceID, @QueryParam("storeID") String storeID) { String msg = "getting space ACLs(" + spaceID + ", " + storeID + ")"; try { log.debug(msg); return addSpaceACLsToResponse(Response.ok(), spaceID, storeID); } catch (ResourceNotFoundException e) { return responseNotFound(msg, e, NOT_FOUND); } catch (ResourceException e) { return responseBad(msg, e, INTERNAL_SERVER_ERROR); } catch (Exception e) { return responseBad(msg, e, INTERNAL_SERVER_ERROR); } }
java
@Path("/acl/{spaceID}") @HEAD public Response getSpaceACLs(@PathParam("spaceID") String spaceID, @QueryParam("storeID") String storeID) { String msg = "getting space ACLs(" + spaceID + ", " + storeID + ")"; try { log.debug(msg); return addSpaceACLsToResponse(Response.ok(), spaceID, storeID); } catch (ResourceNotFoundException e) { return responseNotFound(msg, e, NOT_FOUND); } catch (ResourceException e) { return responseBad(msg, e, INTERNAL_SERVER_ERROR); } catch (Exception e) { return responseBad(msg, e, INTERNAL_SERVER_ERROR); } }
[ "@", "Path", "(", "\"/acl/{spaceID}\"", ")", "@", "HEAD", "public", "Response", "getSpaceACLs", "(", "@", "PathParam", "(", "\"spaceID\"", ")", "String", "spaceID", ",", "@", "QueryParam", "(", "\"storeID\"", ")", "String", "storeID", ")", "{", "String", "msg", "=", "\"getting space ACLs(\"", "+", "spaceID", "+", "\", \"", "+", "storeID", "+", "\")\"", ";", "try", "{", "log", ".", "debug", "(", "msg", ")", ";", "return", "addSpaceACLsToResponse", "(", "Response", ".", "ok", "(", ")", ",", "spaceID", ",", "storeID", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "return", "responseNotFound", "(", "msg", ",", "e", ",", "NOT_FOUND", ")", ";", "}", "catch", "(", "ResourceException", "e", ")", "{", "return", "responseBad", "(", "msg", ",", "e", ",", "INTERNAL_SERVER_ERROR", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "responseBad", "(", "msg", ",", "e", ",", "INTERNAL_SERVER_ERROR", ")", ";", "}", "}" ]
see SpaceResource.getSpaceACLs(String, String); @return 200 response with space ACLs included as header values
[ "see", "SpaceResource", ".", "getSpaceACLs", "(", "String", "String", ")", ";" ]
train
https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java#L194-L213
jbundle/jbundle
base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/html/HAppletHtmlScreen.java
HAppletHtmlScreen.printReport
public void printReport(PrintWriter out, ResourceBundle reg) throws DBException { if (reg == null) reg = ((BaseApplication)this.getTask().getApplication()).getResources("HtmlApplet", false); super.printReport(out, reg); }
java
public void printReport(PrintWriter out, ResourceBundle reg) throws DBException { if (reg == null) reg = ((BaseApplication)this.getTask().getApplication()).getResources("HtmlApplet", false); super.printReport(out, reg); }
[ "public", "void", "printReport", "(", "PrintWriter", "out", ",", "ResourceBundle", "reg", ")", "throws", "DBException", "{", "if", "(", "reg", "==", "null", ")", "reg", "=", "(", "(", "BaseApplication", ")", "this", ".", "getTask", "(", ")", ".", "getApplication", "(", ")", ")", ".", "getResources", "(", "\"HtmlApplet\"", ",", "false", ")", ";", "super", ".", "printReport", "(", "out", ",", "reg", ")", ";", "}" ]
Output this screen using HTML. Display the html headers, etc. then: <ol> - Parse any parameters passed in and set the field values. - Process any command (such as move=Next). - Render this screen as Html (by calling printHtmlScreen()). </ol> @param out The html out stream. @exception DBException File exception.
[ "Output", "this", "screen", "using", "HTML", ".", "Display", "the", "html", "headers", "etc", ".", "then", ":", "<ol", ">", "-", "Parse", "any", "parameters", "passed", "in", "and", "set", "the", "field", "values", ".", "-", "Process", "any", "command", "(", "such", "as", "move", "=", "Next", ")", ".", "-", "Render", "this", "screen", "as", "Html", "(", "by", "calling", "printHtmlScreen", "()", ")", ".", "<", "/", "ol", ">" ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/html/HAppletHtmlScreen.java#L78-L84
grpc/grpc-java
stub/src/main/java/io/grpc/stub/AbstractStub.java
AbstractStub.withDeadlineAfter
public final S withDeadlineAfter(long duration, TimeUnit unit) { return build(channel, callOptions.withDeadlineAfter(duration, unit)); }
java
public final S withDeadlineAfter(long duration, TimeUnit unit) { return build(channel, callOptions.withDeadlineAfter(duration, unit)); }
[ "public", "final", "S", "withDeadlineAfter", "(", "long", "duration", ",", "TimeUnit", "unit", ")", "{", "return", "build", "(", "channel", ",", "callOptions", ".", "withDeadlineAfter", "(", "duration", ",", "unit", ")", ")", ";", "}" ]
Returns a new stub with a deadline that is after the given {@code duration} from now. @since 1.0.0 @see CallOptions#withDeadlineAfter
[ "Returns", "a", "new", "stub", "with", "a", "deadline", "that", "is", "after", "the", "given", "{", "@code", "duration", "}", "from", "now", "." ]
train
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/stub/src/main/java/io/grpc/stub/AbstractStub.java#L123-L125
Azure/azure-sdk-for-java
network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/P2sVpnServerConfigurationsInner.java
P2sVpnServerConfigurationsInner.beginCreateOrUpdate
public P2SVpnServerConfigurationInner beginCreateOrUpdate(String resourceGroupName, String virtualWanName, String p2SVpnServerConfigurationName, P2SVpnServerConfigurationInner p2SVpnServerConfigurationParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualWanName, p2SVpnServerConfigurationName, p2SVpnServerConfigurationParameters).toBlocking().single().body(); }
java
public P2SVpnServerConfigurationInner beginCreateOrUpdate(String resourceGroupName, String virtualWanName, String p2SVpnServerConfigurationName, P2SVpnServerConfigurationInner p2SVpnServerConfigurationParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualWanName, p2SVpnServerConfigurationName, p2SVpnServerConfigurationParameters).toBlocking().single().body(); }
[ "public", "P2SVpnServerConfigurationInner", "beginCreateOrUpdate", "(", "String", "resourceGroupName", ",", "String", "virtualWanName", ",", "String", "p2SVpnServerConfigurationName", ",", "P2SVpnServerConfigurationInner", "p2SVpnServerConfigurationParameters", ")", "{", "return", "beginCreateOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "virtualWanName", ",", "p2SVpnServerConfigurationName", ",", "p2SVpnServerConfigurationParameters", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Creates a P2SVpnServerConfiguration to associate with a VirtualWan if it doesn't exist else updates the existing P2SVpnServerConfiguration. @param resourceGroupName The resource group name of the VirtualWan. @param virtualWanName The name of the VirtualWan. @param p2SVpnServerConfigurationName The name of the P2SVpnServerConfiguration. @param p2SVpnServerConfigurationParameters Parameters supplied to create or Update a P2SVpnServerConfiguration. @throws IllegalArgumentException thrown if parameters fail the validation @throws ErrorException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @return the P2SVpnServerConfigurationInner object if successful.
[ "Creates", "a", "P2SVpnServerConfiguration", "to", "associate", "with", "a", "VirtualWan", "if", "it", "doesn", "t", "exist", "else", "updates", "the", "existing", "P2SVpnServerConfiguration", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/P2sVpnServerConfigurationsInner.java#L279-L281
jtablesaw/tablesaw
core/src/main/java/tech/tablesaw/table/StandardTableSliceGroup.java
StandardTableSliceGroup.create
public static StandardTableSliceGroup create(Table original, String... columnsNames) { List<CategoricalColumn<?>> columns = original.categoricalColumns(columnsNames); return new StandardTableSliceGroup(original, columns.toArray(new CategoricalColumn<?>[0])); }
java
public static StandardTableSliceGroup create(Table original, String... columnsNames) { List<CategoricalColumn<?>> columns = original.categoricalColumns(columnsNames); return new StandardTableSliceGroup(original, columns.toArray(new CategoricalColumn<?>[0])); }
[ "public", "static", "StandardTableSliceGroup", "create", "(", "Table", "original", ",", "String", "...", "columnsNames", ")", "{", "List", "<", "CategoricalColumn", "<", "?", ">", ">", "columns", "=", "original", ".", "categoricalColumns", "(", "columnsNames", ")", ";", "return", "new", "StandardTableSliceGroup", "(", "original", ",", "columns", ".", "toArray", "(", "new", "CategoricalColumn", "<", "?", ">", "[", "0", "]", ")", ")", ";", "}" ]
Returns a viewGroup splitting the original table on the given columns. The named columns must be CategoricalColumns
[ "Returns", "a", "viewGroup", "splitting", "the", "original", "table", "on", "the", "given", "columns", ".", "The", "named", "columns", "must", "be", "CategoricalColumns" ]
train
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/StandardTableSliceGroup.java#L50-L53
albfernandez/itext2
src/main/java/com/lowagie/text/Image.java
Image.getInstance
public static Image getInstance(int width, int height, int components, int bpc, byte data[], int transparency[]) throws BadElementException { if (transparency != null && transparency.length != components * 2) throw new BadElementException( "Transparency length must be equal to (componentes * 2)"); if (components == 1 && bpc == 1) { byte g4[] = CCITTG4Encoder.compress(data, width, height); return Image.getInstance(width, height, false, Image.CCITTG4, Image.CCITT_BLACKIS1, g4, transparency); } Image img = new ImgRaw(width, height, components, bpc, data); img.transparency = transparency; return img; }
java
public static Image getInstance(int width, int height, int components, int bpc, byte data[], int transparency[]) throws BadElementException { if (transparency != null && transparency.length != components * 2) throw new BadElementException( "Transparency length must be equal to (componentes * 2)"); if (components == 1 && bpc == 1) { byte g4[] = CCITTG4Encoder.compress(data, width, height); return Image.getInstance(width, height, false, Image.CCITTG4, Image.CCITT_BLACKIS1, g4, transparency); } Image img = new ImgRaw(width, height, components, bpc, data); img.transparency = transparency; return img; }
[ "public", "static", "Image", "getInstance", "(", "int", "width", ",", "int", "height", ",", "int", "components", ",", "int", "bpc", ",", "byte", "data", "[", "]", ",", "int", "transparency", "[", "]", ")", "throws", "BadElementException", "{", "if", "(", "transparency", "!=", "null", "&&", "transparency", ".", "length", "!=", "components", "*", "2", ")", "throw", "new", "BadElementException", "(", "\"Transparency length must be equal to (componentes * 2)\"", ")", ";", "if", "(", "components", "==", "1", "&&", "bpc", "==", "1", ")", "{", "byte", "g4", "[", "]", "=", "CCITTG4Encoder", ".", "compress", "(", "data", ",", "width", ",", "height", ")", ";", "return", "Image", ".", "getInstance", "(", "width", ",", "height", ",", "false", ",", "Image", ".", "CCITTG4", ",", "Image", ".", "CCITT_BLACKIS1", ",", "g4", ",", "transparency", ")", ";", "}", "Image", "img", "=", "new", "ImgRaw", "(", "width", ",", "height", ",", "components", ",", "bpc", ",", "data", ")", ";", "img", ".", "transparency", "=", "transparency", ";", "return", "img", ";", "}" ]
Gets an instance of an Image in raw mode. @param width the width of the image in pixels @param height the height of the image in pixels @param components 1,3 or 4 for GrayScale, RGB and CMYK @param data the image data @param bpc bits per component @param transparency transparency information in the Mask format of the image dictionary @return an object of type <CODE>ImgRaw</CODE> @throws BadElementException on error
[ "Gets", "an", "instance", "of", "an", "Image", "in", "raw", "mode", "." ]
train
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Image.java#L572-L586
operasoftware/operaprestodriver
src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java
OperaLauncherProtocol.sendRequestWithoutResponse
public void sendRequestWithoutResponse(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } }
java
public void sendRequestWithoutResponse(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } }
[ "public", "void", "sendRequestWithoutResponse", "(", "MessageType", "type", ",", "byte", "[", "]", "body", ")", "throws", "IOException", "{", "sendRequestHeader", "(", "type", ",", "(", "body", "!=", "null", ")", "?", "body", ".", "length", ":", "0", ")", ";", "if", "(", "body", "!=", "null", ")", "{", "os", ".", "write", "(", "body", ")", ";", "}", "}" ]
Send a request without a response. Used for shutdown. @param type the request type to be sent @param body the serialized request payload @throws IOException if socket read error or protocol parse error
[ "Send", "a", "request", "without", "a", "response", ".", "Used", "for", "shutdown", "." ]
train
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java#L163-L168
OpenLiberty/open-liberty
dev/com.ibm.ws.injection.core/src/com/ibm/wsspi/injectionengine/InjectionBinding.java
InjectionBinding.setObjects
public void setObjects(Object injectionObject, Reference bindingObject) throws InjectionException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "setObjects", injectionObject, bindingObjectToString(bindingObject)); ivInjectedObject = injectionObject; // d392996.3 if (bindingObject != null) { ivBindingObject = bindingObject; ivObjectFactoryClassName = bindingObject.getFactoryClassName(); // F48603.4 if (ivObjectFactoryClassName == null) // F54050 { throw new IllegalArgumentException("expected non-null getFactoryClassName"); } } else { ivBindingObject = injectionObject; } }
java
public void setObjects(Object injectionObject, Reference bindingObject) throws InjectionException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "setObjects", injectionObject, bindingObjectToString(bindingObject)); ivInjectedObject = injectionObject; // d392996.3 if (bindingObject != null) { ivBindingObject = bindingObject; ivObjectFactoryClassName = bindingObject.getFactoryClassName(); // F48603.4 if (ivObjectFactoryClassName == null) // F54050 { throw new IllegalArgumentException("expected non-null getFactoryClassName"); } } else { ivBindingObject = injectionObject; } }
[ "public", "void", "setObjects", "(", "Object", "injectionObject", ",", "Reference", "bindingObject", ")", "throws", "InjectionException", "{", "final", "boolean", "isTraceOn", "=", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", ";", "if", "(", "isTraceOn", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"setObjects\"", ",", "injectionObject", ",", "bindingObjectToString", "(", "bindingObject", ")", ")", ";", "ivInjectedObject", "=", "injectionObject", ";", "// d392996.3", "if", "(", "bindingObject", "!=", "null", ")", "{", "ivBindingObject", "=", "bindingObject", ";", "ivObjectFactoryClassName", "=", "bindingObject", ".", "getFactoryClassName", "(", ")", ";", "// F48603.4", "if", "(", "ivObjectFactoryClassName", "==", "null", ")", "// F54050", "{", "throw", "new", "IllegalArgumentException", "(", "\"expected non-null getFactoryClassName\"", ")", ";", "}", "}", "else", "{", "ivBindingObject", "=", "injectionObject", ";", "}", "}" ]
Sets the object to use for injection and the Reference to use for binding. Usually, the injection object is null. @param injectionObject the object to inject, or null if the object should be obtained from the binding object instead @param bindingObject the object to bind, or null if injectionObject should be bound directly if is non-null @throws InjectionException if a problem occurs while creating the instance to be injected
[ "Sets", "the", "object", "to", "use", "for", "injection", "and", "the", "Reference", "to", "use", "for", "binding", ".", "Usually", "the", "injection", "object", "is", "null", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection.core/src/com/ibm/wsspi/injectionengine/InjectionBinding.java#L1283-L1305
Samsung/GearVRf
GVRf/Extensions/gvrf-particlesystem/src/main/java/org/gearvrf/particlesystem/GVREmitter.java
GVREmitter.setVelocityRange
public void setVelocityRange( final Vector3f minV, final Vector3f maxV ) { if (null != mGVRContext) { mGVRContext.runOnGlThread(new Runnable() { @Override public void run() { minVelocity = minV; maxVelocity = maxV; } }); } }
java
public void setVelocityRange( final Vector3f minV, final Vector3f maxV ) { if (null != mGVRContext) { mGVRContext.runOnGlThread(new Runnable() { @Override public void run() { minVelocity = minV; maxVelocity = maxV; } }); } }
[ "public", "void", "setVelocityRange", "(", "final", "Vector3f", "minV", ",", "final", "Vector3f", "maxV", ")", "{", "if", "(", "null", "!=", "mGVRContext", ")", "{", "mGVRContext", ".", "runOnGlThread", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "minVelocity", "=", "minV", ";", "maxVelocity", "=", "maxV", ";", "}", "}", ")", ";", "}", "}" ]
The range of velocities that a particle generated from this emitter can have. @param minV Minimum velocity that a particle can have @param maxV Maximum velocity that a particle can have
[ "The", "range", "of", "velocities", "that", "a", "particle", "generated", "from", "this", "emitter", "can", "have", "." ]
train
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/gvrf-particlesystem/src/main/java/org/gearvrf/particlesystem/GVREmitter.java#L294-L306
eiichiro/gig
gig-appengine/src/main/java/org/eiichiro/gig/appengine/GeoPtConverter.java
GeoPtConverter.convertToType
@SuppressWarnings("rawtypes") @Override protected Object convertToType(Class type, Object value) throws Throwable { String[] strings = value.toString().split(","); if (strings.length != 2) { throw new ConversionException( "GeoPt 'value' must be able to be splitted into 2 float values " + "by ',' (latitude,longitude)"); } try { float latitude = new BigDecimal(strings[0].trim()).floatValue(); float longitude = new BigDecimal(strings[1].trim()).floatValue(); return new GeoPt(latitude, longitude); } catch (Exception e) { throw new ConversionException( "Cannot parse GeoPt value into 2 float values: " + "latitude [" + strings[0].trim() + "], longitude [" + strings[1].trim() + "]"); } }
java
@SuppressWarnings("rawtypes") @Override protected Object convertToType(Class type, Object value) throws Throwable { String[] strings = value.toString().split(","); if (strings.length != 2) { throw new ConversionException( "GeoPt 'value' must be able to be splitted into 2 float values " + "by ',' (latitude,longitude)"); } try { float latitude = new BigDecimal(strings[0].trim()).floatValue(); float longitude = new BigDecimal(strings[1].trim()).floatValue(); return new GeoPt(latitude, longitude); } catch (Exception e) { throw new ConversionException( "Cannot parse GeoPt value into 2 float values: " + "latitude [" + strings[0].trim() + "], longitude [" + strings[1].trim() + "]"); } }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "@", "Override", "protected", "Object", "convertToType", "(", "Class", "type", ",", "Object", "value", ")", "throws", "Throwable", "{", "String", "[", "]", "strings", "=", "value", ".", "toString", "(", ")", ".", "split", "(", "\",\"", ")", ";", "if", "(", "strings", ".", "length", "!=", "2", ")", "{", "throw", "new", "ConversionException", "(", "\"GeoPt 'value' must be able to be splitted into 2 float values \"", "+", "\"by ',' (latitude,longitude)\"", ")", ";", "}", "try", "{", "float", "latitude", "=", "new", "BigDecimal", "(", "strings", "[", "0", "]", ".", "trim", "(", ")", ")", ".", "floatValue", "(", ")", ";", "float", "longitude", "=", "new", "BigDecimal", "(", "strings", "[", "1", "]", ".", "trim", "(", ")", ")", ".", "floatValue", "(", ")", ";", "return", "new", "GeoPt", "(", "latitude", ",", "longitude", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ConversionException", "(", "\"Cannot parse GeoPt value into 2 float values: \"", "+", "\"latitude [\"", "+", "strings", "[", "0", "]", ".", "trim", "(", ")", "+", "\"], longitude [\"", "+", "strings", "[", "1", "]", ".", "trim", "(", ")", "+", "\"]\"", ")", ";", "}", "}" ]
Converts the specified value to {@code com.google.appengine.api.datastore.GeoPt}. @see org.apache.commons.beanutils.converters.AbstractConverter#convertToType(java.lang.Class, java.lang.Object)
[ "Converts", "the", "specified", "value", "to", "{", "@code", "com", ".", "google", ".", "appengine", ".", "api", ".", "datastore", ".", "GeoPt", "}", "." ]
train
https://github.com/eiichiro/gig/blob/21181fb36a17d2154f989e5e8c6edbb39fc81900/gig-appengine/src/main/java/org/eiichiro/gig/appengine/GeoPtConverter.java#L41-L62
aws/aws-sdk-java
aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetStageResult.java
GetStageResult.withRouteSettings
public GetStageResult withRouteSettings(java.util.Map<String, RouteSettings> routeSettings) { setRouteSettings(routeSettings); return this; }
java
public GetStageResult withRouteSettings(java.util.Map<String, RouteSettings> routeSettings) { setRouteSettings(routeSettings); return this; }
[ "public", "GetStageResult", "withRouteSettings", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "RouteSettings", ">", "routeSettings", ")", "{", "setRouteSettings", "(", "routeSettings", ")", ";", "return", "this", ";", "}" ]
<p> Route settings for the stage. </p> @param routeSettings Route settings for the stage. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "Route", "settings", "for", "the", "stage", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetStageResult.java#L398-L401
OpenLiberty/open-liberty
dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/webapp/UIComponentTag.java
UIComponentTag.createComponent
@Override protected UIComponent createComponent(FacesContext context, String id) { String componentType = getComponentType(); if (componentType == null) { throw new NullPointerException("componentType"); } if (_binding != null) { Application application = context.getApplication(); ValueBinding componentBinding = application.createValueBinding(_binding); UIComponent component = application.createComponent(componentBinding, context, componentType); component.setId(id); component.setValueBinding("binding", componentBinding); setProperties(component); return component; } UIComponent component = context.getApplication().createComponent(componentType); component.setId(id); setProperties(component); return component; }
java
@Override protected UIComponent createComponent(FacesContext context, String id) { String componentType = getComponentType(); if (componentType == null) { throw new NullPointerException("componentType"); } if (_binding != null) { Application application = context.getApplication(); ValueBinding componentBinding = application.createValueBinding(_binding); UIComponent component = application.createComponent(componentBinding, context, componentType); component.setId(id); component.setValueBinding("binding", componentBinding); setProperties(component); return component; } UIComponent component = context.getApplication().createComponent(componentType); component.setId(id); setProperties(component); return component; }
[ "@", "Override", "protected", "UIComponent", "createComponent", "(", "FacesContext", "context", ",", "String", "id", ")", "{", "String", "componentType", "=", "getComponentType", "(", ")", ";", "if", "(", "componentType", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"componentType\"", ")", ";", "}", "if", "(", "_binding", "!=", "null", ")", "{", "Application", "application", "=", "context", ".", "getApplication", "(", ")", ";", "ValueBinding", "componentBinding", "=", "application", ".", "createValueBinding", "(", "_binding", ")", ";", "UIComponent", "component", "=", "application", ".", "createComponent", "(", "componentBinding", ",", "context", ",", "componentType", ")", ";", "component", ".", "setId", "(", "id", ")", ";", "component", ".", "setValueBinding", "(", "\"binding\"", ",", "componentBinding", ")", ";", "setProperties", "(", "component", ")", ";", "return", "component", ";", "}", "UIComponent", "component", "=", "context", ".", "getApplication", "(", ")", ".", "createComponent", "(", "componentType", ")", ";", "component", ".", "setId", "(", "id", ")", ";", "setProperties", "(", "component", ")", ";", "return", "component", ";", "}" ]
Create a UIComponent. Abstract method getComponentType is invoked to determine the actual type name for the component to be created. If this tag has a "binding" attribute, then that is immediately evaluated to store the created component in the specified property.
[ "Create", "a", "UIComponent", ".", "Abstract", "method", "getComponentType", "is", "invoked", "to", "determine", "the", "actual", "type", "name", "for", "the", "component", "to", "be", "created", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/webapp/UIComponentTag.java#L126-L154
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DateUtils.java
DateUtils.parseDate
public static Date parseDate(final String dateValue, final String[] dateFormats) { return parseDate(dateValue, dateFormats, null); }
java
public static Date parseDate(final String dateValue, final String[] dateFormats) { return parseDate(dateValue, dateFormats, null); }
[ "public", "static", "Date", "parseDate", "(", "final", "String", "dateValue", ",", "final", "String", "[", "]", "dateFormats", ")", "{", "return", "parseDate", "(", "dateValue", ",", "dateFormats", ",", "null", ")", ";", "}" ]
Parses the date value using the given date formats. @param dateValue the date value to parse @param dateFormats the date formats to use @return the parsed date or null if input could not be parsed
[ "Parses", "the", "date", "value", "using", "the", "given", "date", "formats", "." ]
train
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DateUtils.java#L121-L123
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMRandom.java
JMRandom.buildRandomIntStream
public static IntStream buildRandomIntStream(int streamSize, long seed, int exclusiveBound) { return buildRandomIntStream(streamSize, new Random(seed), exclusiveBound); }
java
public static IntStream buildRandomIntStream(int streamSize, long seed, int exclusiveBound) { return buildRandomIntStream(streamSize, new Random(seed), exclusiveBound); }
[ "public", "static", "IntStream", "buildRandomIntStream", "(", "int", "streamSize", ",", "long", "seed", ",", "int", "exclusiveBound", ")", "{", "return", "buildRandomIntStream", "(", "streamSize", ",", "new", "Random", "(", "seed", ")", ",", "exclusiveBound", ")", ";", "}" ]
Build random int stream int stream. @param streamSize the stream size @param seed the seed @param exclusiveBound the exclusive bound @return the int stream
[ "Build", "random", "int", "stream", "int", "stream", "." ]
train
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMRandom.java#L167-L171
structr/structr
structr-core/src/main/java/org/structr/core/graph/NodeServiceCommand.java
NodeServiceCommand.bulkGraphOperation
public <T> long bulkGraphOperation(final SecurityContext securityContext, final Iterator<T> iterator, final long commitCount, String description, final BulkGraphOperation<T> operation) { return bulkGraphOperation(securityContext, iterator, commitCount, description, operation, true); }
java
public <T> long bulkGraphOperation(final SecurityContext securityContext, final Iterator<T> iterator, final long commitCount, String description, final BulkGraphOperation<T> operation) { return bulkGraphOperation(securityContext, iterator, commitCount, description, operation, true); }
[ "public", "<", "T", ">", "long", "bulkGraphOperation", "(", "final", "SecurityContext", "securityContext", ",", "final", "Iterator", "<", "T", ">", "iterator", ",", "final", "long", "commitCount", ",", "String", "description", ",", "final", "BulkGraphOperation", "<", "T", ">", "operation", ")", "{", "return", "bulkGraphOperation", "(", "securityContext", ",", "iterator", ",", "commitCount", ",", "description", ",", "operation", ",", "true", ")", ";", "}" ]
Executes the given operation on all nodes in the given list. @param <T> @param securityContext @param iterator the iterator that provides the nodes to operate on @param commitCount @param description @param operation the operation to execute @return the number of nodes processed
[ "Executes", "the", "given", "operation", "on", "all", "nodes", "in", "the", "given", "list", "." ]
train
https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/core/graph/NodeServiceCommand.java#L72-L74
alkacon/opencms-core
src/org/opencms/staticexport/CmsLinkManager.java
CmsLinkManager.getSitePath
@Deprecated public static String getSitePath(CmsObject cms, String basePath, String targetUri) { return OpenCms.getLinkManager().getRootPath(cms, targetUri, basePath); }
java
@Deprecated public static String getSitePath(CmsObject cms, String basePath, String targetUri) { return OpenCms.getLinkManager().getRootPath(cms, targetUri, basePath); }
[ "@", "Deprecated", "public", "static", "String", "getSitePath", "(", "CmsObject", "cms", ",", "String", "basePath", ",", "String", "targetUri", ")", "{", "return", "OpenCms", ".", "getLinkManager", "(", ")", ".", "getRootPath", "(", "cms", ",", "targetUri", ",", "basePath", ")", ";", "}" ]
Returns the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site.<p> @param cms the current users OpenCms context @param basePath path to use as base site for the target URI (can be <code>null</code>) @param targetUri the target URI @return the resource root path for the given target URI in the OpenCms VFS, or <code>null</code> in case the target URI points to an external site @deprecated use {@link #getRootPath(CmsObject, String, String)} instead, obtain the link manager with {@link OpenCms#getLinkManager()}
[ "Returns", "the", "resource", "root", "path", "for", "the", "given", "target", "URI", "in", "the", "OpenCms", "VFS", "or", "<code", ">", "null<", "/", "code", ">", "in", "case", "the", "target", "URI", "points", "to", "an", "external", "site", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L192-L196
Ordinastie/MalisisCore
src/main/java/net/malisis/core/renderer/font/MalisisFont.java
MalisisFont.getMaxStringWidth
public float getMaxStringWidth(List<String> strings, FontOptions options) { float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
java
public float getMaxStringWidth(List<String> strings, FontOptions options) { float width = 0; for (String str : strings) width = Math.max(width, getStringWidth(str, options)); return width; } /** * Gets the rendering width of a character. * * @param c the c * @param options the options * @return the char width */ public float getCharWidth(char c, FontOptions options) { if (c == '\r' || c == '\n') return 0; if (c == '\t') return getCharWidth(' ', options) * 4; return getCharData(c).getCharWidth() / fontGeneratorOptions.fontSize * (options != null ? options.getFontScale() : 1) * 9; }
[ "public", "float", "getMaxStringWidth", "(", "List", "<", "String", ">", "strings", ",", "FontOptions", "options", ")", "{", "float", "width", "=", "0", ";", "for", "(", "String", "str", ":", "strings", ")", "width", "=", "Math", ".", "max", "(", "width", ",", "getStringWidth", "(", "str", ",", "options", ")", ")", ";", "return", "width", ";", "}", "/**\n\t * Gets the rendering width of a character.\n\t *\n\t * @param c the c\n\t * @param options the options\n\t * @return the char width\n\t */", "public", "float", "getCharWidth", "(", "char", "c", ",", "FontOptions", "options", ")", "{", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "return", "0", ";", "if", "(", "c", "==", "'", "'", ")", "return", "getCharWidth", "(", "'", "'", ",", "options", ")", "*", "4", ";", "return", "getCharData", "(", "c", ")", ".", "getCharWidth", "(", ")", "/", "fontGeneratorOptions", ".", "fontSize", "*", "(", "options", "!=", "null", "?", "options", ".", "getFontScale", "(", ")", ":", "1", ")", "*", "9", ";", "}" ]
Gets max rendering width of an array of string. @param strings the strings @param options the options @return the max string width
[ "Gets", "max", "rendering", "width", "of", "an", "array", "of", "string", "." ]
train
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L508-L531
Azure/azure-sdk-for-java
authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/DenyAssignmentsInner.java
DenyAssignmentsInner.getAsync
public Observable<DenyAssignmentInner> getAsync(String scope, String denyAssignmentId) { return getWithServiceResponseAsync(scope, denyAssignmentId).map(new Func1<ServiceResponse<DenyAssignmentInner>, DenyAssignmentInner>() { @Override public DenyAssignmentInner call(ServiceResponse<DenyAssignmentInner> response) { return response.body(); } }); }
java
public Observable<DenyAssignmentInner> getAsync(String scope, String denyAssignmentId) { return getWithServiceResponseAsync(scope, denyAssignmentId).map(new Func1<ServiceResponse<DenyAssignmentInner>, DenyAssignmentInner>() { @Override public DenyAssignmentInner call(ServiceResponse<DenyAssignmentInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "DenyAssignmentInner", ">", "getAsync", "(", "String", "scope", ",", "String", "denyAssignmentId", ")", "{", "return", "getWithServiceResponseAsync", "(", "scope", ",", "denyAssignmentId", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "DenyAssignmentInner", ">", ",", "DenyAssignmentInner", ">", "(", ")", "{", "@", "Override", "public", "DenyAssignmentInner", "call", "(", "ServiceResponse", "<", "DenyAssignmentInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Get the specified deny assignment. @param scope The scope of the deny assignment. @param denyAssignmentId The ID of the deny assignment to get. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DenyAssignmentInner object
[ "Get", "the", "specified", "deny", "assignment", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/DenyAssignmentsInner.java#L861-L868
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/SerializationUtil.java
SerializationUtil.writeNullablePartitionIdSet
public static void writeNullablePartitionIdSet(PartitionIdSet partitionIds, ObjectDataOutput out) throws IOException { if (partitionIds == null) { out.writeInt(-1); return; } out.writeInt(partitionIds.getPartitionCount()); out.writeInt(partitionIds.size()); PrimitiveIterator.OfInt intIterator = partitionIds.intIterator(); while (intIterator.hasNext()) { out.writeInt(intIterator.nextInt()); } }
java
public static void writeNullablePartitionIdSet(PartitionIdSet partitionIds, ObjectDataOutput out) throws IOException { if (partitionIds == null) { out.writeInt(-1); return; } out.writeInt(partitionIds.getPartitionCount()); out.writeInt(partitionIds.size()); PrimitiveIterator.OfInt intIterator = partitionIds.intIterator(); while (intIterator.hasNext()) { out.writeInt(intIterator.nextInt()); } }
[ "public", "static", "void", "writeNullablePartitionIdSet", "(", "PartitionIdSet", "partitionIds", ",", "ObjectDataOutput", "out", ")", "throws", "IOException", "{", "if", "(", "partitionIds", "==", "null", ")", "{", "out", ".", "writeInt", "(", "-", "1", ")", ";", "return", ";", "}", "out", ".", "writeInt", "(", "partitionIds", ".", "getPartitionCount", "(", ")", ")", ";", "out", ".", "writeInt", "(", "partitionIds", ".", "size", "(", ")", ")", ";", "PrimitiveIterator", ".", "OfInt", "intIterator", "=", "partitionIds", ".", "intIterator", "(", ")", ";", "while", "(", "intIterator", ".", "hasNext", "(", ")", ")", "{", "out", ".", "writeInt", "(", "intIterator", ".", "nextInt", "(", ")", ")", ";", "}", "}" ]
Writes a nullable {@link PartitionIdSet} to the given data output. @param partitionIds @param out @throws IOException
[ "Writes", "a", "nullable", "{" ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/SerializationUtil.java#L275-L286
caelum/vraptor4
vraptor-core/src/main/java/br/com/caelum/vraptor/view/DefaultLogicResult.java
DefaultLogicResult.forwardTo
@Override public <T> T forwardTo(final Class<T> type) { return proxifier.proxify(type, new MethodInvocation<T>() { @Override public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { try { logger.debug("Executing {}", method); ControllerMethod old = methodInfo.getControllerMethod(); methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method)); Object methodResult = method.invoke(container.instanceFor(type), args); methodInfo.setControllerMethod(old); Type returnType = method.getGenericReturnType(); if (!(returnType == void.class)) { request.setAttribute(extractor.nameFor(returnType), methodResult); } if (response.isCommitted()) { logger.debug("Response already commited, not forwarding."); return null; } String path = resolver.pathFor(DefaultControllerMethod.instanceFor(type, method)); logger.debug("Forwarding to {}", path); request.getRequestDispatcher(path).forward(request, response); return null; } catch (InvocationTargetException e) { propagateIfPossible(e.getCause()); throw new ProxyInvocationException(e); } catch (Exception e) { throw new ProxyInvocationException(e); } } }); }
java
@Override public <T> T forwardTo(final Class<T> type) { return proxifier.proxify(type, new MethodInvocation<T>() { @Override public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { try { logger.debug("Executing {}", method); ControllerMethod old = methodInfo.getControllerMethod(); methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method)); Object methodResult = method.invoke(container.instanceFor(type), args); methodInfo.setControllerMethod(old); Type returnType = method.getGenericReturnType(); if (!(returnType == void.class)) { request.setAttribute(extractor.nameFor(returnType), methodResult); } if (response.isCommitted()) { logger.debug("Response already commited, not forwarding."); return null; } String path = resolver.pathFor(DefaultControllerMethod.instanceFor(type, method)); logger.debug("Forwarding to {}", path); request.getRequestDispatcher(path).forward(request, response); return null; } catch (InvocationTargetException e) { propagateIfPossible(e.getCause()); throw new ProxyInvocationException(e); } catch (Exception e) { throw new ProxyInvocationException(e); } } }); }
[ "@", "Override", "public", "<", "T", ">", "T", "forwardTo", "(", "final", "Class", "<", "T", ">", "type", ")", "{", "return", "proxifier", ".", "proxify", "(", "type", ",", "new", "MethodInvocation", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "Object", "intercept", "(", "T", "proxy", ",", "Method", "method", ",", "Object", "[", "]", "args", ",", "SuperMethod", "superMethod", ")", "{", "try", "{", "logger", ".", "debug", "(", "\"Executing {}\"", ",", "method", ")", ";", "ControllerMethod", "old", "=", "methodInfo", ".", "getControllerMethod", "(", ")", ";", "methodInfo", ".", "setControllerMethod", "(", "DefaultControllerMethod", ".", "instanceFor", "(", "type", ",", "method", ")", ")", ";", "Object", "methodResult", "=", "method", ".", "invoke", "(", "container", ".", "instanceFor", "(", "type", ")", ",", "args", ")", ";", "methodInfo", ".", "setControllerMethod", "(", "old", ")", ";", "Type", "returnType", "=", "method", ".", "getGenericReturnType", "(", ")", ";", "if", "(", "!", "(", "returnType", "==", "void", ".", "class", ")", ")", "{", "request", ".", "setAttribute", "(", "extractor", ".", "nameFor", "(", "returnType", ")", ",", "methodResult", ")", ";", "}", "if", "(", "response", ".", "isCommitted", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Response already commited, not forwarding.\"", ")", ";", "return", "null", ";", "}", "String", "path", "=", "resolver", ".", "pathFor", "(", "DefaultControllerMethod", ".", "instanceFor", "(", "type", ",", "method", ")", ")", ";", "logger", ".", "debug", "(", "\"Forwarding to {}\"", ",", "path", ")", ";", "request", ".", "getRequestDispatcher", "(", "path", ")", ".", "forward", "(", "request", ",", "response", ")", ";", "return", "null", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "propagateIfPossible", "(", "e", ".", "getCause", "(", ")", ")", ";", "throw", "new", "ProxyInvocationException", "(", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ProxyInvocationException", "(", "e", ")", ";", "}", "}", "}", ")", ";", "}" ]
This implementation don't actually use request dispatcher for the forwarding. It runs forwarding logic, and renders its <b>default</b> view.
[ "This", "implementation", "don", "t", "actually", "use", "request", "dispatcher", "for", "the", "forwarding", ".", "It", "runs", "forwarding", "logic", "and", "renders", "its", "<b", ">", "default<", "/", "b", ">", "view", "." ]
train
https://github.com/caelum/vraptor4/blob/593ce9ad60f9d38c360881b2132417c56b8cc093/vraptor-core/src/main/java/br/com/caelum/vraptor/view/DefaultLogicResult.java#L97-L131
javagl/CommonUI
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
CheckBoxTree.setSelectionState
private void setSelectionState(Object node, State state, boolean propagate) { Objects.requireNonNull(state, "The state may not be null"); Objects.requireNonNull(node, "The node may not be null"); State oldState = selectionStates.put(node, state); if (!state.equals(oldState)) { fireStateChanged(node, oldState, state); if (propagate) { updateSelection(node); } } repaint(); }
java
private void setSelectionState(Object node, State state, boolean propagate) { Objects.requireNonNull(state, "The state may not be null"); Objects.requireNonNull(node, "The node may not be null"); State oldState = selectionStates.put(node, state); if (!state.equals(oldState)) { fireStateChanged(node, oldState, state); if (propagate) { updateSelection(node); } } repaint(); }
[ "private", "void", "setSelectionState", "(", "Object", "node", ",", "State", "state", ",", "boolean", "propagate", ")", "{", "Objects", ".", "requireNonNull", "(", "state", ",", "\"The state may not be null\"", ")", ";", "Objects", ".", "requireNonNull", "(", "node", ",", "\"The node may not be null\"", ")", ";", "State", "oldState", "=", "selectionStates", ".", "put", "(", "node", ",", "state", ")", ";", "if", "(", "!", "state", ".", "equals", "(", "oldState", ")", ")", "{", "fireStateChanged", "(", "node", ",", "oldState", ",", "state", ")", ";", "if", "(", "propagate", ")", "{", "updateSelection", "(", "node", ")", ";", "}", "}", "repaint", "(", ")", ";", "}" ]
Set the selection state of the given node @param node The node @param state The state @param propagate Whether the state change should be propagated to its children and ancestor nodes
[ "Set", "the", "selection", "state", "of", "the", "given", "node" ]
train
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L256-L270
Azure/azure-sdk-for-java
network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java
VirtualHubsInner.beginCreateOrUpdateAsync
public Observable<VirtualHubInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualHubName, VirtualHubInner virtualHubParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualHubName, virtualHubParameters).map(new Func1<ServiceResponse<VirtualHubInner>, VirtualHubInner>() { @Override public VirtualHubInner call(ServiceResponse<VirtualHubInner> response) { return response.body(); } }); }
java
public Observable<VirtualHubInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualHubName, VirtualHubInner virtualHubParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualHubName, virtualHubParameters).map(new Func1<ServiceResponse<VirtualHubInner>, VirtualHubInner>() { @Override public VirtualHubInner call(ServiceResponse<VirtualHubInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "VirtualHubInner", ">", "beginCreateOrUpdateAsync", "(", "String", "resourceGroupName", ",", "String", "virtualHubName", ",", "VirtualHubInner", "virtualHubParameters", ")", "{", "return", "beginCreateOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "virtualHubName", ",", "virtualHubParameters", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "VirtualHubInner", ">", ",", "VirtualHubInner", ">", "(", ")", "{", "@", "Override", "public", "VirtualHubInner", "call", "(", "ServiceResponse", "<", "VirtualHubInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Creates a VirtualHub resource if it doesn't exist else updates the existing VirtualHub. @param resourceGroupName The resource group name of the VirtualHub. @param virtualHubName The name of the VirtualHub. @param virtualHubParameters Parameters supplied to create or update VirtualHub. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the VirtualHubInner object
[ "Creates", "a", "VirtualHub", "resource", "if", "it", "doesn", "t", "exist", "else", "updates", "the", "existing", "VirtualHub", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java#L313-L320
snazy/ohc
ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java
FrequencySketch.incrementAt
private boolean incrementAt(int i, int j) { int offset = j << 2; long mask = (0xfL << offset); long t = tableAt(i); if ((t & mask) != mask) { tableAt(i, t + (1L << offset)); return true; } return false; }
java
private boolean incrementAt(int i, int j) { int offset = j << 2; long mask = (0xfL << offset); long t = tableAt(i); if ((t & mask) != mask) { tableAt(i, t + (1L << offset)); return true; } return false; }
[ "private", "boolean", "incrementAt", "(", "int", "i", ",", "int", "j", ")", "{", "int", "offset", "=", "j", "<<", "2", ";", "long", "mask", "=", "(", "0xf", "L", "<<", "offset", ")", ";", "long", "t", "=", "tableAt", "(", "i", ")", ";", "if", "(", "(", "t", "&", "mask", ")", "!=", "mask", ")", "{", "tableAt", "(", "i", ",", "t", "+", "(", "1L", "<<", "offset", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Increments the specified counter by 1 if it is not already at the maximum value (15). @param i the table index (16 counters) @param j the counter to increment @return if incremented
[ "Increments", "the", "specified", "counter", "by", "1", "if", "it", "is", "not", "already", "at", "the", "maximum", "value", "(", "15", ")", "." ]
train
https://github.com/snazy/ohc/blob/af47142711993a3eaaf3b496332c27e2b43454e4/ohc-core/src/main/java/org/caffinitas/ohc/linked/FrequencySketch.java#L181-L192
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/util/Util.java
Util.sortIMarkers
public static void sortIMarkers(IMarker[] markers) { Arrays.sort(markers, new Comparator<IMarker>() { @Override public int compare(IMarker arg0, IMarker arg1) { IResource resource0 = arg0.getResource(); IResource resource1 = arg1.getResource(); if (resource0 != null && resource1 != null) { return resource0.getName().compareTo(resource1.getName()); } if (resource0 != null && resource1 == null) { return 1; } if (resource0 == null && resource1 != null) { return -1; } return 0; } }); }
java
public static void sortIMarkers(IMarker[] markers) { Arrays.sort(markers, new Comparator<IMarker>() { @Override public int compare(IMarker arg0, IMarker arg1) { IResource resource0 = arg0.getResource(); IResource resource1 = arg1.getResource(); if (resource0 != null && resource1 != null) { return resource0.getName().compareTo(resource1.getName()); } if (resource0 != null && resource1 == null) { return 1; } if (resource0 == null && resource1 != null) { return -1; } return 0; } }); }
[ "public", "static", "void", "sortIMarkers", "(", "IMarker", "[", "]", "markers", ")", "{", "Arrays", ".", "sort", "(", "markers", ",", "new", "Comparator", "<", "IMarker", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "IMarker", "arg0", ",", "IMarker", "arg1", ")", "{", "IResource", "resource0", "=", "arg0", ".", "getResource", "(", ")", ";", "IResource", "resource1", "=", "arg1", ".", "getResource", "(", ")", ";", "if", "(", "resource0", "!=", "null", "&&", "resource1", "!=", "null", ")", "{", "return", "resource0", ".", "getName", "(", ")", ".", "compareTo", "(", "resource1", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "resource0", "!=", "null", "&&", "resource1", "==", "null", ")", "{", "return", "1", ";", "}", "if", "(", "resource0", "==", "null", "&&", "resource1", "!=", "null", ")", "{", "return", "-", "1", ";", "}", "return", "0", ";", "}", "}", ")", ";", "}" ]
Sorts an array of IMarkers based on their underlying resource name @param markers
[ "Sorts", "an", "array", "of", "IMarkers", "based", "on", "their", "underlying", "resource", "name" ]
train
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/util/Util.java#L215-L233
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/TableFormBuilder.java
TableFormBuilder.addTextArea
public JComponent[] addTextArea(String fieldName, String attributes) { JComponent textArea = createTextArea(fieldName); String labelAttributes = getLabelAttributes(); if (labelAttributes == null) { labelAttributes = VALIGN_TOP; } else if (!labelAttributes.contains(TableLayoutBuilder.VALIGN)) { labelAttributes += " " + VALIGN_TOP; } return addBinding(createBinding(fieldName, textArea), new JScrollPane(textArea), attributes, labelAttributes); }
java
public JComponent[] addTextArea(String fieldName, String attributes) { JComponent textArea = createTextArea(fieldName); String labelAttributes = getLabelAttributes(); if (labelAttributes == null) { labelAttributes = VALIGN_TOP; } else if (!labelAttributes.contains(TableLayoutBuilder.VALIGN)) { labelAttributes += " " + VALIGN_TOP; } return addBinding(createBinding(fieldName, textArea), new JScrollPane(textArea), attributes, labelAttributes); }
[ "public", "JComponent", "[", "]", "addTextArea", "(", "String", "fieldName", ",", "String", "attributes", ")", "{", "JComponent", "textArea", "=", "createTextArea", "(", "fieldName", ")", ";", "String", "labelAttributes", "=", "getLabelAttributes", "(", ")", ";", "if", "(", "labelAttributes", "==", "null", ")", "{", "labelAttributes", "=", "VALIGN_TOP", ";", "}", "else", "if", "(", "!", "labelAttributes", ".", "contains", "(", "TableLayoutBuilder", ".", "VALIGN", ")", ")", "{", "labelAttributes", "+=", "\" \"", "+", "VALIGN_TOP", ";", "}", "return", "addBinding", "(", "createBinding", "(", "fieldName", ",", "textArea", ")", ",", "new", "JScrollPane", "(", "textArea", ")", ",", "attributes", ",", "labelAttributes", ")", ";", "}" ]
Adds the field to the form by using a text area component which is wrapped inside a scrollpane. {@link #createTextArea(String)} is used to create the component for the text area field <p> Note: this method ensures that the the label of the textarea has a top vertical alignment if <code>valign</code> is not defined in the default label attributes @param fieldName the name of the field to add @param attributes optional layout attributes for the scrollpane. See {@link TableLayoutBuilder} for syntax details @return an array containing the label, the textarea and the scrollpane and which where added to the form @see #createTextArea(String)
[ "Adds", "the", "field", "to", "the", "form", "by", "using", "a", "text", "area", "component", "which", "is", "wrapped", "inside", "a", "scrollpane", ".", "{", "@link", "#createTextArea", "(", "String", ")", "}", "is", "used", "to", "create", "the", "component", "for", "the", "text", "area", "field", "<p", ">", "Note", ":", "this", "method", "ensures", "that", "the", "the", "label", "of", "the", "textarea", "has", "a", "top", "vertical", "alignment", "if", "<code", ">", "valign<", "/", "code", ">", "is", "not", "defined", "in", "the", "default", "label", "attributes" ]
train
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/TableFormBuilder.java#L245-L254
junit-team/junit4
src/main/java/org/junit/runner/Computer.java
Computer.getRunner
protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); }
java
protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); }
[ "protected", "Runner", "getRunner", "(", "RunnerBuilder", "builder", ",", "Class", "<", "?", ">", "testClass", ")", "throws", "Throwable", "{", "return", "builder", ".", "runnerForClass", "(", "testClass", ")", ";", "}" ]
Create a single-class runner for {@code testClass}, using {@code builder}
[ "Create", "a", "single", "-", "class", "runner", "for", "{" ]
train
https://github.com/junit-team/junit4/blob/d9861ecdb6e487f6c352437ee823879aca3b81d4/src/main/java/org/junit/runner/Computer.java#L49-L51
oehf/ipf-oht-atna
auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java
GenericAuditEventMessageImpl.setAuditSourceId
public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypeCodes[] typeCodes) { addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes); }
java
public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypeCodes[] typeCodes) { addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes); }
[ "public", "void", "setAuditSourceId", "(", "String", "sourceId", ",", "String", "enterpriseSiteId", ",", "RFC3881AuditSourceTypeCodes", "[", "]", "typeCodes", ")", "{", "addAuditSourceIdentification", "(", "sourceId", ",", "enterpriseSiteId", ",", "typeCodes", ")", ";", "}" ]
Sets a Audit Source Identification block for a given Audit Source ID, Audit Source Enterprise Site ID, and a list of audit source type codes @param sourceId The Audit Source ID to use @param enterpriseSiteId The Audit Enterprise Site ID to use @param typeCodes The RFC 3881 Audit Source Type codes to use @deprecated use {@link #setAuditSourceId(String, String, RFC3881AuditSourceTypes[])}
[ "Sets", "a", "Audit", "Source", "Identification", "block", "for", "a", "given", "Audit", "Source", "ID", "Audit", "Source", "Enterprise", "Site", "ID", "and", "a", "list", "of", "audit", "source", "type", "codes", "@param", "sourceId", "The", "Audit", "Source", "ID", "to", "use", "@param", "enterpriseSiteId", "The", "Audit", "Enterprise", "Site", "ID", "to", "use", "@param", "typeCodes", "The", "RFC", "3881", "Audit", "Source", "Type", "codes", "to", "use" ]
train
https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java#L91-L94
ZieIony/Carbon
carbon/src/main/java/carbon/drawable/ripple/TypedArrayCompat.java
TypedArrayCompat.getDrawable
public static Drawable getDrawable(Resources.Theme theme, TypedArray a, TypedValue[] values, int index) { if (values != null && theme != null) { TypedValue v = values[index]; if (v.type == TypedValue.TYPE_ATTRIBUTE) { TEMP_ARRAY[0] = v.data; TypedArray tmp = theme.obtainStyledAttributes(null, TEMP_ARRAY, 0, 0); try { return tmp.getDrawable(0); } finally { tmp.recycle(); } } } if (a != null) { return LollipopDrawablesCompat.getDrawable(a, index, theme); } return null; }
java
public static Drawable getDrawable(Resources.Theme theme, TypedArray a, TypedValue[] values, int index) { if (values != null && theme != null) { TypedValue v = values[index]; if (v.type == TypedValue.TYPE_ATTRIBUTE) { TEMP_ARRAY[0] = v.data; TypedArray tmp = theme.obtainStyledAttributes(null, TEMP_ARRAY, 0, 0); try { return tmp.getDrawable(0); } finally { tmp.recycle(); } } } if (a != null) { return LollipopDrawablesCompat.getDrawable(a, index, theme); } return null; }
[ "public", "static", "Drawable", "getDrawable", "(", "Resources", ".", "Theme", "theme", ",", "TypedArray", "a", ",", "TypedValue", "[", "]", "values", ",", "int", "index", ")", "{", "if", "(", "values", "!=", "null", "&&", "theme", "!=", "null", ")", "{", "TypedValue", "v", "=", "values", "[", "index", "]", ";", "if", "(", "v", ".", "type", "==", "TypedValue", ".", "TYPE_ATTRIBUTE", ")", "{", "TEMP_ARRAY", "[", "0", "]", "=", "v", ".", "data", ";", "TypedArray", "tmp", "=", "theme", ".", "obtainStyledAttributes", "(", "null", ",", "TEMP_ARRAY", ",", "0", ",", "0", ")", ";", "try", "{", "return", "tmp", ".", "getDrawable", "(", "0", ")", ";", "}", "finally", "{", "tmp", ".", "recycle", "(", ")", ";", "}", "}", "}", "if", "(", "a", "!=", "null", ")", "{", "return", "LollipopDrawablesCompat", ".", "getDrawable", "(", "a", ",", "index", ",", "theme", ")", ";", "}", "return", "null", ";", "}" ]
Retrieve the Drawable for the attribute at <var>index</var>. @param index Index of attribute to retrieve. @return Drawable for the attribute, or null if not defined.
[ "Retrieve", "the", "Drawable", "for", "the", "attribute", "at", "<var", ">", "index<", "/", "var", ">", "." ]
train
https://github.com/ZieIony/Carbon/blob/78b0a432bd49edc7a6a13ce111cab274085d1693/carbon/src/main/java/carbon/drawable/ripple/TypedArrayCompat.java#L77-L98
iig-uni-freiburg/SEWOL
src/de/uni/freiburg/iig/telematik/sewol/log/LogViewSerialization.java
LogViewSerialization.write
public static void write(LogView logView, String path) throws IOException { String xml = xstream.toXML(logView); try (BufferedWriter out = new BufferedWriter(new FileWriter(path))) { out.write(xml); } }
java
public static void write(LogView logView, String path) throws IOException { String xml = xstream.toXML(logView); try (BufferedWriter out = new BufferedWriter(new FileWriter(path))) { out.write(xml); } }
[ "public", "static", "void", "write", "(", "LogView", "logView", ",", "String", "path", ")", "throws", "IOException", "{", "String", "xml", "=", "xstream", ".", "toXML", "(", "logView", ")", ";", "try", "(", "BufferedWriter", "out", "=", "new", "BufferedWriter", "(", "new", "FileWriter", "(", "path", ")", ")", ")", "{", "out", ".", "write", "(", "xml", ")", ";", "}", "}" ]
Serializes the log view under the given path. @param logView Log view to serialize. @param path Target path of the serialized log view. @throws IOException If the log view can't be written under the given path.
[ "Serializes", "the", "log", "view", "under", "the", "given", "path", "." ]
train
https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/src/de/uni/freiburg/iig/telematik/sewol/log/LogViewSerialization.java#L160-L165
alkacon/opencms-core
src-gwt/org/opencms/gwt/client/util/CmsSlideAnimation.java
CmsSlideAnimation.slideOut
public static CmsSlideAnimation slideOut(Element element, Command callback, int duration) { CmsSlideAnimation animation = new CmsSlideAnimation(element, false, callback); animation.run(duration); return animation; }
java
public static CmsSlideAnimation slideOut(Element element, Command callback, int duration) { CmsSlideAnimation animation = new CmsSlideAnimation(element, false, callback); animation.run(duration); return animation; }
[ "public", "static", "CmsSlideAnimation", "slideOut", "(", "Element", "element", ",", "Command", "callback", ",", "int", "duration", ")", "{", "CmsSlideAnimation", "animation", "=", "new", "CmsSlideAnimation", "(", "element", ",", "false", ",", "callback", ")", ";", "animation", ".", "run", "(", "duration", ")", ";", "return", "animation", ";", "}" ]
Slides the given element out of view executing the callback afterwards.<p> @param element the element to slide out @param callback the callback @param duration the animation duration @return the running animation object
[ "Slides", "the", "given", "element", "out", "of", "view", "executing", "the", "callback", "afterwards", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsSlideAnimation.java#L102-L107
primefaces/primefaces
src/main/java/org/primefaces/util/FileUploadUtils.java
FileUploadUtils.isValidType
public static boolean isValidType(FileUpload fileUpload, String fileName, InputStream inputStream) { try { boolean validType = isValidFileName(fileUpload, fileName) && isValidFileContent(fileUpload, fileName, inputStream); if (validType) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(String.format("The uploaded file %s meets the filename and content type specifications", fileName)); } } return validType; } catch (IOException | ScriptException ex) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, String.format("The type of the uploaded file %s could not be validated", fileName), ex); } return false; } }
java
public static boolean isValidType(FileUpload fileUpload, String fileName, InputStream inputStream) { try { boolean validType = isValidFileName(fileUpload, fileName) && isValidFileContent(fileUpload, fileName, inputStream); if (validType) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(String.format("The uploaded file %s meets the filename and content type specifications", fileName)); } } return validType; } catch (IOException | ScriptException ex) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, String.format("The type of the uploaded file %s could not be validated", fileName), ex); } return false; } }
[ "public", "static", "boolean", "isValidType", "(", "FileUpload", "fileUpload", ",", "String", "fileName", ",", "InputStream", "inputStream", ")", "{", "try", "{", "boolean", "validType", "=", "isValidFileName", "(", "fileUpload", ",", "fileName", ")", "&&", "isValidFileContent", "(", "fileUpload", ",", "fileName", ",", "inputStream", ")", ";", "if", "(", "validType", ")", "{", "if", "(", "LOGGER", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "LOGGER", ".", "fine", "(", "String", ".", "format", "(", "\"The uploaded file %s meets the filename and content type specifications\"", ",", "fileName", ")", ")", ";", "}", "}", "return", "validType", ";", "}", "catch", "(", "IOException", "|", "ScriptException", "ex", ")", "{", "if", "(", "LOGGER", ".", "isLoggable", "(", "Level", ".", "WARNING", ")", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "String", ".", "format", "(", "\"The type of the uploaded file %s could not be validated\"", ",", "fileName", ")", ",", "ex", ")", ";", "}", "return", "false", ";", "}", "}" ]
Check if an uploaded file meets all specifications regarding its filename and content type. It evaluates {@link FileUpload#getAllowTypes} as well as {@link FileUpload#getAccept} and uses the installed {@link java.nio.file.spi.FileTypeDetector} implementation. For most reliable content type checking it's recommended to plug in Apache Tika as an implementation. @param fileUpload the fileUpload component @param fileName the name of the uploaded file @param inputStream the input stream to receive the file's content from @return <code>true</code>, if all validations regarding filename and content type passed, <code>false</code> else
[ "Check", "if", "an", "uploaded", "file", "meets", "all", "specifications", "regarding", "its", "filename", "and", "content", "type", ".", "It", "evaluates", "{" ]
train
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/FileUploadUtils.java#L143-L159
gallandarakhneorg/afc
advanced/attributes/src/main/java/org/arakhne/afc/attrs/collection/BufferedAttributeCollection.java
BufferedAttributeCollection.setAttributeFromRawValue
protected Attribute setAttributeFromRawValue(String name, AttributeValue value) throws AttributeException { return setAttributeFromRawValue(name, value.getType(), value.getValue()); }
java
protected Attribute setAttributeFromRawValue(String name, AttributeValue value) throws AttributeException { return setAttributeFromRawValue(name, value.getType(), value.getValue()); }
[ "protected", "Attribute", "setAttributeFromRawValue", "(", "String", "name", ",", "AttributeValue", "value", ")", "throws", "AttributeException", "{", "return", "setAttributeFromRawValue", "(", "name", ",", "value", ".", "getType", "(", ")", ",", "value", ".", "getValue", "(", ")", ")", ";", "}" ]
Set the attribute value. @param name is the name of the attribute @param value is the raw value to store. @return the new created attribute @throws AttributeException on error.
[ "Set", "the", "attribute", "value", "." ]
train
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/attributes/src/main/java/org/arakhne/afc/attrs/collection/BufferedAttributeCollection.java#L229-L231
to2mbn/JMCCC
jmccc/src/main/java/org/to2mbn/jmccc/util/ExtraArgumentsTemplates.java
ExtraArgumentsTemplates.OSX_DOCK_ICON
public static String OSX_DOCK_ICON(MinecraftDirectory minecraftDir, Version version) throws IOException { Set<Asset> assetIndex = Versions.resolveAssets(minecraftDir, version); if (assetIndex == null) return null; return OSX_DOCK_ICON(minecraftDir, assetIndex); }
java
public static String OSX_DOCK_ICON(MinecraftDirectory minecraftDir, Version version) throws IOException { Set<Asset> assetIndex = Versions.resolveAssets(minecraftDir, version); if (assetIndex == null) return null; return OSX_DOCK_ICON(minecraftDir, assetIndex); }
[ "public", "static", "String", "OSX_DOCK_ICON", "(", "MinecraftDirectory", "minecraftDir", ",", "Version", "version", ")", "throws", "IOException", "{", "Set", "<", "Asset", ">", "assetIndex", "=", "Versions", ".", "resolveAssets", "(", "minecraftDir", ",", "version", ")", ";", "if", "(", "assetIndex", "==", "null", ")", "return", "null", ";", "return", "OSX_DOCK_ICON", "(", "minecraftDir", ",", "assetIndex", ")", ";", "}" ]
Caution: This option is available only on OSX. @param minecraftDir the minecraft directory @param version the minecraft version @return a <code>-Xdock:icon</code> option, null if the assets cannot be resolved @throws IOException if an I/O error has occurred during resolving asset index @see #OSX_DOCK_ICON(MinecraftDirectory, Set) @see #OSX_DOCK_NAME
[ "Caution", ":", "This", "option", "is", "available", "only", "on", "OSX", "." ]
train
https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/util/ExtraArgumentsTemplates.java#L63-L69
jpmml/jpmml-evaluator
pmml-evaluator/src/main/java/org/jpmml/evaluator/TypeUtil.java
TypeUtil.toDouble
static private Double toDouble(Object value){ if(value instanceof Double){ return (Double)value; } else if((value instanceof Float) || (value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)){ Number number = (Number)value; return toDouble(number.doubleValue()); } else if(value instanceof Boolean){ Boolean flag = (Boolean)value; return (flag.booleanValue() ? Numbers.DOUBLE_ONE : Numbers.DOUBLE_ZERO); } else if((value instanceof DaysSinceDate) || (value instanceof SecondsSinceDate) || (value instanceof SecondsSinceMidnight)){ Number number = (Number)value; return toDouble(number.doubleValue()); } throw new TypeCheckException(DataType.DOUBLE, value); }
java
static private Double toDouble(Object value){ if(value instanceof Double){ return (Double)value; } else if((value instanceof Float) || (value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)){ Number number = (Number)value; return toDouble(number.doubleValue()); } else if(value instanceof Boolean){ Boolean flag = (Boolean)value; return (flag.booleanValue() ? Numbers.DOUBLE_ONE : Numbers.DOUBLE_ZERO); } else if((value instanceof DaysSinceDate) || (value instanceof SecondsSinceDate) || (value instanceof SecondsSinceMidnight)){ Number number = (Number)value; return toDouble(number.doubleValue()); } throw new TypeCheckException(DataType.DOUBLE, value); }
[ "static", "private", "Double", "toDouble", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "Double", ")", "{", "return", "(", "Double", ")", "value", ";", "}", "else", "if", "(", "(", "value", "instanceof", "Float", ")", "||", "(", "value", "instanceof", "Long", ")", "||", "(", "value", "instanceof", "Integer", ")", "||", "(", "value", "instanceof", "Short", ")", "||", "(", "value", "instanceof", "Byte", ")", ")", "{", "Number", "number", "=", "(", "Number", ")", "value", ";", "return", "toDouble", "(", "number", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "Boolean", "flag", "=", "(", "Boolean", ")", "value", ";", "return", "(", "flag", ".", "booleanValue", "(", ")", "?", "Numbers", ".", "DOUBLE_ONE", ":", "Numbers", ".", "DOUBLE_ZERO", ")", ";", "}", "else", "if", "(", "(", "value", "instanceof", "DaysSinceDate", ")", "||", "(", "value", "instanceof", "SecondsSinceDate", ")", "||", "(", "value", "instanceof", "SecondsSinceMidnight", ")", ")", "{", "Number", "number", "=", "(", "Number", ")", "value", ";", "return", "toDouble", "(", "number", ".", "doubleValue", "(", ")", ")", ";", "}", "throw", "new", "TypeCheckException", "(", "DataType", ".", "DOUBLE", ",", "value", ")", ";", "}" ]
<p> Casts the specified value to Double data type. </p> @see DataType#DOUBLE
[ "<p", ">", "Casts", "the", "specified", "value", "to", "Double", "data", "type", ".", "<", "/", "p", ">" ]
train
https://github.com/jpmml/jpmml-evaluator/blob/ac8a48775877b6fa9dbc5f259871f3278489cc61/pmml-evaluator/src/main/java/org/jpmml/evaluator/TypeUtil.java#L688-L714
jparsec/jparsec
jparsec/src/main/java/org/jparsec/Terminals.java
Terminals.caseSensitive
@Deprecated public static Terminals caseSensitive(String[] ops, String[] keywords) { return operators(ops).words(Scanners.IDENTIFIER).keywords(asList(keywords)).build(); }
java
@Deprecated public static Terminals caseSensitive(String[] ops, String[] keywords) { return operators(ops).words(Scanners.IDENTIFIER).keywords(asList(keywords)).build(); }
[ "@", "Deprecated", "public", "static", "Terminals", "caseSensitive", "(", "String", "[", "]", "ops", ",", "String", "[", "]", "keywords", ")", "{", "return", "operators", "(", "ops", ")", ".", "words", "(", "Scanners", ".", "IDENTIFIER", ")", ".", "keywords", "(", "asList", "(", "keywords", ")", ")", ".", "build", "(", ")", ";", "}" ]
Returns a {@link Terminals} object for lexing and parsing the operators with names specified in {@code ops}, and for lexing and parsing the keywords case sensitively. Parsers for operators and keywords can be obtained through {@link #token}; parsers for identifiers through {@link #identifier}. <p>In detail, keywords and operators are lexed as {@link Tokens.Fragment} with {@link Tag#RESERVED} tag. Words that are not among {@code keywords} are lexed as {@code Fragment} with {@link Tag#IDENTIFIER} tag. <p>A word is defined as an alphanumeric string that starts with {@code [_a - zA - Z]}, with 0 or more {@code [0 - 9_a - zA - Z]} following. @param ops the operator names. @param keywords the keyword names. @return the Terminals instance. @deprecated Use {@code operators(ops) .words(Scanners.IDENTIFIER) .keywords(keywords) .build()} instead.
[ "Returns", "a", "{", "@link", "Terminals", "}", "object", "for", "lexing", "and", "parsing", "the", "operators", "with", "names", "specified", "in", "{", "@code", "ops", "}", "and", "for", "lexing", "and", "parsing", "the", "keywords", "case", "sensitively", ".", "Parsers", "for", "operators", "and", "keywords", "can", "be", "obtained", "through", "{", "@link", "#token", "}", ";", "parsers", "for", "identifiers", "through", "{", "@link", "#identifier", "}", "." ]
train
https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Terminals.java#L267-L270
apache/flink
flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java
TypeExtractionUtils.validateLambdaType
public static void validateLambdaType(Class<?> baseClass, Type t) { if (!(t instanceof Class)) { return; } final Class<?> clazz = (Class<?>) t; if (clazz.getTypeParameters().length > 0) { throw new InvalidTypesException("The generic type parameters of '" + clazz.getSimpleName() + "' are missing. " + "In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved. " + "An easy workaround is to use an (anonymous) class instead that implements the '" + baseClass.getName() + "' interface. " + "Otherwise the type has to be specified explicitly using type information."); } }
java
public static void validateLambdaType(Class<?> baseClass, Type t) { if (!(t instanceof Class)) { return; } final Class<?> clazz = (Class<?>) t; if (clazz.getTypeParameters().length > 0) { throw new InvalidTypesException("The generic type parameters of '" + clazz.getSimpleName() + "' are missing. " + "In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved. " + "An easy workaround is to use an (anonymous) class instead that implements the '" + baseClass.getName() + "' interface. " + "Otherwise the type has to be specified explicitly using type information."); } }
[ "public", "static", "void", "validateLambdaType", "(", "Class", "<", "?", ">", "baseClass", ",", "Type", "t", ")", "{", "if", "(", "!", "(", "t", "instanceof", "Class", ")", ")", "{", "return", ";", "}", "final", "Class", "<", "?", ">", "clazz", "=", "(", "Class", "<", "?", ">", ")", "t", ";", "if", "(", "clazz", ".", "getTypeParameters", "(", ")", ".", "length", ">", "0", ")", "{", "throw", "new", "InvalidTypesException", "(", "\"The generic type parameters of '\"", "+", "clazz", ".", "getSimpleName", "(", ")", "+", "\"' are missing. \"", "+", "\"In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved. \"", "+", "\"An easy workaround is to use an (anonymous) class instead that implements the '\"", "+", "baseClass", ".", "getName", "(", ")", "+", "\"' interface. \"", "+", "\"Otherwise the type has to be specified explicitly using type information.\"", ")", ";", "}", "}" ]
Checks whether the given type has the generic parameters declared in the class definition. @param t type to be validated
[ "Checks", "whether", "the", "given", "type", "has", "the", "generic", "parameters", "declared", "in", "the", "class", "definition", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java#L341-L353
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java
FontUtils.drawRight
public static void drawRight(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.RIGHT, x, y, width, Color.white); }
java
public static void drawRight(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.RIGHT, x, y, width, Color.white); }
[ "public", "static", "void", "drawRight", "(", "Font", "font", ",", "String", "s", ",", "int", "x", ",", "int", "y", ",", "int", "width", ")", "{", "drawString", "(", "font", ",", "s", ",", "Alignment", ".", "RIGHT", ",", "x", ",", "y", ",", "width", ",", "Color", ".", "white", ")", ";", "}" ]
Draw text right justified @param font The font to draw with @param s The string to draw @param x The x location to draw at @param y The y location to draw at @param width The width to fill with the text
[ "Draw", "text", "right", "justified" ]
train
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java#L79-L81
fhoeben/hsac-fitnesse-fixtures
src/main/java/nl/hsac/fitnesse/fixture/util/LambdaMetaHelper.java
LambdaMetaHelper.getConstructor
public <T, A> Function<A, T> getConstructor(Class<? extends T> clazz, Class<A> arg) { return getConstructorAs(Function.class, "apply", clazz, arg); }
java
public <T, A> Function<A, T> getConstructor(Class<? extends T> clazz, Class<A> arg) { return getConstructorAs(Function.class, "apply", clazz, arg); }
[ "public", "<", "T", ",", "A", ">", "Function", "<", "A", ",", "T", ">", "getConstructor", "(", "Class", "<", "?", "extends", "T", ">", "clazz", ",", "Class", "<", "A", ">", "arg", ")", "{", "return", "getConstructorAs", "(", "Function", ".", "class", ",", "\"apply\"", ",", "clazz", ",", "arg", ")", ";", "}" ]
Gets single arg constructor as Function. @param clazz class to get constructor for. @param arg constructor argument type. @param <T> clazz. @param <A> argument class. @return function.
[ "Gets", "single", "arg", "constructor", "as", "Function", "." ]
train
https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/LambdaMetaHelper.java#L37-L39
JosePaumard/streams-utils
src/main/java/org/paumard/streams/StreamsUtils.java
StreamsUtils.shiftingWindowSummarizingLong
public static <E> Stream<LongSummaryStatistics> shiftingWindowSummarizingLong(Stream<E> stream, int rollingFactor, ToLongFunction<? super E> mapper) { Objects.requireNonNull(stream); Objects.requireNonNull(mapper); LongStream longStream = stream.mapToLong(mapper); return shiftingWindowSummarizingLong(longStream, rollingFactor); }
java
public static <E> Stream<LongSummaryStatistics> shiftingWindowSummarizingLong(Stream<E> stream, int rollingFactor, ToLongFunction<? super E> mapper) { Objects.requireNonNull(stream); Objects.requireNonNull(mapper); LongStream longStream = stream.mapToLong(mapper); return shiftingWindowSummarizingLong(longStream, rollingFactor); }
[ "public", "static", "<", "E", ">", "Stream", "<", "LongSummaryStatistics", ">", "shiftingWindowSummarizingLong", "(", "Stream", "<", "E", ">", "stream", ",", "int", "rollingFactor", ",", "ToLongFunction", "<", "?", "super", "E", ">", "mapper", ")", "{", "Objects", ".", "requireNonNull", "(", "stream", ")", ";", "Objects", ".", "requireNonNull", "(", "mapper", ")", ";", "LongStream", "longStream", "=", "stream", ".", "mapToLong", "(", "mapper", ")", ";", "return", "shiftingWindowSummarizingLong", "(", "longStream", ",", "rollingFactor", ")", ";", "}" ]
<p>Generates a stream that is computed from a provided stream following two steps.</p> <p>The first steps maps this stream to an <code>LongStream</code> that is then rolled following the same principle as the <code>roll()</code> method. This steps builds a <code>Stream&lt;LongStream&gt;</code>. </p> <p>Then long summary statistics are computed on each <code>LongStream</code> using a <code>collect()</code> call, and a <code>Stream&lt;LongSummaryStatistics&gt;</code> is returned.</p> <p>The resulting stream has the same number of elements as the provided stream, minus the size of the window width, to preserve consistency of each collection. </p> <p>A <code>NullPointerException</code> will be thrown if the provided stream or the mapper is null.</p> @param stream the processed stream @param rollingFactor the size of the window to apply the collector on @param mapper the mapper applied @param <E> the type of the provided stream @return a stream in which each value is the collection of the provided stream
[ "<p", ">", "Generates", "a", "stream", "that", "is", "computed", "from", "a", "provided", "stream", "following", "two", "steps", ".", "<", "/", "p", ">", "<p", ">", "The", "first", "steps", "maps", "this", "stream", "to", "an", "<code", ">", "LongStream<", "/", "code", ">", "that", "is", "then", "rolled", "following", "the", "same", "principle", "as", "the", "<code", ">", "roll", "()", "<", "/", "code", ">", "method", ".", "This", "steps", "builds", "a", "<code", ">", "Stream&lt", ";", "LongStream&gt", ";", "<", "/", "code", ">", ".", "<", "/", "p", ">", "<p", ">", "Then", "long", "summary", "statistics", "are", "computed", "on", "each", "<code", ">", "LongStream<", "/", "code", ">", "using", "a", "<code", ">", "collect", "()", "<", "/", "code", ">", "call", "and", "a", "<code", ">", "Stream&lt", ";", "LongSummaryStatistics&gt", ";", "<", "/", "code", ">", "is", "returned", ".", "<", "/", "p", ">", "<p", ">", "The", "resulting", "stream", "has", "the", "same", "number", "of", "elements", "as", "the", "provided", "stream", "minus", "the", "size", "of", "the", "window", "width", "to", "preserve", "consistency", "of", "each", "collection", ".", "<", "/", "p", ">", "<p", ">", "A", "<code", ">", "NullPointerException<", "/", "code", ">", "will", "be", "thrown", "if", "the", "provided", "stream", "or", "the", "mapper", "is", "null", ".", "<", "/", "p", ">" ]
train
https://github.com/JosePaumard/streams-utils/blob/56152574af0aca44c5f679761202a8f90984ab73/src/main/java/org/paumard/streams/StreamsUtils.java#L751-L757
datacleaner/DataCleaner
desktop/ui/src/main/java/org/datacleaner/windows/CreateTableDialog.java
CreateTableDialog.isCreateTableAppropriate
public static boolean isCreateTableAppropriate(final Datastore datastore, final Schema schema) { if (datastore == null || schema == null) { return false; } if (!(datastore instanceof UpdateableDatastore)) { return false; } if (datastore instanceof CsvDatastore) { // see issue https://issues.apache.org/jira/browse/METAMODEL-31 - as // long as this is an issue we do not want to expose "create table" // functionality to CSV datastores. return false; } if (MetaModelHelper.isInformationSchema(schema)) { return false; } return true; }
java
public static boolean isCreateTableAppropriate(final Datastore datastore, final Schema schema) { if (datastore == null || schema == null) { return false; } if (!(datastore instanceof UpdateableDatastore)) { return false; } if (datastore instanceof CsvDatastore) { // see issue https://issues.apache.org/jira/browse/METAMODEL-31 - as // long as this is an issue we do not want to expose "create table" // functionality to CSV datastores. return false; } if (MetaModelHelper.isInformationSchema(schema)) { return false; } return true; }
[ "public", "static", "boolean", "isCreateTableAppropriate", "(", "final", "Datastore", "datastore", ",", "final", "Schema", "schema", ")", "{", "if", "(", "datastore", "==", "null", "||", "schema", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "!", "(", "datastore", "instanceof", "UpdateableDatastore", ")", ")", "{", "return", "false", ";", "}", "if", "(", "datastore", "instanceof", "CsvDatastore", ")", "{", "// see issue https://issues.apache.org/jira/browse/METAMODEL-31 - as", "// long as this is an issue we do not want to expose \"create table\"", "// functionality to CSV datastores.", "return", "false", ";", "}", "if", "(", "MetaModelHelper", ".", "isInformationSchema", "(", "schema", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determines if it is appropriate/possible to create a table in a particular schema or a particular datastore. @param datastore @param schema @return
[ "Determines", "if", "it", "is", "appropriate", "/", "possible", "to", "create", "a", "table", "in", "a", "particular", "schema", "or", "a", "particular", "datastore", "." ]
train
https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/desktop/ui/src/main/java/org/datacleaner/windows/CreateTableDialog.java#L117-L134
Javacord/Javacord
javacord-api/src/main/java/org/javacord/api/AccountUpdater.java
AccountUpdater.setAvatar
public AccountUpdater setAvatar(InputStream avatar, String fileType) { delegate.setAvatar(avatar, fileType); return this; }
java
public AccountUpdater setAvatar(InputStream avatar, String fileType) { delegate.setAvatar(avatar, fileType); return this; }
[ "public", "AccountUpdater", "setAvatar", "(", "InputStream", "avatar", ",", "String", "fileType", ")", "{", "delegate", ".", "setAvatar", "(", "avatar", ",", "fileType", ")", ";", "return", "this", ";", "}" ]
Queues the avatar of the connected account to get updated. @param avatar The avatar to set. @param fileType The type of the avatar, e.g. "png" or "jpg". @return The current instance in order to chain call methods.
[ "Queues", "the", "avatar", "of", "the", "connected", "account", "to", "get", "updated", "." ]
train
https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/AccountUpdater.java#L143-L146
OpenLiberty/open-liberty
dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelUtilsBase.java
ChannelUtilsBase.traceChains
protected final void traceChains(Object logTool, ChannelFramework cfw, Class<?> factory, String message, String prefix) { ChainData[] chains = null; String fstring = "(" + (factory == null ? "no factory specified" : factory.getName()) + ")"; if (cfw == null) { debugTrace(logTool, prefix + " - No cfw to test factory " + fstring); return; } try { if (factory != null) chains = cfw.getAllChains(factory); else chains = cfw.getAllChains(); } catch (Exception e) { debugTrace(logTool, "Caught Exception while trying to display configured chains: ", e); return; } if (chains == null || chains.length <= 0) debugTrace(logTool, prefix + " - No chains found for factory " + fstring); else traceChains(logTool, Arrays.asList(chains), message, prefix); }
java
protected final void traceChains(Object logTool, ChannelFramework cfw, Class<?> factory, String message, String prefix) { ChainData[] chains = null; String fstring = "(" + (factory == null ? "no factory specified" : factory.getName()) + ")"; if (cfw == null) { debugTrace(logTool, prefix + " - No cfw to test factory " + fstring); return; } try { if (factory != null) chains = cfw.getAllChains(factory); else chains = cfw.getAllChains(); } catch (Exception e) { debugTrace(logTool, "Caught Exception while trying to display configured chains: ", e); return; } if (chains == null || chains.length <= 0) debugTrace(logTool, prefix + " - No chains found for factory " + fstring); else traceChains(logTool, Arrays.asList(chains), message, prefix); }
[ "protected", "final", "void", "traceChains", "(", "Object", "logTool", ",", "ChannelFramework", "cfw", ",", "Class", "<", "?", ">", "factory", ",", "String", "message", ",", "String", "prefix", ")", "{", "ChainData", "[", "]", "chains", "=", "null", ";", "String", "fstring", "=", "\"(\"", "+", "(", "factory", "==", "null", "?", "\"no factory specified\"", ":", "factory", ".", "getName", "(", ")", ")", "+", "\")\"", ";", "if", "(", "cfw", "==", "null", ")", "{", "debugTrace", "(", "logTool", ",", "prefix", "+", "\" - No cfw to test factory \"", "+", "fstring", ")", ";", "return", ";", "}", "try", "{", "if", "(", "factory", "!=", "null", ")", "chains", "=", "cfw", ".", "getAllChains", "(", "factory", ")", ";", "else", "chains", "=", "cfw", ".", "getAllChains", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "debugTrace", "(", "logTool", ",", "\"Caught Exception while trying to display configured chains: \"", ",", "e", ")", ";", "return", ";", "}", "if", "(", "chains", "==", "null", "||", "chains", ".", "length", "<=", "0", ")", "debugTrace", "(", "logTool", ",", "prefix", "+", "\" - No chains found for factory \"", "+", "fstring", ")", ";", "else", "traceChains", "(", "logTool", ",", "Arrays", ".", "asList", "(", "chains", ")", ",", "message", ",", "prefix", ")", ";", "}" ]
Display configured channel chains. @param logTool Caller's LogTool (should be Logger OR TraceComponent) @param cfw Reference to channel framework service @param factory Factory class that chains to be traced are associated with (e.g. ORBInboundChannelFactory.. ) @param message Description to accompany trace, e.g. "CFW Channel Configuration" @param prefix Component-type prefix used to associate traces together, e.g. "XMEM", "ZIOP", "TCP", "SOAP"
[ "Display", "configured", "channel", "chains", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelUtilsBase.java#L62-L85
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExtraLanguageGenerator.java
AbstractExtraLanguageGenerator.toFilename
protected String toFilename(QualifiedName name, String separator) { final List<String> segments = name.getSegments(); if (segments.isEmpty()) { return ""; //$NON-NLS-1$ } final StringBuilder builder = new StringBuilder(); builder.append(name.toString(separator)); builder.append(getFilenameExtension()); return builder.toString(); }
java
protected String toFilename(QualifiedName name, String separator) { final List<String> segments = name.getSegments(); if (segments.isEmpty()) { return ""; //$NON-NLS-1$ } final StringBuilder builder = new StringBuilder(); builder.append(name.toString(separator)); builder.append(getFilenameExtension()); return builder.toString(); }
[ "protected", "String", "toFilename", "(", "QualifiedName", "name", ",", "String", "separator", ")", "{", "final", "List", "<", "String", ">", "segments", "=", "name", ".", "getSegments", "(", ")", ";", "if", "(", "segments", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "//$NON-NLS-1$", "}", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "name", ".", "toString", "(", "separator", ")", ")", ";", "builder", ".", "append", "(", "getFilenameExtension", "(", ")", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Replies the filename for the qualified name. @param name the qualified name. @param separator the filename separator. @return the filename.
[ "Replies", "the", "filename", "for", "the", "qualified", "name", "." ]
train
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExtraLanguageGenerator.java#L438-L447
mfornos/humanize
humanize-icu/src/main/java/humanize/ICUHumanize.java
ICUHumanize.naturalTime
public static String naturalTime(final Date reference, final Date duration, final Locale locale) { return withinLocale(new Callable<String>() { public String call() { return naturalTime(reference, duration); } }, locale); }
java
public static String naturalTime(final Date reference, final Date duration, final Locale locale) { return withinLocale(new Callable<String>() { public String call() { return naturalTime(reference, duration); } }, locale); }
[ "public", "static", "String", "naturalTime", "(", "final", "Date", "reference", ",", "final", "Date", "duration", ",", "final", "Locale", "locale", ")", "{", "return", "withinLocale", "(", "new", "Callable", "<", "String", ">", "(", ")", "{", "public", "String", "call", "(", ")", "{", "return", "naturalTime", "(", "reference", ",", "duration", ")", ";", "}", "}", ",", "locale", ")", ";", "}" ]
<p> Same as {@link #naturalTime(Date, Date) naturalTime} for the specified locale. </p> @param reference Date to be used as reference @param duration Date to be used as duration from reference @param locale Target locale @return String representing the relative date
[ "<p", ">", "Same", "as", "{", "@link", "#naturalTime", "(", "Date", "Date", ")", "naturalTime", "}", "for", "the", "specified", "locale", ".", "<", "/", "p", ">" ]
train
https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-icu/src/main/java/humanize/ICUHumanize.java#L1356-L1365
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cql3/ErrorCollector.java
ErrorCollector.appendQuerySnippet
private void appendQuerySnippet(Parser parser, StringBuilder builder) { TokenStream tokenStream = parser.getTokenStream(); int index = tokenStream.index(); int size = tokenStream.size(); Token from = tokenStream.get(getSnippetFirstTokenIndex(index)); Token to = tokenStream.get(getSnippetLastTokenIndex(index, size)); Token offending = tokenStream.get(getOffendingTokenIndex(index, size)); appendSnippet(builder, from, to, offending); }
java
private void appendQuerySnippet(Parser parser, StringBuilder builder) { TokenStream tokenStream = parser.getTokenStream(); int index = tokenStream.index(); int size = tokenStream.size(); Token from = tokenStream.get(getSnippetFirstTokenIndex(index)); Token to = tokenStream.get(getSnippetLastTokenIndex(index, size)); Token offending = tokenStream.get(getOffendingTokenIndex(index, size)); appendSnippet(builder, from, to, offending); }
[ "private", "void", "appendQuerySnippet", "(", "Parser", "parser", ",", "StringBuilder", "builder", ")", "{", "TokenStream", "tokenStream", "=", "parser", ".", "getTokenStream", "(", ")", ";", "int", "index", "=", "tokenStream", ".", "index", "(", ")", ";", "int", "size", "=", "tokenStream", ".", "size", "(", ")", ";", "Token", "from", "=", "tokenStream", ".", "get", "(", "getSnippetFirstTokenIndex", "(", "index", ")", ")", ";", "Token", "to", "=", "tokenStream", ".", "get", "(", "getSnippetLastTokenIndex", "(", "index", ",", "size", ")", ")", ";", "Token", "offending", "=", "tokenStream", ".", "get", "(", "getOffendingTokenIndex", "(", "index", ",", "size", ")", ")", ";", "appendSnippet", "(", "builder", ",", "from", ",", "to", ",", "offending", ")", ";", "}" ]
Appends a query snippet to the message to help the user to understand the problem. @param parser the parser used to parse the query @param builder the <code>StringBuilder</code> used to build the error message
[ "Appends", "a", "query", "snippet", "to", "the", "message", "to", "help", "the", "user", "to", "understand", "the", "problem", "." ]
train
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/ErrorCollector.java#L110-L121
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UniversalTimeScale.java
UniversalTimeScale.toBigDecimal
public static BigDecimal toBigDecimal(long universalTime, int timeScale) { TimeScaleData data = getTimeScaleData(timeScale); BigDecimal universal = new BigDecimal(universalTime); BigDecimal units = new BigDecimal(data.units); BigDecimal epochOffset = new BigDecimal(data.epochOffset); return universal.divide(units, BigDecimal.ROUND_HALF_UP).subtract(epochOffset); }
java
public static BigDecimal toBigDecimal(long universalTime, int timeScale) { TimeScaleData data = getTimeScaleData(timeScale); BigDecimal universal = new BigDecimal(universalTime); BigDecimal units = new BigDecimal(data.units); BigDecimal epochOffset = new BigDecimal(data.epochOffset); return universal.divide(units, BigDecimal.ROUND_HALF_UP).subtract(epochOffset); }
[ "public", "static", "BigDecimal", "toBigDecimal", "(", "long", "universalTime", ",", "int", "timeScale", ")", "{", "TimeScaleData", "data", "=", "getTimeScaleData", "(", "timeScale", ")", ";", "BigDecimal", "universal", "=", "new", "BigDecimal", "(", "universalTime", ")", ";", "BigDecimal", "units", "=", "new", "BigDecimal", "(", "data", ".", "units", ")", ";", "BigDecimal", "epochOffset", "=", "new", "BigDecimal", "(", "data", ".", "epochOffset", ")", ";", "return", "universal", ".", "divide", "(", "units", ",", "BigDecimal", ".", "ROUND_HALF_UP", ")", ".", "subtract", "(", "epochOffset", ")", ";", "}" ]
Convert a datetime from the universal time scale to a <code>BigDecimal</code> in the given time scale. @param universalTime The datetime in the universal time scale @param timeScale The time scale to convert to @return The datetime converted to the given time scale
[ "Convert", "a", "datetime", "from", "the", "universal", "time", "scale", "to", "a", "<code", ">", "BigDecimal<", "/", "code", ">", "in", "the", "given", "time", "scale", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UniversalTimeScale.java#L467-L475
eclipse/xtext-lib
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java
ProcedureExtensions.curry
@Pure public static <P1, P2, P3, P4, P5> Procedure4<P2, P3, P4, P5> curry(final Procedure5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5> procedure, final P1 argument) { if (procedure == null) throw new NullPointerException("procedure"); return new Procedure4<P2, P3, P4, P5>() { @Override public void apply(P2 p2, P3 p3, P4 p4, P5 p5) { procedure.apply(argument, p2, p3, p4, p5); } }; }
java
@Pure public static <P1, P2, P3, P4, P5> Procedure4<P2, P3, P4, P5> curry(final Procedure5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5> procedure, final P1 argument) { if (procedure == null) throw new NullPointerException("procedure"); return new Procedure4<P2, P3, P4, P5>() { @Override public void apply(P2 p2, P3 p3, P4 p4, P5 p5) { procedure.apply(argument, p2, p3, p4, p5); } }; }
[ "@", "Pure", "public", "static", "<", "P1", ",", "P2", ",", "P3", ",", "P4", ",", "P5", ">", "Procedure4", "<", "P2", ",", "P3", ",", "P4", ",", "P5", ">", "curry", "(", "final", "Procedure5", "<", "?", "super", "P1", ",", "?", "super", "P2", ",", "?", "super", "P3", ",", "?", "super", "P4", ",", "?", "super", "P5", ">", "procedure", ",", "final", "P1", "argument", ")", "{", "if", "(", "procedure", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"procedure\"", ")", ";", "return", "new", "Procedure4", "<", "P2", ",", "P3", ",", "P4", ",", "P5", ">", "(", ")", "{", "@", "Override", "public", "void", "apply", "(", "P2", "p2", ",", "P3", "p3", ",", "P4", "p4", ",", "P5", "p5", ")", "{", "procedure", ".", "apply", "(", "argument", ",", "p2", ",", "p3", ",", "p4", ",", "p5", ")", ";", "}", "}", ";", "}" ]
Curries a procedure that takes five arguments. @param procedure the original procedure. May not be <code>null</code>. @param argument the fixed first argument of {@code procedure}. @return a procedure that takes four arguments. Never <code>null</code>.
[ "Curries", "a", "procedure", "that", "takes", "five", "arguments", "." ]
train
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java#L122-L133
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.durationMS
public static long durationMS(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) { return 0; } return Duration.between(start, end).toMillis(); }
java
public static long durationMS(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) { return 0; } return Duration.between(start, end).toMillis(); }
[ "public", "static", "long", "durationMS", "(", "LocalDateTime", "start", ",", "LocalDateTime", "end", ")", "{", "if", "(", "start", "==", "null", "||", "end", "==", "null", ")", "{", "return", "0", ";", "}", "return", "Duration", ".", "between", "(", "start", ",", "end", ")", ".", "toMillis", "(", ")", ";", "}" ]
The time between two dates @param start the begin time @param end the finish time @return duration in milliseconds
[ "The", "time", "between", "two", "dates" ]
train
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L85-L93
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
CacheProxyUtil.validateConfiguredKeyType
public static <K> void validateConfiguredKeyType(Class<K> keyType, K key) throws ClassCastException { if (Object.class != keyType) { // means that type checks is required if (!keyType.isAssignableFrom(key.getClass())) { throw new ClassCastException("Key '" + key + "' is not assignable to " + keyType); } } }
java
public static <K> void validateConfiguredKeyType(Class<K> keyType, K key) throws ClassCastException { if (Object.class != keyType) { // means that type checks is required if (!keyType.isAssignableFrom(key.getClass())) { throw new ClassCastException("Key '" + key + "' is not assignable to " + keyType); } } }
[ "public", "static", "<", "K", ">", "void", "validateConfiguredKeyType", "(", "Class", "<", "K", ">", "keyType", ",", "K", "key", ")", "throws", "ClassCastException", "{", "if", "(", "Object", ".", "class", "!=", "keyType", ")", "{", "// means that type checks is required", "if", "(", "!", "keyType", ".", "isAssignableFrom", "(", "key", ".", "getClass", "(", ")", ")", ")", "{", "throw", "new", "ClassCastException", "(", "\"Key '\"", "+", "key", "+", "\"' is not assignable to \"", "+", "keyType", ")", ";", "}", "}", "}" ]
Validates the key with key type. @param keyType key class. @param key key to be validated. @param <K> the type of key. @throws ClassCastException if the provided key do not match with keyType.
[ "Validates", "the", "key", "with", "key", "type", "." ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L214-L221
NordicSemiconductor/Android-DFU-Library
dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java
SecureDfuImpl.writeCreateRequest
private void writeCreateRequest(final int type, final int size) throws DeviceDisconnectedException, DfuException, UploadAbortedException, RemoteDfuException, UnknownResponseException { if (!mConnected) throw new DeviceDisconnectedException("Unable to create object: device disconnected"); final byte[] data = (type == OBJECT_COMMAND) ? OP_CODE_CREATE_COMMAND : OP_CODE_CREATE_DATA; setObjectSize(data, size); writeOpCode(mControlPointCharacteristic, data); final byte[] response = readNotificationResponse(); final int status = getStatusCode(response, OP_CODE_CREATE_KEY); if (status == SecureDfuError.EXTENDED_ERROR) throw new RemoteDfuExtendedErrorException("Creating Command object failed", response[3]); if (status != DFU_STATUS_SUCCESS) throw new RemoteDfuException("Creating Command object failed", status); }
java
private void writeCreateRequest(final int type, final int size) throws DeviceDisconnectedException, DfuException, UploadAbortedException, RemoteDfuException, UnknownResponseException { if (!mConnected) throw new DeviceDisconnectedException("Unable to create object: device disconnected"); final byte[] data = (type == OBJECT_COMMAND) ? OP_CODE_CREATE_COMMAND : OP_CODE_CREATE_DATA; setObjectSize(data, size); writeOpCode(mControlPointCharacteristic, data); final byte[] response = readNotificationResponse(); final int status = getStatusCode(response, OP_CODE_CREATE_KEY); if (status == SecureDfuError.EXTENDED_ERROR) throw new RemoteDfuExtendedErrorException("Creating Command object failed", response[3]); if (status != DFU_STATUS_SUCCESS) throw new RemoteDfuException("Creating Command object failed", status); }
[ "private", "void", "writeCreateRequest", "(", "final", "int", "type", ",", "final", "int", "size", ")", "throws", "DeviceDisconnectedException", ",", "DfuException", ",", "UploadAbortedException", ",", "RemoteDfuException", ",", "UnknownResponseException", "{", "if", "(", "!", "mConnected", ")", "throw", "new", "DeviceDisconnectedException", "(", "\"Unable to create object: device disconnected\"", ")", ";", "final", "byte", "[", "]", "data", "=", "(", "type", "==", "OBJECT_COMMAND", ")", "?", "OP_CODE_CREATE_COMMAND", ":", "OP_CODE_CREATE_DATA", ";", "setObjectSize", "(", "data", ",", "size", ")", ";", "writeOpCode", "(", "mControlPointCharacteristic", ",", "data", ")", ";", "final", "byte", "[", "]", "response", "=", "readNotificationResponse", "(", ")", ";", "final", "int", "status", "=", "getStatusCode", "(", "response", ",", "OP_CODE_CREATE_KEY", ")", ";", "if", "(", "status", "==", "SecureDfuError", ".", "EXTENDED_ERROR", ")", "throw", "new", "RemoteDfuExtendedErrorException", "(", "\"Creating Command object failed\"", ",", "response", "[", "3", "]", ")", ";", "if", "(", "status", "!=", "DFU_STATUS_SUCCESS", ")", "throw", "new", "RemoteDfuException", "(", "\"Creating Command object failed\"", ",", "status", ")", ";", "}" ]
Writes Create Object request providing the type and size of the object. @param type {@link #OBJECT_COMMAND} or {@link #OBJECT_DATA}. @param size size of the object or current part of the object. @throws DeviceDisconnectedException @throws DfuException @throws UploadAbortedException @throws RemoteDfuException thrown when the returned status code is not equal to {@link #DFU_STATUS_SUCCESS} @throws UnknownResponseException
[ "Writes", "Create", "Object", "request", "providing", "the", "type", "and", "size", "of", "the", "object", "." ]
train
https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ec14c8c522bebe801a9a4c3dfbbeb1f53262c03f/dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java#L807-L823
google/j2objc
jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerValue.java
DerValue.getPositiveBigInteger
public BigInteger getPositiveBigInteger() throws IOException { if (tag != tag_Integer) throw new IOException("DerValue.getBigInteger, not an int " + tag); return buffer.getBigInteger(data.available(), true); }
java
public BigInteger getPositiveBigInteger() throws IOException { if (tag != tag_Integer) throw new IOException("DerValue.getBigInteger, not an int " + tag); return buffer.getBigInteger(data.available(), true); }
[ "public", "BigInteger", "getPositiveBigInteger", "(", ")", "throws", "IOException", "{", "if", "(", "tag", "!=", "tag_Integer", ")", "throw", "new", "IOException", "(", "\"DerValue.getBigInteger, not an int \"", "+", "tag", ")", ";", "return", "buffer", ".", "getBigInteger", "(", "data", ".", "available", "(", ")", ",", "true", ")", ";", "}" ]
Returns an ASN.1 INTEGER value as a positive BigInteger. This is just to deal with implementations that incorrectly encode some values as negative. @return the integer held in this DER value as a BigInteger.
[ "Returns", "an", "ASN", ".", "1", "INTEGER", "value", "as", "a", "positive", "BigInteger", ".", "This", "is", "just", "to", "deal", "with", "implementations", "that", "incorrectly", "encode", "some", "values", "as", "negative", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerValue.java#L535-L539
lievendoclo/Valkyrie-RCP
valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/LayoutManager.java
LayoutManager.loadPageLayoutData
public static boolean loadPageLayoutData(DockingManager manager, String pageId, Perspective perspective){ manager.beginLoadLayoutData(); try{ if(isValidLayout(manager, pageId, perspective)){ String pageLayout = MessageFormat.format(PAGE_LAYOUT, pageId, perspective.getId()); manager.loadLayoutDataFrom(pageLayout); return true; } else{ manager.loadLayoutData(); return false; } } catch(Exception e){ manager.loadLayoutData(); return false; } }
java
public static boolean loadPageLayoutData(DockingManager manager, String pageId, Perspective perspective){ manager.beginLoadLayoutData(); try{ if(isValidLayout(manager, pageId, perspective)){ String pageLayout = MessageFormat.format(PAGE_LAYOUT, pageId, perspective.getId()); manager.loadLayoutDataFrom(pageLayout); return true; } else{ manager.loadLayoutData(); return false; } } catch(Exception e){ manager.loadLayoutData(); return false; } }
[ "public", "static", "boolean", "loadPageLayoutData", "(", "DockingManager", "manager", ",", "String", "pageId", ",", "Perspective", "perspective", ")", "{", "manager", ".", "beginLoadLayoutData", "(", ")", ";", "try", "{", "if", "(", "isValidLayout", "(", "manager", ",", "pageId", ",", "perspective", ")", ")", "{", "String", "pageLayout", "=", "MessageFormat", ".", "format", "(", "PAGE_LAYOUT", ",", "pageId", ",", "perspective", ".", "getId", "(", ")", ")", ";", "manager", ".", "loadLayoutDataFrom", "(", "pageLayout", ")", ";", "return", "true", ";", "}", "else", "{", "manager", ".", "loadLayoutData", "(", ")", ";", "return", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "manager", ".", "loadLayoutData", "(", ")", ";", "return", "false", ";", "}", "}" ]
Loads a the previously saved layout for the current page. If no previously persisted layout exists for the given page the built in default layout is used. @param manager The docking manager to use @param pageId The page to get the layout for @return a boolean saying if the layout requested was previously saved
[ "Loads", "a", "the", "previously", "saved", "layout", "for", "the", "current", "page", ".", "If", "no", "previously", "persisted", "layout", "exists", "for", "the", "given", "page", "the", "built", "in", "default", "layout", "is", "used", "." ]
train
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/LayoutManager.java#L51-L68
alkacon/opencms-core
src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java
CmsContainerpageController.addToRecentList
public void addToRecentList(final String clientId, final Runnable nextAction) { CmsRpcAction<Void> action = new CmsRpcAction<Void>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { getContainerpageService().addToRecentList(getData().getRpcContext(), clientId, this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override protected void onResponse(Void result) { if (nextAction != null) { nextAction.run(); } } }; action.execute(); }
java
public void addToRecentList(final String clientId, final Runnable nextAction) { CmsRpcAction<Void> action = new CmsRpcAction<Void>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { getContainerpageService().addToRecentList(getData().getRpcContext(), clientId, this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override protected void onResponse(Void result) { if (nextAction != null) { nextAction.run(); } } }; action.execute(); }
[ "public", "void", "addToRecentList", "(", "final", "String", "clientId", ",", "final", "Runnable", "nextAction", ")", "{", "CmsRpcAction", "<", "Void", ">", "action", "=", "new", "CmsRpcAction", "<", "Void", ">", "(", ")", "{", "/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()\n */", "@", "Override", "public", "void", "execute", "(", ")", "{", "getContainerpageService", "(", ")", ".", "addToRecentList", "(", "getData", "(", ")", ".", "getRpcContext", "(", ")", ",", "clientId", ",", "this", ")", ";", "}", "/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)\n */", "@", "Override", "protected", "void", "onResponse", "(", "Void", "result", ")", "{", "if", "(", "nextAction", "!=", "null", ")", "{", "nextAction", ".", "run", "(", ")", ";", "}", "}", "}", ";", "action", ".", "execute", "(", ")", ";", "}" ]
Adds an element specified by it's id to the recent list.<p> @param clientId the element id @param nextAction the action to execute after the element has been added
[ "Adds", "an", "element", "specified", "by", "it", "s", "id", "to", "the", "recent", "list", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java#L875-L900
lightbend/config
config/src/main/java/com/typesafe/config/ConfigFactory.java
ConfigFactory.parseResources
public static Config parseResources(ClassLoader loader, String resource) { return parseResources(loader, resource, ConfigParseOptions.defaults()); }
java
public static Config parseResources(ClassLoader loader, String resource) { return parseResources(loader, resource, ConfigParseOptions.defaults()); }
[ "public", "static", "Config", "parseResources", "(", "ClassLoader", "loader", ",", "String", "resource", ")", "{", "return", "parseResources", "(", "loader", ",", "resource", ",", "ConfigParseOptions", ".", "defaults", "(", ")", ")", ";", "}" ]
Like {@link #parseResources(ClassLoader,String,ConfigParseOptions)} but always uses default parse options. @param loader will be used to load resources @param resource resource to look up in the loader @return the parsed configuration
[ "Like", "{", "@link", "#parseResources", "(", "ClassLoader", "String", "ConfigParseOptions", ")", "}", "but", "always", "uses", "default", "parse", "options", "." ]
train
https://github.com/lightbend/config/blob/68cebfde5e861e9a5fdc75ceff366ed95e17d475/config/src/main/java/com/typesafe/config/ConfigFactory.java#L948-L950
headius/invokebinder
src/main/java/com/headius/invokebinder/Binder.java
Binder.invokeStatic
public MethodHandle invokeStatic(MethodHandles.Lookup lookup, Class<?> target, String name) throws NoSuchMethodException, IllegalAccessException { return invoke(lookup.findStatic(target, name, type())); }
java
public MethodHandle invokeStatic(MethodHandles.Lookup lookup, Class<?> target, String name) throws NoSuchMethodException, IllegalAccessException { return invoke(lookup.findStatic(target, name, type())); }
[ "public", "MethodHandle", "invokeStatic", "(", "MethodHandles", ".", "Lookup", "lookup", ",", "Class", "<", "?", ">", "target", ",", "String", "name", ")", "throws", "NoSuchMethodException", ",", "IllegalAccessException", "{", "return", "invoke", "(", "lookup", ".", "findStatic", "(", "target", ",", "name", ",", "type", "(", ")", ")", ")", ";", "}" ]
Apply the chain of transforms and bind them to a static method specified using the end signature plus the given class and name. The method will be retrieved using the given Lookup and must match the end signature exactly. If the final handle's type does not exactly match the initial type for this Binder, an additional cast will be attempted. @param lookup the MethodHandles.Lookup to use to unreflect the method @param target the class in which to find the method @param name the name of the method to invoke @return the full handle chain, bound to the given method @throws java.lang.NoSuchMethodException if the method does not exist @throws java.lang.IllegalAccessException if the method is not accessible
[ "Apply", "the", "chain", "of", "transforms", "and", "bind", "them", "to", "a", "static", "method", "specified", "using", "the", "end", "signature", "plus", "the", "given", "class", "and", "name", ".", "The", "method", "will", "be", "retrieved", "using", "the", "given", "Lookup", "and", "must", "match", "the", "end", "signature", "exactly", "." ]
train
https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1210-L1212
sawano/java-commons
src/main/java/se/sawano/java/commons/lang/validate/Validate.java
Validate.notNull
public static <T> T notNull(final T object, final String message, final Object... values) { return INSTANCE.notNull(object, message, values); }
java
public static <T> T notNull(final T object, final String message, final Object... values) { return INSTANCE.notNull(object, message, values); }
[ "public", "static", "<", "T", ">", "T", "notNull", "(", "final", "T", "object", ",", "final", "String", "message", ",", "final", "Object", "...", "values", ")", "{", "return", "INSTANCE", ".", "notNull", "(", "object", ",", "message", ",", "values", ")", ";", "}" ]
<p>Validate that the specified argument is not {@code null}; otherwise throwing an exception with the specified message. <pre>Validate.notNull(myObject, "The object must not be null");</pre> @param <T> the object type @param object the object to check @param message the {@link String#format(String, Object...)} exception message if invalid, not null @param values the optional values for the formatted exception message @return the validated object (never {@code null} for method chaining) @throws NullPointerValidationException if the object is {@code null} @see #notNull(Object)
[ "<p", ">", "Validate", "that", "the", "specified", "argument", "is", "not", "{", "@code", "null", "}", ";", "otherwise", "throwing", "an", "exception", "with", "the", "specified", "message", ".", "<pre", ">", "Validate", ".", "notNull", "(", "myObject", "The", "object", "must", "not", "be", "null", ")", ";", "<", "/", "pre", ">" ]
train
https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/Validate.java#L788-L790
astrapi69/jaulp-wicket
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/textfield/LabeledPasswordTextFieldPanel.java
LabeledPasswordTextFieldPanel.newPasswordTextField
protected PasswordTextField newPasswordTextField(final String id, final IModel<M> model) { return ComponentFactory.newPasswordTextField(id, new PropertyModel<String>(model.getObject(), getId())); }
java
protected PasswordTextField newPasswordTextField(final String id, final IModel<M> model) { return ComponentFactory.newPasswordTextField(id, new PropertyModel<String>(model.getObject(), getId())); }
[ "protected", "PasswordTextField", "newPasswordTextField", "(", "final", "String", "id", ",", "final", "IModel", "<", "M", ">", "model", ")", "{", "return", "ComponentFactory", ".", "newPasswordTextField", "(", "id", ",", "new", "PropertyModel", "<", "String", ">", "(", "model", ".", "getObject", "(", ")", ",", "getId", "(", ")", ")", ")", ";", "}" ]
Factory method for create the new {@link PasswordTextField}. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a new {@link PasswordTextField}. @param id the id @param model the model @return the new {@link PasswordTextField}
[ "Factory", "method", "for", "create", "the", "new", "{", "@link", "PasswordTextField", "}", ".", "This", "method", "is", "invoked", "in", "the", "constructor", "from", "the", "derived", "classes", "and", "can", "be", "overridden", "so", "users", "can", "provide", "their", "own", "version", "of", "a", "new", "{", "@link", "PasswordTextField", "}", "." ]
train
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/textfield/LabeledPasswordTextFieldPanel.java#L92-L96
phax/peppol-directory
peppol-directory-indexer/src/main/java/com/helger/pd/indexer/lucene/PDLucene.java
PDLucene.readLockedAtomic
@Nullable public <T> T readLockedAtomic (@Nonnull final IThrowingSupplier <T, IOException> aRunnable) throws IOException { m_aRWLock.readLock ().lock (); try { if (isClosing ()) LOGGER.info ("Cannot executed something read locked, because Lucene is shutting down"); else return aRunnable.get (); } finally { m_aRWLock.readLock ().unlock (); } return null; }
java
@Nullable public <T> T readLockedAtomic (@Nonnull final IThrowingSupplier <T, IOException> aRunnable) throws IOException { m_aRWLock.readLock ().lock (); try { if (isClosing ()) LOGGER.info ("Cannot executed something read locked, because Lucene is shutting down"); else return aRunnable.get (); } finally { m_aRWLock.readLock ().unlock (); } return null; }
[ "@", "Nullable", "public", "<", "T", ">", "T", "readLockedAtomic", "(", "@", "Nonnull", "final", "IThrowingSupplier", "<", "T", ",", "IOException", ">", "aRunnable", ")", "throws", "IOException", "{", "m_aRWLock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "isClosing", "(", ")", ")", "LOGGER", ".", "info", "(", "\"Cannot executed something read locked, because Lucene is shutting down\"", ")", ";", "else", "return", "aRunnable", ".", "get", "(", ")", ";", "}", "finally", "{", "m_aRWLock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "return", "null", ";", "}" ]
Run the provided action within a locked section.<br> Note: because of a problem with JDK 1.8.60 (+) command line compiler, this method uses type "Exception" instead of "IOException" in the parameter signature @param aRunnable Callback to be executed. @return <code>null</code> if the index is just closing @throws IOException may be thrown by the callback @param <T> Result type
[ "Run", "the", "provided", "action", "within", "a", "locked", "section", ".", "<br", ">", "Note", ":", "because", "of", "a", "problem", "with", "JDK", "1", ".", "8", ".", "60", "(", "+", ")", "command", "line", "compiler", "this", "method", "uses", "type", "Exception", "instead", "of", "IOException", "in", "the", "parameter", "signature" ]
train
https://github.com/phax/peppol-directory/blob/98da26da29fb7178371d6b029516cbf01be223fb/peppol-directory-indexer/src/main/java/com/helger/pd/indexer/lucene/PDLucene.java#L415-L431
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.fetchDeviceList
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException { PubSubManager pm = PubSubManager.getInstanceFor(connection, contact); String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; LeafNode node = pm.getLeafNode(nodeName); if (node == null) { return null; } List<PayloadItem<OmemoDeviceListElement>> items = node.getItems(); if (items.isEmpty()) { return null; } return items.get(items.size() - 1).getPayload(); }
java
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException { PubSubManager pm = PubSubManager.getInstanceFor(connection, contact); String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; LeafNode node = pm.getLeafNode(nodeName); if (node == null) { return null; } List<PayloadItem<OmemoDeviceListElement>> items = node.getItems(); if (items.isEmpty()) { return null; } return items.get(items.size() - 1).getPayload(); }
[ "private", "static", "OmemoDeviceListElement", "fetchDeviceList", "(", "XMPPConnection", "connection", ",", "BareJid", "contact", ")", "throws", "InterruptedException", ",", "PubSubException", ".", "NotALeafNodeException", ",", "SmackException", ".", "NoResponseException", ",", "SmackException", ".", "NotConnectedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "PubSubException", ".", "NotAPubSubNodeException", "{", "PubSubManager", "pm", "=", "PubSubManager", ".", "getInstanceFor", "(", "connection", ",", "contact", ")", ";", "String", "nodeName", "=", "OmemoConstants", ".", "PEP_NODE_DEVICE_LIST", ";", "LeafNode", "node", "=", "pm", ".", "getLeafNode", "(", "nodeName", ")", ";", "if", "(", "node", "==", "null", ")", "{", "return", "null", ";", "}", "List", "<", "PayloadItem", "<", "OmemoDeviceListElement", ">", ">", "items", "=", "node", ".", "getItems", "(", ")", ";", "if", "(", "items", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "return", "items", ".", "get", "(", "items", ".", "size", "(", ")", "-", "1", ")", ".", "getPayload", "(", ")", ";", "}" ]
Retrieve the OMEMO device list of a contact. @param connection authenticated XMPP connection. @param contact BareJid of the contact of which we want to retrieve the device list from. @return @throws InterruptedException @throws PubSubException.NotALeafNodeException @throws SmackException.NoResponseException @throws SmackException.NotConnectedException @throws XMPPException.XMPPErrorException @throws PubSubException.NotAPubSubNodeException
[ "Retrieve", "the", "OMEMO", "device", "list", "of", "a", "contact", "." ]
train
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L604-L623
greatman/GreatmancodeTools
src/main/java/com/greatmancode/tools/utils/Metrics.java
Metrics.appendJSONPair
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; } } catch (NumberFormatException e) { isValueNumeric = false; } if (json.charAt(json.length() - 1) != '{') { json.append(','); } json.append(escapeJSON(key)); json.append(':'); if (isValueNumeric) { json.append(value); } else { json.append(escapeJSON(value)); } }
java
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; } } catch (NumberFormatException e) { isValueNumeric = false; } if (json.charAt(json.length() - 1) != '{') { json.append(','); } json.append(escapeJSON(key)); json.append(':'); if (isValueNumeric) { json.append(value); } else { json.append(escapeJSON(value)); } }
[ "private", "static", "void", "appendJSONPair", "(", "StringBuilder", "json", ",", "String", "key", ",", "String", "value", ")", "throws", "UnsupportedEncodingException", "{", "boolean", "isValueNumeric", "=", "false", ";", "try", "{", "if", "(", "value", ".", "equals", "(", "\"0\"", ")", "||", "!", "value", ".", "endsWith", "(", "\"0\"", ")", ")", "{", "Double", ".", "parseDouble", "(", "value", ")", ";", "isValueNumeric", "=", "true", ";", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "isValueNumeric", "=", "false", ";", "}", "if", "(", "json", ".", "charAt", "(", "json", ".", "length", "(", ")", "-", "1", ")", "!=", "'", "'", ")", "{", "json", ".", "append", "(", "'", "'", ")", ";", "}", "json", ".", "append", "(", "escapeJSON", "(", "key", ")", ")", ";", "json", ".", "append", "(", "'", "'", ")", ";", "if", "(", "isValueNumeric", ")", "{", "json", ".", "append", "(", "value", ")", ";", "}", "else", "{", "json", ".", "append", "(", "escapeJSON", "(", "value", ")", ")", ";", "}", "}" ]
Appends a json encoded key/value pair to the given string builder. @param json @param key @param value @throws UnsupportedEncodingException
[ "Appends", "a", "json", "encoded", "key", "/", "value", "pair", "to", "the", "given", "string", "builder", "." ]
train
https://github.com/greatman/GreatmancodeTools/blob/4c9d2656c5c8298ff9e1f235c9be8b148e43c9f1/src/main/java/com/greatmancode/tools/utils/Metrics.java#L547-L571
twotoasters/JazzyListView
library/src/main/java/com/twotoasters/jazzylistview/JazzyHelper.java
JazzyHelper.notifyAdditionalOnScrollListener
private void notifyAdditionalOnScrollListener(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mAdditionalOnScrollListener != null) { mAdditionalOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } }
java
private void notifyAdditionalOnScrollListener(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mAdditionalOnScrollListener != null) { mAdditionalOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } }
[ "private", "void", "notifyAdditionalOnScrollListener", "(", "AbsListView", "view", ",", "int", "firstVisibleItem", ",", "int", "visibleItemCount", ",", "int", "totalItemCount", ")", "{", "if", "(", "mAdditionalOnScrollListener", "!=", "null", ")", "{", "mAdditionalOnScrollListener", ".", "onScroll", "(", "view", ",", "firstVisibleItem", ",", "visibleItemCount", ",", "totalItemCount", ")", ";", "}", "}" ]
Notifies the OnScrollListener of an onScroll event, since JazzyListView is the primary listener for onScroll events.
[ "Notifies", "the", "OnScrollListener", "of", "an", "onScroll", "event", "since", "JazzyListView", "is", "the", "primary", "listener", "for", "onScroll", "events", "." ]
train
https://github.com/twotoasters/JazzyListView/blob/4a69239f90374a71e7d4073448ca049bd074f7fe/library/src/main/java/com/twotoasters/jazzylistview/JazzyHelper.java#L296-L300
finmath/finmath-lib
src/main/java/net/finmath/montecarlo/interestrate/models/HullWhiteModel.java
HullWhiteModel.getA
private RandomVariable getA(double time, double maturity) { int timeIndex = getProcess().getTimeIndex(time); double timeStep = getProcess().getTimeDiscretization().getTimeStep(timeIndex); RandomVariable zeroRate = getZeroRateFromForwardCurve(time); //getDiscountFactorFromForwardCurve(time).div(getDiscountFactorFromForwardCurve(timeNext)).log().div(timeNext-time); RandomVariable forwardBond = getDiscountFactorFromForwardCurve(maturity).div(getDiscountFactorFromForwardCurve(time)).log(); RandomVariable B = getB(time,maturity); RandomVariable lnA = B.mult(zeroRate).sub(B.squared().mult(getShortRateConditionalVariance(0,time).div(2))).add(forwardBond); return lnA.exp(); }
java
private RandomVariable getA(double time, double maturity) { int timeIndex = getProcess().getTimeIndex(time); double timeStep = getProcess().getTimeDiscretization().getTimeStep(timeIndex); RandomVariable zeroRate = getZeroRateFromForwardCurve(time); //getDiscountFactorFromForwardCurve(time).div(getDiscountFactorFromForwardCurve(timeNext)).log().div(timeNext-time); RandomVariable forwardBond = getDiscountFactorFromForwardCurve(maturity).div(getDiscountFactorFromForwardCurve(time)).log(); RandomVariable B = getB(time,maturity); RandomVariable lnA = B.mult(zeroRate).sub(B.squared().mult(getShortRateConditionalVariance(0,time).div(2))).add(forwardBond); return lnA.exp(); }
[ "private", "RandomVariable", "getA", "(", "double", "time", ",", "double", "maturity", ")", "{", "int", "timeIndex", "=", "getProcess", "(", ")", ".", "getTimeIndex", "(", "time", ")", ";", "double", "timeStep", "=", "getProcess", "(", ")", ".", "getTimeDiscretization", "(", ")", ".", "getTimeStep", "(", "timeIndex", ")", ";", "RandomVariable", "zeroRate", "=", "getZeroRateFromForwardCurve", "(", "time", ")", ";", "//getDiscountFactorFromForwardCurve(time).div(getDiscountFactorFromForwardCurve(timeNext)).log().div(timeNext-time);", "RandomVariable", "forwardBond", "=", "getDiscountFactorFromForwardCurve", "(", "maturity", ")", ".", "div", "(", "getDiscountFactorFromForwardCurve", "(", "time", ")", ")", ".", "log", "(", ")", ";", "RandomVariable", "B", "=", "getB", "(", "time", ",", "maturity", ")", ";", "RandomVariable", "lnA", "=", "B", ".", "mult", "(", "zeroRate", ")", ".", "sub", "(", "B", ".", "squared", "(", ")", ".", "mult", "(", "getShortRateConditionalVariance", "(", "0", ",", "time", ")", ".", "div", "(", "2", ")", ")", ")", ".", "add", "(", "forwardBond", ")", ";", "return", "lnA", ".", "exp", "(", ")", ";", "}" ]
Returns A(t,T) where \( A(t,T) = P(T)/P(t) \cdot exp(B(t,T) \cdot f(0,t) - \frac{1}{2} \phi(0,t) * B(t,T)^{2} ) \) and \( \phi(t,T) \) is the value calculated from integrating \( ( \sigma(s) exp(-\int_{s}^{T} a(\tau) \mathrm{d}\tau ) )^{2} \) with respect to s from t to T in <code>getShortRateConditionalVariance</code>. @param time The parameter t. @param maturity The parameter T. @return The value A(t,T).
[ "Returns", "A", "(", "t", "T", ")", "where", "\\", "(", "A", "(", "t", "T", ")", "=", "P", "(", "T", ")", "/", "P", "(", "t", ")", "\\", "cdot", "exp", "(", "B", "(", "t", "T", ")", "\\", "cdot", "f", "(", "0", "t", ")", "-", "\\", "frac", "{", "1", "}", "{", "2", "}", "\\", "phi", "(", "0", "t", ")", "*", "B", "(", "t", "T", ")", "^", "{", "2", "}", ")", "\\", ")", "and", "\\", "(", "\\", "phi", "(", "t", "T", ")", "\\", ")", "is", "the", "value", "calculated", "from", "integrating", "\\", "(", "(", "\\", "sigma", "(", "s", ")", "exp", "(", "-", "\\", "int_", "{", "s", "}", "^", "{", "T", "}", "a", "(", "\\", "tau", ")", "\\", "mathrm", "{", "d", "}", "\\", "tau", ")", ")", "^", "{", "2", "}", "\\", ")", "with", "respect", "to", "s", "from", "t", "to", "T", "in", "<code", ">", "getShortRateConditionalVariance<", "/", "code", ">", "." ]
train
https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/montecarlo/interestrate/models/HullWhiteModel.java#L558-L571
OpenLiberty/open-liberty
dev/com.ibm.ws.kernel.boot.core/src/com/ibm/wsspi/kernel/embeddable/ServerBuilder.java
ServerBuilder.addProductExtension
public ServerBuilder addProductExtension(String name, Properties props) { if ((name != null) && (props != null)) { if (productExtensions == null) { productExtensions = new HashMap<String, Properties>(); } this.productExtensions.put(name, props); } return this; }
java
public ServerBuilder addProductExtension(String name, Properties props) { if ((name != null) && (props != null)) { if (productExtensions == null) { productExtensions = new HashMap<String, Properties>(); } this.productExtensions.put(name, props); } return this; }
[ "public", "ServerBuilder", "addProductExtension", "(", "String", "name", ",", "Properties", "props", ")", "{", "if", "(", "(", "name", "!=", "null", ")", "&&", "(", "props", "!=", "null", ")", ")", "{", "if", "(", "productExtensions", "==", "null", ")", "{", "productExtensions", "=", "new", "HashMap", "<", "String", ",", "Properties", ">", "(", ")", ";", "}", "this", ".", "productExtensions", ".", "put", "(", "name", ",", "props", ")", ";", "}", "return", "this", ";", "}" ]
Add a product extension. <p> The addProductExtension method can be called multiple times to add multiple extensions. <p> When the server is started, any product extension files added by this method will be combined with the product extension files found in other source locations. Any duplicate product names will invoke the following override logic: product extensions defined through this SPI will override product extensions defined by the Environment variable <code>WLP_PRODUCT_EXT_DIR</code> which in turn would override product extensions found in <code>$WLP_INSTALL_DIR/etc/extensions</code> to constitute the full set of product extensions for this instance of the running server. @param name The name of the product extension. @param props A properties file containing com.ibm.websphere.productId and com.ibm.websphere.productInstall. @return a reference to this object.
[ "Add", "a", "product", "extension", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/wsspi/kernel/embeddable/ServerBuilder.java#L214-L222
alibaba/Virtualview-Android
virtualview/src/main/java/com/tmall/wireless/vaf/virtualview/Helper/RtlHelper.java
RtlHelper.getRealLeft
public static int getRealLeft(boolean isRtl, int parentLeft, int parentWidth, int left, int width) { if (isRtl) { // 1, trim the parent's left. left -= parentLeft; // 2, calculate the RTL left. left = parentWidth - width - left; // 3, add the parent's left. left += parentLeft; } return left; }
java
public static int getRealLeft(boolean isRtl, int parentLeft, int parentWidth, int left, int width) { if (isRtl) { // 1, trim the parent's left. left -= parentLeft; // 2, calculate the RTL left. left = parentWidth - width - left; // 3, add the parent's left. left += parentLeft; } return left; }
[ "public", "static", "int", "getRealLeft", "(", "boolean", "isRtl", ",", "int", "parentLeft", ",", "int", "parentWidth", ",", "int", "left", ",", "int", "width", ")", "{", "if", "(", "isRtl", ")", "{", "// 1, trim the parent's left.", "left", "-=", "parentLeft", ";", "// 2, calculate the RTL left.", "left", "=", "parentWidth", "-", "width", "-", "left", ";", "// 3, add the parent's left.", "left", "+=", "parentLeft", ";", "}", "return", "left", ";", "}" ]
Convert left to RTL left if need. @param parentLeft parent's left @param parentWidth parent's width @param left self's left @param width self's width @return
[ "Convert", "left", "to", "RTL", "left", "if", "need", "." ]
train
https://github.com/alibaba/Virtualview-Android/blob/30c65791f34458ec840e00d2b84ab2912ea102f0/virtualview/src/main/java/com/tmall/wireless/vaf/virtualview/Helper/RtlHelper.java#L49-L59
alkacon/opencms-core
src/org/opencms/jsp/CmsJspNavBuilder.java
CmsJspNavBuilder.isNavLevelFolder
public static boolean isNavLevelFolder(CmsObject cms, CmsResource resource) { if (resource.isFolder()) { I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type.getTypeName())) { try { CmsProperty prop = cms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false); return !prop.isNullProperty() && NAVIGATION_LEVEL_FOLDER.equals(prop.getValue()); } catch (CmsException e) { LOG.debug(e.getMessage(), e); } } } return false; }
java
public static boolean isNavLevelFolder(CmsObject cms, CmsResource resource) { if (resource.isFolder()) { I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type.getTypeName())) { try { CmsProperty prop = cms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false); return !prop.isNullProperty() && NAVIGATION_LEVEL_FOLDER.equals(prop.getValue()); } catch (CmsException e) { LOG.debug(e.getMessage(), e); } } } return false; }
[ "public", "static", "boolean", "isNavLevelFolder", "(", "CmsObject", "cms", ",", "CmsResource", "resource", ")", "{", "if", "(", "resource", ".", "isFolder", "(", ")", ")", "{", "I_CmsResourceType", "type", "=", "OpenCms", ".", "getResourceManager", "(", ")", ".", "getResourceType", "(", "resource", ")", ";", "if", "(", "CmsResourceTypeFolder", ".", "RESOURCE_TYPE_NAME", ".", "equals", "(", "type", ".", "getTypeName", "(", ")", ")", ")", "{", "try", "{", "CmsProperty", "prop", "=", "cms", ".", "readPropertyObject", "(", "resource", ",", "CmsPropertyDefinition", ".", "PROPERTY_DEFAULT_FILE", ",", "false", ")", ";", "return", "!", "prop", ".", "isNullProperty", "(", ")", "&&", "NAVIGATION_LEVEL_FOLDER", ".", "equals", "(", "prop", ".", "getValue", "(", ")", ")", ";", "}", "catch", "(", "CmsException", "e", ")", "{", "LOG", ".", "debug", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns whether the given resource is a folder and is marked to be a navigation level folder.<p> @param cms the cms context @param resource the resource @return <code>true</code> if the resource is marked to be a navigation level folder
[ "Returns", "whether", "the", "given", "resource", "is", "a", "folder", "and", "is", "marked", "to", "be", "a", "navigation", "level", "folder", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspNavBuilder.java#L332-L349
op4j/op4j
src/main/java/org/op4j/functions/Call.java
Call.shr
public static Function<Object,Short> shr(final String methodName, final Object... optionalParameters) { return methodForShort(methodName, optionalParameters); }
java
public static Function<Object,Short> shr(final String methodName, final Object... optionalParameters) { return methodForShort(methodName, optionalParameters); }
[ "public", "static", "Function", "<", "Object", ",", "Short", ">", "shr", "(", "final", "String", "methodName", ",", "final", "Object", "...", "optionalParameters", ")", "{", "return", "methodForShort", "(", "methodName", ",", "optionalParameters", ")", ";", "}" ]
<p> Abbreviation for {{@link #methodForShort(String, Object...)}. </p> @since 1.1 @param methodName the name of the method @param optionalParameters the (optional) parameters of the method. @return the result of the method execution
[ "<p", ">", "Abbreviation", "for", "{{", "@link", "#methodForShort", "(", "String", "Object", "...", ")", "}", ".", "<", "/", "p", ">" ]
train
https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/Call.java#L488-L490
santhosh-tekuri/jlibs
core/src/main/java/jlibs/core/lang/ArrayUtil.java
ArrayUtil.concat
public static Object[] concat(Object array1[], Object array2[]){ Class<?> class1 = array1.getClass().getComponentType(); Class<?> class2 = array2.getClass().getComponentType(); Class<?> commonClass = class1.isAssignableFrom(class2) ? class1 : (class2.isAssignableFrom(class1) ? class2 : Object.class); return concat(array1, array2, commonClass); }
java
public static Object[] concat(Object array1[], Object array2[]){ Class<?> class1 = array1.getClass().getComponentType(); Class<?> class2 = array2.getClass().getComponentType(); Class<?> commonClass = class1.isAssignableFrom(class2) ? class1 : (class2.isAssignableFrom(class1) ? class2 : Object.class); return concat(array1, array2, commonClass); }
[ "public", "static", "Object", "[", "]", "concat", "(", "Object", "array1", "[", "]", ",", "Object", "array2", "[", "]", ")", "{", "Class", "<", "?", ">", "class1", "=", "array1", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ";", "Class", "<", "?", ">", "class2", "=", "array2", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ";", "Class", "<", "?", ">", "commonClass", "=", "class1", ".", "isAssignableFrom", "(", "class2", ")", "?", "class1", ":", "(", "class2", ".", "isAssignableFrom", "(", "class1", ")", "?", "class2", ":", "Object", ".", "class", ")", ";", "return", "concat", "(", "array1", ",", "array2", ",", "commonClass", ")", ";", "}" ]
Returns new array which has all values from array1 and array2 in order. The componentType for the new array is determined by the componentTypes of two arrays.
[ "Returns", "new", "array", "which", "has", "all", "values", "from", "array1", "and", "array2", "in", "order", ".", "The", "componentType", "for", "the", "new", "array", "is", "determined", "by", "the", "componentTypes", "of", "two", "arrays", "." ]
train
https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/core/src/main/java/jlibs/core/lang/ArrayUtil.java#L195-L202
alkacon/opencms-core
src-gwt/org/opencms/gwt/client/ui/CmsAreaSelectPanel.java
CmsAreaSelectPanel.getYForX
private int getYForX(int newX, int newY) { int height = (int)Math.floor((newX - m_firstX) * m_heightToWidth); int result = m_firstY + height; if (((m_firstY - newY) * (m_firstY - result)) < 0) { result = m_firstY - height; } return result; }
java
private int getYForX(int newX, int newY) { int height = (int)Math.floor((newX - m_firstX) * m_heightToWidth); int result = m_firstY + height; if (((m_firstY - newY) * (m_firstY - result)) < 0) { result = m_firstY - height; } return result; }
[ "private", "int", "getYForX", "(", "int", "newX", ",", "int", "newY", ")", "{", "int", "height", "=", "(", "int", ")", "Math", ".", "floor", "(", "(", "newX", "-", "m_firstX", ")", "*", "m_heightToWidth", ")", ";", "int", "result", "=", "m_firstY", "+", "height", ";", "if", "(", "(", "(", "m_firstY", "-", "newY", ")", "*", "(", "m_firstY", "-", "result", ")", ")", "<", "0", ")", "{", "result", "=", "m_firstY", "-", "height", ";", "}", "return", "result", ";", "}" ]
Calculates the matching Y (top/height) value in case of a fixed height/width ratio.<p> @param newX the cursor X offset to the selection area @param newY the cursor Y offset to the selection area @return the matching Y value
[ "Calculates", "the", "matching", "Y", "(", "top", "/", "height", ")", "value", "in", "case", "of", "a", "fixed", "height", "/", "width", "ratio", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsAreaSelectPanel.java#L673-L681
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Request.java
Request.addParameter
public void addParameter(String name, String sub, Object data) { pack(name); pack(sub); pack(BrokerUtil.toString(data)); }
java
public void addParameter(String name, String sub, Object data) { pack(name); pack(sub); pack(BrokerUtil.toString(data)); }
[ "public", "void", "addParameter", "(", "String", "name", ",", "String", "sub", ",", "Object", "data", ")", "{", "pack", "(", "name", ")", ";", "pack", "(", "sub", ")", ";", "pack", "(", "BrokerUtil", ".", "toString", "(", "data", ")", ")", ";", "}" ]
Adds a subscripted parameter to the request. @param name Parameter name. @param sub Subscript(s). @param data Parameter value.
[ "Adds", "a", "subscripted", "parameter", "to", "the", "request", "." ]
train
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/Request.java#L154-L158
dlemmermann/CalendarFX
CalendarFXView/src/main/java/com/calendarfx/view/DateControl.java
DateControl.setDateDetailsCallback
public final void setDateDetailsCallback(Callback<DateDetailsParameter, Boolean> callback) { requireNonNull(callback); dateDetailsCallbackProperty().set(callback); }
java
public final void setDateDetailsCallback(Callback<DateDetailsParameter, Boolean> callback) { requireNonNull(callback); dateDetailsCallbackProperty().set(callback); }
[ "public", "final", "void", "setDateDetailsCallback", "(", "Callback", "<", "DateDetailsParameter", ",", "Boolean", ">", "callback", ")", "{", "requireNonNull", "(", "callback", ")", ";", "dateDetailsCallbackProperty", "(", ")", ".", "set", "(", "callback", ")", ";", "}" ]
Sets the value of {@link #dateDetailsCallbackProperty()}. @param callback the date details callback
[ "Sets", "the", "value", "of", "{", "@link", "#dateDetailsCallbackProperty", "()", "}", "." ]
train
https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/DateControl.java#L1597-L1600
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/HTTPFaxClientSpi.java
HTTPFaxClientSpi.submitHTTPRequestImpl
protected HTTPResponse submitHTTPRequestImpl(HTTPRequest httpRequest,HTTPMethod httpMethod) { return this.httpClient.submitHTTPRequest(httpRequest,this.httpClientConfiguration,httpMethod); }
java
protected HTTPResponse submitHTTPRequestImpl(HTTPRequest httpRequest,HTTPMethod httpMethod) { return this.httpClient.submitHTTPRequest(httpRequest,this.httpClientConfiguration,httpMethod); }
[ "protected", "HTTPResponse", "submitHTTPRequestImpl", "(", "HTTPRequest", "httpRequest", ",", "HTTPMethod", "httpMethod", ")", "{", "return", "this", ".", "httpClient", ".", "submitHTTPRequest", "(", "httpRequest", ",", "this", ".", "httpClientConfiguration", ",", "httpMethod", ")", ";", "}" ]
Submits the HTTP request and returns the HTTP response. @param httpRequest The HTTP request to send @param httpMethod The HTTP method to use @return The HTTP response
[ "Submits", "the", "HTTP", "request", "and", "returns", "the", "HTTP", "response", "." ]
train
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/HTTPFaxClientSpi.java#L626-L629
PeterisP/LVTagger
src/main/java/edu/stanford/nlp/classify/LinearClassifier.java
LinearClassifier.probabilityOf
public Counter<L> probabilityOf(Datum<L, F> example) { if(example instanceof RVFDatum<?, ?>)return probabilityOfRVFDatum((RVFDatum<L,F>)example); Counter<L> scores = logProbabilityOf(example); for (L label : scores.keySet()) { scores.setCount(label, Math.exp(scores.getCount(label))); } return scores; }
java
public Counter<L> probabilityOf(Datum<L, F> example) { if(example instanceof RVFDatum<?, ?>)return probabilityOfRVFDatum((RVFDatum<L,F>)example); Counter<L> scores = logProbabilityOf(example); for (L label : scores.keySet()) { scores.setCount(label, Math.exp(scores.getCount(label))); } return scores; }
[ "public", "Counter", "<", "L", ">", "probabilityOf", "(", "Datum", "<", "L", ",", "F", ">", "example", ")", "{", "if", "(", "example", "instanceof", "RVFDatum", "<", "?", ",", "?", ">", ")", "return", "probabilityOfRVFDatum", "(", "(", "RVFDatum", "<", "L", ",", "F", ">", ")", "example", ")", ";", "Counter", "<", "L", ">", "scores", "=", "logProbabilityOf", "(", "example", ")", ";", "for", "(", "L", "label", ":", "scores", ".", "keySet", "(", ")", ")", "{", "scores", ".", "setCount", "(", "label", ",", "Math", ".", "exp", "(", "scores", ".", "getCount", "(", "label", ")", ")", ")", ";", "}", "return", "scores", ";", "}" ]
Returns a counter mapping from each class name to the probability of that class for a certain example. Looking at the the sum of each count v, should be 1.0.
[ "Returns", "a", "counter", "mapping", "from", "each", "class", "name", "to", "the", "probability", "of", "that", "class", "for", "a", "certain", "example", ".", "Looking", "at", "the", "the", "sum", "of", "each", "count", "v", "should", "be", "1", ".", "0", "." ]
train
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/classify/LinearClassifier.java#L249-L256
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceStatisticsWithClasses.java
DistanceStatisticsWithClasses.shrinkHeap
private static void shrinkHeap(TreeSet<DoubleDBIDPair> hotset, int k) { // drop duplicates ModifiableDBIDs seenids = DBIDUtil.newHashSet(2 * k); int cnt = 0; for(Iterator<DoubleDBIDPair> i = hotset.iterator(); i.hasNext();) { DoubleDBIDPair p = i.next(); if(cnt > k || seenids.contains(p)) { i.remove(); } else { seenids.add(p); cnt++; } } }
java
private static void shrinkHeap(TreeSet<DoubleDBIDPair> hotset, int k) { // drop duplicates ModifiableDBIDs seenids = DBIDUtil.newHashSet(2 * k); int cnt = 0; for(Iterator<DoubleDBIDPair> i = hotset.iterator(); i.hasNext();) { DoubleDBIDPair p = i.next(); if(cnt > k || seenids.contains(p)) { i.remove(); } else { seenids.add(p); cnt++; } } }
[ "private", "static", "void", "shrinkHeap", "(", "TreeSet", "<", "DoubleDBIDPair", ">", "hotset", ",", "int", "k", ")", "{", "// drop duplicates", "ModifiableDBIDs", "seenids", "=", "DBIDUtil", ".", "newHashSet", "(", "2", "*", "k", ")", ";", "int", "cnt", "=", "0", ";", "for", "(", "Iterator", "<", "DoubleDBIDPair", ">", "i", "=", "hotset", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "DoubleDBIDPair", "p", "=", "i", ".", "next", "(", ")", ";", "if", "(", "cnt", ">", "k", "||", "seenids", ".", "contains", "(", "p", ")", ")", "{", "i", ".", "remove", "(", ")", ";", "}", "else", "{", "seenids", ".", "add", "(", "p", ")", ";", "cnt", "++", ";", "}", "}", "}" ]
Shrink the heap of "hot" (extreme) items. @param hotset Set of hot items @param k target size
[ "Shrink", "the", "heap", "of", "hot", "(", "extreme", ")", "items", "." ]
train
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceStatisticsWithClasses.java#L382-L396
amlinv/registry-utils
src/main/java/com/amlinv/registry/util/ConcurrentRegistry.java
ConcurrentRegistry.putIfAbsent
public V putIfAbsent (K putKey, V putValue) { V existingValue = this.store.putIfAbsent(putKey, putValue); if ( existingValue == null ) { this.notificationExecutor.firePutNotification(this.listeners.iterator(), putKey, putValue); } return existingValue; }
java
public V putIfAbsent (K putKey, V putValue) { V existingValue = this.store.putIfAbsent(putKey, putValue); if ( existingValue == null ) { this.notificationExecutor.firePutNotification(this.listeners.iterator(), putKey, putValue); } return existingValue; }
[ "public", "V", "putIfAbsent", "(", "K", "putKey", ",", "V", "putValue", ")", "{", "V", "existingValue", "=", "this", ".", "store", ".", "putIfAbsent", "(", "putKey", ",", "putValue", ")", ";", "if", "(", "existingValue", "==", "null", ")", "{", "this", ".", "notificationExecutor", ".", "firePutNotification", "(", "this", ".", "listeners", ".", "iterator", "(", ")", ",", "putKey", ",", "putValue", ")", ";", "}", "return", "existingValue", ";", "}" ]
Add the given entry into the registry under the specified key, but only if the key is not already registered. @param putKey key identifying the entry in the registry to add, if it does not already exist. @param putValue value to add to the registry. @return existing value in the registry if already defined; null if the new value is added to the registry.
[ "Add", "the", "given", "entry", "into", "the", "registry", "under", "the", "specified", "key", "but", "only", "if", "the", "key", "is", "not", "already", "registered", "." ]
train
https://github.com/amlinv/registry-utils/blob/784c455be38acb0df3a35c38afe60a516b8e4f32/src/main/java/com/amlinv/registry/util/ConcurrentRegistry.java#L153-L161
ManfredTremmel/gwt-commons-lang3
src/main/java/org/apache/commons/lang3/time/DateUtils.java
DateUtils.getFragmentInMilliseconds
@GwtIncompatible("incompatible method") public static long getFragmentInMilliseconds(final Date date, final int fragment) { return getFragment(date, fragment, TimeUnit.MILLISECONDS); }
java
@GwtIncompatible("incompatible method") public static long getFragmentInMilliseconds(final Date date, final int fragment) { return getFragment(date, fragment, TimeUnit.MILLISECONDS); }
[ "@", "GwtIncompatible", "(", "\"incompatible method\"", ")", "public", "static", "long", "getFragmentInMilliseconds", "(", "final", "Date", "date", ",", "final", "int", "fragment", ")", "{", "return", "getFragment", "(", "date", ",", "fragment", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}" ]
<p>Returns the number of milliseconds within the fragment. All datefields greater than the fragment will be ignored.</p> <p>Asking the milliseconds of any date will only return the number of milliseconds of the current second (resulting in a number between 0 and 999). This method will retrieve the number of milliseconds for any fragment. For example, if you want to calculate the number of milliseconds past today, your fragment is Calendar.DATE or Calendar.DAY_OF_YEAR. The result will be all milliseconds of the past hour(s), minutes(s) and second(s).</p> <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND A fragment less than or equal to a SECOND field will return 0.</p> <ul> <li>January 1, 2008 7:15:10.538 with Calendar.SECOND as fragment will return 538</li> <li>January 6, 2008 7:15:10.538 with Calendar.SECOND as fragment will return 538</li> <li>January 6, 2008 7:15:10.538 with Calendar.MINUTE as fragment will return 10538 (10*1000 + 538)</li> <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 (a millisecond cannot be split in milliseconds)</li> </ul> @param date the date to work with, not null @param fragment the {@code Calendar} field part of date to calculate @return number of milliseconds within the fragment of date @throws IllegalArgumentException if the date is <code>null</code> or fragment is not supported @since 2.4
[ "<p", ">", "Returns", "the", "number", "of", "milliseconds", "within", "the", "fragment", ".", "All", "datefields", "greater", "than", "the", "fragment", "will", "be", "ignored", ".", "<", "/", "p", ">" ]
train
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L1296-L1299
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectCalendar.java
ProjectCalendar.getTime
private long getTime(Date start, Date end, long target, boolean after) { long total = 0; if (start != null && end != null) { Date startTime = DateHelper.getCanonicalTime(start); Date endTime = DateHelper.getCanonicalTime(end); Date startDay = DateHelper.getDayStartDate(start); Date finishDay = DateHelper.getDayStartDate(end); // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if (startDay.getTime() != finishDay.getTime()) { endTime = DateHelper.addDays(endTime, 1); } int diff = DateHelper.compare(startTime, endTime, target); if (diff == 0) { if (after == true) { total = (endTime.getTime() - target); } else { total = (target - startTime.getTime()); } } else { if ((after == true && diff < 0) || (after == false && diff > 0)) { total = (endTime.getTime() - startTime.getTime()); } } } return (total); }
java
private long getTime(Date start, Date end, long target, boolean after) { long total = 0; if (start != null && end != null) { Date startTime = DateHelper.getCanonicalTime(start); Date endTime = DateHelper.getCanonicalTime(end); Date startDay = DateHelper.getDayStartDate(start); Date finishDay = DateHelper.getDayStartDate(end); // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if (startDay.getTime() != finishDay.getTime()) { endTime = DateHelper.addDays(endTime, 1); } int diff = DateHelper.compare(startTime, endTime, target); if (diff == 0) { if (after == true) { total = (endTime.getTime() - target); } else { total = (target - startTime.getTime()); } } else { if ((after == true && diff < 0) || (after == false && diff > 0)) { total = (endTime.getTime() - startTime.getTime()); } } } return (total); }
[ "private", "long", "getTime", "(", "Date", "start", ",", "Date", "end", ",", "long", "target", ",", "boolean", "after", ")", "{", "long", "total", "=", "0", ";", "if", "(", "start", "!=", "null", "&&", "end", "!=", "null", ")", "{", "Date", "startTime", "=", "DateHelper", ".", "getCanonicalTime", "(", "start", ")", ";", "Date", "endTime", "=", "DateHelper", ".", "getCanonicalTime", "(", "end", ")", ";", "Date", "startDay", "=", "DateHelper", ".", "getDayStartDate", "(", "start", ")", ";", "Date", "finishDay", "=", "DateHelper", ".", "getDayStartDate", "(", "end", ")", ";", "//", "// Handle the case where the end of the range is at midnight -", "// this will show up as the start and end days not matching", "//", "if", "(", "startDay", ".", "getTime", "(", ")", "!=", "finishDay", ".", "getTime", "(", ")", ")", "{", "endTime", "=", "DateHelper", ".", "addDays", "(", "endTime", ",", "1", ")", ";", "}", "int", "diff", "=", "DateHelper", ".", "compare", "(", "startTime", ",", "endTime", ",", "target", ")", ";", "if", "(", "diff", "==", "0", ")", "{", "if", "(", "after", "==", "true", ")", "{", "total", "=", "(", "endTime", ".", "getTime", "(", ")", "-", "target", ")", ";", "}", "else", "{", "total", "=", "(", "target", "-", "startTime", ".", "getTime", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "(", "after", "==", "true", "&&", "diff", "<", "0", ")", "||", "(", "after", "==", "false", "&&", "diff", ">", "0", ")", ")", "{", "total", "=", "(", "endTime", ".", "getTime", "(", ")", "-", "startTime", ".", "getTime", "(", ")", ")", ";", "}", "}", "}", "return", "(", "total", ")", ";", "}" ]
Calculates how much of a time range is before or after a target intersection point. @param start time range start @param end time range end @param target target intersection point @param after true if time after target required, false for time before @return length of time in milliseconds
[ "Calculates", "how", "much", "of", "a", "time", "range", "is", "before", "or", "after", "a", "target", "intersection", "point", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1514-L1555
mockito/mockito
src/main/java/org/mockito/Mockito.java
Mockito.doReturn
@SuppressWarnings({"unchecked", "varargs"}) @CheckReturnValue public static Stubber doReturn(Object toBeReturned, Object... toBeReturnedNext) { return MOCKITO_CORE.stubber().doReturn(toBeReturned, toBeReturnedNext); }
java
@SuppressWarnings({"unchecked", "varargs"}) @CheckReturnValue public static Stubber doReturn(Object toBeReturned, Object... toBeReturnedNext) { return MOCKITO_CORE.stubber().doReturn(toBeReturned, toBeReturnedNext); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"varargs\"", "}", ")", "@", "CheckReturnValue", "public", "static", "Stubber", "doReturn", "(", "Object", "toBeReturned", ",", "Object", "...", "toBeReturnedNext", ")", "{", "return", "MOCKITO_CORE", ".", "stubber", "(", ")", ".", "doReturn", "(", "toBeReturned", ",", "toBeReturnedNext", ")", ";", "}" ]
Same as {@link #doReturn(Object)} but sets consecutive values to be returned. Remember to use <code>doReturn()</code> in those rare occasions when you cannot use {@link Mockito#when(Object)}. <p> <b>Beware that {@link Mockito#when(Object)} is always recommended for stubbing because it is argument type-safe and more readable</b> (especially when stubbing consecutive calls). <p> Here are those rare occasions when doReturn() comes handy: <p> <ol> <li>When spying real objects and calling real methods on a spy brings side effects <pre class="code"><code class="java"> List list = new LinkedList(); List spy = spy(list); //Impossible: real method is called so spy.get(0) throws IndexOutOfBoundsException (the list is yet empty) when(spy.get(0)).thenReturn("foo", "bar", "qix"); //You have to use doReturn() for stubbing: doReturn("foo", "bar", "qix").when(spy).get(0); </code></pre> </li> <li>Overriding a previous exception-stubbing: <pre class="code"><code class="java"> when(mock.foo()).thenThrow(new RuntimeException()); //Impossible: the exception-stubbed foo() method is called so RuntimeException is thrown. when(mock.foo()).thenReturn("bar", "foo", "qix"); //You have to use doReturn() for stubbing: doReturn("bar", "foo", "qix").when(mock).foo(); </code></pre> </li> </ol> Above scenarios shows a trade-off of Mockito's elegant syntax. Note that the scenarios are very rare, though. Spying should be sporadic and overriding exception-stubbing is very rare. Not to mention that in general overridding stubbing is a potential code smell that points out too much stubbing. <p> See examples in javadoc for {@link Mockito} class @param toBeReturned to be returned when the stubbed method is called @param toBeReturnedNext to be returned in consecutive calls when the stubbed method is called @return stubber - to select a method for stubbing @since 2.1.0
[ "Same", "as", "{", "@link", "#doReturn", "(", "Object", ")", "}", "but", "sets", "consecutive", "values", "to", "be", "returned", ".", "Remember", "to", "use", "<code", ">", "doReturn", "()", "<", "/", "code", ">", "in", "those", "rare", "occasions", "when", "you", "cannot", "use", "{", "@link", "Mockito#when", "(", "Object", ")", "}", ".", "<p", ">", "<b", ">", "Beware", "that", "{", "@link", "Mockito#when", "(", "Object", ")", "}", "is", "always", "recommended", "for", "stubbing", "because", "it", "is", "argument", "type", "-", "safe", "and", "more", "readable<", "/", "b", ">", "(", "especially", "when", "stubbing", "consecutive", "calls", ")", ".", "<p", ">", "Here", "are", "those", "rare", "occasions", "when", "doReturn", "()", "comes", "handy", ":", "<p", ">" ]
train
https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/Mockito.java#L2533-L2537
Mozu/mozu-java
mozu-java-core/src/main/java/com/mozu/api/urls/commerce/shipping/admin/profiles/ShippingInclusionRuleUrl.java
ShippingInclusionRuleUrl.getShippingInclusionRulesUrl
public static MozuUrl getShippingInclusionRulesUrl(String profilecode, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/shipping/admin/profiles/{profilecode}/rules/shippinginclusions?responseFields={responseFields}"); formatter.formatUrl("profilecode", profilecode); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
java
public static MozuUrl getShippingInclusionRulesUrl(String profilecode, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/shipping/admin/profiles/{profilecode}/rules/shippinginclusions?responseFields={responseFields}"); formatter.formatUrl("profilecode", profilecode); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
[ "public", "static", "MozuUrl", "getShippingInclusionRulesUrl", "(", "String", "profilecode", ",", "String", "responseFields", ")", "{", "UrlFormatter", "formatter", "=", "new", "UrlFormatter", "(", "\"/api/commerce/shipping/admin/profiles/{profilecode}/rules/shippinginclusions?responseFields={responseFields}\"", ")", ";", "formatter", ".", "formatUrl", "(", "\"profilecode\"", ",", "profilecode", ")", ";", "formatter", ".", "formatUrl", "(", "\"responseFields\"", ",", "responseFields", ")", ";", "return", "new", "MozuUrl", "(", "formatter", ".", "getResourceUrl", "(", ")", ",", "MozuUrl", ".", "UrlLocation", ".", "TENANT_POD", ")", ";", "}" ]
Get Resource Url for GetShippingInclusionRules @param profilecode The unique, user-defined code of the profile with which the shipping inclusion rule is associated. @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", "GetShippingInclusionRules" ]
train
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/shipping/admin/profiles/ShippingInclusionRuleUrl.java#L38-L44
bazaarvoice/emodb
sor/src/main/java/com/bazaarvoice/emodb/sor/db/astyanax/DeltaPlacement.java
DeltaPlacement.createTableDDL
private TableDDL createTableDDL(String tableName) { TableMetadata tableMetadata = _keyspace.getKeyspaceMetadata().getTable(tableName); String rowKeyColumnName = tableMetadata.getPrimaryKey().get(0).getName(); String timeSeriesColumnName = tableMetadata.getPrimaryKey().get(1).getName(); String valueColumnName = tableMetadata.getColumns().get(2).getName(); return new TableDDL(tableMetadata, rowKeyColumnName, timeSeriesColumnName, valueColumnName); }
java
private TableDDL createTableDDL(String tableName) { TableMetadata tableMetadata = _keyspace.getKeyspaceMetadata().getTable(tableName); String rowKeyColumnName = tableMetadata.getPrimaryKey().get(0).getName(); String timeSeriesColumnName = tableMetadata.getPrimaryKey().get(1).getName(); String valueColumnName = tableMetadata.getColumns().get(2).getName(); return new TableDDL(tableMetadata, rowKeyColumnName, timeSeriesColumnName, valueColumnName); }
[ "private", "TableDDL", "createTableDDL", "(", "String", "tableName", ")", "{", "TableMetadata", "tableMetadata", "=", "_keyspace", ".", "getKeyspaceMetadata", "(", ")", ".", "getTable", "(", "tableName", ")", ";", "String", "rowKeyColumnName", "=", "tableMetadata", ".", "getPrimaryKey", "(", ")", ".", "get", "(", "0", ")", ".", "getName", "(", ")", ";", "String", "timeSeriesColumnName", "=", "tableMetadata", ".", "getPrimaryKey", "(", ")", ".", "get", "(", "1", ")", ".", "getName", "(", ")", ";", "String", "valueColumnName", "=", "tableMetadata", ".", "getColumns", "(", ")", ".", "get", "(", "2", ")", ".", "getName", "(", ")", ";", "return", "new", "TableDDL", "(", "tableMetadata", ",", "rowKeyColumnName", ",", "timeSeriesColumnName", ",", "valueColumnName", ")", ";", "}" ]
Both placement tables -- delta, and delta history -- follow the same DDL.
[ "Both", "placement", "tables", "--", "delta", "and", "delta", "history", "--", "follow", "the", "same", "DDL", "." ]
train
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/sor/src/main/java/com/bazaarvoice/emodb/sor/db/astyanax/DeltaPlacement.java#L45-L52
weld/core
impl/src/main/java/org/jboss/weld/util/AnnotatedTypes.java
AnnotatedTypes.compareAnnotated
private static boolean compareAnnotated(Annotated a1, Annotated a2) { return a1.getAnnotations().equals(a2.getAnnotations()); }
java
private static boolean compareAnnotated(Annotated a1, Annotated a2) { return a1.getAnnotations().equals(a2.getAnnotations()); }
[ "private", "static", "boolean", "compareAnnotated", "(", "Annotated", "a1", ",", "Annotated", "a2", ")", "{", "return", "a1", ".", "getAnnotations", "(", ")", ".", "equals", "(", "a2", ".", "getAnnotations", "(", ")", ")", ";", "}" ]
compares two annotated elements to see if they have the same annotations @param a1 @param a2 @return
[ "compares", "two", "annotated", "elements", "to", "see", "if", "they", "have", "the", "same", "annotations" ]
train
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/AnnotatedTypes.java#L428-L430
boncey/Flickr4Java
src/main/java/com/flickr4java/flickr/photosets/PhotosetsInterface.java
PhotosetsInterface.editPhotos
public void editPhotos(String photosetId, String primaryPhotoId, String[] photoIds) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_PHOTOS); parameters.put("photoset_id", photosetId); parameters.put("primary_photo_id", primaryPhotoId); parameters.put("photo_ids", StringUtilities.join(photoIds, ",")); Response response = transportAPI.post(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
java
public void editPhotos(String photosetId, String primaryPhotoId, String[] photoIds) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_PHOTOS); parameters.put("photoset_id", photosetId); parameters.put("primary_photo_id", primaryPhotoId); parameters.put("photo_ids", StringUtilities.join(photoIds, ",")); Response response = transportAPI.post(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
[ "public", "void", "editPhotos", "(", "String", "photosetId", ",", "String", "primaryPhotoId", ",", "String", "[", "]", "photoIds", ")", "throws", "FlickrException", "{", "Map", "<", "String", ",", "Object", ">", "parameters", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "parameters", ".", "put", "(", "\"method\"", ",", "METHOD_EDIT_PHOTOS", ")", ";", "parameters", ".", "put", "(", "\"photoset_id\"", ",", "photosetId", ")", ";", "parameters", ".", "put", "(", "\"primary_photo_id\"", ",", "primaryPhotoId", ")", ";", "parameters", ".", "put", "(", "\"photo_ids\"", ",", "StringUtilities", ".", "join", "(", "photoIds", ",", "\",\"", ")", ")", ";", "Response", "response", "=", "transportAPI", ".", "post", "(", "transportAPI", ".", "getPath", "(", ")", ",", "parameters", ",", "apiKey", ",", "sharedSecret", ")", ";", "if", "(", "response", ".", "isError", "(", ")", ")", "{", "throw", "new", "FlickrException", "(", "response", ".", "getErrorCode", "(", ")", ",", "response", ".", "getErrorMessage", "(", ")", ")", ";", "}", "}" ]
Edit which photos are in the photoset. @param photosetId The photoset ID @param primaryPhotoId The primary photo Id @param photoIds The photo IDs for the photos in the set @throws FlickrException
[ "Edit", "which", "photos", "are", "in", "the", "photoset", "." ]
train
https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/photosets/PhotosetsInterface.java#L189-L201
facebookarchive/hadoop-20
src/core/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java
MetricsRecordImpl.setTag
public void setTag(String tagName, byte tagValue) { tagTable.put(tagName, Byte.valueOf(tagValue)); }
java
public void setTag(String tagName, byte tagValue) { tagTable.put(tagName, Byte.valueOf(tagValue)); }
[ "public", "void", "setTag", "(", "String", "tagName", ",", "byte", "tagValue", ")", "{", "tagTable", ".", "put", "(", "tagName", ",", "Byte", ".", "valueOf", "(", "tagValue", ")", ")", ";", "}" ]
Sets the named tag to the specified value. @param tagName name of the tag @param tagValue new value of the tag @throws MetricsException if the tagName conflicts with the configuration
[ "Sets", "the", "named", "tag", "to", "the", "specified", "value", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java#L112-L114
wildfly/wildfly-core
patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java
IdentityPatchContext.backupDirectory
static void backupDirectory(final File source, final File target) throws IOException { if (!target.exists()) { if (!target.mkdirs()) { throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(target.getAbsolutePath()); } } final File[] files = source.listFiles(CONFIG_FILTER); for (final File file : files) { final File t = new File(target, file.getName()); IoUtils.copyFile(file, t); } }
java
static void backupDirectory(final File source, final File target) throws IOException { if (!target.exists()) { if (!target.mkdirs()) { throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(target.getAbsolutePath()); } } final File[] files = source.listFiles(CONFIG_FILTER); for (final File file : files) { final File t = new File(target, file.getName()); IoUtils.copyFile(file, t); } }
[ "static", "void", "backupDirectory", "(", "final", "File", "source", ",", "final", "File", "target", ")", "throws", "IOException", "{", "if", "(", "!", "target", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "target", ".", "mkdirs", "(", ")", ")", "{", "throw", "PatchLogger", ".", "ROOT_LOGGER", ".", "cannotCreateDirectory", "(", "target", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}", "final", "File", "[", "]", "files", "=", "source", ".", "listFiles", "(", "CONFIG_FILTER", ")", ";", "for", "(", "final", "File", "file", ":", "files", ")", "{", "final", "File", "t", "=", "new", "File", "(", "target", ",", "file", ".", "getName", "(", ")", ")", ";", "IoUtils", ".", "copyFile", "(", "file", ",", "t", ")", ";", "}", "}" ]
Backup all xml files in a given directory. @param source the source directory @param target the target directory @throws IOException for any error
[ "Backup", "all", "xml", "files", "in", "a", "given", "directory", "." ]
train
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java#L1013-L1024
OpenLiberty/open-liberty
dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java
FileUtils.copyDir
public static void copyDir(File from, File to) throws FileNotFoundException, IOException { File[] files = from.listFiles(); if (files != null) { for (File ff : files) { File tf = new File(to, ff.getName()); if (ff.isDirectory()) { if (tf.mkdir()) { copyDir(ff, tf); } } else if (ff.isFile()) { copyFile(tf, ff); } } } }
java
public static void copyDir(File from, File to) throws FileNotFoundException, IOException { File[] files = from.listFiles(); if (files != null) { for (File ff : files) { File tf = new File(to, ff.getName()); if (ff.isDirectory()) { if (tf.mkdir()) { copyDir(ff, tf); } } else if (ff.isFile()) { copyFile(tf, ff); } } } }
[ "public", "static", "void", "copyDir", "(", "File", "from", ",", "File", "to", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "File", "[", "]", "files", "=", "from", ".", "listFiles", "(", ")", ";", "if", "(", "files", "!=", "null", ")", "{", "for", "(", "File", "ff", ":", "files", ")", "{", "File", "tf", "=", "new", "File", "(", "to", ",", "ff", ".", "getName", "(", ")", ")", ";", "if", "(", "ff", ".", "isDirectory", "(", ")", ")", "{", "if", "(", "tf", ".", "mkdir", "(", ")", ")", "{", "copyDir", "(", "ff", ",", "tf", ")", ";", "}", "}", "else", "if", "(", "ff", ".", "isFile", "(", ")", ")", "{", "copyFile", "(", "tf", ",", "ff", ")", ";", "}", "}", "}", "}" ]
Recursively copy the files from one dir to the other. @param from The directory to copy from, must exist. @param to The directory to copy to, must exist, must be empty. @throws IOException @throws FileNotFoundException
[ "Recursively", "copy", "the", "files", "from", "one", "dir", "to", "the", "other", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L162-L177
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java
FindbugsPlugin.resetStore
private static void resetStore(IPreferenceStore store, String prefix) { int start = 0; // 99 is paranoia. while(start < 99){ String name = prefix + start; if(store.contains(name)){ store.setToDefault(name); } else { break; } start ++; } }
java
private static void resetStore(IPreferenceStore store, String prefix) { int start = 0; // 99 is paranoia. while(start < 99){ String name = prefix + start; if(store.contains(name)){ store.setToDefault(name); } else { break; } start ++; } }
[ "private", "static", "void", "resetStore", "(", "IPreferenceStore", "store", ",", "String", "prefix", ")", "{", "int", "start", "=", "0", ";", "// 99 is paranoia.", "while", "(", "start", "<", "99", ")", "{", "String", "name", "=", "prefix", "+", "start", ";", "if", "(", "store", ".", "contains", "(", "name", ")", ")", "{", "store", ".", "setToDefault", "(", "name", ")", ";", "}", "else", "{", "break", ";", "}", "start", "++", ";", "}", "}" ]
Removes all consequent enumerated keys from given store staring with given prefix
[ "Removes", "all", "consequent", "enumerated", "keys", "from", "given", "store", "staring", "with", "given", "prefix" ]
train
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java#L1025-L1037
UrielCh/ovh-java-sdk
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
ApiOvhTelephony.billingAccount_ddi_serviceName_PUT
public void billingAccount_ddi_serviceName_PUT(String billingAccount, String serviceName, OvhDdi body) throws IOException { String qPath = "/telephony/{billingAccount}/ddi/{serviceName}"; StringBuilder sb = path(qPath, billingAccount, serviceName); exec(qPath, "PUT", sb.toString(), body); }
java
public void billingAccount_ddi_serviceName_PUT(String billingAccount, String serviceName, OvhDdi body) throws IOException { String qPath = "/telephony/{billingAccount}/ddi/{serviceName}"; StringBuilder sb = path(qPath, billingAccount, serviceName); exec(qPath, "PUT", sb.toString(), body); }
[ "public", "void", "billingAccount_ddi_serviceName_PUT", "(", "String", "billingAccount", ",", "String", "serviceName", ",", "OvhDdi", "body", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/telephony/{billingAccount}/ddi/{serviceName}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "billingAccount", ",", "serviceName", ")", ";", "exec", "(", "qPath", ",", "\"PUT\"", ",", "sb", ".", "toString", "(", ")", ",", "body", ")", ";", "}" ]
Alter this object properties REST: PUT /telephony/{billingAccount}/ddi/{serviceName} @param body [required] New object properties @param billingAccount [required] The name of your billingAccount @param serviceName [required]
[ "Alter", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L8501-L8505
moparisthebest/beehive
beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/AnchorBase.java
AnchorBase.createPageAnchor
private boolean createPageAnchor(ServletRequest req, TagRenderingBase trb) { // create the fragment identifier. If the _linkName starts with // '#' then we treat it as if it was fully qualified. Otherwise we // need to qualify it before we add the '#'. _linkName = _linkName.trim(); if (_linkName.charAt(0) != '#') { _state.href = "#" + getIdForTagId(_linkName); } else { _state.href = _linkName; } // if the tagId was set then rewrite it and output it. if (_state.id != null) { //_state.id = getIdForTagId(_state.id); _state.name = _state.id; renderNameAndId((HttpServletRequest) req, _state,null); //renderDefaultNameAndId((HttpServletRequest) req, _state, _state.id, _state.id); } // write out the tag. WriteRenderAppender writer = new WriteRenderAppender(pageContext); trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req); trb.doStartTag(writer, _state); return !hasErrors(); }
java
private boolean createPageAnchor(ServletRequest req, TagRenderingBase trb) { // create the fragment identifier. If the _linkName starts with // '#' then we treat it as if it was fully qualified. Otherwise we // need to qualify it before we add the '#'. _linkName = _linkName.trim(); if (_linkName.charAt(0) != '#') { _state.href = "#" + getIdForTagId(_linkName); } else { _state.href = _linkName; } // if the tagId was set then rewrite it and output it. if (_state.id != null) { //_state.id = getIdForTagId(_state.id); _state.name = _state.id; renderNameAndId((HttpServletRequest) req, _state,null); //renderDefaultNameAndId((HttpServletRequest) req, _state, _state.id, _state.id); } // write out the tag. WriteRenderAppender writer = new WriteRenderAppender(pageContext); trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req); trb.doStartTag(writer, _state); return !hasErrors(); }
[ "private", "boolean", "createPageAnchor", "(", "ServletRequest", "req", ",", "TagRenderingBase", "trb", ")", "{", "// create the fragment identifier. If the _linkName starts with", "// '#' then we treat it as if it was fully qualified. Otherwise we", "// need to qualify it before we add the '#'.", "_linkName", "=", "_linkName", ".", "trim", "(", ")", ";", "if", "(", "_linkName", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "{", "_state", ".", "href", "=", "\"#\"", "+", "getIdForTagId", "(", "_linkName", ")", ";", "}", "else", "{", "_state", ".", "href", "=", "_linkName", ";", "}", "// if the tagId was set then rewrite it and output it.", "if", "(", "_state", ".", "id", "!=", "null", ")", "{", "//_state.id = getIdForTagId(_state.id);", "_state", ".", "name", "=", "_state", ".", "id", ";", "renderNameAndId", "(", "(", "HttpServletRequest", ")", "req", ",", "_state", ",", "null", ")", ";", "//renderDefaultNameAndId((HttpServletRequest) req, _state, _state.id, _state.id);", "}", "// write out the tag.", "WriteRenderAppender", "writer", "=", "new", "WriteRenderAppender", "(", "pageContext", ")", ";", "trb", "=", "TagRenderingBase", ".", "Factory", ".", "getRendering", "(", "TagRenderingBase", ".", "ANCHOR_TAG", ",", "req", ")", ";", "trb", ".", "doStartTag", "(", "writer", ",", "_state", ")", ";", "return", "!", "hasErrors", "(", ")", ";", "}" ]
This method will output an anchor with a fragment identifier. This should be a valid ID within the document. If the name begins with the "#" we will not qualify the set link name. If the name doesn't begin with #, then we will qualify it into the current scope container. @param req The servlet request. @param trb The TagRenderer that will output the link @return return a boolean indicating if an error occurred or not
[ "This", "method", "will", "output", "an", "anchor", "with", "a", "fragment", "identifier", ".", "This", "should", "be", "a", "valid", "ID", "within", "the", "document", ".", "If", "the", "name", "begins", "with", "the", "#", "we", "will", "not", "qualify", "the", "set", "link", "name", ".", "If", "the", "name", "doesn", "t", "begin", "with", "#", "then", "we", "will", "qualify", "it", "into", "the", "current", "scope", "container", "." ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/AnchorBase.java#L555-L581
UrielCh/ovh-java-sdk
ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java
ApiOvhCloud.createProjectInfo_GET
public OvhNewProjectInfo createProjectInfo_GET(String voucher) throws IOException { String qPath = "/cloud/createProjectInfo"; StringBuilder sb = path(qPath); query(sb, "voucher", voucher); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhNewProjectInfo.class); }
java
public OvhNewProjectInfo createProjectInfo_GET(String voucher) throws IOException { String qPath = "/cloud/createProjectInfo"; StringBuilder sb = path(qPath); query(sb, "voucher", voucher); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhNewProjectInfo.class); }
[ "public", "OvhNewProjectInfo", "createProjectInfo_GET", "(", "String", "voucher", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/cloud/createProjectInfo\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ")", ";", "query", "(", "sb", ",", "\"voucher\"", ",", "voucher", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhNewProjectInfo", ".", "class", ")", ";", "}" ]
Get information about a cloud project creation REST: GET /cloud/createProjectInfo @param voucher [required] Voucher code
[ "Get", "information", "about", "a", "cloud", "project", "creation" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L2403-L2409
getsentry/sentry-java
sentry/src/main/java/io/sentry/buffer/DiskBuffer.java
DiskBuffer.discard
@Override public void discard(Event event) { File eventFile = new File(bufferDir, event.getId().toString() + FILE_SUFFIX); if (eventFile.exists()) { logger.debug("Discarding Event from offline storage: " + eventFile.getAbsolutePath()); if (!eventFile.delete()) { logger.warn("Failed to delete Event: " + eventFile.getAbsolutePath()); } } }
java
@Override public void discard(Event event) { File eventFile = new File(bufferDir, event.getId().toString() + FILE_SUFFIX); if (eventFile.exists()) { logger.debug("Discarding Event from offline storage: " + eventFile.getAbsolutePath()); if (!eventFile.delete()) { logger.warn("Failed to delete Event: " + eventFile.getAbsolutePath()); } } }
[ "@", "Override", "public", "void", "discard", "(", "Event", "event", ")", "{", "File", "eventFile", "=", "new", "File", "(", "bufferDir", ",", "event", ".", "getId", "(", ")", ".", "toString", "(", ")", "+", "FILE_SUFFIX", ")", ";", "if", "(", "eventFile", ".", "exists", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Discarding Event from offline storage: \"", "+", "eventFile", ".", "getAbsolutePath", "(", ")", ")", ";", "if", "(", "!", "eventFile", ".", "delete", "(", ")", ")", "{", "logger", ".", "warn", "(", "\"Failed to delete Event: \"", "+", "eventFile", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}", "}" ]
Deletes a buffered {@link Event} from disk. @param event Event to delete from the disk.
[ "Deletes", "a", "buffered", "{", "@link", "Event", "}", "from", "disk", "." ]
train
https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/buffer/DiskBuffer.java#L94-L103
SonarSource/sonarqube
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
RulesProfile.getActiveRule
@CheckForNull public ActiveRule getActiveRule(String repositoryKey, String ruleKey) { for (ActiveRule activeRule : activeRules) { if (StringUtils.equals(activeRule.getRepositoryKey(), repositoryKey) && StringUtils.equals(activeRule.getRuleKey(), ruleKey) && activeRule.isEnabled()) { return activeRule; } } return null; }
java
@CheckForNull public ActiveRule getActiveRule(String repositoryKey, String ruleKey) { for (ActiveRule activeRule : activeRules) { if (StringUtils.equals(activeRule.getRepositoryKey(), repositoryKey) && StringUtils.equals(activeRule.getRuleKey(), ruleKey) && activeRule.isEnabled()) { return activeRule; } } return null; }
[ "@", "CheckForNull", "public", "ActiveRule", "getActiveRule", "(", "String", "repositoryKey", ",", "String", "ruleKey", ")", "{", "for", "(", "ActiveRule", "activeRule", ":", "activeRules", ")", "{", "if", "(", "StringUtils", ".", "equals", "(", "activeRule", ".", "getRepositoryKey", "(", ")", ",", "repositoryKey", ")", "&&", "StringUtils", ".", "equals", "(", "activeRule", ".", "getRuleKey", "(", ")", ",", "ruleKey", ")", "&&", "activeRule", ".", "isEnabled", "(", ")", ")", "{", "return", "activeRule", ";", "}", "}", "return", "null", ";", "}" ]
Note: disabled rules are excluded. @return an active rule from a plugin key and a rule key if the rule is activated, null otherwise
[ "Note", ":", "disabled", "rules", "are", "excluded", "." ]
train
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java#L271-L279
OpenLiberty/open-liberty
dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/wsspi/kernel/embeddable/EmbeddedServerDriver.java
EmbeddedServerDriver.isProductExtensionInstalled
private boolean isProductExtensionInstalled(String inputString, String productExtension) { if ((productExtension == null) || (inputString == null)) { return false; } int msgIndex = inputString.indexOf("CWWKF0012I: The server installed the following features:"); if (msgIndex == -1) { return false; } String msgString = inputString.substring(msgIndex); int leftBracketIndex = msgString.indexOf("["); int rightBracketIndex = msgString.indexOf("]"); if ((leftBracketIndex == -1) || (rightBracketIndex == -1) || (rightBracketIndex < leftBracketIndex)) { return false; } String features = msgString.substring(leftBracketIndex, rightBracketIndex); Log.info(c, "isProductExtensionInstalled", features); if (features.indexOf(productExtension) == -1) { return false; } return true; }
java
private boolean isProductExtensionInstalled(String inputString, String productExtension) { if ((productExtension == null) || (inputString == null)) { return false; } int msgIndex = inputString.indexOf("CWWKF0012I: The server installed the following features:"); if (msgIndex == -1) { return false; } String msgString = inputString.substring(msgIndex); int leftBracketIndex = msgString.indexOf("["); int rightBracketIndex = msgString.indexOf("]"); if ((leftBracketIndex == -1) || (rightBracketIndex == -1) || (rightBracketIndex < leftBracketIndex)) { return false; } String features = msgString.substring(leftBracketIndex, rightBracketIndex); Log.info(c, "isProductExtensionInstalled", features); if (features.indexOf(productExtension) == -1) { return false; } return true; }
[ "private", "boolean", "isProductExtensionInstalled", "(", "String", "inputString", ",", "String", "productExtension", ")", "{", "if", "(", "(", "productExtension", "==", "null", ")", "||", "(", "inputString", "==", "null", ")", ")", "{", "return", "false", ";", "}", "int", "msgIndex", "=", "inputString", ".", "indexOf", "(", "\"CWWKF0012I: The server installed the following features:\"", ")", ";", "if", "(", "msgIndex", "==", "-", "1", ")", "{", "return", "false", ";", "}", "String", "msgString", "=", "inputString", ".", "substring", "(", "msgIndex", ")", ";", "int", "leftBracketIndex", "=", "msgString", ".", "indexOf", "(", "\"[\"", ")", ";", "int", "rightBracketIndex", "=", "msgString", ".", "indexOf", "(", "\"]\"", ")", ";", "if", "(", "(", "leftBracketIndex", "==", "-", "1", ")", "||", "(", "rightBracketIndex", "==", "-", "1", ")", "||", "(", "rightBracketIndex", "<", "leftBracketIndex", ")", ")", "{", "return", "false", ";", "}", "String", "features", "=", "msgString", ".", "substring", "(", "leftBracketIndex", ",", "rightBracketIndex", ")", ";", "Log", ".", "info", "(", "c", ",", "\"isProductExtensionInstalled\"", ",", "features", ")", ";", "if", "(", "features", ".", "indexOf", "(", "productExtension", ")", "==", "-", "1", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determine if the input product extension exists in the input string. @param inputString string to search. @param productExtension product extension to search for. @return true if input product extension is found in the input string.
[ "Determine", "if", "the", "input", "product", "extension", "exists", "in", "the", "input", "string", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/wsspi/kernel/embeddable/EmbeddedServerDriver.java#L239-L263
offbynull/coroutines
instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/DebugGenerators.java
DebugGenerators.debugMarker
public static InsnList debugMarker(MarkerType markerType, String text) { Validate.notNull(markerType); Validate.notNull(text); InsnList ret = new InsnList(); switch (markerType) { case NONE: break; case CONSTANT: ret.add(new LdcInsnNode(text)); ret.add(new InsnNode(Opcodes.POP)); break; case STDOUT: ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); ret.add(new LdcInsnNode(text)); ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); break; default: throw new IllegalStateException(); } return ret; }
java
public static InsnList debugMarker(MarkerType markerType, String text) { Validate.notNull(markerType); Validate.notNull(text); InsnList ret = new InsnList(); switch (markerType) { case NONE: break; case CONSTANT: ret.add(new LdcInsnNode(text)); ret.add(new InsnNode(Opcodes.POP)); break; case STDOUT: ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); ret.add(new LdcInsnNode(text)); ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); break; default: throw new IllegalStateException(); } return ret; }
[ "public", "static", "InsnList", "debugMarker", "(", "MarkerType", "markerType", ",", "String", "text", ")", "{", "Validate", ".", "notNull", "(", "markerType", ")", ";", "Validate", ".", "notNull", "(", "text", ")", ";", "InsnList", "ret", "=", "new", "InsnList", "(", ")", ";", "switch", "(", "markerType", ")", "{", "case", "NONE", ":", "break", ";", "case", "CONSTANT", ":", "ret", ".", "add", "(", "new", "LdcInsnNode", "(", "text", ")", ")", ";", "ret", ".", "add", "(", "new", "InsnNode", "(", "Opcodes", ".", "POP", ")", ")", ";", "break", ";", "case", "STDOUT", ":", "ret", ".", "add", "(", "new", "FieldInsnNode", "(", "Opcodes", ".", "GETSTATIC", ",", "\"java/lang/System\"", ",", "\"out\"", ",", "\"Ljava/io/PrintStream;\"", ")", ")", ";", "ret", ".", "add", "(", "new", "LdcInsnNode", "(", "text", ")", ")", ";", "ret", ".", "add", "(", "new", "MethodInsnNode", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "\"java/io/PrintStream\"", ",", "\"println\"", ",", "\"(Ljava/lang/String;)V\"", ",", "false", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "return", "ret", ";", "}" ]
Generates instructions for generating marker instructions. These marker instructions are meant to be is useful for debugging instrumented code. For example, you can spot a specific portion of instrumented code by looking for specific markers in the assembly output. @param markerType marker type (determines what kind of instructions are generated) @param text text to print out @return instructions to call System.out.println with a string constant @throws NullPointerException if any argument is {@code null}
[ "Generates", "instructions", "for", "generating", "marker", "instructions", ".", "These", "marker", "instructions", "are", "meant", "to", "be", "is", "useful", "for", "debugging", "instrumented", "code", ".", "For", "example", "you", "can", "spot", "a", "specific", "portion", "of", "instrumented", "code", "by", "looking", "for", "specific", "markers", "in", "the", "assembly", "output", "." ]
train
https://github.com/offbynull/coroutines/blob/b1b83c293945f53a2f63fca8f15a53e88b796bf5/instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/DebugGenerators.java#L46-L69
webjars/webjars-locator
src/main/java/org/webjars/RequireJS.java
RequireJS.getBowerWebJarRequireJsConfig
public static ObjectNode getBowerWebJarRequireJsConfig(Map.Entry<String, String> webJar, List<Map.Entry<String, Boolean>> prefixes) { String bowerJsonPath = WebJarAssetLocator.WEBJARS_PATH_PREFIX + "/" + webJar.getKey() + "/" + webJar.getValue() + "/" + "bower.json"; return getWebJarRequireJsConfigFromMainConfig(webJar, prefixes, bowerJsonPath); }
java
public static ObjectNode getBowerWebJarRequireJsConfig(Map.Entry<String, String> webJar, List<Map.Entry<String, Boolean>> prefixes) { String bowerJsonPath = WebJarAssetLocator.WEBJARS_PATH_PREFIX + "/" + webJar.getKey() + "/" + webJar.getValue() + "/" + "bower.json"; return getWebJarRequireJsConfigFromMainConfig(webJar, prefixes, bowerJsonPath); }
[ "public", "static", "ObjectNode", "getBowerWebJarRequireJsConfig", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "webJar", ",", "List", "<", "Map", ".", "Entry", "<", "String", ",", "Boolean", ">", ">", "prefixes", ")", "{", "String", "bowerJsonPath", "=", "WebJarAssetLocator", ".", "WEBJARS_PATH_PREFIX", "+", "\"/\"", "+", "webJar", ".", "getKey", "(", ")", "+", "\"/\"", "+", "webJar", ".", "getValue", "(", ")", "+", "\"/\"", "+", "\"bower.json\"", ";", "return", "getWebJarRequireJsConfigFromMainConfig", "(", "webJar", ",", "prefixes", ",", "bowerJsonPath", ")", ";", "}" ]
Returns the JSON RequireJS config for a given Bower WebJar @param webJar A tuple (artifactId -&gt; version) representing the WebJar. @param prefixes A list of the prefixes to use in the `paths` part of the RequireJS config. @return The JSON RequireJS config for the WebJar based on the meta-data in the WebJar's pom.xml file.
[ "Returns", "the", "JSON", "RequireJS", "config", "for", "a", "given", "Bower", "WebJar" ]
train
https://github.com/webjars/webjars-locator/blob/8796fb3ff1b9ad5c0d433ecf63a60520c715e3a0/src/main/java/org/webjars/RequireJS.java#L375-L380
OpenLiberty/open-liberty
dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java
TwitterEndpointServices.createParameterStringForSignature
public String createParameterStringForSignature(Map<String, String> parameters) { if (parameters == null) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Null parameters object provided; returning empty string"); } return ""; } Map<String, String> encodedParams = new HashMap<String, String>(); // Step 1: Percent encode every key and value that will be signed for (Entry<String, String> entry : parameters.entrySet()) { String encodedKey = Utils.percentEncode(entry.getKey()); String encodedValue = Utils.percentEncode(entry.getValue()); encodedParams.put(encodedKey, encodedValue); } // Step 2: Sort the list of parameters alphabetically by encoded key List<String> encodedKeysList = new ArrayList<String>(); encodedKeysList.addAll(encodedParams.keySet()); Collections.sort(encodedKeysList); StringBuilder paramString = new StringBuilder(); // Step 3: Go through each key/value pair for (int i = 0; i < encodedKeysList.size(); i++) { String key = encodedKeysList.get(i); String value = encodedParams.get(key); // Steps 4-6: Append encoded key, "=" character, and encoded value to the output string paramString.append(key).append("=").append(value); if (i < (encodedKeysList.size() - 1)) { // Step 7: If more key/value pairs remain, append "&" character to the output string paramString.append("&"); } } return paramString.toString(); }
java
public String createParameterStringForSignature(Map<String, String> parameters) { if (parameters == null) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Null parameters object provided; returning empty string"); } return ""; } Map<String, String> encodedParams = new HashMap<String, String>(); // Step 1: Percent encode every key and value that will be signed for (Entry<String, String> entry : parameters.entrySet()) { String encodedKey = Utils.percentEncode(entry.getKey()); String encodedValue = Utils.percentEncode(entry.getValue()); encodedParams.put(encodedKey, encodedValue); } // Step 2: Sort the list of parameters alphabetically by encoded key List<String> encodedKeysList = new ArrayList<String>(); encodedKeysList.addAll(encodedParams.keySet()); Collections.sort(encodedKeysList); StringBuilder paramString = new StringBuilder(); // Step 3: Go through each key/value pair for (int i = 0; i < encodedKeysList.size(); i++) { String key = encodedKeysList.get(i); String value = encodedParams.get(key); // Steps 4-6: Append encoded key, "=" character, and encoded value to the output string paramString.append(key).append("=").append(value); if (i < (encodedKeysList.size() - 1)) { // Step 7: If more key/value pairs remain, append "&" character to the output string paramString.append("&"); } } return paramString.toString(); }
[ "public", "String", "createParameterStringForSignature", "(", "Map", "<", "String", ",", "String", ">", "parameters", ")", "{", "if", "(", "parameters", "==", "null", ")", "{", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"Null parameters object provided; returning empty string\"", ")", ";", "}", "return", "\"\"", ";", "}", "Map", "<", "String", ",", "String", ">", "encodedParams", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "// Step 1: Percent encode every key and value that will be signed", "for", "(", "Entry", "<", "String", ",", "String", ">", "entry", ":", "parameters", ".", "entrySet", "(", ")", ")", "{", "String", "encodedKey", "=", "Utils", ".", "percentEncode", "(", "entry", ".", "getKey", "(", ")", ")", ";", "String", "encodedValue", "=", "Utils", ".", "percentEncode", "(", "entry", ".", "getValue", "(", ")", ")", ";", "encodedParams", ".", "put", "(", "encodedKey", ",", "encodedValue", ")", ";", "}", "// Step 2: Sort the list of parameters alphabetically by encoded key", "List", "<", "String", ">", "encodedKeysList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "encodedKeysList", ".", "addAll", "(", "encodedParams", ".", "keySet", "(", ")", ")", ";", "Collections", ".", "sort", "(", "encodedKeysList", ")", ";", "StringBuilder", "paramString", "=", "new", "StringBuilder", "(", ")", ";", "// Step 3: Go through each key/value pair", "for", "(", "int", "i", "=", "0", ";", "i", "<", "encodedKeysList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "key", "=", "encodedKeysList", ".", "get", "(", "i", ")", ";", "String", "value", "=", "encodedParams", ".", "get", "(", "key", ")", ";", "// Steps 4-6: Append encoded key, \"=\" character, and encoded value to the output string", "paramString", ".", "append", "(", "key", ")", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "value", ")", ";", "if", "(", "i", "<", "(", "encodedKeysList", ".", "size", "(", ")", "-", "1", ")", ")", "{", "// Step 7: If more key/value pairs remain, append \"&\" character to the output string", "paramString", ".", "append", "(", "\"&\"", ")", ";", "}", "}", "return", "paramString", ".", "toString", "(", ")", ";", "}" ]
Per {@link https://dev.twitter.com/oauth/overview/creating-signatures}, the parameter string for signatures must be built the following way: 1. Percent encode every key and value that will be signed. 2. Sort the list of parameters alphabetically by encoded key. 3. For each key/value pair: 4. Append the encoded key to the output string. 5. Append the '=' character to the output string. 6. Append the encoded value to the output string. 7. If there are more key/value pairs remaining, append a '&' character to the output string. @param parameters @return
[ "Per", "{", "@link", "https", ":", "//", "dev", ".", "twitter", ".", "com", "/", "oauth", "/", "overview", "/", "creating", "-", "signatures", "}", "the", "parameter", "string", "for", "signatures", "must", "be", "built", "the", "following", "way", ":", "1", ".", "Percent", "encode", "every", "key", "and", "value", "that", "will", "be", "signed", ".", "2", ".", "Sort", "the", "list", "of", "parameters", "alphabetically", "by", "encoded", "key", ".", "3", ".", "For", "each", "key", "/", "value", "pair", ":", "4", ".", "Append", "the", "encoded", "key", "to", "the", "output", "string", ".", "5", ".", "Append", "the", "=", "character", "to", "the", "output", "string", ".", "6", ".", "Append", "the", "encoded", "value", "to", "the", "output", "string", ".", "7", ".", "If", "there", "are", "more", "key", "/", "value", "pairs", "remaining", "append", "a", "&", "character", "to", "the", "output", "string", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L184-L223
michel-kraemer/bson4jackson
src/main/java/de/undercouch/bson4jackson/BsonFactory.java
BsonFactory.configure
public final BsonFactory configure(BsonParser.Feature f, boolean state) { if (state) { return enable(f); } return disable(f); }
java
public final BsonFactory configure(BsonParser.Feature f, boolean state) { if (state) { return enable(f); } return disable(f); }
[ "public", "final", "BsonFactory", "configure", "(", "BsonParser", ".", "Feature", "f", ",", "boolean", "state", ")", "{", "if", "(", "state", ")", "{", "return", "enable", "(", "f", ")", ";", "}", "return", "disable", "(", "f", ")", ";", "}" ]
Method for enabling/disabling specified parser features (check {@link BsonParser.Feature} for list of features) @param f the feature to enable or disable @param state true if the feature should be enabled, false otherwise @return this BsonFactory
[ "Method", "for", "enabling", "/", "disabling", "specified", "parser", "features", "(", "check", "{" ]
train
https://github.com/michel-kraemer/bson4jackson/blob/32d2ab3c516b3c07490fdfcf0c5e4ed0a2ee3979/src/main/java/de/undercouch/bson4jackson/BsonFactory.java#L161-L166