id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
145,500
geomajas/geomajas-project-hammer-gwt
hammer-gwt/src/main/java/org/geomajas/hammergwt/client/HammerGwt.java
HammerGwt.off
public static void off(HammerTime hammerTime, EventType eventType, NativeHammmerHandler callback) { off(hammerTime, callback, eventType.getText()); }
java
public static void off(HammerTime hammerTime, EventType eventType, NativeHammmerHandler callback) { off(hammerTime, callback, eventType.getText()); }
[ "public", "static", "void", "off", "(", "HammerTime", "hammerTime", ",", "EventType", "eventType", ",", "NativeHammmerHandler", "callback", ")", "{", "off", "(", "hammerTime", ",", "callback", ",", "eventType", ".", "getText", "(", ")", ")", ";", "}" ]
Unregister hammer event. @param hammerTime {@link HammerTime} hammer gwt instance. @param eventType {@link org.geomajas.hammergwt.client.event.EventType} @param callback {@link org.geomajas.hammergwt.client.handler.NativeHammmerHandler} of the event that needs to be unregistered.
[ "Unregister", "hammer", "event", "." ]
bc764171bed55e5a9eced72f0078ec22b8105b62
https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt/src/main/java/org/geomajas/hammergwt/client/HammerGwt.java#L58-L60
145,501
jbundle/webapp
proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java
ProxyServlet.getProxyURLString
public String getProxyURLString(HttpServletRequest req) throws MalformedURLException { String proxyUrlString = proxyURLPrefix; if (req.getPathInfo() != null) if (req.getPathInfo().length() > 0) proxyUrlString += req.getPathInfo(); if (req.getQueryString() != null) if (req.getQueryString().length() > 0) proxyUrlString += "?" + req.getQueryString(); req.getContentType(); return proxyUrlString; }
java
public String getProxyURLString(HttpServletRequest req) throws MalformedURLException { String proxyUrlString = proxyURLPrefix; if (req.getPathInfo() != null) if (req.getPathInfo().length() > 0) proxyUrlString += req.getPathInfo(); if (req.getQueryString() != null) if (req.getQueryString().length() > 0) proxyUrlString += "?" + req.getQueryString(); req.getContentType(); return proxyUrlString; }
[ "public", "String", "getProxyURLString", "(", "HttpServletRequest", "req", ")", "throws", "MalformedURLException", "{", "String", "proxyUrlString", "=", "proxyURLPrefix", ";", "if", "(", "req", ".", "getPathInfo", "(", ")", "!=", "null", ")", "if", "(", "req", ".", "getPathInfo", "(", ")", ".", "length", "(", ")", ">", "0", ")", "proxyUrlString", "+=", "req", ".", "getPathInfo", "(", ")", ";", "if", "(", "req", ".", "getQueryString", "(", ")", "!=", "null", ")", "if", "(", "req", ".", "getQueryString", "(", ")", ".", "length", "(", ")", ">", "0", ")", "proxyUrlString", "+=", "\"?\"", "+", "req", ".", "getQueryString", "(", ")", ";", "req", ".", "getContentType", "(", ")", ";", "return", "proxyUrlString", ";", "}" ]
Create the url string for the proxy server. @param req @return @throws MalformedURLException
[ "Create", "the", "url", "string", "for", "the", "proxy", "server", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java#L102-L113
145,502
jbundle/webapp
proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java
ProxyServlet.getHttpRequest
public HttpRequestBase getHttpRequest(HttpServletRequest req, String urlString) { // Prepare a request object HttpRequestBase httpget = null; String method = req.getMethod(); if (GET.equalsIgnoreCase(method)) httpget = new HttpGet(urlString); else if (POST.equalsIgnoreCase(method)) httpget = new HttpPost(urlString); else if (PUT.equalsIgnoreCase(method)) httpget = new HttpPut(urlString); else if (DELETE.equalsIgnoreCase(method)) httpget = new HttpDelete(urlString); else if (HEAD.equalsIgnoreCase(method)) httpget = new HttpHead(urlString); else if (OPTIONS.equalsIgnoreCase(method)) httpget = new HttpOptions(urlString); else if (TRACE.equalsIgnoreCase(method)) httpget = new HttpTrace(urlString); return httpget; }
java
public HttpRequestBase getHttpRequest(HttpServletRequest req, String urlString) { // Prepare a request object HttpRequestBase httpget = null; String method = req.getMethod(); if (GET.equalsIgnoreCase(method)) httpget = new HttpGet(urlString); else if (POST.equalsIgnoreCase(method)) httpget = new HttpPost(urlString); else if (PUT.equalsIgnoreCase(method)) httpget = new HttpPut(urlString); else if (DELETE.equalsIgnoreCase(method)) httpget = new HttpDelete(urlString); else if (HEAD.equalsIgnoreCase(method)) httpget = new HttpHead(urlString); else if (OPTIONS.equalsIgnoreCase(method)) httpget = new HttpOptions(urlString); else if (TRACE.equalsIgnoreCase(method)) httpget = new HttpTrace(urlString); return httpget; }
[ "public", "HttpRequestBase", "getHttpRequest", "(", "HttpServletRequest", "req", ",", "String", "urlString", ")", "{", "// Prepare a request object", "HttpRequestBase", "httpget", "=", "null", ";", "String", "method", "=", "req", ".", "getMethod", "(", ")", ";", "if", "(", "GET", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpGet", "(", "urlString", ")", ";", "else", "if", "(", "POST", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpPost", "(", "urlString", ")", ";", "else", "if", "(", "PUT", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpPut", "(", "urlString", ")", ";", "else", "if", "(", "DELETE", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpDelete", "(", "urlString", ")", ";", "else", "if", "(", "HEAD", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpHead", "(", "urlString", ")", ";", "else", "if", "(", "OPTIONS", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpOptions", "(", "urlString", ")", ";", "else", "if", "(", "TRACE", ".", "equalsIgnoreCase", "(", "method", ")", ")", "httpget", "=", "new", "HttpTrace", "(", "urlString", ")", ";", "return", "httpget", ";", "}" ]
Get the correct client type for this request. @param req @param urlString @return
[ "Get", "the", "correct", "client", "type", "for", "this", "request", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java#L120-L139
145,503
jbundle/webapp
proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java
ProxyServlet.addHeaders
public void addHeaders(HttpServletRequest reqSource, HttpRequestBase httpTarget) { Enumeration<?> headerNames = reqSource.getHeaderNames(); while (headerNames.hasMoreElements()) { String key = headerNames.nextElement().toString(); if (CONTENT_LENGTH.equalsIgnoreCase(key)) continue; // Length will be different Enumeration<?> headers = reqSource.getHeaders(key); while (headers.hasMoreElements()) { String value = (String)headers.nextElement(); if (HOST.equalsIgnoreCase(key)) { value = proxyURLPrefix; if (value.indexOf(":") != -1) { value = value.substring(value.indexOf(":") + 1); while (value.startsWith("/")) { value = value.substring(1); } } if (value.indexOf("/") != -1) value = value.substring(0, value.indexOf("/")); } httpTarget.setHeader(new BasicHeader(key, value)); } } }
java
public void addHeaders(HttpServletRequest reqSource, HttpRequestBase httpTarget) { Enumeration<?> headerNames = reqSource.getHeaderNames(); while (headerNames.hasMoreElements()) { String key = headerNames.nextElement().toString(); if (CONTENT_LENGTH.equalsIgnoreCase(key)) continue; // Length will be different Enumeration<?> headers = reqSource.getHeaders(key); while (headers.hasMoreElements()) { String value = (String)headers.nextElement(); if (HOST.equalsIgnoreCase(key)) { value = proxyURLPrefix; if (value.indexOf(":") != -1) { value = value.substring(value.indexOf(":") + 1); while (value.startsWith("/")) { value = value.substring(1); } } if (value.indexOf("/") != -1) value = value.substring(0, value.indexOf("/")); } httpTarget.setHeader(new BasicHeader(key, value)); } } }
[ "public", "void", "addHeaders", "(", "HttpServletRequest", "reqSource", ",", "HttpRequestBase", "httpTarget", ")", "{", "Enumeration", "<", "?", ">", "headerNames", "=", "reqSource", ".", "getHeaderNames", "(", ")", ";", "while", "(", "headerNames", ".", "hasMoreElements", "(", ")", ")", "{", "String", "key", "=", "headerNames", ".", "nextElement", "(", ")", ".", "toString", "(", ")", ";", "if", "(", "CONTENT_LENGTH", ".", "equalsIgnoreCase", "(", "key", ")", ")", "continue", ";", "// Length will be different", "Enumeration", "<", "?", ">", "headers", "=", "reqSource", ".", "getHeaders", "(", "key", ")", ";", "while", "(", "headers", ".", "hasMoreElements", "(", ")", ")", "{", "String", "value", "=", "(", "String", ")", "headers", ".", "nextElement", "(", ")", ";", "if", "(", "HOST", ".", "equalsIgnoreCase", "(", "key", ")", ")", "{", "value", "=", "proxyURLPrefix", ";", "if", "(", "value", ".", "indexOf", "(", "\":\"", ")", "!=", "-", "1", ")", "{", "value", "=", "value", ".", "substring", "(", "value", ".", "indexOf", "(", "\":\"", ")", "+", "1", ")", ";", "while", "(", "value", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "value", "=", "value", ".", "substring", "(", "1", ")", ";", "}", "}", "if", "(", "value", ".", "indexOf", "(", "\"/\"", ")", "!=", "-", "1", ")", "value", "=", "value", ".", "substring", "(", "0", ",", "value", ".", "indexOf", "(", "\"/\"", ")", ")", ";", "}", "httpTarget", ".", "setHeader", "(", "new", "BasicHeader", "(", "key", ",", "value", ")", ")", ";", "}", "}", "}" ]
Move the header info to the proxy request. @param reqSource @param httpTarget
[ "Move", "the", "header", "info", "to", "the", "proxy", "request", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java#L145-L174
145,504
jbundle/webapp
proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java
ProxyServlet.getDataFromClient
public void getDataFromClient(HttpRequestBase httpget, OutputStream streamOut) throws ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); // Execute the request HttpResponse response = httpclient.execute(httpget); // Get the response entity HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); ProxyServlet.transferURLStream(instream, streamOut); // Closing the input stream will trigger connection release instream.close(); // There is probably a less resource intensive way to do this. httpclient.getConnectionManager().shutdown(); } }
java
public void getDataFromClient(HttpRequestBase httpget, OutputStream streamOut) throws ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); // Execute the request HttpResponse response = httpclient.execute(httpget); // Get the response entity HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); ProxyServlet.transferURLStream(instream, streamOut); // Closing the input stream will trigger connection release instream.close(); // There is probably a less resource intensive way to do this. httpclient.getConnectionManager().shutdown(); } }
[ "public", "void", "getDataFromClient", "(", "HttpRequestBase", "httpget", ",", "OutputStream", "streamOut", ")", "throws", "ClientProtocolException", ",", "IOException", "{", "HttpClient", "httpclient", "=", "new", "DefaultHttpClient", "(", ")", ";", "// Execute the request", "HttpResponse", "response", "=", "httpclient", ".", "execute", "(", "httpget", ")", ";", "// Get the response entity", "HttpEntity", "entity", "=", "response", ".", "getEntity", "(", ")", ";", "if", "(", "entity", "!=", "null", ")", "{", "InputStream", "instream", "=", "entity", ".", "getContent", "(", ")", ";", "ProxyServlet", ".", "transferURLStream", "(", "instream", ",", "streamOut", ")", ";", "// Closing the input stream will trigger connection release", "instream", ".", "close", "(", ")", ";", "// There is probably a less resource intensive way to do this.", "httpclient", ".", "getConnectionManager", "(", ")", ".", "shutdown", "(", ")", ";", "}", "}" ]
Get the data from the proxy and send it to the client. @param httpget @param streamOut @throws IOException @throws ClientProtocolException
[ "Get", "the", "data", "from", "the", "proxy", "and", "send", "it", "to", "the", "client", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java#L194-L216
145,505
jbundle/webapp
proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java
ProxyServlet.transferURLStream
public static void transferURLStream(InputStream streamIn, OutputStream streamOut) { try { byte[] cbuf = new byte[1000]; int iLen = 0; while ((iLen = streamIn.read(cbuf, 0, cbuf.length)) > 0) { // Write the entire file to the output buffer streamOut.write(cbuf, 0, iLen); } streamIn.close(); if (streamIn != null) streamIn.close(); } catch (MalformedURLException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
java
public static void transferURLStream(InputStream streamIn, OutputStream streamOut) { try { byte[] cbuf = new byte[1000]; int iLen = 0; while ((iLen = streamIn.read(cbuf, 0, cbuf.length)) > 0) { // Write the entire file to the output buffer streamOut.write(cbuf, 0, iLen); } streamIn.close(); if (streamIn != null) streamIn.close(); } catch (MalformedURLException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
[ "public", "static", "void", "transferURLStream", "(", "InputStream", "streamIn", ",", "OutputStream", "streamOut", ")", "{", "try", "{", "byte", "[", "]", "cbuf", "=", "new", "byte", "[", "1000", "]", ";", "int", "iLen", "=", "0", ";", "while", "(", "(", "iLen", "=", "streamIn", ".", "read", "(", "cbuf", ",", "0", ",", "cbuf", ".", "length", ")", ")", ">", "0", ")", "{", "// Write the entire file to the output buffer", "streamOut", ".", "write", "(", "cbuf", ",", "0", ",", "iLen", ")", ";", "}", "streamIn", ".", "close", "(", ")", ";", "if", "(", "streamIn", "!=", "null", ")", "streamIn", ".", "close", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Transfer the data stream from this URL to another stream. @param strURL The URL to read. @param strFilename If non-null, create this file and send the URL data here. @param strFilename If null, return the stream as a string. @param in If this is non-null, read from this input source. @return The stream as a string if filename is null.
[ "Transfer", "the", "data", "stream", "from", "this", "URL", "to", "another", "stream", "." ]
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/proxy/src/main/java/org/jbundle/util/webapp/proxy/ProxyServlet.java#L225-L242
145,506
akberc/ceylon-maven-plugin
src/main/java/com/dgwave/car/maven/CeylonSdkCheck.java
CeylonSdkCheck.findSdkHome
File findSdkHome(final String path) { File dotCeylon = new File(path); // or some other directory File[] homes = null; if (!dotCeylon.exists()) { return null; } else { homes = dotCeylon.listFiles(new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { if (name.startsWith("ceylon-1.")) { return true; } return false; } }); } if (homes.length == 0) { return null; } else if (homes.length == 1 & homes[0].isDirectory()) { return homes[0]; } else { Arrays.sort(homes); if (homes[homes.length - 1].isDirectory()) { return homes[homes.length - 1]; } else { return null; } } }
java
File findSdkHome(final String path) { File dotCeylon = new File(path); // or some other directory File[] homes = null; if (!dotCeylon.exists()) { return null; } else { homes = dotCeylon.listFiles(new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { if (name.startsWith("ceylon-1.")) { return true; } return false; } }); } if (homes.length == 0) { return null; } else if (homes.length == 1 & homes[0].isDirectory()) { return homes[0]; } else { Arrays.sort(homes); if (homes[homes.length - 1].isDirectory()) { return homes[homes.length - 1]; } else { return null; } } }
[ "File", "findSdkHome", "(", "final", "String", "path", ")", "{", "File", "dotCeylon", "=", "new", "File", "(", "path", ")", ";", "// or some other directory\r", "File", "[", "]", "homes", "=", "null", ";", "if", "(", "!", "dotCeylon", ".", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "homes", "=", "dotCeylon", ".", "listFiles", "(", "new", "FilenameFilter", "(", ")", "{", "@", "Override", "public", "boolean", "accept", "(", "final", "File", "dir", ",", "final", "String", "name", ")", "{", "if", "(", "name", ".", "startsWith", "(", "\"ceylon-1.\"", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", ")", ";", "}", "if", "(", "homes", ".", "length", "==", "0", ")", "{", "return", "null", ";", "}", "else", "if", "(", "homes", ".", "length", "==", "1", "&", "homes", "[", "0", "]", ".", "isDirectory", "(", ")", ")", "{", "return", "homes", "[", "0", "]", ";", "}", "else", "{", "Arrays", ".", "sort", "(", "homes", ")", ";", "if", "(", "homes", "[", "homes", ".", "length", "-", "1", "]", ".", "isDirectory", "(", ")", ")", "{", "return", "homes", "[", "homes", ".", "length", "-", "1", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}" ]
Find Ceylon SDK home in a folder, in the form of 'ceylon-1.x.x'. @param path Folder path to search in @return File folder whose name is alphabetically highest, or null if not found.
[ "Find", "Ceylon", "SDK", "home", "in", "a", "folder", "in", "the", "form", "of", "ceylon", "-", "1", ".", "x", ".", "x", "." ]
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonSdkCheck.java#L93-L124
145,507
dbracewell/mango
src/main/java/com/davidbracewell/reflection/BeanMap.java
BeanMap.getType
public Class<?> getType(String key) { if (beanDescriptor.hasReadMethod(key)) { return beanDescriptor.getReadMethod(key).getReturnType(); } else if (beanDescriptor.hasWriteMethod(key)) { Class<?>[] paramTypes = beanDescriptor.getWriteMethod(key).getParameterTypes(); if (paramTypes.length > 0) { return paramTypes[0]; } } return null; }
java
public Class<?> getType(String key) { if (beanDescriptor.hasReadMethod(key)) { return beanDescriptor.getReadMethod(key).getReturnType(); } else if (beanDescriptor.hasWriteMethod(key)) { Class<?>[] paramTypes = beanDescriptor.getWriteMethod(key).getParameterTypes(); if (paramTypes.length > 0) { return paramTypes[0]; } } return null; }
[ "public", "Class", "<", "?", ">", "getType", "(", "String", "key", ")", "{", "if", "(", "beanDescriptor", ".", "hasReadMethod", "(", "key", ")", ")", "{", "return", "beanDescriptor", ".", "getReadMethod", "(", "key", ")", ".", "getReturnType", "(", ")", ";", "}", "else", "if", "(", "beanDescriptor", ".", "hasWriteMethod", "(", "key", ")", ")", "{", "Class", "<", "?", ">", "[", "]", "paramTypes", "=", "beanDescriptor", ".", "getWriteMethod", "(", "key", ")", ".", "getParameterTypes", "(", ")", ";", "if", "(", "paramTypes", ".", "length", ">", "0", ")", "{", "return", "paramTypes", "[", "0", "]", ";", "}", "}", "return", "null", ";", "}" ]
Gets the type of the parameter on the setter method. @param key The setter method @return A <code>Class</code> representing the parameter type of the setter method
[ "Gets", "the", "type", "of", "the", "parameter", "on", "the", "setter", "method", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/reflection/BeanMap.java#L115-L125
145,508
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.get
@Override public T get(X primaryID) { if(primaryID == null) { return null; } T dbObject = this.mongoTemplate.findById(primaryID, this.entityClass); return dbObject; }
java
@Override public T get(X primaryID) { if(primaryID == null) { return null; } T dbObject = this.mongoTemplate.findById(primaryID, this.entityClass); return dbObject; }
[ "@", "Override", "public", "T", "get", "(", "X", "primaryID", ")", "{", "if", "(", "primaryID", "==", "null", ")", "{", "return", "null", ";", "}", "T", "dbObject", "=", "this", ".", "mongoTemplate", ".", "findById", "(", "primaryID", ",", "this", ".", "entityClass", ")", ";", "return", "dbObject", ";", "}" ]
Return the object as defined by this primary key. @param primaryID the primary key for record @return the record if available, <code>null</code> otherwise
[ "Return", "the", "object", "as", "defined", "by", "this", "primary", "key", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L103-L111
145,509
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.insert
@Override public boolean insert(T entity) { if(entity == null) { return false; } X primaryID = getPrimaryID(entity); if(primaryID != null) { if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } } try { this.mongoTemplate.insert(entity); } catch(RuntimeException e) { // this ensures that any insert operation that fails returns a false return false; } return true; }
java
@Override public boolean insert(T entity) { if(entity == null) { return false; } X primaryID = getPrimaryID(entity); if(primaryID != null) { if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } } try { this.mongoTemplate.insert(entity); } catch(RuntimeException e) { // this ensures that any insert operation that fails returns a false return false; } return true; }
[ "@", "Override", "public", "boolean", "insert", "(", "T", "entity", ")", "{", "if", "(", "entity", "==", "null", ")", "{", "return", "false", ";", "}", "X", "primaryID", "=", "getPrimaryID", "(", "entity", ")", ";", "if", "(", "primaryID", "!=", "null", ")", "{", "if", "(", "!", "allowEmptyOrZeroID", "(", ")", "&&", "AssertUtils", ".", "isEmpty", "(", "primaryID", ")", ")", "{", "return", "false", ";", "}", "}", "try", "{", "this", ".", "mongoTemplate", ".", "insert", "(", "entity", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "// this ensures that any insert operation that fails returns a false", "return", "false", ";", "}", "return", "true", ";", "}" ]
Insert the object into the data store. @param entity the entity to insert @return <code>true</code> if inserted, <code>false</code> otherwise
[ "Insert", "the", "object", "into", "the", "data", "store", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L172-L193
145,510
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.update
@Override public boolean update(T entity) { if(entity == null) { return false; } X primaryID = getPrimaryID(entity); if(primaryID == null) { return false; } if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } this.mongoTemplate.save(entity); return true; }
java
@Override public boolean update(T entity) { if(entity == null) { return false; } X primaryID = getPrimaryID(entity); if(primaryID == null) { return false; } if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } this.mongoTemplate.save(entity); return true; }
[ "@", "Override", "public", "boolean", "update", "(", "T", "entity", ")", "{", "if", "(", "entity", "==", "null", ")", "{", "return", "false", ";", "}", "X", "primaryID", "=", "getPrimaryID", "(", "entity", ")", ";", "if", "(", "primaryID", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "!", "allowEmptyOrZeroID", "(", ")", "&&", "AssertUtils", ".", "isEmpty", "(", "primaryID", ")", ")", "{", "return", "false", ";", "}", "this", ".", "mongoTemplate", ".", "save", "(", "entity", ")", ";", "return", "true", ";", "}" ]
Update the entity in the data store. @param entity the entity to update @return <code>true</code> if updated, <code>false</code> otherwise
[ "Update", "the", "entity", "in", "the", "data", "store", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L203-L220
145,511
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.addOrUpdate
@Override public boolean addOrUpdate(T object) { if(object == null) { return false; } X primaryID = getPrimaryID(object); if(primaryID == null) { this.mongoTemplate.save(object); return true; } if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } this.mongoTemplate.save(object); return true; }
java
@Override public boolean addOrUpdate(T object) { if(object == null) { return false; } X primaryID = getPrimaryID(object); if(primaryID == null) { this.mongoTemplate.save(object); return true; } if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) { return false; } this.mongoTemplate.save(object); return true; }
[ "@", "Override", "public", "boolean", "addOrUpdate", "(", "T", "object", ")", "{", "if", "(", "object", "==", "null", ")", "{", "return", "false", ";", "}", "X", "primaryID", "=", "getPrimaryID", "(", "object", ")", ";", "if", "(", "primaryID", "==", "null", ")", "{", "this", ".", "mongoTemplate", ".", "save", "(", "object", ")", ";", "return", "true", ";", "}", "if", "(", "!", "allowEmptyOrZeroID", "(", ")", "&&", "AssertUtils", ".", "isEmpty", "(", "primaryID", ")", ")", "{", "return", "false", ";", "}", "this", ".", "mongoTemplate", ".", "save", "(", "object", ")", ";", "return", "true", ";", "}" ]
Add or update an existing object in the data store. @param object the object to save @return <code>true</code> if saved, <code>false</code> otherwise
[ "Add", "or", "update", "an", "existing", "object", "in", "the", "data", "store", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L230-L248
145,512
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.delete
@Override public T delete(X primaryID) { if(primaryID == null) { return null; } T entity = get(primaryID); if(entity == null) { return null; } this.mongoTemplate.remove(entity); return entity; }
java
@Override public T delete(X primaryID) { if(primaryID == null) { return null; } T entity = get(primaryID); if(entity == null) { return null; } this.mongoTemplate.remove(entity); return entity; }
[ "@", "Override", "public", "T", "delete", "(", "X", "primaryID", ")", "{", "if", "(", "primaryID", "==", "null", ")", "{", "return", "null", ";", "}", "T", "entity", "=", "get", "(", "primaryID", ")", ";", "if", "(", "entity", "==", "null", ")", "{", "return", "null", ";", "}", "this", ".", "mongoTemplate", ".", "remove", "(", "entity", ")", ";", "return", "entity", ";", "}" ]
Delete the object against the given primary key. @param primaryID the primary key @return the record that was removed
[ "Delete", "the", "object", "against", "the", "given", "primary", "key", "." ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L258-L271
145,513
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.getPrimaryID
public X getPrimaryID(T entity) { if(mappingContext == null || conversionService == null) { fetchMappingContextAndConversionService(); } MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entity.getClass()); MongoPersistentProperty idProperty = persistentEntity.getIdProperty(); if(idProperty == null) { return null; } // X idValue = BeanWrapper.create(entity, conversionService).getProperty(idProperty, this.primaryIDClass); X idValue = (X) this.mappingContext.getPersistentEntity(this.entityClass).getPropertyAccessor(entity).getProperty(idProperty); return idValue; }
java
public X getPrimaryID(T entity) { if(mappingContext == null || conversionService == null) { fetchMappingContextAndConversionService(); } MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entity.getClass()); MongoPersistentProperty idProperty = persistentEntity.getIdProperty(); if(idProperty == null) { return null; } // X idValue = BeanWrapper.create(entity, conversionService).getProperty(idProperty, this.primaryIDClass); X idValue = (X) this.mappingContext.getPersistentEntity(this.entityClass).getPropertyAccessor(entity).getProperty(idProperty); return idValue; }
[ "public", "X", "getPrimaryID", "(", "T", "entity", ")", "{", "if", "(", "mappingContext", "==", "null", "||", "conversionService", "==", "null", ")", "{", "fetchMappingContextAndConversionService", "(", ")", ";", "}", "MongoPersistentEntity", "<", "?", ">", "persistentEntity", "=", "mappingContext", ".", "getPersistentEntity", "(", "entity", ".", "getClass", "(", ")", ")", ";", "MongoPersistentProperty", "idProperty", "=", "persistentEntity", ".", "getIdProperty", "(", ")", ";", "if", "(", "idProperty", "==", "null", ")", "{", "return", "null", ";", "}", "//\t\tX idValue = BeanWrapper.create(entity, conversionService).getProperty(idProperty, this.primaryIDClass);", "X", "idValue", "=", "(", "X", ")", "this", ".", "mappingContext", ".", "getPersistentEntity", "(", "this", ".", "entityClass", ")", ".", "getPropertyAccessor", "(", "entity", ")", ".", "getProperty", "(", "idProperty", ")", ";", "return", "idValue", ";", "}" ]
Extract the value of the primary ID of the entity object @param entity the entity to get primary key value of @return the primary key value
[ "Extract", "the", "value", "of", "the", "primary", "ID", "of", "the", "entity", "object" ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L311-L325
145,514
sangupta/jerry-services
src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java
MongoDBBasicOperations.fetchMappingContextAndConversionService
private synchronized void fetchMappingContextAndConversionService() { if(mappingContext == null) { MongoConverter mongoConverter = this.mongoTemplate.getConverter(); mappingContext = mongoConverter.getMappingContext(); conversionService = mongoConverter.getConversionService(); MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entityClass); MongoPersistentProperty idProperty = persistentEntity.getIdProperty(); this.idKey = idProperty == null ? "_id" : idProperty.getName(); } }
java
private synchronized void fetchMappingContextAndConversionService() { if(mappingContext == null) { MongoConverter mongoConverter = this.mongoTemplate.getConverter(); mappingContext = mongoConverter.getMappingContext(); conversionService = mongoConverter.getConversionService(); MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entityClass); MongoPersistentProperty idProperty = persistentEntity.getIdProperty(); this.idKey = idProperty == null ? "_id" : idProperty.getName(); } }
[ "private", "synchronized", "void", "fetchMappingContextAndConversionService", "(", ")", "{", "if", "(", "mappingContext", "==", "null", ")", "{", "MongoConverter", "mongoConverter", "=", "this", ".", "mongoTemplate", ".", "getConverter", "(", ")", ";", "mappingContext", "=", "mongoConverter", ".", "getMappingContext", "(", ")", ";", "conversionService", "=", "mongoConverter", ".", "getConversionService", "(", ")", ";", "MongoPersistentEntity", "<", "?", ">", "persistentEntity", "=", "mappingContext", ".", "getPersistentEntity", "(", "entityClass", ")", ";", "MongoPersistentProperty", "idProperty", "=", "persistentEntity", ".", "getIdProperty", "(", ")", ";", "this", ".", "idKey", "=", "idProperty", "==", "null", "?", "\"_id\"", ":", "idProperty", ".", "getName", "(", ")", ";", "}", "}" ]
Get the basic services from mongo template
[ "Get", "the", "basic", "services", "from", "mongo", "template" ]
25ff6577445850916425c72068d654c08eba9bcc
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/db/service/impl/MongoDBBasicOperations.java#L330-L340
145,515
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.readConfiguration
public void readConfiguration(File configFile) throws TracerFactory.Exception, FileNotFoundException { if (!configFile.exists()) throw new FileNotFoundException(configFile + "doesn't exist."); try (FileInputStream fileInputStream = new FileInputStream(configFile)) { readConfiguration(fileInputStream); } catch (IOException ex) { ex.printStackTrace(System.err); } }
java
public void readConfiguration(File configFile) throws TracerFactory.Exception, FileNotFoundException { if (!configFile.exists()) throw new FileNotFoundException(configFile + "doesn't exist."); try (FileInputStream fileInputStream = new FileInputStream(configFile)) { readConfiguration(fileInputStream); } catch (IOException ex) { ex.printStackTrace(System.err); } }
[ "public", "void", "readConfiguration", "(", "File", "configFile", ")", "throws", "TracerFactory", ".", "Exception", ",", "FileNotFoundException", "{", "if", "(", "!", "configFile", ".", "exists", "(", ")", ")", "throw", "new", "FileNotFoundException", "(", "configFile", "+", "\"doesn't exist.\"", ")", ";", "try", "(", "FileInputStream", "fileInputStream", "=", "new", "FileInputStream", "(", "configFile", ")", ")", "{", "readConfiguration", "(", "fileInputStream", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", "System", ".", "err", ")", ";", "}", "}" ]
Reads the given configuration file, validates it against a XML-Schema and creates the tracer pool, its mappings and the queue accordingly. This method should normally be invoked once at program start. Multiple calls with the same configuration file leads to instantiations of new tracer objects and mappings which will replace the old tracers and their mappings. @param configFile the configuration file @throws TracerFactory.Exception indicates a configuration problem @throws FileNotFoundException indicates a missing configuration file
[ "Reads", "the", "given", "configuration", "file", "validates", "it", "against", "a", "XML", "-", "Schema", "and", "creates", "the", "tracer", "pool", "its", "mappings", "and", "the", "queue", "accordingly", ".", "This", "method", "should", "normally", "be", "invoked", "once", "at", "program", "start", ".", "Multiple", "calls", "with", "the", "same", "configuration", "file", "leads", "to", "instantiations", "of", "new", "tracer", "objects", "and", "mappings", "which", "will", "replace", "the", "old", "tracers", "and", "their", "mappings", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L353-L362
145,516
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.getTracer
public AbstractTracer getTracer(String name) throws TracerFactory.Exception { this.poolReadLock.lock(); try { return getTracerByName(name); } finally { this.poolReadLock.unlock(); } }
java
public AbstractTracer getTracer(String name) throws TracerFactory.Exception { this.poolReadLock.lock(); try { return getTracerByName(name); } finally { this.poolReadLock.unlock(); } }
[ "public", "AbstractTracer", "getTracer", "(", "String", "name", ")", "throws", "TracerFactory", ".", "Exception", "{", "this", ".", "poolReadLock", ".", "lock", "(", ")", ";", "try", "{", "return", "getTracerByName", "(", "name", ")", ";", "}", "finally", "{", "this", ".", "poolReadLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns the pooled tracer with the given name. @param name the name of the desired tracer @return the pooled tracer @throws TracerFactory.Exception if no tracer exists with the given name
[ "Returns", "the", "pooled", "tracer", "with", "the", "given", "name", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L499-L507
145,517
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.reset
public void reset() { this.poolWriteLock.lock(); try { this.defaultTracer = TracerFactory.NULLTRACER; this.threadName2Element.clear(); this.threadNames.clear(); this.tracerMap.clear(); this.tracerPool.clear(); } finally { this.poolWriteLock.unlock(); } this.queueWriteLock.lock(); try { this.queueConfig = new Queue(); } finally { this.queueWriteLock.unlock(); } }
java
public void reset() { this.poolWriteLock.lock(); try { this.defaultTracer = TracerFactory.NULLTRACER; this.threadName2Element.clear(); this.threadNames.clear(); this.tracerMap.clear(); this.tracerPool.clear(); } finally { this.poolWriteLock.unlock(); } this.queueWriteLock.lock(); try { this.queueConfig = new Queue(); } finally { this.queueWriteLock.unlock(); } }
[ "public", "void", "reset", "(", ")", "{", "this", ".", "poolWriteLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "defaultTracer", "=", "TracerFactory", ".", "NULLTRACER", ";", "this", ".", "threadName2Element", ".", "clear", "(", ")", ";", "this", ".", "threadNames", ".", "clear", "(", ")", ";", "this", ".", "tracerMap", ".", "clear", "(", ")", ";", "this", ".", "tracerPool", ".", "clear", "(", ")", ";", "}", "finally", "{", "this", ".", "poolWriteLock", ".", "unlock", "(", ")", ";", "}", "this", ".", "queueWriteLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "queueConfig", "=", "new", "Queue", "(", ")", ";", "}", "finally", "{", "this", ".", "queueWriteLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Clears the pool, the mappings and the queue.
[ "Clears", "the", "pool", "the", "mappings", "and", "the", "queue", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L566-L586
145,518
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.openPoolTracer
public void openPoolTracer() { this.poolWriteLock.lock(); try { for (AbstractTracer tracer : this.tracerPool.values()) { tracer.open(); } } finally { this.poolWriteLock.unlock(); } }
java
public void openPoolTracer() { this.poolWriteLock.lock(); try { for (AbstractTracer tracer : this.tracerPool.values()) { tracer.open(); } } finally { this.poolWriteLock.unlock(); } }
[ "public", "void", "openPoolTracer", "(", ")", "{", "this", ".", "poolWriteLock", ".", "lock", "(", ")", ";", "try", "{", "for", "(", "AbstractTracer", "tracer", ":", "this", ".", "tracerPool", ".", "values", "(", ")", ")", "{", "tracer", ".", "open", "(", ")", ";", "}", "}", "finally", "{", "this", ".", "poolWriteLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Opens all pooled tracers.
[ "Opens", "all", "pooled", "tracers", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L591-L601
145,519
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.closePoolTracer
public void closePoolTracer() { this.poolWriteLock.lock(); try { for (AbstractTracer tracer : this.tracerPool.values()) { tracer.close(); } } finally { this.poolWriteLock.unlock(); } }
java
public void closePoolTracer() { this.poolWriteLock.lock(); try { for (AbstractTracer tracer : this.tracerPool.values()) { tracer.close(); } } finally { this.poolWriteLock.unlock(); } }
[ "public", "void", "closePoolTracer", "(", ")", "{", "this", ".", "poolWriteLock", ".", "lock", "(", ")", ";", "try", "{", "for", "(", "AbstractTracer", "tracer", ":", "this", ".", "tracerPool", ".", "values", "(", ")", ")", "{", "tracer", ".", "close", "(", ")", ";", "}", "}", "finally", "{", "this", ".", "poolWriteLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Closes all pooled tracers.
[ "Closes", "all", "pooled", "tracers", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L606-L616
145,520
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.openQueueTracer
public boolean openQueueTracer() { final int TRIALS = 5; int tracerCounter = 0, trialCounter = 0; boolean success = false; do { this.queueWriteLock.lock(); try { if (this.queueConfig.enabled) { for (QueueTracer<?> queueTracer : this.queueConfig.blockingTracerDeque) { if (!queueTracer.isOpened()) { queueTracer.open(); tracerCounter++; if (tracerCounter == this.queueConfig.size) success = true; } } } } finally { this.queueWriteLock.unlock(); } trialCounter++; } while (tracerCounter < this.queueConfig.size && trialCounter < TRIALS); return success; }
java
public boolean openQueueTracer() { final int TRIALS = 5; int tracerCounter = 0, trialCounter = 0; boolean success = false; do { this.queueWriteLock.lock(); try { if (this.queueConfig.enabled) { for (QueueTracer<?> queueTracer : this.queueConfig.blockingTracerDeque) { if (!queueTracer.isOpened()) { queueTracer.open(); tracerCounter++; if (tracerCounter == this.queueConfig.size) success = true; } } } } finally { this.queueWriteLock.unlock(); } trialCounter++; } while (tracerCounter < this.queueConfig.size && trialCounter < TRIALS); return success; }
[ "public", "boolean", "openQueueTracer", "(", ")", "{", "final", "int", "TRIALS", "=", "5", ";", "int", "tracerCounter", "=", "0", ",", "trialCounter", "=", "0", ";", "boolean", "success", "=", "false", ";", "do", "{", "this", ".", "queueWriteLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "this", ".", "queueConfig", ".", "enabled", ")", "{", "for", "(", "QueueTracer", "<", "?", ">", "queueTracer", ":", "this", ".", "queueConfig", ".", "blockingTracerDeque", ")", "{", "if", "(", "!", "queueTracer", ".", "isOpened", "(", ")", ")", "{", "queueTracer", ".", "open", "(", ")", ";", "tracerCounter", "++", ";", "if", "(", "tracerCounter", "==", "this", ".", "queueConfig", ".", "size", ")", "success", "=", "true", ";", "}", "}", "}", "}", "finally", "{", "this", ".", "queueWriteLock", ".", "unlock", "(", ")", ";", "}", "trialCounter", "++", ";", "}", "while", "(", "tracerCounter", "<", "this", ".", "queueConfig", ".", "size", "&&", "trialCounter", "<", "TRIALS", ")", ";", "return", "success", ";", "}" ]
Tries to open all enqueued QueueTracer. @return true if all configured tracers has been opened, false otherwise
[ "Tries", "to", "open", "all", "enqueued", "QueueTracer", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L691-L717
145,521
chr78rm/tracelogger
src/main/java/de/christofreichardt/diagnosis/TracerFactory.java
TracerFactory.getCurrentQueueTracer
public QueueTracer<?> getCurrentQueueTracer() { this.queueReadLock.lock(); try { QueueTracer<?> tracer; if (this.queueConfig.enabled) { // tracer = this.queueConfig.tracerMap.get(Thread.currentThread()); tracer = this.queueConfig.currentTracer.get(); if (tracer == null) { tracer = this.queueConfig.queueNullTracer; } } else { tracer = this.queueConfig.queueNullTracer; } return tracer; } finally { this.queueReadLock.unlock(); } }
java
public QueueTracer<?> getCurrentQueueTracer() { this.queueReadLock.lock(); try { QueueTracer<?> tracer; if (this.queueConfig.enabled) { // tracer = this.queueConfig.tracerMap.get(Thread.currentThread()); tracer = this.queueConfig.currentTracer.get(); if (tracer == null) { tracer = this.queueConfig.queueNullTracer; } } else { tracer = this.queueConfig.queueNullTracer; } return tracer; } finally { this.queueReadLock.unlock(); } }
[ "public", "QueueTracer", "<", "?", ">", "getCurrentQueueTracer", "(", ")", "{", "this", ".", "queueReadLock", ".", "lock", "(", ")", ";", "try", "{", "QueueTracer", "<", "?", ">", "tracer", ";", "if", "(", "this", ".", "queueConfig", ".", "enabled", ")", "{", "// tracer = this.queueConfig.tracerMap.get(Thread.currentThread());\r", "tracer", "=", "this", ".", "queueConfig", ".", "currentTracer", ".", "get", "(", ")", ";", "if", "(", "tracer", "==", "null", ")", "{", "tracer", "=", "this", ".", "queueConfig", ".", "queueNullTracer", ";", "}", "}", "else", "{", "tracer", "=", "this", ".", "queueConfig", ".", "queueNullTracer", ";", "}", "return", "tracer", ";", "}", "finally", "{", "this", ".", "queueReadLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns the QueueTracer for the current thread. If no one was found a QueueNullTracer will be returned. @return the QueueTracer for the current thread
[ "Returns", "the", "QueueTracer", "for", "the", "current", "thread", ".", "If", "no", "one", "was", "found", "a", "QueueNullTracer", "will", "be", "returned", "." ]
ad22452b20f8111ad4d367302c2b26a100a20200
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/TracerFactory.java#L756-L776
145,522
dbracewell/mango
src/main/java/com/davidbracewell/cli/NamedOption.java
NamedOption.setValue
void setValue(String optionValue) { if (StringUtils.isNullOrBlank(optionValue) && isBoolean()) { this.value = true; } else if (!StringUtils.isNullOrBlank(optionValue)) { if (Collection.class.isAssignableFrom(type)) { Class<?> genericType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; this.value = Convert.convert(optionValue, type, genericType); } else if (Map.class.isAssignableFrom(type)) { Class<?> keyType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; Class<?> valueType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1]; this.value = Convert.convert(optionValue, type, keyType, valueType); } else { this.value = Convert.convert(optionValue, type); } } }
java
void setValue(String optionValue) { if (StringUtils.isNullOrBlank(optionValue) && isBoolean()) { this.value = true; } else if (!StringUtils.isNullOrBlank(optionValue)) { if (Collection.class.isAssignableFrom(type)) { Class<?> genericType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; this.value = Convert.convert(optionValue, type, genericType); } else if (Map.class.isAssignableFrom(type)) { Class<?> keyType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; Class<?> valueType = field == null ? String.class : (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1]; this.value = Convert.convert(optionValue, type, keyType, valueType); } else { this.value = Convert.convert(optionValue, type); } } }
[ "void", "setValue", "(", "String", "optionValue", ")", "{", "if", "(", "StringUtils", ".", "isNullOrBlank", "(", "optionValue", ")", "&&", "isBoolean", "(", ")", ")", "{", "this", ".", "value", "=", "true", ";", "}", "else", "if", "(", "!", "StringUtils", ".", "isNullOrBlank", "(", "optionValue", ")", ")", "{", "if", "(", "Collection", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "Class", "<", "?", ">", "genericType", "=", "field", "==", "null", "?", "String", ".", "class", ":", "(", "Class", "<", "?", ">", ")", "(", "(", "ParameterizedType", ")", "field", ".", "getGenericType", "(", ")", ")", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "this", ".", "value", "=", "Convert", ".", "convert", "(", "optionValue", ",", "type", ",", "genericType", ")", ";", "}", "else", "if", "(", "Map", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "Class", "<", "?", ">", "keyType", "=", "field", "==", "null", "?", "String", ".", "class", ":", "(", "Class", "<", "?", ">", ")", "(", "(", "ParameterizedType", ")", "field", ".", "getGenericType", "(", ")", ")", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "Class", "<", "?", ">", "valueType", "=", "field", "==", "null", "?", "String", ".", "class", ":", "(", "Class", "<", "?", ">", ")", "(", "(", "ParameterizedType", ")", "field", ".", "getGenericType", "(", ")", ")", ".", "getActualTypeArguments", "(", ")", "[", "1", "]", ";", "this", ".", "value", "=", "Convert", ".", "convert", "(", "optionValue", ",", "type", ",", "keyType", ",", "valueType", ")", ";", "}", "else", "{", "this", ".", "value", "=", "Convert", ".", "convert", "(", "optionValue", ",", "type", ")", ";", "}", "}", "}" ]
Sets the value of the option. @param optionValue the option value
[ "Sets", "the", "value", "of", "the", "option", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cli/NamedOption.java#L188-L221
145,523
flex-oss/flex-fruit
fruit-core/src/main/java/org/cdlflex/fruit/Range.java
Range.includes
public boolean includes(T value, boolean inclusive) { if (inclusive) { return value.compareTo(getStart()) >= 0 && value.compareTo(getEnd()) <= 0; } else { return value.compareTo(getStart()) > 0 && value.compareTo(getEnd()) < 0; } }
java
public boolean includes(T value, boolean inclusive) { if (inclusive) { return value.compareTo(getStart()) >= 0 && value.compareTo(getEnd()) <= 0; } else { return value.compareTo(getStart()) > 0 && value.compareTo(getEnd()) < 0; } }
[ "public", "boolean", "includes", "(", "T", "value", ",", "boolean", "inclusive", ")", "{", "if", "(", "inclusive", ")", "{", "return", "value", ".", "compareTo", "(", "getStart", "(", ")", ")", ">=", "0", "&&", "value", ".", "compareTo", "(", "getEnd", "(", ")", ")", "<=", "0", ";", "}", "else", "{", "return", "value", ".", "compareTo", "(", "getStart", "(", ")", ")", ">", "0", "&&", "value", ".", "compareTo", "(", "getEnd", "(", ")", ")", "<", "0", ";", "}", "}" ]
Checks whether the given value is included in this range. If inclusive is set to true, checking for 1 in the range of 1,10 will return true. @param value the value to check @param inclusive whether or not the range is open (the value is included) @return true if the value is inside this range, false otherwise
[ "Checks", "whether", "the", "given", "value", "is", "included", "in", "this", "range", ".", "If", "inclusive", "is", "set", "to", "true", "checking", "for", "1", "in", "the", "range", "of", "1", "10", "will", "return", "true", "." ]
30d7eca5ee796b829f96c9932a95b259ca9738d9
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-core/src/main/java/org/cdlflex/fruit/Range.java#L73-L80
145,524
fuinorg/utils4j
src/main/java/org/fuin/utils4j/fileprocessor/FileProcessor.java
FileProcessor.process
public final void process(final File file) { if (file == null) { throw new IllegalArgumentException("Argument 'file' cannot be NULL"); } if (file.isFile()) { handler.handleFile(file); } else { processDir(file); } }
java
public final void process(final File file) { if (file == null) { throw new IllegalArgumentException("Argument 'file' cannot be NULL"); } if (file.isFile()) { handler.handleFile(file); } else { processDir(file); } }
[ "public", "final", "void", "process", "(", "final", "File", "file", ")", "{", "if", "(", "file", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Argument 'file' cannot be NULL\"", ")", ";", "}", "if", "(", "file", ".", "isFile", "(", ")", ")", "{", "handler", ".", "handleFile", "(", "file", ")", ";", "}", "else", "{", "processDir", "(", "file", ")", ";", "}", "}" ]
Processes a file or directory. @param file File - Cannot be NULL.
[ "Processes", "a", "file", "or", "directory", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/fileprocessor/FileProcessor.java#L88-L97
145,525
fuinorg/utils4j
src/main/java/org/fuin/utils4j/filter/PropertyFilter.java
PropertyFilter.getProperty
protected final Object getProperty(final Object obj, final String property) { if ((obj == null) || (property == null) || (property.trim().length() == 0)) { return null; } final String[] getterNames = createGetterNames(property); for (int i = 0; i < getterNames.length; i++) { final String getter = getterNames[i]; try { final Class cl = obj.getClass(); final Method m = cl.getMethod(getter, new Class[] {}); return m.invoke(obj, new Object[] {}); } catch (final IllegalAccessException e) { throw new RuntimeException("Accessing " + getter + " method of property '" + property + "' failed (private? protected?)! [" + obj.getClass() + "]", e); } catch (final InvocationTargetException e) { throw new RuntimeException( "Exception within " + getter + " method of property '" + property + "'! [" + obj.getClass() + "]", e.getCause()); } catch (final NoSuchMethodException e) { if (i == getter.length() - 1) { throw new RuntimeException("No " + getter + " method found for property! '" + property + "'! [" + obj.getClass() + "]", e); } } } throw new IllegalStateException("No getters defined in 'createGetterNames()'!"); }
java
protected final Object getProperty(final Object obj, final String property) { if ((obj == null) || (property == null) || (property.trim().length() == 0)) { return null; } final String[] getterNames = createGetterNames(property); for (int i = 0; i < getterNames.length; i++) { final String getter = getterNames[i]; try { final Class cl = obj.getClass(); final Method m = cl.getMethod(getter, new Class[] {}); return m.invoke(obj, new Object[] {}); } catch (final IllegalAccessException e) { throw new RuntimeException("Accessing " + getter + " method of property '" + property + "' failed (private? protected?)! [" + obj.getClass() + "]", e); } catch (final InvocationTargetException e) { throw new RuntimeException( "Exception within " + getter + " method of property '" + property + "'! [" + obj.getClass() + "]", e.getCause()); } catch (final NoSuchMethodException e) { if (i == getter.length() - 1) { throw new RuntimeException("No " + getter + " method found for property! '" + property + "'! [" + obj.getClass() + "]", e); } } } throw new IllegalStateException("No getters defined in 'createGetterNames()'!"); }
[ "protected", "final", "Object", "getProperty", "(", "final", "Object", "obj", ",", "final", "String", "property", ")", "{", "if", "(", "(", "obj", "==", "null", ")", "||", "(", "property", "==", "null", ")", "||", "(", "property", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "null", ";", "}", "final", "String", "[", "]", "getterNames", "=", "createGetterNames", "(", "property", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getterNames", ".", "length", ";", "i", "++", ")", "{", "final", "String", "getter", "=", "getterNames", "[", "i", "]", ";", "try", "{", "final", "Class", "cl", "=", "obj", ".", "getClass", "(", ")", ";", "final", "Method", "m", "=", "cl", ".", "getMethod", "(", "getter", ",", "new", "Class", "[", "]", "{", "}", ")", ";", "return", "m", ".", "invoke", "(", "obj", ",", "new", "Object", "[", "]", "{", "}", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Accessing \"", "+", "getter", "+", "\" method of property '\"", "+", "property", "+", "\"' failed (private? protected?)! [\"", "+", "obj", ".", "getClass", "(", ")", "+", "\"]\"", ",", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Exception within \"", "+", "getter", "+", "\" method of property '\"", "+", "property", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", "+", "\"]\"", ",", "e", ".", "getCause", "(", ")", ")", ";", "}", "catch", "(", "final", "NoSuchMethodException", "e", ")", "{", "if", "(", "i", "==", "getter", ".", "length", "(", ")", "-", "1", ")", "{", "throw", "new", "RuntimeException", "(", "\"No \"", "+", "getter", "+", "\" method found for property! '\"", "+", "property", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", "+", "\"]\"", ",", "e", ")", ";", "}", "}", "}", "throw", "new", "IllegalStateException", "(", "\"No getters defined in 'createGetterNames()'!\"", ")", ";", "}" ]
Return the value of a property via reflection. @param obj Object to retrieve a value from. @param property Name of the property. @return Value returned via the getter of the property.
[ "Return", "the", "value", "of", "a", "property", "via", "reflection", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/filter/PropertyFilter.java#L71-L96
145,526
astrapi69/runtime-compiler
src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java
CompilerExtensions.generateCompilationStacktrace
public static String generateCompilationStacktrace( final DiagnosticCollector<JavaFileObject> diagnosticCollectors) { final StringBuilder sb = new StringBuilder(); for (final Diagnostic<? extends JavaFileObject> diagnostic : diagnosticCollectors .getDiagnostics()) { sb.append(diagnostic.getMessage(null)); sb.append(SeparatorConstants.SEMI_COLON_WHITE_SPACE); } return sb.toString(); }
java
public static String generateCompilationStacktrace( final DiagnosticCollector<JavaFileObject> diagnosticCollectors) { final StringBuilder sb = new StringBuilder(); for (final Diagnostic<? extends JavaFileObject> diagnostic : diagnosticCollectors .getDiagnostics()) { sb.append(diagnostic.getMessage(null)); sb.append(SeparatorConstants.SEMI_COLON_WHITE_SPACE); } return sb.toString(); }
[ "public", "static", "String", "generateCompilationStacktrace", "(", "final", "DiagnosticCollector", "<", "JavaFileObject", ">", "diagnosticCollectors", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "final", "Diagnostic", "<", "?", "extends", "JavaFileObject", ">", "diagnostic", ":", "diagnosticCollectors", ".", "getDiagnostics", "(", ")", ")", "{", "sb", ".", "append", "(", "diagnostic", ".", "getMessage", "(", "null", ")", ")", ";", "sb", ".", "append", "(", "SeparatorConstants", ".", "SEMI_COLON_WHITE_SPACE", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Generate a compilation stacktrace from the given parameter. @param diagnosticCollectors the diagnostic collectors @return the generated stacktrace string.
[ "Generate", "a", "compilation", "stacktrace", "from", "the", "given", "parameter", "." ]
9aed71f2940ddf30e6930de6cbf509206f3bd7de
https://github.com/astrapi69/runtime-compiler/blob/9aed71f2940ddf30e6930de6cbf509206f3bd7de/src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java#L50-L61
145,527
astrapi69/runtime-compiler
src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java
CompilerExtensions.getClassNameWithExtension
public static String getClassNameWithExtension(final String className) { return new StringBuilder().append(className).append(Kind.SOURCE.extension).toString(); }
java
public static String getClassNameWithExtension(final String className) { return new StringBuilder().append(className).append(Kind.SOURCE.extension).toString(); }
[ "public", "static", "String", "getClassNameWithExtension", "(", "final", "String", "className", ")", "{", "return", "new", "StringBuilder", "(", ")", ".", "append", "(", "className", ")", ".", "append", "(", "Kind", ".", "SOURCE", ".", "extension", ")", ".", "toString", "(", ")", ";", "}" ]
Gets the class name with java file extension. @param className the class name @return the class name with extension
[ "Gets", "the", "class", "name", "with", "java", "file", "extension", "." ]
9aed71f2940ddf30e6930de6cbf509206f3bd7de
https://github.com/astrapi69/runtime-compiler/blob/9aed71f2940ddf30e6930de6cbf509206f3bd7de/src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java#L70-L73
145,528
astrapi69/runtime-compiler
src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java
CompilerExtensions.newQualifiedClassName
public static String newQualifiedClassName(final String packageName, final String className) { if (StringUtils.isBlank(packageName)) { return className; } return new StringBuilder().append(packageName).append(SeparatorConstants.DOT) .append(className).toString(); }
java
public static String newQualifiedClassName(final String packageName, final String className) { if (StringUtils.isBlank(packageName)) { return className; } return new StringBuilder().append(packageName).append(SeparatorConstants.DOT) .append(className).toString(); }
[ "public", "static", "String", "newQualifiedClassName", "(", "final", "String", "packageName", ",", "final", "String", "className", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "packageName", ")", ")", "{", "return", "className", ";", "}", "return", "new", "StringBuilder", "(", ")", ".", "append", "(", "packageName", ")", ".", "append", "(", "SeparatorConstants", ".", "DOT", ")", ".", "append", "(", "className", ")", ".", "toString", "(", ")", ";", "}" ]
Factory method for create a qualified class name from the given arguments. @param packageName the package name @param className the class name @return the created qualified class name
[ "Factory", "method", "for", "create", "a", "qualified", "class", "name", "from", "the", "given", "arguments", "." ]
9aed71f2940ddf30e6930de6cbf509206f3bd7de
https://github.com/astrapi69/runtime-compiler/blob/9aed71f2940ddf30e6930de6cbf509206f3bd7de/src/main/java/de/alpharogroup/runtime/compiler/CompilerExtensions.java#L84-L92
145,529
fuinorg/utils4j
src/main/java/org/fuin/utils4j/WaitHelper.java
WaitHelper.waitUntilNoMoreException
public void waitUntilNoMoreException(final Runnable runnable, final List<Class<? extends Exception>> expectedExceptions) { final List<RuntimeException> actualExceptions = new ArrayList<>(); int tries = 0; while (tries < maxTries) { try { runnable.run(); return; } catch (final RuntimeException ex) { if (!Utils4J.expectedException(ex, expectedExceptions) && !Utils4J.expectedCause(ex, expectedExceptions)) { throw ex; } actualExceptions.add(ex); tries++; Utils4J.sleep(sleepMillis); } } throw new IllegalStateException("Waited too long for execution without exception. Expected exceptions: " + expectedExceptions + ", Actual exceptions: " + actualExceptions); }
java
public void waitUntilNoMoreException(final Runnable runnable, final List<Class<? extends Exception>> expectedExceptions) { final List<RuntimeException> actualExceptions = new ArrayList<>(); int tries = 0; while (tries < maxTries) { try { runnable.run(); return; } catch (final RuntimeException ex) { if (!Utils4J.expectedException(ex, expectedExceptions) && !Utils4J.expectedCause(ex, expectedExceptions)) { throw ex; } actualExceptions.add(ex); tries++; Utils4J.sleep(sleepMillis); } } throw new IllegalStateException("Waited too long for execution without exception. Expected exceptions: " + expectedExceptions + ", Actual exceptions: " + actualExceptions); }
[ "public", "void", "waitUntilNoMoreException", "(", "final", "Runnable", "runnable", ",", "final", "List", "<", "Class", "<", "?", "extends", "Exception", ">", ">", "expectedExceptions", ")", "{", "final", "List", "<", "RuntimeException", ">", "actualExceptions", "=", "new", "ArrayList", "<>", "(", ")", ";", "int", "tries", "=", "0", ";", "while", "(", "tries", "<", "maxTries", ")", "{", "try", "{", "runnable", ".", "run", "(", ")", ";", "return", ";", "}", "catch", "(", "final", "RuntimeException", "ex", ")", "{", "if", "(", "!", "Utils4J", ".", "expectedException", "(", "ex", ",", "expectedExceptions", ")", "&&", "!", "Utils4J", ".", "expectedCause", "(", "ex", ",", "expectedExceptions", ")", ")", "{", "throw", "ex", ";", "}", "actualExceptions", ".", "add", "(", "ex", ")", ";", "tries", "++", ";", "Utils4J", ".", "sleep", "(", "sleepMillis", ")", ";", "}", "}", "throw", "new", "IllegalStateException", "(", "\"Waited too long for execution without exception. Expected exceptions: \"", "+", "expectedExceptions", "+", "\", Actual exceptions: \"", "+", "actualExceptions", ")", ";", "}" ]
Wait until no more expected exception is thrown or the number of wait cycles has been exceeded. @param runnable Code to run. @param expectedExceptions List of expected exceptions.
[ "Wait", "until", "no", "more", "expected", "exception", "is", "thrown", "or", "the", "number", "of", "wait", "cycles", "has", "been", "exceeded", "." ]
71cf88e0a8d8ed67bbac513bf3cab165cd7e3280
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/WaitHelper.java#L55-L75
145,530
dbracewell/mango
src/main/java/com/davidbracewell/EnhancedDoubleStatistics.java
EnhancedDoubleStatistics.clear
public void clear() { this.min = Double.POSITIVE_INFINITY; this.max = Double.NEGATIVE_INFINITY; this.sum = 0; this.sumOfSq = 0; this.count = 0; }
java
public void clear() { this.min = Double.POSITIVE_INFINITY; this.max = Double.NEGATIVE_INFINITY; this.sum = 0; this.sumOfSq = 0; this.count = 0; }
[ "public", "void", "clear", "(", ")", "{", "this", ".", "min", "=", "Double", ".", "POSITIVE_INFINITY", ";", "this", ".", "max", "=", "Double", ".", "NEGATIVE_INFINITY", ";", "this", ".", "sum", "=", "0", ";", "this", ".", "sumOfSq", "=", "0", ";", "this", ".", "count", "=", "0", ";", "}" ]
Clears the accumulated values.
[ "Clears", "the", "accumulated", "values", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/EnhancedDoubleStatistics.java#L55-L61
145,531
dbracewell/mango
src/main/java/com/davidbracewell/EnhancedDoubleStatistics.java
EnhancedDoubleStatistics.getPopulationVariance
public double getPopulationVariance() { if (getCount() <= 0) { return Double.NaN; } else if (getCount() == 1) { return 0d; } return Math.abs(getSumOfSquares() - getAverage() * getSum()) / getCount(); }
java
public double getPopulationVariance() { if (getCount() <= 0) { return Double.NaN; } else if (getCount() == 1) { return 0d; } return Math.abs(getSumOfSquares() - getAverage() * getSum()) / getCount(); }
[ "public", "double", "getPopulationVariance", "(", ")", "{", "if", "(", "getCount", "(", ")", "<=", "0", ")", "{", "return", "Double", ".", "NaN", ";", "}", "else", "if", "(", "getCount", "(", ")", "==", "1", ")", "{", "return", "0d", ";", "}", "return", "Math", ".", "abs", "(", "getSumOfSquares", "(", ")", "-", "getAverage", "(", ")", "*", "getSum", "(", ")", ")", "/", "getCount", "(", ")", ";", "}" ]
Gets the population variance. @return the population variance
[ "Gets", "the", "population", "variance", "." ]
2cec08826f1fccd658694dd03abce10fc97618ec
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/EnhancedDoubleStatistics.java#L178-L185
145,532
febit/wit
wit-core/src/main/java/org/febit/wit/Engine.java
Engine.getTemplate
public Template getTemplate(final String parentName, final String name) throws ResourceNotFoundException { return getTemplate(this.loader.concat(parentName, name)); }
java
public Template getTemplate(final String parentName, final String name) throws ResourceNotFoundException { return getTemplate(this.loader.concat(parentName, name)); }
[ "public", "Template", "getTemplate", "(", "final", "String", "parentName", ",", "final", "String", "name", ")", "throws", "ResourceNotFoundException", "{", "return", "getTemplate", "(", "this", ".", "loader", ".", "concat", "(", "parentName", ",", "name", ")", ")", ";", "}" ]
get template by parent template's name and it's relative name. @param parentName parent template's name @param name template's relative name @return Template @throws ResourceNotFoundException if resource not found
[ "get", "template", "by", "parent", "template", "s", "name", "and", "it", "s", "relative", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Engine.java#L66-L68
145,533
febit/wit
wit-core/src/main/java/org/febit/wit/Engine.java
Engine.getTemplate
public Template getTemplate(final String name) throws ResourceNotFoundException { final Template template = this.cachedTemplates.get(name); if (template != null) { return template; } return createTemplateIfAbsent(name); }
java
public Template getTemplate(final String name) throws ResourceNotFoundException { final Template template = this.cachedTemplates.get(name); if (template != null) { return template; } return createTemplateIfAbsent(name); }
[ "public", "Template", "getTemplate", "(", "final", "String", "name", ")", "throws", "ResourceNotFoundException", "{", "final", "Template", "template", "=", "this", ".", "cachedTemplates", ".", "get", "(", "name", ")", ";", "if", "(", "template", "!=", "null", ")", "{", "return", "template", ";", "}", "return", "createTemplateIfAbsent", "(", "name", ")", ";", "}" ]
get template by name. @param name template's name @return Template @throws ResourceNotFoundException if resource not found
[ "get", "template", "by", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Engine.java#L77-L83
145,534
febit/wit
wit-core/src/main/java/org/febit/wit/Engine.java
Engine.exists
public boolean exists(final String resourceName) { final Loader myLoader = this.loader; final String normalizedName = myLoader.normalize(resourceName); if (normalizedName == null) { return false; } return myLoader.get(normalizedName).exists(); }
java
public boolean exists(final String resourceName) { final Loader myLoader = this.loader; final String normalizedName = myLoader.normalize(resourceName); if (normalizedName == null) { return false; } return myLoader.get(normalizedName).exists(); }
[ "public", "boolean", "exists", "(", "final", "String", "resourceName", ")", "{", "final", "Loader", "myLoader", "=", "this", ".", "loader", ";", "final", "String", "normalizedName", "=", "myLoader", ".", "normalize", "(", "resourceName", ")", ";", "if", "(", "normalizedName", "==", "null", ")", "{", "return", "false", ";", "}", "return", "myLoader", ".", "get", "(", "normalizedName", ")", ".", "exists", "(", ")", ";", "}" ]
if exists this resource. @param resourceName resource name @return if exists @since 1.4.1
[ "if", "exists", "this", "resource", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Engine.java#L92-L99
145,535
febit/wit
wit-core/src/main/java/org/febit/wit/Engine.java
Engine.create
public static Engine create(final String configPath, final Map<String, Object> parameters) { return create(createConfigProps(configPath), parameters); }
java
public static Engine create(final String configPath, final Map<String, Object> parameters) { return create(createConfigProps(configPath), parameters); }
[ "public", "static", "Engine", "create", "(", "final", "String", "configPath", ",", "final", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "return", "create", "(", "createConfigProps", "(", "configPath", ")", ",", "parameters", ")", ";", "}" ]
Create a Engine with given configPath and extra-parameters. @param configPath config path @param parameters parameters map @return Engine @since 1.5.0
[ "Create", "a", "Engine", "with", "given", "configPath", "and", "extra", "-", "parameters", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Engine.java#L237-L239
145,536
febit/wit
wit-core/src/main/java/org/febit/wit/Engine.java
Engine.create
public static Engine create(final Props props, final Map<String, Object> parameters) { final Petite petite = new Petite(); petite.config(props, parameters); petite.initComponents(); final Engine engine = petite.get(Engine.class); engine.getLogger().info("Loaded props: {}", props.getModulesString()); try { engine.executeInits(); } catch (ResourceNotFoundException ex) { throw new IllegalConfigException("engine.inits", ex); } return engine; }
java
public static Engine create(final Props props, final Map<String, Object> parameters) { final Petite petite = new Petite(); petite.config(props, parameters); petite.initComponents(); final Engine engine = petite.get(Engine.class); engine.getLogger().info("Loaded props: {}", props.getModulesString()); try { engine.executeInits(); } catch (ResourceNotFoundException ex) { throw new IllegalConfigException("engine.inits", ex); } return engine; }
[ "public", "static", "Engine", "create", "(", "final", "Props", "props", ",", "final", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "final", "Petite", "petite", "=", "new", "Petite", "(", ")", ";", "petite", ".", "config", "(", "props", ",", "parameters", ")", ";", "petite", ".", "initComponents", "(", ")", ";", "final", "Engine", "engine", "=", "petite", ".", "get", "(", "Engine", ".", "class", ")", ";", "engine", ".", "getLogger", "(", ")", ".", "info", "(", "\"Loaded props: {}\"", ",", "props", ".", "getModulesString", "(", ")", ")", ";", "try", "{", "engine", ".", "executeInits", "(", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "ex", ")", "{", "throw", "new", "IllegalConfigException", "(", "\"engine.inits\"", ",", "ex", ")", ";", "}", "return", "engine", ";", "}" ]
Create a Engine with given baseProps and extra-parameters. @param props props @param parameters parameters map @return Engine @since 1.5.0
[ "Create", "a", "Engine", "with", "given", "baseProps", "and", "extra", "-", "parameters", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Engine.java#L249-L262
145,537
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/core/QueryExecutor.java
QueryExecutor.run
@SuppressWarnings("unchecked") public static Sequence run(Query query, QueryableIndex index) { return findFactory(query).createRunner(new QueryableIndexSegment("", index)).run(query, null); }
java
@SuppressWarnings("unchecked") public static Sequence run(Query query, QueryableIndex index) { return findFactory(query).createRunner(new QueryableIndexSegment("", index)).run(query, null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Sequence", "run", "(", "Query", "query", ",", "QueryableIndex", "index", ")", "{", "return", "findFactory", "(", "query", ")", ".", "createRunner", "(", "new", "QueryableIndexSegment", "(", "\"\"", ",", "index", ")", ")", ".", "run", "(", "query", ",", "null", ")", ";", "}" ]
Executes a Query by identifying the appropriate QueryRunner @param query Query to execute @param index Index to execute query on @return Result of the query
[ "Executes", "a", "Query", "by", "identifying", "the", "appropriate", "QueryRunner" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/core/QueryExecutor.java#L186-L189
145,538
politie/cinch
src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchContext.java
StreamingCinchContext.executeJob
public void executeJob() { AbstractApplicationContext springContext = SpringContext.getContext(getSpringConfigurationClass()); StreamingCinchJob cinchJob = springContext.getBean(StreamingCinchJob.class); cinchJob.execute(this); }
java
public void executeJob() { AbstractApplicationContext springContext = SpringContext.getContext(getSpringConfigurationClass()); StreamingCinchJob cinchJob = springContext.getBean(StreamingCinchJob.class); cinchJob.execute(this); }
[ "public", "void", "executeJob", "(", ")", "{", "AbstractApplicationContext", "springContext", "=", "SpringContext", ".", "getContext", "(", "getSpringConfigurationClass", "(", ")", ")", ";", "StreamingCinchJob", "cinchJob", "=", "springContext", ".", "getBean", "(", "StreamingCinchJob", ".", "class", ")", ";", "cinchJob", ".", "execute", "(", "this", ")", ";", "}" ]
Executes your streaming job from the spring context.
[ "Executes", "your", "streaming", "job", "from", "the", "spring", "context", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchContext.java#L27-L32
145,539
politie/cinch
src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchContext.java
StreamingCinchContext.foreachRddFunction
public <T> ForeachRddFunction<T> foreachRddFunction(Class<? extends VoidFunction<T>> springBeanClass) { return new ForeachRddFunction<>(voidFunction(springBeanClass)); }
java
public <T> ForeachRddFunction<T> foreachRddFunction(Class<? extends VoidFunction<T>> springBeanClass) { return new ForeachRddFunction<>(voidFunction(springBeanClass)); }
[ "public", "<", "T", ">", "ForeachRddFunction", "<", "T", ">", "foreachRddFunction", "(", "Class", "<", "?", "extends", "VoidFunction", "<", "T", ">", ">", "springBeanClass", ")", "{", "return", "new", "ForeachRddFunction", "<>", "(", "voidFunction", "(", "springBeanClass", ")", ")", ";", "}" ]
Create a new ForeachRddFunction, which implements Spark's VoidFunction interface.
[ "Create", "a", "new", "ForeachRddFunction", "which", "implements", "Spark", "s", "VoidFunction", "interface", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchContext.java#L37-L39
145,540
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/MethodWriter.java
MethodWriter.renderTo
final void renderTo(final ByteBuffer out) { final ByteBuffer code = this.code; out.putShort(access).putShort(name).putShort(desc); int attributeCount = 0; if (code.length > 0) { ++attributeCount; } int exceptionCount = exceptions.length; if (exceptionCount > 0) { ++attributeCount; } // if ((access & Constants.ACC_SYNTHETIC) != 0) { // ++attributeCount; // } // if ((access & Constants.ACC_DEPRECATED) != 0) { // ++attributeCount; // } out.putShort(attributeCount); if (code.length > 0) { int size = 12 + code.length + 8 * catchCount; if (localVar != null) { size += 8 + localVar.length; } out.putShort(cw.newUTF8("Code")).putInt(size) .putShort(maxStack).putShort(maxLocals) .putInt(code.length).put(code) .putShort(catchCount); if (catchCount > 0) { out.put(catchTable); } attributeCount = 0; if (localVar != null) { ++attributeCount; } out.putShort(attributeCount); if (localVar != null) { out.putShort(cw.newUTF8("LocalVariableTable")) .putInt(localVar.length + 2).putShort(localVarCount) .put(localVar); } } if (exceptionCount > 0) { out.putShort(cw.newUTF8("Exceptions")).putInt(2 * exceptionCount + 2) .putShort(exceptionCount); for (int i = 0; i < exceptionCount; ++i) { out.putShort(exceptions[i]); } } // if ((access & Constants.ACC_SYNTHETIC) != 0) { // out.putShort(cw.newUTF8("Synthetic")).putInt(0); // } // if ((access & Constants.ACC_DEPRECATED) != 0) { // out.putShort(cw.newUTF8("Deprecated")).putInt(0); // } }
java
final void renderTo(final ByteBuffer out) { final ByteBuffer code = this.code; out.putShort(access).putShort(name).putShort(desc); int attributeCount = 0; if (code.length > 0) { ++attributeCount; } int exceptionCount = exceptions.length; if (exceptionCount > 0) { ++attributeCount; } // if ((access & Constants.ACC_SYNTHETIC) != 0) { // ++attributeCount; // } // if ((access & Constants.ACC_DEPRECATED) != 0) { // ++attributeCount; // } out.putShort(attributeCount); if (code.length > 0) { int size = 12 + code.length + 8 * catchCount; if (localVar != null) { size += 8 + localVar.length; } out.putShort(cw.newUTF8("Code")).putInt(size) .putShort(maxStack).putShort(maxLocals) .putInt(code.length).put(code) .putShort(catchCount); if (catchCount > 0) { out.put(catchTable); } attributeCount = 0; if (localVar != null) { ++attributeCount; } out.putShort(attributeCount); if (localVar != null) { out.putShort(cw.newUTF8("LocalVariableTable")) .putInt(localVar.length + 2).putShort(localVarCount) .put(localVar); } } if (exceptionCount > 0) { out.putShort(cw.newUTF8("Exceptions")).putInt(2 * exceptionCount + 2) .putShort(exceptionCount); for (int i = 0; i < exceptionCount; ++i) { out.putShort(exceptions[i]); } } // if ((access & Constants.ACC_SYNTHETIC) != 0) { // out.putShort(cw.newUTF8("Synthetic")).putInt(0); // } // if ((access & Constants.ACC_DEPRECATED) != 0) { // out.putShort(cw.newUTF8("Deprecated")).putInt(0); // } }
[ "final", "void", "renderTo", "(", "final", "ByteBuffer", "out", ")", "{", "final", "ByteBuffer", "code", "=", "this", ".", "code", ";", "out", ".", "putShort", "(", "access", ")", ".", "putShort", "(", "name", ")", ".", "putShort", "(", "desc", ")", ";", "int", "attributeCount", "=", "0", ";", "if", "(", "code", ".", "length", ">", "0", ")", "{", "++", "attributeCount", ";", "}", "int", "exceptionCount", "=", "exceptions", ".", "length", ";", "if", "(", "exceptionCount", ">", "0", ")", "{", "++", "attributeCount", ";", "}", "// if ((access & Constants.ACC_SYNTHETIC) != 0) {", "// ++attributeCount;", "// }", "// if ((access & Constants.ACC_DEPRECATED) != 0) {", "// ++attributeCount;", "// }", "out", ".", "putShort", "(", "attributeCount", ")", ";", "if", "(", "code", ".", "length", ">", "0", ")", "{", "int", "size", "=", "12", "+", "code", ".", "length", "+", "8", "*", "catchCount", ";", "if", "(", "localVar", "!=", "null", ")", "{", "size", "+=", "8", "+", "localVar", ".", "length", ";", "}", "out", ".", "putShort", "(", "cw", ".", "newUTF8", "(", "\"Code\"", ")", ")", ".", "putInt", "(", "size", ")", ".", "putShort", "(", "maxStack", ")", ".", "putShort", "(", "maxLocals", ")", ".", "putInt", "(", "code", ".", "length", ")", ".", "put", "(", "code", ")", ".", "putShort", "(", "catchCount", ")", ";", "if", "(", "catchCount", ">", "0", ")", "{", "out", ".", "put", "(", "catchTable", ")", ";", "}", "attributeCount", "=", "0", ";", "if", "(", "localVar", "!=", "null", ")", "{", "++", "attributeCount", ";", "}", "out", ".", "putShort", "(", "attributeCount", ")", ";", "if", "(", "localVar", "!=", "null", ")", "{", "out", ".", "putShort", "(", "cw", ".", "newUTF8", "(", "\"LocalVariableTable\"", ")", ")", ".", "putInt", "(", "localVar", ".", "length", "+", "2", ")", ".", "putShort", "(", "localVarCount", ")", ".", "put", "(", "localVar", ")", ";", "}", "}", "if", "(", "exceptionCount", ">", "0", ")", "{", "out", ".", "putShort", "(", "cw", ".", "newUTF8", "(", "\"Exceptions\"", ")", ")", ".", "putInt", "(", "2", "*", "exceptionCount", "+", "2", ")", ".", "putShort", "(", "exceptionCount", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "exceptionCount", ";", "++", "i", ")", "{", "out", ".", "putShort", "(", "exceptions", "[", "i", "]", ")", ";", "}", "}", "// if ((access & Constants.ACC_SYNTHETIC) != 0) {", "// out.putShort(cw.newUTF8(\"Synthetic\")).putInt(0);", "// }", "// if ((access & Constants.ACC_DEPRECATED) != 0) {", "// out.putShort(cw.newUTF8(\"Deprecated\")).putInt(0);", "// }", "}" ]
Puts the bytecode of this method in the given byte vector. @param out the byte vector into which the bytecode of this method must be copied.
[ "Puts", "the", "bytecode", "of", "this", "method", "in", "the", "given", "byte", "vector", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/MethodWriter.java#L1023-L1077
145,541
javabits/pojo-mbean
pojo-mbean-impl/src/main/java/org/softee/util/Preconditions.java
Preconditions.notNull
public static <E> E notNull(E obj, String msg) { if (obj == null) { throw (msg == null) ? new NullPointerException() : new NullPointerException(msg); } return obj; }
java
public static <E> E notNull(E obj, String msg) { if (obj == null) { throw (msg == null) ? new NullPointerException() : new NullPointerException(msg); } return obj; }
[ "public", "static", "<", "E", ">", "E", "notNull", "(", "E", "obj", ",", "String", "msg", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "throw", "(", "msg", "==", "null", ")", "?", "new", "NullPointerException", "(", ")", ":", "new", "NullPointerException", "(", "msg", ")", ";", "}", "return", "obj", ";", "}" ]
An assertion method that makes null validation more fluent @param <E> The type of elements @param obj an Object @param msg a message that is reported in the exception @return {@code obj} @throws NullPointerException if {@code obj} is null
[ "An", "assertion", "method", "that", "makes", "null", "validation", "more", "fluent" ]
9aa7fb065e560ec1e3e63373b28cd95ad438b26a
https://github.com/javabits/pojo-mbean/blob/9aa7fb065e560ec1e3e63373b28cd95ad438b26a/pojo-mbean-impl/src/main/java/org/softee/util/Preconditions.java#L27-L32
145,542
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/loader/Loader.java
Loader.csv
public static Loader csv(Reader reader, List<String> columns, List<String> dimensions, String timestampDimension) { return new CSVLoader(reader, columns, dimensions, timestampDimension); }
java
public static Loader csv(Reader reader, List<String> columns, List<String> dimensions, String timestampDimension) { return new CSVLoader(reader, columns, dimensions, timestampDimension); }
[ "public", "static", "Loader", "csv", "(", "Reader", "reader", ",", "List", "<", "String", ">", "columns", ",", "List", "<", "String", ">", "dimensions", ",", "String", "timestampDimension", ")", "{", "return", "new", "CSVLoader", "(", "reader", ",", "columns", ",", "dimensions", ",", "timestampDimension", ")", ";", "}" ]
CSVLoader implementation of the Loader @param reader A Reader opened to the CSV file @param columns List of columns in the CSV @param dimensions List of dimensions to index @param timestampDimension Timestamp dimension @return A new CSVLoader to the CSV file specified by the reader
[ "CSVLoader", "implementation", "of", "the", "Loader" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/loader/Loader.java#L38-L40
145,543
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java
ClassWriter.newInteger
private Item newInteger(final int value) { Item result = get(key.set(INT, value)); if (result == null) { pool.putByte(INT).putInt(value); result = new Item(poolIndex++, key); put(result); } return result; }
java
private Item newInteger(final int value) { Item result = get(key.set(INT, value)); if (result == null) { pool.putByte(INT).putInt(value); result = new Item(poolIndex++, key); put(result); } return result; }
[ "private", "Item", "newInteger", "(", "final", "int", "value", ")", "{", "Item", "result", "=", "get", "(", "key", ".", "set", "(", "INT", ",", "value", ")", ")", ";", "if", "(", "result", "==", "null", ")", "{", "pool", ".", "putByte", "(", "INT", ")", ".", "putInt", "(", "value", ")", ";", "result", "=", "new", "Item", "(", "poolIndex", "++", ",", "key", ")", ";", "put", "(", "result", ")", ";", "}", "return", "result", ";", "}" ]
Adds an integer to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. @param value the int value. @return a new or already existing int item.
[ "Adds", "an", "integer", "to", "the", "constant", "pool", "of", "the", "class", "being", "build", ".", "Does", "nothing", "if", "the", "constant", "pool", "already", "contains", "a", "similar", "item", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L614-L622
145,544
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java
ClassWriter.newFloat
private Item newFloat(final float value) { Item result = get(key.set(FLOAT, value)); if (result == null) { pool.putByte(FLOAT).putInt(Float.floatToIntBits(value)); result = new Item(poolIndex++, key); put(result); } return result; }
java
private Item newFloat(final float value) { Item result = get(key.set(FLOAT, value)); if (result == null) { pool.putByte(FLOAT).putInt(Float.floatToIntBits(value)); result = new Item(poolIndex++, key); put(result); } return result; }
[ "private", "Item", "newFloat", "(", "final", "float", "value", ")", "{", "Item", "result", "=", "get", "(", "key", ".", "set", "(", "FLOAT", ",", "value", ")", ")", ";", "if", "(", "result", "==", "null", ")", "{", "pool", ".", "putByte", "(", "FLOAT", ")", ".", "putInt", "(", "Float", ".", "floatToIntBits", "(", "value", ")", ")", ";", "result", "=", "new", "Item", "(", "poolIndex", "++", ",", "key", ")", ";", "put", "(", "result", ")", ";", "}", "return", "result", ";", "}" ]
Adds a float to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. @param value the float value. @return a new or already existing float item.
[ "Adds", "a", "float", "to", "the", "constant", "pool", "of", "the", "class", "being", "build", ".", "Does", "nothing", "if", "the", "constant", "pool", "already", "contains", "a", "similar", "item", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L631-L639
145,545
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java
ClassWriter.newLong
private Item newLong(final long value) { Item result = get(key.set(LONG, value)); if (result == null) { pool.putByte(LONG).putLong(value); result = new Item(poolIndex, key); put(result); poolIndex += 2; } return result; }
java
private Item newLong(final long value) { Item result = get(key.set(LONG, value)); if (result == null) { pool.putByte(LONG).putLong(value); result = new Item(poolIndex, key); put(result); poolIndex += 2; } return result; }
[ "private", "Item", "newLong", "(", "final", "long", "value", ")", "{", "Item", "result", "=", "get", "(", "key", ".", "set", "(", "LONG", ",", "value", ")", ")", ";", "if", "(", "result", "==", "null", ")", "{", "pool", ".", "putByte", "(", "LONG", ")", ".", "putLong", "(", "value", ")", ";", "result", "=", "new", "Item", "(", "poolIndex", ",", "key", ")", ";", "put", "(", "result", ")", ";", "poolIndex", "+=", "2", ";", "}", "return", "result", ";", "}" ]
Adds a long to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. @param value the long value. @return a new or already existing long item.
[ "Adds", "a", "long", "to", "the", "constant", "pool", "of", "the", "class", "being", "build", ".", "Does", "nothing", "if", "the", "constant", "pool", "already", "contains", "a", "similar", "item", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L648-L657
145,546
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java
ClassWriter.newString
private Item newString(final String value) { Item result = get(key2.set(STR, value, null, null)); if (result == null) { pool.putBS(STR, newUTF8(value)); result = new Item(poolIndex++, key2); put(result); } return result; }
java
private Item newString(final String value) { Item result = get(key2.set(STR, value, null, null)); if (result == null) { pool.putBS(STR, newUTF8(value)); result = new Item(poolIndex++, key2); put(result); } return result; }
[ "private", "Item", "newString", "(", "final", "String", "value", ")", "{", "Item", "result", "=", "get", "(", "key2", ".", "set", "(", "STR", ",", "value", ",", "null", ",", "null", ")", ")", ";", "if", "(", "result", "==", "null", ")", "{", "pool", ".", "putBS", "(", "STR", ",", "newUTF8", "(", "value", ")", ")", ";", "result", "=", "new", "Item", "(", "poolIndex", "++", ",", "key2", ")", ";", "put", "(", "result", ")", ";", "}", "return", "result", ";", "}" ]
Adds a string to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. @param value the String value. @return a new or already existing string item.
[ "Adds", "a", "string", "to", "the", "constant", "pool", "of", "the", "class", "being", "build", ".", "Does", "nothing", "if", "the", "constant", "pool", "already", "contains", "a", "similar", "item", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L684-L692
145,547
febit/wit
wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java
ClassWriter.put122
private void put122(final int b, final int s1, final int s2) { pool.putBS(b, s1).putShort(s2); }
java
private void put122(final int b, final int s1, final int s2) { pool.putBS(b, s1).putShort(s2); }
[ "private", "void", "put122", "(", "final", "int", "b", ",", "final", "int", "s1", ",", "final", "int", "s2", ")", "{", "pool", ".", "putBS", "(", "b", ",", "s1", ")", ".", "putShort", "(", "s2", ")", ";", "}" ]
Puts one byte and two shorts into the constant pool. @param b a byte. @param s1 a short. @param s2 another short.
[ "Puts", "one", "byte", "and", "two", "shorts", "into", "the", "constant", "pool", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L741-L743
145,548
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/util/Utils.java
Utils.readFile
public static ByteBuffer readFile(File inFile) throws IOException { ByteBuffer mBuf; try (FileInputStream fIn = new FileInputStream(inFile); FileChannel fChan = fIn.getChannel()) { long fSize = fChan.size(); mBuf = ByteBuffer.allocate((int) fSize); fChan.read(mBuf); mBuf.rewind(); } return mBuf; }
java
public static ByteBuffer readFile(File inFile) throws IOException { ByteBuffer mBuf; try (FileInputStream fIn = new FileInputStream(inFile); FileChannel fChan = fIn.getChannel()) { long fSize = fChan.size(); mBuf = ByteBuffer.allocate((int) fSize); fChan.read(mBuf); mBuf.rewind(); } return mBuf; }
[ "public", "static", "ByteBuffer", "readFile", "(", "File", "inFile", ")", "throws", "IOException", "{", "ByteBuffer", "mBuf", ";", "try", "(", "FileInputStream", "fIn", "=", "new", "FileInputStream", "(", "inFile", ")", ";", "FileChannel", "fChan", "=", "fIn", ".", "getChannel", "(", ")", ")", "{", "long", "fSize", "=", "fChan", ".", "size", "(", ")", ";", "mBuf", "=", "ByteBuffer", ".", "allocate", "(", "(", "int", ")", "fSize", ")", ";", "fChan", ".", "read", "(", "mBuf", ")", ";", "mBuf", ".", "rewind", "(", ")", ";", "}", "return", "mBuf", ";", "}" ]
Helper method to read a file into a ByteBuffer @param inFile File to read from @return ByteBuffer containing the contents of the file @throws IOException Thrown if there was a problem reading the file
[ "Helper", "method", "to", "read", "a", "file", "into", "a", "ByteBuffer" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/util/Utils.java#L69-L79
145,549
OSSIndex/java-api
src/main/java/net/ossindex/common/filter/VulnerabilityFilterFactory.java
VulnerabilityFilterFactory.shouldFilter
public static boolean shouldFilter(final IVulnerabilityFilter filter, final List<PackageCoordinate> path, final String vid) { return ((VulnerabilityFilterImpl)filter).shouldFilter(path, vid); }
java
public static boolean shouldFilter(final IVulnerabilityFilter filter, final List<PackageCoordinate> path, final String vid) { return ((VulnerabilityFilterImpl)filter).shouldFilter(path, vid); }
[ "public", "static", "boolean", "shouldFilter", "(", "final", "IVulnerabilityFilter", "filter", ",", "final", "List", "<", "PackageCoordinate", ">", "path", ",", "final", "String", "vid", ")", "{", "return", "(", "(", "VulnerabilityFilterImpl", ")", "filter", ")", ".", "shouldFilter", "(", "path", ",", "vid", ")", ";", "}" ]
Kind of filthy this being here. It is in lieu of making a separate utility class for now. It allows us to run the filter without exposing private functionality to the users.
[ "Kind", "of", "filthy", "this", "being", "here", ".", "It", "is", "in", "lieu", "of", "making", "a", "separate", "utility", "class", "for", "now", ".", "It", "allows", "us", "to", "run", "the", "filter", "without", "exposing", "private", "functionality", "to", "the", "users", "." ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/filter/VulnerabilityFilterFactory.java#L29-L33
145,550
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.postTaskSuccess
public static void postTaskSuccess(final TaskCompletionListener completionListener) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(); } } }); }
java
public static void postTaskSuccess(final TaskCompletionListener completionListener) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(); } } }); }
[ "public", "static", "void", "postTaskSuccess", "(", "final", "TaskCompletionListener", "completionListener", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onSuccess", "(", ")", ";", "}", "}", "}", ")", ";", "}" ]
A helper function to post success to a TaskCompletionListener on the UI thread @param completionListener The TaskCompletionListener to notify
[ "A", "helper", "function", "to", "post", "success", "to", "a", "TaskCompletionListener", "on", "the", "UI", "thread" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L63-L72
145,551
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.postTaskError
public static void postTaskError(final TaskCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
java
public static void postTaskError(final TaskCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
[ "public", "static", "void", "postTaskError", "(", "final", "TaskCompletionListener", "completionListener", ",", "final", "String", "errorMessage", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onError", "(", "errorMessage", ")", ";", "}", "}", "}", ")", ";", "}" ]
A helper function to post an error message to a TaskCompletionListener on the UI thread @param completionListener The TaskCompletionListener to notify @param errorMessage The error message to post
[ "A", "helper", "function", "to", "post", "an", "error", "message", "to", "a", "TaskCompletionListener", "on", "the", "UI", "thread" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L81-L90
145,552
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.makeGUID
public static String makeGUID() { String uuid = ""; String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int rnd = 0; int r; for (int i = 0; i < GUID_STRING_LENGTH; i += 1) { if (i == 8 || i == 13 || i == 18 || i == 23) { uuid = uuid + "-"; } else if (i == 14) { uuid = uuid + "4"; } else { if (rnd <= 0x02) { rnd = (int) (0x2000000 + Math.round(java.lang.Math.random() * 0x1000000)); } r = rnd & 0xf; rnd = rnd >> 4; if (i == 19) { uuid = uuid + chars.charAt((r & 0x3) | 0x8); } else { uuid = uuid + chars.charAt(r); } } } return uuid; }
java
public static String makeGUID() { String uuid = ""; String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int rnd = 0; int r; for (int i = 0; i < GUID_STRING_LENGTH; i += 1) { if (i == 8 || i == 13 || i == 18 || i == 23) { uuid = uuid + "-"; } else if (i == 14) { uuid = uuid + "4"; } else { if (rnd <= 0x02) { rnd = (int) (0x2000000 + Math.round(java.lang.Math.random() * 0x1000000)); } r = rnd & 0xf; rnd = rnd >> 4; if (i == 19) { uuid = uuid + chars.charAt((r & 0x3) | 0x8); } else { uuid = uuid + chars.charAt(r); } } } return uuid; }
[ "public", "static", "String", "makeGUID", "(", ")", "{", "String", "uuid", "=", "\"\"", ";", "String", "chars", "=", "\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"", ";", "int", "rnd", "=", "0", ";", "int", "r", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "GUID_STRING_LENGTH", ";", "i", "+=", "1", ")", "{", "if", "(", "i", "==", "8", "||", "i", "==", "13", "||", "i", "==", "18", "||", "i", "==", "23", ")", "{", "uuid", "=", "uuid", "+", "\"-\"", ";", "}", "else", "if", "(", "i", "==", "14", ")", "{", "uuid", "=", "uuid", "+", "\"4\"", ";", "}", "else", "{", "if", "(", "rnd", "<=", "0x02", ")", "{", "rnd", "=", "(", "int", ")", "(", "0x2000000", "+", "Math", ".", "round", "(", "java", ".", "lang", ".", "Math", ".", "random", "(", ")", "*", "0x1000000", ")", ")", ";", "}", "r", "=", "rnd", "&", "0xf", ";", "rnd", "=", "rnd", ">>", "4", ";", "if", "(", "i", "==", "19", ")", "{", "uuid", "=", "uuid", "+", "chars", ".", "charAt", "(", "(", "r", "&", "0x3", ")", "|", "0x8", ")", ";", "}", "else", "{", "uuid", "=", "uuid", "+", "chars", ".", "charAt", "(", "r", ")", ";", "}", "}", "}", "return", "uuid", ";", "}" ]
Create a globally unique identifier for naming instances @return New globally unique identifier
[ "Create", "a", "globally", "unique", "identifier", "for", "naming", "instances" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L153-L179
145,553
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.unregisterPushServices
public void unregisterPushServices(TaskCompletionListener completionListener) { RespokeClient activeInstance = null; // If there are already client instances running, check if any of them have already connected for (RespokeClient eachInstance : instances) { if (eachInstance.isConnected()) { // The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one) activeInstance = eachInstance; break; } } if (null != activeInstance) { activeInstance.unregisterFromPushServices(completionListener); } else { postTaskError(completionListener, "There is no active client to unregister"); } }
java
public void unregisterPushServices(TaskCompletionListener completionListener) { RespokeClient activeInstance = null; // If there are already client instances running, check if any of them have already connected for (RespokeClient eachInstance : instances) { if (eachInstance.isConnected()) { // The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one) activeInstance = eachInstance; break; } } if (null != activeInstance) { activeInstance.unregisterFromPushServices(completionListener); } else { postTaskError(completionListener, "There is no active client to unregister"); } }
[ "public", "void", "unregisterPushServices", "(", "TaskCompletionListener", "completionListener", ")", "{", "RespokeClient", "activeInstance", "=", "null", ";", "// If there are already client instances running, check if any of them have already connected", "for", "(", "RespokeClient", "eachInstance", ":", "instances", ")", "{", "if", "(", "eachInstance", ".", "isConnected", "(", ")", ")", "{", "// The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one)", "activeInstance", "=", "eachInstance", ";", "break", ";", "}", "}", "if", "(", "null", "!=", "activeInstance", ")", "{", "activeInstance", ".", "unregisterFromPushServices", "(", "completionListener", ")", ";", "}", "else", "{", "postTaskError", "(", "completionListener", ",", "\"There is no active client to unregister\"", ")", ";", "}", "}" ]
Unregister this device from the Respoke push notification service and stop any future notifications until it is re-registered @param completionListener A listener to be notified of the success of the asynchronous unregistration operation
[ "Unregister", "this", "device", "from", "the", "Respoke", "push", "notification", "service", "and", "stop", "any", "future", "notifications", "until", "it", "is", "re", "-", "registered" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L201-L218
145,554
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.clientConnected
public void clientConnected(RespokeClient client) { if (null != pushToken) { registerPushServices(); } if (!factoryStaticInitialized) { // Perform a one-time WebRTC global initialization PeerConnectionFactory.initializeAndroidGlobals(context, true, true, true, VideoRendererGui.getEGLContext()); factoryStaticInitialized = true; } }
java
public void clientConnected(RespokeClient client) { if (null != pushToken) { registerPushServices(); } if (!factoryStaticInitialized) { // Perform a one-time WebRTC global initialization PeerConnectionFactory.initializeAndroidGlobals(context, true, true, true, VideoRendererGui.getEGLContext()); factoryStaticInitialized = true; } }
[ "public", "void", "clientConnected", "(", "RespokeClient", "client", ")", "{", "if", "(", "null", "!=", "pushToken", ")", "{", "registerPushServices", "(", ")", ";", "}", "if", "(", "!", "factoryStaticInitialized", ")", "{", "// Perform a one-time WebRTC global initialization", "PeerConnectionFactory", ".", "initializeAndroidGlobals", "(", "context", ",", "true", ",", "true", ",", "true", ",", "VideoRendererGui", ".", "getEGLContext", "(", ")", ")", ";", "factoryStaticInitialized", "=", "true", ";", "}", "}" ]
Notify the shared SDK instance that the specified client has connected. This is for internal use only, and should never be called by your client application. @param client The client that just connected
[ "Notify", "the", "shared", "SDK", "instance", "that", "the", "specified", "client", "has", "connected", ".", "This", "is", "for", "internal", "use", "only", "and", "should", "never", "be", "called", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L226-L236
145,555
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java
Respoke.registerPushServices
private void registerPushServices() { RespokeClient activeInstance = null; // If there are already client instances running, check if any of them have already connected for (RespokeClient eachInstance : instances) { if (eachInstance.isConnected()) { // The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one) activeInstance = eachInstance; } } if (null != activeInstance) { // Notify the Respoke servers that this device is eligible to receive notifications directed at this endpointID activeInstance.registerPushServicesWithToken(pushToken); } }
java
private void registerPushServices() { RespokeClient activeInstance = null; // If there are already client instances running, check if any of them have already connected for (RespokeClient eachInstance : instances) { if (eachInstance.isConnected()) { // The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one) activeInstance = eachInstance; } } if (null != activeInstance) { // Notify the Respoke servers that this device is eligible to receive notifications directed at this endpointID activeInstance.registerPushServicesWithToken(pushToken); } }
[ "private", "void", "registerPushServices", "(", ")", "{", "RespokeClient", "activeInstance", "=", "null", ";", "// If there are already client instances running, check if any of them have already connected", "for", "(", "RespokeClient", "eachInstance", ":", "instances", ")", "{", "if", "(", "eachInstance", ".", "isConnected", "(", ")", ")", "{", "// The push service only supports one endpoint per device, so the token only needs to be registered for the first active client (if there is more than one)", "activeInstance", "=", "eachInstance", ";", "}", "}", "if", "(", "null", "!=", "activeInstance", ")", "{", "// Notify the Respoke servers that this device is eligible to receive notifications directed at this endpointID", "activeInstance", ".", "registerPushServicesWithToken", "(", "pushToken", ")", ";", "}", "}" ]
Attempt to register push services for this device
[ "Attempt", "to", "register", "push", "services", "for", "this", "device" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/Respoke.java#L245-L260
145,556
jenkinsci/lib-jira-api
src/main/java/org/jenkinsci/jira/JIRA.java
JIRA.connect
public static JiraRestClient connect(URL jiraUrl, String username, String password) throws IOException { return new AsynchronousJiraRestClientFactory() .createWithBasicHttpAuthentication(URI.create(jiraUrl.toExternalForm()), username, password); }
java
public static JiraRestClient connect(URL jiraUrl, String username, String password) throws IOException { return new AsynchronousJiraRestClientFactory() .createWithBasicHttpAuthentication(URI.create(jiraUrl.toExternalForm()), username, password); }
[ "public", "static", "JiraRestClient", "connect", "(", "URL", "jiraUrl", ",", "String", "username", ",", "String", "password", ")", "throws", "IOException", "{", "return", "new", "AsynchronousJiraRestClientFactory", "(", ")", ".", "createWithBasicHttpAuthentication", "(", "URI", ".", "create", "(", "jiraUrl", ".", "toExternalForm", "(", ")", ")", ",", "username", ",", "password", ")", ";", "}" ]
Connects to the JIRA server.
[ "Connects", "to", "the", "JIRA", "server", "." ]
a52ce9138ed16ba162513762dcfd3da5d543cd7f
https://github.com/jenkinsci/lib-jira-api/blob/a52ce9138ed16ba162513762dcfd3da5d543cd7f/src/main/java/org/jenkinsci/jira/JIRA.java#L19-L22
145,557
flow/commons
src/main/java/com/flowpowered/commons/datatable/delta/DeltaMap.java
DeltaMap.get
@Override public <T extends Serializable> T get(Object key, T defaultValue) { throw new UnsupportedOperationException("DeltaMap must only be read in bulk."); }
java
@Override public <T extends Serializable> T get(Object key, T defaultValue) { throw new UnsupportedOperationException("DeltaMap must only be read in bulk."); }
[ "@", "Override", "public", "<", "T", "extends", "Serializable", ">", "T", "get", "(", "Object", "key", ",", "T", "defaultValue", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"DeltaMap must only be read in bulk.\"", ")", ";", "}" ]
- If we clear this map, the type changes to REPLACE and all elements are cleared
[ "-", "If", "we", "clear", "this", "map", "the", "type", "changes", "to", "REPLACE", "and", "all", "elements", "are", "cleared" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/datatable/delta/DeltaMap.java#L96-L99
145,558
flow/commons
src/main/java/com/flowpowered/commons/TPSMonitor.java
TPSMonitor.update
public void update() { final long time = System.currentTimeMillis(); elapsedTime += time - lastUpdateTime; lastUpdateTime = time; frameCount++; if (elapsedTime >= 1000) { tps = frameCount; frameCount = 0; elapsedTime = 0; } }
java
public void update() { final long time = System.currentTimeMillis(); elapsedTime += time - lastUpdateTime; lastUpdateTime = time; frameCount++; if (elapsedTime >= 1000) { tps = frameCount; frameCount = 0; elapsedTime = 0; } }
[ "public", "void", "update", "(", ")", "{", "final", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "elapsedTime", "+=", "time", "-", "lastUpdateTime", ";", "lastUpdateTime", "=", "time", ";", "frameCount", "++", ";", "if", "(", "elapsedTime", ">=", "1000", ")", "{", "tps", "=", "frameCount", ";", "frameCount", "=", "0", ";", "elapsedTime", "=", "0", ";", "}", "}" ]
Updates the TPS.
[ "Updates", "the", "TPS", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/TPSMonitor.java#L45-L55
145,559
febit/wit
wit-core/src/main/java/org/febit/wit/InternalContext.java
InternalContext.createSubContext
public InternalContext createSubContext(VariantIndexer[] indexers, InternalContext localContext, int varSize) { Object[][] myParentScopes = this.parentScopes; //cal the new-context's parent-scopes Object[][] scopes; if (myParentScopes == null) { scopes = new Object[][]{this.vars}; } else { scopes = new Object[myParentScopes.length + 1][]; scopes[0] = this.vars; System.arraycopy(myParentScopes, 0, scopes, 1, myParentScopes.length); } InternalContext newContext = new InternalContext(template, localContext.out, Vars.EMPTY, indexers, varSize, scopes); newContext.localContext = localContext; return newContext; }
java
public InternalContext createSubContext(VariantIndexer[] indexers, InternalContext localContext, int varSize) { Object[][] myParentScopes = this.parentScopes; //cal the new-context's parent-scopes Object[][] scopes; if (myParentScopes == null) { scopes = new Object[][]{this.vars}; } else { scopes = new Object[myParentScopes.length + 1][]; scopes[0] = this.vars; System.arraycopy(myParentScopes, 0, scopes, 1, myParentScopes.length); } InternalContext newContext = new InternalContext(template, localContext.out, Vars.EMPTY, indexers, varSize, scopes); newContext.localContext = localContext; return newContext; }
[ "public", "InternalContext", "createSubContext", "(", "VariantIndexer", "[", "]", "indexers", ",", "InternalContext", "localContext", ",", "int", "varSize", ")", "{", "Object", "[", "]", "[", "]", "myParentScopes", "=", "this", ".", "parentScopes", ";", "//cal the new-context's parent-scopes", "Object", "[", "]", "[", "]", "scopes", ";", "if", "(", "myParentScopes", "==", "null", ")", "{", "scopes", "=", "new", "Object", "[", "]", "[", "]", "{", "this", ".", "vars", "}", ";", "}", "else", "{", "scopes", "=", "new", "Object", "[", "myParentScopes", ".", "length", "+", "1", "]", "[", "", "]", ";", "scopes", "[", "0", "]", "=", "this", ".", "vars", ";", "System", ".", "arraycopy", "(", "myParentScopes", ",", "0", ",", "scopes", ",", "1", ",", "myParentScopes", ".", "length", ")", ";", "}", "InternalContext", "newContext", "=", "new", "InternalContext", "(", "template", ",", "localContext", ".", "out", ",", "Vars", ".", "EMPTY", ",", "indexers", ",", "varSize", ",", "scopes", ")", ";", "newContext", ".", "localContext", "=", "localContext", ";", "return", "newContext", ";", "}" ]
Create a sub context. @param indexers indexers @param localContext local context @param varSize var size @return a new sub context
[ "Create", "a", "sub", "context", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/InternalContext.java#L129-L145
145,560
febit/wit
wit-core/src/main/java/org/febit/wit/InternalContext.java
InternalContext.resetReturnLoop
public Object resetReturnLoop() { Object result = this.loopType == LoopInfo.RETURN ? this.returned : VOID; resetLoop(); return result; }
java
public Object resetReturnLoop() { Object result = this.loopType == LoopInfo.RETURN ? this.returned : VOID; resetLoop(); return result; }
[ "public", "Object", "resetReturnLoop", "(", ")", "{", "Object", "result", "=", "this", ".", "loopType", "==", "LoopInfo", ".", "RETURN", "?", "this", ".", "returned", ":", "VOID", ";", "resetLoop", "(", ")", ";", "return", "result", ";", "}" ]
Unmark loops, at the end of functions. @return the returned
[ "Unmark", "loops", "at", "the", "end", "of", "functions", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/InternalContext.java#L232-L237
145,561
febit/wit
wit-core/src/main/java/org/febit/wit/InternalContext.java
InternalContext.getBeanProperty
public <T> Object getBeanProperty(final T bean, final Object property) { if (bean != null) { @SuppressWarnings("unchecked") GetResolver<T> resolver = this.getters.unsafeGet(bean.getClass()); if (resolver != null) { return resolver.get(bean, property); } } return this.resolverManager.get(bean, property); }
java
public <T> Object getBeanProperty(final T bean, final Object property) { if (bean != null) { @SuppressWarnings("unchecked") GetResolver<T> resolver = this.getters.unsafeGet(bean.getClass()); if (resolver != null) { return resolver.get(bean, property); } } return this.resolverManager.get(bean, property); }
[ "public", "<", "T", ">", "Object", "getBeanProperty", "(", "final", "T", "bean", ",", "final", "Object", "property", ")", "{", "if", "(", "bean", "!=", "null", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "GetResolver", "<", "T", ">", "resolver", "=", "this", ".", "getters", ".", "unsafeGet", "(", "bean", ".", "getClass", "(", ")", ")", ";", "if", "(", "resolver", "!=", "null", ")", "{", "return", "resolver", ".", "get", "(", "bean", ",", "property", ")", ";", "}", "}", "return", "this", ".", "resolverManager", ".", "get", "(", "bean", ",", "property", ")", ";", "}" ]
Get a bean's property. @param <T> bean type @param bean bean @param property property @return value
[ "Get", "a", "bean", "s", "property", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/InternalContext.java#L255-L264
145,562
febit/wit
wit-core/src/main/java/org/febit/wit/InternalContext.java
InternalContext.setBeanProperty
public <T> void setBeanProperty(final T bean, final Object property, final Object value) { if (bean != null) { @SuppressWarnings("unchecked") SetResolver<T> resolver = this.setters.unsafeGet(bean.getClass()); if (resolver != null) { resolver.set(bean, property, value); return; } } this.resolverManager.set(bean, property, value); }
java
public <T> void setBeanProperty(final T bean, final Object property, final Object value) { if (bean != null) { @SuppressWarnings("unchecked") SetResolver<T> resolver = this.setters.unsafeGet(bean.getClass()); if (resolver != null) { resolver.set(bean, property, value); return; } } this.resolverManager.set(bean, property, value); }
[ "public", "<", "T", ">", "void", "setBeanProperty", "(", "final", "T", "bean", ",", "final", "Object", "property", ",", "final", "Object", "value", ")", "{", "if", "(", "bean", "!=", "null", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "SetResolver", "<", "T", ">", "resolver", "=", "this", ".", "setters", ".", "unsafeGet", "(", "bean", ".", "getClass", "(", ")", ")", ";", "if", "(", "resolver", "!=", "null", ")", "{", "resolver", ".", "set", "(", "bean", ",", "property", ",", "value", ")", ";", "return", ";", "}", "}", "this", ".", "resolverManager", ".", "set", "(", "bean", ",", "property", ",", "value", ")", ";", "}" ]
Set a bean's property. @param bean bean @param property property @param value value
[ "Set", "a", "bean", "s", "property", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/InternalContext.java#L273-L283
145,563
politie/cinch
src/main/java/eu/icolumbo/cinch/CinchJob.java
CinchJob.execute
@Override public void execute(CinchContext cinchContext, SparkConf sparkConf) { JavaSparkContext sparkContext = new JavaSparkContext(sparkConf); execute(sparkContext, cinchContext); }
java
@Override public void execute(CinchContext cinchContext, SparkConf sparkConf) { JavaSparkContext sparkContext = new JavaSparkContext(sparkConf); execute(sparkContext, cinchContext); }
[ "@", "Override", "public", "void", "execute", "(", "CinchContext", "cinchContext", ",", "SparkConf", "sparkConf", ")", "{", "JavaSparkContext", "sparkContext", "=", "new", "JavaSparkContext", "(", "sparkConf", ")", ";", "execute", "(", "sparkContext", ",", "cinchContext", ")", ";", "}" ]
Execute cinch job with context.
[ "Execute", "cinch", "job", "with", "context", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/CinchJob.java#L14-L19
145,564
febit/wit
wit-core/src/main/java/org/febit/wit/util/Props.java
Props.put
private void put(String section, String key, String value, boolean append) { // ignore lines without = if (key == null) { return; } if (section == null) { put(key, value, append); return; } put(key.isEmpty() ? section : section + '.' + key, value, append); }
java
private void put(String section, String key, String value, boolean append) { // ignore lines without = if (key == null) { return; } if (section == null) { put(key, value, append); return; } put(key.isEmpty() ? section : section + '.' + key, value, append); }
[ "private", "void", "put", "(", "String", "section", ",", "String", "key", ",", "String", "value", ",", "boolean", "append", ")", "{", "// ignore lines without =", "if", "(", "key", "==", "null", ")", "{", "return", ";", "}", "if", "(", "section", "==", "null", ")", "{", "put", "(", "key", ",", "value", ",", "append", ")", ";", "return", ";", "}", "put", "(", "key", ".", "isEmpty", "(", ")", "?", "section", ":", "section", "+", "'", "'", "+", "key", ",", "value", ",", "append", ")", ";", "}" ]
Adds accumulated value to key and current section.
[ "Adds", "accumulated", "value", "to", "key", "and", "current", "section", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/util/Props.java#L146-L159
145,565
febit/wit
wit-core/src/main/java/org/febit/wit/global/GlobalManager.java
GlobalManager.forEachConst
public void forEachConst(BiConsumer<String, Object> action) { Objects.requireNonNull(action); this.constVars.forEach(action); }
java
public void forEachConst(BiConsumer<String, Object> action) { Objects.requireNonNull(action); this.constVars.forEach(action); }
[ "public", "void", "forEachConst", "(", "BiConsumer", "<", "String", ",", "Object", ">", "action", ")", "{", "Objects", ".", "requireNonNull", "(", "action", ")", ";", "this", ".", "constVars", ".", "forEach", "(", "action", ")", ";", "}" ]
Performs the given action for each const vars until all have been processed or the action throws an exception. @param action @since 2.5.0
[ "Performs", "the", "given", "action", "for", "each", "const", "vars", "until", "all", "have", "been", "processed", "or", "the", "action", "throws", "an", "exception", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/global/GlobalManager.java#L50-L53
145,566
febit/wit
wit-core/src/main/java/org/febit/wit/global/GlobalManager.java
GlobalManager.forEachGlobal
public void forEachGlobal(BiConsumer<String, Object> action) { Objects.requireNonNull(action); this.globalVars.forEach(action); }
java
public void forEachGlobal(BiConsumer<String, Object> action) { Objects.requireNonNull(action); this.globalVars.forEach(action); }
[ "public", "void", "forEachGlobal", "(", "BiConsumer", "<", "String", ",", "Object", ">", "action", ")", "{", "Objects", ".", "requireNonNull", "(", "action", ")", ";", "this", ".", "globalVars", ".", "forEach", "(", "action", ")", ";", "}" ]
Performs the given action for each global vars until all have been processed or the action throws an exception. @param action @since 2.5.0
[ "Performs", "the", "given", "action", "for", "each", "global", "vars", "until", "all", "have", "been", "processed", "or", "the", "action", "throws", "an", "exception", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/global/GlobalManager.java#L61-L64
145,567
ISOBlue/isoblue-android
libISOBlue-example/src/org/isoblue/ISOBlueDemo/ISOBlueDemo.java
ISOBlueDemo.sendMessage
private void sendMessage(org.isoblue.isobus.Message message) { // Check that we're actually connected before trying anything if (mChatService.getState() != BluetoothService.STATE_CONNECTED) { Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT) .show(); return; } // Get the message bytes and tell the BluetoothChatService to write mChatService.write(message); // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); }
java
private void sendMessage(org.isoblue.isobus.Message message) { // Check that we're actually connected before trying anything if (mChatService.getState() != BluetoothService.STATE_CONNECTED) { Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT) .show(); return; } // Get the message bytes and tell the BluetoothChatService to write mChatService.write(message); // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); }
[ "private", "void", "sendMessage", "(", "org", ".", "isoblue", ".", "isobus", ".", "Message", "message", ")", "{", "// Check that we're actually connected before trying anything", "if", "(", "mChatService", ".", "getState", "(", ")", "!=", "BluetoothService", ".", "STATE_CONNECTED", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "R", ".", "string", ".", "not_connected", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "return", ";", "}", "// Get the message bytes and tell the BluetoothChatService to write", "mChatService", ".", "write", "(", "message", ")", ";", "// Reset out string buffer to zero and clear the edit text field", "mOutStringBuffer", ".", "setLength", "(", "0", ")", ";", "}" ]
Sends a message. @param message A string of text to send.
[ "Sends", "a", "message", "." ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/org/isoblue/ISOBlueDemo/ISOBlueDemo.java#L216-L229
145,568
OSSIndex/java-api
src/main/java/net/ossindex/common/request/OssIndexHttpClient.java
OssIndexHttpClient.setHost
static void setHost(String scheme, String host, int port) { BASE_URL = scheme + "://" + host + ":" + port + "/" + VERSION + "/"; }
java
static void setHost(String scheme, String host, int port) { BASE_URL = scheme + "://" + host + ":" + port + "/" + VERSION + "/"; }
[ "static", "void", "setHost", "(", "String", "scheme", ",", "String", "host", ",", "int", "port", ")", "{", "BASE_URL", "=", "scheme", "+", "\"://\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/\"", "+", "VERSION", "+", "\"/\"", ";", "}" ]
Override the server location.
[ "Override", "the", "server", "location", "." ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/request/OssIndexHttpClient.java#L92-L94
145,569
OSSIndex/java-api
src/main/java/net/ossindex/common/request/OssIndexHttpClient.java
OssIndexHttpClient.performPostRequest
public String performPostRequest(String requestString, String data) throws IOException { HttpPost request = new HttpPost(getBaseUrl() + requestString); String json = null; CloseableHttpClient httpClient = HttpClients.createDefault(); if (proxies.size() > 0) { // We only check the first proxy for now Proxy myProxy = proxies.get(0); HttpHost proxy = myProxy.getHttpHost(); RequestConfig config = RequestConfig.custom() .setProxy(proxy) .setSocketTimeout(myProxy.getProxySocketTimeout()) .setConnectTimeout(myProxy.getProxyConnectTimeout()) .setConnectionRequestTimeout(myProxy.getProxyConnectionRequestTimeout()) .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC)) .build(); request.setConfig(config); } try { logger.debug("------------------------------------------------"); logger.debug("OSS Index POST: " + getBaseUrl() + requestString); logger.debug(data); logger.debug("------------------------------------------------"); request.setEntity(new StringEntity(data)); CloseableHttpResponse response = httpClient.execute(request); int code = response.getStatusLine().getStatusCode(); if(code < 200 || code > 299) { throw new ConnectException(response.getStatusLine().getReasonPhrase() + " (" + code + ")"); } json = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch(ParseException e) { throw new IOException(e); } finally { httpClient.close(); } return json; }
java
public String performPostRequest(String requestString, String data) throws IOException { HttpPost request = new HttpPost(getBaseUrl() + requestString); String json = null; CloseableHttpClient httpClient = HttpClients.createDefault(); if (proxies.size() > 0) { // We only check the first proxy for now Proxy myProxy = proxies.get(0); HttpHost proxy = myProxy.getHttpHost(); RequestConfig config = RequestConfig.custom() .setProxy(proxy) .setSocketTimeout(myProxy.getProxySocketTimeout()) .setConnectTimeout(myProxy.getProxyConnectTimeout()) .setConnectionRequestTimeout(myProxy.getProxyConnectionRequestTimeout()) .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC)) .build(); request.setConfig(config); } try { logger.debug("------------------------------------------------"); logger.debug("OSS Index POST: " + getBaseUrl() + requestString); logger.debug(data); logger.debug("------------------------------------------------"); request.setEntity(new StringEntity(data)); CloseableHttpResponse response = httpClient.execute(request); int code = response.getStatusLine().getStatusCode(); if(code < 200 || code > 299) { throw new ConnectException(response.getStatusLine().getReasonPhrase() + " (" + code + ")"); } json = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch(ParseException e) { throw new IOException(e); } finally { httpClient.close(); } return json; }
[ "public", "String", "performPostRequest", "(", "String", "requestString", ",", "String", "data", ")", "throws", "IOException", "{", "HttpPost", "request", "=", "new", "HttpPost", "(", "getBaseUrl", "(", ")", "+", "requestString", ")", ";", "String", "json", "=", "null", ";", "CloseableHttpClient", "httpClient", "=", "HttpClients", ".", "createDefault", "(", ")", ";", "if", "(", "proxies", ".", "size", "(", ")", ">", "0", ")", "{", "// We only check the first proxy for now", "Proxy", "myProxy", "=", "proxies", ".", "get", "(", "0", ")", ";", "HttpHost", "proxy", "=", "myProxy", ".", "getHttpHost", "(", ")", ";", "RequestConfig", "config", "=", "RequestConfig", ".", "custom", "(", ")", ".", "setProxy", "(", "proxy", ")", ".", "setSocketTimeout", "(", "myProxy", ".", "getProxySocketTimeout", "(", ")", ")", ".", "setConnectTimeout", "(", "myProxy", ".", "getProxyConnectTimeout", "(", ")", ")", ".", "setConnectionRequestTimeout", "(", "myProxy", ".", "getProxyConnectionRequestTimeout", "(", ")", ")", ".", "setProxyPreferredAuthSchemes", "(", "Arrays", ".", "asList", "(", "AuthSchemes", ".", "BASIC", ")", ")", ".", "build", "(", ")", ";", "request", ".", "setConfig", "(", "config", ")", ";", "}", "try", "{", "logger", ".", "debug", "(", "\"------------------------------------------------\"", ")", ";", "logger", ".", "debug", "(", "\"OSS Index POST: \"", "+", "getBaseUrl", "(", ")", "+", "requestString", ")", ";", "logger", ".", "debug", "(", "data", ")", ";", "logger", ".", "debug", "(", "\"------------------------------------------------\"", ")", ";", "request", ".", "setEntity", "(", "new", "StringEntity", "(", "data", ")", ")", ";", "CloseableHttpResponse", "response", "=", "httpClient", ".", "execute", "(", "request", ")", ";", "int", "code", "=", "response", ".", "getStatusLine", "(", ")", ".", "getStatusCode", "(", ")", ";", "if", "(", "code", "<", "200", "||", "code", ">", "299", ")", "{", "throw", "new", "ConnectException", "(", "response", ".", "getStatusLine", "(", ")", ".", "getReasonPhrase", "(", ")", "+", "\" (\"", "+", "code", "+", "\")\"", ")", ";", "}", "json", "=", "EntityUtils", ".", "toString", "(", "response", ".", "getEntity", "(", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "finally", "{", "httpClient", ".", "close", "(", ")", ";", "}", "return", "json", ";", "}" ]
Perform the request with the given URL and JSON data. @param requestString Server request relative URL @param data JSON data for the request @return JSON results of the request @throws IOException On query problems
[ "Perform", "the", "request", "with", "the", "given", "URL", "and", "JSON", "data", "." ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/request/OssIndexHttpClient.java#L103-L140
145,570
OSSIndex/java-api
src/main/java/net/ossindex/common/request/OssIndexHttpClient.java
OssIndexHttpClient.performGetRequest
protected String performGetRequest(String requestString) throws IOException { HttpGet request = new HttpGet(getBaseUrl() + requestString); if (USER != null && !USER.isEmpty()) { request.setHeader("Authorization", USER + ":" + TOKEN); } String json = null; CloseableHttpClient httpClient = HttpClients.createDefault(); try { logger.debug("------------------------------------------------"); logger.debug("OSS Index GET: " + getBaseUrl() + requestString); logger.debug("------------------------------------------------"); CloseableHttpResponse response = httpClient.execute(request); int code = response.getStatusLine().getStatusCode(); if(code < 200 || code > 299) { throw new ConnectException(response.getStatusLine().getReasonPhrase() + " (" + code + ")"); } json = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch(ParseException e) { throw new IOException(e); } finally { httpClient.close(); } return json; }
java
protected String performGetRequest(String requestString) throws IOException { HttpGet request = new HttpGet(getBaseUrl() + requestString); if (USER != null && !USER.isEmpty()) { request.setHeader("Authorization", USER + ":" + TOKEN); } String json = null; CloseableHttpClient httpClient = HttpClients.createDefault(); try { logger.debug("------------------------------------------------"); logger.debug("OSS Index GET: " + getBaseUrl() + requestString); logger.debug("------------------------------------------------"); CloseableHttpResponse response = httpClient.execute(request); int code = response.getStatusLine().getStatusCode(); if(code < 200 || code > 299) { throw new ConnectException(response.getStatusLine().getReasonPhrase() + " (" + code + ")"); } json = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch(ParseException e) { throw new IOException(e); } finally { httpClient.close(); } return json; }
[ "protected", "String", "performGetRequest", "(", "String", "requestString", ")", "throws", "IOException", "{", "HttpGet", "request", "=", "new", "HttpGet", "(", "getBaseUrl", "(", ")", "+", "requestString", ")", ";", "if", "(", "USER", "!=", "null", "&&", "!", "USER", ".", "isEmpty", "(", ")", ")", "{", "request", ".", "setHeader", "(", "\"Authorization\"", ",", "USER", "+", "\":\"", "+", "TOKEN", ")", ";", "}", "String", "json", "=", "null", ";", "CloseableHttpClient", "httpClient", "=", "HttpClients", ".", "createDefault", "(", ")", ";", "try", "{", "logger", ".", "debug", "(", "\"------------------------------------------------\"", ")", ";", "logger", ".", "debug", "(", "\"OSS Index GET: \"", "+", "getBaseUrl", "(", ")", "+", "requestString", ")", ";", "logger", ".", "debug", "(", "\"------------------------------------------------\"", ")", ";", "CloseableHttpResponse", "response", "=", "httpClient", ".", "execute", "(", "request", ")", ";", "int", "code", "=", "response", ".", "getStatusLine", "(", ")", ".", "getStatusCode", "(", ")", ";", "if", "(", "code", "<", "200", "||", "code", ">", "299", ")", "{", "throw", "new", "ConnectException", "(", "response", ".", "getStatusLine", "(", ")", ".", "getReasonPhrase", "(", ")", "+", "\" (\"", "+", "code", "+", "\")\"", ")", ";", "}", "json", "=", "EntityUtils", ".", "toString", "(", "response", ".", "getEntity", "(", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "finally", "{", "httpClient", ".", "close", "(", ")", ";", "}", "return", "json", ";", "}" ]
Perform a get request @param requestString @return @throws IOException
[ "Perform", "a", "get", "request" ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/request/OssIndexHttpClient.java#L148-L173
145,571
febit/wit
wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java
AbstractLoader.concat
@Override public String concat(final String parent, final String name) { return parent != null ? FileNameUtil.concat(FileNameUtil.getPath(parent), name) : name; }
java
@Override public String concat(final String parent, final String name) { return parent != null ? FileNameUtil.concat(FileNameUtil.getPath(parent), name) : name; }
[ "@", "Override", "public", "String", "concat", "(", "final", "String", "parent", ",", "final", "String", "name", ")", "{", "return", "parent", "!=", "null", "?", "FileNameUtil", ".", "concat", "(", "FileNameUtil", ".", "getPath", "(", "parent", ")", ",", "name", ")", ":", "name", ";", "}" ]
get child template name by parent template name and relative name. <pre> example: /path/to/tmpl1.wit , tmpl2.wit =&gt; /path/to/tmpl2.wit /path/to/tmpl1.wit , /tmpl2.wit =&gt; /tmpl2.wit /path/to/tmpl1.wit , ./tmpl2.wit =&gt; /path/to/tmpl2.wit /path/to/tmpl1.wit , ../tmpl2.wit =&gt; /path/tmpl2.wit </pre> @param parent parent template's name @param name relative name @return child template's name
[ "get", "child", "template", "name", "by", "parent", "template", "name", "and", "relative", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java#L43-L48
145,572
febit/wit
wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java
AbstractLoader.getRealPath
protected String getRealPath(final String name) { return this.root != null ? this.root.concat(name) : name.substring(1); }
java
protected String getRealPath(final String name) { return this.root != null ? this.root.concat(name) : name.substring(1); }
[ "protected", "String", "getRealPath", "(", "final", "String", "name", ")", "{", "return", "this", ".", "root", "!=", "null", "?", "this", ".", "root", ".", "concat", "(", "name", ")", ":", "name", ".", "substring", "(", "1", ")", ";", "}" ]
get real path from name. @param name @return
[ "get", "real", "path", "from", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java#L56-L60
145,573
febit/wit
wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java
AbstractLoader.normalize
@Override public String normalize(String name) { if (name == null) { return null; } if (name.isEmpty()) { return "/"; } if (name.charAt(0) != '/' && name.charAt(0) != '\\') { name = "/".concat(name); } name = FileNameUtil.normalize(name); if (name == null) { return null; } if (!this.appendLostSuffix || name.endsWith(this.suffix) || name.charAt(name.length() - 1) == '/') { return name; } else { for (String item : this.assistantSuffixs) { if (name.endsWith(item)) { return name; } } return name.concat(this.suffix); } }
java
@Override public String normalize(String name) { if (name == null) { return null; } if (name.isEmpty()) { return "/"; } if (name.charAt(0) != '/' && name.charAt(0) != '\\') { name = "/".concat(name); } name = FileNameUtil.normalize(name); if (name == null) { return null; } if (!this.appendLostSuffix || name.endsWith(this.suffix) || name.charAt(name.length() - 1) == '/') { return name; } else { for (String item : this.assistantSuffixs) { if (name.endsWith(item)) { return name; } } return name.concat(this.suffix); } }
[ "@", "Override", "public", "String", "normalize", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "name", ".", "isEmpty", "(", ")", ")", "{", "return", "\"/\"", ";", "}", "if", "(", "name", ".", "charAt", "(", "0", ")", "!=", "'", "'", "&&", "name", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "{", "name", "=", "\"/\"", ".", "concat", "(", "name", ")", ";", "}", "name", "=", "FileNameUtil", ".", "normalize", "(", "name", ")", ";", "if", "(", "name", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "this", ".", "appendLostSuffix", "||", "name", ".", "endsWith", "(", "this", ".", "suffix", ")", "||", "name", ".", "charAt", "(", "name", ".", "length", "(", ")", "-", "1", ")", "==", "'", "'", ")", "{", "return", "name", ";", "}", "else", "{", "for", "(", "String", "item", ":", "this", ".", "assistantSuffixs", ")", "{", "if", "(", "name", ".", "endsWith", "(", "item", ")", ")", "{", "return", "name", ";", "}", "}", "return", "name", ".", "concat", "(", "this", ".", "suffix", ")", ";", "}", "}" ]
normalize a template's name. <pre> example: path/to/tmpl.wit /path/to/tmpl.wit /path/to/./tmpl.wit /path/to/tmpl.wit /path/to/../tmpl.wit /path/tmpl.wit \path\to\..\tmpl.wit /path/tmpl.wit \path\to\..\..\tmpl.wit /tmpl.wit \path\to\..\..\..\tmpl.wit null </pre> @param name template's name @return normalized name
[ "normalize", "a", "template", "s", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/loaders/AbstractLoader.java#L78-L105
145,574
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicVariableWidthArray.java
AtomicVariableWidthArray.get
public final int get(int i) { if (fullWidth) { return array.get(i); } return unPack(array.get(getIndex(i)), getSubIndex(i)); }
java
public final int get(int i) { if (fullWidth) { return array.get(i); } return unPack(array.get(getIndex(i)), getSubIndex(i)); }
[ "public", "final", "int", "get", "(", "int", "i", ")", "{", "if", "(", "fullWidth", ")", "{", "return", "array", ".", "get", "(", "i", ")", ";", "}", "return", "unPack", "(", "array", ".", "get", "(", "getIndex", "(", "i", ")", ")", ",", "getSubIndex", "(", "i", ")", ")", ";", "}" ]
Gets an element from the array at a given index @param i the index @return the element
[ "Gets", "an", "element", "from", "the", "array", "at", "a", "given", "index" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicVariableWidthArray.java#L131-L137
145,575
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicVariableWidthArray.java
AtomicVariableWidthArray.getPacked
public int[] getPacked() { int length = this.array.length(); int[] packed = new int[length]; for (int i = 0; i < length; i++) { packed[i] = this.array.get(i); } return packed; }
java
public int[] getPacked() { int length = this.array.length(); int[] packed = new int[length]; for (int i = 0; i < length; i++) { packed[i] = this.array.get(i); } return packed; }
[ "public", "int", "[", "]", "getPacked", "(", ")", "{", "int", "length", "=", "this", ".", "array", ".", "length", "(", ")", ";", "int", "[", "]", "packed", "=", "new", "int", "[", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "packed", "[", "i", "]", "=", "this", ".", "array", ".", "get", "(", "i", ")", ";", "}", "return", "packed", ";", "}" ]
Gets a packed version of this array. Tearing may occur if the array is updated during this method call.
[ "Gets", "a", "packed", "version", "of", "this", "array", ".", "Tearing", "may", "occur", "if", "the", "array", "is", "updated", "during", "this", "method", "call", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicVariableWidthArray.java#L278-L285
145,576
febit/wit
wit-core/src/main/java/org/febit/wit/util/Petite.java
Petite.get
@SuppressWarnings("unchecked") public <T> T get(final Class<T> type) { T bean = (T) components.get(type); if (bean != null) { return bean; } return (T) get(type.getName()); }
java
@SuppressWarnings("unchecked") public <T> T get(final Class<T> type) { T bean = (T) components.get(type); if (bean != null) { return bean; } return (T) get(type.getName()); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "get", "(", "final", "Class", "<", "T", ">", "type", ")", "{", "T", "bean", "=", "(", "T", ")", "components", ".", "get", "(", "type", ")", ";", "if", "(", "bean", "!=", "null", ")", "{", "return", "bean", ";", "}", "return", "(", "T", ")", "get", "(", "type", ".", "getName", "(", ")", ")", ";", "}" ]
Get component or bean by type. @param <T> @param type @return Component
[ "Get", "component", "or", "bean", "by", "type", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/util/Petite.java#L36-L43
145,577
febit/wit
wit-core/src/main/java/org/febit/wit/util/Petite.java
Petite.get
public Object get(final String name) { Object bean = this.beans.get(name); if (bean != null) { return bean; } return resolveBeanIfAbsent(name); }
java
public Object get(final String name) { Object bean = this.beans.get(name); if (bean != null) { return bean; } return resolveBeanIfAbsent(name); }
[ "public", "Object", "get", "(", "final", "String", "name", ")", "{", "Object", "bean", "=", "this", ".", "beans", ".", "get", "(", "name", ")", ";", "if", "(", "bean", "!=", "null", ")", "{", "return", "bean", ";", "}", "return", "resolveBeanIfAbsent", "(", "name", ")", ";", "}" ]
Get bean by name. @param name @return bean
[ "Get", "bean", "by", "name", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/util/Petite.java#L51-L57
145,578
ISOBlue/isoblue-android
libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java
BluetoothService.setState
private synchronized void setState(int state) { mState = state; // Give the new state to the Handler so the UI Activity can update mHandler.obtainMessage(ISOBlueDemo.MESSAGE_STATE_CHANGE, state, -1) .sendToTarget(); }
java
private synchronized void setState(int state) { mState = state; // Give the new state to the Handler so the UI Activity can update mHandler.obtainMessage(ISOBlueDemo.MESSAGE_STATE_CHANGE, state, -1) .sendToTarget(); }
[ "private", "synchronized", "void", "setState", "(", "int", "state", ")", "{", "mState", "=", "state", ";", "// Give the new state to the Handler so the UI Activity can update", "mHandler", ".", "obtainMessage", "(", "ISOBlueDemo", ".", "MESSAGE_STATE_CHANGE", ",", "state", ",", "-", "1", ")", ".", "sendToTarget", "(", ")", ";", "}" ]
Set the current state of the chat connection @param state An integer defining the current connection state
[ "Set", "the", "current", "state", "of", "the", "chat", "connection" ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java#L83-L89
145,579
ISOBlue/isoblue-android
libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java
BluetoothService.connect
public synchronized void connect(BluetoothDevice device, boolean past) throws IOException, InterruptedException { // Cancel any thread attempting to make a connection if (mState == STATE_CONNECTING) { if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } } // Cancel any thread currently running a connection if (mEngConnectedThread != null) { mEngConnectedThread.cancel(); mEngConnectedThread = null; } if (mImpConnectedThread != null) { mImpConnectedThread.cancel(); mImpConnectedThread = null; } mPast = past; // Start the thread to connect with the given device try { mConnectThread = new ConnectThread(device); mConnectThread.start(); } catch (IOException e) { e.printStackTrace(); connectionFailed(); setState(STATE_NONE); } setState(STATE_CONNECTING); }
java
public synchronized void connect(BluetoothDevice device, boolean past) throws IOException, InterruptedException { // Cancel any thread attempting to make a connection if (mState == STATE_CONNECTING) { if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } } // Cancel any thread currently running a connection if (mEngConnectedThread != null) { mEngConnectedThread.cancel(); mEngConnectedThread = null; } if (mImpConnectedThread != null) { mImpConnectedThread.cancel(); mImpConnectedThread = null; } mPast = past; // Start the thread to connect with the given device try { mConnectThread = new ConnectThread(device); mConnectThread.start(); } catch (IOException e) { e.printStackTrace(); connectionFailed(); setState(STATE_NONE); } setState(STATE_CONNECTING); }
[ "public", "synchronized", "void", "connect", "(", "BluetoothDevice", "device", ",", "boolean", "past", ")", "throws", "IOException", ",", "InterruptedException", "{", "// Cancel any thread attempting to make a connection", "if", "(", "mState", "==", "STATE_CONNECTING", ")", "{", "if", "(", "mConnectThread", "!=", "null", ")", "{", "mConnectThread", ".", "cancel", "(", ")", ";", "mConnectThread", "=", "null", ";", "}", "}", "// Cancel any thread currently running a connection", "if", "(", "mEngConnectedThread", "!=", "null", ")", "{", "mEngConnectedThread", ".", "cancel", "(", ")", ";", "mEngConnectedThread", "=", "null", ";", "}", "if", "(", "mImpConnectedThread", "!=", "null", ")", "{", "mImpConnectedThread", ".", "cancel", "(", ")", ";", "mImpConnectedThread", "=", "null", ";", "}", "mPast", "=", "past", ";", "// Start the thread to connect with the given device", "try", "{", "mConnectThread", "=", "new", "ConnectThread", "(", "device", ")", ";", "mConnectThread", ".", "start", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "connectionFailed", "(", ")", ";", "setState", "(", "STATE_NONE", ")", ";", "}", "setState", "(", "STATE_CONNECTING", ")", ";", "}" ]
Start the ConnectThread to initiate a connection to a remote device. @param device The BluetoothDevice to connect @param past @param secure Socket Security type - Secure (true) , Insecure (false) @throws InterruptedException @throws IOException
[ "Start", "the", "ConnectThread", "to", "initiate", "a", "connection", "to", "a", "remote", "device", "." ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java#L133-L165
145,580
ISOBlue/isoblue-android
libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java
BluetoothService.write
public void write(org.isoblue.isobus.Message out) { // Create temporary object ConnectedThread r; // Synchronize a copy of the ConnectedThread synchronized (this) { if (mState != STATE_CONNECTED) return; r = mEngConnectedThread; } // Perform the write unsynchronized r.write(out); }
java
public void write(org.isoblue.isobus.Message out) { // Create temporary object ConnectedThread r; // Synchronize a copy of the ConnectedThread synchronized (this) { if (mState != STATE_CONNECTED) return; r = mEngConnectedThread; } // Perform the write unsynchronized r.write(out); }
[ "public", "void", "write", "(", "org", ".", "isoblue", ".", "isobus", ".", "Message", "out", ")", "{", "// Create temporary object", "ConnectedThread", "r", ";", "// Synchronize a copy of the ConnectedThread", "synchronized", "(", "this", ")", "{", "if", "(", "mState", "!=", "STATE_CONNECTED", ")", "return", ";", "r", "=", "mEngConnectedThread", ";", "}", "// Perform the write unsynchronized", "r", ".", "write", "(", "out", ")", ";", "}" ]
Write to the ConnectedThread in an unsynchronized manner @param out The bytes to write @see ConnectedThread#write(byte[])
[ "Write", "to", "the", "ConnectedThread", "in", "an", "unsynchronized", "manner" ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java#L245-L256
145,581
ISOBlue/isoblue-android
libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java
BluetoothService.connectionFailed
private void connectionFailed() { // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(ISOBlueDemo.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(ISOBlueDemo.TOAST, "Unable to connect device"); msg.setData(bundle); mHandler.sendMessage(msg); // Start the service over to restart listening mode BluetoothService.this.start(); }
java
private void connectionFailed() { // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(ISOBlueDemo.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(ISOBlueDemo.TOAST, "Unable to connect device"); msg.setData(bundle); mHandler.sendMessage(msg); // Start the service over to restart listening mode BluetoothService.this.start(); }
[ "private", "void", "connectionFailed", "(", ")", "{", "// Send a failure message back to the Activity", "Message", "msg", "=", "mHandler", ".", "obtainMessage", "(", "ISOBlueDemo", ".", "MESSAGE_TOAST", ")", ";", "Bundle", "bundle", "=", "new", "Bundle", "(", ")", ";", "bundle", ".", "putString", "(", "ISOBlueDemo", ".", "TOAST", ",", "\"Unable to connect device\"", ")", ";", "msg", ".", "setData", "(", "bundle", ")", ";", "mHandler", ".", "sendMessage", "(", "msg", ")", ";", "// Start the service over to restart listening mode", "BluetoothService", ".", "this", ".", "start", "(", ")", ";", "}" ]
Indicate that the connection attempt failed and notify the UI Activity.
[ "Indicate", "that", "the", "connection", "attempt", "failed", "and", "notify", "the", "UI", "Activity", "." ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/org/isoblue/ISOBlueDemo/BluetoothService.java#L261-L271
145,582
ISOBlue/isoblue-android
libISOBlue-example/src/com/authorwjf/AboutDialog.java
AboutDialog.onCreate
@Override public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.about); TextView tv = (TextView) findViewById(R.id.legal_text); tv.setText(readRawTextFile(R.raw.legal)); tv = (TextView) findViewById(R.id.info_text); tv.setText(Html.fromHtml(readRawTextFile(R.raw.info))); tv.setLinkTextColor(Color.WHITE); Linkify.addLinks(tv, Linkify.ALL); }
java
@Override public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.about); TextView tv = (TextView) findViewById(R.id.legal_text); tv.setText(readRawTextFile(R.raw.legal)); tv = (TextView) findViewById(R.id.info_text); tv.setText(Html.fromHtml(readRawTextFile(R.raw.info))); tv.setLinkTextColor(Color.WHITE); Linkify.addLinks(tv, Linkify.ALL); }
[ "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "setContentView", "(", "R", ".", "layout", ".", "about", ")", ";", "TextView", "tv", "=", "(", "TextView", ")", "findViewById", "(", "R", ".", "id", ".", "legal_text", ")", ";", "tv", ".", "setText", "(", "readRawTextFile", "(", "R", ".", "raw", ".", "legal", ")", ")", ";", "tv", "=", "(", "TextView", ")", "findViewById", "(", "R", ".", "id", ".", "info_text", ")", ";", "tv", ".", "setText", "(", "Html", ".", "fromHtml", "(", "readRawTextFile", "(", "R", ".", "raw", ".", "info", ")", ")", ")", ";", "tv", ".", "setLinkTextColor", "(", "Color", ".", "WHITE", ")", ";", "Linkify", ".", "addLinks", "(", "tv", ",", "Linkify", ".", "ALL", ")", ";", "}" ]
This is the standard Android on create method that gets called when the activity initialized.
[ "This", "is", "the", "standard", "Android", "on", "create", "method", "that", "gets", "called", "when", "the", "activity", "initialized", "." ]
7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb
https://github.com/ISOBlue/isoblue-android/blob/7eab6447f1ffb4d2ad4b7b0b60373d02f9646fcb/libISOBlue-example/src/com/authorwjf/AboutDialog.java#L36-L45
145,583
flow/commons
src/main/java/com/flowpowered/commons/LogicUtil.java
LogicUtil.equalsAny
public static <A, B> boolean equalsAny(A object, B... objects) { for (B o : objects) { if (bothNullOrEqual(o, object)) { return true; } } return false; }
java
public static <A, B> boolean equalsAny(A object, B... objects) { for (B o : objects) { if (bothNullOrEqual(o, object)) { return true; } } return false; }
[ "public", "static", "<", "A", ",", "B", ">", "boolean", "equalsAny", "(", "A", "object", ",", "B", "...", "objects", ")", "{", "for", "(", "B", "o", ":", "objects", ")", "{", "if", "(", "bothNullOrEqual", "(", "o", ",", "object", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the object equals one of the other objects given @param object to check @param objects to use equals against @return True if one of the objects equal the object
[ "Checks", "if", "the", "object", "equals", "one", "of", "the", "other", "objects", "given" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/LogicUtil.java#L58-L65
145,584
flow/commons
src/main/java/com/flowpowered/commons/LogicUtil.java
LogicUtil.bothNullOrEqual
public static boolean bothNullOrEqual(Object a, Object b) { return (a == null || b == null) ? (a == b) : a.equals(b); }
java
public static boolean bothNullOrEqual(Object a, Object b) { return (a == null || b == null) ? (a == b) : a.equals(b); }
[ "public", "static", "boolean", "bothNullOrEqual", "(", "Object", "a", ",", "Object", "b", ")", "{", "return", "(", "a", "==", "null", "||", "b", "==", "null", ")", "?", "(", "a", "==", "b", ")", ":", "a", ".", "equals", "(", "b", ")", ";", "}" ]
Checks if object a and b are both null or are equal @return if both null or equal
[ "Checks", "if", "object", "a", "and", "b", "are", "both", "null", "or", "are", "equal" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/LogicUtil.java#L72-L74
145,585
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/SignSupportServiceImpl.java
SignSupportServiceImpl.verifySadRequest
protected void verifySadRequest(SignatureActivationDataContext sadRequest, ProfileRequestContext<?, ?> context) throws ExternalAutenticationErrorCodeException { final AuthnRequest authnRequest = this.getAuthnRequest(context); if (authnRequest == null) { log.error("No AuthnRequest available [{}]", this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(AuthnEventIds.INVALID_AUTHN_CTX, "Missing AuthnRequest"); } final SADRequest r = sadRequest.getSadRequest(); // Verify the version is what we understand ... // if (r.getRequestedVersion() != null && !supportedSadVersions.contains(r.getRequestedVersion())) { final String msg = String.format("Requested SAD version (%s) is not supported by the IdP", r.getRequestedVersion()); log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Check the RequesterID ... // if (!StringUtils.hasText(r.getRequesterID())) { final String msg = "RequesterID is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } final String issuer = authnRequest.getIssuer().getValue(); if (!r.getRequesterID().equals(issuer)) { final String msg = String.format("Invalid RequestID of SADRequest (%s) - Issuer of AuthnRequest is '%s'", r.getRequesterID(), issuer); log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Verify that the SignRequestID is there ... // if (!StringUtils.hasText(r.getSignRequestID())) { final String msg = "SignRequestID is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Assert that we have a DocCount element ... // if (r.getDocCount() == null) { final String msg = "DocCount is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Assert that we have an ID for the SADRequest ... // if (!StringUtils.hasText(r.getID())) { final String msg = "ID attribute is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } }
java
protected void verifySadRequest(SignatureActivationDataContext sadRequest, ProfileRequestContext<?, ?> context) throws ExternalAutenticationErrorCodeException { final AuthnRequest authnRequest = this.getAuthnRequest(context); if (authnRequest == null) { log.error("No AuthnRequest available [{}]", this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(AuthnEventIds.INVALID_AUTHN_CTX, "Missing AuthnRequest"); } final SADRequest r = sadRequest.getSadRequest(); // Verify the version is what we understand ... // if (r.getRequestedVersion() != null && !supportedSadVersions.contains(r.getRequestedVersion())) { final String msg = String.format("Requested SAD version (%s) is not supported by the IdP", r.getRequestedVersion()); log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Check the RequesterID ... // if (!StringUtils.hasText(r.getRequesterID())) { final String msg = "RequesterID is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } final String issuer = authnRequest.getIssuer().getValue(); if (!r.getRequesterID().equals(issuer)) { final String msg = String.format("Invalid RequestID of SADRequest (%s) - Issuer of AuthnRequest is '%s'", r.getRequesterID(), issuer); log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Verify that the SignRequestID is there ... // if (!StringUtils.hasText(r.getSignRequestID())) { final String msg = "SignRequestID is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Assert that we have a DocCount element ... // if (r.getDocCount() == null) { final String msg = "DocCount is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } // Assert that we have an ID for the SADRequest ... // if (!StringUtils.hasText(r.getID())) { final String msg = "ID attribute is not present in the SADRequest - invalid"; log.info("{} [{}]", msg, this.getLogString(context)); throw new ExternalAutenticationErrorCodeException(ExtAuthnEventIds.BAD_SAD_REQUEST, msg); } }
[ "protected", "void", "verifySadRequest", "(", "SignatureActivationDataContext", "sadRequest", ",", "ProfileRequestContext", "<", "?", ",", "?", ">", "context", ")", "throws", "ExternalAutenticationErrorCodeException", "{", "final", "AuthnRequest", "authnRequest", "=", "this", ".", "getAuthnRequest", "(", "context", ")", ";", "if", "(", "authnRequest", "==", "null", ")", "{", "log", ".", "error", "(", "\"No AuthnRequest available [{}]\"", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "AuthnEventIds", ".", "INVALID_AUTHN_CTX", ",", "\"Missing AuthnRequest\"", ")", ";", "}", "final", "SADRequest", "r", "=", "sadRequest", ".", "getSadRequest", "(", ")", ";", "// Verify the version is what we understand ...", "//", "if", "(", "r", ".", "getRequestedVersion", "(", ")", "!=", "null", "&&", "!", "supportedSadVersions", ".", "contains", "(", "r", ".", "getRequestedVersion", "(", ")", ")", ")", "{", "final", "String", "msg", "=", "String", ".", "format", "(", "\"Requested SAD version (%s) is not supported by the IdP\"", ",", "r", ".", "getRequestedVersion", "(", ")", ")", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "// Check the RequesterID ...", "//", "if", "(", "!", "StringUtils", ".", "hasText", "(", "r", ".", "getRequesterID", "(", ")", ")", ")", "{", "final", "String", "msg", "=", "\"RequesterID is not present in the SADRequest - invalid\"", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "final", "String", "issuer", "=", "authnRequest", ".", "getIssuer", "(", ")", ".", "getValue", "(", ")", ";", "if", "(", "!", "r", ".", "getRequesterID", "(", ")", ".", "equals", "(", "issuer", ")", ")", "{", "final", "String", "msg", "=", "String", ".", "format", "(", "\"Invalid RequestID of SADRequest (%s) - Issuer of AuthnRequest is '%s'\"", ",", "r", ".", "getRequesterID", "(", ")", ",", "issuer", ")", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "// Verify that the SignRequestID is there ...", "//", "if", "(", "!", "StringUtils", ".", "hasText", "(", "r", ".", "getSignRequestID", "(", ")", ")", ")", "{", "final", "String", "msg", "=", "\"SignRequestID is not present in the SADRequest - invalid\"", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "// Assert that we have a DocCount element ...", "//", "if", "(", "r", ".", "getDocCount", "(", ")", "==", "null", ")", "{", "final", "String", "msg", "=", "\"DocCount is not present in the SADRequest - invalid\"", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "// Assert that we have an ID for the SADRequest ...", "//", "if", "(", "!", "StringUtils", ".", "hasText", "(", "r", ".", "getID", "(", ")", ")", ")", "{", "final", "String", "msg", "=", "\"ID attribute is not present in the SADRequest - invalid\"", ";", "log", ".", "info", "(", "\"{} [{}]\"", ",", "msg", ",", "this", ".", "getLogString", "(", "context", ")", ")", ";", "throw", "new", "ExternalAutenticationErrorCodeException", "(", "ExtAuthnEventIds", ".", "BAD_SAD_REQUEST", ",", "msg", ")", ";", "}", "}" ]
Verifies a received SAD request. @param sadRequest the request to verify @param context the context @throws ExternalAutenticationErrorCodeException for errors
[ "Verifies", "a", "received", "SAD", "request", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/SignSupportServiceImpl.java#L330-L386
145,586
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/SignSupportServiceImpl.java
SignSupportServiceImpl.isSignMessageURI
protected boolean isSignMessageURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); return (loa != null && loa.isSignatureMessageUri()); }
java
protected boolean isSignMessageURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); return (loa != null && loa.isSignatureMessageUri()); }
[ "protected", "boolean", "isSignMessageURI", "(", "String", "uri", ")", "{", "LoaEnum", "loa", "=", "LoaEnum", ".", "parse", "(", "uri", ")", ";", "return", "(", "loa", "!=", "null", "&&", "loa", ".", "isSignatureMessageUri", "(", ")", ")", ";", "}" ]
Predicate that tells if the supplied URI is a URI indicating sign message display. @param uri the URI to test @return {@code true} if the supplied URI is for sign message, and {@code false} otherwise
[ "Predicate", "that", "tells", "if", "the", "supplied", "URI", "is", "a", "URI", "indicating", "sign", "message", "display", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/SignSupportServiceImpl.java#L511-L514
145,587
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.connect
public void connect(String endpointID, String appID, boolean shouldReconnect, final Object initialPresence, Context context, final ConnectCompletionListener completionListener) { if ((endpointID != null) && (appID != null) && (endpointID.length() > 0) && (appID.length() > 0)) { connectionInProgress = true; reconnect = shouldReconnect; applicationID = appID; appContext = context; APIGetToken request = new APIGetToken(context, baseURL) { @Override public void transactionComplete() { super.transactionComplete(); if (success) { connect(this.token, initialPresence, appContext, new ConnectCompletionListener() { @Override public void onError(final String errorMessage) { connectionInProgress = false; postConnectError(completionListener, errorMessage); } }); } else { connectionInProgress = false; postConnectError(completionListener, this.errorMessage); } } }; request.appID = appID; request.endpointID = endpointID; request.go(); } else { postConnectError(completionListener, "AppID and endpointID must be specified"); } }
java
public void connect(String endpointID, String appID, boolean shouldReconnect, final Object initialPresence, Context context, final ConnectCompletionListener completionListener) { if ((endpointID != null) && (appID != null) && (endpointID.length() > 0) && (appID.length() > 0)) { connectionInProgress = true; reconnect = shouldReconnect; applicationID = appID; appContext = context; APIGetToken request = new APIGetToken(context, baseURL) { @Override public void transactionComplete() { super.transactionComplete(); if (success) { connect(this.token, initialPresence, appContext, new ConnectCompletionListener() { @Override public void onError(final String errorMessage) { connectionInProgress = false; postConnectError(completionListener, errorMessage); } }); } else { connectionInProgress = false; postConnectError(completionListener, this.errorMessage); } } }; request.appID = appID; request.endpointID = endpointID; request.go(); } else { postConnectError(completionListener, "AppID and endpointID must be specified"); } }
[ "public", "void", "connect", "(", "String", "endpointID", ",", "String", "appID", ",", "boolean", "shouldReconnect", ",", "final", "Object", "initialPresence", ",", "Context", "context", ",", "final", "ConnectCompletionListener", "completionListener", ")", "{", "if", "(", "(", "endpointID", "!=", "null", ")", "&&", "(", "appID", "!=", "null", ")", "&&", "(", "endpointID", ".", "length", "(", ")", ">", "0", ")", "&&", "(", "appID", ".", "length", "(", ")", ">", "0", ")", ")", "{", "connectionInProgress", "=", "true", ";", "reconnect", "=", "shouldReconnect", ";", "applicationID", "=", "appID", ";", "appContext", "=", "context", ";", "APIGetToken", "request", "=", "new", "APIGetToken", "(", "context", ",", "baseURL", ")", "{", "@", "Override", "public", "void", "transactionComplete", "(", ")", "{", "super", ".", "transactionComplete", "(", ")", ";", "if", "(", "success", ")", "{", "connect", "(", "this", ".", "token", ",", "initialPresence", ",", "appContext", ",", "new", "ConnectCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "connectionInProgress", "=", "false", ";", "postConnectError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "else", "{", "connectionInProgress", "=", "false", ";", "postConnectError", "(", "completionListener", ",", "this", ".", "errorMessage", ")", ";", "}", "}", "}", ";", "request", ".", "appID", "=", "appID", ";", "request", ".", "endpointID", "=", "endpointID", ";", "request", ".", "go", "(", ")", ";", "}", "else", "{", "postConnectError", "(", "completionListener", ",", "\"AppID and endpointID must be specified\"", ")", ";", "}", "}" ]
Connect to the Respoke infrastructure and authenticate in development mode using the specified endpoint ID and app ID. Attempt to obtain an authentication token automatically from the Respoke infrastructure. @param endpointID The endpoint ID to use when connecting @param appID Your Application ID @param shouldReconnect Whether or not to automatically reconnect to the Respoke service when a disconnect occurs. @param initialPresence The optional initial presence value to set for this client @param context An application context with which to access system resources @param completionListener A listener to be called when an error occurs, passing a string describing the error
[ "Connect", "to", "the", "Respoke", "infrastructure", "and", "authenticate", "in", "development", "mode", "using", "the", "specified", "endpoint", "ID", "and", "app", "ID", ".", "Attempt", "to", "obtain", "an", "authentication", "token", "automatically", "from", "the", "Respoke", "infrastructure", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L297-L332
145,588
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.connect
public void connect(String tokenID, final Object initialPresence, Context context, final ConnectCompletionListener completionListener) { if ((tokenID != null) && (tokenID.length() > 0)) { connectionInProgress = true; appContext = context; APIDoOpen request = new APIDoOpen(context, baseURL) { @Override public void transactionComplete() { super.transactionComplete(); if (success) { // Remember the presence value to set once connected presence = initialPresence; signalingChannel = new RespokeSignalingChannel(appToken, RespokeClient.this, baseURL, appContext); signalingChannel.authenticate(); } else { connectionInProgress = false; postConnectError(completionListener, this.errorMessage); } } }; request.tokenID = tokenID; request.go(); } else { postConnectError(completionListener, "TokenID must be specified"); } }
java
public void connect(String tokenID, final Object initialPresence, Context context, final ConnectCompletionListener completionListener) { if ((tokenID != null) && (tokenID.length() > 0)) { connectionInProgress = true; appContext = context; APIDoOpen request = new APIDoOpen(context, baseURL) { @Override public void transactionComplete() { super.transactionComplete(); if (success) { // Remember the presence value to set once connected presence = initialPresence; signalingChannel = new RespokeSignalingChannel(appToken, RespokeClient.this, baseURL, appContext); signalingChannel.authenticate(); } else { connectionInProgress = false; postConnectError(completionListener, this.errorMessage); } } }; request.tokenID = tokenID; request.go(); } else { postConnectError(completionListener, "TokenID must be specified"); } }
[ "public", "void", "connect", "(", "String", "tokenID", ",", "final", "Object", "initialPresence", ",", "Context", "context", ",", "final", "ConnectCompletionListener", "completionListener", ")", "{", "if", "(", "(", "tokenID", "!=", "null", ")", "&&", "(", "tokenID", ".", "length", "(", ")", ">", "0", ")", ")", "{", "connectionInProgress", "=", "true", ";", "appContext", "=", "context", ";", "APIDoOpen", "request", "=", "new", "APIDoOpen", "(", "context", ",", "baseURL", ")", "{", "@", "Override", "public", "void", "transactionComplete", "(", ")", "{", "super", ".", "transactionComplete", "(", ")", ";", "if", "(", "success", ")", "{", "// Remember the presence value to set once connected", "presence", "=", "initialPresence", ";", "signalingChannel", "=", "new", "RespokeSignalingChannel", "(", "appToken", ",", "RespokeClient", ".", "this", ",", "baseURL", ",", "appContext", ")", ";", "signalingChannel", ".", "authenticate", "(", ")", ";", "}", "else", "{", "connectionInProgress", "=", "false", ";", "postConnectError", "(", "completionListener", ",", "this", ".", "errorMessage", ")", ";", "}", "}", "}", ";", "request", ".", "tokenID", "=", "tokenID", ";", "request", ".", "go", "(", ")", ";", "}", "else", "{", "postConnectError", "(", "completionListener", ",", "\"TokenID must be specified\"", ")", ";", "}", "}" ]
Connect to the Respoke infrastructure and authenticate with the specified brokered auth token ID. @param tokenID The token ID to use when connecting @param initialPresence The optional initial presence value to set for this client @param context An application context with which to access system resources @param completionListener A listener to be called when an error occurs, passing a string describing the error
[ "Connect", "to", "the", "Respoke", "infrastructure", "and", "authenticate", "with", "the", "specified", "brokered", "auth", "token", "ID", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L342-L371
145,589
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.joinGroups
public void joinGroups(final ArrayList<String> groupIDList, final JoinGroupCompletionListener completionListener) { if (isConnected()) { if ((groupIDList != null) && (groupIDList.size() > 0)) { String urlEndpoint = "/v1/groups"; JSONArray groupList = new JSONArray(groupIDList); JSONObject data = new JSONObject(); try { data.put("groups", groupList); signalingChannel.sendRESTMessage("post", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { final ArrayList<RespokeGroup> newGroupList = new ArrayList<RespokeGroup>(); for (String eachGroupID : groupIDList) { RespokeGroup newGroup = new RespokeGroup(eachGroupID, signalingChannel, RespokeClient.this); groups.put(eachGroupID, newGroup); newGroupList.add(newGroup); } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(newGroupList); } } }); } @Override public void onError(final String errorMessage) { postJoinGroupMembersError(completionListener, errorMessage); } }); } catch (JSONException e) { postJoinGroupMembersError(completionListener, "Error encoding group list to json"); } } else { postJoinGroupMembersError(completionListener, "At least one group must be specified"); } } else { postJoinGroupMembersError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
java
public void joinGroups(final ArrayList<String> groupIDList, final JoinGroupCompletionListener completionListener) { if (isConnected()) { if ((groupIDList != null) && (groupIDList.size() > 0)) { String urlEndpoint = "/v1/groups"; JSONArray groupList = new JSONArray(groupIDList); JSONObject data = new JSONObject(); try { data.put("groups", groupList); signalingChannel.sendRESTMessage("post", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { final ArrayList<RespokeGroup> newGroupList = new ArrayList<RespokeGroup>(); for (String eachGroupID : groupIDList) { RespokeGroup newGroup = new RespokeGroup(eachGroupID, signalingChannel, RespokeClient.this); groups.put(eachGroupID, newGroup); newGroupList.add(newGroup); } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(newGroupList); } } }); } @Override public void onError(final String errorMessage) { postJoinGroupMembersError(completionListener, errorMessage); } }); } catch (JSONException e) { postJoinGroupMembersError(completionListener, "Error encoding group list to json"); } } else { postJoinGroupMembersError(completionListener, "At least one group must be specified"); } } else { postJoinGroupMembersError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
[ "public", "void", "joinGroups", "(", "final", "ArrayList", "<", "String", ">", "groupIDList", ",", "final", "JoinGroupCompletionListener", "completionListener", ")", "{", "if", "(", "isConnected", "(", ")", ")", "{", "if", "(", "(", "groupIDList", "!=", "null", ")", "&&", "(", "groupIDList", ".", "size", "(", ")", ">", "0", ")", ")", "{", "String", "urlEndpoint", "=", "\"/v1/groups\"", ";", "JSONArray", "groupList", "=", "new", "JSONArray", "(", "groupIDList", ")", ";", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "data", ".", "put", "(", "\"groups\"", ",", "groupList", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "urlEndpoint", ",", "data", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "final", "ArrayList", "<", "RespokeGroup", ">", "newGroupList", "=", "new", "ArrayList", "<", "RespokeGroup", ">", "(", ")", ";", "for", "(", "String", "eachGroupID", ":", "groupIDList", ")", "{", "RespokeGroup", "newGroup", "=", "new", "RespokeGroup", "(", "eachGroupID", ",", "signalingChannel", ",", "RespokeClient", ".", "this", ")", ";", "groups", ".", "put", "(", "eachGroupID", ",", "newGroup", ")", ";", "newGroupList", ".", "add", "(", "newGroup", ")", ";", "}", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onSuccess", "(", "newGroupList", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "postJoinGroupMembersError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "postJoinGroupMembersError", "(", "completionListener", ",", "\"Error encoding group list to json\"", ")", ";", "}", "}", "else", "{", "postJoinGroupMembersError", "(", "completionListener", ",", "\"At least one group must be specified\"", ")", ";", "}", "}", "else", "{", "postJoinGroupMembersError", "(", "completionListener", ",", "\"Can't complete request when not connected. Please reconnect!\"", ")", ";", "}", "}" ]
Join a list of Groups and begin keeping track of them. @param groupIDList An array of IDs of the groups to join @param completionListener A listener to receive a notification of the success or failure of the asynchronous operation
[ "Join", "a", "list", "of", "Groups", "and", "begin", "keeping", "track", "of", "them", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L399-L443
145,590
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getConnection
public RespokeConnection getConnection(String connectionID, String endpointID, boolean skipCreate) { RespokeConnection connection = null; if (null != connectionID) { RespokeEndpoint endpoint = getEndpoint(endpointID, skipCreate); if (null != endpoint) { for (RespokeConnection eachConnection : endpoint.connections) { if (eachConnection.connectionID.equals(connectionID)) { connection = eachConnection; break; } } if ((null == connection) && (!skipCreate)) { connection = new RespokeConnection(connectionID, endpoint); endpoint.connections.add(connection); } } } return connection; }
java
public RespokeConnection getConnection(String connectionID, String endpointID, boolean skipCreate) { RespokeConnection connection = null; if (null != connectionID) { RespokeEndpoint endpoint = getEndpoint(endpointID, skipCreate); if (null != endpoint) { for (RespokeConnection eachConnection : endpoint.connections) { if (eachConnection.connectionID.equals(connectionID)) { connection = eachConnection; break; } } if ((null == connection) && (!skipCreate)) { connection = new RespokeConnection(connectionID, endpoint); endpoint.connections.add(connection); } } } return connection; }
[ "public", "RespokeConnection", "getConnection", "(", "String", "connectionID", ",", "String", "endpointID", ",", "boolean", "skipCreate", ")", "{", "RespokeConnection", "connection", "=", "null", ";", "if", "(", "null", "!=", "connectionID", ")", "{", "RespokeEndpoint", "endpoint", "=", "getEndpoint", "(", "endpointID", ",", "skipCreate", ")", ";", "if", "(", "null", "!=", "endpoint", ")", "{", "for", "(", "RespokeConnection", "eachConnection", ":", "endpoint", ".", "connections", ")", "{", "if", "(", "eachConnection", ".", "connectionID", ".", "equals", "(", "connectionID", ")", ")", "{", "connection", "=", "eachConnection", ";", "break", ";", "}", "}", "if", "(", "(", "null", "==", "connection", ")", "&&", "(", "!", "skipCreate", ")", ")", "{", "connection", "=", "new", "RespokeConnection", "(", "connectionID", ",", "endpoint", ")", ";", "endpoint", ".", "connections", ".", "add", "(", "connection", ")", ";", "}", "}", "}", "return", "connection", ";", "}" ]
Find a Connection by id and return it. In most cases, if we don't find it we will create it. This is useful in the case of dynamic endpoints where groups are not in use. Set skipCreate=true to return null if the Connection is not already known. @param connectionID The ID of the connection to return @param endpointID The ID of the endpoint to which this connection belongs @param skipCreate If true, return null if the connection is not already known @return The connection whose ID was specified
[ "Find", "a", "Connection", "by", "id", "and", "return", "it", ".", "In", "most", "cases", "if", "we", "don", "t", "find", "it", "we", "will", "create", "it", ".", "This", "is", "useful", "in", "the", "case", "of", "dynamic", "endpoints", "where", "groups", "are", "not", "in", "use", ".", "Set", "skipCreate", "=", "true", "to", "return", "null", "if", "the", "Connection", "is", "not", "already", "known", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L456-L478
145,591
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.joinConference
public RespokeCall joinConference(RespokeCall.Listener callListener, Context context, String conferenceID) { RespokeCall call = null; if ((null != signalingChannel) && (signalingChannel.connected)) { call = new RespokeCall(signalingChannel, conferenceID, "conference"); call.setListener(callListener); call.startCall(context, null, true); } return call; }
java
public RespokeCall joinConference(RespokeCall.Listener callListener, Context context, String conferenceID) { RespokeCall call = null; if ((null != signalingChannel) && (signalingChannel.connected)) { call = new RespokeCall(signalingChannel, conferenceID, "conference"); call.setListener(callListener); call.startCall(context, null, true); } return call; }
[ "public", "RespokeCall", "joinConference", "(", "RespokeCall", ".", "Listener", "callListener", ",", "Context", "context", ",", "String", "conferenceID", ")", "{", "RespokeCall", "call", "=", "null", ";", "if", "(", "(", "null", "!=", "signalingChannel", ")", "&&", "(", "signalingChannel", ".", "connected", ")", ")", "{", "call", "=", "new", "RespokeCall", "(", "signalingChannel", ",", "conferenceID", ",", "\"conference\"", ")", ";", "call", ".", "setListener", "(", "callListener", ")", ";", "call", ".", "startCall", "(", "context", ",", "null", ",", "true", ")", ";", "}", "return", "call", ";", "}" ]
Initiate a call to a conference. @param callListener A listener to receive notifications about the new call @param context An application context with which to access system resources @param conferenceID The ID of the conference to call @return A reference to the new RespokeCall object representing this call
[ "Initiate", "a", "call", "to", "a", "conference", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L489-L500
145,592
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getEndpoint
public RespokeEndpoint getEndpoint(String endpointIDToFind, boolean skipCreate) { RespokeEndpoint endpoint = null; if (null != endpointIDToFind) { for (RespokeEndpoint eachEndpoint : knownEndpoints) { if (eachEndpoint.getEndpointID().equals(endpointIDToFind)) { endpoint = eachEndpoint; break; } } if ((null == endpoint) && (!skipCreate)) { endpoint = new RespokeEndpoint(signalingChannel, endpointIDToFind, this); knownEndpoints.add(endpoint); } if (null != endpoint) { queuePresenceRegistration(endpoint.getEndpointID()); } } return endpoint; }
java
public RespokeEndpoint getEndpoint(String endpointIDToFind, boolean skipCreate) { RespokeEndpoint endpoint = null; if (null != endpointIDToFind) { for (RespokeEndpoint eachEndpoint : knownEndpoints) { if (eachEndpoint.getEndpointID().equals(endpointIDToFind)) { endpoint = eachEndpoint; break; } } if ((null == endpoint) && (!skipCreate)) { endpoint = new RespokeEndpoint(signalingChannel, endpointIDToFind, this); knownEndpoints.add(endpoint); } if (null != endpoint) { queuePresenceRegistration(endpoint.getEndpointID()); } } return endpoint; }
[ "public", "RespokeEndpoint", "getEndpoint", "(", "String", "endpointIDToFind", ",", "boolean", "skipCreate", ")", "{", "RespokeEndpoint", "endpoint", "=", "null", ";", "if", "(", "null", "!=", "endpointIDToFind", ")", "{", "for", "(", "RespokeEndpoint", "eachEndpoint", ":", "knownEndpoints", ")", "{", "if", "(", "eachEndpoint", ".", "getEndpointID", "(", ")", ".", "equals", "(", "endpointIDToFind", ")", ")", "{", "endpoint", "=", "eachEndpoint", ";", "break", ";", "}", "}", "if", "(", "(", "null", "==", "endpoint", ")", "&&", "(", "!", "skipCreate", ")", ")", "{", "endpoint", "=", "new", "RespokeEndpoint", "(", "signalingChannel", ",", "endpointIDToFind", ",", "this", ")", ";", "knownEndpoints", ".", "add", "(", "endpoint", ")", ";", "}", "if", "(", "null", "!=", "endpoint", ")", "{", "queuePresenceRegistration", "(", "endpoint", ".", "getEndpointID", "(", ")", ")", ";", "}", "}", "return", "endpoint", ";", "}" ]
Find an endpoint by id and return it. In most cases, if we don't find it we will create it. This is useful in the case of dynamic endpoints where groups are not in use. Set skipCreate=true to return null if the Endpoint is not already known. @param endpointIDToFind The ID of the endpoint to return @param skipCreate If true, return null if the connection is not already known @return The endpoint whose ID was specified
[ "Find", "an", "endpoint", "by", "id", "and", "return", "it", ".", "In", "most", "cases", "if", "we", "don", "t", "find", "it", "we", "will", "create", "it", ".", "This", "is", "useful", "in", "the", "case", "of", "dynamic", "endpoints", "where", "groups", "are", "not", "in", "use", ".", "Set", "skipCreate", "=", "true", "to", "return", "null", "if", "the", "Endpoint", "is", "not", "already", "known", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L512-L534
145,593
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getGroup
public RespokeGroup getGroup(String groupIDToFind) { RespokeGroup group = null; if (null != groupIDToFind) { group = groups.get(groupIDToFind); } return group; }
java
public RespokeGroup getGroup(String groupIDToFind) { RespokeGroup group = null; if (null != groupIDToFind) { group = groups.get(groupIDToFind); } return group; }
[ "public", "RespokeGroup", "getGroup", "(", "String", "groupIDToFind", ")", "{", "RespokeGroup", "group", "=", "null", ";", "if", "(", "null", "!=", "groupIDToFind", ")", "{", "group", "=", "groups", ".", "get", "(", "groupIDToFind", ")", ";", "}", "return", "group", ";", "}" ]
Returns the group with the specified ID @param groupIDToFind The ID of the group to find @return The group with specified ID, or null if it was not found
[ "Returns", "the", "group", "with", "the", "specified", "ID" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L543-L551
145,594
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getGroupHistories
public void getGroupHistories(final List<String> groupIds, final Integer maxMessages, final GroupHistoriesCompletionListener completionListener) { if (!isConnected()) { getGroupHistoriesError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((maxMessages == null) || (maxMessages < 1)) { getGroupHistoriesError(completionListener, "maxMessages must be at least 1"); return; } if ((groupIds == null) || (groupIds.size() == 0)) { getGroupHistoriesError(completionListener, "At least 1 group must be specified"); return; } JSONObject body = new JSONObject(); try { body.put("limit", maxMessages.toString()); JSONArray groupIdParams = new JSONArray(groupIds); body.put("groupIds", groupIdParams); } catch(JSONException e) { getGroupHistoriesError(completionListener, "Error forming JSON body to send."); return; } // This has been modifed to use the newer group-history-search route over the // deprecated group-histories route. String urlEndpoint = "/v1/group-history-search"; signalingChannel.sendRESTMessage("post", urlEndpoint, body, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { if (!(response instanceof JSONObject)) { getGroupHistoriesError(completionListener, "Invalid response from server"); return; } final JSONObject json = (JSONObject) response; final HashMap<String, List<RespokeGroupMessage>> results = new HashMap<>(); for (Iterator<String> keys = json.keys(); keys.hasNext();) { final String key = keys.next(); try { final JSONArray jsonMessages = json.getJSONArray(key); final ArrayList<RespokeGroupMessage> messageList = new ArrayList<>(jsonMessages.length()); for (int i = 0; i < jsonMessages.length(); i++) { final JSONObject jsonMessage = jsonMessages.getJSONObject(i); final RespokeGroupMessage message = buildGroupMessage(jsonMessage); messageList.add(message); } results.put(key, messageList); } catch (JSONException e) { getGroupHistoriesError(completionListener, "Error parsing JSON response"); return; } } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(results); } } }); } @Override public void onError(final String errorMessage) { getGroupHistoriesError(completionListener, errorMessage); } }); }
java
public void getGroupHistories(final List<String> groupIds, final Integer maxMessages, final GroupHistoriesCompletionListener completionListener) { if (!isConnected()) { getGroupHistoriesError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((maxMessages == null) || (maxMessages < 1)) { getGroupHistoriesError(completionListener, "maxMessages must be at least 1"); return; } if ((groupIds == null) || (groupIds.size() == 0)) { getGroupHistoriesError(completionListener, "At least 1 group must be specified"); return; } JSONObject body = new JSONObject(); try { body.put("limit", maxMessages.toString()); JSONArray groupIdParams = new JSONArray(groupIds); body.put("groupIds", groupIdParams); } catch(JSONException e) { getGroupHistoriesError(completionListener, "Error forming JSON body to send."); return; } // This has been modifed to use the newer group-history-search route over the // deprecated group-histories route. String urlEndpoint = "/v1/group-history-search"; signalingChannel.sendRESTMessage("post", urlEndpoint, body, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { if (!(response instanceof JSONObject)) { getGroupHistoriesError(completionListener, "Invalid response from server"); return; } final JSONObject json = (JSONObject) response; final HashMap<String, List<RespokeGroupMessage>> results = new HashMap<>(); for (Iterator<String> keys = json.keys(); keys.hasNext();) { final String key = keys.next(); try { final JSONArray jsonMessages = json.getJSONArray(key); final ArrayList<RespokeGroupMessage> messageList = new ArrayList<>(jsonMessages.length()); for (int i = 0; i < jsonMessages.length(); i++) { final JSONObject jsonMessage = jsonMessages.getJSONObject(i); final RespokeGroupMessage message = buildGroupMessage(jsonMessage); messageList.add(message); } results.put(key, messageList); } catch (JSONException e) { getGroupHistoriesError(completionListener, "Error parsing JSON response"); return; } } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(results); } } }); } @Override public void onError(final String errorMessage) { getGroupHistoriesError(completionListener, errorMessage); } }); }
[ "public", "void", "getGroupHistories", "(", "final", "List", "<", "String", ">", "groupIds", ",", "final", "Integer", "maxMessages", ",", "final", "GroupHistoriesCompletionListener", "completionListener", ")", "{", "if", "(", "!", "isConnected", "(", ")", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"Can't complete request when not connected, \"", "+", "\"Please reconnect!\"", ")", ";", "return", ";", "}", "if", "(", "(", "maxMessages", "==", "null", ")", "||", "(", "maxMessages", "<", "1", ")", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"maxMessages must be at least 1\"", ")", ";", "return", ";", "}", "if", "(", "(", "groupIds", "==", "null", ")", "||", "(", "groupIds", ".", "size", "(", ")", "==", "0", ")", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"At least 1 group must be specified\"", ")", ";", "return", ";", "}", "JSONObject", "body", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "body", ".", "put", "(", "\"limit\"", ",", "maxMessages", ".", "toString", "(", ")", ")", ";", "JSONArray", "groupIdParams", "=", "new", "JSONArray", "(", "groupIds", ")", ";", "body", ".", "put", "(", "\"groupIds\"", ",", "groupIdParams", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"Error forming JSON body to send.\"", ")", ";", "return", ";", "}", "// This has been modifed to use the newer group-history-search route over the", "// deprecated group-histories route.", "String", "urlEndpoint", "=", "\"/v1/group-history-search\"", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "urlEndpoint", ",", "body", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "if", "(", "!", "(", "response", "instanceof", "JSONObject", ")", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"Invalid response from server\"", ")", ";", "return", ";", "}", "final", "JSONObject", "json", "=", "(", "JSONObject", ")", "response", ";", "final", "HashMap", "<", "String", ",", "List", "<", "RespokeGroupMessage", ">", ">", "results", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "keys", "=", "json", ".", "keys", "(", ")", ";", "keys", ".", "hasNext", "(", ")", ";", ")", "{", "final", "String", "key", "=", "keys", ".", "next", "(", ")", ";", "try", "{", "final", "JSONArray", "jsonMessages", "=", "json", ".", "getJSONArray", "(", "key", ")", ";", "final", "ArrayList", "<", "RespokeGroupMessage", ">", "messageList", "=", "new", "ArrayList", "<>", "(", "jsonMessages", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "jsonMessages", ".", "length", "(", ")", ";", "i", "++", ")", "{", "final", "JSONObject", "jsonMessage", "=", "jsonMessages", ".", "getJSONObject", "(", "i", ")", ";", "final", "RespokeGroupMessage", "message", "=", "buildGroupMessage", "(", "jsonMessage", ")", ";", "messageList", ".", "add", "(", "message", ")", ";", "}", "results", ".", "put", "(", "key", ",", "messageList", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "\"Error parsing JSON response\"", ")", ";", "return", ";", "}", "}", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "completionListener", "!=", "null", ")", "{", "completionListener", ".", "onSuccess", "(", "results", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "getGroupHistoriesError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}" ]
Retrieve the history of messages that have been persisted for 1 or more groups. Only those messages that have been marked to be persisted when sent will show up in the history. Note: This operation returns history for a set of specified groups. If you simply want the set of conversations that the connected endpoint has stored on the server (without needing to specify the groups), use the getConversations() method. @param groupIds The groups to pull history for @param maxMessages The maximum number of messages per group to pull. Must be &gt;= 1 @param completionListener The callback called when this async operation has completed
[ "Retrieve", "the", "history", "of", "messages", "that", "have", "been", "persisted", "for", "1", "or", "more", "groups", ".", "Only", "those", "messages", "that", "have", "been", "marked", "to", "be", "persisted", "when", "sent", "will", "show", "up", "in", "the", "history", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L579-L659
145,595
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.setConversationsRead
public void setConversationsRead(final List<RespokeConversationReadStatus> updates, final Respoke.TaskCompletionListener completionListener) { if (!isConnected()) { Respoke.postTaskError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((updates == null) || (updates.size() == 0)) { Respoke.postTaskError(completionListener, "At least 1 conversation must be specified"); return; } JSONObject body = new JSONObject(); JSONArray groupsJsonArray = new JSONArray(); try { // Add each status object to the array. for (RespokeConversationReadStatus status : updates) { JSONObject jsonStatus = new JSONObject(); jsonStatus.put("groupId", status.groupId); jsonStatus.put("timestamp", status.timestamp.toString()); groupsJsonArray.put(jsonStatus); } // Set the array to the 'groups' property. body.put("groups", groupsJsonArray); } catch(JSONException e) { Respoke.postTaskError(completionListener, "Error forming JSON body to send."); return; } String urlEndpoint = "/v1/endpoints/" + localEndpointID + "/conversations"; signalingChannel.sendRESTMessage("put", urlEndpoint, body, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(); } } }); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); }
java
public void setConversationsRead(final List<RespokeConversationReadStatus> updates, final Respoke.TaskCompletionListener completionListener) { if (!isConnected()) { Respoke.postTaskError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((updates == null) || (updates.size() == 0)) { Respoke.postTaskError(completionListener, "At least 1 conversation must be specified"); return; } JSONObject body = new JSONObject(); JSONArray groupsJsonArray = new JSONArray(); try { // Add each status object to the array. for (RespokeConversationReadStatus status : updates) { JSONObject jsonStatus = new JSONObject(); jsonStatus.put("groupId", status.groupId); jsonStatus.put("timestamp", status.timestamp.toString()); groupsJsonArray.put(jsonStatus); } // Set the array to the 'groups' property. body.put("groups", groupsJsonArray); } catch(JSONException e) { Respoke.postTaskError(completionListener, "Error forming JSON body to send."); return; } String urlEndpoint = "/v1/endpoints/" + localEndpointID + "/conversations"; signalingChannel.sendRESTMessage("put", urlEndpoint, body, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(); } } }); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); }
[ "public", "void", "setConversationsRead", "(", "final", "List", "<", "RespokeConversationReadStatus", ">", "updates", ",", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "!", "isConnected", "(", ")", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Can't complete request when not connected, \"", "+", "\"Please reconnect!\"", ")", ";", "return", ";", "}", "if", "(", "(", "updates", "==", "null", ")", "||", "(", "updates", ".", "size", "(", ")", "==", "0", ")", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"At least 1 conversation must be specified\"", ")", ";", "return", ";", "}", "JSONObject", "body", "=", "new", "JSONObject", "(", ")", ";", "JSONArray", "groupsJsonArray", "=", "new", "JSONArray", "(", ")", ";", "try", "{", "// Add each status object to the array.", "for", "(", "RespokeConversationReadStatus", "status", ":", "updates", ")", "{", "JSONObject", "jsonStatus", "=", "new", "JSONObject", "(", ")", ";", "jsonStatus", ".", "put", "(", "\"groupId\"", ",", "status", ".", "groupId", ")", ";", "jsonStatus", ".", "put", "(", "\"timestamp\"", ",", "status", ".", "timestamp", ".", "toString", "(", ")", ")", ";", "groupsJsonArray", ".", "put", "(", "jsonStatus", ")", ";", "}", "// Set the array to the 'groups' property.", "body", ".", "put", "(", "\"groups\"", ",", "groupsJsonArray", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error forming JSON body to send.\"", ")", ";", "return", ";", "}", "String", "urlEndpoint", "=", "\"/v1/endpoints/\"", "+", "localEndpointID", "+", "\"/conversations\"", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"put\"", ",", "urlEndpoint", ",", "body", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "completionListener", "!=", "null", ")", "{", "completionListener", ".", "onSuccess", "(", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}" ]
Mark messages in a conversation as having been read, up to the given timestamp @param updates An array of records, each of which indicates a groupId and timestamp of the the most recent message the client has "read". @param completionListener The callback called when this async operation has completed.
[ "Mark", "messages", "in", "a", "conversation", "as", "having", "been", "read", "up", "to", "the", "given", "timestamp" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L735-L787
145,596
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getGroupHistory
public void getGroupHistory(final String groupId, final Integer maxMessages, final GroupHistoryCompletionListener completionListener) { getGroupHistory(groupId, maxMessages, null, completionListener); }
java
public void getGroupHistory(final String groupId, final Integer maxMessages, final GroupHistoryCompletionListener completionListener) { getGroupHistory(groupId, maxMessages, null, completionListener); }
[ "public", "void", "getGroupHistory", "(", "final", "String", "groupId", ",", "final", "Integer", "maxMessages", ",", "final", "GroupHistoryCompletionListener", "completionListener", ")", "{", "getGroupHistory", "(", "groupId", ",", "maxMessages", ",", "null", ",", "completionListener", ")", ";", "}" ]
Retrieve the history of messages that have been persisted for a specific group. Only those messages that have been marked to be persisted when sent will show up in the history. To retrieve messages further back in the history than right now, use the other method signature that allows `before` to be specified. @param groupId The groups to pull history for @param maxMessages The maximum number of messages per group to pull. Must be &gt;= 1 @param completionListener The callback called when this async operation has completed
[ "Retrieve", "the", "history", "of", "messages", "that", "have", "been", "persisted", "for", "a", "specific", "group", ".", "Only", "those", "messages", "that", "have", "been", "marked", "to", "be", "persisted", "when", "sent", "will", "show", "up", "in", "the", "history", ".", "To", "retrieve", "messages", "further", "back", "in", "the", "history", "than", "right", "now", "use", "the", "other", "method", "signature", "that", "allows", "before", "to", "be", "specified", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L815-L818
145,597
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.getGroupHistory
public void getGroupHistory(final String groupId, final Integer maxMessages, final Date before, final GroupHistoryCompletionListener completionListener) { if (!isConnected()) { getGroupHistoryError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((maxMessages == null) || (maxMessages < 1)) { getGroupHistoryError(completionListener, "maxMessages must be at least 1"); return; } if ((groupId == null) || groupId.length() == 0) { getGroupHistoryError(completionListener, "groupId cannot be blank"); return; } Uri.Builder builder = new Uri.Builder(); builder.appendQueryParameter("limit", maxMessages.toString()); if (before != null) { builder.appendQueryParameter("before", Long.toString(before.getTime())); } String urlEndpoint = String.format("/v1/groups/%s/history%s", groupId, builder.build().toString()); signalingChannel.sendRESTMessage("get", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { if (!(response instanceof JSONArray)) { getGroupHistoryError(completionListener, "Invalid response from server"); return; } final JSONArray json = (JSONArray) response; final ArrayList<RespokeGroupMessage> results = new ArrayList<>(json.length()); try { for (int i = 0; i < json.length(); i++) { final JSONObject jsonMessage = json.getJSONObject(i); final RespokeGroupMessage message = buildGroupMessage(jsonMessage); results.add(message); } } catch (JSONException e) { getGroupHistoryError(completionListener, "Error parsing JSON response"); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(results); } } }); } @Override public void onError(final String errorMessage) { getGroupHistoryError(completionListener, errorMessage); } }); }
java
public void getGroupHistory(final String groupId, final Integer maxMessages, final Date before, final GroupHistoryCompletionListener completionListener) { if (!isConnected()) { getGroupHistoryError(completionListener, "Can't complete request when not connected, " + "Please reconnect!"); return; } if ((maxMessages == null) || (maxMessages < 1)) { getGroupHistoryError(completionListener, "maxMessages must be at least 1"); return; } if ((groupId == null) || groupId.length() == 0) { getGroupHistoryError(completionListener, "groupId cannot be blank"); return; } Uri.Builder builder = new Uri.Builder(); builder.appendQueryParameter("limit", maxMessages.toString()); if (before != null) { builder.appendQueryParameter("before", Long.toString(before.getTime())); } String urlEndpoint = String.format("/v1/groups/%s/history%s", groupId, builder.build().toString()); signalingChannel.sendRESTMessage("get", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { if (!(response instanceof JSONArray)) { getGroupHistoryError(completionListener, "Invalid response from server"); return; } final JSONArray json = (JSONArray) response; final ArrayList<RespokeGroupMessage> results = new ArrayList<>(json.length()); try { for (int i = 0; i < json.length(); i++) { final JSONObject jsonMessage = json.getJSONObject(i); final RespokeGroupMessage message = buildGroupMessage(jsonMessage); results.add(message); } } catch (JSONException e) { getGroupHistoryError(completionListener, "Error parsing JSON response"); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (completionListener != null) { completionListener.onSuccess(results); } } }); } @Override public void onError(final String errorMessage) { getGroupHistoryError(completionListener, errorMessage); } }); }
[ "public", "void", "getGroupHistory", "(", "final", "String", "groupId", ",", "final", "Integer", "maxMessages", ",", "final", "Date", "before", ",", "final", "GroupHistoryCompletionListener", "completionListener", ")", "{", "if", "(", "!", "isConnected", "(", ")", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "\"Can't complete request when not connected, \"", "+", "\"Please reconnect!\"", ")", ";", "return", ";", "}", "if", "(", "(", "maxMessages", "==", "null", ")", "||", "(", "maxMessages", "<", "1", ")", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "\"maxMessages must be at least 1\"", ")", ";", "return", ";", "}", "if", "(", "(", "groupId", "==", "null", ")", "||", "groupId", ".", "length", "(", ")", "==", "0", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "\"groupId cannot be blank\"", ")", ";", "return", ";", "}", "Uri", ".", "Builder", "builder", "=", "new", "Uri", ".", "Builder", "(", ")", ";", "builder", ".", "appendQueryParameter", "(", "\"limit\"", ",", "maxMessages", ".", "toString", "(", ")", ")", ";", "if", "(", "before", "!=", "null", ")", "{", "builder", ".", "appendQueryParameter", "(", "\"before\"", ",", "Long", ".", "toString", "(", "before", ".", "getTime", "(", ")", ")", ")", ";", "}", "String", "urlEndpoint", "=", "String", ".", "format", "(", "\"/v1/groups/%s/history%s\"", ",", "groupId", ",", "builder", ".", "build", "(", ")", ".", "toString", "(", ")", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"get\"", ",", "urlEndpoint", ",", "null", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "if", "(", "!", "(", "response", "instanceof", "JSONArray", ")", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "\"Invalid response from server\"", ")", ";", "return", ";", "}", "final", "JSONArray", "json", "=", "(", "JSONArray", ")", "response", ";", "final", "ArrayList", "<", "RespokeGroupMessage", ">", "results", "=", "new", "ArrayList", "<>", "(", "json", ".", "length", "(", ")", ")", ";", "try", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "json", ".", "length", "(", ")", ";", "i", "++", ")", "{", "final", "JSONObject", "jsonMessage", "=", "json", ".", "getJSONObject", "(", "i", ")", ";", "final", "RespokeGroupMessage", "message", "=", "buildGroupMessage", "(", "jsonMessage", ")", ";", "results", ".", "add", "(", "message", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "\"Error parsing JSON response\"", ")", ";", "return", ";", "}", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "completionListener", "!=", "null", ")", "{", "completionListener", ".", "onSuccess", "(", "results", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "getGroupHistoryError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}" ]
Retrieve the history of messages that have been persisted for a specific group. Only those messages that have been marked to be persisted when sent will show up in the history. @param groupId The groups to pull history for @param maxMessages The maximum number of messages per group to pull. Must be &gt;= 1 @param before Limit messages to those with a timestamp before this value @param completionListener The callback called when this async operation has completed
[ "Retrieve", "the", "history", "of", "messages", "that", "have", "been", "persisted", "for", "a", "specific", "group", ".", "Only", "those", "messages", "that", "have", "been", "marked", "to", "be", "persisted", "when", "sent", "will", "show", "up", "in", "the", "history", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L829-L893
145,598
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.setPresence
public void setPresence(Object newPresence, final Respoke.TaskCompletionListener completionListener) { if (isConnected()) { Object presenceToSet = newPresence; if (null == presenceToSet) { presenceToSet = "available"; } JSONObject typeData = new JSONObject(); JSONObject data = new JSONObject(); try { typeData.put("type", presenceToSet); data.put("presence", typeData); final Object finalPresence = presenceToSet; signalingChannel.sendRESTMessage("post", "/v1/presence", data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { presence = finalPresence; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding presence to json"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
java
public void setPresence(Object newPresence, final Respoke.TaskCompletionListener completionListener) { if (isConnected()) { Object presenceToSet = newPresence; if (null == presenceToSet) { presenceToSet = "available"; } JSONObject typeData = new JSONObject(); JSONObject data = new JSONObject(); try { typeData.put("type", presenceToSet); data.put("presence", typeData); final Object finalPresence = presenceToSet; signalingChannel.sendRESTMessage("post", "/v1/presence", data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { presence = finalPresence; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding presence to json"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
[ "public", "void", "setPresence", "(", "Object", "newPresence", ",", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "isConnected", "(", ")", ")", "{", "Object", "presenceToSet", "=", "newPresence", ";", "if", "(", "null", "==", "presenceToSet", ")", "{", "presenceToSet", "=", "\"available\"", ";", "}", "JSONObject", "typeData", "=", "new", "JSONObject", "(", ")", ";", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "typeData", ".", "put", "(", "\"type\"", ",", "presenceToSet", ")", ";", "data", ".", "put", "(", "\"presence\"", ",", "typeData", ")", ";", "final", "Object", "finalPresence", "=", "presenceToSet", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "\"/v1/presence\"", ",", "data", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "presence", "=", "finalPresence", ";", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error encoding presence to json\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Can't complete request when not connected. Please reconnect!\"", ")", ";", "}", "}" ]
Set the presence on the client session @param newPresence The new presence to use @param completionListener A listener to receive the notification on the success or failure of the asynchronous operation
[ "Set", "the", "presence", "on", "the", "client", "session" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L910-L946
145,599
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.registerPushServicesWithToken
public void registerPushServicesWithToken(final String token) { String httpURI; String httpMethod; JSONObject data = new JSONObject(); try { data.put("token", token); data.put("service", "google"); SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); if (null != prefs) { String lastKnownPushToken = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN, "notAvailable"); String lastKnownPushTokenID = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN_ID, "notAvailable"); if ((null == lastKnownPushTokenID) || (lastKnownPushTokenID.equals("notAvailable"))) { httpURI = String.format("/v1/connections/%s/push-token", localConnectionID); httpMethod = "post"; createOrUpdatePushServiceToken(token, httpURI, httpMethod, data, prefs); } else if (!lastKnownPushToken.equals("notAvailable") && !lastKnownPushToken.equals(token)) { httpURI = String.format("/v1/connections/%s/push-token/%s", localConnectionID, lastKnownPushTokenID); httpMethod = "put"; createOrUpdatePushServiceToken(token, httpURI, httpMethod, data, prefs); } } } catch(JSONException e) { Log.d("", "Invalid JSON format for token"); } }
java
public void registerPushServicesWithToken(final String token) { String httpURI; String httpMethod; JSONObject data = new JSONObject(); try { data.put("token", token); data.put("service", "google"); SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); if (null != prefs) { String lastKnownPushToken = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN, "notAvailable"); String lastKnownPushTokenID = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN_ID, "notAvailable"); if ((null == lastKnownPushTokenID) || (lastKnownPushTokenID.equals("notAvailable"))) { httpURI = String.format("/v1/connections/%s/push-token", localConnectionID); httpMethod = "post"; createOrUpdatePushServiceToken(token, httpURI, httpMethod, data, prefs); } else if (!lastKnownPushToken.equals("notAvailable") && !lastKnownPushToken.equals(token)) { httpURI = String.format("/v1/connections/%s/push-token/%s", localConnectionID, lastKnownPushTokenID); httpMethod = "put"; createOrUpdatePushServiceToken(token, httpURI, httpMethod, data, prefs); } } } catch(JSONException e) { Log.d("", "Invalid JSON format for token"); } }
[ "public", "void", "registerPushServicesWithToken", "(", "final", "String", "token", ")", "{", "String", "httpURI", ";", "String", "httpMethod", ";", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "data", ".", "put", "(", "\"token\"", ",", "token", ")", ";", "data", ".", "put", "(", "\"service\"", ",", "\"google\"", ")", ";", "SharedPreferences", "prefs", "=", "appContext", ".", "getSharedPreferences", "(", "appContext", ".", "getPackageName", "(", ")", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "if", "(", "null", "!=", "prefs", ")", "{", "String", "lastKnownPushToken", "=", "prefs", ".", "getString", "(", "PROPERTY_LAST_VALID_PUSH_TOKEN", ",", "\"notAvailable\"", ")", ";", "String", "lastKnownPushTokenID", "=", "prefs", ".", "getString", "(", "PROPERTY_LAST_VALID_PUSH_TOKEN_ID", ",", "\"notAvailable\"", ")", ";", "if", "(", "(", "null", "==", "lastKnownPushTokenID", ")", "||", "(", "lastKnownPushTokenID", ".", "equals", "(", "\"notAvailable\"", ")", ")", ")", "{", "httpURI", "=", "String", ".", "format", "(", "\"/v1/connections/%s/push-token\"", ",", "localConnectionID", ")", ";", "httpMethod", "=", "\"post\"", ";", "createOrUpdatePushServiceToken", "(", "token", ",", "httpURI", ",", "httpMethod", ",", "data", ",", "prefs", ")", ";", "}", "else", "if", "(", "!", "lastKnownPushToken", ".", "equals", "(", "\"notAvailable\"", ")", "&&", "!", "lastKnownPushToken", ".", "equals", "(", "token", ")", ")", "{", "httpURI", "=", "String", ".", "format", "(", "\"/v1/connections/%s/push-token/%s\"", ",", "localConnectionID", ",", "lastKnownPushTokenID", ")", ";", "httpMethod", "=", "\"put\"", ";", "createOrUpdatePushServiceToken", "(", "token", ",", "httpURI", ",", "httpMethod", ",", "data", ",", "prefs", ")", ";", "}", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "d", "(", "\"\"", ",", "\"Invalid JSON format for token\"", ")", ";", "}", "}" ]
Register the client to receive push notifications when the socket is not active @param token The GCMS token to register
[ "Register", "the", "client", "to", "receive", "push", "notifications", "when", "the", "socket", "is", "not", "active" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L962-L990