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
partition
stringclasses
1 value
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java
TopicAccessManager.checkAccessTopicGlobalAC
boolean checkAccessTopicGlobalAC(UserContext ctx, String topic) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from GlobalAccess", topic); Iterable<JsTopicAccessController> accessControls = topicAccessController.select(DEFAULT_AT); return checkAccessTopicFromControllers(ctx, topic, accessControls); }
java
boolean checkAccessTopicGlobalAC(UserContext ctx, String topic) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from GlobalAccess", topic); Iterable<JsTopicAccessController> accessControls = topicAccessController.select(DEFAULT_AT); return checkAccessTopicFromControllers(ctx, topic, accessControls); }
[ "boolean", "checkAccessTopicGlobalAC", "(", "UserContext", "ctx", ",", "String", "topic", ")", "throws", "IllegalAccessException", "{", "logger", ".", "debug", "(", "\"Looking for accessController for topic '{}' from GlobalAccess\"", ",", "topic", ")", ";", "Iterable", "<...
Check if global access control is allowed @param ctx @param topic @return true if at least one global topicAccessControl exist @throws IllegalAccessException
[ "Check", "if", "global", "access", "control", "is", "allowed" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java#L67-L71
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java
TopicAccessManager.checkAccessTopicFromJsTopicAccessControllers
boolean checkAccessTopicFromJsTopicAccessControllers(UserContext ctx, String topic, Iterable<JsTopicAccessController> controllers) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from JsTopicAccessControllers", topic); for (JsTopicAccessController jsTopicAccessController : controllers) { if(checkAccessTopicFromController(ctx, topic, jsTopicAccessController)) { return true; } } return false; }
java
boolean checkAccessTopicFromJsTopicAccessControllers(UserContext ctx, String topic, Iterable<JsTopicAccessController> controllers) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from JsTopicAccessControllers", topic); for (JsTopicAccessController jsTopicAccessController : controllers) { if(checkAccessTopicFromController(ctx, topic, jsTopicAccessController)) { return true; } } return false; }
[ "boolean", "checkAccessTopicFromJsTopicAccessControllers", "(", "UserContext", "ctx", ",", "String", "topic", ",", "Iterable", "<", "JsTopicAccessController", ">", "controllers", ")", "throws", "IllegalAccessException", "{", "logger", ".", "debug", "(", "\"Looking for acc...
Check if specific access control is allowed from controllers @param ctx @param topic @param controllers @return true if at least one specific topicAccessControl exist @throws IllegalAccessException
[ "Check", "if", "specific", "access", "control", "is", "allowed", "from", "controllers" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java#L110-L118
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java
TopicAccessManager.checkAccessTopicFromController
boolean checkAccessTopicFromController(UserContext ctx, String topic, JsTopicAccessController jsTopicAccessController) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from JsTopicAccessController {}", topic, jsTopicAccessController); JsTopicControls jsTopicControls = jsTopicControlsTools.getJsTopicControlsFromProxyClass(jsTopicAccessController.getClass()); logger.debug("Looking for accessController for topic '{}' from jsTopicControls {}", topic, jsTopicControls); if(null != jsTopicControls) { logger.debug("Looking for accessController for topic '{}' from jsTopicControls {}, {}", topic, jsTopicControls, jsTopicControls.value()); for (JsTopicControl jsTopicControl : jsTopicControls.value()) { if(topic.equals(jsTopicControl.value())) { logger.debug("Found accessController for topic '{}' from JsTopicControls annotation", topic); checkAccessTopicFromControllers(ctx, topic, Arrays.asList(jsTopicAccessController)); return true; } } } return false; }
java
boolean checkAccessTopicFromController(UserContext ctx, String topic, JsTopicAccessController jsTopicAccessController) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from JsTopicAccessController {}", topic, jsTopicAccessController); JsTopicControls jsTopicControls = jsTopicControlsTools.getJsTopicControlsFromProxyClass(jsTopicAccessController.getClass()); logger.debug("Looking for accessController for topic '{}' from jsTopicControls {}", topic, jsTopicControls); if(null != jsTopicControls) { logger.debug("Looking for accessController for topic '{}' from jsTopicControls {}, {}", topic, jsTopicControls, jsTopicControls.value()); for (JsTopicControl jsTopicControl : jsTopicControls.value()) { if(topic.equals(jsTopicControl.value())) { logger.debug("Found accessController for topic '{}' from JsTopicControls annotation", topic); checkAccessTopicFromControllers(ctx, topic, Arrays.asList(jsTopicAccessController)); return true; } } } return false; }
[ "boolean", "checkAccessTopicFromController", "(", "UserContext", "ctx", ",", "String", "topic", ",", "JsTopicAccessController", "jsTopicAccessController", ")", "throws", "IllegalAccessException", "{", "logger", ".", "debug", "(", "\"Looking for accessController for topic '{}' f...
Check if specific access control is allowed from controller @param ctx @param topic @param controllers @return true if at least one specific topicAccessControl exist @throws IllegalAccessException
[ "Check", "if", "specific", "access", "control", "is", "allowed", "from", "controller" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java#L128-L143
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java
TopicAccessManager.checkAccessTopicFromControllers
boolean checkAccessTopicFromControllers(UserContext ctx, String topic, Iterable<JsTopicAccessController> accessControls) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' : '{}'", topic, accessControls); boolean tacPresent = false; if (null != accessControls) { for (JsTopicAccessController accessControl : accessControls) { accessControl.checkAccess(ctx, topic); tacPresent = true; } } return tacPresent; }
java
boolean checkAccessTopicFromControllers(UserContext ctx, String topic, Iterable<JsTopicAccessController> accessControls) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' : '{}'", topic, accessControls); boolean tacPresent = false; if (null != accessControls) { for (JsTopicAccessController accessControl : accessControls) { accessControl.checkAccess(ctx, topic); tacPresent = true; } } return tacPresent; }
[ "boolean", "checkAccessTopicFromControllers", "(", "UserContext", "ctx", ",", "String", "topic", ",", "Iterable", "<", "JsTopicAccessController", ">", "accessControls", ")", "throws", "IllegalAccessException", "{", "logger", ".", "debug", "(", "\"Looking for accessControl...
Check if access topic is granted by accessControls @param ctx @param topic @param accessControls @return @throws IllegalAccessException
[ "Check", "if", "access", "topic", "is", "granted", "by", "accessControls" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/topicAccess/TopicAccessManager.java#L153-L163
train
ocelotds/ocelot
ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java
JsTopicInterceptor.isJsonPayload
boolean isJsonPayload(Method method) { if(null == method || !method.isAnnotationPresent(JsTopic.class) ) { return false; } JsTopic jsTopic = method.getAnnotation(JsTopic.class); return jsTopic.jsonPayload(); }
java
boolean isJsonPayload(Method method) { if(null == method || !method.isAnnotationPresent(JsTopic.class) ) { return false; } JsTopic jsTopic = method.getAnnotation(JsTopic.class); return jsTopic.jsonPayload(); }
[ "boolean", "isJsonPayload", "(", "Method", "method", ")", "{", "if", "(", "null", "==", "method", "||", "!", "method", ".", "isAnnotationPresent", "(", "JsTopic", ".", "class", ")", ")", "{", "return", "false", ";", "}", "JsTopic", "jsTopic", "=", "metho...
The topic receive directly payload in json @param method @return
[ "The", "topic", "receive", "directly", "payload", "in", "json" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java#L101-L107
train
ocelotds/ocelot
ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java
JsTopicInterceptor.getJsTopicNameAnnotation
JsTopicName getJsTopicNameAnnotation(Annotation[] parameterAnnotations) { for (Annotation parameterAnnotation : parameterAnnotations) { if (parameterAnnotation.annotationType().equals(JsTopicName.class)) { return (JsTopicName) parameterAnnotation; } } return null; }
java
JsTopicName getJsTopicNameAnnotation(Annotation[] parameterAnnotations) { for (Annotation parameterAnnotation : parameterAnnotations) { if (parameterAnnotation.annotationType().equals(JsTopicName.class)) { return (JsTopicName) parameterAnnotation; } } return null; }
[ "JsTopicName", "getJsTopicNameAnnotation", "(", "Annotation", "[", "]", "parameterAnnotations", ")", "{", "for", "(", "Annotation", "parameterAnnotation", ":", "parameterAnnotations", ")", "{", "if", "(", "parameterAnnotation", ".", "annotationType", "(", ")", ".", ...
Get JsTopicName annotation @param parameterAnnotations @param topic @return
[ "Get", "JsTopicName", "annotation" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java#L116-L123
train
ocelotds/ocelot
ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java
JsTopicInterceptor.computeTopic
String computeTopic(JsTopicName jsTopicName, String topic) { StringBuilder result = new StringBuilder(); if (!jsTopicName.prefix().isEmpty()) { result.append(jsTopicName.prefix()).append(Constants.Topic.COLON); } result.append(topic); if (!jsTopicName.postfix().isEmpty()) { result.append(Constants.Topic.COLON).append(jsTopicName.postfix()); } return result.toString(); }
java
String computeTopic(JsTopicName jsTopicName, String topic) { StringBuilder result = new StringBuilder(); if (!jsTopicName.prefix().isEmpty()) { result.append(jsTopicName.prefix()).append(Constants.Topic.COLON); } result.append(topic); if (!jsTopicName.postfix().isEmpty()) { result.append(Constants.Topic.COLON).append(jsTopicName.postfix()); } return result.toString(); }
[ "String", "computeTopic", "(", "JsTopicName", "jsTopicName", ",", "String", "topic", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "!", "jsTopicName", ".", "prefix", "(", ")", ".", "isEmpty", "(", ")", ")", "...
Compute full topicname from jsTopicName.prefix, topic and jsTopicName.postfix @param jsTopicName @param topic @return
[ "Compute", "full", "topicname", "from", "jsTopicName", ".", "prefix", "topic", "and", "jsTopicName", ".", "postfix" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java#L131-L141
train
ocelotds/ocelot
ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java
JsTopicInterceptor.proceedAndSendMessage
Object proceedAndSendMessage(InvocationContext ctx, String topic, boolean jsonPayload) throws Exception { MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(topic); Object result = ctx.proceed(); if(jsonPayload) { if(!String.class.isInstance(result)) { throw new UnsupportedOperationException("Method annotated JsTopic(jsonPayload=true) must return String type and correct Json."); } messageToClient.setJson((String) result); } else { messageToClient.setResponse(result); } wsEvent.fire(messageToClient); return result; }
java
Object proceedAndSendMessage(InvocationContext ctx, String topic, boolean jsonPayload) throws Exception { MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(topic); Object result = ctx.proceed(); if(jsonPayload) { if(!String.class.isInstance(result)) { throw new UnsupportedOperationException("Method annotated JsTopic(jsonPayload=true) must return String type and correct Json."); } messageToClient.setJson((String) result); } else { messageToClient.setResponse(result); } wsEvent.fire(messageToClient); return result; }
[ "Object", "proceedAndSendMessage", "(", "InvocationContext", "ctx", ",", "String", "topic", ",", "boolean", "jsonPayload", ")", "throws", "Exception", "{", "MessageToClient", "messageToClient", "=", "new", "MessageToClient", "(", ")", ";", "messageToClient", ".", "s...
Proceed the method and send MessageToClient to topic @param ctx @param topic @return @throws Exception
[ "Proceed", "the", "method", "and", "send", "MessageToClient", "to", "topic" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-core/src/main/java/org/ocelotds/messaging/JsTopicInterceptor.java#L150-L164
train
hageldave/ImagingKit
ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ComplexPixel.java
ComplexPixel.mult
public ComplexPixel mult(double r, double i){ double thisr = real(), thisi = imag(); return setComplex(thisr*r-thisi*i, thisr*i+thisi*r); }
java
public ComplexPixel mult(double r, double i){ double thisr = real(), thisi = imag(); return setComplex(thisr*r-thisi*i, thisr*i+thisi*r); }
[ "public", "ComplexPixel", "mult", "(", "double", "r", ",", "double", "i", ")", "{", "double", "thisr", "=", "real", "(", ")", ",", "thisi", "=", "imag", "(", ")", ";", "return", "setComplex", "(", "thisr", "*", "r", "-", "thisi", "*", "i", ",", "...
Multiplies a complex number to this pixel. This performs a complex multiplication and stores the result in this pixel. @param r real part to multiply @param i imaginary part to multiply @return this
[ "Multiplies", "a", "complex", "number", "to", "this", "pixel", ".", "This", "performs", "a", "complex", "multiplication", "and", "stores", "the", "result", "in", "this", "pixel", "." ]
3837c7d550a12cf4dc5718b644ced94b97f52668
https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ComplexPixel.java#L245-L248
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/CredentialsUtils.java
CredentialsUtils.savePrivateKey
public static void savePrivateKey(OutputStream os, PrivateKey key, PrivateKeyEncoding encoding) throws IOException { switch (encoding) { case PKCS_1: savePrivateKeyPKCS1(os, key); break; case PKCS_8: savePrivateKeyPKCS8(os, key); break; default: throw new IllegalArgumentException("Unsupported private key encoding: " + encoding.name()); } }
java
public static void savePrivateKey(OutputStream os, PrivateKey key, PrivateKeyEncoding encoding) throws IOException { switch (encoding) { case PKCS_1: savePrivateKeyPKCS1(os, key); break; case PKCS_8: savePrivateKeyPKCS8(os, key); break; default: throw new IllegalArgumentException("Unsupported private key encoding: " + encoding.name()); } }
[ "public", "static", "void", "savePrivateKey", "(", "OutputStream", "os", ",", "PrivateKey", "key", ",", "PrivateKeyEncoding", "encoding", ")", "throws", "IOException", "{", "switch", "(", "encoding", ")", "{", "case", "PKCS_1", ":", "savePrivateKeyPKCS1", "(", "...
Serializes a private key to an output stream according to an encoding. @param os the target output stream @param key the key to be serialized @param encoding the encoding @throws IllegalArgumentException for unsupported private key encodings @throws IOException if write fails for any reason on the output stream
[ "Serializes", "a", "private", "key", "to", "an", "output", "stream", "according", "to", "an", "encoding", "." ]
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/CredentialsUtils.java#L72-L86
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/CredentialsUtils.java
CredentialsUtils.savePrivateKeyPKCS8
private static void savePrivateKeyPKCS8(OutputStream os, PrivateKey key) throws IllegalArgumentException, IOException { CertificateUtils.savePrivateKey(os, key, Encoding.PEM, null, null); }
java
private static void savePrivateKeyPKCS8(OutputStream os, PrivateKey key) throws IllegalArgumentException, IOException { CertificateUtils.savePrivateKey(os, key, Encoding.PEM, null, null); }
[ "private", "static", "void", "savePrivateKeyPKCS8", "(", "OutputStream", "os", ",", "PrivateKey", "key", ")", "throws", "IllegalArgumentException", ",", "IOException", "{", "CertificateUtils", ".", "savePrivateKey", "(", "os", ",", "key", ",", "Encoding", ".", "PE...
Serializes a private key to an output stream following the pkcs8 encoding. This method just delegates to canl, but provides a much more understandable signature. @param os @param key @throws IllegalArgumentException @throws IOException
[ "Serializes", "a", "private", "key", "to", "an", "output", "stream", "following", "the", "pkcs8", "encoding", "." ]
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/CredentialsUtils.java#L99-L104
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/CredentialsUtils.java
CredentialsUtils.savePrivateKeyPKCS1
private static void savePrivateKeyPKCS1(OutputStream os, PrivateKey key) throws IllegalArgumentException, IOException { CertificateUtils.savePrivateKey(os, key, Encoding.PEM, null, new char[0], true); }
java
private static void savePrivateKeyPKCS1(OutputStream os, PrivateKey key) throws IllegalArgumentException, IOException { CertificateUtils.savePrivateKey(os, key, Encoding.PEM, null, new char[0], true); }
[ "private", "static", "void", "savePrivateKeyPKCS1", "(", "OutputStream", "os", ",", "PrivateKey", "key", ")", "throws", "IllegalArgumentException", ",", "IOException", "{", "CertificateUtils", ".", "savePrivateKey", "(", "os", ",", "key", ",", "Encoding", ".", "PE...
Serializes a private key to an output stream following the pkcs1 encoding. This method just delegates to canl, but provides a much more understandable signature. @param os @param key @throws IllegalArgumentException @throws IOException
[ "Serializes", "a", "private", "key", "to", "an", "output", "stream", "following", "the", "pkcs1", "encoding", "." ]
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/CredentialsUtils.java#L117-L123
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/CredentialsUtils.java
CredentialsUtils.saveProxyCredentials
public static void saveProxyCredentials(String proxyFileName, X509Credential uc, PrivateKeyEncoding encoding) throws IOException { File f = new File(proxyFileName); RandomAccessFile raf = new RandomAccessFile(f, "rws"); FileChannel channel = raf.getChannel(); FilePermissionHelper.setProxyPermissions(proxyFileName); channel.truncate(0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); saveProxyCredentials(baos, uc, encoding); baos.close(); channel.write(ByteBuffer.wrap(baos.toByteArray())); channel.close(); raf.close(); }
java
public static void saveProxyCredentials(String proxyFileName, X509Credential uc, PrivateKeyEncoding encoding) throws IOException { File f = new File(proxyFileName); RandomAccessFile raf = new RandomAccessFile(f, "rws"); FileChannel channel = raf.getChannel(); FilePermissionHelper.setProxyPermissions(proxyFileName); channel.truncate(0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); saveProxyCredentials(baos, uc, encoding); baos.close(); channel.write(ByteBuffer.wrap(baos.toByteArray())); channel.close(); raf.close(); }
[ "public", "static", "void", "saveProxyCredentials", "(", "String", "proxyFileName", ",", "X509Credential", "uc", ",", "PrivateKeyEncoding", "encoding", ")", "throws", "IOException", "{", "File", "f", "=", "new", "File", "(", "proxyFileName", ")", ";", "RandomAcces...
Saves proxy credentials to a file. This method ensures that the stored proxy is saved with the appropriate file permissions. @param proxyFileName the file where the proxy will be saved @param uc the credential to be saved @param encoding the private key encoding @throws IOException in case of errors writing to the proxy file
[ "Saves", "proxy", "credentials", "to", "a", "file", ".", "This", "method", "ensures", "that", "the", "stored", "proxy", "is", "saved", "with", "the", "appropriate", "file", "permissions", "." ]
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/CredentialsUtils.java#L206-L224
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/web/SessionManager.java
SessionManager.getValidSessionsElseRemove
Collection<Session> getValidSessionsElseRemove(String httpid, Predicate<Session> predicat) { Collection<Session> wss = new ArrayList(); if(httpid_wss.containsKey(httpid)) { Collection<Session> befores = httpid_wss.get(httpid); for (Session before : befores) { if(predicat.test(before)) { wss.add(before); wsid_httpid.put(before.getId(), httpid); } else { wsid_httpid.remove(before.getId()); } } if(wss.isEmpty()) { httpid_wss.remove(httpid); } else { httpid_wss.put(httpid, wss); } } return wss; }
java
Collection<Session> getValidSessionsElseRemove(String httpid, Predicate<Session> predicat) { Collection<Session> wss = new ArrayList(); if(httpid_wss.containsKey(httpid)) { Collection<Session> befores = httpid_wss.get(httpid); for (Session before : befores) { if(predicat.test(before)) { wss.add(before); wsid_httpid.put(before.getId(), httpid); } else { wsid_httpid.remove(before.getId()); } } if(wss.isEmpty()) { httpid_wss.remove(httpid); } else { httpid_wss.put(httpid, wss); } } return wss; }
[ "Collection", "<", "Session", ">", "getValidSessionsElseRemove", "(", "String", "httpid", ",", "Predicate", "<", "Session", ">", "predicat", ")", "{", "Collection", "<", "Session", ">", "wss", "=", "new", "ArrayList", "(", ")", ";", "if", "(", "httpid_wss", ...
Return all sessions for httpid and for the predicate if some session negate the predicate, its are removed @param httpid @param predicat @return
[ "Return", "all", "sessions", "for", "httpid", "and", "for", "the", "predicate", "if", "some", "session", "negate", "the", "predicate", "its", "are", "removed" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/web/SessionManager.java#L51-L70
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/FilePermissionHelper.java
FilePermissionHelper.checkPrivateKeyPermissions
public static void checkPrivateKeyPermissions(String privateKeyFile) throws IOException { for (PosixFilePermission p : PRIVATE_KEY_PERMS) { try { matchesFilePermissions(privateKeyFile, p); return; } catch (FilePermissionError e) { } } final String errorMessage = String.format( "Wrong file permissions on file %s. Required permissions are: %s ", privateKeyFile, PRIVATE_KEY_PERMS_STR); throw new FilePermissionError(errorMessage); }
java
public static void checkPrivateKeyPermissions(String privateKeyFile) throws IOException { for (PosixFilePermission p : PRIVATE_KEY_PERMS) { try { matchesFilePermissions(privateKeyFile, p); return; } catch (FilePermissionError e) { } } final String errorMessage = String.format( "Wrong file permissions on file %s. Required permissions are: %s ", privateKeyFile, PRIVATE_KEY_PERMS_STR); throw new FilePermissionError(errorMessage); }
[ "public", "static", "void", "checkPrivateKeyPermissions", "(", "String", "privateKeyFile", ")", "throws", "IOException", "{", "for", "(", "PosixFilePermission", "p", ":", "PRIVATE_KEY_PERMS", ")", "{", "try", "{", "matchesFilePermissions", "(", "privateKeyFile", ",", ...
Checks whether a private key file has the 'right' permissions @param privateKeyFile the file to be checked @throws IOException if an error occurs checking file attributes @throws FilePermissionError if the permissions are not correct
[ "Checks", "whether", "a", "private", "key", "file", "has", "the", "right", "permissions" ]
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/FilePermissionHelper.java#L109-L125
train
italiangrid/voms-api-java
src/main/java/org/italiangrid/voms/util/FilePermissionHelper.java
FilePermissionHelper.matchesFilePermissions
public static void matchesFilePermissions(String filename, PosixFilePermission p) throws IOException { filenameSanityChecks(filename); if (p == null) throw new NullPointerException("null permission passed as argument"); File f = new File(filename); // Don't get fooled by symlinks... String canonicalPath = f.getCanonicalPath(); String filePerms = getFilePermissions(canonicalPath); if (!filePerms.startsWith(p.statForm)) throw new FilePermissionError("Wrong file permissions on file " + filename + ". Required permissions are: " + p.chmodForm()); }
java
public static void matchesFilePermissions(String filename, PosixFilePermission p) throws IOException { filenameSanityChecks(filename); if (p == null) throw new NullPointerException("null permission passed as argument"); File f = new File(filename); // Don't get fooled by symlinks... String canonicalPath = f.getCanonicalPath(); String filePerms = getFilePermissions(canonicalPath); if (!filePerms.startsWith(p.statForm)) throw new FilePermissionError("Wrong file permissions on file " + filename + ". Required permissions are: " + p.chmodForm()); }
[ "public", "static", "void", "matchesFilePermissions", "(", "String", "filename", ",", "PosixFilePermission", "p", ")", "throws", "IOException", "{", "filenameSanityChecks", "(", "filename", ")", ";", "if", "(", "p", "==", "null", ")", "throw", "new", "NullPointe...
Checks that a given file has the appropriate unix permissions. This naive implementation just fetches the output of ls -al on a given file and matches the resulting string with the permissionString passed as argument. So the permissionString must be something like: <pre> -rw------- </pre> @param filename the filename to be checked @param p the permission string that must be matched @throws IOException if an error occurs checking file attributes @throws FilePermissionError if file permissions are not as requested
[ "Checks", "that", "a", "given", "file", "has", "the", "appropriate", "unix", "permissions", ".", "This", "naive", "implementation", "just", "fetches", "the", "output", "of", "ls", "-", "al", "on", "a", "given", "file", "and", "matches", "the", "resulting", ...
b33d6cf98ca9449bed87b1cc307d411514589deb
https://github.com/italiangrid/voms-api-java/blob/b33d6cf98ca9449bed87b1cc307d411514589deb/src/main/java/org/italiangrid/voms/util/FilePermissionHelper.java#L163-L182
train
ocelotds/ocelot
ocelot-processor/src/main/java/org/ocelotds/KeyMaker.java
KeyMaker.getMd5
public String getMd5(String msg) { MessageDigest md; try { md = getMessageDigest(); byte[] hash = md.digest(msg.getBytes(StandardCharsets.UTF_8)); //converting byte array to Hexadecimal String StringBuilder sb = new StringBuilder(2 * hash.length); for (byte b : hash) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } catch (NoSuchAlgorithmException ex) { logger.error("Fail to get MD5 of String "+msg, ex); } return null; }
java
public String getMd5(String msg) { MessageDigest md; try { md = getMessageDigest(); byte[] hash = md.digest(msg.getBytes(StandardCharsets.UTF_8)); //converting byte array to Hexadecimal String StringBuilder sb = new StringBuilder(2 * hash.length); for (byte b : hash) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } catch (NoSuchAlgorithmException ex) { logger.error("Fail to get MD5 of String "+msg, ex); } return null; }
[ "public", "String", "getMd5", "(", "String", "msg", ")", "{", "MessageDigest", "md", ";", "try", "{", "md", "=", "getMessageDigest", "(", ")", ";", "byte", "[", "]", "hash", "=", "md", ".", "digest", "(", "msg", ".", "getBytes", "(", "StandardCharsets"...
Create a md5 from string @param msg @return
[ "Create", "a", "md5", "from", "string" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/KeyMaker.java#L27-L42
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/web/ws/WSController.java
WSController.getLocale
Locale getLocale(HandshakeRequest request) { if(null != request) { Map<String, List<String>> headers = request.getHeaders(); if(null != headers) { List<String> accepts = headers.get(HttpHeaders.ACCEPT_LANGUAGE); logger.debug("Get accept-language from client headers : {}", accepts); if (null != accepts) { for (String accept : accepts) { try { return localeExtractor.extractFromAccept(accept); } catch (LocaleNotFoundException ex) { } } } } } return Locale.US; }
java
Locale getLocale(HandshakeRequest request) { if(null != request) { Map<String, List<String>> headers = request.getHeaders(); if(null != headers) { List<String> accepts = headers.get(HttpHeaders.ACCEPT_LANGUAGE); logger.debug("Get accept-language from client headers : {}", accepts); if (null != accepts) { for (String accept : accepts) { try { return localeExtractor.extractFromAccept(accept); } catch (LocaleNotFoundException ex) { } } } } } return Locale.US; }
[ "Locale", "getLocale", "(", "HandshakeRequest", "request", ")", "{", "if", "(", "null", "!=", "request", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "headers", "=", "request", ".", "getHeaders", "(", ")", ";", "if", "(", "nu...
Return locale of client @param request @return
[ "Return", "locale", "of", "client" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/web/ws/WSController.java#L114-L131
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/configuration/OcelotRequestConfigurator.java
OcelotRequestConfigurator.modifyHandshake
@Override public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) { sec.getUserProperties().put(Constants.HANDSHAKEREQUEST, request); super.modifyHandshake(sec, request, response); }
java
@Override public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) { sec.getUserProperties().put(Constants.HANDSHAKEREQUEST, request); super.modifyHandshake(sec, request, response); }
[ "@", "Override", "public", "void", "modifyHandshake", "(", "ServerEndpointConfig", "sec", ",", "HandshakeRequest", "request", ",", "HandshakeResponse", "response", ")", "{", "sec", ".", "getUserProperties", "(", ")", ".", "put", "(", "Constants", ".", "HANDSHAKERE...
Set user information from open websocket @param sec @param request @param response
[ "Set", "user", "information", "from", "open", "websocket" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/configuration/OcelotRequestConfigurator.java#L29-L33
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/core/ws/CallServiceManager.java
CallServiceManager.sendMessageToClient
@Override public boolean sendMessageToClient(MessageFromClient message, Session client) { MessageToClient mtc = messageToClientService.createMessageToClient(message, client); if (mtc != null) { client.getAsyncRemote().sendObject(mtc); return true; } return false; }
java
@Override public boolean sendMessageToClient(MessageFromClient message, Session client) { MessageToClient mtc = messageToClientService.createMessageToClient(message, client); if (mtc != null) { client.getAsyncRemote().sendObject(mtc); return true; } return false; }
[ "@", "Override", "public", "boolean", "sendMessageToClient", "(", "MessageFromClient", "message", ",", "Session", "client", ")", "{", "MessageToClient", "mtc", "=", "messageToClientService", ".", "createMessageToClient", "(", "message", ",", "client", ")", ";", "if"...
Build and send response messages after call request @param message @param client @return
[ "Build", "and", "send", "response", "messages", "after", "call", "request" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/core/ws/CallServiceManager.java#L30-L38
train
xqbase/tuna
misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java
DoSServerFilter.onBlock
protected void onBlock(ConnectionFilter filter, String remoteAddr, int connections, int requests, int bytes) { filter.disconnect(); filter.onDisconnect(); }
java
protected void onBlock(ConnectionFilter filter, String remoteAddr, int connections, int requests, int bytes) { filter.disconnect(); filter.onDisconnect(); }
[ "protected", "void", "onBlock", "(", "ConnectionFilter", "filter", ",", "String", "remoteAddr", ",", "int", "connections", ",", "int", "requests", ",", "int", "bytes", ")", "{", "filter", ".", "disconnect", "(", ")", ";", "filter", ".", "onDisconnect", "(", ...
Called when connections, requests or bytes reach to the limit. @param remoteAddr @param connections @param requests @param bytes
[ "Called", "when", "connections", "requests", "or", "bytes", "reach", "to", "the", "limit", "." ]
60d05a9e03877a3daafe9de83dc4427c6cbb9995
https://github.com/xqbase/tuna/blob/60d05a9e03877a3daafe9de83dc4427c6cbb9995/misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java#L98-L102
train
xqbase/tuna
misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java
DoSServerFilter.setParameters
public void setParameters(int period, int connections, int requests, int bytes) { this.period = period; this.connections_ = connections; this.requests_ = requests; this.bytes_ = bytes; }
java
public void setParameters(int period, int connections, int requests, int bytes) { this.period = period; this.connections_ = connections; this.requests_ = requests; this.bytes_ = bytes; }
[ "public", "void", "setParameters", "(", "int", "period", ",", "int", "connections", ",", "int", "requests", ",", "int", "bytes", ")", "{", "this", ".", "period", "=", "period", ";", "this", ".", "connections_", "=", "connections", ";", "this", ".", "requ...
Reset the parameters @param period - The period, in milliseconds. @param connections - Maximum concurrent connections the same IP. @param requests - Maximum requests (connection events) in the period from the same IP. @param bytes - Maximum sent bytes in the period from the same IP.
[ "Reset", "the", "parameters" ]
60d05a9e03877a3daafe9de83dc4427c6cbb9995
https://github.com/xqbase/tuna/blob/60d05a9e03877a3daafe9de83dc4427c6cbb9995/misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java#L127-L132
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/topic/TopicsMessagesObservers.java
TopicsMessagesObservers.sendObjectToTopic
public void sendObjectToTopic(@Observes @JsTopicEvent("") Object payload, EventMetadata metadata) { MessageToClient msg = new MessageToClient(); InjectionPoint injectionPoint = metadata.getInjectionPoint(); Annotated annotated = injectionPoint.getAnnotated(); JsTopicEvent jte = annotated.getAnnotation(JsTopicEvent.class); if (jte != null) { String topic = jte.value(); msg.setId(topic); JsonMarshaller jm = annotated.getAnnotation(JsonMarshaller.class); try { if (jm != null) { msg.setJson(argumentServices.getJsonResultFromSpecificMarshaller(jm, payload)); } else if(jte.jsonPayload()) { if(!String.class.isInstance(payload)) { throw new UnsupportedOperationException("'"+payload+"' cannot be a json object. Field annotated JsTopicEvent(jsonPayload=true) must be Event<String> type and fire correct Json."); } msg.setJson((String) payload); } else { msg.setResponse(payload); } topicsMessagesBroadcaster.sendMessageToTopic(msg, payload); } catch (JsonMarshallingException ex) { logger.error("'"+payload+"' cannot be send to : '"+topic+"'. It cannot be serialized with marshaller "+jm, ex); } catch (Throwable ex) { logger.error("'"+payload+"' cannot be send to : '"+topic+"'.", ex); } } }
java
public void sendObjectToTopic(@Observes @JsTopicEvent("") Object payload, EventMetadata metadata) { MessageToClient msg = new MessageToClient(); InjectionPoint injectionPoint = metadata.getInjectionPoint(); Annotated annotated = injectionPoint.getAnnotated(); JsTopicEvent jte = annotated.getAnnotation(JsTopicEvent.class); if (jte != null) { String topic = jte.value(); msg.setId(topic); JsonMarshaller jm = annotated.getAnnotation(JsonMarshaller.class); try { if (jm != null) { msg.setJson(argumentServices.getJsonResultFromSpecificMarshaller(jm, payload)); } else if(jte.jsonPayload()) { if(!String.class.isInstance(payload)) { throw new UnsupportedOperationException("'"+payload+"' cannot be a json object. Field annotated JsTopicEvent(jsonPayload=true) must be Event<String> type and fire correct Json."); } msg.setJson((String) payload); } else { msg.setResponse(payload); } topicsMessagesBroadcaster.sendMessageToTopic(msg, payload); } catch (JsonMarshallingException ex) { logger.error("'"+payload+"' cannot be send to : '"+topic+"'. It cannot be serialized with marshaller "+jm, ex); } catch (Throwable ex) { logger.error("'"+payload+"' cannot be send to : '"+topic+"'.", ex); } } }
[ "public", "void", "sendObjectToTopic", "(", "@", "Observes", "@", "JsTopicEvent", "(", "\"\"", ")", "Object", "payload", ",", "EventMetadata", "metadata", ")", "{", "MessageToClient", "msg", "=", "new", "MessageToClient", "(", ")", ";", "InjectionPoint", "inject...
Send message to topic @param payload @param metadata
[ "Send", "message", "to", "topic" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/TopicsMessagesObservers.java#L55-L82
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java
JsCacheAnnotationServices.processJsCacheRemoveAll
public void processJsCacheRemoveAll() { logger.debug("Process JsCacheRemoveAll annotation"); MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(Constants.Cache.CLEANCACHE_TOPIC); messageToClient.setResponse(Constants.Cache.ALL); wsEvent.fire(messageToClient); }
java
public void processJsCacheRemoveAll() { logger.debug("Process JsCacheRemoveAll annotation"); MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(Constants.Cache.CLEANCACHE_TOPIC); messageToClient.setResponse(Constants.Cache.ALL); wsEvent.fire(messageToClient); }
[ "public", "void", "processJsCacheRemoveAll", "(", ")", "{", "logger", ".", "debug", "(", "\"Process JsCacheRemoveAll annotation\"", ")", ";", "MessageToClient", "messageToClient", "=", "new", "MessageToClient", "(", ")", ";", "messageToClient", ".", "setId", "(", "C...
Process annotation JsCacheRemoveAll and send message for suppress all the cache
[ "Process", "annotation", "JsCacheRemoveAll", "and", "send", "message", "for", "suppress", "all", "the", "cache" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java#L53-L59
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java
JsCacheAnnotationServices.processJsCacheRemove
public void processJsCacheRemove(JsCacheRemove jcr, List<String> paramNames, List<String> jsonArgs) { logger.debug("Process JsCacheRemove annotation : {}", jcr); MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(Constants.Cache.CLEANCACHE_TOPIC); String argpart = cacheArgumentServices.computeArgPart(jcr.keys(), jsonArgs, paramNames); String cachekey = computeCacheKey(jcr.cls(), jcr.methodName(), argpart); if (logger.isDebugEnabled()) { logger.debug("JsonArgs from Call : {}", Arrays.toString(jsonArgs.toArray(new String[jsonArgs.size()]))); logger.debug("ParamName from considerated method : {}", Arrays.toString(paramNames.toArray(new String[paramNames.size()]))); logger.debug("Computed key : {}", cachekey); } messageToClient.setResponse(cachekey); if (jcr.userScope()) { wsUserEvent.fire(messageToClient); } else { wsEvent.fire(messageToClient); cacheEvent.fire(cachekey); } }
java
public void processJsCacheRemove(JsCacheRemove jcr, List<String> paramNames, List<String> jsonArgs) { logger.debug("Process JsCacheRemove annotation : {}", jcr); MessageToClient messageToClient = new MessageToClient(); messageToClient.setId(Constants.Cache.CLEANCACHE_TOPIC); String argpart = cacheArgumentServices.computeArgPart(jcr.keys(), jsonArgs, paramNames); String cachekey = computeCacheKey(jcr.cls(), jcr.methodName(), argpart); if (logger.isDebugEnabled()) { logger.debug("JsonArgs from Call : {}", Arrays.toString(jsonArgs.toArray(new String[jsonArgs.size()]))); logger.debug("ParamName from considerated method : {}", Arrays.toString(paramNames.toArray(new String[paramNames.size()]))); logger.debug("Computed key : {}", cachekey); } messageToClient.setResponse(cachekey); if (jcr.userScope()) { wsUserEvent.fire(messageToClient); } else { wsEvent.fire(messageToClient); cacheEvent.fire(cachekey); } }
[ "public", "void", "processJsCacheRemove", "(", "JsCacheRemove", "jcr", ",", "List", "<", "String", ">", "paramNames", ",", "List", "<", "String", ">", "jsonArgs", ")", "{", "logger", ".", "debug", "(", "\"Process JsCacheRemove annotation : {}\"", ",", "jcr", ")"...
Process an annotation JsCacheRemove and send a removeCache message to all clients connected @param jcr : l'annotation @param paramNames : name of parameters @param jsonArgs : method arguments json format
[ "Process", "an", "annotation", "JsCacheRemove", "and", "send", "a", "removeCache", "message", "to", "all", "clients", "connected" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java#L99-L117
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java
JsCacheAnnotationServices.computeCacheKey
String computeCacheKey(Class cls, String methodName, String argpart) { String cachekey = keyMaker.getMd5(cls.getName() + "." + methodName); if (!argpart.isEmpty()) { cachekey += "_" + keyMaker.getMd5(argpart); } logger.debug("CACHEID : {}.{}_{} = {}", cls.getName(), methodName, argpart, cachekey); return cachekey; }
java
String computeCacheKey(Class cls, String methodName, String argpart) { String cachekey = keyMaker.getMd5(cls.getName() + "." + methodName); if (!argpart.isEmpty()) { cachekey += "_" + keyMaker.getMd5(argpart); } logger.debug("CACHEID : {}.{}_{} = {}", cls.getName(), methodName, argpart, cachekey); return cachekey; }
[ "String", "computeCacheKey", "(", "Class", "cls", ",", "String", "methodName", ",", "String", "argpart", ")", "{", "String", "cachekey", "=", "keyMaker", ".", "getMd5", "(", "cls", ".", "getName", "(", ")", "+", "\".\"", "+", "methodName", ")", ";", "if"...
Compute the cache key from classname, methodname, and args @param cls @param methodName @param argpart @return
[ "Compute", "the", "cache", "key", "from", "classname", "methodname", "and", "args" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/JsCacheAnnotationServices.java#L127-L134
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/cache/CacheManager.java
CacheManager.processCacheAnnotations
public long processCacheAnnotations(Method nonProxiedMethod, List<String> parameters) { if (isJsCached(nonProxiedMethod)) { return jsCacheAnnotationServices.getJsCacheResultDeadline(nonProxiedMethod.getAnnotation(JsCacheResult.class)); } return 0L; }
java
public long processCacheAnnotations(Method nonProxiedMethod, List<String> parameters) { if (isJsCached(nonProxiedMethod)) { return jsCacheAnnotationServices.getJsCacheResultDeadline(nonProxiedMethod.getAnnotation(JsCacheResult.class)); } return 0L; }
[ "public", "long", "processCacheAnnotations", "(", "Method", "nonProxiedMethod", ",", "List", "<", "String", ">", "parameters", ")", "{", "if", "(", "isJsCached", "(", "nonProxiedMethod", ")", ")", "{", "return", "jsCacheAnnotationServices", ".", "getJsCacheResultDea...
Process annotations JsCacheResult, JsCacheRemove and JsCacheRemoves @param nonProxiedMethod @param parameters @return
[ "Process", "annotations", "JsCacheResult", "JsCacheRemove", "and", "JsCacheRemoves" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/CacheManager.java#L33-L38
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/cache/CacheManager.java
CacheManager.isJsCached
boolean isJsCached(Method nonProxiedMethod) { boolean cached = nonProxiedMethod.isAnnotationPresent(JsCacheResult.class); logger.debug("The result of the method {} should be cached on client side {}.", nonProxiedMethod.getName(), cached); return cached; }
java
boolean isJsCached(Method nonProxiedMethod) { boolean cached = nonProxiedMethod.isAnnotationPresent(JsCacheResult.class); logger.debug("The result of the method {} should be cached on client side {}.", nonProxiedMethod.getName(), cached); return cached; }
[ "boolean", "isJsCached", "(", "Method", "nonProxiedMethod", ")", "{", "boolean", "cached", "=", "nonProxiedMethod", ".", "isAnnotationPresent", "(", "JsCacheResult", ".", "class", ")", ";", "logger", ".", "debug", "(", "\"The result of the method {} should be cached on ...
Check if result should be cached in front-end @param nonProxiedMethod : method non proxified @return boolean
[ "Check", "if", "result", "should", "be", "cached", "in", "front", "-", "end" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/CacheManager.java#L46-L50
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/security/RoleConfigurationManager.java
RoleConfigurationManager.readDashboardRolesConfig
public void readDashboardRolesConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc) { readFromConfigurationRoles(); readFromInitParameter(sc); logger.debug("'{}' value : '{}'.", Constants.Options.DASHBOARD_ROLES, roles); }
java
public void readDashboardRolesConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc) { readFromConfigurationRoles(); readFromInitParameter(sc); logger.debug("'{}' value : '{}'.", Constants.Options.DASHBOARD_ROLES, roles); }
[ "public", "void", "readDashboardRolesConfig", "(", "@", "Observes", "@", "Initialized", "(", "ApplicationScoped", ".", "class", ")", "ServletContext", "sc", ")", "{", "readFromConfigurationRoles", "(", ")", ";", "readFromInitParameter", "(", "sc", ")", ";", "logge...
Read in web.xml and differents producers the optional DASHBOARD_ROLES config and set it in OcelotConfiguration @param sc
[ "Read", "in", "web", ".", "xml", "and", "differents", "producers", "the", "optional", "DASHBOARD_ROLES", "config", "and", "set", "it", "in", "OcelotConfiguration" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/security/RoleConfigurationManager.java#L44-L48
train
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/core/services/FaultServices.java
FaultServices.buildFault
public Fault buildFault(Throwable ex) { Fault fault; int stacktracelength = configuration.getStacktracelength(); if (stacktracelength == 0 || logger.isDebugEnabled()) { logger.error("Invocation failed", ex); } fault = new Fault(ex, stacktracelength); return fault; }
java
public Fault buildFault(Throwable ex) { Fault fault; int stacktracelength = configuration.getStacktracelength(); if (stacktracelength == 0 || logger.isDebugEnabled()) { logger.error("Invocation failed", ex); } fault = new Fault(ex, stacktracelength); return fault; }
[ "public", "Fault", "buildFault", "(", "Throwable", "ex", ")", "{", "Fault", "fault", ";", "int", "stacktracelength", "=", "configuration", ".", "getStacktracelength", "(", ")", ";", "if", "(", "stacktracelength", "==", "0", "||", "logger", ".", "isDebugEnabled...
Build an fault Object from exception with stacktrace length from configuration @param ex @return
[ "Build", "an", "fault", "Object", "from", "exception", "with", "stacktrace", "length", "from", "configuration" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/core/services/FaultServices.java#L29-L37
train
dkpro/dkpro-statistics
dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/CoincidenceMatrixPrinter.java
CoincidenceMatrixPrinter.print
public void print(final PrintStream out, final ICodingAnnotationStudy study, final ICodingAnnotationItem item) { Map<Object, Map<Object, Double>> coincidence = CodingAnnotationStudy.countCategoryCoincidence(item); doPrint(out, study, coincidence); }
java
public void print(final PrintStream out, final ICodingAnnotationStudy study, final ICodingAnnotationItem item) { Map<Object, Map<Object, Double>> coincidence = CodingAnnotationStudy.countCategoryCoincidence(item); doPrint(out, study, coincidence); }
[ "public", "void", "print", "(", "final", "PrintStream", "out", ",", "final", "ICodingAnnotationStudy", "study", ",", "final", "ICodingAnnotationItem", "item", ")", "{", "Map", "<", "Object", ",", "Map", "<", "Object", ",", "Double", ">", ">", "coincidence", ...
Print the coincidence matrix for the given annotation item.
[ "Print", "the", "coincidence", "matrix", "for", "the", "given", "annotation", "item", "." ]
0b0e93dc49223984964411cbc6df420ba796a8cb
https://github.com/dkpro/dkpro-statistics/blob/0b0e93dc49223984964411cbc6df420ba796a8cb/dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/CoincidenceMatrixPrinter.java#L48-L53
train
dkpro/dkpro-statistics
dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/DistanceMatrixPrinter.java
DistanceMatrixPrinter.print
public void print(final PrintStream out, final Iterable<Object> categories, final IDistanceFunction distanceFunction) { doPrint(out, categories, null, distanceFunction); }
java
public void print(final PrintStream out, final Iterable<Object> categories, final IDistanceFunction distanceFunction) { doPrint(out, categories, null, distanceFunction); }
[ "public", "void", "print", "(", "final", "PrintStream", "out", ",", "final", "Iterable", "<", "Object", ">", "categories", ",", "final", "IDistanceFunction", "distanceFunction", ")", "{", "doPrint", "(", "out", ",", "categories", ",", "null", ",", "distanceFun...
Print a matrix of the distances between each pair of categories.
[ "Print", "a", "matrix", "of", "the", "distances", "between", "each", "pair", "of", "categories", "." ]
0b0e93dc49223984964411cbc6df420ba796a8cb
https://github.com/dkpro/dkpro-statistics/blob/0b0e93dc49223984964411cbc6df420ba796a8cb/dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/DistanceMatrixPrinter.java#L35-L38
train
dkpro/dkpro-statistics
dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/DistanceMatrixPrinter.java
DistanceMatrixPrinter.print
public void print(final PrintStream out, final ICodingAnnotationStudy study, final IDistanceFunction distanceFunction) { doPrint(out, study.getCategories(), study, distanceFunction); }
java
public void print(final PrintStream out, final ICodingAnnotationStudy study, final IDistanceFunction distanceFunction) { doPrint(out, study.getCategories(), study, distanceFunction); }
[ "public", "void", "print", "(", "final", "PrintStream", "out", ",", "final", "ICodingAnnotationStudy", "study", ",", "final", "IDistanceFunction", "distanceFunction", ")", "{", "doPrint", "(", "out", ",", "study", ".", "getCategories", "(", ")", ",", "study", ...
Print a matrix representation of the distances between each pair of categories of the given study.
[ "Print", "a", "matrix", "representation", "of", "the", "distances", "between", "each", "pair", "of", "categories", "of", "the", "given", "study", "." ]
0b0e93dc49223984964411cbc6df420ba796a8cb
https://github.com/dkpro/dkpro-statistics/blob/0b0e93dc49223984964411cbc6df420ba796a8cb/dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/visualization/DistanceMatrixPrinter.java#L42-L45
train
darcy-framework/darcy-ui
src/main/java/com/redhat/darcy/ui/internal/Analyzer.java
Analyzer.isViewElementFindableOrList
private boolean isViewElementFindableOrList(Field field) { Class<?> fieldType = field.getType(); return View.class.isAssignableFrom(fieldType) || Element.class.isAssignableFrom(fieldType) || Findable.class.isAssignableFrom(fieldType) || List.class.isAssignableFrom(fieldType); }
java
private boolean isViewElementFindableOrList(Field field) { Class<?> fieldType = field.getType(); return View.class.isAssignableFrom(fieldType) || Element.class.isAssignableFrom(fieldType) || Findable.class.isAssignableFrom(fieldType) || List.class.isAssignableFrom(fieldType); }
[ "private", "boolean", "isViewElementFindableOrList", "(", "Field", "field", ")", "{", "Class", "<", "?", ">", "fieldType", "=", "field", ".", "getType", "(", ")", ";", "return", "View", ".", "class", ".", "isAssignableFrom", "(", "fieldType", ")", "||", "E...
Those are only supported types which make sense to look at.
[ "Those", "are", "only", "supported", "types", "which", "make", "sense", "to", "look", "at", "." ]
ae0d89a1ca45f8257ef2764a01e4cfe68f432e33
https://github.com/darcy-framework/darcy-ui/blob/ae0d89a1ca45f8257ef2764a01e4cfe68f432e33/src/main/java/com/redhat/darcy/ui/internal/Analyzer.java#L200-L206
train
darcy-framework/darcy-ui
src/main/java/com/redhat/darcy/ui/internal/Analyzer.java
Analyzer.isRequired
private boolean isRequired(Field field) { return field.getAnnotation(Require.class) != null // Use the field's declaring class for RequireAll; may be a super class || (field.getDeclaringClass().getAnnotation(RequireAll.class) != null && field.getAnnotation(NotRequired.class) == null); }
java
private boolean isRequired(Field field) { return field.getAnnotation(Require.class) != null // Use the field's declaring class for RequireAll; may be a super class || (field.getDeclaringClass().getAnnotation(RequireAll.class) != null && field.getAnnotation(NotRequired.class) == null); }
[ "private", "boolean", "isRequired", "(", "Field", "field", ")", "{", "return", "field", ".", "getAnnotation", "(", "Require", ".", "class", ")", "!=", "null", "// Use the field's declaring class for RequireAll; may be a super class", "||", "(", "field", ".", "getDecla...
Determines whether a field is required or not based on combination of Require, RequireAll, and NotRequired annotations.
[ "Determines", "whether", "a", "field", "is", "required", "or", "not", "based", "on", "combination", "of", "Require", "RequireAll", "and", "NotRequired", "annotations", "." ]
ae0d89a1ca45f8257ef2764a01e4cfe68f432e33
https://github.com/darcy-framework/darcy-ui/blob/ae0d89a1ca45f8257ef2764a01e4cfe68f432e33/src/main/java/com/redhat/darcy/ui/internal/Analyzer.java#L219-L224
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getLiteralType
public String getLiteralType(Type type) { String result = ""; if (type != null) { if (ParameterizedType.class.isAssignableFrom(type.getClass())) { ParameterizedType parameterizedType = (ParameterizedType) type; result = parameterizedType.toString(); } else { result = ((Class) type).getCanonicalName(); } } return result; }
java
public String getLiteralType(Type type) { String result = ""; if (type != null) { if (ParameterizedType.class.isAssignableFrom(type.getClass())) { ParameterizedType parameterizedType = (ParameterizedType) type; result = parameterizedType.toString(); } else { result = ((Class) type).getCanonicalName(); } } return result; }
[ "public", "String", "getLiteralType", "(", "Type", "type", ")", "{", "String", "result", "=", "\"\"", ";", "if", "(", "type", "!=", "null", ")", "{", "if", "(", "ParameterizedType", ".", "class", ".", "isAssignableFrom", "(", "type", ".", "getClass", "("...
Return human reading of type @param type @return
[ "Return", "human", "reading", "of", "type" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L59-L70
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getJsonMarshaller
public IJsonMarshaller getJsonMarshaller(Annotation[] annotations) throws JsonMarshallerException { if (annotations != null) { for (Annotation annotation : annotations) { if (JsonUnmarshaller.class.isAssignableFrom(annotation.annotationType())) { return getJsonMarshallerFromAnnotation((JsonUnmarshaller) annotation); } } } return null; }
java
public IJsonMarshaller getJsonMarshaller(Annotation[] annotations) throws JsonMarshallerException { if (annotations != null) { for (Annotation annotation : annotations) { if (JsonUnmarshaller.class.isAssignableFrom(annotation.annotationType())) { return getJsonMarshallerFromAnnotation((JsonUnmarshaller) annotation); } } } return null; }
[ "public", "IJsonMarshaller", "getJsonMarshaller", "(", "Annotation", "[", "]", "annotations", ")", "throws", "JsonMarshallerException", "{", "if", "(", "annotations", "!=", "null", ")", "{", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "...
Return JsonUnmarshaller instance if annotation JsonUnmarshaller is present @param annotations @return @throws org.ocelotds.marshalling.exceptions.JsonMarshallerException
[ "Return", "JsonUnmarshaller", "instance", "if", "annotation", "JsonUnmarshaller", "is", "present" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L79-L88
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getJsonMarshallerFromAnnotation
public IJsonMarshaller getJsonMarshallerFromAnnotation(JsonUnmarshaller jua) throws JsonMarshallerException { if (jua != null) { return argumentServices.getIJsonMarshallerInstance(jua.value()); } return null; }
java
public IJsonMarshaller getJsonMarshallerFromAnnotation(JsonUnmarshaller jua) throws JsonMarshallerException { if (jua != null) { return argumentServices.getIJsonMarshallerInstance(jua.value()); } return null; }
[ "public", "IJsonMarshaller", "getJsonMarshallerFromAnnotation", "(", "JsonUnmarshaller", "jua", ")", "throws", "JsonMarshallerException", "{", "if", "(", "jua", "!=", "null", ")", "{", "return", "argumentServices", ".", "getIJsonMarshallerInstance", "(", "jua", ".", "...
Return JsonUnmarshaller instance from annotation JsonUnmarshaller @param jua @return @throws org.ocelotds.marshalling.exceptions.JsonMarshallerException
[ "Return", "JsonUnmarshaller", "instance", "from", "annotation", "JsonUnmarshaller" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L97-L102
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getInstanceNameFromDataservice
public String getInstanceNameFromDataservice(Class cls) { DataService dataService = (DataService) cls.getAnnotation(DataService.class); String clsName = dataService.name(); if (clsName.isEmpty()) { clsName = cls.getSimpleName(); } return getInstanceName(clsName); }
java
public String getInstanceNameFromDataservice(Class cls) { DataService dataService = (DataService) cls.getAnnotation(DataService.class); String clsName = dataService.name(); if (clsName.isEmpty()) { clsName = cls.getSimpleName(); } return getInstanceName(clsName); }
[ "public", "String", "getInstanceNameFromDataservice", "(", "Class", "cls", ")", "{", "DataService", "dataService", "=", "(", "DataService", ")", "cls", ".", "getAnnotation", "(", "DataService", ".", "class", ")", ";", "String", "clsName", "=", "dataService", "."...
Get instancename from Dataservice Class @param cls @return
[ "Get", "instancename", "from", "Dataservice", "Class" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L125-L132
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.isConsiderateMethod
public boolean isConsiderateMethod(Method method) { if (method.isAnnotationPresent(TransientDataService.class) || method.isAnnotationPresent(WsDataService.class) || method.getDeclaringClass().isAssignableFrom(Object.class)) { return false; } int modifiers = method.getModifiers(); return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers); }
java
public boolean isConsiderateMethod(Method method) { if (method.isAnnotationPresent(TransientDataService.class) || method.isAnnotationPresent(WsDataService.class) || method.getDeclaringClass().isAssignableFrom(Object.class)) { return false; } int modifiers = method.getModifiers(); return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers); }
[ "public", "boolean", "isConsiderateMethod", "(", "Method", "method", ")", "{", "if", "(", "method", ".", "isAnnotationPresent", "(", "TransientDataService", ".", "class", ")", "||", "method", ".", "isAnnotationPresent", "(", "WsDataService", ".", "class", ")", "...
Method is expose to frontend ? @param method @return
[ "Method", "is", "expose", "to", "frontend", "?" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L140-L146
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getInstanceOfClass
Object getInstanceOfClass(Class cls) { if (Boolean.class.isAssignableFrom(cls) || Boolean.TYPE.isAssignableFrom(cls)) { return Boolean.FALSE; } else if (Integer.TYPE.isAssignableFrom(cls) || Short.TYPE.isAssignableFrom(cls) || Integer.class.isAssignableFrom(cls) || Short.class.isAssignableFrom(cls)) { return 0; } else if (Long.TYPE.isAssignableFrom(cls) || Long.class.isAssignableFrom(cls)) { return 0L; } else if (Float.TYPE.isAssignableFrom(cls) || Float.class.isAssignableFrom(cls)) { return 0.1F; } else if (Double.TYPE.isAssignableFrom(cls) || Double.class.isAssignableFrom(cls)) { return 0.1D; } else if (cls.isArray()) { Class<?> comp = cls.getComponentType(); Object instance = getInstanceOfClass(comp); return new Object[]{instance, instance}; } else { try { return cls.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { return getObjectFromConstantFields(cls); } } }
java
Object getInstanceOfClass(Class cls) { if (Boolean.class.isAssignableFrom(cls) || Boolean.TYPE.isAssignableFrom(cls)) { return Boolean.FALSE; } else if (Integer.TYPE.isAssignableFrom(cls) || Short.TYPE.isAssignableFrom(cls) || Integer.class.isAssignableFrom(cls) || Short.class.isAssignableFrom(cls)) { return 0; } else if (Long.TYPE.isAssignableFrom(cls) || Long.class.isAssignableFrom(cls)) { return 0L; } else if (Float.TYPE.isAssignableFrom(cls) || Float.class.isAssignableFrom(cls)) { return 0.1F; } else if (Double.TYPE.isAssignableFrom(cls) || Double.class.isAssignableFrom(cls)) { return 0.1D; } else if (cls.isArray()) { Class<?> comp = cls.getComponentType(); Object instance = getInstanceOfClass(comp); return new Object[]{instance, instance}; } else { try { return cls.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { return getObjectFromConstantFields(cls); } } }
[ "Object", "getInstanceOfClass", "(", "Class", "cls", ")", "{", "if", "(", "Boolean", ".", "class", ".", "isAssignableFrom", "(", "cls", ")", "||", "Boolean", ".", "TYPE", ".", "isAssignableFrom", "(", "cls", ")", ")", "{", "return", "Boolean", ".", "FALS...
Get instance for classic class @param cls @return
[ "Get", "instance", "for", "classic", "class" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L184-L206
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getObjectFromConstantFields
Object getObjectFromConstantFields(Class cls) { Field[] fields = cls.getFields(); Object instance = null; for (Field field : fields) { instance = getObjectFromConstantField(cls, field); if(instance!=null) { break; } } return instance; }
java
Object getObjectFromConstantFields(Class cls) { Field[] fields = cls.getFields(); Object instance = null; for (Field field : fields) { instance = getObjectFromConstantField(cls, field); if(instance!=null) { break; } } return instance; }
[ "Object", "getObjectFromConstantFields", "(", "Class", "cls", ")", "{", "Field", "[", "]", "fields", "=", "cls", ".", "getFields", "(", ")", ";", "Object", "instance", "=", "null", ";", "for", "(", "Field", "field", ":", "fields", ")", "{", "instance", ...
If the class has not empty constructor, look static field if it return instance @param cls @return
[ "If", "the", "class", "has", "not", "empty", "constructor", "look", "static", "field", "if", "it", "return", "instance" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L214-L224
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getTemplateOfParameterizedType
String getTemplateOfParameterizedType(ParameterizedType parameterizedType, IJsonMarshaller jsonMarshaller) { Class cls = (Class) parameterizedType.getRawType(); Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); String res; if (Iterable.class.isAssignableFrom(cls)) { res = getTemplateOfIterable(actualTypeArguments, jsonMarshaller); } else if (Map.class.isAssignableFrom(cls)) { res = getTemplateOfMap(actualTypeArguments, jsonMarshaller); } else { res = cls.getSimpleName().toLowerCase(Locale.ENGLISH); } return res; }
java
String getTemplateOfParameterizedType(ParameterizedType parameterizedType, IJsonMarshaller jsonMarshaller) { Class cls = (Class) parameterizedType.getRawType(); Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); String res; if (Iterable.class.isAssignableFrom(cls)) { res = getTemplateOfIterable(actualTypeArguments, jsonMarshaller); } else if (Map.class.isAssignableFrom(cls)) { res = getTemplateOfMap(actualTypeArguments, jsonMarshaller); } else { res = cls.getSimpleName().toLowerCase(Locale.ENGLISH); } return res; }
[ "String", "getTemplateOfParameterizedType", "(", "ParameterizedType", "parameterizedType", ",", "IJsonMarshaller", "jsonMarshaller", ")", "{", "Class", "cls", "=", "(", "Class", ")", "parameterizedType", ".", "getRawType", "(", ")", ";", "Type", "[", "]", "actualTyp...
Get template from parameterizedType @param parameterizedType @return
[ "Get", "template", "from", "parameterizedType" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L247-L259
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getTemplateOfIterable
String getTemplateOfIterable(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) { String res = "["; for (Type actualTypeArgument : actualTypeArguments) { String template = _getTemplateOfType(actualTypeArgument, jsonMarshaller); res += template + "," + template; break; } return res + "]"; }
java
String getTemplateOfIterable(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) { String res = "["; for (Type actualTypeArgument : actualTypeArguments) { String template = _getTemplateOfType(actualTypeArgument, jsonMarshaller); res += template + "," + template; break; } return res + "]"; }
[ "String", "getTemplateOfIterable", "(", "Type", "[", "]", "actualTypeArguments", ",", "IJsonMarshaller", "jsonMarshaller", ")", "{", "String", "res", "=", "\"[\"", ";", "for", "(", "Type", "actualTypeArgument", ":", "actualTypeArguments", ")", "{", "String", "temp...
Get template of iterable class from generic type @param actualTypeArguments @return
[ "Get", "template", "of", "iterable", "class", "from", "generic", "type" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L267-L275
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getTemplateOfMap
String getTemplateOfMap(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) { StringBuilder res = new StringBuilder("{"); boolean first = true; for (Type actualTypeArgument : actualTypeArguments) { if (!first) { res.append(":"); } res.append(_getTemplateOfType(actualTypeArgument, jsonMarshaller)); first = false; } res.append("}"); return res.toString(); }
java
String getTemplateOfMap(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) { StringBuilder res = new StringBuilder("{"); boolean first = true; for (Type actualTypeArgument : actualTypeArguments) { if (!first) { res.append(":"); } res.append(_getTemplateOfType(actualTypeArgument, jsonMarshaller)); first = false; } res.append("}"); return res.toString(); }
[ "String", "getTemplateOfMap", "(", "Type", "[", "]", "actualTypeArguments", ",", "IJsonMarshaller", "jsonMarshaller", ")", "{", "StringBuilder", "res", "=", "new", "StringBuilder", "(", "\"{\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "Type...
Get template of map class from generic type @param actualTypeArguments @return
[ "Get", "template", "of", "map", "class", "from", "generic", "type" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L283-L295
train
ocelotds/ocelot
ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java
ServiceTools.getInstanceName
String getInstanceName(String clsName) { return clsName.substring(0, 1).toLowerCase(Locale.ENGLISH) + clsName.substring(1); }
java
String getInstanceName(String clsName) { return clsName.substring(0, 1).toLowerCase(Locale.ENGLISH) + clsName.substring(1); }
[ "String", "getInstanceName", "(", "String", "clsName", ")", "{", "return", "clsName", ".", "substring", "(", "0", ",", "1", ")", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", "+", "clsName", ".", "substring", "(", "1", ")", ";", "}" ]
Get instancename from clasname @param clsName @return
[ "Get", "instancename", "from", "clasname" ]
5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L303-L305
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/ItemListBox.java
ItemListBox.builder
public static <T> Builder<T, ItemListBox<T>> builder () { return new Builder<T, ItemListBox<T>>(new ItemListBox<T>()); }
java
public static <T> Builder<T, ItemListBox<T>> builder () { return new Builder<T, ItemListBox<T>>(new ItemListBox<T>()); }
[ "public", "static", "<", "T", ">", "Builder", "<", "T", ",", "ItemListBox", "<", "T", ">", ">", "builder", "(", ")", "{", "return", "new", "Builder", "<", "T", ",", "ItemListBox", "<", "T", ">", ">", "(", "new", "ItemListBox", "<", "T", ">", "(",...
Creates a new builder for an ItemListBox.
[ "Creates", "a", "new", "builder", "for", "an", "ItemListBox", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/ItemListBox.java#L96-L99
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/ItemListBox.java
ItemListBox.removeItem
public boolean removeItem (T item) { int index = _items.indexOf(item); if (index == -1) { return false; } _items.remove(index); removeItem(index); return true; }
java
public boolean removeItem (T item) { int index = _items.indexOf(item); if (index == -1) { return false; } _items.remove(index); removeItem(index); return true; }
[ "public", "boolean", "removeItem", "(", "T", "item", ")", "{", "int", "index", "=", "_items", ".", "indexOf", "(", "item", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "return", "false", ";", "}", "_items", ".", "remove", "(", "index", ...
Removes the supplied item from this list box, returning true if the item was found.
[ "Removes", "the", "supplied", "item", "from", "this", "list", "box", "returning", "true", "if", "the", "item", "was", "found", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/ItemListBox.java#L157-L166
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/PagedTable.java
PagedTable.addRow
protected static boolean addRow (SmartTable table, List<Widget> widgets) { if (widgets == null) { return false; } int row = table.getRowCount(); for (int col=0; col<widgets.size(); ++col) { table.setWidget(row, col, widgets.get(col)); table.getFlexCellFormatter().setStyleName(row, col, "col"+col); } return true; }
java
protected static boolean addRow (SmartTable table, List<Widget> widgets) { if (widgets == null) { return false; } int row = table.getRowCount(); for (int col=0; col<widgets.size(); ++col) { table.setWidget(row, col, widgets.get(col)); table.getFlexCellFormatter().setStyleName(row, col, "col"+col); } return true; }
[ "protected", "static", "boolean", "addRow", "(", "SmartTable", "table", ",", "List", "<", "Widget", ">", "widgets", ")", "{", "if", "(", "widgets", "==", "null", ")", "{", "return", "false", ";", "}", "int", "row", "=", "table", ".", "getRowCount", "("...
Convenience function to append a list of widgets to a table as a new row.
[ "Convenience", "function", "to", "append", "a", "list", "of", "widgets", "to", "a", "table", "as", "a", "new", "row", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/PagedTable.java#L68-L79
train
ebean-orm/ebean-mocker
src/main/java/io/ebean/WithStaticFinder.java
WithStaticFinder.findField
protected Field findField() throws FinderFieldNotFoundException { try { if (fieldName != null) { return beanType.getField(fieldName); } try { return beanType.getField("find"); } catch (NoSuchFieldException e) { return beanType.getField("FIND"); } } catch (NoSuchFieldException e) { throw new FinderFieldNotFoundException(e); } }
java
protected Field findField() throws FinderFieldNotFoundException { try { if (fieldName != null) { return beanType.getField(fieldName); } try { return beanType.getField("find"); } catch (NoSuchFieldException e) { return beanType.getField("FIND"); } } catch (NoSuchFieldException e) { throw new FinderFieldNotFoundException(e); } }
[ "protected", "Field", "findField", "(", ")", "throws", "FinderFieldNotFoundException", "{", "try", "{", "if", "(", "fieldName", "!=", "null", ")", "{", "return", "beanType", ".", "getField", "(", "fieldName", ")", ";", "}", "try", "{", "return", "beanType", ...
Find and return the "find" field.
[ "Find", "and", "return", "the", "find", "field", "." ]
98c14a58253e8cd40b2a0c9b49526a307079389a
https://github.com/ebean-orm/ebean-mocker/blob/98c14a58253e8cd40b2a0c9b49526a307079389a/src/main/java/io/ebean/WithStaticFinder.java#L107-L123
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/PagedGrid.java
PagedGrid.setCellAlignment
public void setCellAlignment (HasAlignment.HorizontalAlignmentConstant horiz, HasAlignment.VerticalAlignmentConstant vert) { _cellHorizAlign = horiz; _cellVertAlign = vert; }
java
public void setCellAlignment (HasAlignment.HorizontalAlignmentConstant horiz, HasAlignment.VerticalAlignmentConstant vert) { _cellHorizAlign = horiz; _cellVertAlign = vert; }
[ "public", "void", "setCellAlignment", "(", "HasAlignment", ".", "HorizontalAlignmentConstant", "horiz", ",", "HasAlignment", ".", "VerticalAlignmentConstant", "vert", ")", "{", "_cellHorizAlign", "=", "horiz", ";", "_cellVertAlign", "=", "vert", ";", "}" ]
Configures the horizontal and vertical alignment of cells. This must be called before the grid is displayed.
[ "Configures", "the", "horizontal", "and", "vertical", "alignment", "of", "cells", ".", "This", "must", "be", "called", "before", "the", "grid", "is", "displayed", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/PagedGrid.java#L63-L68
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/PagedGrid.java
PagedGrid.formatCell
protected void formatCell (HTMLTable.CellFormatter formatter, int row, int col, int limit) { formatter.setHorizontalAlignment(row, col, _cellHorizAlign); formatter.setVerticalAlignment(row, col, _cellVertAlign); formatter.setStyleName(row, col, "Cell"); if (row == (limit-1)/_cols) { formatter.addStyleName(row, col, "BottomCell"); } else if (row == 0) { formatter.addStyleName(row, col, "TopCell"); } else { formatter.addStyleName(row, col, "MiddleCell"); } }
java
protected void formatCell (HTMLTable.CellFormatter formatter, int row, int col, int limit) { formatter.setHorizontalAlignment(row, col, _cellHorizAlign); formatter.setVerticalAlignment(row, col, _cellVertAlign); formatter.setStyleName(row, col, "Cell"); if (row == (limit-1)/_cols) { formatter.addStyleName(row, col, "BottomCell"); } else if (row == 0) { formatter.addStyleName(row, col, "TopCell"); } else { formatter.addStyleName(row, col, "MiddleCell"); } }
[ "protected", "void", "formatCell", "(", "HTMLTable", ".", "CellFormatter", "formatter", ",", "int", "row", ",", "int", "col", ",", "int", "limit", ")", "{", "formatter", ".", "setHorizontalAlignment", "(", "row", ",", "col", ",", "_cellHorizAlign", ")", ";",...
Configures the formatting for a particular cell based on its location in the grid.
[ "Configures", "the", "formatting", "for", "a", "particular", "cell", "based", "on", "its", "location", "in", "the", "grid", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/PagedGrid.java#L99-L111
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.doCollectEmpty
@SuppressWarnings("unchecked") <C, T> Stage<T> doCollectEmpty( final Function<? super Collection<C>, ? extends T> collector ) { try { return this.completed(collector.apply((Collection<C>) EMPTY_RESULTS)); } catch (Exception e) { return failed(e); } }
java
@SuppressWarnings("unchecked") <C, T> Stage<T> doCollectEmpty( final Function<? super Collection<C>, ? extends T> collector ) { try { return this.completed(collector.apply((Collection<C>) EMPTY_RESULTS)); } catch (Exception e) { return failed(e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "<", "C", ",", "T", ">", "Stage", "<", "T", ">", "doCollectEmpty", "(", "final", "Function", "<", "?", "super", "Collection", "<", "C", ">", ",", "?", "extends", "T", ">", "collector", ")", "{", "tr...
Shortcut for when the list of stages is empty. @param collector collector to apply
[ "Shortcut", "for", "when", "the", "list", "of", "stages", "is", "empty", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L189-L198
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.doStreamCollectEmpty
<T, U> Stage<U> doStreamCollectEmpty( final Consumer<? super T> consumer, final Supplier<? extends U> supplier ) { try { return this.completed(supplier.get()); } catch (Exception e) { return failed(e); } }
java
<T, U> Stage<U> doStreamCollectEmpty( final Consumer<? super T> consumer, final Supplier<? extends U> supplier ) { try { return this.completed(supplier.get()); } catch (Exception e) { return failed(e); } }
[ "<", "T", ",", "U", ">", "Stage", "<", "U", ">", "doStreamCollectEmpty", "(", "final", "Consumer", "<", "?", "super", "T", ">", "consumer", ",", "final", "Supplier", "<", "?", "extends", "U", ">", "supplier", ")", "{", "try", "{", "return", "this", ...
Shortcut for when the list of stages is empty with stream collector. @param consumer consumer to apply @param supplier supplier to provide result @param <T> source type @param <U> target type
[ "Shortcut", "for", "when", "the", "list", "of", "stages", "is", "empty", "with", "stream", "collector", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L220-L228
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.doStreamCollect
<T, U> Stage<U> doStreamCollect( final Collection<? extends Stage<? extends T>> stages, final Consumer<? super T> consumer, final Supplier<? extends U> supplier ) { final Completable<U> target = completable(); final StreamCollectHelper<? super T, ? extends U> done = new StreamCollectHelper<>(caller, stages.size(), consumer, supplier, target); for (final Stage<? extends T> q : stages) { q.handle(done); } bindSignals(target, stages); return target; }
java
<T, U> Stage<U> doStreamCollect( final Collection<? extends Stage<? extends T>> stages, final Consumer<? super T> consumer, final Supplier<? extends U> supplier ) { final Completable<U> target = completable(); final StreamCollectHelper<? super T, ? extends U> done = new StreamCollectHelper<>(caller, stages.size(), consumer, supplier, target); for (final Stage<? extends T> q : stages) { q.handle(done); } bindSignals(target, stages); return target; }
[ "<", "T", ",", "U", ">", "Stage", "<", "U", ">", "doStreamCollect", "(", "final", "Collection", "<", "?", "extends", "Stage", "<", "?", "extends", "T", ">", ">", "stages", ",", "final", "Consumer", "<", "?", "super", "T", ">", "consumer", ",", "fin...
Perform collection for stream collector. @param stages stages to apply to collector @param consumer consumer to apply @param supplier supplier to provide result @param <T> source type @param <U> target type
[ "Perform", "collection", "for", "stream", "collector", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L239-L254
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.doEventuallyCollect
<T, U> Stage<U> doEventuallyCollect( final Collection<? extends Callable<? extends Stage<? extends T>>> tasks, final Consumer<? super T> consumer, Supplier<? extends U> supplier, int parallelism ) { final ExecutorService executor = executor(); final Completable<U> stage = completable(); executor.execute( new DelayedCollectCoordinator<>(caller, tasks, consumer, supplier, stage, parallelism)); return stage; }
java
<T, U> Stage<U> doEventuallyCollect( final Collection<? extends Callable<? extends Stage<? extends T>>> tasks, final Consumer<? super T> consumer, Supplier<? extends U> supplier, int parallelism ) { final ExecutorService executor = executor(); final Completable<U> stage = completable(); executor.execute( new DelayedCollectCoordinator<>(caller, tasks, consumer, supplier, stage, parallelism)); return stage; }
[ "<", "T", ",", "U", ">", "Stage", "<", "U", ">", "doEventuallyCollect", "(", "final", "Collection", "<", "?", "extends", "Callable", "<", "?", "extends", "Stage", "<", "?", "extends", "T", ">", ">", ">", "tasks", ",", "final", "Consumer", "<", "?", ...
Perform an eventual collection. @param tasks tasks to invoke for stages @param consumer consumer to apply @param supplier supplier to provide result @param parallelism number of tasks to run in parallel @param <T> source type @param <U> target type @return a completable
[ "Perform", "an", "eventual", "collection", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L320-L329
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.doCollectAndDiscard
Stage<Void> doCollectAndDiscard( Collection<? extends Stage<?>> stages ) { final Completable<Void> target = completable(); final CollectAndDiscardHelper done = new CollectAndDiscardHelper(stages.size(), target); for (final Stage<?> q : stages) { q.handle(done); } bindSignals(target, stages); return target; }
java
Stage<Void> doCollectAndDiscard( Collection<? extends Stage<?>> stages ) { final Completable<Void> target = completable(); final CollectAndDiscardHelper done = new CollectAndDiscardHelper(stages.size(), target); for (final Stage<?> q : stages) { q.handle(done); } bindSignals(target, stages); return target; }
[ "Stage", "<", "Void", ">", "doCollectAndDiscard", "(", "Collection", "<", "?", "extends", "Stage", "<", "?", ">", ">", "stages", ")", "{", "final", "Completable", "<", "Void", ">", "target", "=", "completable", "(", ")", ";", "final", "CollectAndDiscardHel...
Perform a collect and discard. @param stages stages to discard @return a completable
[ "Perform", "a", "collect", "and", "discard", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L348-L361
train
udoprog/tiny-async-java
tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java
CoreAsync.bindSignals
void bindSignals( final Stage<?> target, final Collection<? extends Stage<?>> stages ) { target.whenCancelled(() -> { for (final Stage<?> f : stages) { f.cancel(); } }); }
java
void bindSignals( final Stage<?> target, final Collection<? extends Stage<?>> stages ) { target.whenCancelled(() -> { for (final Stage<?> f : stages) { f.cancel(); } }); }
[ "void", "bindSignals", "(", "final", "Stage", "<", "?", ">", "target", ",", "final", "Collection", "<", "?", "extends", "Stage", "<", "?", ">", ">", "stages", ")", "{", "target", ".", "whenCancelled", "(", "(", ")", "->", "{", "for", "(", "final", ...
Bind the given collection of stages to the target completable, which if cancelled, or failed will do the corresponding to their collection of stages. @param target The completable to cancel, and fail on. @param stages The stages to cancel, when {@code target} is cancelled.
[ "Bind", "the", "given", "collection", "of", "stages", "to", "the", "target", "completable", "which", "if", "cancelled", "or", "failed", "will", "do", "the", "corresponding", "to", "their", "collection", "of", "stages", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-core/src/main/java/eu/toolchain/concurrent/CoreAsync.java#L385-L393
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/ClickCallback.java
ClickCallback.onFailure
public void onFailure (Throwable cause) { Console.log("Callback failure", "for", _trigger, cause); setEnabled(true); reportFailure(cause); }
java
public void onFailure (Throwable cause) { Console.log("Callback failure", "for", _trigger, cause); setEnabled(true); reportFailure(cause); }
[ "public", "void", "onFailure", "(", "Throwable", "cause", ")", "{", "Console", ".", "log", "(", "\"Callback failure\"", ",", "\"for\"", ",", "_trigger", ",", "cause", ")", ";", "setEnabled", "(", "true", ")", ";", "reportFailure", "(", "cause", ")", ";", ...
from interface AsyncCallback
[ "from", "interface", "AsyncCallback" ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/ClickCallback.java#L77-L82
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/ClickCallback.java
ClickCallback.setConfirmChoices
public ClickCallback<T> setConfirmChoices (String confirm, String abort) { _confirmChoices = new String[] { confirm, abort }; return this; }
java
public ClickCallback<T> setConfirmChoices (String confirm, String abort) { _confirmChoices = new String[] { confirm, abort }; return this; }
[ "public", "ClickCallback", "<", "T", ">", "setConfirmChoices", "(", "String", "confirm", ",", "String", "abort", ")", "{", "_confirmChoices", "=", "new", "String", "[", "]", "{", "confirm", ",", "abort", "}", ";", "return", "this", ";", "}" ]
Configures the choices to be shown in the confirmation dialog.
[ "Configures", "the", "choices", "to", "be", "shown", "in", "the", "confirmation", "dialog", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/ClickCallback.java#L107-L111
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/ClickCallback.java
ClickCallback.showError
protected void showError (Throwable cause, Widget near) { if (near == null) { Popups.error(formatError(cause)); } else { Popups.errorBelow(formatError(cause), near); } }
java
protected void showError (Throwable cause, Widget near) { if (near == null) { Popups.error(formatError(cause)); } else { Popups.errorBelow(formatError(cause), near); } }
[ "protected", "void", "showError", "(", "Throwable", "cause", ",", "Widget", "near", ")", "{", "if", "(", "near", "==", "null", ")", "{", "Popups", ".", "error", "(", "formatError", "(", "cause", ")", ")", ";", "}", "else", "{", "Popups", ".", "errorB...
Displays a popup reporting the specified error, near the specified widget if it is non-null.
[ "Displays", "a", "popup", "reporting", "the", "specified", "error", "near", "the", "specified", "widget", "if", "it", "is", "non", "-", "null", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/ClickCallback.java#L149-L156
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/ClickCallback.java
ClickCallback.addConfirmPopupMessage
protected int addConfirmPopupMessage (SmartTable contents, int row) { if (_confirmHTML) { contents.setHTML(row, 0, _confirmMessage, 2, "Message"); } else { contents.setText(row, 0, _confirmMessage, 2, "Message"); } return row + 1; }
java
protected int addConfirmPopupMessage (SmartTable contents, int row) { if (_confirmHTML) { contents.setHTML(row, 0, _confirmMessage, 2, "Message"); } else { contents.setText(row, 0, _confirmMessage, 2, "Message"); } return row + 1; }
[ "protected", "int", "addConfirmPopupMessage", "(", "SmartTable", "contents", ",", "int", "row", ")", "{", "if", "(", "_confirmHTML", ")", "{", "contents", ".", "setHTML", "(", "row", ",", "0", ",", "_confirmMessage", ",", "2", ",", "\"Message\"", ")", ";",...
Adds the message area for the confirmation popup to the given row and returns the row to insert next.
[ "Adds", "the", "message", "area", "for", "the", "confirmation", "popup", "to", "the", "given", "row", "and", "returns", "the", "row", "to", "insert", "next", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/ClickCallback.java#L222-L230
train
icode/ameba
src/main/java/ameba/mvc/template/internal/TemplateModelProcessor.java
TemplateModelProcessor.createEnhancingMethods
private void createEnhancingMethods(final Class<?> resourceClass, final Object resourceInstance, final List<ModelProcessorUtil.Method> newMethods) { final Template template = resourceClass.getAnnotation(Template.class); if (template != null) { final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(resourceClass); final List<MediaType> produces = MediaTypes .createQualitySourceMediaTypes(annotatedResourceClass.getAnnotation(Produces.class)); final List<MediaType> consumes = MediaTypes.createFrom(annotatedResourceClass.getAnnotation(Consumes.class)); final TemplateInflectorImpl inflector = new TemplateInflectorImpl(template.name(), resourceClass, resourceInstance); newMethods.add(new ModelProcessorUtil.Method(HttpMethod.GET, consumes, produces, inflector)); newMethods.add(new ModelProcessorUtil.Method(IMPLICIT_VIEW_PATH_PARAMETER_TEMPLATE, HttpMethod.GET, consumes, produces, inflector)); } }
java
private void createEnhancingMethods(final Class<?> resourceClass, final Object resourceInstance, final List<ModelProcessorUtil.Method> newMethods) { final Template template = resourceClass.getAnnotation(Template.class); if (template != null) { final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(resourceClass); final List<MediaType> produces = MediaTypes .createQualitySourceMediaTypes(annotatedResourceClass.getAnnotation(Produces.class)); final List<MediaType> consumes = MediaTypes.createFrom(annotatedResourceClass.getAnnotation(Consumes.class)); final TemplateInflectorImpl inflector = new TemplateInflectorImpl(template.name(), resourceClass, resourceInstance); newMethods.add(new ModelProcessorUtil.Method(HttpMethod.GET, consumes, produces, inflector)); newMethods.add(new ModelProcessorUtil.Method(IMPLICIT_VIEW_PATH_PARAMETER_TEMPLATE, HttpMethod.GET, consumes, produces, inflector)); } }
[ "private", "void", "createEnhancingMethods", "(", "final", "Class", "<", "?", ">", "resourceClass", ",", "final", "Object", "resourceInstance", ",", "final", "List", "<", "ModelProcessorUtil", ".", "Method", ">", "newMethods", ")", "{", "final", "Template", "tem...
Creates enhancing methods for given resource. @param resourceClass resource class for which enhancing methods should be created. @param resourceInstance resource instance for which enhancing methods should be created. May be {@code null}. @param newMethods list to store new methods into.
[ "Creates", "enhancing", "methods", "for", "given", "resource", "." ]
9d4956e935898e41331b2745e400ef869cd265e0
https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/mvc/template/internal/TemplateModelProcessor.java#L197-L215
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Anchor.java
Anchor.setHref
public void setHref (String href) { if (_forceProtocol) { // This will correct URLs that don't have http:// as well // as provide protection against JS injection if ( ! href.matches("^\\s*\\w+://.*")) { href = "http://" + href; } } else { // Always do some sort of JS protection if (href.trim().toLowerCase().startsWith("javascript:")) { // He's been a naughty boy href = "#"; } } DOM.setElementProperty(getElement(), "href", href); }
java
public void setHref (String href) { if (_forceProtocol) { // This will correct URLs that don't have http:// as well // as provide protection against JS injection if ( ! href.matches("^\\s*\\w+://.*")) { href = "http://" + href; } } else { // Always do some sort of JS protection if (href.trim().toLowerCase().startsWith("javascript:")) { // He's been a naughty boy href = "#"; } } DOM.setElementProperty(getElement(), "href", href); }
[ "public", "void", "setHref", "(", "String", "href", ")", "{", "if", "(", "_forceProtocol", ")", "{", "// This will correct URLs that don't have http:// as well", "// as provide protection against JS injection", "if", "(", "!", "href", ".", "matches", "(", "\"^\\\\s*\\\\w+...
Set the href location.
[ "Set", "the", "href", "location", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Anchor.java#L88-L105
train
xebialabs/overcast
src/main/java/com/xebialabs/overcast/support/libvirt/jdom/DomainXml.java
DomainXml.prepareForCloning
public static Document prepareForCloning(Document domainXml) { XPathFactory xpf = XPathFactory.instance(); // remove uuid so it will be generated domainXml.getRootElement().removeChild("uuid"); // remove mac address, so it will be generated XPathExpression<Element> macExpr = xpf.compile("/domain/devices/interface/mac", Filters.element()); for (Element mac : macExpr.evaluate(domainXml)) { mac.getParentElement().removeChild("mac"); } return domainXml; }
java
public static Document prepareForCloning(Document domainXml) { XPathFactory xpf = XPathFactory.instance(); // remove uuid so it will be generated domainXml.getRootElement().removeChild("uuid"); // remove mac address, so it will be generated XPathExpression<Element> macExpr = xpf.compile("/domain/devices/interface/mac", Filters.element()); for (Element mac : macExpr.evaluate(domainXml)) { mac.getParentElement().removeChild("mac"); } return domainXml; }
[ "public", "static", "Document", "prepareForCloning", "(", "Document", "domainXml", ")", "{", "XPathFactory", "xpf", "=", "XPathFactory", ".", "instance", "(", ")", ";", "// remove uuid so it will be generated", "domainXml", ".", "getRootElement", "(", ")", ".", "rem...
remove elements that need to be unique per clone.
[ "remove", "elements", "that", "need", "to", "be", "unique", "per", "clone", "." ]
716e57b66870c9afe51edc3b6045863a34fb0061
https://github.com/xebialabs/overcast/blob/716e57b66870c9afe51edc3b6045863a34fb0061/src/main/java/com/xebialabs/overcast/support/libvirt/jdom/DomainXml.java#L39-L51
train
icode/ameba
src/main/java/ameba/lib/Strands.java
Strands.join
public static void join(Object strand, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { Strand.join(strand, timeout, unit); }
java
public static void join(Object strand, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { Strand.join(strand, timeout, unit); }
[ "public", "static", "void", "join", "(", "Object", "strand", ",", "long", "timeout", ",", "TimeUnit", "unit", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "TimeoutException", "{", "Strand", ".", "join", "(", "strand", ",", "timeout", ...
Awaits the termination of a given strand, at most for the timeout duration specified. This method blocks until this strand terminates or the timeout elapses. @param strand the strand to join. May be an object of type {@code Strand}, {@code Fiber} or {@code Thread}. @param timeout the maximum duration to wait for the strand to terminate in the time unit specified by {@code unit}. @param unit the time unit of {@code timeout}. @throws TimeoutException if this strand did not terminate by the time the timeout has elapsed. @throws ExecutionException if this strand has terminated as a result of an uncaught exception (which will be the {@link Throwable#getCause() cause} of the thrown {@code ExecutionException}. @throws InterruptedException
[ "Awaits", "the", "termination", "of", "a", "given", "strand", "at", "most", "for", "the", "timeout", "duration", "specified", ".", "This", "method", "blocks", "until", "this", "strand", "terminates", "or", "the", "timeout", "elapses", "." ]
9d4956e935898e41331b2745e400ef869cd265e0
https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/lib/Strands.java#L112-L114
train
alexvasilkov/Events
library/src/main/java/com/alexvasilkov/events/internal/Utils.java
Utils.log
static void log(Object targetObj, String msg) { if (EventsParams.isDebug()) { Log.d(TAG, toLogStr(targetObj, msg)); } }
java
static void log(Object targetObj, String msg) { if (EventsParams.isDebug()) { Log.d(TAG, toLogStr(targetObj, msg)); } }
[ "static", "void", "log", "(", "Object", "targetObj", ",", "String", "msg", ")", "{", "if", "(", "EventsParams", ".", "isDebug", "(", ")", ")", "{", "Log", ".", "d", "(", "TAG", ",", "toLogStr", "(", "targetObj", ",", "msg", ")", ")", ";", "}", "}...
Logs target object
[ "Logs", "target", "object" ]
4208e11fab35d99229fe6c3b3d434ca1948f3fc5
https://github.com/alexvasilkov/Events/blob/4208e11fab35d99229fe6c3b3d434ca1948f3fc5/library/src/main/java/com/alexvasilkov/events/internal/Utils.java#L27-L31
train
alexvasilkov/Events
library/src/main/java/com/alexvasilkov/events/internal/Utils.java
Utils.logE
static void logE(Object targetObj, String msg) { Log.e(TAG, toLogStr(targetObj, msg)); }
java
static void logE(Object targetObj, String msg) { Log.e(TAG, toLogStr(targetObj, msg)); }
[ "static", "void", "logE", "(", "Object", "targetObj", ",", "String", "msg", ")", "{", "Log", ".", "e", "(", "TAG", ",", "toLogStr", "(", "targetObj", ",", "msg", ")", ")", ";", "}" ]
Logs target object error
[ "Logs", "target", "object", "error" ]
4208e11fab35d99229fe6c3b3d434ca1948f3fc5
https://github.com/alexvasilkov/Events/blob/4208e11fab35d99229fe6c3b3d434ca1948f3fc5/library/src/main/java/com/alexvasilkov/events/internal/Utils.java#L60-L62
train
alexvasilkov/Events
library/src/main/java/com/alexvasilkov/events/internal/Utils.java
Utils.logE
static void logE(String eventKey, String msg) { Log.e(TAG, toLogStr(eventKey, msg)); }
java
static void logE(String eventKey, String msg) { Log.e(TAG, toLogStr(eventKey, msg)); }
[ "static", "void", "logE", "(", "String", "eventKey", ",", "String", "msg", ")", "{", "Log", ".", "e", "(", "TAG", ",", "toLogStr", "(", "eventKey", ",", "msg", ")", ")", ";", "}" ]
Logs event error
[ "Logs", "event", "error" ]
4208e11fab35d99229fe6c3b3d434ca1948f3fc5
https://github.com/alexvasilkov/Events/blob/4208e11fab35d99229fe6c3b3d434ca1948f3fc5/library/src/main/java/com/alexvasilkov/events/internal/Utils.java#L65-L67
train
udoprog/tiny-async-java
tiny-async-examples/src/main/java/eu/toolchain/examples/helpers/ChartUtils.java
ChartUtils.createChart
private static JFreeChart createChart( String title, String xAxis, String yAxis1, XYDataset dataset1, String yAxis2, XYDataset dataset2 ) { JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis1, dataset1, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); int count = Math.min(dataset1.getSeriesCount(), dataset2.getSeriesCount()); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseStroke(LINE); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setDrawSeriesLineAsPath(true); for (int i = 0; i < count; i++) { renderer.setSeriesPaint(i, COLORS.get(i % COLORS.size())); } } chart.setBackgroundPaint(Color.white); // chart two { final NumberAxis axis2 = new NumberAxis(yAxis2); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setAutoPopulateSeriesPaint(false); renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setDrawSeriesLineAsPath(true); renderer.setBaseStroke(DASHED); for (int i = 0; i < count; i++) { renderer.setSeriesPaint(i, COLORS.get(i % COLORS.size())); } plot.setRenderer(1, renderer); } return chart; }
java
private static JFreeChart createChart( String title, String xAxis, String yAxis1, XYDataset dataset1, String yAxis2, XYDataset dataset2 ) { JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis1, dataset1, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); int count = Math.min(dataset1.getSeriesCount(), dataset2.getSeriesCount()); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseStroke(LINE); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setDrawSeriesLineAsPath(true); for (int i = 0; i < count; i++) { renderer.setSeriesPaint(i, COLORS.get(i % COLORS.size())); } } chart.setBackgroundPaint(Color.white); // chart two { final NumberAxis axis2 = new NumberAxis(yAxis2); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setAutoPopulateSeriesPaint(false); renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setDrawSeriesLineAsPath(true); renderer.setBaseStroke(DASHED); for (int i = 0; i < count; i++) { renderer.setSeriesPaint(i, COLORS.get(i % COLORS.size())); } plot.setRenderer(1, renderer); } return chart; }
[ "private", "static", "JFreeChart", "createChart", "(", "String", "title", ",", "String", "xAxis", ",", "String", "yAxis1", ",", "XYDataset", "dataset1", ",", "String", "yAxis2", ",", "XYDataset", "dataset2", ")", "{", "JFreeChart", "chart", "=", "ChartFactory", ...
Creates a chart. @return A chart.
[ "Creates", "a", "chart", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-examples/src/main/java/eu/toolchain/examples/helpers/ChartUtils.java#L38-L100
train
udoprog/tiny-async-java
tiny-async-examples/src/main/java/eu/toolchain/examples/helpers/ChartUtils.java
ChartUtils.showChart
public static void showChart( String name, String xAxis, String yAxis1, XYDataset dataset1, String yAxis2, XYDataset dataset2 ) { final JFreeChart chart = createChart(name, xAxis, yAxis1, dataset1, yAxis2, dataset2); final ChartPanel chartPanel = createPanel(chart); final ApplicationFrame app = new ApplicationFrame(name); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); app.setContentPane(chartPanel); app.pack(); RefineryUtilities.centerFrameOnScreen(app); app.setVisible(true); }
java
public static void showChart( String name, String xAxis, String yAxis1, XYDataset dataset1, String yAxis2, XYDataset dataset2 ) { final JFreeChart chart = createChart(name, xAxis, yAxis1, dataset1, yAxis2, dataset2); final ChartPanel chartPanel = createPanel(chart); final ApplicationFrame app = new ApplicationFrame(name); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); app.setContentPane(chartPanel); app.pack(); RefineryUtilities.centerFrameOnScreen(app); app.setVisible(true); }
[ "public", "static", "void", "showChart", "(", "String", "name", ",", "String", "xAxis", ",", "String", "yAxis1", ",", "XYDataset", "dataset1", ",", "String", "yAxis2", ",", "XYDataset", "dataset2", ")", "{", "final", "JFreeChart", "chart", "=", "createChart", ...
Starting point for the demonstration application.
[ "Starting", "point", "for", "the", "demonstration", "application", "." ]
987706d4b7f2d13b45eefdc6c54ea63ce64b3310
https://github.com/udoprog/tiny-async-java/blob/987706d4b7f2d13b45eefdc6c54ea63ce64b3310/tiny-async-examples/src/main/java/eu/toolchain/examples/helpers/ChartUtils.java#L117-L133
train
stackify/stackify-metrics
src/main/java/com/stackify/metric/impl/MetricCollector.java
MetricCollector.submit
public void submit(final Metric metric) { if (metric != null) { LOGGER.debug("Collecting metric: {}", metric); queue.offer(metric); } }
java
public void submit(final Metric metric) { if (metric != null) { LOGGER.debug("Collecting metric: {}", metric); queue.offer(metric); } }
[ "public", "void", "submit", "(", "final", "Metric", "metric", ")", "{", "if", "(", "metric", "!=", "null", ")", "{", "LOGGER", ".", "debug", "(", "\"Collecting metric: {}\"", ",", "metric", ")", ";", "queue", ".", "offer", "(", "metric", ")", ";", "}",...
Submits a metric to the queue @param metric The metric
[ "Submits", "a", "metric", "to", "the", "queue" ]
6827d516085e4b29a3e54da963eebb2955822a5c
https://github.com/stackify/stackify-metrics/blob/6827d516085e4b29a3e54da963eebb2955822a5c/src/main/java/com/stackify/metric/impl/MetricCollector.java#L96-L101
train
stackify/stackify-metrics
src/main/java/com/stackify/metric/impl/MetricCollector.java
MetricCollector.flush
public int flush(final MetricSender sender) throws IOException, HttpException { Preconditions.checkNotNull(sender); // aggregate metrics that were enqueued before the current minute long currentMinute = (System.currentTimeMillis() / MS_IN_MIN) * MS_IN_MIN; LOGGER.debug("Flushing metrics < {}", currentMinute); LOGGER.debug("Metrics queue size {}", queue.size()); MetricAggregator aggregator = new MetricAggregator(currentMinute, lastValues); while ((!queue.isEmpty()) && (queue.peek().getOccurredMillis() < currentMinute)) { aggregator.add(queue.remove()); } // handle the auto reports if (lastFlush < currentMinute) { aggregator.autoReportZero(autoReportZeroMetrics); aggregator.autoReportLast(autoReportLastMetrics); } lastFlush = currentMinute; // get the aggregates List<MetricAggregate> aggregates = aggregator.getAggregates(); // Save the values of gauge and average metrics for the next iteration // Gauge last value = aggregate last value // Average last value = aggregate last value / aggregate count if ((aggregates != null) && (!aggregates.isEmpty())) { for (MetricAggregate aggregate : aggregates) { if (aggregate.getIdentity().getType().equals(MetricMonitorType.GAUGE)) { lastValues.put(aggregate.getIdentity(), aggregate.getValue()); } else if (aggregate.getIdentity().getType().equals(MetricMonitorType.AVERAGE)) { lastValues.put(aggregate.getIdentity(), aggregate.getValue() / aggregate.getCount()); } } } // send the aggregates to Stackify int numSent = 0; if ((aggregates != null) && (!aggregates.isEmpty())) { LOGGER.debug("Sending aggregate metrics: {}", aggregates); sender.send(aggregates); numSent = aggregates.size(); } return numSent; }
java
public int flush(final MetricSender sender) throws IOException, HttpException { Preconditions.checkNotNull(sender); // aggregate metrics that were enqueued before the current minute long currentMinute = (System.currentTimeMillis() / MS_IN_MIN) * MS_IN_MIN; LOGGER.debug("Flushing metrics < {}", currentMinute); LOGGER.debug("Metrics queue size {}", queue.size()); MetricAggregator aggregator = new MetricAggregator(currentMinute, lastValues); while ((!queue.isEmpty()) && (queue.peek().getOccurredMillis() < currentMinute)) { aggregator.add(queue.remove()); } // handle the auto reports if (lastFlush < currentMinute) { aggregator.autoReportZero(autoReportZeroMetrics); aggregator.autoReportLast(autoReportLastMetrics); } lastFlush = currentMinute; // get the aggregates List<MetricAggregate> aggregates = aggregator.getAggregates(); // Save the values of gauge and average metrics for the next iteration // Gauge last value = aggregate last value // Average last value = aggregate last value / aggregate count if ((aggregates != null) && (!aggregates.isEmpty())) { for (MetricAggregate aggregate : aggregates) { if (aggregate.getIdentity().getType().equals(MetricMonitorType.GAUGE)) { lastValues.put(aggregate.getIdentity(), aggregate.getValue()); } else if (aggregate.getIdentity().getType().equals(MetricMonitorType.AVERAGE)) { lastValues.put(aggregate.getIdentity(), aggregate.getValue() / aggregate.getCount()); } } } // send the aggregates to Stackify int numSent = 0; if ((aggregates != null) && (!aggregates.isEmpty())) { LOGGER.debug("Sending aggregate metrics: {}", aggregates); sender.send(aggregates); numSent = aggregates.size(); } return numSent; }
[ "public", "int", "flush", "(", "final", "MetricSender", "sender", ")", "throws", "IOException", ",", "HttpException", "{", "Preconditions", ".", "checkNotNull", "(", "sender", ")", ";", "// aggregate metrics that were enqueued before the current minute", "long", "currentM...
Flushes all queued metrics to Stackify @param sender Responsible for sending to Stackify @return The number of metric aggregates sent to Stackify @throws IOException @throws HttpException
[ "Flushes", "all", "queued", "metrics", "to", "Stackify" ]
6827d516085e4b29a3e54da963eebb2955822a5c
https://github.com/stackify/stackify-metrics/blob/6827d516085e4b29a3e54da963eebb2955822a5c/src/main/java/com/stackify/metric/impl/MetricCollector.java#L110-L164
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.infoOn
public static InfoPopup infoOn (String message, Widget target) { return centerOn(new InfoPopup(message), target); }
java
public static InfoPopup infoOn (String message, Widget target) { return centerOn(new InfoPopup(message), target); }
[ "public", "static", "InfoPopup", "infoOn", "(", "String", "message", ",", "Widget", "target", ")", "{", "return", "centerOn", "(", "new", "InfoPopup", "(", "message", ")", ",", "target", ")", ";", "}" ]
Displays an info message centered horizontally on the page and centered vertically on the specified target widget.
[ "Displays", "an", "info", "message", "centered", "horizontally", "on", "the", "page", "and", "centered", "vertically", "on", "the", "specified", "target", "widget", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L93-L96
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.show
public static <T extends PopupPanel> T show (T popup, Position pos, Widget target) { popup.setVisible(false); popup.show(); int left, top; switch (pos) { case RIGHT: left = target.getAbsoluteLeft() + target.getOffsetWidth() + NEAR_GAP; break; default: left = target.getAbsoluteLeft(); break; } if (left + popup.getOffsetWidth() > Window.getClientWidth()) { left = Math.max(0, Window.getClientWidth() - popup.getOffsetWidth()); } switch (pos) { case ABOVE: top = target.getAbsoluteTop() - popup.getOffsetHeight() - NEAR_GAP; break; case OVER: top = target.getAbsoluteTop(); break; case RIGHT: top = target.getAbsoluteTop() + (target.getOffsetHeight() - popup.getOffsetHeight())/2; break; default: case BELOW: top = target.getAbsoluteTop() + target.getOffsetHeight() + NEAR_GAP; break; } popup.setPopupPosition(left, top); popup.setVisible(true); return popup; }
java
public static <T extends PopupPanel> T show (T popup, Position pos, Widget target) { popup.setVisible(false); popup.show(); int left, top; switch (pos) { case RIGHT: left = target.getAbsoluteLeft() + target.getOffsetWidth() + NEAR_GAP; break; default: left = target.getAbsoluteLeft(); break; } if (left + popup.getOffsetWidth() > Window.getClientWidth()) { left = Math.max(0, Window.getClientWidth() - popup.getOffsetWidth()); } switch (pos) { case ABOVE: top = target.getAbsoluteTop() - popup.getOffsetHeight() - NEAR_GAP; break; case OVER: top = target.getAbsoluteTop(); break; case RIGHT: top = target.getAbsoluteTop() + (target.getOffsetHeight() - popup.getOffsetHeight())/2; break; default: case BELOW: top = target.getAbsoluteTop() + target.getOffsetHeight() + NEAR_GAP; break; } popup.setPopupPosition(left, top); popup.setVisible(true); return popup; }
[ "public", "static", "<", "T", "extends", "PopupPanel", ">", "T", "show", "(", "T", "popup", ",", "Position", "pos", ",", "Widget", "target", ")", "{", "popup", ".", "setVisible", "(", "false", ")", ";", "popup", ".", "show", "(", ")", ";", "int", "...
Shows the supplied popup in the specified position relative to the specified target widget.
[ "Shows", "the", "supplied", "popup", "in", "the", "specified", "position", "relative", "to", "the", "specified", "target", "widget", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L156-L193
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.showAbove
public static <T extends PopupPanel> T showAbove (T popup, Widget target) { return show(popup, Position.ABOVE, target); }
java
public static <T extends PopupPanel> T showAbove (T popup, Widget target) { return show(popup, Position.ABOVE, target); }
[ "public", "static", "<", "T", "extends", "PopupPanel", ">", "T", "showAbove", "(", "T", "popup", ",", "Widget", "target", ")", "{", "return", "show", "(", "popup", ",", "Position", ".", "ABOVE", ",", "target", ")", ";", "}" ]
Shows the supplied popup panel near the specified target.
[ "Shows", "the", "supplied", "popup", "panel", "near", "the", "specified", "target", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L204-L207
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.showOver
public static <T extends PopupPanel> T showOver (T popup, Widget target) { return show(popup, Position.OVER, target); }
java
public static <T extends PopupPanel> T showOver (T popup, Widget target) { return show(popup, Position.OVER, target); }
[ "public", "static", "<", "T", "extends", "PopupPanel", ">", "T", "showOver", "(", "T", "popup", ",", "Widget", "target", ")", "{", "return", "show", "(", "popup", ",", "Position", ".", "OVER", ",", "target", ")", ";", "}" ]
Shows the supplied popup panel over the specified target.
[ "Shows", "the", "supplied", "popup", "panel", "over", "the", "specified", "target", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L212-L215
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.showBelow
public static <T extends PopupPanel> T showBelow (T popup, Widget target) { return show(popup, Position.BELOW, target); }
java
public static <T extends PopupPanel> T showBelow (T popup, Widget target) { return show(popup, Position.BELOW, target); }
[ "public", "static", "<", "T", "extends", "PopupPanel", ">", "T", "showBelow", "(", "T", "popup", ",", "Widget", "target", ")", "{", "return", "show", "(", "popup", ",", "Position", ".", "BELOW", ",", "target", ")", ";", "}" ]
Shows the supplied popup panel below the specified target.
[ "Shows", "the", "supplied", "popup", "panel", "below", "the", "specified", "target", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L220-L223
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.newPopup
public static PopupPanel newPopup (String styleName, Widget contents) { PopupPanel panel = new PopupPanel(); panel.setStyleName(styleName); panel.setWidget(contents); return panel; }
java
public static PopupPanel newPopup (String styleName, Widget contents) { PopupPanel panel = new PopupPanel(); panel.setStyleName(styleName); panel.setWidget(contents); return panel; }
[ "public", "static", "PopupPanel", "newPopup", "(", "String", "styleName", ",", "Widget", "contents", ")", "{", "PopupPanel", "panel", "=", "new", "PopupPanel", "(", ")", ";", "panel", ".", "setStyleName", "(", "styleName", ")", ";", "panel", ".", "setWidget"...
Creates and returns a new popup with the specified style name and contents.
[ "Creates", "and", "returns", "a", "new", "popup", "with", "the", "specified", "style", "name", "and", "contents", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L269-L275
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.newPopup
public static PopupPanel newPopup (String styleName, Widget contents, Position pos, Widget target) { PopupPanel panel = newPopup(styleName, contents); show(panel, pos, target); return panel; }
java
public static PopupPanel newPopup (String styleName, Widget contents, Position pos, Widget target) { PopupPanel panel = newPopup(styleName, contents); show(panel, pos, target); return panel; }
[ "public", "static", "PopupPanel", "newPopup", "(", "String", "styleName", ",", "Widget", "contents", ",", "Position", "pos", ",", "Widget", "target", ")", "{", "PopupPanel", "panel", "=", "newPopup", "(", "styleName", ",", "contents", ")", ";", "show", "(", ...
Creates a new popup with the specified style name and contents and shows it near the specified target widget. Returns the newly created popup.
[ "Creates", "a", "new", "popup", "with", "the", "specified", "style", "name", "and", "contents", "and", "shows", "it", "near", "the", "specified", "target", "widget", ".", "Returns", "the", "newly", "created", "popup", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L281-L287
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.createHider
public static ClickHandler createHider (final PopupPanel popup) { return new ClickHandler() { public void onClick (ClickEvent event) { popup.hide(); } }; }
java
public static ClickHandler createHider (final PopupPanel popup) { return new ClickHandler() { public void onClick (ClickEvent event) { popup.hide(); } }; }
[ "public", "static", "ClickHandler", "createHider", "(", "final", "PopupPanel", "popup", ")", "{", "return", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "popup", ".", "hide", "(", ")", ";", "}", ...
Creates a click handler that hides the specified popup. Useful when creating popups that behave like menus.
[ "Creates", "a", "click", "handler", "that", "hides", "the", "specified", "popup", ".", "Useful", "when", "creating", "popups", "that", "behave", "like", "menus", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L293-L300
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/Popups.java
Popups.makeDraggable
public static void makeDraggable (HasAllMouseHandlers dragHandle, PopupPanel target) { DragHandler dragger = new DragHandler(target); dragHandle.addMouseDownHandler(dragger); dragHandle.addMouseUpHandler(dragger); dragHandle.addMouseMoveHandler(dragger); }
java
public static void makeDraggable (HasAllMouseHandlers dragHandle, PopupPanel target) { DragHandler dragger = new DragHandler(target); dragHandle.addMouseDownHandler(dragger); dragHandle.addMouseUpHandler(dragger); dragHandle.addMouseMoveHandler(dragger); }
[ "public", "static", "void", "makeDraggable", "(", "HasAllMouseHandlers", "dragHandle", ",", "PopupPanel", "target", ")", "{", "DragHandler", "dragger", "=", "new", "DragHandler", "(", "target", ")", ";", "dragHandle", ".", "addMouseDownHandler", "(", "dragger", ")...
Adds mouse handlers to the specified drag handle that cause the supplied target popup to be dragged around the display. The drag handle is assumed to be a child of the popup.
[ "Adds", "mouse", "handlers", "to", "the", "specified", "drag", "handle", "that", "cause", "the", "supplied", "target", "popup", "to", "be", "dragged", "around", "the", "display", ".", "The", "drag", "handle", "is", "assumed", "to", "be", "a", "child", "of"...
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L392-L398
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.setHTML
public void setHTML (int row, int column, String text, int colSpan, String... styles) { setHTML(row, column, text); if (colSpan > 0) { getFlexCellFormatter().setColSpan(row, column, colSpan); } setStyleNames(row, column, styles); }
java
public void setHTML (int row, int column, String text, int colSpan, String... styles) { setHTML(row, column, text); if (colSpan > 0) { getFlexCellFormatter().setColSpan(row, column, colSpan); } setStyleNames(row, column, styles); }
[ "public", "void", "setHTML", "(", "int", "row", ",", "int", "column", ",", "String", "text", ",", "int", "colSpan", ",", "String", "...", "styles", ")", "{", "setHTML", "(", "row", ",", "column", ",", "text", ")", ";", "if", "(", "colSpan", ">", "0...
Sets the HTML in the specified cell, with the specified style and column span.
[ "Sets", "the", "HTML", "in", "the", "specified", "cell", "with", "the", "specified", "style", "and", "column", "span", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L282-L289
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.addText
public int addText (Object text, int colSpan, String... styles) { int row = getRowCount(); setText(row, 0, text, colSpan, styles); return row; }
java
public int addText (Object text, int colSpan, String... styles) { int row = getRowCount(); setText(row, 0, text, colSpan, styles); return row; }
[ "public", "int", "addText", "(", "Object", "text", ",", "int", "colSpan", ",", "String", "...", "styles", ")", "{", "int", "row", "=", "getRowCount", "(", ")", ";", "setText", "(", "row", ",", "0", ",", "text", ",", "colSpan", ",", "styles", ")", "...
Adds text to the bottom row of this table in column zero, with the specified column span and style. @param text an object whose string value will be displayed. @return the row to which the text was added.
[ "Adds", "text", "to", "the", "bottom", "row", "of", "this", "table", "in", "column", "zero", "with", "the", "specified", "column", "span", "and", "style", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L311-L316
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.addWidget
public int addWidget (Widget widget, int colSpan, String... styles) { int row = getRowCount(); setWidget(row, 0, widget, colSpan, styles); return row; }
java
public int addWidget (Widget widget, int colSpan, String... styles) { int row = getRowCount(); setWidget(row, 0, widget, colSpan, styles); return row; }
[ "public", "int", "addWidget", "(", "Widget", "widget", ",", "int", "colSpan", ",", "String", "...", "styles", ")", "{", "int", "row", "=", "getRowCount", "(", ")", ";", "setWidget", "(", "row", ",", "0", ",", "widget", ",", "colSpan", ",", "styles", ...
Adds a widget to the bottom row of this table in column zero, with the specified column span and style. @return the row to which the widget was added.
[ "Adds", "a", "widget", "to", "the", "bottom", "row", "of", "this", "table", "in", "column", "zero", "with", "the", "specified", "column", "span", "and", "style", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L324-L329
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.setStyleNames
public void setStyleNames (int row, int column, String... styles) { int idx = 0; for (String style : styles) { if (idx++ == 0) { getFlexCellFormatter().setStyleName(row, column, style); } else { getFlexCellFormatter().addStyleName(row, column, style); } } }
java
public void setStyleNames (int row, int column, String... styles) { int idx = 0; for (String style : styles) { if (idx++ == 0) { getFlexCellFormatter().setStyleName(row, column, style); } else { getFlexCellFormatter().addStyleName(row, column, style); } } }
[ "public", "void", "setStyleNames", "(", "int", "row", ",", "int", "column", ",", "String", "...", "styles", ")", "{", "int", "idx", "=", "0", ";", "for", "(", "String", "style", ":", "styles", ")", "{", "if", "(", "idx", "++", "==", "0", ")", "{"...
Configures the specified style names on the specified row and column. The first style is set as the primary style and additional styles are added onto that.
[ "Configures", "the", "specified", "style", "names", "on", "the", "specified", "row", "and", "column", ".", "The", "first", "style", "is", "set", "as", "the", "primary", "style", "and", "additional", "styles", "are", "added", "onto", "that", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L335-L345
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.setColumnCellStyles
public void setColumnCellStyles (int column, String... styles) { int rowCount = getRowCount(); for (int row = 0; row < rowCount; ++row) { setStyleNames(row, column, styles); } }
java
public void setColumnCellStyles (int column, String... styles) { int rowCount = getRowCount(); for (int row = 0; row < rowCount; ++row) { setStyleNames(row, column, styles); } }
[ "public", "void", "setColumnCellStyles", "(", "int", "column", ",", "String", "...", "styles", ")", "{", "int", "rowCount", "=", "getRowCount", "(", ")", ";", "for", "(", "int", "row", "=", "0", ";", "row", "<", "rowCount", ";", "++", "row", ")", "{"...
Sets the style of all cells in the given column to the given values. The first style is set as the primary style and additional styles are added onto that.
[ "Sets", "the", "style", "of", "all", "cells", "in", "the", "given", "column", "to", "the", "given", "values", ".", "The", "first", "style", "is", "set", "as", "the", "primary", "style", "and", "additional", "styles", "are", "added", "onto", "that", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L351-L357
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.removeStyleNames
public void removeStyleNames (int row, int column, String... styles) { for (String style : styles) { getFlexCellFormatter().removeStyleName(row, column, style); } }
java
public void removeStyleNames (int row, int column, String... styles) { for (String style : styles) { getFlexCellFormatter().removeStyleName(row, column, style); } }
[ "public", "void", "removeStyleNames", "(", "int", "row", ",", "int", "column", ",", "String", "...", "styles", ")", "{", "for", "(", "String", "style", ":", "styles", ")", "{", "getFlexCellFormatter", "(", ")", ".", "removeStyleName", "(", "row", ",", "c...
Removes the specified style names on the specified row and column.
[ "Removes", "the", "specified", "style", "names", "on", "the", "specified", "row", "and", "column", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L362-L367
train
ebean-orm/ebean-mocker
src/main/java/io/ebean/MethodCall.java
MethodCall.with
public MethodCall with(String name1, Object arg1) { return with(name1, arg1, null, null, null, null); }
java
public MethodCall with(String name1, Object arg1) { return with(name1, arg1, null, null, null, null); }
[ "public", "MethodCall", "with", "(", "String", "name1", ",", "Object", "arg1", ")", "{", "return", "with", "(", "name1", ",", "arg1", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Add the single argument.
[ "Add", "the", "single", "argument", "." ]
98c14a58253e8cd40b2a0c9b49526a307079389a
https://github.com/ebean-orm/ebean-mocker/blob/98c14a58253e8cd40b2a0c9b49526a307079389a/src/main/java/io/ebean/MethodCall.java#L29-L31
train
ebean-orm/ebean-mocker
src/main/java/io/ebean/MethodCall.java
MethodCall.with
public MethodCall with(String name1, Object arg1, String name2, Object arg2) { return with(name1, arg1, name2, arg2, null, null); }
java
public MethodCall with(String name1, Object arg1, String name2, Object arg2) { return with(name1, arg1, name2, arg2, null, null); }
[ "public", "MethodCall", "with", "(", "String", "name1", ",", "Object", "arg1", ",", "String", "name2", ",", "Object", "arg2", ")", "{", "return", "with", "(", "name1", ",", "arg1", ",", "name2", ",", "arg2", ",", "null", ",", "null", ")", ";", "}" ]
Add the two arguments.
[ "Add", "the", "two", "arguments", "." ]
98c14a58253e8cd40b2a0c9b49526a307079389a
https://github.com/ebean-orm/ebean-mocker/blob/98c14a58253e8cd40b2a0c9b49526a307079389a/src/main/java/io/ebean/MethodCall.java#L36-L38
train
ebean-orm/ebean-mocker
src/main/java/io/ebean/MethodCall.java
MethodCall.with
public MethodCall with(String name1, Object arg1, String name2, Object arg2, String name3, Object arg3, String name4, Object arg4) { args.put(name1, arg1); if (name2 != null) { args.put(name2, arg2); if (name3 != null) { args.put(name3, arg3); if (name4 != null) { args.put(name4, arg4); } } } return this; }
java
public MethodCall with(String name1, Object arg1, String name2, Object arg2, String name3, Object arg3, String name4, Object arg4) { args.put(name1, arg1); if (name2 != null) { args.put(name2, arg2); if (name3 != null) { args.put(name3, arg3); if (name4 != null) { args.put(name4, arg4); } } } return this; }
[ "public", "MethodCall", "with", "(", "String", "name1", ",", "Object", "arg1", ",", "String", "name2", ",", "Object", "arg2", ",", "String", "name3", ",", "Object", "arg3", ",", "String", "name4", ",", "Object", "arg4", ")", "{", "args", ".", "put", "(...
Add four arguments.
[ "Add", "four", "arguments", "." ]
98c14a58253e8cd40b2a0c9b49526a307079389a
https://github.com/ebean-orm/ebean-mocker/blob/98c14a58253e8cd40b2a0c9b49526a307079389a/src/main/java/io/ebean/MethodCall.java#L50-L62
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/Functions.java
Functions.forMap
public static <K, V> Function<K, V> forMap (final Map<K, ? extends V> map, final V defaultValue) { return new Function<K, V>() { public V apply (K key) { V value = map.get(key); return (value != null || map.containsKey(key)) ? value : defaultValue; } }; }
java
public static <K, V> Function<K, V> forMap (final Map<K, ? extends V> map, final V defaultValue) { return new Function<K, V>() { public V apply (K key) { V value = map.get(key); return (value != null || map.containsKey(key)) ? value : defaultValue; } }; }
[ "public", "static", "<", "K", ",", "V", ">", "Function", "<", "K", ",", "V", ">", "forMap", "(", "final", "Map", "<", "K", ",", "?", "extends", "V", ">", "map", ",", "final", "V", "defaultValue", ")", "{", "return", "new", "Function", "<", "K", ...
Returns a function which performs a map lookup with a default value. The function created by this method returns defaultValue for all inputs that do not belong to the map's key set.
[ "Returns", "a", "function", "which", "performs", "a", "map", "lookup", "with", "a", "default", "value", ".", "The", "function", "created", "by", "this", "method", "returns", "defaultValue", "for", "all", "inputs", "that", "do", "not", "belong", "to", "the", ...
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/Functions.java#L45-L53
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/Functions.java
Functions.forPredicate
public static <T> Function<T, Boolean> forPredicate (final Predicate<T> predicate) { return new Function<T, Boolean>() { public Boolean apply (T arg) { return predicate.apply(arg); } }; }
java
public static <T> Function<T, Boolean> forPredicate (final Predicate<T> predicate) { return new Function<T, Boolean>() { public Boolean apply (T arg) { return predicate.apply(arg); } }; }
[ "public", "static", "<", "T", ">", "Function", "<", "T", ",", "Boolean", ">", "forPredicate", "(", "final", "Predicate", "<", "T", ">", "predicate", ")", "{", "return", "new", "Function", "<", "T", ",", "Boolean", ">", "(", ")", "{", "public", "Boole...
Returns a function that returns the same boolean output as the given predicate for all inputs.
[ "Returns", "a", "function", "that", "returns", "the", "same", "boolean", "output", "as", "the", "given", "predicate", "for", "all", "inputs", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/Functions.java#L59-L66
train
xebialabs/overcast
src/main/java/com/xebialabs/overcast/OvercastProperties.java
OvercastProperties.getOvercastPropertyNames
public static Set<String> getOvercastPropertyNames(final String path) { Config overcastConfig = getOvercastConfig(); if (!overcastConfig.hasPath(path)) { return new HashSet<>(); } Config cfg = overcastConfig.getConfig(path); Set<String> result = new HashSet<>(); for (Map.Entry<String, ConfigValue> e : cfg.entrySet()) { result.add(ConfigUtil.splitPath(e.getKey()).get(0)); } return result; }
java
public static Set<String> getOvercastPropertyNames(final String path) { Config overcastConfig = getOvercastConfig(); if (!overcastConfig.hasPath(path)) { return new HashSet<>(); } Config cfg = overcastConfig.getConfig(path); Set<String> result = new HashSet<>(); for (Map.Entry<String, ConfigValue> e : cfg.entrySet()) { result.add(ConfigUtil.splitPath(e.getKey()).get(0)); } return result; }
[ "public", "static", "Set", "<", "String", ">", "getOvercastPropertyNames", "(", "final", "String", "path", ")", "{", "Config", "overcastConfig", "=", "getOvercastConfig", "(", ")", ";", "if", "(", "!", "overcastConfig", ".", "hasPath", "(", "path", ")", ")",...
Get set of property names directly below path.
[ "Get", "set", "of", "property", "names", "directly", "below", "path", "." ]
716e57b66870c9afe51edc3b6045863a34fb0061
https://github.com/xebialabs/overcast/blob/716e57b66870c9afe51edc3b6045863a34fb0061/src/main/java/com/xebialabs/overcast/OvercastProperties.java#L53-L66
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/WindowUtil.java
WindowUtil.getScrollIntoView
public static int getScrollIntoView (Widget target) { int top = Window.getScrollTop(), height = Window.getClientHeight(); int ttop = target.getAbsoluteTop(), theight = target.getOffsetHeight(); // if the target widget is taller than the browser window, or is above the current scroll // position of the browser window, scroll the top of the widget to the top of the window if (theight > height || ttop < top) { return ttop; // otherwise scroll the bottom of the widget to the bottom of the window } else if (ttop + theight > top + height) { return ttop - (height - theight); } else { return top; // no scrolling needed } }
java
public static int getScrollIntoView (Widget target) { int top = Window.getScrollTop(), height = Window.getClientHeight(); int ttop = target.getAbsoluteTop(), theight = target.getOffsetHeight(); // if the target widget is taller than the browser window, or is above the current scroll // position of the browser window, scroll the top of the widget to the top of the window if (theight > height || ttop < top) { return ttop; // otherwise scroll the bottom of the widget to the bottom of the window } else if (ttop + theight > top + height) { return ttop - (height - theight); } else { return top; // no scrolling needed } }
[ "public", "static", "int", "getScrollIntoView", "(", "Widget", "target", ")", "{", "int", "top", "=", "Window", ".", "getScrollTop", "(", ")", ",", "height", "=", "Window", ".", "getClientHeight", "(", ")", ";", "int", "ttop", "=", "target", ".", "getAbs...
Returns the vertical scroll position needed to place the specified target widget in view, while trying to minimize scrolling.
[ "Returns", "the", "vertical", "scroll", "position", "needed", "to", "place", "the", "specified", "target", "widget", "in", "view", "while", "trying", "to", "minimize", "scrolling", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/WindowUtil.java#L74-L88
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/WindowUtil.java
WindowUtil.getScrollToMiddle
public static int getScrollToMiddle (Widget target) { int wheight = Window.getClientHeight(), theight = target.getOffsetHeight(); int ttop = target.getAbsoluteTop(); return Math.max(ttop, ttop + (wheight - theight)); }
java
public static int getScrollToMiddle (Widget target) { int wheight = Window.getClientHeight(), theight = target.getOffsetHeight(); int ttop = target.getAbsoluteTop(); return Math.max(ttop, ttop + (wheight - theight)); }
[ "public", "static", "int", "getScrollToMiddle", "(", "Widget", "target", ")", "{", "int", "wheight", "=", "Window", ".", "getClientHeight", "(", ")", ",", "theight", "=", "target", ".", "getOffsetHeight", "(", ")", ";", "int", "ttop", "=", "target", ".", ...
Returns the vertical scroll position needed to center the target widget vertically in the browser viewport. If the widget is taller than the viewport, its top is returned.
[ "Returns", "the", "vertical", "scroll", "position", "needed", "to", "center", "the", "target", "widget", "vertically", "in", "the", "browser", "viewport", ".", "If", "the", "widget", "is", "taller", "than", "the", "viewport", "its", "top", "is", "returned", ...
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/WindowUtil.java#L103-L108
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/WindowUtil.java
WindowUtil.isScrolledIntoView
public static boolean isScrolledIntoView (Widget target, int minPixels) { int wtop = Window.getScrollTop(), wheight = Window.getClientHeight(); int ttop = target.getAbsoluteTop(); if (ttop > wtop) { return (wtop + wheight - ttop > minPixels); } else { return (ttop + target.getOffsetHeight() - wtop > minPixels); } }
java
public static boolean isScrolledIntoView (Widget target, int minPixels) { int wtop = Window.getScrollTop(), wheight = Window.getClientHeight(); int ttop = target.getAbsoluteTop(); if (ttop > wtop) { return (wtop + wheight - ttop > minPixels); } else { return (ttop + target.getOffsetHeight() - wtop > minPixels); } }
[ "public", "static", "boolean", "isScrolledIntoView", "(", "Widget", "target", ",", "int", "minPixels", ")", "{", "int", "wtop", "=", "Window", ".", "getScrollTop", "(", ")", ",", "wheight", "=", "Window", ".", "getClientHeight", "(", ")", ";", "int", "ttop...
Returns true if the target widget is vertically scrolled into view. @param minPixels the minimum number of pixels that must be visible to count as "in view".
[ "Returns", "true", "if", "the", "target", "widget", "is", "vertically", "scrolled", "into", "view", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/WindowUtil.java#L133-L142
train
stackify/stackify-metrics
src/main/java/com/stackify/metric/impl/MetricAggregate.java
MetricAggregate.fromMetricIdentity
public static MetricAggregate fromMetricIdentity(final MetricIdentity identity, final long currentMinute) { Preconditions.checkNotNull(identity); return new MetricAggregate(identity, currentMinute); }
java
public static MetricAggregate fromMetricIdentity(final MetricIdentity identity, final long currentMinute) { Preconditions.checkNotNull(identity); return new MetricAggregate(identity, currentMinute); }
[ "public", "static", "MetricAggregate", "fromMetricIdentity", "(", "final", "MetricIdentity", "identity", ",", "final", "long", "currentMinute", ")", "{", "Preconditions", ".", "checkNotNull", "(", "identity", ")", ";", "return", "new", "MetricAggregate", "(", "ident...
Creates a MetricAggregate @param identity The metric identity @param currentMinute Current minute @return The MetricAggregate
[ "Creates", "a", "MetricAggregate" ]
6827d516085e4b29a3e54da963eebb2955822a5c
https://github.com/stackify/stackify-metrics/blob/6827d516085e4b29a3e54da963eebb2955822a5c/src/main/java/com/stackify/metric/impl/MetricAggregate.java#L52-L55
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/util/Console.java
Console.log
public static void log (String message, Object... args) { StringBuilder sb = new StringBuilder(); sb.append(message); if (args.length > 1) { sb.append(" ["); for (int ii = 0, ll = args.length/2; ii < ll; ii++) { if (ii > 0) { sb.append(", "); } sb.append(args[2*ii]).append("=").append(args[2*ii+1]); } sb.append("]"); } Object error = (args.length % 2 == 1) ? args[args.length-1] : null; if (GWT.isScript()) { if (error != null) { sb.append(": ").append(error); } firebugLog(sb.toString(), error); } else { GWT.log(sb.toString(), (Throwable)error); } }
java
public static void log (String message, Object... args) { StringBuilder sb = new StringBuilder(); sb.append(message); if (args.length > 1) { sb.append(" ["); for (int ii = 0, ll = args.length/2; ii < ll; ii++) { if (ii > 0) { sb.append(", "); } sb.append(args[2*ii]).append("=").append(args[2*ii+1]); } sb.append("]"); } Object error = (args.length % 2 == 1) ? args[args.length-1] : null; if (GWT.isScript()) { if (error != null) { sb.append(": ").append(error); } firebugLog(sb.toString(), error); } else { GWT.log(sb.toString(), (Throwable)error); } }
[ "public", "static", "void", "log", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "message", ")", ";", "if", "(", "args", ".", "length", "...
Formats and logs a message. If we are running in HostedMode the log message will be reported to its console. If we're running in Firefox, the log message will be sent to Firebug if it is enabled.
[ "Formats", "and", "logs", "a", "message", ".", "If", "we", "are", "running", "in", "HostedMode", "the", "log", "message", "will", "be", "reported", "to", "its", "console", ".", "If", "we", "re", "running", "in", "Firefox", "the", "log", "message", "will"...
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/Console.java#L36-L59
train
threerings/gwt-utils
src/main/java/com/threerings/gwt/tools/I18nSync.java
I18nSync.main
public static void main (String[] args) { if (args.length <= 1) { System.err.println("Usage: I18nSyncTask rootDir rootDir/com/mypackage/Foo.properties " + "[.../Bar.properties ...]"); System.exit(255); } File rootDir = new File(args[0]); if (!rootDir.isDirectory()) { System.err.println("Invalid root directory: " + rootDir); System.exit(255); } I18nSync tool = new I18nSync(); boolean errors = false; for (int ii = 1; ii < args.length; ii++) { try { tool.process(rootDir, new File(args[ii])); } catch (IOException ioe) { System.err.println("Error processing '" + args[ii] + "': " + ioe); errors = true; } } System.exit(errors ? 255 : 0); }
java
public static void main (String[] args) { if (args.length <= 1) { System.err.println("Usage: I18nSyncTask rootDir rootDir/com/mypackage/Foo.properties " + "[.../Bar.properties ...]"); System.exit(255); } File rootDir = new File(args[0]); if (!rootDir.isDirectory()) { System.err.println("Invalid root directory: " + rootDir); System.exit(255); } I18nSync tool = new I18nSync(); boolean errors = false; for (int ii = 1; ii < args.length; ii++) { try { tool.process(rootDir, new File(args[ii])); } catch (IOException ioe) { System.err.println("Error processing '" + args[ii] + "': " + ioe); errors = true; } } System.exit(errors ? 255 : 0); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "<=", "1", ")", "{", "System", ".", "err", ".", "println", "(", "\"Usage: I18nSyncTask rootDir rootDir/com/mypackage/Foo.properties \"", "+", "\"[....
Entry point for command line tool.
[ "Entry", "point", "for", "command", "line", "tool", "." ]
31b31a23b667f2a9c683160d77646db259f2aae5
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/tools/I18nSync.java#L42-L67
train