id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
8,400
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java
JRebirthThread.manageStyleSheetReloading
private void manageStyleSheetReloading(final Scene scene) { if (CoreParameters.DEVELOPER_MODE.get() && scene != null) { for (final String styleSheet : scene.getStylesheets()) { getFacade().serviceFacade().retrieve(StyleSheetTrackerService.class).listen(styleSheet, this.application.scene()); } getFacade().serviceFacade().retrieve(StyleSheetTrackerService.class).start(); } }
java
private void manageStyleSheetReloading(final Scene scene) { if (CoreParameters.DEVELOPER_MODE.get() && scene != null) { for (final String styleSheet : scene.getStylesheets()) { getFacade().serviceFacade().retrieve(StyleSheetTrackerService.class).listen(styleSheet, this.application.scene()); } getFacade().serviceFacade().retrieve(StyleSheetTrackerService.class).start(); } }
[ "private", "void", "manageStyleSheetReloading", "(", "final", "Scene", "scene", ")", "{", "if", "(", "CoreParameters", ".", "DEVELOPER_MODE", ".", "get", "(", ")", "&&", "scene", "!=", "null", ")", "{", "for", "(", "final", "String", "styleSheet", ":", "scene", ".", "getStylesheets", "(", ")", ")", "{", "getFacade", "(", ")", ".", "serviceFacade", "(", ")", ".", "retrieve", "(", "StyleSheetTrackerService", ".", "class", ")", ".", "listen", "(", "styleSheet", ",", "this", ".", "application", ".", "scene", "(", ")", ")", ";", "}", "getFacade", "(", ")", ".", "serviceFacade", "(", ")", ".", "retrieve", "(", "StyleSheetTrackerService", ".", "class", ")", ".", "start", "(", ")", ";", "}", "}" ]
Manage style sheet reloading by using a custom service provide by JRebirth Core. @param scene the scene to reload in case of Style Sheet update
[ "Manage", "style", "sheet", "reloading", "by", "using", "a", "custom", "service", "provide", "by", "JRebirth", "Core", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java#L188-L197
8,401
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java
JRebirthThread.bootUp
public void bootUp() throws JRebirthThreadException { final List<Wave> chainedWaveList = new ArrayList<>(); // Manage waves to run before the First node creation final List<Wave> preBootList = getApplication().preBootWaveList(); if (preBootList != null && !preBootList.isEmpty()) { chainedWaveList.addAll(preBootList); } // Manage the creation of the first node and show it ! final Wave firstViewWave = getLaunchFirstViewWave(); if (firstViewWave != null) { chainedWaveList.add(firstViewWave); } // Manage waves to run after the First node creation final List<Wave> postBootList = getApplication().postBootWaveList(); if (postBootList != null && !postBootList.isEmpty()) { chainedWaveList.addAll(postBootList); } if (!chainedWaveList.isEmpty()) { getFacade().notifier().sendWave(WBuilder.chainWaveCommand(chainedWaveList)); } }
java
public void bootUp() throws JRebirthThreadException { final List<Wave> chainedWaveList = new ArrayList<>(); // Manage waves to run before the First node creation final List<Wave> preBootList = getApplication().preBootWaveList(); if (preBootList != null && !preBootList.isEmpty()) { chainedWaveList.addAll(preBootList); } // Manage the creation of the first node and show it ! final Wave firstViewWave = getLaunchFirstViewWave(); if (firstViewWave != null) { chainedWaveList.add(firstViewWave); } // Manage waves to run after the First node creation final List<Wave> postBootList = getApplication().postBootWaveList(); if (postBootList != null && !postBootList.isEmpty()) { chainedWaveList.addAll(postBootList); } if (!chainedWaveList.isEmpty()) { getFacade().notifier().sendWave(WBuilder.chainWaveCommand(chainedWaveList)); } }
[ "public", "void", "bootUp", "(", ")", "throws", "JRebirthThreadException", "{", "final", "List", "<", "Wave", ">", "chainedWaveList", "=", "new", "ArrayList", "<>", "(", ")", ";", "// Manage waves to run before the First node creation", "final", "List", "<", "Wave", ">", "preBootList", "=", "getApplication", "(", ")", ".", "preBootWaveList", "(", ")", ";", "if", "(", "preBootList", "!=", "null", "&&", "!", "preBootList", ".", "isEmpty", "(", ")", ")", "{", "chainedWaveList", ".", "addAll", "(", "preBootList", ")", ";", "}", "// Manage the creation of the first node and show it !", "final", "Wave", "firstViewWave", "=", "getLaunchFirstViewWave", "(", ")", ";", "if", "(", "firstViewWave", "!=", "null", ")", "{", "chainedWaveList", ".", "add", "(", "firstViewWave", ")", ";", "}", "// Manage waves to run after the First node creation", "final", "List", "<", "Wave", ">", "postBootList", "=", "getApplication", "(", ")", ".", "postBootWaveList", "(", ")", ";", "if", "(", "postBootList", "!=", "null", "&&", "!", "postBootList", ".", "isEmpty", "(", ")", ")", "{", "chainedWaveList", ".", "addAll", "(", "postBootList", ")", ";", "}", "if", "(", "!", "chainedWaveList", ".", "isEmpty", "(", ")", ")", "{", "getFacade", "(", ")", ".", "notifier", "(", ")", ".", "sendWave", "(", "WBuilder", ".", "chainWaveCommand", "(", "chainedWaveList", ")", ")", ";", "}", "}" ]
Attach the first view and run pre and post command. @throws JRebirthThreadException if a problem occurred while calling the command
[ "Attach", "the", "first", "view", "and", "run", "pre", "and", "post", "command", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java#L204-L230
8,402
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java
JRebirthThread.close
public void close() { // Infinite loop is still active if (this.infiniteLoop.get()) { // First attempt to close the application this.infiniteLoop.set(false); } else { // N-th attempt to close the application this.forceClose.set(true); // All Task Queues are cleared // this.queuedTasks.clear(); this.processingTasks.clear(); } }
java
public void close() { // Infinite loop is still active if (this.infiniteLoop.get()) { // First attempt to close the application this.infiniteLoop.set(false); } else { // N-th attempt to close the application this.forceClose.set(true); // All Task Queues are cleared // this.queuedTasks.clear(); this.processingTasks.clear(); } }
[ "public", "void", "close", "(", ")", "{", "// Infinite loop is still active", "if", "(", "this", ".", "infiniteLoop", ".", "get", "(", ")", ")", "{", "// First attempt to close the application", "this", ".", "infiniteLoop", ".", "set", "(", "false", ")", ";", "}", "else", "{", "// N-th attempt to close the application", "this", ".", "forceClose", ".", "set", "(", "true", ")", ";", "// All Task Queues are cleared", "// this.queuedTasks.clear();", "this", ".", "processingTasks", ".", "clear", "(", ")", ";", "}", "}" ]
This method can be called a lot of time while application is running. The first time to stop the infinite loop, then to purge all queues and let the thread terminate itself.
[ "This", "method", "can", "be", "called", "a", "lot", "of", "time", "while", "application", "is", "running", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java#L248-L263
8,403
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java
JRebirthThread.shutdown
private void shutdown() { try { this.facade.stop(); this.facade = null; // Destroy the static reference destroyInstance(); } catch (final CoreException e) { LOGGER.log(SHUTDOWN_ERROR, e); } }
java
private void shutdown() { try { this.facade.stop(); this.facade = null; // Destroy the static reference destroyInstance(); } catch (final CoreException e) { LOGGER.log(SHUTDOWN_ERROR, e); } }
[ "private", "void", "shutdown", "(", ")", "{", "try", "{", "this", ".", "facade", ".", "stop", "(", ")", ";", "this", ".", "facade", "=", "null", ";", "// Destroy the static reference", "destroyInstance", "(", ")", ";", "}", "catch", "(", "final", "CoreException", "e", ")", "{", "LOGGER", ".", "log", "(", "SHUTDOWN_ERROR", ",", "e", ")", ";", "}", "}" ]
Release all resources.
[ "Release", "all", "resources", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java#L268-L277
8,404
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java
JRebirthThread.getLaunchFirstViewWave
protected Wave getLaunchFirstViewWave() { Wave firstWave = null; // Generates the command wave directly to win a Wave cycle if (this.application != null && this.application.rootNode() != null && this.application.firstModelClass() != null) { final UniqueKey<? extends Model> modelKey = Key.create(this.application.firstModelClass(), this.application.firstModelOptionalData(), this.application.firstModelKeyParts()); firstWave = WBuilder.callCommand(ShowModelCommand.class).waveBean( DisplayModelWaveBean.create() .childrenPlaceHolder(this.application.rootNode().getChildren()) .showModelKey(modelKey)); // // // ShowModelWaveBuilder.create() // .childrenPlaceHolder(this.application.getRootNode().getChildren()) // .showModelKey(getFacade().getUiFacade().buildKey((Class<Model>) this.application.getFirstModelClass())) // .build(); } return firstWave; }
java
protected Wave getLaunchFirstViewWave() { Wave firstWave = null; // Generates the command wave directly to win a Wave cycle if (this.application != null && this.application.rootNode() != null && this.application.firstModelClass() != null) { final UniqueKey<? extends Model> modelKey = Key.create(this.application.firstModelClass(), this.application.firstModelOptionalData(), this.application.firstModelKeyParts()); firstWave = WBuilder.callCommand(ShowModelCommand.class).waveBean( DisplayModelWaveBean.create() .childrenPlaceHolder(this.application.rootNode().getChildren()) .showModelKey(modelKey)); // // // ShowModelWaveBuilder.create() // .childrenPlaceHolder(this.application.getRootNode().getChildren()) // .showModelKey(getFacade().getUiFacade().buildKey((Class<Model>) this.application.getFirstModelClass())) // .build(); } return firstWave; }
[ "protected", "Wave", "getLaunchFirstViewWave", "(", ")", "{", "Wave", "firstWave", "=", "null", ";", "// Generates the command wave directly to win a Wave cycle", "if", "(", "this", ".", "application", "!=", "null", "&&", "this", ".", "application", ".", "rootNode", "(", ")", "!=", "null", "&&", "this", ".", "application", ".", "firstModelClass", "(", ")", "!=", "null", ")", "{", "final", "UniqueKey", "<", "?", "extends", "Model", ">", "modelKey", "=", "Key", ".", "create", "(", "this", ".", "application", ".", "firstModelClass", "(", ")", ",", "this", ".", "application", ".", "firstModelOptionalData", "(", ")", ",", "this", ".", "application", ".", "firstModelKeyParts", "(", ")", ")", ";", "firstWave", "=", "WBuilder", ".", "callCommand", "(", "ShowModelCommand", ".", "class", ")", ".", "waveBean", "(", "DisplayModelWaveBean", ".", "create", "(", ")", ".", "childrenPlaceHolder", "(", "this", ".", "application", ".", "rootNode", "(", ")", ".", "getChildren", "(", ")", ")", ".", "showModelKey", "(", "modelKey", ")", ")", ";", "//", "//", "// ShowModelWaveBuilder.create()", "// .childrenPlaceHolder(this.application.getRootNode().getChildren())", "// .showModelKey(getFacade().getUiFacade().buildKey((Class<Model>) this.application.getFirstModelClass()))", "// .build();", "}", "return", "firstWave", ";", "}" ]
Launch the first view by adding it into the root node. @return the wave responsible of the creation of the first view
[ "Launch", "the", "first", "view", "by", "adding", "it", "into", "the", "root", "node", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThread.java#L291-L310
8,405
JRebirth/JRebirth
org.jrebirth.af/processor/src/main/java/org/jrebirth/af/processor/ComponentProcessor.java
ComponentProcessor.createSPIFile
private void createSPIFile(String moduleName) { try { final FileObject fo = this.processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", MODULE_STARTER_SPI_PATH); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "creating spi file: " + fo.toUri()); final Writer writer = fo.openWriter(); writer.write(moduleName); writer.close(); } catch (final IOException e) { e.printStackTrace(); throw new RuntimeException(e); } }
java
private void createSPIFile(String moduleName) { try { final FileObject fo = this.processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", MODULE_STARTER_SPI_PATH); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "creating spi file: " + fo.toUri()); final Writer writer = fo.openWriter(); writer.write(moduleName); writer.close(); } catch (final IOException e) { e.printStackTrace(); throw new RuntimeException(e); } }
[ "private", "void", "createSPIFile", "(", "String", "moduleName", ")", "{", "try", "{", "final", "FileObject", "fo", "=", "this", ".", "processingEnv", ".", "getFiler", "(", ")", ".", "createResource", "(", "StandardLocation", ".", "CLASS_OUTPUT", ",", "\"\"", ",", "MODULE_STARTER_SPI_PATH", ")", ";", "this", ".", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "NOTE", ",", "\"creating spi file: \"", "+", "fo", ".", "toUri", "(", ")", ")", ";", "final", "Writer", "writer", "=", "fo", ".", "openWriter", "(", ")", ";", "writer", ".", "write", "(", "moduleName", ")", ";", "writer", ".", "close", "(", ")", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Creates SPI file to expose the module stater @param moduleName the name of the module
[ "Creates", "SPI", "file", "to", "expose", "the", "module", "stater" ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/processor/src/main/java/org/jrebirth/af/processor/ComponentProcessor.java#L124-L137
8,406
JRebirth/JRebirth
org.jrebirth.af/processor/src/main/java/org/jrebirth/af/processor/ComponentProcessor.java
ComponentProcessor.createModuleStarter
private String createModuleStarter(final Map<Class<?>, Set<? extends Element>> annotationMap, ProcessingEnvironment processingEnv) { String moduleName; try { moduleName = getModuleStarterName(processingEnv); final String starterName = moduleName.substring(moduleName.lastIndexOf('.') + 1); final String pkg = moduleName.substring(0, moduleName.lastIndexOf('.')); final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); javaClass.setPackage(pkg).setName(starterName); javaClass.extendSuperType(AbstractModuleStarter.class); final StringBuilder body = new StringBuilder(); appendRegistrationPoints(javaClass, body, annotationMap.get(RegistrationPoint.class)); appendRegistrations(javaClass, body, annotationMap.get(Register.class)); appendPreload(javaClass, body, annotationMap.get(Preload.class)); appendBootComponent(javaClass, body, annotationMap.get(BootComponent.class)); if (!javaClass.hasMethodSignature("start")) { final MethodSource<?> method = javaClass.addMethod() .setName("start") .setPublic() .setBody(body.toString()) .setReturnTypeVoid(); method.getJavaDoc().setFullText("{@inheritDoc}"); method.addAnnotation(Override.class); } else { javaClass.getMethod("start").setBody(javaClass.getMethod("start").getBody() + body.toString()); } final Properties prefs = new Properties(); prefs.load(this.getClass().getResourceAsStream(FORMATTER_PROPERTIES_FILE)); final String formattedSource = Formatter.format(prefs, javaClass); // System.out.println(formattedSource); final JavaFileObject jfo = this.processingEnv.getFiler().createSourceFile(moduleName); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "creating source file: " + jfo.toUri()); final Writer writer = jfo.openWriter(); writer.write(formattedSource); writer.close(); } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return moduleName; }
java
private String createModuleStarter(final Map<Class<?>, Set<? extends Element>> annotationMap, ProcessingEnvironment processingEnv) { String moduleName; try { moduleName = getModuleStarterName(processingEnv); final String starterName = moduleName.substring(moduleName.lastIndexOf('.') + 1); final String pkg = moduleName.substring(0, moduleName.lastIndexOf('.')); final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); javaClass.setPackage(pkg).setName(starterName); javaClass.extendSuperType(AbstractModuleStarter.class); final StringBuilder body = new StringBuilder(); appendRegistrationPoints(javaClass, body, annotationMap.get(RegistrationPoint.class)); appendRegistrations(javaClass, body, annotationMap.get(Register.class)); appendPreload(javaClass, body, annotationMap.get(Preload.class)); appendBootComponent(javaClass, body, annotationMap.get(BootComponent.class)); if (!javaClass.hasMethodSignature("start")) { final MethodSource<?> method = javaClass.addMethod() .setName("start") .setPublic() .setBody(body.toString()) .setReturnTypeVoid(); method.getJavaDoc().setFullText("{@inheritDoc}"); method.addAnnotation(Override.class); } else { javaClass.getMethod("start").setBody(javaClass.getMethod("start").getBody() + body.toString()); } final Properties prefs = new Properties(); prefs.load(this.getClass().getResourceAsStream(FORMATTER_PROPERTIES_FILE)); final String formattedSource = Formatter.format(prefs, javaClass); // System.out.println(formattedSource); final JavaFileObject jfo = this.processingEnv.getFiler().createSourceFile(moduleName); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "creating source file: " + jfo.toUri()); final Writer writer = jfo.openWriter(); writer.write(formattedSource); writer.close(); } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return moduleName; }
[ "private", "String", "createModuleStarter", "(", "final", "Map", "<", "Class", "<", "?", ">", ",", "Set", "<", "?", "extends", "Element", ">", ">", "annotationMap", ",", "ProcessingEnvironment", "processingEnv", ")", "{", "String", "moduleName", ";", "try", "{", "moduleName", "=", "getModuleStarterName", "(", "processingEnv", ")", ";", "final", "String", "starterName", "=", "moduleName", ".", "substring", "(", "moduleName", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ";", "final", "String", "pkg", "=", "moduleName", ".", "substring", "(", "0", ",", "moduleName", ".", "lastIndexOf", "(", "'", "'", ")", ")", ";", "final", "JavaClassSource", "javaClass", "=", "Roaster", ".", "create", "(", "JavaClassSource", ".", "class", ")", ";", "javaClass", ".", "setPackage", "(", "pkg", ")", ".", "setName", "(", "starterName", ")", ";", "javaClass", ".", "extendSuperType", "(", "AbstractModuleStarter", ".", "class", ")", ";", "final", "StringBuilder", "body", "=", "new", "StringBuilder", "(", ")", ";", "appendRegistrationPoints", "(", "javaClass", ",", "body", ",", "annotationMap", ".", "get", "(", "RegistrationPoint", ".", "class", ")", ")", ";", "appendRegistrations", "(", "javaClass", ",", "body", ",", "annotationMap", ".", "get", "(", "Register", ".", "class", ")", ")", ";", "appendPreload", "(", "javaClass", ",", "body", ",", "annotationMap", ".", "get", "(", "Preload", ".", "class", ")", ")", ";", "appendBootComponent", "(", "javaClass", ",", "body", ",", "annotationMap", ".", "get", "(", "BootComponent", ".", "class", ")", ")", ";", "if", "(", "!", "javaClass", ".", "hasMethodSignature", "(", "\"start\"", ")", ")", "{", "final", "MethodSource", "<", "?", ">", "method", "=", "javaClass", ".", "addMethod", "(", ")", ".", "setName", "(", "\"start\"", ")", ".", "setPublic", "(", ")", ".", "setBody", "(", "body", ".", "toString", "(", ")", ")", ".", "setReturnTypeVoid", "(", ")", ";", "method", ".", "getJavaDoc", "(", ")", ".", "setFullText", "(", "\"{@inheritDoc}\"", ")", ";", "method", ".", "addAnnotation", "(", "Override", ".", "class", ")", ";", "}", "else", "{", "javaClass", ".", "getMethod", "(", "\"start\"", ")", ".", "setBody", "(", "javaClass", ".", "getMethod", "(", "\"start\"", ")", ".", "getBody", "(", ")", "+", "body", ".", "toString", "(", ")", ")", ";", "}", "final", "Properties", "prefs", "=", "new", "Properties", "(", ")", ";", "prefs", ".", "load", "(", "this", ".", "getClass", "(", ")", ".", "getResourceAsStream", "(", "FORMATTER_PROPERTIES_FILE", ")", ")", ";", "final", "String", "formattedSource", "=", "Formatter", ".", "format", "(", "prefs", ",", "javaClass", ")", ";", "// System.out.println(formattedSource);", "final", "JavaFileObject", "jfo", "=", "this", ".", "processingEnv", ".", "getFiler", "(", ")", ".", "createSourceFile", "(", "moduleName", ")", ";", "this", ".", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "NOTE", ",", "\"creating source file: \"", "+", "jfo", ".", "toUri", "(", ")", ")", ";", "final", "Writer", "writer", "=", "jfo", ".", "openWriter", "(", ")", ";", "writer", ".", "write", "(", "formattedSource", ")", ";", "writer", ".", "close", "(", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "moduleName", ";", "}" ]
Creates module stater class according to the annotations @param annotationMap map of annotations to process @param processingEnv environment to access facilities the tool framework provides to the processor @return Module name
[ "Creates", "module", "stater", "class", "according", "to", "the", "annotations" ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/processor/src/main/java/org/jrebirth/af/processor/ComponentProcessor.java#L146-L200
8,407
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/basic/StyleSheetTrackerService.java
StyleSheetTrackerService.listen
public void listen(final String styleSheetPath, final Scene scene) { final File file = new File(styleSheetPath); file.lastModified(); // StyleManager.getInstance().reloadStylesheets(scene); }
java
public void listen(final String styleSheetPath, final Scene scene) { final File file = new File(styleSheetPath); file.lastModified(); // StyleManager.getInstance().reloadStylesheets(scene); }
[ "public", "void", "listen", "(", "final", "String", "styleSheetPath", ",", "final", "Scene", "scene", ")", "{", "final", "File", "file", "=", "new", "File", "(", "styleSheetPath", ")", ";", "file", ".", "lastModified", "(", ")", ";", "// StyleManager.getInstance().reloadStylesheets(scene);\r", "}" ]
Listen new style sheet path. @param styleSheetPath the style hseet path @param scene the root scene
[ "Listen", "new", "style", "sheet", "path", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/basic/StyleSheetTrackerService.java#L61-L69
8,408
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.getWaveTypesString
private String getWaveTypesString(final WaveType[] waveTypes) { final StringBuilder sb = new StringBuilder(); for (final WaveType waveType : waveTypes) { sb.append(waveType.toString()).append(" "); } return sb.toString(); }
java
private String getWaveTypesString(final WaveType[] waveTypes) { final StringBuilder sb = new StringBuilder(); for (final WaveType waveType : waveTypes) { sb.append(waveType.toString()).append(" "); } return sb.toString(); }
[ "private", "String", "getWaveTypesString", "(", "final", "WaveType", "[", "]", "waveTypes", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "final", "WaveType", "waveType", ":", "waveTypes", ")", "{", "sb", ".", "append", "(", "waveType", ".", "toString", "(", ")", ")", ".", "append", "(", "\" \"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Return the human-readable list of Wave Type. @param waveTypes the list of wave type @return the string list of Wave Type
[ "Return", "the", "human", "-", "readable", "list", "of", "Wave", "Type", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L140-L146
8,409
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.sendWaveIntoJit
private Wave sendWaveIntoJit(final Wave wave) { CheckerUtility.checkWave(wave); wave.status(Status.Sent); final PriorityLevel priority = wave.contains(JRebirthItems.priority) ? wave.get(JRebirthItems.priority) : PriorityLevel.Normal; final RunType runType = wave.contains(JRebirthItems.runSynchronously) && wave.get(JRebirthItems.runSynchronously) ? RunType.JIT_SYNC : RunType.JIT; final Long timeout = wave.contains(JRebirthItems.syncTimeout) ? wave.get(JRebirthItems.syncTimeout) : SyncRunnable.DEFAULT_TIME_OUT; // Use the JRebirth Thread to manage Waves JRebirth.run(runType, SEND_WAVE.getText(wave.toString()), priority, () -> getNotifier().sendWave(wave), timeout); return wave; }
java
private Wave sendWaveIntoJit(final Wave wave) { CheckerUtility.checkWave(wave); wave.status(Status.Sent); final PriorityLevel priority = wave.contains(JRebirthItems.priority) ? wave.get(JRebirthItems.priority) : PriorityLevel.Normal; final RunType runType = wave.contains(JRebirthItems.runSynchronously) && wave.get(JRebirthItems.runSynchronously) ? RunType.JIT_SYNC : RunType.JIT; final Long timeout = wave.contains(JRebirthItems.syncTimeout) ? wave.get(JRebirthItems.syncTimeout) : SyncRunnable.DEFAULT_TIME_OUT; // Use the JRebirth Thread to manage Waves JRebirth.run(runType, SEND_WAVE.getText(wave.toString()), priority, () -> getNotifier().sendWave(wave), timeout); return wave; }
[ "private", "Wave", "sendWaveIntoJit", "(", "final", "Wave", "wave", ")", "{", "CheckerUtility", ".", "checkWave", "(", "wave", ")", ";", "wave", ".", "status", "(", "Status", ".", "Sent", ")", ";", "final", "PriorityLevel", "priority", "=", "wave", ".", "contains", "(", "JRebirthItems", ".", "priority", ")", "?", "wave", ".", "get", "(", "JRebirthItems", ".", "priority", ")", ":", "PriorityLevel", ".", "Normal", ";", "final", "RunType", "runType", "=", "wave", ".", "contains", "(", "JRebirthItems", ".", "runSynchronously", ")", "&&", "wave", ".", "get", "(", "JRebirthItems", ".", "runSynchronously", ")", "?", "RunType", ".", "JIT_SYNC", ":", "RunType", ".", "JIT", ";", "final", "Long", "timeout", "=", "wave", ".", "contains", "(", "JRebirthItems", ".", "syncTimeout", ")", "?", "wave", ".", "get", "(", "JRebirthItems", ".", "syncTimeout", ")", ":", "SyncRunnable", ".", "DEFAULT_TIME_OUT", ";", "// Use the JRebirth Thread to manage Waves", "JRebirth", ".", "run", "(", "runType", ",", "SEND_WAVE", ".", "getText", "(", "wave", ".", "toString", "(", ")", ")", ",", "priority", ",", "(", ")", "->", "getNotifier", "(", ")", ".", "sendWave", "(", "wave", ")", ",", "timeout", ")", ";", "return", "wave", ";", "}" ]
Send the given wave using the JRebirth Thread. @param wave the wave to send @return the wave sent to JIT (with Sent status)
[ "Send", "the", "given", "wave", "using", "the", "JRebirth", "Thread", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L285-L299
8,410
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.createWave
private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> componentClass, final WaveData<?>... waveData) { final Wave wave = wave() .waveGroup(waveGroup) .waveType(waveType) .fromClass(this.getClass()) .componentClass(componentClass) .addDatas(waveData); // Track wave creation localFacade().globalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass()); return wave; }
java
private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> componentClass, final WaveData<?>... waveData) { final Wave wave = wave() .waveGroup(waveGroup) .waveType(waveType) .fromClass(this.getClass()) .componentClass(componentClass) .addDatas(waveData); // Track wave creation localFacade().globalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass()); return wave; }
[ "private", "Wave", "createWave", "(", "final", "WaveGroup", "waveGroup", ",", "final", "WaveType", "waveType", ",", "final", "Class", "<", "?", ">", "componentClass", ",", "final", "WaveData", "<", "?", ">", "...", "waveData", ")", "{", "final", "Wave", "wave", "=", "wave", "(", ")", ".", "waveGroup", "(", "waveGroup", ")", ".", "waveType", "(", "waveType", ")", ".", "fromClass", "(", "this", ".", "getClass", "(", ")", ")", ".", "componentClass", "(", "componentClass", ")", ".", "addDatas", "(", "waveData", ")", ";", "// Track wave creation", "localFacade", "(", ")", ".", "globalFacade", "(", ")", ".", "trackEvent", "(", "JRebirthEventType", ".", "CREATE_WAVE", ",", "this", ".", "getClass", "(", ")", ",", "wave", ".", "getClass", "(", ")", ")", ";", "return", "wave", ";", "}" ]
Build a wave object. @param waveGroup the group of the wave @param waveType the type of the wave @param componentClass the component class if any @param waveData wave data to use @return the wave built
[ "Build", "a", "wave", "object", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L311-L324
8,411
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.createWave
private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> componentClass, final WaveBean waveBean, final WaveBean... waveBeans) { final List<WaveBean> waveBeanList = new ArrayList<>(); waveBeanList.add(waveBean); if (waveBeans.length > 0) { waveBeanList.addAll(Arrays.asList(waveBeans)); } final Wave wave = wave() .waveGroup(waveGroup) .waveType(waveType) .fromClass(this.getClass()) .componentClass(componentClass) .waveBeanList(waveBeanList); // Track wave creation localFacade().globalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass()); return wave; }
java
private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> componentClass, final WaveBean waveBean, final WaveBean... waveBeans) { final List<WaveBean> waveBeanList = new ArrayList<>(); waveBeanList.add(waveBean); if (waveBeans.length > 0) { waveBeanList.addAll(Arrays.asList(waveBeans)); } final Wave wave = wave() .waveGroup(waveGroup) .waveType(waveType) .fromClass(this.getClass()) .componentClass(componentClass) .waveBeanList(waveBeanList); // Track wave creation localFacade().globalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass()); return wave; }
[ "private", "Wave", "createWave", "(", "final", "WaveGroup", "waveGroup", ",", "final", "WaveType", "waveType", ",", "final", "Class", "<", "?", ">", "componentClass", ",", "final", "WaveBean", "waveBean", ",", "final", "WaveBean", "...", "waveBeans", ")", "{", "final", "List", "<", "WaveBean", ">", "waveBeanList", "=", "new", "ArrayList", "<>", "(", ")", ";", "waveBeanList", ".", "add", "(", "waveBean", ")", ";", "if", "(", "waveBeans", ".", "length", ">", "0", ")", "{", "waveBeanList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "waveBeans", ")", ")", ";", "}", "final", "Wave", "wave", "=", "wave", "(", ")", ".", "waveGroup", "(", "waveGroup", ")", ".", "waveType", "(", "waveType", ")", ".", "fromClass", "(", "this", ".", "getClass", "(", ")", ")", ".", "componentClass", "(", "componentClass", ")", ".", "waveBeanList", "(", "waveBeanList", ")", ";", "// Track wave creation", "localFacade", "(", ")", ".", "globalFacade", "(", ")", ".", "trackEvent", "(", "JRebirthEventType", ".", "CREATE_WAVE", ",", "this", ".", "getClass", "(", ")", ",", "wave", ".", "getClass", "(", ")", ")", ";", "return", "wave", ";", "}" ]
Build a wave object with its dedicated WaveBean. @param waveGroup the group of the wave @param waveType the type of the wave @param componentClass the component class if any @param waveBean the wave bean that holds all required data @param waveBeans the extra Wave Beans that holds all other required data @return the wave built
[ "Build", "a", "wave", "object", "with", "its", "dedicated", "WaveBean", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L337-L356
8,412
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.callAnnotatedMethod
private void callAnnotatedMethod(final Class<? extends Annotation> annotationClass) { if (this.lifecycleMethod.get(annotationClass.getName()) != null) { for (final Method method : this.lifecycleMethod.get(annotationClass.getName())) { try { ClassUtility.callMethod(method, this); } catch (final CoreException e) { LOGGER.error(CALL_ANNOTATED_METHOD_ERROR, e); } } } }
java
private void callAnnotatedMethod(final Class<? extends Annotation> annotationClass) { if (this.lifecycleMethod.get(annotationClass.getName()) != null) { for (final Method method : this.lifecycleMethod.get(annotationClass.getName())) { try { ClassUtility.callMethod(method, this); } catch (final CoreException e) { LOGGER.error(CALL_ANNOTATED_METHOD_ERROR, e); } } } }
[ "private", "void", "callAnnotatedMethod", "(", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ")", "{", "if", "(", "this", ".", "lifecycleMethod", ".", "get", "(", "annotationClass", ".", "getName", "(", ")", ")", "!=", "null", ")", "{", "for", "(", "final", "Method", "method", ":", "this", ".", "lifecycleMethod", ".", "get", "(", "annotationClass", ".", "getName", "(", ")", ")", ")", "{", "try", "{", "ClassUtility", ".", "callMethod", "(", "method", ",", "this", ")", ";", "}", "catch", "(", "final", "CoreException", "e", ")", "{", "LOGGER", ".", "error", "(", "CALL_ANNOTATED_METHOD_ERROR", ",", "e", ")", ";", "}", "}", "}", "}" ]
Call annotated methods corresponding at given lifecycle annotation. @param annotationClass the annotation related to the lifecycle
[ "Call", "annotated", "methods", "corresponding", "at", "given", "lifecycle", "annotation", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L473-L484
8,413
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java
AbstractComponent.internalRelease
private void internalRelease() { // try { // setKey(null); // getNotifier().unlistenAll(getWaveReady()); callAnnotatedMethod(OnRelease.class); if (localFacade() != null) { localFacade().unregister(key()); } // thisObject.ready = false; // Shall also release all InnerComponent if (getInnerComponentMap().isPresent()) { final List<Component<?>> toRemove = new ArrayList<>(); for (final Component<?> innerComponent : getInnerComponentMap().get().values()) { // Release the InnerComponent innerComponent.release(); // Store it to avoid co-modification error toRemove.add(innerComponent); } for (final Component<?> innerComponent : toRemove) { // Remove it from the list // getInnerComponentList().get().remove(innerComponent); // Then remove it from map getInnerComponentMap().get().remove(innerComponent.key()); } } // } catch (final JRebirthThreadException jte) { // LOGGER.error(COMPONENT_RELEASE_ERROR, jte); // } }
java
private void internalRelease() { // try { // setKey(null); // getNotifier().unlistenAll(getWaveReady()); callAnnotatedMethod(OnRelease.class); if (localFacade() != null) { localFacade().unregister(key()); } // thisObject.ready = false; // Shall also release all InnerComponent if (getInnerComponentMap().isPresent()) { final List<Component<?>> toRemove = new ArrayList<>(); for (final Component<?> innerComponent : getInnerComponentMap().get().values()) { // Release the InnerComponent innerComponent.release(); // Store it to avoid co-modification error toRemove.add(innerComponent); } for (final Component<?> innerComponent : toRemove) { // Remove it from the list // getInnerComponentList().get().remove(innerComponent); // Then remove it from map getInnerComponentMap().get().remove(innerComponent.key()); } } // } catch (final JRebirthThreadException jte) { // LOGGER.error(COMPONENT_RELEASE_ERROR, jte); // } }
[ "private", "void", "internalRelease", "(", ")", "{", "// try {", "// setKey(null);", "// getNotifier().unlistenAll(getWaveReady());", "callAnnotatedMethod", "(", "OnRelease", ".", "class", ")", ";", "if", "(", "localFacade", "(", ")", "!=", "null", ")", "{", "localFacade", "(", ")", ".", "unregister", "(", "key", "(", ")", ")", ";", "}", "// thisObject.ready = false;", "// Shall also release all InnerComponent", "if", "(", "getInnerComponentMap", "(", ")", ".", "isPresent", "(", ")", ")", "{", "final", "List", "<", "Component", "<", "?", ">", ">", "toRemove", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "Component", "<", "?", ">", "innerComponent", ":", "getInnerComponentMap", "(", ")", ".", "get", "(", ")", ".", "values", "(", ")", ")", "{", "// Release the InnerComponent", "innerComponent", ".", "release", "(", ")", ";", "// Store it to avoid co-modification error", "toRemove", ".", "add", "(", "innerComponent", ")", ";", "}", "for", "(", "final", "Component", "<", "?", ">", "innerComponent", ":", "toRemove", ")", "{", "// Remove it from the list", "// getInnerComponentList().get().remove(innerComponent);", "// Then remove it from map", "getInnerComponentMap", "(", ")", ".", "get", "(", ")", ".", "remove", "(", "innerComponent", ".", "key", "(", ")", ")", ";", "}", "}", "// } catch (final JRebirthThreadException jte) {", "// LOGGER.error(COMPONENT_RELEASE_ERROR, jte);", "// }", "}" ]
Perform the internal release.
[ "Perform", "the", "internal", "release", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/component/basic/AbstractComponent.java#L576-L619
8,414
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/sockjs/impl/SockJSSession.java
SockJSSession.close
@Override public synchronized void close() { if (endHandler != null) { endHandler.handle(null); } closed = true; if (listener != null && handleCalled) { listener.sessionClosed(); } }
java
@Override public synchronized void close() { if (endHandler != null) { endHandler.handle(null); } closed = true; if (listener != null && handleCalled) { listener.sessionClosed(); } }
[ "@", "Override", "public", "synchronized", "void", "close", "(", ")", "{", "if", "(", "endHandler", "!=", "null", ")", "{", "endHandler", ".", "handle", "(", "null", ")", ";", "}", "closed", "=", "true", ";", "if", "(", "listener", "!=", "null", "&&", "handleCalled", ")", "{", "listener", ".", "sessionClosed", "(", ")", ";", "}", "}" ]
Yes, SockJS is weird, but it's hard to work out expected server behaviour when there's no spec
[ "Yes", "SockJS", "is", "weird", "but", "it", "s", "hard", "to", "work", "out", "expected", "server", "behaviour", "when", "there", "s", "no", "spec" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/sockjs/impl/SockJSSession.java#L184-L193
8,415
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/sockjs/impl/SockJSSession.java
SockJSSession.doClose
private void doClose() { super.close(); // We must call this or handlers don't get unregistered and we get a leak if (heartbeatID != -1) { vertx.cancelTimer(heartbeatID); } if (timeoutTimerID != -1) { vertx.cancelTimer(timeoutTimerID); } if (id != null) { // Can be null if websocket session sessions.remove(id); } if (!closed) { closed = true; if (endHandler != null) { endHandler.handle(null); } } }
java
private void doClose() { super.close(); // We must call this or handlers don't get unregistered and we get a leak if (heartbeatID != -1) { vertx.cancelTimer(heartbeatID); } if (timeoutTimerID != -1) { vertx.cancelTimer(timeoutTimerID); } if (id != null) { // Can be null if websocket session sessions.remove(id); } if (!closed) { closed = true; if (endHandler != null) { endHandler.handle(null); } } }
[ "private", "void", "doClose", "(", ")", "{", "super", ".", "close", "(", ")", ";", "// We must call this or handlers don't get unregistered and we get a leak", "if", "(", "heartbeatID", "!=", "-", "1", ")", "{", "vertx", ".", "cancelTimer", "(", "heartbeatID", ")", ";", "}", "if", "(", "timeoutTimerID", "!=", "-", "1", ")", "{", "vertx", ".", "cancelTimer", "(", "timeoutTimerID", ")", ";", "}", "if", "(", "id", "!=", "null", ")", "{", "// Can be null if websocket session", "sessions", ".", "remove", "(", "id", ")", ";", "}", "if", "(", "!", "closed", ")", "{", "closed", "=", "true", ";", "if", "(", "endHandler", "!=", "null", ")", "{", "endHandler", ".", "handle", "(", "null", ")", ";", "}", "}", "}" ]
Yes, I know it's weird but that's the way SockJS likes it.
[ "Yes", "I", "know", "it", "s", "weird", "but", "that", "s", "the", "way", "SockJS", "likes", "it", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/sockjs/impl/SockJSSession.java#L298-L317
8,416
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/controls/ControlsModel.java
ControlsModel.doEventsLoaded
public void doEventsLoaded(final List<JRebirthEvent> eventList, final Wave wave) { view().activateButtons(!eventList.isEmpty()); }
java
public void doEventsLoaded(final List<JRebirthEvent> eventList, final Wave wave) { view().activateButtons(!eventList.isEmpty()); }
[ "public", "void", "doEventsLoaded", "(", "final", "List", "<", "JRebirthEvent", ">", "eventList", ",", "final", "Wave", "wave", ")", "{", "view", "(", ")", ".", "activateButtons", "(", "!", "eventList", ".", "isEmpty", "(", ")", ")", ";", "}" ]
Call when event are loaded. @param eventList the list of events loaded @param wave the wave received
[ "Call", "when", "event", "are", "loaded", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/controls/ControlsModel.java#L51-L53
8,417
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/BasicAuth.java
BasicAuth.handle401
private void handle401(final YokeRequest request, final Handler<Object> next) { YokeResponse response = request.response(); response.putHeader("WWW-Authenticate", "Basic realm=\"" + getRealm(request) + "\""); response.setStatusCode(401); next.handle("No authorization token"); }
java
private void handle401(final YokeRequest request, final Handler<Object> next) { YokeResponse response = request.response(); response.putHeader("WWW-Authenticate", "Basic realm=\"" + getRealm(request) + "\""); response.setStatusCode(401); next.handle("No authorization token"); }
[ "private", "void", "handle401", "(", "final", "YokeRequest", "request", ",", "final", "Handler", "<", "Object", ">", "next", ")", "{", "YokeResponse", "response", "=", "request", ".", "response", "(", ")", ";", "response", ".", "putHeader", "(", "\"WWW-Authenticate\"", ",", "\"Basic realm=\\\"\"", "+", "getRealm", "(", "request", ")", "+", "\"\\\"\"", ")", ";", "response", ".", "setStatusCode", "(", "401", ")", ";", "next", ".", "handle", "(", "\"No authorization token\"", ")", ";", "}" ]
Handle all forbidden errors, in this case we need to add a special header to the response @param request yoke request @param next middleware to be called next
[ "Handle", "all", "forbidden", "errors", "in", "this", "case", "we", "need", "to", "add", "a", "special", "header", "to", "the", "response" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/BasicAuth.java#L128-L133
8,418
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/controls/ControlsView.java
ControlsView.activateButtons
void activateButtons(final boolean enable) { this.unloadButton.setDisable(!enable); this.playPauseButton.setDisable(!enable); this.backwardButton.setDisable(!enable); this.forwardButton.setDisable(!enable); this.stopButton.setDisable(!enable); }
java
void activateButtons(final boolean enable) { this.unloadButton.setDisable(!enable); this.playPauseButton.setDisable(!enable); this.backwardButton.setDisable(!enable); this.forwardButton.setDisable(!enable); this.stopButton.setDisable(!enable); }
[ "void", "activateButtons", "(", "final", "boolean", "enable", ")", "{", "this", ".", "unloadButton", ".", "setDisable", "(", "!", "enable", ")", ";", "this", ".", "playPauseButton", ".", "setDisable", "(", "!", "enable", ")", ";", "this", ".", "backwardButton", ".", "setDisable", "(", "!", "enable", ")", ";", "this", ".", "forwardButton", ".", "setDisable", "(", "!", "enable", ")", ";", "this", ".", "stopButton", ".", "setDisable", "(", "!", "enable", ")", ";", "}" ]
Change activation of all buttons. @param enable true to enable all buttons false otherwise
[ "Change", "activation", "of", "all", "buttons", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/controls/ControlsView.java#L115-L121
8,419
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/fxml/FXMLBuilder.java
FXMLBuilder.buildFXMLComponent
private FXMLComponent buildFXMLComponent(final FXML fxmlParam) { return FXMLUtils.loadFXML(null, fxmlParam.getFxmlPath() + FXML.FXML_EXT, fxmlParam.getBundlePath()); }
java
private FXMLComponent buildFXMLComponent(final FXML fxmlParam) { return FXMLUtils.loadFXML(null, fxmlParam.getFxmlPath() + FXML.FXML_EXT, fxmlParam.getBundlePath()); }
[ "private", "FXMLComponent", "buildFXMLComponent", "(", "final", "FXML", "fxmlParam", ")", "{", "return", "FXMLUtils", ".", "loadFXML", "(", "null", ",", "fxmlParam", ".", "getFxmlPath", "(", ")", "+", "FXML", ".", "FXML_EXT", ",", "fxmlParam", ".", "getBundlePath", "(", ")", ")", ";", "}" ]
Build a FXML component that embed a node and its FXML controller. @param fxmlParam the FXMLParams object @return the FXMLcomponent wrapper object
[ "Build", "a", "FXML", "component", "that", "embed", "a", "node", "and", "its", "FXML", "controller", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/fxml/FXMLBuilder.java#L59-L62
8,420
JRebirth/JRebirth
org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java
UndoRedoService.stackUp
public void stackUp(final Undoable command) { // Stack up the command this.commandStack.add(command); // Call the redo method of the Undoable command this.commandStack.get(this.commandStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, false))); }
java
public void stackUp(final Undoable command) { // Stack up the command this.commandStack.add(command); // Call the redo method of the Undoable command this.commandStack.get(this.commandStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, false))); }
[ "public", "void", "stackUp", "(", "final", "Undoable", "command", ")", "{", "// Stack up the command", "this", ".", "commandStack", ".", "add", "(", "command", ")", ";", "// Call the redo method of the Undoable command", "this", ".", "commandStack", ".", "get", "(", "this", ".", "commandStack", ".", "size", "(", ")", "-", "1", ")", ".", "run", "(", "WBuilder", ".", "wave", "(", ")", ".", "addDatas", "(", "WBuilder", ".", "waveData", "(", "UndoRedoWaves", ".", "UNDO_REDO", ",", "false", ")", ")", ")", ";", "}" ]
Stack up a command. Move internal index and execute the command by triggering a Redo Wave Command @param command the command
[ "Stack", "up", "a", "command", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java#L58-L66
8,421
JRebirth/JRebirth
org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java
UndoRedoService.undo
public void undo() { // If there is at least one command left to undo if (this.commandStack.size() > 0) { // Here put the last command on the undone stack this.undoneStack.add(this.commandStack.get(this.commandStack.size() - 1)); // here remove the last command of the command stack this.commandStack.remove(this.commandStack.get(this.commandStack.size() - 1)); // Call Undo method this.undoneStack.get(this.undoneStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, true))); } else { // begin of stack, do nothing LOGGER.info("No more command to undo, begin of stack"); } }
java
public void undo() { // If there is at least one command left to undo if (this.commandStack.size() > 0) { // Here put the last command on the undone stack this.undoneStack.add(this.commandStack.get(this.commandStack.size() - 1)); // here remove the last command of the command stack this.commandStack.remove(this.commandStack.get(this.commandStack.size() - 1)); // Call Undo method this.undoneStack.get(this.undoneStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, true))); } else { // begin of stack, do nothing LOGGER.info("No more command to undo, begin of stack"); } }
[ "public", "void", "undo", "(", ")", "{", "// If there is at least one command left to undo", "if", "(", "this", ".", "commandStack", ".", "size", "(", ")", ">", "0", ")", "{", "// Here put the last command on the undone stack", "this", ".", "undoneStack", ".", "add", "(", "this", ".", "commandStack", ".", "get", "(", "this", ".", "commandStack", ".", "size", "(", ")", "-", "1", ")", ")", ";", "// here remove the last command of the command stack", "this", ".", "commandStack", ".", "remove", "(", "this", ".", "commandStack", ".", "get", "(", "this", ".", "commandStack", ".", "size", "(", ")", "-", "1", ")", ")", ";", "// Call Undo method", "this", ".", "undoneStack", ".", "get", "(", "this", ".", "undoneStack", ".", "size", "(", ")", "-", "1", ")", ".", "run", "(", "WBuilder", ".", "wave", "(", ")", ".", "addDatas", "(", "WBuilder", ".", "waveData", "(", "UndoRedoWaves", ".", "UNDO_REDO", ",", "true", ")", ")", ")", ";", "}", "else", "{", "// begin of stack, do nothing", "LOGGER", ".", "info", "(", "\"No more command to undo, begin of stack\"", ")", ";", "}", "}" ]
Undo the last command.
[ "Undo", "the", "last", "command", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java#L71-L86
8,422
JRebirth/JRebirth
org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java
UndoRedoService.redo
public void redo() { // If there is at least one command to redo if (this.undoneStack.size() > 0) { // add the last undone command on the command stack this.commandStack.add(this.undoneStack.get(this.undoneStack.size() - 1)); // remove the command to redo of the undone stack. this.undoneStack.remove(this.undoneStack.size() - 1); // Call Redo method this.commandStack.get(this.commandStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, false))); } else { // End of stack, do nothing LOGGER.info("No more command to redo, end of stack"); } }
java
public void redo() { // If there is at least one command to redo if (this.undoneStack.size() > 0) { // add the last undone command on the command stack this.commandStack.add(this.undoneStack.get(this.undoneStack.size() - 1)); // remove the command to redo of the undone stack. this.undoneStack.remove(this.undoneStack.size() - 1); // Call Redo method this.commandStack.get(this.commandStack.size() - 1) .run(WBuilder.wave().addDatas(WBuilder.waveData(UndoRedoWaves.UNDO_REDO, false))); } else { // End of stack, do nothing LOGGER.info("No more command to redo, end of stack"); } }
[ "public", "void", "redo", "(", ")", "{", "// If there is at least one command to redo", "if", "(", "this", ".", "undoneStack", ".", "size", "(", ")", ">", "0", ")", "{", "// add the last undone command on the command stack", "this", ".", "commandStack", ".", "add", "(", "this", ".", "undoneStack", ".", "get", "(", "this", ".", "undoneStack", ".", "size", "(", ")", "-", "1", ")", ")", ";", "// remove the command to redo of the undone stack.", "this", ".", "undoneStack", ".", "remove", "(", "this", ".", "undoneStack", ".", "size", "(", ")", "-", "1", ")", ";", "// Call Redo method", "this", ".", "commandStack", ".", "get", "(", "this", ".", "commandStack", ".", "size", "(", ")", "-", "1", ")", ".", "run", "(", "WBuilder", ".", "wave", "(", ")", ".", "addDatas", "(", "WBuilder", ".", "waveData", "(", "UndoRedoWaves", ".", "UNDO_REDO", ",", "false", ")", ")", ")", ";", "}", "else", "{", "// End of stack, do nothing", "LOGGER", ".", "info", "(", "\"No more command to redo, end of stack\"", ")", ";", "}", "}" ]
Redo the last command that was undo-ed.
[ "Redo", "the", "last", "command", "that", "was", "undo", "-", "ed", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/undoredo/src/main/java/org/jrebirth/af/undoredo/service/UndoRedoService.java#L91-L106
8,423
inloop/easygcm
easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java
EasyGcm.removeRegistrationId
public static void removeRegistrationId(Context context) { final SharedPreferences prefs = getGcmPreferences(context); prefs.edit() .remove(PROPERTY_REG_ID) .remove(PROPERTY_APP_VERSION) .apply(); }
java
public static void removeRegistrationId(Context context) { final SharedPreferences prefs = getGcmPreferences(context); prefs.edit() .remove(PROPERTY_REG_ID) .remove(PROPERTY_APP_VERSION) .apply(); }
[ "public", "static", "void", "removeRegistrationId", "(", "Context", "context", ")", "{", "final", "SharedPreferences", "prefs", "=", "getGcmPreferences", "(", "context", ")", ";", "prefs", ".", "edit", "(", ")", ".", "remove", "(", "PROPERTY_REG_ID", ")", ".", "remove", "(", "PROPERTY_APP_VERSION", ")", ".", "apply", "(", ")", ";", "}" ]
Removes the current registration id effectively forcing the app to register again. @param context application's context.
[ "Removes", "the", "current", "registration", "id", "effectively", "forcing", "the", "app", "to", "register", "again", "." ]
d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6
https://github.com/inloop/easygcm/blob/d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6/easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java#L131-L137
8,424
inloop/easygcm
easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java
EasyGcm.onCreate
private void onCreate(Context context) { // The check method fails if: no network connection / app already registered / GooglePlayServices unavailable if (GcmUtils.checkCanAndShouldRegister(context)) { // Start a background service to register in a background thread context.startService(GcmRegistrationService.createGcmRegistrationIntent(context)); } }
java
private void onCreate(Context context) { // The check method fails if: no network connection / app already registered / GooglePlayServices unavailable if (GcmUtils.checkCanAndShouldRegister(context)) { // Start a background service to register in a background thread context.startService(GcmRegistrationService.createGcmRegistrationIntent(context)); } }
[ "private", "void", "onCreate", "(", "Context", "context", ")", "{", "// The check method fails if: no network connection / app already registered / GooglePlayServices unavailable", "if", "(", "GcmUtils", ".", "checkCanAndShouldRegister", "(", "context", ")", ")", "{", "// Start a background service to register in a background thread", "context", ".", "startService", "(", "GcmRegistrationService", ".", "createGcmRegistrationIntent", "(", "context", ")", ")", ";", "}", "}" ]
Registers the application defined by a context activity to GCM in case the registration has not been done already. The method can be called anytime, but typically at app startup. The registration itself is guaranteed to only run once. @param context Activity belonging to the app being registered
[ "Registers", "the", "application", "defined", "by", "a", "context", "activity", "to", "GCM", "in", "case", "the", "registration", "has", "not", "been", "done", "already", ".", "The", "method", "can", "be", "called", "anytime", "but", "typically", "at", "app", "startup", ".", "The", "registration", "itself", "is", "guaranteed", "to", "only", "run", "once", "." ]
d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6
https://github.com/inloop/easygcm/blob/d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6/easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java#L174-L180
8,425
inloop/easygcm
easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java
EasyGcm.onSuccessfulRegistration
void onSuccessfulRegistration(Context context, String regId) { // You should send the registration ID to your server over HTTP, so it // can use GCM/HTTP or CCS to send messages to your app. getGcmListener(context).sendRegistrationIdToBackend(regId); // Persist the regID - no need to register again. // Also serves for detection of previous registrations storeRegistrationId(context, regId); }
java
void onSuccessfulRegistration(Context context, String regId) { // You should send the registration ID to your server over HTTP, so it // can use GCM/HTTP or CCS to send messages to your app. getGcmListener(context).sendRegistrationIdToBackend(regId); // Persist the regID - no need to register again. // Also serves for detection of previous registrations storeRegistrationId(context, regId); }
[ "void", "onSuccessfulRegistration", "(", "Context", "context", ",", "String", "regId", ")", "{", "// You should send the registration ID to your server over HTTP, so it", "// can use GCM/HTTP or CCS to send messages to your app.", "getGcmListener", "(", "context", ")", ".", "sendRegistrationIdToBackend", "(", "regId", ")", ";", "// Persist the regID - no need to register again.", "// Also serves for detection of previous registrations", "storeRegistrationId", "(", "context", ",", "regId", ")", ";", "}" ]
Called from an IntentService background thread
[ "Called", "from", "an", "IntentService", "background", "thread" ]
d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6
https://github.com/inloop/easygcm/blob/d06bbff11e52b956c3a7b1a2dc4f9799f20cf2c6/easygcm-lib/src/main/java/eu/inloop/easygcm/EasyGcm.java#L214-L223
8,426
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java
AbstractModuleStarter.define
protected void define(final Class<? extends Component<?>> interfaceClass, final boolean exclusive, final boolean reverse) { preloadClass(interfaceClass); getFacade().componentFactory().define( RegistrationPointItemBase.create() .interfaceClass(interfaceClass) .exclusive(exclusive) .reverse(reverse)); }
java
protected void define(final Class<? extends Component<?>> interfaceClass, final boolean exclusive, final boolean reverse) { preloadClass(interfaceClass); getFacade().componentFactory().define( RegistrationPointItemBase.create() .interfaceClass(interfaceClass) .exclusive(exclusive) .reverse(reverse)); }
[ "protected", "void", "define", "(", "final", "Class", "<", "?", "extends", "Component", "<", "?", ">", ">", "interfaceClass", ",", "final", "boolean", "exclusive", ",", "final", "boolean", "reverse", ")", "{", "preloadClass", "(", "interfaceClass", ")", ";", "getFacade", "(", ")", ".", "componentFactory", "(", ")", ".", "define", "(", "RegistrationPointItemBase", ".", "create", "(", ")", ".", "interfaceClass", "(", "interfaceClass", ")", ".", "exclusive", "(", "exclusive", ")", ".", "reverse", "(", "reverse", ")", ")", ";", "}" ]
Define a new component interface definition. @param interfaceClass the interface class implemented @param exclusive the exclusive flag @param reverse the reverse flag
[ "Define", "a", "new", "component", "interface", "definition", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java#L49-L58
8,427
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java
AbstractModuleStarter.bootComponent
@SuppressWarnings("unchecked") protected void bootComponent(final Class<? extends Component<?>> componentClass) { preloadClass(componentClass); try { if (Command.class.isAssignableFrom(componentClass)) { getFacade().commandFacade().retrieve((Class<Command>) componentClass); } else if (Service.class.isAssignableFrom(componentClass)) { getFacade().serviceFacade().retrieve((Class<Service>) componentClass); } else if (Model.class.isAssignableFrom(componentClass)) { getFacade().uiFacade().retrieve((Class<Model>) componentClass); } } catch (final CoreRuntimeException e) { LOGGER.error(BOOT_COMPONENT_ERROR, e, componentClass.getName()); } }
java
@SuppressWarnings("unchecked") protected void bootComponent(final Class<? extends Component<?>> componentClass) { preloadClass(componentClass); try { if (Command.class.isAssignableFrom(componentClass)) { getFacade().commandFacade().retrieve((Class<Command>) componentClass); } else if (Service.class.isAssignableFrom(componentClass)) { getFacade().serviceFacade().retrieve((Class<Service>) componentClass); } else if (Model.class.isAssignableFrom(componentClass)) { getFacade().uiFacade().retrieve((Class<Model>) componentClass); } } catch (final CoreRuntimeException e) { LOGGER.error(BOOT_COMPONENT_ERROR, e, componentClass.getName()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "bootComponent", "(", "final", "Class", "<", "?", "extends", "Component", "<", "?", ">", ">", "componentClass", ")", "{", "preloadClass", "(", "componentClass", ")", ";", "try", "{", "if", "(", "Command", ".", "class", ".", "isAssignableFrom", "(", "componentClass", ")", ")", "{", "getFacade", "(", ")", ".", "commandFacade", "(", ")", ".", "retrieve", "(", "(", "Class", "<", "Command", ">", ")", "componentClass", ")", ";", "}", "else", "if", "(", "Service", ".", "class", ".", "isAssignableFrom", "(", "componentClass", ")", ")", "{", "getFacade", "(", ")", ".", "serviceFacade", "(", ")", ".", "retrieve", "(", "(", "Class", "<", "Service", ">", ")", "componentClass", ")", ";", "}", "else", "if", "(", "Model", ".", "class", ".", "isAssignableFrom", "(", "componentClass", ")", ")", "{", "getFacade", "(", ")", ".", "uiFacade", "(", ")", ".", "retrieve", "(", "(", "Class", "<", "Model", ">", ")", "componentClass", ")", ";", "}", "}", "catch", "(", "final", "CoreRuntimeException", "e", ")", "{", "LOGGER", ".", "error", "(", "BOOT_COMPONENT_ERROR", ",", "e", ",", "componentClass", ".", "getName", "(", ")", ")", ";", "}", "}" ]
Boot component by retrieving it from its facade. @param componentClass the component class to boot
[ "Boot", "component", "by", "retrieving", "it", "from", "its", "facade", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java#L106-L122
8,428
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java
AbstractModuleStarter.preloadClass
protected void preloadClass(final Class<?> objectClass) { try { Class.forName(objectClass.getName()); } catch (final ClassNotFoundException e) { LOGGER.error(CLASS_NOT_FOUND, e, objectClass.getName()); } }
java
protected void preloadClass(final Class<?> objectClass) { try { Class.forName(objectClass.getName()); } catch (final ClassNotFoundException e) { LOGGER.error(CLASS_NOT_FOUND, e, objectClass.getName()); } }
[ "protected", "void", "preloadClass", "(", "final", "Class", "<", "?", ">", "objectClass", ")", "{", "try", "{", "Class", ".", "forName", "(", "objectClass", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "final", "ClassNotFoundException", "e", ")", "{", "LOGGER", ".", "error", "(", "CLASS_NOT_FOUND", ",", "e", ",", "objectClass", ".", "getName", "(", ")", ")", ";", "}", "}" ]
Preload class, useful to preload field initialized with JRebirth Builder. @param objectClass the object class to load from classloader
[ "Preload", "class", "useful", "to", "preload", "field", "initialized", "with", "JRebirth", "Builder", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/module/AbstractModuleStarter.java#L129-L135
8,429
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Favicon.java
Favicon.init
@Override public Middleware init(@NotNull final Yoke yoke, @NotNull final String mount) { try { super.init(yoke, mount); if (path == null) { icon = new Icon(Utils.readResourceToBuffer(getClass(), "favicon.ico")); } else { icon = new Icon(fileSystem().readFileBlocking(path)); } } catch (Exception e) { throw new RuntimeException(e); } return this; }
java
@Override public Middleware init(@NotNull final Yoke yoke, @NotNull final String mount) { try { super.init(yoke, mount); if (path == null) { icon = new Icon(Utils.readResourceToBuffer(getClass(), "favicon.ico")); } else { icon = new Icon(fileSystem().readFileBlocking(path)); } } catch (Exception e) { throw new RuntimeException(e); } return this; }
[ "@", "Override", "public", "Middleware", "init", "(", "@", "NotNull", "final", "Yoke", "yoke", ",", "@", "NotNull", "final", "String", "mount", ")", "{", "try", "{", "super", ".", "init", "(", "yoke", ",", "mount", ")", ";", "if", "(", "path", "==", "null", ")", "{", "icon", "=", "new", "Icon", "(", "Utils", ".", "readResourceToBuffer", "(", "getClass", "(", ")", ",", "\"favicon.ico\"", ")", ")", ";", "}", "else", "{", "icon", "=", "new", "Icon", "(", "fileSystem", "(", ")", ".", "readFileBlocking", "(", "path", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "this", ";", "}" ]
Loads the icon from the file system once we get a reference to Vert.x @param yoke @param mount
[ "Loads", "the", "icon", "from", "the", "file", "system", "once", "we", "get", "a", "reference", "to", "Vert", ".", "x" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Favicon.java#L127-L141
8,430
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/style/StyleSheetBuilder.java
StyleSheetBuilder.buildUrl
private URL buildUrl(final String styleSheetPath, final boolean skipStylesFolder) { URL cssResource = null; final List<String> stylePaths = skipStylesFolder ? Collections.singletonList("") : ResourceParameters.STYLE_FOLDER.get(); for (int i = 0; i < stylePaths.size() && cssResource == null; i++) { String stylePath = stylePaths.get(i); if (!stylePath.isEmpty()) { stylePath += Resources.PATH_SEP; } cssResource = Thread.currentThread().getContextClassLoader().getResource(stylePath + styleSheetPath); } if (cssResource == null) { LOGGER.error("Style Sheet : {} not found into base folder: {}", styleSheetPath, ResourceParameters.STYLE_FOLDER.get()); } return cssResource; }
java
private URL buildUrl(final String styleSheetPath, final boolean skipStylesFolder) { URL cssResource = null; final List<String> stylePaths = skipStylesFolder ? Collections.singletonList("") : ResourceParameters.STYLE_FOLDER.get(); for (int i = 0; i < stylePaths.size() && cssResource == null; i++) { String stylePath = stylePaths.get(i); if (!stylePath.isEmpty()) { stylePath += Resources.PATH_SEP; } cssResource = Thread.currentThread().getContextClassLoader().getResource(stylePath + styleSheetPath); } if (cssResource == null) { LOGGER.error("Style Sheet : {} not found into base folder: {}", styleSheetPath, ResourceParameters.STYLE_FOLDER.get()); } return cssResource; }
[ "private", "URL", "buildUrl", "(", "final", "String", "styleSheetPath", ",", "final", "boolean", "skipStylesFolder", ")", "{", "URL", "cssResource", "=", "null", ";", "final", "List", "<", "String", ">", "stylePaths", "=", "skipStylesFolder", "?", "Collections", ".", "singletonList", "(", "\"\"", ")", ":", "ResourceParameters", ".", "STYLE_FOLDER", ".", "get", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stylePaths", ".", "size", "(", ")", "&&", "cssResource", "==", "null", ";", "i", "++", ")", "{", "String", "stylePath", "=", "stylePaths", ".", "get", "(", "i", ")", ";", "if", "(", "!", "stylePath", ".", "isEmpty", "(", ")", ")", "{", "stylePath", "+=", "Resources", ".", "PATH_SEP", ";", "}", "cssResource", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResource", "(", "stylePath", "+", "styleSheetPath", ")", ";", "}", "if", "(", "cssResource", "==", "null", ")", "{", "LOGGER", ".", "error", "(", "\"Style Sheet : {} not found into base folder: {}\"", ",", "styleSheetPath", ",", "ResourceParameters", ".", "STYLE_FOLDER", ".", "get", "(", ")", ")", ";", "}", "return", "cssResource", ";", "}" ]
Get a style sheet URL. @param styleSheetPath the path of the style sheet, path must be separated by '/' @param skipStylesFolder skip stylesFolder usage @return the stylesheet url
[ "Get", "a", "style", "sheet", "URL", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/style/StyleSheetBuilder.java#L95-L114
8,431
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/engine/AbstractEngineSync.java
AbstractEngineSync.lastModified
public long lastModified(final String filename) { LRUCache.CacheEntry<String, T> cacheEntry = cache.get(filename); if (cacheEntry == null) { return -1; } return cacheEntry.lastModified; }
java
public long lastModified(final String filename) { LRUCache.CacheEntry<String, T> cacheEntry = cache.get(filename); if (cacheEntry == null) { return -1; } return cacheEntry.lastModified; }
[ "public", "long", "lastModified", "(", "final", "String", "filename", ")", "{", "LRUCache", ".", "CacheEntry", "<", "String", ",", "T", ">", "cacheEntry", "=", "cache", ".", "get", "(", "filename", ")", ";", "if", "(", "cacheEntry", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "cacheEntry", ".", "lastModified", ";", "}" ]
Returns the last modified time for the cache entry @param filename File to look for
[ "Returns", "the", "last", "modified", "time", "for", "the", "cache", "entry" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/engine/AbstractEngineSync.java#L75-L81
8,432
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.get
@SuppressWarnings("unchecked") public <R> R get(@NotNull final String name) { // do some conversions for JsonObject/JsonArray Object o = context.get(name); if (o instanceof Map) { return (R) new JsonObject((Map) o); } if (o instanceof List) { return (R) new JsonArray((List) o); } return (R) o; }
java
@SuppressWarnings("unchecked") public <R> R get(@NotNull final String name) { // do some conversions for JsonObject/JsonArray Object o = context.get(name); if (o instanceof Map) { return (R) new JsonObject((Map) o); } if (o instanceof List) { return (R) new JsonArray((List) o); } return (R) o; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "R", ">", "R", "get", "(", "@", "NotNull", "final", "String", "name", ")", "{", "// do some conversions for JsonObject/JsonArray", "Object", "o", "=", "context", ".", "get", "(", "name", ")", ";", "if", "(", "o", "instanceof", "Map", ")", "{", "return", "(", "R", ")", "new", "JsonObject", "(", "(", "Map", ")", "o", ")", ";", "}", "if", "(", "o", "instanceof", "List", ")", "{", "return", "(", "R", ")", "new", "JsonArray", "(", "(", "List", ")", "o", ")", ";", "}", "return", "(", "R", ")", "o", ";", "}" ]
Allow getting properties in a generified way. @param name The key to get @return {R} The found object
[ "Allow", "getting", "properties", "in", "a", "generified", "way", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L104-L116
8,433
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.get
public <R> R get(@NotNull final String name, R defaultValue) { if (context.containsKey(name)) { return get(name); } else { return defaultValue; } }
java
public <R> R get(@NotNull final String name, R defaultValue) { if (context.containsKey(name)) { return get(name); } else { return defaultValue; } }
[ "public", "<", "R", ">", "R", "get", "(", "@", "NotNull", "final", "String", "name", ",", "R", "defaultValue", ")", "{", "if", "(", "context", ".", "containsKey", "(", "name", ")", ")", "{", "return", "get", "(", "name", ")", ";", "}", "else", "{", "return", "defaultValue", ";", "}", "}" ]
Allow getting properties in a generified way and return defaultValue if the key does not exist. @param name The key to get @param defaultValue value returned when the key does not exist @return {R} The found object
[ "Allow", "getting", "properties", "in", "a", "generified", "way", "and", "return", "defaultValue", "if", "the", "key", "does", "not", "exist", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L124-L130
8,434
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.put
@SuppressWarnings("unchecked") public <R> R put(@NotNull final String name, R value) { if (value == null) { return (R) context.remove(name); } return (R) context.put(name, value); }
java
@SuppressWarnings("unchecked") public <R> R put(@NotNull final String name, R value) { if (value == null) { return (R) context.remove(name); } return (R) context.put(name, value); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "R", ">", "R", "put", "(", "@", "NotNull", "final", "String", "name", ",", "R", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "(", "R", ")", "context", ".", "remove", "(", "name", ")", ";", "}", "return", "(", "R", ")", "context", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Allows putting a value into the context @param name the key to store @param value the value to store @return {R} the previous value or null
[ "Allows", "putting", "a", "value", "into", "the", "context" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L138-L144
8,435
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getCookie
public YokeCookie getCookie(@NotNull final String name) { if (cookies != null) { for (YokeCookie c : cookies) { if (name.equals(c.name())) { return c; } } } return null; }
java
public YokeCookie getCookie(@NotNull final String name) { if (cookies != null) { for (YokeCookie c : cookies) { if (name.equals(c.name())) { return c; } } } return null; }
[ "public", "YokeCookie", "getCookie", "(", "@", "NotNull", "final", "String", "name", ")", "{", "if", "(", "cookies", "!=", "null", ")", "{", "for", "(", "YokeCookie", "c", ":", "cookies", ")", "{", "if", "(", "name", ".", "equals", "(", "c", ".", "name", "(", ")", ")", ")", "{", "return", "c", ";", "}", "}", "}", "return", "null", ";", "}" ]
Allow getting Cookie by name. @param name The key to get @return The found object
[ "Allow", "getting", "Cookie", "by", "name", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L197-L206
8,436
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getAllCookies
public List<YokeCookie> getAllCookies(@NotNull final String name) { List<YokeCookie> foundCookies = new ArrayList<>(); if (cookies != null) { for (YokeCookie c : cookies) { if (name.equals(c.name())) { foundCookies.add(c); } } } return foundCookies; }
java
public List<YokeCookie> getAllCookies(@NotNull final String name) { List<YokeCookie> foundCookies = new ArrayList<>(); if (cookies != null) { for (YokeCookie c : cookies) { if (name.equals(c.name())) { foundCookies.add(c); } } } return foundCookies; }
[ "public", "List", "<", "YokeCookie", ">", "getAllCookies", "(", "@", "NotNull", "final", "String", "name", ")", "{", "List", "<", "YokeCookie", ">", "foundCookies", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "cookies", "!=", "null", ")", "{", "for", "(", "YokeCookie", "c", ":", "cookies", ")", "{", "if", "(", "name", ".", "equals", "(", "c", ".", "name", "(", ")", ")", ")", "{", "foundCookies", ".", "add", "(", "c", ")", ";", "}", "}", "}", "return", "foundCookies", ";", "}" ]
Allow getting all Cookie by name. @param name The key to get @return The found objects
[ "Allow", "getting", "all", "Cookie", "by", "name", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L213-L223
8,437
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.contentLength
public long contentLength() { String contentLengthHeader = headers().get("content-length"); if (contentLengthHeader != null) { return Long.parseLong(contentLengthHeader); } else { return -1; } }
java
public long contentLength() { String contentLengthHeader = headers().get("content-length"); if (contentLengthHeader != null) { return Long.parseLong(contentLengthHeader); } else { return -1; } }
[ "public", "long", "contentLength", "(", ")", "{", "String", "contentLengthHeader", "=", "headers", "(", ")", ".", "get", "(", "\"content-length\"", ")", ";", "if", "(", "contentLengthHeader", "!=", "null", ")", "{", "return", "Long", ".", "parseLong", "(", "contentLengthHeader", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}" ]
Returns the content length of this request setBody or -1 if header is not present.
[ "Returns", "the", "content", "length", "of", "this", "request", "setBody", "or", "-", "1", "if", "header", "is", "not", "present", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L259-L266
8,438
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.body
@SuppressWarnings("unchecked") public <V> V body() { if (body != null) { if (body instanceof Map) { return (V) new JsonObject((Map) body); } if (body instanceof List) { return (V) new JsonArray((List) body); } } return (V) body; }
java
@SuppressWarnings("unchecked") public <V> V body() { if (body != null) { if (body instanceof Map) { return (V) new JsonObject((Map) body); } if (body instanceof List) { return (V) new JsonArray((List) body); } } return (V) body; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "V", ">", "V", "body", "(", ")", "{", "if", "(", "body", "!=", "null", ")", "{", "if", "(", "body", "instanceof", "Map", ")", "{", "return", "(", "V", ")", "new", "JsonObject", "(", "(", "Map", ")", "body", ")", ";", "}", "if", "(", "body", "instanceof", "List", ")", "{", "return", "(", "V", ")", "new", "JsonArray", "(", "(", "List", ")", "body", ")", ";", "}", "}", "return", "(", "V", ")", "body", ";", "}" ]
The request body and eventually a parsed version of it in json or map
[ "The", "request", "body", "and", "eventually", "a", "parsed", "version", "of", "it", "in", "json", "or", "map" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L269-L281
8,439
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getFile
public YokeFileUpload getFile(@NotNull final String name) { if (files == null) { return null; } return files.get(name); }
java
public YokeFileUpload getFile(@NotNull final String name) { if (files == null) { return null; } return files.get(name); }
[ "public", "YokeFileUpload", "getFile", "(", "@", "NotNull", "final", "String", "name", ")", "{", "if", "(", "files", "==", "null", ")", "{", "return", "null", ";", "}", "return", "files", ".", "get", "(", "name", ")", ";", "}" ]
Get an uploaded file
[ "Get", "an", "uploaded", "file" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L295-L301
8,440
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.destroySession
public void destroySession() { JsonObject session = get("session"); if (session == null) { return; } String sessionId = session.getString("id"); // remove from the context put("session", null); if (sessionId == null) { return; } store.destroy(sessionId, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); }
java
public void destroySession() { JsonObject session = get("session"); if (session == null) { return; } String sessionId = session.getString("id"); // remove from the context put("session", null); if (sessionId == null) { return; } store.destroy(sessionId, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); }
[ "public", "void", "destroySession", "(", ")", "{", "JsonObject", "session", "=", "get", "(", "\"session\"", ")", ";", "if", "(", "session", "==", "null", ")", "{", "return", ";", "}", "String", "sessionId", "=", "session", ".", "getString", "(", "\"id\"", ")", ";", "// remove from the context", "put", "(", "\"session\"", ",", "null", ")", ";", "if", "(", "sessionId", "==", "null", ")", "{", "return", ";", "}", "store", ".", "destroy", "(", "sessionId", ",", "new", "Handler", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "Object", "error", ")", "{", "if", "(", "error", "!=", "null", ")", "{", "// TODO: better handling of errors", "System", ".", "err", ".", "println", "(", "error", ")", ";", "}", "}", "}", ")", ";", "}" ]
Destroys a session from the request context and also from the storage engine.
[ "Destroys", "a", "session", "from", "the", "request", "context", "and", "also", "from", "the", "storage", "engine", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L317-L340
8,441
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.loadSession
public void loadSession(final String sessionId, final Handler<Object> handler) { if (sessionId == null) { handler.handle(null); return; } store.get(sessionId, new Handler<JsonObject>() { @Override public void handle(JsonObject session) { if (session != null) { put("session", session); } response().headersHandler(new Handler<Void>() { @Override public void handle(Void event) { int responseStatus = response().getStatusCode(); // Only save on success and redirect status codes if (responseStatus >= 200 && responseStatus < 400) { JsonObject session = get("session"); if (session != null) { store.set(sessionId, session, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); } } } }); handler.handle(null); } }); }
java
public void loadSession(final String sessionId, final Handler<Object> handler) { if (sessionId == null) { handler.handle(null); return; } store.get(sessionId, new Handler<JsonObject>() { @Override public void handle(JsonObject session) { if (session != null) { put("session", session); } response().headersHandler(new Handler<Void>() { @Override public void handle(Void event) { int responseStatus = response().getStatusCode(); // Only save on success and redirect status codes if (responseStatus >= 200 && responseStatus < 400) { JsonObject session = get("session"); if (session != null) { store.set(sessionId, session, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); } } } }); handler.handle(null); } }); }
[ "public", "void", "loadSession", "(", "final", "String", "sessionId", ",", "final", "Handler", "<", "Object", ">", "handler", ")", "{", "if", "(", "sessionId", "==", "null", ")", "{", "handler", ".", "handle", "(", "null", ")", ";", "return", ";", "}", "store", ".", "get", "(", "sessionId", ",", "new", "Handler", "<", "JsonObject", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "JsonObject", "session", ")", "{", "if", "(", "session", "!=", "null", ")", "{", "put", "(", "\"session\"", ",", "session", ")", ";", "}", "response", "(", ")", ".", "headersHandler", "(", "new", "Handler", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "Void", "event", ")", "{", "int", "responseStatus", "=", "response", "(", ")", ".", "getStatusCode", "(", ")", ";", "// Only save on success and redirect status codes", "if", "(", "responseStatus", ">=", "200", "&&", "responseStatus", "<", "400", ")", "{", "JsonObject", "session", "=", "get", "(", "\"session\"", ")", ";", "if", "(", "session", "!=", "null", ")", "{", "store", ".", "set", "(", "sessionId", ",", "session", ",", "new", "Handler", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "Object", "error", ")", "{", "if", "(", "error", "!=", "null", ")", "{", "// TODO: better handling of errors", "System", ".", "err", ".", "println", "(", "error", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}", "}", ")", ";", "handler", ".", "handle", "(", "null", ")", ";", "}", "}", ")", ";", "}" ]
Loads a session given its session id and sets the "session" property in the request context. @param sessionId the id to load @param handler the success/complete handler
[ "Loads", "a", "session", "given", "its", "session", "id", "and", "sets", "the", "session", "property", "in", "the", "request", "context", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L346-L384
8,442
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.createSession
public JsonObject createSession(@NotNull final String sessionId) { final JsonObject session = new JsonObject().put("id", sessionId); put("session", session); response().headersHandler(new Handler<Void>() { @Override public void handle(Void event) { int responseStatus = response().getStatusCode(); // Only save on success and redirect status codes if (responseStatus >= 200 && responseStatus < 400) { JsonObject session = get("session"); if (session != null) { store.set(sessionId, session, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); } } } }); return session; }
java
public JsonObject createSession(@NotNull final String sessionId) { final JsonObject session = new JsonObject().put("id", sessionId); put("session", session); response().headersHandler(new Handler<Void>() { @Override public void handle(Void event) { int responseStatus = response().getStatusCode(); // Only save on success and redirect status codes if (responseStatus >= 200 && responseStatus < 400) { JsonObject session = get("session"); if (session != null) { store.set(sessionId, session, new Handler<Object>() { @Override public void handle(Object error) { if (error != null) { // TODO: better handling of errors System.err.println(error); } } }); } } } }); return session; }
[ "public", "JsonObject", "createSession", "(", "@", "NotNull", "final", "String", "sessionId", ")", "{", "final", "JsonObject", "session", "=", "new", "JsonObject", "(", ")", ".", "put", "(", "\"id\"", ",", "sessionId", ")", ";", "put", "(", "\"session\"", ",", "session", ")", ";", "response", "(", ")", ".", "headersHandler", "(", "new", "Handler", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "Void", "event", ")", "{", "int", "responseStatus", "=", "response", "(", ")", ".", "getStatusCode", "(", ")", ";", "// Only save on success and redirect status codes", "if", "(", "responseStatus", ">=", "200", "&&", "responseStatus", "<", "400", ")", "{", "JsonObject", "session", "=", "get", "(", "\"session\"", ")", ";", "if", "(", "session", "!=", "null", ")", "{", "store", ".", "set", "(", "sessionId", ",", "session", ",", "new", "Handler", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "void", "handle", "(", "Object", "error", ")", "{", "if", "(", "error", "!=", "null", ")", "{", "// TODO: better handling of errors", "System", ".", "err", ".", "println", "(", "error", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}", "}", ")", ";", "return", "session", ";", "}" ]
Create a new Session with custom Id and store it with the underlying storage. Internally create a entry in the request context under the name "session" and add a end handler to save that object once the execution is terminated. Custom session id could be used with external auth provider like mod-auth-mgr. @param sessionId custom session id @return {JsonObject} session
[ "Create", "a", "new", "Session", "with", "custom", "Id", "and", "store", "it", "with", "the", "underlying", "storage", ".", "Internally", "create", "a", "entry", "in", "the", "request", "context", "under", "the", "name", "session", "and", "add", "a", "end", "handler", "to", "save", "that", "object", "once", "the", "execution", "is", "terminated", ".", "Custom", "session", "id", "could", "be", "used", "with", "external", "auth", "provider", "like", "mod", "-", "auth", "-", "mgr", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L405-L433
8,443
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.sortedHeader
public List<String> sortedHeader(@NotNull final String header) { String accept = getHeader(header); // accept anything when accept is not present if (accept == null) { return Collections.emptyList(); } // parse String[] items = accept.split(" *, *"); // sort on quality Arrays.sort(items, ACCEPT_X_COMPARATOR); List<String> list = new ArrayList<>(items.length); for (String item : items) { // find any ; e.g.: "application/json;q=0.8" int space = item.indexOf(';'); if (space != -1) { list.add(item.substring(0, space)); } else { list.add(item); } } return list; }
java
public List<String> sortedHeader(@NotNull final String header) { String accept = getHeader(header); // accept anything when accept is not present if (accept == null) { return Collections.emptyList(); } // parse String[] items = accept.split(" *, *"); // sort on quality Arrays.sort(items, ACCEPT_X_COMPARATOR); List<String> list = new ArrayList<>(items.length); for (String item : items) { // find any ; e.g.: "application/json;q=0.8" int space = item.indexOf(';'); if (space != -1) { list.add(item.substring(0, space)); } else { list.add(item); } } return list; }
[ "public", "List", "<", "String", ">", "sortedHeader", "(", "@", "NotNull", "final", "String", "header", ")", "{", "String", "accept", "=", "getHeader", "(", "header", ")", ";", "// accept anything when accept is not present", "if", "(", "accept", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "// parse", "String", "[", "]", "items", "=", "accept", ".", "split", "(", "\" *, *\"", ")", ";", "// sort on quality", "Arrays", ".", "sort", "(", "items", ",", "ACCEPT_X_COMPARATOR", ")", ";", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", "items", ".", "length", ")", ";", "for", "(", "String", "item", ":", "items", ")", "{", "// find any ; e.g.: \"application/json;q=0.8\"", "int", "space", "=", "item", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "space", "!=", "-", "1", ")", "{", "list", ".", "add", "(", "item", ".", "substring", "(", "0", ",", "space", ")", ")", ";", "}", "else", "{", "list", ".", "add", "(", "item", ")", ";", "}", "}", "return", "list", ";", "}" ]
Returns the array of accept-? ordered by quality.
[ "Returns", "the", "array", "of", "accept", "-", "?", "ordered", "by", "quality", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L492-L518
8,444
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getParam
public String getParam(@NotNull final String name, String defaultValue) { String value = getParam(name); if (value == null) { return defaultValue; } return value; }
java
public String getParam(@NotNull final String name, String defaultValue) { String value = getParam(name); if (value == null) { return defaultValue; } return value; }
[ "public", "String", "getParam", "(", "@", "NotNull", "final", "String", "name", ",", "String", "defaultValue", ")", "{", "String", "value", "=", "getParam", "(", "name", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "return", "value", ";", "}" ]
Allow getting parameters in a generified way and return defaultValue if the key does not exist. @param name The key to get @param defaultValue value returned when the key does not exist @return {String} The found object
[ "Allow", "getting", "parameters", "in", "a", "generified", "way", "and", "return", "defaultValue", "if", "the", "key", "does", "not", "exist", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L602-L610
8,445
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getFormAttribute
public String getFormAttribute(@NotNull final String name, String defaultValue) { String value = request.formAttributes().get(name); if (value == null) { return defaultValue; } return value; }
java
public String getFormAttribute(@NotNull final String name, String defaultValue) { String value = request.formAttributes().get(name); if (value == null) { return defaultValue; } return value; }
[ "public", "String", "getFormAttribute", "(", "@", "NotNull", "final", "String", "name", ",", "String", "defaultValue", ")", "{", "String", "value", "=", "request", ".", "formAttributes", "(", ")", ".", "get", "(", "name", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "return", "value", ";", "}" ]
Allow getting form parameters in a generified way and return defaultValue if the key does not exist. @param name The key to get @param defaultValue value returned when the key does not exist @return {String} The found object
[ "Allow", "getting", "form", "parameters", "in", "a", "generified", "way", "and", "return", "defaultValue", "if", "the", "key", "does", "not", "exist", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L647-L655
8,446
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.getFormParameterList
public List<String> getFormParameterList(@NotNull final String name) { return request.formAttributes().getAll(name); }
java
public List<String> getFormParameterList(@NotNull final String name) { return request.formAttributes().getAll(name); }
[ "public", "List", "<", "String", ">", "getFormParameterList", "(", "@", "NotNull", "final", "String", "name", ")", "{", "return", "request", ".", "formAttributes", "(", ")", ".", "getAll", "(", "name", ")", ";", "}" ]
Allow getting form parameters in a generified way. @param name The key to get @return {List} The found object
[ "Allow", "getting", "form", "parameters", "in", "a", "generified", "way", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L662-L664
8,447
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
YokeRequest.locale
public Locale locale() { String languages = getHeader("Accept-Language"); if (languages != null) { // parse String[] acceptLanguages = languages.split(" *, *"); // sort on quality Arrays.sort(acceptLanguages, ACCEPT_X_COMPARATOR); String bestLanguage = acceptLanguages[0]; int idx = bestLanguage.indexOf(';'); if (idx != -1) { bestLanguage = bestLanguage.substring(0, idx).trim(); } String[] parts = bestLanguage.split("_|-"); switch (parts.length) { case 3: return new Locale(parts[0], parts[1], parts[2]); case 2: return new Locale(parts[0], parts[1]); case 1: return new Locale(parts[0]); } } return Locale.getDefault(); }
java
public Locale locale() { String languages = getHeader("Accept-Language"); if (languages != null) { // parse String[] acceptLanguages = languages.split(" *, *"); // sort on quality Arrays.sort(acceptLanguages, ACCEPT_X_COMPARATOR); String bestLanguage = acceptLanguages[0]; int idx = bestLanguage.indexOf(';'); if (idx != -1) { bestLanguage = bestLanguage.substring(0, idx).trim(); } String[] parts = bestLanguage.split("_|-"); switch (parts.length) { case 3: return new Locale(parts[0], parts[1], parts[2]); case 2: return new Locale(parts[0], parts[1]); case 1: return new Locale(parts[0]); } } return Locale.getDefault(); }
[ "public", "Locale", "locale", "(", ")", "{", "String", "languages", "=", "getHeader", "(", "\"Accept-Language\"", ")", ";", "if", "(", "languages", "!=", "null", ")", "{", "// parse", "String", "[", "]", "acceptLanguages", "=", "languages", ".", "split", "(", "\" *, *\"", ")", ";", "// sort on quality", "Arrays", ".", "sort", "(", "acceptLanguages", ",", "ACCEPT_X_COMPARATOR", ")", ";", "String", "bestLanguage", "=", "acceptLanguages", "[", "0", "]", ";", "int", "idx", "=", "bestLanguage", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "bestLanguage", "=", "bestLanguage", ".", "substring", "(", "0", ",", "idx", ")", ".", "trim", "(", ")", ";", "}", "String", "[", "]", "parts", "=", "bestLanguage", ".", "split", "(", "\"_|-\"", ")", ";", "switch", "(", "parts", ".", "length", ")", "{", "case", "3", ":", "return", "new", "Locale", "(", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", ",", "parts", "[", "2", "]", ")", ";", "case", "2", ":", "return", "new", "Locale", "(", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", ")", ";", "case", "1", ":", "return", "new", "Locale", "(", "parts", "[", "0", "]", ")", ";", "}", "}", "return", "Locale", ".", "getDefault", "(", ")", ";", "}" ]
Read the default locale for this request @return Locale (best match if more than one)
[ "Read", "the", "default", "locale", "for", "this", "request" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L675-L700
8,448
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java
FXMLUtils.loadFXML
public static <M extends Model> FXMLComponentBase loadFXML(final M model, final String fxmlPath) { return loadFXML(model, fxmlPath, null); }
java
public static <M extends Model> FXMLComponentBase loadFXML(final M model, final String fxmlPath) { return loadFXML(model, fxmlPath, null); }
[ "public", "static", "<", "M", "extends", "Model", ">", "FXMLComponentBase", "loadFXML", "(", "final", "M", "model", ",", "final", "String", "fxmlPath", ")", "{", "return", "loadFXML", "(", "model", ",", "fxmlPath", ",", "null", ")", ";", "}" ]
Load a FXML component without resource bundle. The fxml path could be : <ul> <li>Relative : fxml file will be loaded with the classloader of the given model class</li> <li>Absolute : fxml file will be loaded with default thread class loader, packages must be separated by / character</li> </ul> @param model the model that will manage the fxml node @param fxmlPath the fxml string path @return a FXMLComponent object that wrap a fxml node with its controller @param <M> the model type that will manage this fxml node
[ "Load", "a", "FXML", "component", "without", "resource", "bundle", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java#L72-L74
8,449
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java
FXMLUtils.loadFXML
@SuppressWarnings("unchecked") public static <M extends Model> FXMLComponentBase loadFXML(final M model, final String fxmlPath, final String bundlePath) { final FXMLLoader fxmlLoader = new FXMLLoader(); final Callback<Class<?>, Object> fxmlControllerFactory = (Callback<Class<?>, Object>) ParameterUtility.buildCustomizableClass(ExtensionParameters.FXML_CONTROLLER_FACTORY, DefaultFXMLControllerFactory.class, FXMLControllerFactory.class); if (fxmlControllerFactory instanceof FXMLControllerFactory) { ((FXMLControllerFactory) fxmlControllerFactory).relatedModel(model); } // Use Custom controller factory to attach the root model to the controller fxmlLoader.setControllerFactory(fxmlControllerFactory); fxmlLoader.setLocation(convertFxmlUrl(model, fxmlPath)); try { if (bundlePath != null) { fxmlLoader.setResources(ResourceBundle.getBundle(bundlePath)); } } catch (final MissingResourceException e) { LOGGER.log(MISSING_RESOURCE_BUNDLE, e, bundlePath); } Node node = null; boolean error = false; try { error = fxmlLoader.getLocation() == null; if (error) { node = TextBuilder.create().text(FXML_ERROR_NODE_LABEL.getText(fxmlPath)).build(); } else { node = (Node) fxmlLoader.load(fxmlLoader.getLocation().openStream()); } } catch (final IOException e) { throw new CoreRuntimeException(FXML_NODE_DOESNT_EXIST.getText(fxmlPath), e); } final FXMLController<M, ?> fxmlController = (FXMLController<M, ?>) fxmlLoader.getController(); // It's tolerated to have a null controller for an fxml node if (fxmlController != null) { // The fxml controller must extends AbstractFXMLController if (!error && !(fxmlLoader.getController() instanceof AbstractFXMLController)) { throw new CoreRuntimeException(BAD_FXML_CONTROLLER_ANCESTOR.getText(fxmlLoader.getController().getClass().getCanonicalName())); } // Link the View component with the fxml controller fxmlController.model(model); } return new FXMLComponentBase(node, fxmlController); }
java
@SuppressWarnings("unchecked") public static <M extends Model> FXMLComponentBase loadFXML(final M model, final String fxmlPath, final String bundlePath) { final FXMLLoader fxmlLoader = new FXMLLoader(); final Callback<Class<?>, Object> fxmlControllerFactory = (Callback<Class<?>, Object>) ParameterUtility.buildCustomizableClass(ExtensionParameters.FXML_CONTROLLER_FACTORY, DefaultFXMLControllerFactory.class, FXMLControllerFactory.class); if (fxmlControllerFactory instanceof FXMLControllerFactory) { ((FXMLControllerFactory) fxmlControllerFactory).relatedModel(model); } // Use Custom controller factory to attach the root model to the controller fxmlLoader.setControllerFactory(fxmlControllerFactory); fxmlLoader.setLocation(convertFxmlUrl(model, fxmlPath)); try { if (bundlePath != null) { fxmlLoader.setResources(ResourceBundle.getBundle(bundlePath)); } } catch (final MissingResourceException e) { LOGGER.log(MISSING_RESOURCE_BUNDLE, e, bundlePath); } Node node = null; boolean error = false; try { error = fxmlLoader.getLocation() == null; if (error) { node = TextBuilder.create().text(FXML_ERROR_NODE_LABEL.getText(fxmlPath)).build(); } else { node = (Node) fxmlLoader.load(fxmlLoader.getLocation().openStream()); } } catch (final IOException e) { throw new CoreRuntimeException(FXML_NODE_DOESNT_EXIST.getText(fxmlPath), e); } final FXMLController<M, ?> fxmlController = (FXMLController<M, ?>) fxmlLoader.getController(); // It's tolerated to have a null controller for an fxml node if (fxmlController != null) { // The fxml controller must extends AbstractFXMLController if (!error && !(fxmlLoader.getController() instanceof AbstractFXMLController)) { throw new CoreRuntimeException(BAD_FXML_CONTROLLER_ANCESTOR.getText(fxmlLoader.getController().getClass().getCanonicalName())); } // Link the View component with the fxml controller fxmlController.model(model); } return new FXMLComponentBase(node, fxmlController); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "M", "extends", "Model", ">", "FXMLComponentBase", "loadFXML", "(", "final", "M", "model", ",", "final", "String", "fxmlPath", ",", "final", "String", "bundlePath", ")", "{", "final", "FXMLLoader", "fxmlLoader", "=", "new", "FXMLLoader", "(", ")", ";", "final", "Callback", "<", "Class", "<", "?", ">", ",", "Object", ">", "fxmlControllerFactory", "=", "(", "Callback", "<", "Class", "<", "?", ">", ",", "Object", ">", ")", "ParameterUtility", ".", "buildCustomizableClass", "(", "ExtensionParameters", ".", "FXML_CONTROLLER_FACTORY", ",", "DefaultFXMLControllerFactory", ".", "class", ",", "FXMLControllerFactory", ".", "class", ")", ";", "if", "(", "fxmlControllerFactory", "instanceof", "FXMLControllerFactory", ")", "{", "(", "(", "FXMLControllerFactory", ")", "fxmlControllerFactory", ")", ".", "relatedModel", "(", "model", ")", ";", "}", "// Use Custom controller factory to attach the root model to the controller\r", "fxmlLoader", ".", "setControllerFactory", "(", "fxmlControllerFactory", ")", ";", "fxmlLoader", ".", "setLocation", "(", "convertFxmlUrl", "(", "model", ",", "fxmlPath", ")", ")", ";", "try", "{", "if", "(", "bundlePath", "!=", "null", ")", "{", "fxmlLoader", ".", "setResources", "(", "ResourceBundle", ".", "getBundle", "(", "bundlePath", ")", ")", ";", "}", "}", "catch", "(", "final", "MissingResourceException", "e", ")", "{", "LOGGER", ".", "log", "(", "MISSING_RESOURCE_BUNDLE", ",", "e", ",", "bundlePath", ")", ";", "}", "Node", "node", "=", "null", ";", "boolean", "error", "=", "false", ";", "try", "{", "error", "=", "fxmlLoader", ".", "getLocation", "(", ")", "==", "null", ";", "if", "(", "error", ")", "{", "node", "=", "TextBuilder", ".", "create", "(", ")", ".", "text", "(", "FXML_ERROR_NODE_LABEL", ".", "getText", "(", "fxmlPath", ")", ")", ".", "build", "(", ")", ";", "}", "else", "{", "node", "=", "(", "Node", ")", "fxmlLoader", ".", "load", "(", "fxmlLoader", ".", "getLocation", "(", ")", ".", "openStream", "(", ")", ")", ";", "}", "}", "catch", "(", "final", "IOException", "e", ")", "{", "throw", "new", "CoreRuntimeException", "(", "FXML_NODE_DOESNT_EXIST", ".", "getText", "(", "fxmlPath", ")", ",", "e", ")", ";", "}", "final", "FXMLController", "<", "M", ",", "?", ">", "fxmlController", "=", "(", "FXMLController", "<", "M", ",", "?", ">", ")", "fxmlLoader", ".", "getController", "(", ")", ";", "// It's tolerated to have a null controller for an fxml node\r", "if", "(", "fxmlController", "!=", "null", ")", "{", "// The fxml controller must extends AbstractFXMLController\r", "if", "(", "!", "error", "&&", "!", "(", "fxmlLoader", ".", "getController", "(", ")", "instanceof", "AbstractFXMLController", ")", ")", "{", "throw", "new", "CoreRuntimeException", "(", "BAD_FXML_CONTROLLER_ANCESTOR", ".", "getText", "(", "fxmlLoader", ".", "getController", "(", ")", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", ")", ")", ";", "}", "// Link the View component with the fxml controller\r", "fxmlController", ".", "model", "(", "model", ")", ";", "}", "return", "new", "FXMLComponentBase", "(", "node", ",", "fxmlController", ")", ";", "}" ]
Load a FXML component. The fxml path could be : <ul> <li>Relative : fxml file will be loaded with the classloader of the given model class</li> <li>Absolute : fxml file will be loaded with default thread class loader, packages must be separated by / character</li> </ul> @param model the model that will manage the fxml node @param fxmlPath the fxml string path @param bundlePath the bundle string path @return a FXMLComponent object that wrap a fxml node with its controller @param <M> the model type that will manage this fxml node
[ "Load", "a", "FXML", "component", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java#L93-L144
8,450
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java
FXMLUtils.convertFxmlUrl
private static <M extends Model> URL convertFxmlUrl(final M model, final String fxmlPath) { URL fxmlUrl = null; // Replace all '.' separator by path separator '/' if (model != null) { // Try to load the resource from the same path as the model class fxmlUrl = model.getClass().getResource(fxmlPath); } if (fxmlUrl == null) { // Try to load the resource from the full path org/jrebirth/core/ui/Test.fxml fxmlUrl = Thread.currentThread().getContextClassLoader().getResource(fxmlPath); } return fxmlUrl; }
java
private static <M extends Model> URL convertFxmlUrl(final M model, final String fxmlPath) { URL fxmlUrl = null; // Replace all '.' separator by path separator '/' if (model != null) { // Try to load the resource from the same path as the model class fxmlUrl = model.getClass().getResource(fxmlPath); } if (fxmlUrl == null) { // Try to load the resource from the full path org/jrebirth/core/ui/Test.fxml fxmlUrl = Thread.currentThread().getContextClassLoader().getResource(fxmlPath); } return fxmlUrl; }
[ "private", "static", "<", "M", "extends", "Model", ">", "URL", "convertFxmlUrl", "(", "final", "M", "model", ",", "final", "String", "fxmlPath", ")", "{", "URL", "fxmlUrl", "=", "null", ";", "// Replace all '.' separator by path separator '/'\r", "if", "(", "model", "!=", "null", ")", "{", "// Try to load the resource from the same path as the model class\r", "fxmlUrl", "=", "model", ".", "getClass", "(", ")", ".", "getResource", "(", "fxmlPath", ")", ";", "}", "if", "(", "fxmlUrl", "==", "null", ")", "{", "// Try to load the resource from the full path org/jrebirth/core/ui/Test.fxml\r", "fxmlUrl", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResource", "(", "fxmlPath", ")", ";", "}", "return", "fxmlUrl", ";", "}" ]
Convert The url of fxml files to allow local and path loading. @param model the model class that will be used for relative loading @param fxmlPath the path of the fxml file (relative or absolute) @return the FXML file URL @param <M> the model type that will manage this fxml node
[ "Convert", "The", "url", "of", "fxml", "files", "to", "allow", "local", "and", "path", "loading", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/fxml/FXMLUtils.java#L156-L169
8,451
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/SyncRunnable.java
SyncRunnable.waitEnd
public void waitEnd(final long... timeout) { long start = System.currentTimeMillis(); if (timeout.length == 1) { start += timeout[0]; } else { start += DEFAULT_TIME_OUT; } while (!this.hasRun.get()) { try { Thread.sleep(SLEEP_TIME); } catch (final InterruptedException e) { break; } if (System.currentTimeMillis() > start) { break; // Break the loop after 1s to avoid freezing the thread } } }
java
public void waitEnd(final long... timeout) { long start = System.currentTimeMillis(); if (timeout.length == 1) { start += timeout[0]; } else { start += DEFAULT_TIME_OUT; } while (!this.hasRun.get()) { try { Thread.sleep(SLEEP_TIME); } catch (final InterruptedException e) { break; } if (System.currentTimeMillis() > start) { break; // Break the loop after 1s to avoid freezing the thread } } }
[ "public", "void", "waitEnd", "(", "final", "long", "...", "timeout", ")", "{", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "timeout", ".", "length", "==", "1", ")", "{", "start", "+=", "timeout", "[", "0", "]", ";", "}", "else", "{", "start", "+=", "DEFAULT_TIME_OUT", ";", "}", "while", "(", "!", "this", ".", "hasRun", ".", "get", "(", ")", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "SLEEP_TIME", ")", ";", "}", "catch", "(", "final", "InterruptedException", "e", ")", "{", "break", ";", "}", "if", "(", "System", ".", "currentTimeMillis", "(", ")", ">", "start", ")", "{", "break", ";", "// Break the loop after 1s to avoid freezing the thread", "}", "}", "}" ]
Wait the end of the runnable. @param timeout the maximum to wait to avoid to freeze the thread
[ "Wait", "the", "end", "of", "the", "runnable", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/SyncRunnable.java#L65-L85
8,452
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java
ErrorHandler.getMessage
private String getMessage(Object error) { if (error instanceof Throwable) { String message = ((Throwable) error).getMessage(); if (message == null) { if (fullStack) { message = error.getClass().getName(); } } return message; } else if (error instanceof String) { return (String) error; } else if (error instanceof Integer) { return HttpResponseStatus.valueOf((Integer) error).reasonPhrase(); } else if (error instanceof JsonObject) { return ((JsonObject) error).getString("message"); } else if (error instanceof Map) { return (String) ((Map) error).get("message"); } else { return error.toString(); } }
java
private String getMessage(Object error) { if (error instanceof Throwable) { String message = ((Throwable) error).getMessage(); if (message == null) { if (fullStack) { message = error.getClass().getName(); } } return message; } else if (error instanceof String) { return (String) error; } else if (error instanceof Integer) { return HttpResponseStatus.valueOf((Integer) error).reasonPhrase(); } else if (error instanceof JsonObject) { return ((JsonObject) error).getString("message"); } else if (error instanceof Map) { return (String) ((Map) error).get("message"); } else { return error.toString(); } }
[ "private", "String", "getMessage", "(", "Object", "error", ")", "{", "if", "(", "error", "instanceof", "Throwable", ")", "{", "String", "message", "=", "(", "(", "Throwable", ")", "error", ")", ".", "getMessage", "(", ")", ";", "if", "(", "message", "==", "null", ")", "{", "if", "(", "fullStack", ")", "{", "message", "=", "error", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "}", "}", "return", "message", ";", "}", "else", "if", "(", "error", "instanceof", "String", ")", "{", "return", "(", "String", ")", "error", ";", "}", "else", "if", "(", "error", "instanceof", "Integer", ")", "{", "return", "HttpResponseStatus", ".", "valueOf", "(", "(", "Integer", ")", "error", ")", ".", "reasonPhrase", "(", ")", ";", "}", "else", "if", "(", "error", "instanceof", "JsonObject", ")", "{", "return", "(", "(", "JsonObject", ")", "error", ")", ".", "getString", "(", "\"message\"", ")", ";", "}", "else", "if", "(", "error", "instanceof", "Map", ")", "{", "return", "(", "String", ")", "(", "(", "Map", ")", "error", ")", ".", "get", "(", "\"message\"", ")", ";", "}", "else", "{", "return", "error", ".", "toString", "(", ")", ";", "}", "}" ]
Extracts a single message from a error Object. This will handle Throwables, Strings and Numbers. In case of numbers these are handled as Http error codes. @param error Error object @return String representation of the error object.
[ "Extracts", "a", "single", "message", "from", "a", "error", "Object", ".", "This", "will", "handle", "Throwables", "Strings", "and", "Numbers", ".", "In", "case", "of", "numbers", "these", "are", "handled", "as", "Http", "error", "codes", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java#L70-L92
8,453
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java
ErrorHandler.getErrorCode
private int getErrorCode(Object error) { if (error instanceof Number) { return ((Number) error).intValue(); } else if (error instanceof YokeException) { return ((YokeException) error).getErrorCode().intValue(); } else if (error instanceof JsonObject) { return ((JsonObject) error).getInteger("errorCode", 500); } else if (error instanceof Map) { Integer tmp = (Integer) ((Map) error).get("errorCode"); return tmp != null ? tmp : 500; } else { return 500; } }
java
private int getErrorCode(Object error) { if (error instanceof Number) { return ((Number) error).intValue(); } else if (error instanceof YokeException) { return ((YokeException) error).getErrorCode().intValue(); } else if (error instanceof JsonObject) { return ((JsonObject) error).getInteger("errorCode", 500); } else if (error instanceof Map) { Integer tmp = (Integer) ((Map) error).get("errorCode"); return tmp != null ? tmp : 500; } else { return 500; } }
[ "private", "int", "getErrorCode", "(", "Object", "error", ")", "{", "if", "(", "error", "instanceof", "Number", ")", "{", "return", "(", "(", "Number", ")", "error", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "error", "instanceof", "YokeException", ")", "{", "return", "(", "(", "YokeException", ")", "error", ")", ".", "getErrorCode", "(", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "error", "instanceof", "JsonObject", ")", "{", "return", "(", "(", "JsonObject", ")", "error", ")", ".", "getInteger", "(", "\"errorCode\"", ",", "500", ")", ";", "}", "else", "if", "(", "error", "instanceof", "Map", ")", "{", "Integer", "tmp", "=", "(", "Integer", ")", "(", "(", "Map", ")", "error", ")", ".", "get", "(", "\"errorCode\"", ")", ";", "return", "tmp", "!=", "null", "?", "tmp", ":", "500", ";", "}", "else", "{", "return", "500", ";", "}", "}" ]
Extracts a single error code from a error Object. This will handle Throwables, Strings and Numbers. @param error Error object @return HTTP status code for the error object
[ "Extracts", "a", "single", "error", "code", "from", "a", "error", "Object", ".", "This", "will", "handle", "Throwables", "Strings", "and", "Numbers", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java#L100-L113
8,454
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java
ErrorHandler.getStackTrace
private List<String> getStackTrace(Object error) { if (fullStack && error instanceof Throwable) { List<String> stackTrace = new ArrayList<>(); for (StackTraceElement t : ((Throwable) error).getStackTrace()) { stackTrace.add(t.toString()); } return stackTrace; } else { return Collections.emptyList(); } }
java
private List<String> getStackTrace(Object error) { if (fullStack && error instanceof Throwable) { List<String> stackTrace = new ArrayList<>(); for (StackTraceElement t : ((Throwable) error).getStackTrace()) { stackTrace.add(t.toString()); } return stackTrace; } else { return Collections.emptyList(); } }
[ "private", "List", "<", "String", ">", "getStackTrace", "(", "Object", "error", ")", "{", "if", "(", "fullStack", "&&", "error", "instanceof", "Throwable", ")", "{", "List", "<", "String", ">", "stackTrace", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "StackTraceElement", "t", ":", "(", "(", "Throwable", ")", "error", ")", ".", "getStackTrace", "(", ")", ")", "{", "stackTrace", ".", "add", "(", "t", ".", "toString", "(", ")", ")", ";", "}", "return", "stackTrace", ";", "}", "else", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "}" ]
Convert the stack trace to a List in order to be rendered in the error template. @param error error object @return List containing the stack trace for the object
[ "Convert", "the", "stack", "trace", "to", "a", "List", "in", "order", "to", "be", "rendered", "in", "the", "error", "template", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/ErrorHandler.java#L121-L131
8,455
JRebirth/JRebirth
org.jrebirth.af/showcase/data/src/main/java/org/jrebirth/af/showcase/data/ui/listing/CheckerController.java
CheckerController.onMouseClicked
void onMouseClicked(final MouseEvent event) { LOGGER.debug("Start button clicked => Call Comparison Service"); // Clear out the table view model().object().pLastResult().clear(); // Call service to populate it again model().returnData(ComparatorService.class, ComparatorService.DO_COMPARE, WBuilder.waveData(JRebirthWaves.PROGRESS_BAR, view().getProgressBar()), WBuilder.waveData(JRebirthWaves.TASK_TITLE, view().getProgressTitle()), WBuilder.waveData(JRebirthWaves.TASK_MESSAGE, view().getProgressMessage()), WBuilder.waveData(ComparatorService.SOURCE, model().object().sourcePath()), WBuilder.waveData(ComparatorService.TARGET, model().object().targetPath())); }
java
void onMouseClicked(final MouseEvent event) { LOGGER.debug("Start button clicked => Call Comparison Service"); // Clear out the table view model().object().pLastResult().clear(); // Call service to populate it again model().returnData(ComparatorService.class, ComparatorService.DO_COMPARE, WBuilder.waveData(JRebirthWaves.PROGRESS_BAR, view().getProgressBar()), WBuilder.waveData(JRebirthWaves.TASK_TITLE, view().getProgressTitle()), WBuilder.waveData(JRebirthWaves.TASK_MESSAGE, view().getProgressMessage()), WBuilder.waveData(ComparatorService.SOURCE, model().object().sourcePath()), WBuilder.waveData(ComparatorService.TARGET, model().object().targetPath())); }
[ "void", "onMouseClicked", "(", "final", "MouseEvent", "event", ")", "{", "LOGGER", ".", "debug", "(", "\"Start button clicked => Call Comparison Service\"", ")", ";", "// Clear out the table view", "model", "(", ")", ".", "object", "(", ")", ".", "pLastResult", "(", ")", ".", "clear", "(", ")", ";", "// Call service to populate it again", "model", "(", ")", ".", "returnData", "(", "ComparatorService", ".", "class", ",", "ComparatorService", ".", "DO_COMPARE", ",", "WBuilder", ".", "waveData", "(", "JRebirthWaves", ".", "PROGRESS_BAR", ",", "view", "(", ")", ".", "getProgressBar", "(", ")", ")", ",", "WBuilder", ".", "waveData", "(", "JRebirthWaves", ".", "TASK_TITLE", ",", "view", "(", ")", ".", "getProgressTitle", "(", ")", ")", ",", "WBuilder", ".", "waveData", "(", "JRebirthWaves", ".", "TASK_MESSAGE", ",", "view", "(", ")", ".", "getProgressMessage", "(", ")", ")", ",", "WBuilder", ".", "waveData", "(", "ComparatorService", ".", "SOURCE", ",", "model", "(", ")", ".", "object", "(", ")", ".", "sourcePath", "(", ")", ")", ",", "WBuilder", ".", "waveData", "(", "ComparatorService", ".", "TARGET", ",", "model", "(", ")", ".", "object", "(", ")", ".", "targetPath", "(", ")", ")", ")", ";", "}" ]
Manage Mouse click of widget that have annotation. @param event the mouse event
[ "Manage", "Mouse", "click", "of", "widget", "that", "have", "annotation", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/data/src/main/java/org/jrebirth/af/showcase/data/ui/listing/CheckerController.java#L63-L79
8,456
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/log/LogbackAdapter.java
LogbackAdapter.convertLevel
private int convertLevel(final JRLevel level) { int logbackLevel = 0; switch (level) { case Trace: logbackLevel = LocationAwareLogger.TRACE_INT; break; case Debug: logbackLevel = LocationAwareLogger.DEBUG_INT; break; case Warn: logbackLevel = LocationAwareLogger.WARN_INT; break; case Error: logbackLevel = LocationAwareLogger.ERROR_INT; break; case Info: logbackLevel = LocationAwareLogger.INFO_INT; break; default: break; } return logbackLevel; }
java
private int convertLevel(final JRLevel level) { int logbackLevel = 0; switch (level) { case Trace: logbackLevel = LocationAwareLogger.TRACE_INT; break; case Debug: logbackLevel = LocationAwareLogger.DEBUG_INT; break; case Warn: logbackLevel = LocationAwareLogger.WARN_INT; break; case Error: logbackLevel = LocationAwareLogger.ERROR_INT; break; case Info: logbackLevel = LocationAwareLogger.INFO_INT; break; default: break; } return logbackLevel; }
[ "private", "int", "convertLevel", "(", "final", "JRLevel", "level", ")", "{", "int", "logbackLevel", "=", "0", ";", "switch", "(", "level", ")", "{", "case", "Trace", ":", "logbackLevel", "=", "LocationAwareLogger", ".", "TRACE_INT", ";", "break", ";", "case", "Debug", ":", "logbackLevel", "=", "LocationAwareLogger", ".", "DEBUG_INT", ";", "break", ";", "case", "Warn", ":", "logbackLevel", "=", "LocationAwareLogger", ".", "WARN_INT", ";", "break", ";", "case", "Error", ":", "logbackLevel", "=", "LocationAwareLogger", ".", "ERROR_INT", ";", "break", ";", "case", "Info", ":", "logbackLevel", "=", "LocationAwareLogger", ".", "INFO_INT", ";", "break", ";", "default", ":", "break", ";", "}", "return", "logbackLevel", ";", "}" ]
Convert JRebirth LogLevel to Logback one. @param level the JRebirth log level to convert @return the logback log level
[ "Convert", "JRebirth", "LogLevel", "to", "Logback", "one", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/log/LogbackAdapter.java#L62-L84
8,457
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java
ServiceTaskBase.getServiceHandlerName
@Override public String getServiceHandlerName() { final StringBuilder sb = new StringBuilder(); sb.append(this.service.getClass().getSimpleName()).append("."); sb.append(this.method.getName()).append("("); for (final Class<?> parameterType : this.method.getParameterTypes()) { sb.append(parameterType.getSimpleName()).append(", "); } sb.append(")"); return sb.toString(); }
java
@Override public String getServiceHandlerName() { final StringBuilder sb = new StringBuilder(); sb.append(this.service.getClass().getSimpleName()).append("."); sb.append(this.method.getName()).append("("); for (final Class<?> parameterType : this.method.getParameterTypes()) { sb.append(parameterType.getSimpleName()).append(", "); } sb.append(")"); return sb.toString(); }
[ "@", "Override", "public", "String", "getServiceHandlerName", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "this", ".", "service", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "\".\"", ")", ";", "sb", ".", "append", "(", "this", ".", "method", ".", "getName", "(", ")", ")", ".", "append", "(", "\"(\"", ")", ";", "for", "(", "final", "Class", "<", "?", ">", "parameterType", ":", "this", ".", "method", ".", "getParameterTypes", "(", ")", ")", "{", "sb", ".", "append", "(", "parameterType", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Return the full service handler name. <ServiceName>.<method> ( <parameter type1>, <parameter type2>...., <parameter typeN> ) @return the full service handler name
[ "Return", "the", "full", "service", "handler", "name", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java#L124-L134
8,458
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java
ServiceTaskBase.handleException
private void handleException(final Throwable e) { if (e instanceof ServiceException) { final ServiceException se = (ServiceException) e; // Only log with warn level to let the application continue its workflow even in developer mode LOGGER.log(SERVICE_TASK_EXCEPTION, se, se.getExplanation(), getServiceHandlerName()); } else { // In developer mode it will stop the application throwing another exception LOGGER.log(SERVICE_TASK_ERROR, e, getServiceHandlerName()); } this.wave.status(Status.Failed); final Class<? extends Throwable> managedException = e instanceof ServiceException ? e.getCause().getClass() : e.getClass(); // Get the exact exception type final Wave exceptionHandlerWave = this.wave.waveType().waveExceptionHandler().get(managedException); if (exceptionHandlerWave != null) { // Fill the wave with useful data exceptionHandlerWave.fromClass(this.service.getClass()) .add(JRebirthItems.exceptionItem, e) .add(JRebirthItems.waveItem, this.wave) .relatedWave(this.wave); LOGGER.log(SERVICE_TASK_HANDLE_EXCEPTION, e, e.getClass().getSimpleName(), getServiceHandlerName()); // Send the exception wave to interested components this.service.sendWave(exceptionHandlerWave); } else { LOGGER.log(SERVICE_TASK_NOT_MANAGED_EXCEPTION, e, e.getClass().getSimpleName(), getServiceHandlerName()); } }
java
private void handleException(final Throwable e) { if (e instanceof ServiceException) { final ServiceException se = (ServiceException) e; // Only log with warn level to let the application continue its workflow even in developer mode LOGGER.log(SERVICE_TASK_EXCEPTION, se, se.getExplanation(), getServiceHandlerName()); } else { // In developer mode it will stop the application throwing another exception LOGGER.log(SERVICE_TASK_ERROR, e, getServiceHandlerName()); } this.wave.status(Status.Failed); final Class<? extends Throwable> managedException = e instanceof ServiceException ? e.getCause().getClass() : e.getClass(); // Get the exact exception type final Wave exceptionHandlerWave = this.wave.waveType().waveExceptionHandler().get(managedException); if (exceptionHandlerWave != null) { // Fill the wave with useful data exceptionHandlerWave.fromClass(this.service.getClass()) .add(JRebirthItems.exceptionItem, e) .add(JRebirthItems.waveItem, this.wave) .relatedWave(this.wave); LOGGER.log(SERVICE_TASK_HANDLE_EXCEPTION, e, e.getClass().getSimpleName(), getServiceHandlerName()); // Send the exception wave to interested components this.service.sendWave(exceptionHandlerWave); } else { LOGGER.log(SERVICE_TASK_NOT_MANAGED_EXCEPTION, e, e.getClass().getSimpleName(), getServiceHandlerName()); } }
[ "private", "void", "handleException", "(", "final", "Throwable", "e", ")", "{", "if", "(", "e", "instanceof", "ServiceException", ")", "{", "final", "ServiceException", "se", "=", "(", "ServiceException", ")", "e", ";", "// Only log with warn level to let the application continue its workflow even in developer mode", "LOGGER", ".", "log", "(", "SERVICE_TASK_EXCEPTION", ",", "se", ",", "se", ".", "getExplanation", "(", ")", ",", "getServiceHandlerName", "(", ")", ")", ";", "}", "else", "{", "// In developer mode it will stop the application throwing another exception", "LOGGER", ".", "log", "(", "SERVICE_TASK_ERROR", ",", "e", ",", "getServiceHandlerName", "(", ")", ")", ";", "}", "this", ".", "wave", ".", "status", "(", "Status", ".", "Failed", ")", ";", "final", "Class", "<", "?", "extends", "Throwable", ">", "managedException", "=", "e", "instanceof", "ServiceException", "?", "e", ".", "getCause", "(", ")", ".", "getClass", "(", ")", ":", "e", ".", "getClass", "(", ")", ";", "// Get the exact exception type", "final", "Wave", "exceptionHandlerWave", "=", "this", ".", "wave", ".", "waveType", "(", ")", ".", "waveExceptionHandler", "(", ")", ".", "get", "(", "managedException", ")", ";", "if", "(", "exceptionHandlerWave", "!=", "null", ")", "{", "// Fill the wave with useful data", "exceptionHandlerWave", ".", "fromClass", "(", "this", ".", "service", ".", "getClass", "(", ")", ")", ".", "add", "(", "JRebirthItems", ".", "exceptionItem", ",", "e", ")", ".", "add", "(", "JRebirthItems", ".", "waveItem", ",", "this", ".", "wave", ")", ".", "relatedWave", "(", "this", ".", "wave", ")", ";", "LOGGER", ".", "log", "(", "SERVICE_TASK_HANDLE_EXCEPTION", ",", "e", ",", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "getServiceHandlerName", "(", ")", ")", ";", "// Send the exception wave to interested components", "this", ".", "service", ".", "sendWave", "(", "exceptionHandlerWave", ")", ";", "}", "else", "{", "LOGGER", ".", "log", "(", "SERVICE_TASK_NOT_MANAGED_EXCEPTION", ",", "e", ",", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "getServiceHandlerName", "(", ")", ")", ";", "}", "}" ]
Handle all exception occurred while doing the task. @param e the exception to handle
[ "Handle", "all", "exception", "occurred", "while", "doing", "the", "task", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java#L196-L228
8,459
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java
ServiceTaskBase.sendReturnWave
@SuppressWarnings("unchecked") private void sendReturnWave(final T res) throws CoreException { Wave returnWave = null; // Try to retrieve the return Wave type, could be null final WaveType responseWaveType = this.wave.waveType().returnWaveType(); final Class<? extends Command> responseCommandClass = this.wave.waveType().returnCommandClass(); if (responseWaveType != null) { final WaveItemBase<T> resultWaveItem; // No service result type defined into a WaveItem if (responseWaveType != JRebirthWaves.RETURN_VOID_WT && responseWaveType.items().isEmpty()) { LOGGER.log(NO_RETURNED_WAVE_ITEM); throw new CoreException(NO_RETURNED_WAVE_ITEM); } else { // Get the first (and unique) WaveItem used to define the service result type resultWaveItem = (WaveItemBase<T>) responseWaveType.items().get(0); } // Try to retrieve the command class, could be null // final Class<? extends Command> responseCommandClass = this.service.getReturnCommand(this.wave.waveType()); if (responseCommandClass != null) { // If a Command Class is provided, call it with the right WaveItem to get the real result type returnWave = WBuilder.wave() .waveGroup(WaveGroup.CALL_COMMAND) .fromClass(this.service.getClass()) .componentClass(responseCommandClass); } else { // Otherwise send a generic wave that can be handled by any component returnWave = WBuilder.wave() .waveType(responseWaveType) .fromClass(this.service.getClass()); } // Add the result wrapped into a WaveData with the right WaveItem if (resultWaveItem != null) { returnWave.addDatas(WBuilder.waveData(resultWaveItem, res)); } // Don't add data when method has returned VOID returnWave.relatedWave(this.wave); returnWave.addWaveListener(new RelatedWaveListener()); // Send the return wave to interested components this.service.sendWave(returnWave); } else { // No service return wave Type defined LOGGER.log(NO_RETURNED_WAVE_TYPE_DEFINED, this.wave.waveType()); throw new CoreException(NO_RETURNED_WAVE_ITEM, this.wave.waveType()); } }
java
@SuppressWarnings("unchecked") private void sendReturnWave(final T res) throws CoreException { Wave returnWave = null; // Try to retrieve the return Wave type, could be null final WaveType responseWaveType = this.wave.waveType().returnWaveType(); final Class<? extends Command> responseCommandClass = this.wave.waveType().returnCommandClass(); if (responseWaveType != null) { final WaveItemBase<T> resultWaveItem; // No service result type defined into a WaveItem if (responseWaveType != JRebirthWaves.RETURN_VOID_WT && responseWaveType.items().isEmpty()) { LOGGER.log(NO_RETURNED_WAVE_ITEM); throw new CoreException(NO_RETURNED_WAVE_ITEM); } else { // Get the first (and unique) WaveItem used to define the service result type resultWaveItem = (WaveItemBase<T>) responseWaveType.items().get(0); } // Try to retrieve the command class, could be null // final Class<? extends Command> responseCommandClass = this.service.getReturnCommand(this.wave.waveType()); if (responseCommandClass != null) { // If a Command Class is provided, call it with the right WaveItem to get the real result type returnWave = WBuilder.wave() .waveGroup(WaveGroup.CALL_COMMAND) .fromClass(this.service.getClass()) .componentClass(responseCommandClass); } else { // Otherwise send a generic wave that can be handled by any component returnWave = WBuilder.wave() .waveType(responseWaveType) .fromClass(this.service.getClass()); } // Add the result wrapped into a WaveData with the right WaveItem if (resultWaveItem != null) { returnWave.addDatas(WBuilder.waveData(resultWaveItem, res)); } // Don't add data when method has returned VOID returnWave.relatedWave(this.wave); returnWave.addWaveListener(new RelatedWaveListener()); // Send the return wave to interested components this.service.sendWave(returnWave); } else { // No service return wave Type defined LOGGER.log(NO_RETURNED_WAVE_TYPE_DEFINED, this.wave.waveType()); throw new CoreException(NO_RETURNED_WAVE_ITEM, this.wave.waveType()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "sendReturnWave", "(", "final", "T", "res", ")", "throws", "CoreException", "{", "Wave", "returnWave", "=", "null", ";", "// Try to retrieve the return Wave type, could be null", "final", "WaveType", "responseWaveType", "=", "this", ".", "wave", ".", "waveType", "(", ")", ".", "returnWaveType", "(", ")", ";", "final", "Class", "<", "?", "extends", "Command", ">", "responseCommandClass", "=", "this", ".", "wave", ".", "waveType", "(", ")", ".", "returnCommandClass", "(", ")", ";", "if", "(", "responseWaveType", "!=", "null", ")", "{", "final", "WaveItemBase", "<", "T", ">", "resultWaveItem", ";", "// No service result type defined into a WaveItem", "if", "(", "responseWaveType", "!=", "JRebirthWaves", ".", "RETURN_VOID_WT", "&&", "responseWaveType", ".", "items", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "LOGGER", ".", "log", "(", "NO_RETURNED_WAVE_ITEM", ")", ";", "throw", "new", "CoreException", "(", "NO_RETURNED_WAVE_ITEM", ")", ";", "}", "else", "{", "// Get the first (and unique) WaveItem used to define the service result type", "resultWaveItem", "=", "(", "WaveItemBase", "<", "T", ">", ")", "responseWaveType", ".", "items", "(", ")", ".", "get", "(", "0", ")", ";", "}", "// Try to retrieve the command class, could be null", "// final Class<? extends Command> responseCommandClass = this.service.getReturnCommand(this.wave.waveType());", "if", "(", "responseCommandClass", "!=", "null", ")", "{", "// If a Command Class is provided, call it with the right WaveItem to get the real result type", "returnWave", "=", "WBuilder", ".", "wave", "(", ")", ".", "waveGroup", "(", "WaveGroup", ".", "CALL_COMMAND", ")", ".", "fromClass", "(", "this", ".", "service", ".", "getClass", "(", ")", ")", ".", "componentClass", "(", "responseCommandClass", ")", ";", "}", "else", "{", "// Otherwise send a generic wave that can be handled by any component", "returnWave", "=", "WBuilder", ".", "wave", "(", ")", ".", "waveType", "(", "responseWaveType", ")", ".", "fromClass", "(", "this", ".", "service", ".", "getClass", "(", ")", ")", ";", "}", "// Add the result wrapped into a WaveData with the right WaveItem", "if", "(", "resultWaveItem", "!=", "null", ")", "{", "returnWave", ".", "addDatas", "(", "WBuilder", ".", "waveData", "(", "resultWaveItem", ",", "res", ")", ")", ";", "}", "// Don't add data when method has returned VOID", "returnWave", ".", "relatedWave", "(", "this", ".", "wave", ")", ";", "returnWave", ".", "addWaveListener", "(", "new", "RelatedWaveListener", "(", ")", ")", ";", "// Send the return wave to interested components", "this", ".", "service", ".", "sendWave", "(", "returnWave", ")", ";", "}", "else", "{", "// No service return wave Type defined", "LOGGER", ".", "log", "(", "NO_RETURNED_WAVE_TYPE_DEFINED", ",", "this", ".", "wave", ".", "waveType", "(", ")", ")", ";", "throw", "new", "CoreException", "(", "NO_RETURNED_WAVE_ITEM", ",", "this", ".", "wave", ".", "waveType", "(", ")", ")", ";", "}", "}" ]
Send a wave that will carry the service result. 2 Kinds of wave can be sent according to service configuration @param res the service result @throws CoreException if the wave generation has failed
[ "Send", "a", "wave", "that", "will", "carry", "the", "service", "result", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java#L239-L297
8,460
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java
ServiceTaskBase.checkProgressRatio
@Override public boolean checkProgressRatio(final double newWorkDone, final double totalWork, final double amountThreshold) { double currentRatio; synchronized (this) { // Compute the actual progression currentRatio = this.localWorkDone >= 0 ? 100 * this.localWorkDone / totalWork : 0.0; } // Compute the future progression final double newRatio = 100 * newWorkDone / totalWork; // return true if the task has progressed of at least block increment value return newRatio - currentRatio > amountThreshold; }
java
@Override public boolean checkProgressRatio(final double newWorkDone, final double totalWork, final double amountThreshold) { double currentRatio; synchronized (this) { // Compute the actual progression currentRatio = this.localWorkDone >= 0 ? 100 * this.localWorkDone / totalWork : 0.0; } // Compute the future progression final double newRatio = 100 * newWorkDone / totalWork; // return true if the task has progressed of at least block increment value return newRatio - currentRatio > amountThreshold; }
[ "@", "Override", "public", "boolean", "checkProgressRatio", "(", "final", "double", "newWorkDone", ",", "final", "double", "totalWork", ",", "final", "double", "amountThreshold", ")", "{", "double", "currentRatio", ";", "synchronized", "(", "this", ")", "{", "// Compute the actual progression", "currentRatio", "=", "this", ".", "localWorkDone", ">=", "0", "?", "100", "*", "this", ".", "localWorkDone", "/", "totalWork", ":", "0.0", ";", "}", "// Compute the future progression", "final", "double", "newRatio", "=", "100", "*", "newWorkDone", "/", "totalWork", ";", "// return true if the task has progressed of at least block increment value", "return", "newRatio", "-", "currentRatio", ">", "amountThreshold", ";", "}" ]
Check if the task has enough progressed according to the given threshold. This method can be called outside the JAT, it's useful to filter useless call to JAT @param newWorkDone the amount of work done @param totalWork the total amount of work @param amountThreshold the minimum threshold amount to return true; range is [0.0 - 100.0] (typically 1.0 for 1%) @return true if the threshold is reached
[ "Check", "if", "the", "task", "has", "enough", "progressed", "according", "to", "the", "given", "threshold", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/ServiceTaskBase.java#L367-L381
8,461
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeResponse.java
YokeResponse.getHeader
@SuppressWarnings("unchecked") public <R> R getHeader(String name) { return (R) headers().get(name); }
java
@SuppressWarnings("unchecked") public <R> R getHeader(String name) { return (R) headers().get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "R", ">", "R", "getHeader", "(", "String", "name", ")", "{", "return", "(", "R", ")", "headers", "(", ")", ".", "get", "(", "name", ")", ";", "}" ]
Allow getting headers in a generified way. @param name The key to get @param <R> The type of the return @return The found object
[ "Allow", "getting", "headers", "in", "a", "generified", "way", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeResponse.java#L141-L144
8,462
amigold/FunDapter
library/src/com/ami/fundapter/FunDapter.java
FunDapter.initFilter
public void initFilter(FunDapterFilter<T> filter) { if (filter == null) throw new IllegalArgumentException("Cannot pass a null filter to FunDapter"); this.funDapterFilter = filter; mFilter = new Filter() { @Override protected void publishResults(CharSequence constraint, FilterResults results) { @SuppressWarnings("unchecked") List<T> list = (List<T>) results.values; if (results.count == 0) { resetData(); } else { mDataItems = list; } notifyDataSetChanged(); } @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); if (constraint == null || constraint.length() == 0) { // No constraint - no point in filtering. results.values = mOrigDataItems; results.count = mOrigDataItems.size(); } else { // Perform the filtering operation List<T> filter = funDapterFilter.filter(constraint.toString(), mOrigDataItems); results.count = filter.size(); results.values = filter; } return results; } }; }
java
public void initFilter(FunDapterFilter<T> filter) { if (filter == null) throw new IllegalArgumentException("Cannot pass a null filter to FunDapter"); this.funDapterFilter = filter; mFilter = new Filter() { @Override protected void publishResults(CharSequence constraint, FilterResults results) { @SuppressWarnings("unchecked") List<T> list = (List<T>) results.values; if (results.count == 0) { resetData(); } else { mDataItems = list; } notifyDataSetChanged(); } @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); if (constraint == null || constraint.length() == 0) { // No constraint - no point in filtering. results.values = mOrigDataItems; results.count = mOrigDataItems.size(); } else { // Perform the filtering operation List<T> filter = funDapterFilter.filter(constraint.toString(), mOrigDataItems); results.count = filter.size(); results.values = filter; } return results; } }; }
[ "public", "void", "initFilter", "(", "FunDapterFilter", "<", "T", ">", "filter", ")", "{", "if", "(", "filter", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot pass a null filter to FunDapter\"", ")", ";", "this", ".", "funDapterFilter", "=", "filter", ";", "mFilter", "=", "new", "Filter", "(", ")", "{", "@", "Override", "protected", "void", "publishResults", "(", "CharSequence", "constraint", ",", "FilterResults", "results", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "T", ">", "list", "=", "(", "List", "<", "T", ">", ")", "results", ".", "values", ";", "if", "(", "results", ".", "count", "==", "0", ")", "{", "resetData", "(", ")", ";", "}", "else", "{", "mDataItems", "=", "list", ";", "}", "notifyDataSetChanged", "(", ")", ";", "}", "@", "Override", "protected", "FilterResults", "performFiltering", "(", "CharSequence", "constraint", ")", "{", "FilterResults", "results", "=", "new", "FilterResults", "(", ")", ";", "if", "(", "constraint", "==", "null", "||", "constraint", ".", "length", "(", ")", "==", "0", ")", "{", "// No constraint - no point in filtering.", "results", ".", "values", "=", "mOrigDataItems", ";", "results", ".", "count", "=", "mOrigDataItems", ".", "size", "(", ")", ";", "}", "else", "{", "// Perform the filtering operation", "List", "<", "T", ">", "filter", "=", "funDapterFilter", ".", "filter", "(", "constraint", ".", "toString", "(", ")", ",", "mOrigDataItems", ")", ";", "results", ".", "count", "=", "filter", ".", "size", "(", ")", ";", "results", ".", "values", "=", "filter", ";", "}", "return", "results", ";", "}", "}", ";", "}" ]
Use this method to enable filtering in the adapter. @param filter - a filter implementation for your adapter.
[ "Use", "this", "method", "to", "enable", "filtering", "in", "the", "adapter", "." ]
fb33241f265901d73276608689077d4310278eaf
https://github.com/amigold/FunDapter/blob/fb33241f265901d73276608689077d4310278eaf/library/src/com/ami/fundapter/FunDapter.java#L182-L228
8,463
JRebirth/JRebirth
org.jrebirth.af/component/src/main/java/org/jrebirth/af/component/ui/tab/TabbedPaneModel.java
TabbedPaneModel.doInsertTab
public void doInsertTab(int idx, final Dockable tab, final Wave wave) { // final TabBB<M> t = TabBB.create() // //.name(model.modelName()) // .modelKey(model.getKey()); // Tab t = model.getBehaviorBean(TabBehavior.class); if (idx < 0) { idx = object().tabs().isEmpty() ? 0 : object().tabs().size(); } // view().addTab(idx, tab); object().tabs().add(idx, tab); }
java
public void doInsertTab(int idx, final Dockable tab, final Wave wave) { // final TabBB<M> t = TabBB.create() // //.name(model.modelName()) // .modelKey(model.getKey()); // Tab t = model.getBehaviorBean(TabBehavior.class); if (idx < 0) { idx = object().tabs().isEmpty() ? 0 : object().tabs().size(); } // view().addTab(idx, tab); object().tabs().add(idx, tab); }
[ "public", "void", "doInsertTab", "(", "int", "idx", ",", "final", "Dockable", "tab", ",", "final", "Wave", "wave", ")", "{", "// final TabBB<M> t = TabBB.create()", "// //.name(model.modelName())", "// .modelKey(model.getKey());", "// Tab t = model.getBehaviorBean(TabBehavior.class);", "if", "(", "idx", "<", "0", ")", "{", "idx", "=", "object", "(", ")", ".", "tabs", "(", ")", ".", "isEmpty", "(", ")", "?", "0", ":", "object", "(", ")", ".", "tabs", "(", ")", ".", "size", "(", ")", ";", "}", "// view().addTab(idx, tab);", "object", "(", ")", ".", "tabs", "(", ")", ".", "add", "(", "idx", ",", "tab", ")", ";", "}" ]
Insert tab. @param idx the idx @param tab the tab @param wave the wave
[ "Insert", "tab", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/component/src/main/java/org/jrebirth/af/component/ui/tab/TabbedPaneModel.java#L180-L194
8,464
JRebirth/JRebirth
org.jrebirth.af/preloader/src/main/java/org/jrebirth/af/preloader/AbstractJRebirthPreloader.java
AbstractJRebirthPreloader.getMessageFromCode
private String getMessageFromCode(final int messageCode) { String res = ""; switch (messageCode) { case 100: res = "Initializing"; break; case 200: res = "";// Provisioned for custom pre-init task break; case 300: res = "";// Provisioned for custom pre-init task break; case 400: res = "Loading Messages Properties"; break; case 500: res = "Loading Parameters Properties"; break; case 600: res = "Preparing Core Engine"; break; case 700: res = "Preloading Resources"; break; case 800: res = "Preloading Modules"; break; case 900: res = "";// Provisioned for custom post-init task break; case 1000: res = "Starting"; break; default: } return res; }
java
private String getMessageFromCode(final int messageCode) { String res = ""; switch (messageCode) { case 100: res = "Initializing"; break; case 200: res = "";// Provisioned for custom pre-init task break; case 300: res = "";// Provisioned for custom pre-init task break; case 400: res = "Loading Messages Properties"; break; case 500: res = "Loading Parameters Properties"; break; case 600: res = "Preparing Core Engine"; break; case 700: res = "Preloading Resources"; break; case 800: res = "Preloading Modules"; break; case 900: res = "";// Provisioned for custom post-init task break; case 1000: res = "Starting"; break; default: } return res; }
[ "private", "String", "getMessageFromCode", "(", "final", "int", "messageCode", ")", "{", "String", "res", "=", "\"\"", ";", "switch", "(", "messageCode", ")", "{", "case", "100", ":", "res", "=", "\"Initializing\"", ";", "break", ";", "case", "200", ":", "res", "=", "\"\"", ";", "// Provisioned for custom pre-init task\r", "break", ";", "case", "300", ":", "res", "=", "\"\"", ";", "// Provisioned for custom pre-init task\r", "break", ";", "case", "400", ":", "res", "=", "\"Loading Messages Properties\"", ";", "break", ";", "case", "500", ":", "res", "=", "\"Loading Parameters Properties\"", ";", "break", ";", "case", "600", ":", "res", "=", "\"Preparing Core Engine\"", ";", "break", ";", "case", "700", ":", "res", "=", "\"Preloading Resources\"", ";", "break", ";", "case", "800", ":", "res", "=", "\"Preloading Modules\"", ";", "break", ";", "case", "900", ":", "res", "=", "\"\"", ";", "// Provisioned for custom post-init task\r", "break", ";", "case", "1000", ":", "res", "=", "\"Starting\"", ";", "break", ";", "default", ":", "}", "return", "res", ";", "}" ]
Gets the message from code. @param messageCode the message code @return the message from code
[ "Gets", "the", "message", "from", "code", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/preloader/src/main/java/org/jrebirth/af/preloader/AbstractJRebirthPreloader.java#L48-L84
8,465
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/log/AbstractLogAdapter.java
AbstractLogAdapter.throwError
protected void throwError(final MessageItem messageItem, final Throwable t, final Object... parameters) { if (messageItem.getLevel() == JRLevel.Exception || messageItem.getLevel() == JRLevel.Error && CoreParameters.DEVELOPER_MODE.get()) { throw new CoreRuntimeException(messageItem, t, parameters); } }
java
protected void throwError(final MessageItem messageItem, final Throwable t, final Object... parameters) { if (messageItem.getLevel() == JRLevel.Exception || messageItem.getLevel() == JRLevel.Error && CoreParameters.DEVELOPER_MODE.get()) { throw new CoreRuntimeException(messageItem, t, parameters); } }
[ "protected", "void", "throwError", "(", "final", "MessageItem", "messageItem", ",", "final", "Throwable", "t", ",", "final", "Object", "...", "parameters", ")", "{", "if", "(", "messageItem", ".", "getLevel", "(", ")", "==", "JRLevel", ".", "Exception", "||", "messageItem", ".", "getLevel", "(", ")", "==", "JRLevel", ".", "Error", "&&", "CoreParameters", ".", "DEVELOPER_MODE", ".", "get", "(", ")", ")", "{", "throw", "new", "CoreRuntimeException", "(", "messageItem", ",", "t", ",", "parameters", ")", ";", "}", "}" ]
If an error is logged when running in Developer Mode, Throw a Runtime Exception. When an exception is logged and when an error is logged and we are running in Developer Mode @param messageItem the message to display for the exception thrown @param t the throwable source (could be null) @param parameters the message parameters
[ "If", "an", "error", "is", "logged", "when", "running", "in", "Developer", "Mode", "Throw", "a", "Runtime", "Exception", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/log/AbstractLogAdapter.java#L46-L51
8,466
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java
AbstractBaseCommand.innerRun
final void innerRun(final Wave wave) throws CommandException { beforePerform(wave); perform(wave); afterPerform(wave); }
java
final void innerRun(final Wave wave) throws CommandException { beforePerform(wave); perform(wave); afterPerform(wave); }
[ "final", "void", "innerRun", "(", "final", "Wave", "wave", ")", "throws", "CommandException", "{", "beforePerform", "(", "wave", ")", ";", "perform", "(", "wave", ")", ";", "afterPerform", "(", "wave", ")", ";", "}" ]
Run the inner task. @param wave the wave that have triggered this command @throws CommandException if an error occurred
[ "Run", "the", "inner", "task", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java#L203-L207
8,467
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java
AbstractBaseCommand.fireConsumed
protected void fireConsumed(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " consumes " + wave.toString()); wave.status(Wave.Status.Consumed); }
java
protected void fireConsumed(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " consumes " + wave.toString()); wave.status(Wave.Status.Consumed); }
[ "protected", "void", "fireConsumed", "(", "final", "Wave", "wave", ")", "{", "LOGGER", ".", "trace", "(", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" consumes \"", "+", "wave", ".", "toString", "(", ")", ")", ";", "wave", ".", "status", "(", "Wave", ".", "Status", ".", "Consumed", ")", ";", "}" ]
Fire a consumed event for command listeners. And consume the wave that trigger this command @param wave forward the wave that has been performed
[ "Fire", "a", "consumed", "event", "for", "command", "listeners", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java#L283-L286
8,468
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java
AbstractBaseCommand.fireHandled
protected void fireHandled(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " handles " + wave.toString()); wave.status(Wave.Status.Handled); }
java
protected void fireHandled(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " handles " + wave.toString()); wave.status(Wave.Status.Handled); }
[ "protected", "void", "fireHandled", "(", "final", "Wave", "wave", ")", "{", "LOGGER", ".", "trace", "(", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" handles \"", "+", "wave", ".", "toString", "(", ")", ")", ";", "wave", ".", "status", "(", "Wave", ".", "Status", ".", "Handled", ")", ";", "}" ]
Fire an handled event for command listeners. And handle the wave that trigger this command @param wave forward the wave that has been performed
[ "Fire", "an", "handled", "event", "for", "command", "listeners", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java#L295-L298
8,469
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java
AbstractBaseCommand.fireFailed
protected void fireFailed(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " has failed " + wave.toString()); wave.status(Wave.Status.Failed); }
java
protected void fireFailed(final Wave wave) { LOGGER.trace(this.getClass().getSimpleName() + " has failed " + wave.toString()); wave.status(Wave.Status.Failed); }
[ "protected", "void", "fireFailed", "(", "final", "Wave", "wave", ")", "{", "LOGGER", ".", "trace", "(", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" has failed \"", "+", "wave", ".", "toString", "(", ")", ")", ";", "wave", ".", "status", "(", "Wave", ".", "Status", ".", "Failed", ")", ";", "}" ]
Fire a failed event for command listeners. And mark as failed the wave that trigger this command @param wave forward the wave that has been performed
[ "Fire", "a", "failed", "event", "for", "command", "listeners", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/command/AbstractBaseCommand.java#L307-L310
8,470
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java
Static.writeHeaders
private void writeHeaders(final YokeRequest request, final FileProps props) { MultiMap headers = request.response().headers(); if (!headers.contains("etag")) { headers.set("etag", "\"" + props.size() + "-" + props.lastModifiedTime() + "\""); } if (!headers.contains("date")) { headers.set("date", format(new Date())); } if (!headers.contains("cache-control")) { headers.set("cache-control", "public, max-age=" + maxAge / 1000); } if (!headers.contains("last-modified")) { headers.set("last-modified", format(new Date(props.lastModifiedTime()))); } }
java
private void writeHeaders(final YokeRequest request, final FileProps props) { MultiMap headers = request.response().headers(); if (!headers.contains("etag")) { headers.set("etag", "\"" + props.size() + "-" + props.lastModifiedTime() + "\""); } if (!headers.contains("date")) { headers.set("date", format(new Date())); } if (!headers.contains("cache-control")) { headers.set("cache-control", "public, max-age=" + maxAge / 1000); } if (!headers.contains("last-modified")) { headers.set("last-modified", format(new Date(props.lastModifiedTime()))); } }
[ "private", "void", "writeHeaders", "(", "final", "YokeRequest", "request", ",", "final", "FileProps", "props", ")", "{", "MultiMap", "headers", "=", "request", ".", "response", "(", ")", ".", "headers", "(", ")", ";", "if", "(", "!", "headers", ".", "contains", "(", "\"etag\"", ")", ")", "{", "headers", ".", "set", "(", "\"etag\"", ",", "\"\\\"\"", "+", "props", ".", "size", "(", ")", "+", "\"-\"", "+", "props", ".", "lastModifiedTime", "(", ")", "+", "\"\\\"\"", ")", ";", "}", "if", "(", "!", "headers", ".", "contains", "(", "\"date\"", ")", ")", "{", "headers", ".", "set", "(", "\"date\"", ",", "format", "(", "new", "Date", "(", ")", ")", ")", ";", "}", "if", "(", "!", "headers", ".", "contains", "(", "\"cache-control\"", ")", ")", "{", "headers", ".", "set", "(", "\"cache-control\"", ",", "\"public, max-age=\"", "+", "maxAge", "/", "1000", ")", ";", "}", "if", "(", "!", "headers", ".", "contains", "(", "\"last-modified\"", ")", ")", "{", "headers", ".", "set", "(", "\"last-modified\"", ",", "format", "(", "new", "Date", "(", "props", ".", "lastModifiedTime", "(", ")", ")", ")", ")", ";", "}", "}" ]
Create all required header so content can be cache by Caching servers or Browsers @param request @param props
[ "Create", "all", "required", "header", "so", "content", "can", "be", "cache", "by", "Caching", "servers", "or", "Browsers" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java#L125-L144
8,471
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java
Static.sendFile
private void sendFile(final YokeRequest request, final String file, final FileProps props) { // write content type String contentType = MimeType.getMime(file); String charset = MimeType.getCharset(contentType); request.response().setContentType(contentType, charset); request.response().putHeader("Content-Length", Long.toString(props.size())); // head support if (HttpMethod.HEAD.equals(request.method())) { request.response().end(); } else { request.response().sendFile(file); } }
java
private void sendFile(final YokeRequest request, final String file, final FileProps props) { // write content type String contentType = MimeType.getMime(file); String charset = MimeType.getCharset(contentType); request.response().setContentType(contentType, charset); request.response().putHeader("Content-Length", Long.toString(props.size())); // head support if (HttpMethod.HEAD.equals(request.method())) { request.response().end(); } else { request.response().sendFile(file); } }
[ "private", "void", "sendFile", "(", "final", "YokeRequest", "request", ",", "final", "String", "file", ",", "final", "FileProps", "props", ")", "{", "// write content type", "String", "contentType", "=", "MimeType", ".", "getMime", "(", "file", ")", ";", "String", "charset", "=", "MimeType", ".", "getCharset", "(", "contentType", ")", ";", "request", ".", "response", "(", ")", ".", "setContentType", "(", "contentType", ",", "charset", ")", ";", "request", ".", "response", "(", ")", ".", "putHeader", "(", "\"Content-Length\"", ",", "Long", ".", "toString", "(", "props", ".", "size", "(", ")", ")", ")", ";", "// head support", "if", "(", "HttpMethod", ".", "HEAD", ".", "equals", "(", "request", ".", "method", "(", ")", ")", ")", "{", "request", ".", "response", "(", ")", ".", "end", "(", ")", ";", "}", "else", "{", "request", ".", "response", "(", ")", ".", "sendFile", "(", "file", ")", ";", "}", "}" ]
Write a file into the response body @param request @param file @param props
[ "Write", "a", "file", "into", "the", "response", "body" ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java#L175-L188
8,472
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java
Static.isFresh
private boolean isFresh(final YokeRequest request) { // defaults boolean etagMatches = true; boolean notModified = true; // fields String modifiedSince = request.getHeader("if-modified-since"); String noneMatch = request.getHeader("if-none-match"); String[] noneMatchTokens = null; String lastModified = request.response().getHeader("last-modified"); String etag = request.response().getHeader("etag"); // unconditional request if (modifiedSince == null && noneMatch == null) { return false; } // parse if-none-match if (noneMatch != null) { noneMatchTokens = noneMatch.split(" *, *"); } // if-none-match if (noneMatchTokens != null) { etagMatches = false; for (String s : noneMatchTokens) { if (etag.equals(s) || "*".equals(noneMatchTokens[0])) { etagMatches = true; break; } } } // if-modified-since if (modifiedSince != null) { try { Date modifiedSinceDate = parse(modifiedSince); Date lastModifiedDate = parse(lastModified); notModified = lastModifiedDate.getTime() <= modifiedSinceDate.getTime(); } catch (ParseException e) { notModified = false; } } return etagMatches && notModified; }
java
private boolean isFresh(final YokeRequest request) { // defaults boolean etagMatches = true; boolean notModified = true; // fields String modifiedSince = request.getHeader("if-modified-since"); String noneMatch = request.getHeader("if-none-match"); String[] noneMatchTokens = null; String lastModified = request.response().getHeader("last-modified"); String etag = request.response().getHeader("etag"); // unconditional request if (modifiedSince == null && noneMatch == null) { return false; } // parse if-none-match if (noneMatch != null) { noneMatchTokens = noneMatch.split(" *, *"); } // if-none-match if (noneMatchTokens != null) { etagMatches = false; for (String s : noneMatchTokens) { if (etag.equals(s) || "*".equals(noneMatchTokens[0])) { etagMatches = true; break; } } } // if-modified-since if (modifiedSince != null) { try { Date modifiedSinceDate = parse(modifiedSince); Date lastModifiedDate = parse(lastModified); notModified = lastModifiedDate.getTime() <= modifiedSinceDate.getTime(); } catch (ParseException e) { notModified = false; } } return etagMatches && notModified; }
[ "private", "boolean", "isFresh", "(", "final", "YokeRequest", "request", ")", "{", "// defaults", "boolean", "etagMatches", "=", "true", ";", "boolean", "notModified", "=", "true", ";", "// fields", "String", "modifiedSince", "=", "request", ".", "getHeader", "(", "\"if-modified-since\"", ")", ";", "String", "noneMatch", "=", "request", ".", "getHeader", "(", "\"if-none-match\"", ")", ";", "String", "[", "]", "noneMatchTokens", "=", "null", ";", "String", "lastModified", "=", "request", ".", "response", "(", ")", ".", "getHeader", "(", "\"last-modified\"", ")", ";", "String", "etag", "=", "request", ".", "response", "(", ")", ".", "getHeader", "(", "\"etag\"", ")", ";", "// unconditional request", "if", "(", "modifiedSince", "==", "null", "&&", "noneMatch", "==", "null", ")", "{", "return", "false", ";", "}", "// parse if-none-match", "if", "(", "noneMatch", "!=", "null", ")", "{", "noneMatchTokens", "=", "noneMatch", ".", "split", "(", "\" *, *\"", ")", ";", "}", "// if-none-match", "if", "(", "noneMatchTokens", "!=", "null", ")", "{", "etagMatches", "=", "false", ";", "for", "(", "String", "s", ":", "noneMatchTokens", ")", "{", "if", "(", "etag", ".", "equals", "(", "s", ")", "||", "\"*\"", ".", "equals", "(", "noneMatchTokens", "[", "0", "]", ")", ")", "{", "etagMatches", "=", "true", ";", "break", ";", "}", "}", "}", "// if-modified-since", "if", "(", "modifiedSince", "!=", "null", ")", "{", "try", "{", "Date", "modifiedSinceDate", "=", "parse", "(", "modifiedSince", ")", ";", "Date", "lastModifiedDate", "=", "parse", "(", "lastModified", ")", ";", "notModified", "=", "lastModifiedDate", ".", "getTime", "(", ")", "<=", "modifiedSinceDate", ".", "getTime", "(", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "notModified", "=", "false", ";", "}", "}", "return", "etagMatches", "&&", "notModified", ";", "}" ]
Verify if a resource is fresh, fresh means that its cache headers are validated against the local resource and etags last-modified headers are still the same. @param request @return {boolean}
[ "Verify", "if", "a", "resource", "is", "fresh", "fresh", "means", "that", "its", "cache", "headers", "are", "validated", "against", "the", "local", "resource", "and", "etags", "last", "-", "modified", "headers", "are", "still", "the", "same", "." ]
fe8a64036f09fb745f0644faddd46162d64faf3c
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Static.java#L304-L349
8,473
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/AbstractFacade.java
AbstractFacade.getReadyObjectList
@SuppressWarnings("unchecked") private <E extends R> List<E> getReadyObjectList(final UniqueKey<E> uniqueKey) { List<E> readyObjectList = null; synchronized (this.componentMap) { // retrieve the component from the singleton map // It the component is already registered, get it to return it if (exists(uniqueKey)) { readyObjectList = new ArrayList<>((Set<E>) this.componentMap.get(uniqueKey)); // // Check that the reference is not null // if (weakHashSet != null) { // // If no key is provided retrieve from the singleton map // // Extract the value from the weak reference // readyObject = (E) weakHashSet.get(); // } } } return readyObjectList; }
java
@SuppressWarnings("unchecked") private <E extends R> List<E> getReadyObjectList(final UniqueKey<E> uniqueKey) { List<E> readyObjectList = null; synchronized (this.componentMap) { // retrieve the component from the singleton map // It the component is already registered, get it to return it if (exists(uniqueKey)) { readyObjectList = new ArrayList<>((Set<E>) this.componentMap.get(uniqueKey)); // // Check that the reference is not null // if (weakHashSet != null) { // // If no key is provided retrieve from the singleton map // // Extract the value from the weak reference // readyObject = (E) weakHashSet.get(); // } } } return readyObjectList; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "<", "E", "extends", "R", ">", "List", "<", "E", ">", "getReadyObjectList", "(", "final", "UniqueKey", "<", "E", ">", "uniqueKey", ")", "{", "List", "<", "E", ">", "readyObjectList", "=", "null", ";", "synchronized", "(", "this", ".", "componentMap", ")", "{", "// retrieve the component from the singleton map", "// It the component is already registered, get it to return it", "if", "(", "exists", "(", "uniqueKey", ")", ")", "{", "readyObjectList", "=", "new", "ArrayList", "<>", "(", "(", "Set", "<", "E", ">", ")", "this", ".", "componentMap", ".", "get", "(", "uniqueKey", ")", ")", ";", "// // Check that the reference is not null", "// if (weakHashSet != null) {", "// // If no key is provided retrieve from the singleton map", "// // Extract the value from the weak reference", "// readyObject = (E) weakHashSet.get();", "// }", "}", "}", "return", "readyObjectList", ";", "}" ]
Check the presence of the Object and return it if possible otherwise return null. @param uniqueKey the unqiueKey of thesearch object @return the readyObject or null
[ "Check", "the", "presence", "of", "the", "Object", "and", "return", "it", "if", "possible", "otherwise", "return", "null", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/AbstractFacade.java#L267-L287
8,474
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/AbstractFacade.java
AbstractFacade.buildComponentList
@SuppressWarnings("unchecked") protected <E extends R> List<E> buildComponentList(final UniqueKey<E> uniqueKey) throws CoreException { // Build a new instance of the component final List<E> readyObjectList = globalFacade().componentFactory().buildComponents(uniqueKey.classField()); for (final E readyObject : readyObjectList) { // Retrieve the right event type to track JRebirthEventType type = JRebirthEventType.NONE; if (readyObject instanceof Model) { type = JRebirthEventType.CREATE_MODEL; } else if (readyObject instanceof Service) { type = JRebirthEventType.CREATE_SERVICE; } else if (readyObject instanceof Command) { type = JRebirthEventType.CREATE_COMMAND; } // Track this instantiation event globalFacade().trackEvent(type, this.getClass(), readyObject.getClass()); // Attach the local facade // Already Done by register method readyObject.localFacade(this); UniqueKey<E> readyKey = null; if (uniqueKey instanceof MultitonKey) { final Object keyPart = ((MultitonKey<?>) uniqueKey).value(); readyKey = (UniqueKey<E>) Key.createMulti(readyObject.getClass(), keyPart instanceof List ? ((List<?>) keyPart).toArray() : new Object[] { keyPart }, uniqueKey.optionalData().toArray()); } else if (uniqueKey instanceof ClassKey) { readyKey = (UniqueKey<E>) Key.createSingle(readyObject.getClass(), uniqueKey.optionalData().toArray()); } readyKey.registrationKey(uniqueKey); // Create the unique key readyObject.key((UniqueKey<R>) readyKey); } // EnhancedComponent Ready ! return readyObjectList; }
java
@SuppressWarnings("unchecked") protected <E extends R> List<E> buildComponentList(final UniqueKey<E> uniqueKey) throws CoreException { // Build a new instance of the component final List<E> readyObjectList = globalFacade().componentFactory().buildComponents(uniqueKey.classField()); for (final E readyObject : readyObjectList) { // Retrieve the right event type to track JRebirthEventType type = JRebirthEventType.NONE; if (readyObject instanceof Model) { type = JRebirthEventType.CREATE_MODEL; } else if (readyObject instanceof Service) { type = JRebirthEventType.CREATE_SERVICE; } else if (readyObject instanceof Command) { type = JRebirthEventType.CREATE_COMMAND; } // Track this instantiation event globalFacade().trackEvent(type, this.getClass(), readyObject.getClass()); // Attach the local facade // Already Done by register method readyObject.localFacade(this); UniqueKey<E> readyKey = null; if (uniqueKey instanceof MultitonKey) { final Object keyPart = ((MultitonKey<?>) uniqueKey).value(); readyKey = (UniqueKey<E>) Key.createMulti(readyObject.getClass(), keyPart instanceof List ? ((List<?>) keyPart).toArray() : new Object[] { keyPart }, uniqueKey.optionalData().toArray()); } else if (uniqueKey instanceof ClassKey) { readyKey = (UniqueKey<E>) Key.createSingle(readyObject.getClass(), uniqueKey.optionalData().toArray()); } readyKey.registrationKey(uniqueKey); // Create the unique key readyObject.key((UniqueKey<R>) readyKey); } // EnhancedComponent Ready ! return readyObjectList; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "<", "E", "extends", "R", ">", "List", "<", "E", ">", "buildComponentList", "(", "final", "UniqueKey", "<", "E", ">", "uniqueKey", ")", "throws", "CoreException", "{", "// Build a new instance of the component", "final", "List", "<", "E", ">", "readyObjectList", "=", "globalFacade", "(", ")", ".", "componentFactory", "(", ")", ".", "buildComponents", "(", "uniqueKey", ".", "classField", "(", ")", ")", ";", "for", "(", "final", "E", "readyObject", ":", "readyObjectList", ")", "{", "// Retrieve the right event type to track", "JRebirthEventType", "type", "=", "JRebirthEventType", ".", "NONE", ";", "if", "(", "readyObject", "instanceof", "Model", ")", "{", "type", "=", "JRebirthEventType", ".", "CREATE_MODEL", ";", "}", "else", "if", "(", "readyObject", "instanceof", "Service", ")", "{", "type", "=", "JRebirthEventType", ".", "CREATE_SERVICE", ";", "}", "else", "if", "(", "readyObject", "instanceof", "Command", ")", "{", "type", "=", "JRebirthEventType", ".", "CREATE_COMMAND", ";", "}", "// Track this instantiation event", "globalFacade", "(", ")", ".", "trackEvent", "(", "type", ",", "this", ".", "getClass", "(", ")", ",", "readyObject", ".", "getClass", "(", ")", ")", ";", "// Attach the local facade", "// Already Done by register method", "readyObject", ".", "localFacade", "(", "this", ")", ";", "UniqueKey", "<", "E", ">", "readyKey", "=", "null", ";", "if", "(", "uniqueKey", "instanceof", "MultitonKey", ")", "{", "final", "Object", "keyPart", "=", "(", "(", "MultitonKey", "<", "?", ">", ")", "uniqueKey", ")", ".", "value", "(", ")", ";", "readyKey", "=", "(", "UniqueKey", "<", "E", ">", ")", "Key", ".", "createMulti", "(", "readyObject", ".", "getClass", "(", ")", ",", "keyPart", "instanceof", "List", "?", "(", "(", "List", "<", "?", ">", ")", "keyPart", ")", ".", "toArray", "(", ")", ":", "new", "Object", "[", "]", "{", "keyPart", "}", ",", "uniqueKey", ".", "optionalData", "(", ")", ".", "toArray", "(", ")", ")", ";", "}", "else", "if", "(", "uniqueKey", "instanceof", "ClassKey", ")", "{", "readyKey", "=", "(", "UniqueKey", "<", "E", ">", ")", "Key", ".", "createSingle", "(", "readyObject", ".", "getClass", "(", ")", ",", "uniqueKey", ".", "optionalData", "(", ")", ".", "toArray", "(", ")", ")", ";", "}", "readyKey", ".", "registrationKey", "(", "uniqueKey", ")", ";", "// Create the unique key", "readyObject", ".", "key", "(", "(", "UniqueKey", "<", "R", ">", ")", "readyKey", ")", ";", "}", "// EnhancedComponent Ready !", "return", "readyObjectList", ";", "}" ]
Build a new instance of the ready object class. @param uniqueKey the unique key for the component to get @return a new instance of the given clazz and key @param <E> the type of the ready object to retrieve @throws CoreException if an error occurred
[ "Build", "a", "new", "instance", "of", "the", "ready", "object", "class", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/AbstractFacade.java#L300-L342
8,475
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThreadPoolExecutor.java
JRebirthThreadPoolExecutor.checkPriority
private boolean checkPriority(final PriorityLevel taskPriority) { boolean highPriority = false; synchronized (this.pending) { for (final JRebirthRunnable jr : this.pending) { highPriority |= taskPriority.level() > jr.priority().level(); } } return !highPriority; }
java
private boolean checkPriority(final PriorityLevel taskPriority) { boolean highPriority = false; synchronized (this.pending) { for (final JRebirthRunnable jr : this.pending) { highPriority |= taskPriority.level() > jr.priority().level(); } } return !highPriority; }
[ "private", "boolean", "checkPriority", "(", "final", "PriorityLevel", "taskPriority", ")", "{", "boolean", "highPriority", "=", "false", ";", "synchronized", "(", "this", ".", "pending", ")", "{", "for", "(", "final", "JRebirthRunnable", "jr", ":", "this", ".", "pending", ")", "{", "highPriority", "|=", "taskPriority", ".", "level", "(", ")", ">", "jr", ".", "priority", "(", ")", ".", "level", "(", ")", ";", "}", "}", "return", "!", "highPriority", ";", "}" ]
Check given priority with current pending list. @param taskPriority the priority to check @return true if the priority is greater than those pending
[ "Check", "given", "priority", "with", "current", "pending", "list", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirthThreadPoolExecutor.java#L85-L94
8,476
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractModel.java
AbstractModel.listenObject
protected <T> void listenObject(ObjectProperty<T> objectProperty, Consumer<T> consumeOld, Consumer<T> consumeNew) { objectProperty.addListener( (final ObservableValue<? extends T> ov, final T old_val, final T new_val) -> { if (old_val != null && consumeOld != null) { consumeOld.accept(old_val); } if (new_val != null && consumeNew != null) { consumeNew.accept(new_val); } }); }
java
protected <T> void listenObject(ObjectProperty<T> objectProperty, Consumer<T> consumeOld, Consumer<T> consumeNew) { objectProperty.addListener( (final ObservableValue<? extends T> ov, final T old_val, final T new_val) -> { if (old_val != null && consumeOld != null) { consumeOld.accept(old_val); } if (new_val != null && consumeNew != null) { consumeNew.accept(new_val); } }); }
[ "protected", "<", "T", ">", "void", "listenObject", "(", "ObjectProperty", "<", "T", ">", "objectProperty", ",", "Consumer", "<", "T", ">", "consumeOld", ",", "Consumer", "<", "T", ">", "consumeNew", ")", "{", "objectProperty", ".", "addListener", "(", "(", "final", "ObservableValue", "<", "?", "extends", "T", ">", "ov", ",", "final", "T", "old_val", ",", "final", "T", "new_val", ")", "->", "{", "if", "(", "old_val", "!=", "null", "&&", "consumeOld", "!=", "null", ")", "{", "consumeOld", ".", "accept", "(", "old_val", ")", ";", "}", "if", "(", "new_val", "!=", "null", "&&", "consumeNew", "!=", "null", ")", "{", "consumeNew", ".", "accept", "(", "new_val", ")", ";", "}", "}", ")", ";", "}" ]
Listen object change. @param objectProperty the object to listen @param consumeOld process the old object @param consumeNew process the new object
[ "Listen", "object", "change", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractModel.java#L178-L188
8,477
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractModel.java
AbstractModel.buildView
@SuppressWarnings("unchecked") protected V buildView() throws CoreException { return (V) ClassUtility.findAndBuildGenericType(this.getClass(), View.class, NullView.class, this); }
java
@SuppressWarnings("unchecked") protected V buildView() throws CoreException { return (V) ClassUtility.findAndBuildGenericType(this.getClass(), View.class, NullView.class, this); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "V", "buildView", "(", ")", "throws", "CoreException", "{", "return", "(", "V", ")", "ClassUtility", ".", "findAndBuildGenericType", "(", "this", ".", "getClass", "(", ")", ",", "View", ".", "class", ",", "NullView", ".", "class", ",", "this", ")", ";", "}" ]
Create the view it was null. @throws CoreException when han't been built correctly
[ "Create", "the", "view", "it", "was", "null", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractModel.java#L213-L217
8,478
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java
BallView.setStyle
public void setStyle(final JRebirthEventType eventType) { switch (eventType) { case CREATE_APPLICATION: this.circle.setFill(BallColors.APPLICATION.get()); this.label.setText("App"); break; case CREATE_NOTIFIER: this.circle.setFill(BallColors.NOTIFIER.get()); this.label.setText("N"); break; case CREATE_GLOBAL_FACADE: this.circle.setFill(BallColors.GLOBAL_FACADE.get()); this.label.setText("GF"); break; case CREATE_UI_FACADE: this.circle.setFill(BallColors.UI_FACADE.get()); this.label.setText("UF"); break; case CREATE_SERVICE_FACADE: this.circle.setFill(BallColors.SERVICE_FACADE.get()); this.label.setText("SF"); break; case CREATE_COMMAND_FACADE: this.circle.setFill(BallColors.COMMAND_FACADE.get()); this.label.setText("CF"); break; case CREATE_SERVICE: this.circle.setFill(BallColors.SERVICE.get()); this.label.setText("S"); break; case CREATE_MODEL: this.circle.setFill(BallColors.MODEL.get()); this.label.setText("M"); break; case CREATE_COMMAND: this.circle.setFill(BallColors.COMMAND.get()); this.label.setText("C"); break; case CREATE_VIEW: this.circle.setFill(BallColors.VIEW.get()); this.label.setText("V"); break; default: // Nothing to colorize } }
java
public void setStyle(final JRebirthEventType eventType) { switch (eventType) { case CREATE_APPLICATION: this.circle.setFill(BallColors.APPLICATION.get()); this.label.setText("App"); break; case CREATE_NOTIFIER: this.circle.setFill(BallColors.NOTIFIER.get()); this.label.setText("N"); break; case CREATE_GLOBAL_FACADE: this.circle.setFill(BallColors.GLOBAL_FACADE.get()); this.label.setText("GF"); break; case CREATE_UI_FACADE: this.circle.setFill(BallColors.UI_FACADE.get()); this.label.setText("UF"); break; case CREATE_SERVICE_FACADE: this.circle.setFill(BallColors.SERVICE_FACADE.get()); this.label.setText("SF"); break; case CREATE_COMMAND_FACADE: this.circle.setFill(BallColors.COMMAND_FACADE.get()); this.label.setText("CF"); break; case CREATE_SERVICE: this.circle.setFill(BallColors.SERVICE.get()); this.label.setText("S"); break; case CREATE_MODEL: this.circle.setFill(BallColors.MODEL.get()); this.label.setText("M"); break; case CREATE_COMMAND: this.circle.setFill(BallColors.COMMAND.get()); this.label.setText("C"); break; case CREATE_VIEW: this.circle.setFill(BallColors.VIEW.get()); this.label.setText("V"); break; default: // Nothing to colorize } }
[ "public", "void", "setStyle", "(", "final", "JRebirthEventType", "eventType", ")", "{", "switch", "(", "eventType", ")", "{", "case", "CREATE_APPLICATION", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "APPLICATION", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"App\"", ")", ";", "break", ";", "case", "CREATE_NOTIFIER", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "NOTIFIER", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"N\"", ")", ";", "break", ";", "case", "CREATE_GLOBAL_FACADE", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "GLOBAL_FACADE", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"GF\"", ")", ";", "break", ";", "case", "CREATE_UI_FACADE", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "UI_FACADE", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"UF\"", ")", ";", "break", ";", "case", "CREATE_SERVICE_FACADE", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "SERVICE_FACADE", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"SF\"", ")", ";", "break", ";", "case", "CREATE_COMMAND_FACADE", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "COMMAND_FACADE", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"CF\"", ")", ";", "break", ";", "case", "CREATE_SERVICE", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "SERVICE", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"S\"", ")", ";", "break", ";", "case", "CREATE_MODEL", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "MODEL", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"M\"", ")", ";", "break", ";", "case", "CREATE_COMMAND", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "COMMAND", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"C\"", ")", ";", "break", ";", "case", "CREATE_VIEW", ":", "this", ".", "circle", ".", "setFill", "(", "BallColors", ".", "VIEW", ".", "get", "(", ")", ")", ";", "this", ".", "label", ".", "setText", "(", "\"V\"", ")", ";", "break", ";", "default", ":", "// Nothing to colorize", "}", "}" ]
Define the ball style. @param eventType the type of event for this ball
[ "Define", "the", "ball", "style", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java#L178-L225
8,479
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java
BallView.resetScale
public void resetScale() { ScaleTransitionBuilder.create() .duration(Duration.millis(400)) .node(node()) .toX(1f) .toY(1f) .cycleCount(1) .autoReverse(false) .build() .play(); }
java
public void resetScale() { ScaleTransitionBuilder.create() .duration(Duration.millis(400)) .node(node()) .toX(1f) .toY(1f) .cycleCount(1) .autoReverse(false) .build() .play(); }
[ "public", "void", "resetScale", "(", ")", "{", "ScaleTransitionBuilder", ".", "create", "(", ")", ".", "duration", "(", "Duration", ".", "millis", "(", "400", ")", ")", ".", "node", "(", "node", "(", ")", ")", ".", "toX", "(", "1f", ")", ".", "toY", "(", "1f", ")", ".", "cycleCount", "(", "1", ")", ".", "autoReverse", "(", "false", ")", ".", "build", "(", ")", ".", "play", "(", ")", ";", "}" ]
To complete.
[ "To", "complete", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java#L230-L240
8,480
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java
BallView.getX
private double getX() { double res; switch (model().getEventModel().eventType()) { case CREATE_APPLICATION: case CREATE_COMMAND: case CREATE_COMMAND_FACADE: res = 0; break; case CREATE_GLOBAL_FACADE: case CREATE_NOTIFIER: res = 70; break; case CREATE_SERVICE_FACADE: case CREATE_SERVICE: res = -200 * Math.cos(Math.PI / 6); break; case CREATE_UI_FACADE: case CREATE_MODEL: res = 200 * Math.cos(Math.PI / 6); break; default: res = 50; } return res; }
java
private double getX() { double res; switch (model().getEventModel().eventType()) { case CREATE_APPLICATION: case CREATE_COMMAND: case CREATE_COMMAND_FACADE: res = 0; break; case CREATE_GLOBAL_FACADE: case CREATE_NOTIFIER: res = 70; break; case CREATE_SERVICE_FACADE: case CREATE_SERVICE: res = -200 * Math.cos(Math.PI / 6); break; case CREATE_UI_FACADE: case CREATE_MODEL: res = 200 * Math.cos(Math.PI / 6); break; default: res = 50; } return res; }
[ "private", "double", "getX", "(", ")", "{", "double", "res", ";", "switch", "(", "model", "(", ")", ".", "getEventModel", "(", ")", ".", "eventType", "(", ")", ")", "{", "case", "CREATE_APPLICATION", ":", "case", "CREATE_COMMAND", ":", "case", "CREATE_COMMAND_FACADE", ":", "res", "=", "0", ";", "break", ";", "case", "CREATE_GLOBAL_FACADE", ":", "case", "CREATE_NOTIFIER", ":", "res", "=", "70", ";", "break", ";", "case", "CREATE_SERVICE_FACADE", ":", "case", "CREATE_SERVICE", ":", "res", "=", "-", "200", "*", "Math", ".", "cos", "(", "Math", ".", "PI", "/", "6", ")", ";", "break", ";", "case", "CREATE_UI_FACADE", ":", "case", "CREATE_MODEL", ":", "res", "=", "200", "*", "Math", ".", "cos", "(", "Math", ".", "PI", "/", "6", ")", ";", "break", ";", "default", ":", "res", "=", "50", ";", "}", "return", "res", ";", "}" ]
Return the x coordinate. @return the x value
[ "Return", "the", "x", "coordinate", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java#L299-L324
8,481
JRebirth/JRebirth
org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java
BallView.getY
private double getY() { double res; switch (model().getEventModel().eventType()) { case CREATE_COMMAND_FACADE: case CREATE_COMMAND: res = -200 * Math.sin(Math.PI / 2); break; case CREATE_GLOBAL_FACADE: case CREATE_APPLICATION: case CREATE_NOTIFIER: res = 0; break; case CREATE_SERVICE_FACADE: case CREATE_UI_FACADE: case CREATE_MODEL: case CREATE_SERVICE: res = +200 * Math.sin(Math.PI / 6); break; default: res = 50; } return res; }
java
private double getY() { double res; switch (model().getEventModel().eventType()) { case CREATE_COMMAND_FACADE: case CREATE_COMMAND: res = -200 * Math.sin(Math.PI / 2); break; case CREATE_GLOBAL_FACADE: case CREATE_APPLICATION: case CREATE_NOTIFIER: res = 0; break; case CREATE_SERVICE_FACADE: case CREATE_UI_FACADE: case CREATE_MODEL: case CREATE_SERVICE: res = +200 * Math.sin(Math.PI / 6); break; default: res = 50; } return res; }
[ "private", "double", "getY", "(", ")", "{", "double", "res", ";", "switch", "(", "model", "(", ")", ".", "getEventModel", "(", ")", ".", "eventType", "(", ")", ")", "{", "case", "CREATE_COMMAND_FACADE", ":", "case", "CREATE_COMMAND", ":", "res", "=", "-", "200", "*", "Math", ".", "sin", "(", "Math", ".", "PI", "/", "2", ")", ";", "break", ";", "case", "CREATE_GLOBAL_FACADE", ":", "case", "CREATE_APPLICATION", ":", "case", "CREATE_NOTIFIER", ":", "res", "=", "0", ";", "break", ";", "case", "CREATE_SERVICE_FACADE", ":", "case", "CREATE_UI_FACADE", ":", "case", "CREATE_MODEL", ":", "case", "CREATE_SERVICE", ":", "res", "=", "+", "200", "*", "Math", ".", "sin", "(", "Math", ".", "PI", "/", "6", ")", ";", "break", ";", "default", ":", "res", "=", "50", ";", "}", "return", "res", ";", "}" ]
Return the y coordinate. @return the y value
[ "Return", "the", "y", "coordinate", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/showcase/analyzer/src/main/java/org/jrebirth/af/showcase/analyzer/ui/editor/ball/BallView.java#L331-L353
8,482
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveTypeBase.java
WaveTypeBase.getItems
public String getItems() { final StringBuilder sb = new StringBuilder(); boolean first = true; for (final WaveItem<?> waveItem : items()) { if (first) { first = false; } else { sb.append(", "); } String fullName = waveItem.type() instanceof ParameterizedType ? ((ParameterizedType) waveItem.type()).toString() : ((Class<?>) waveItem.type()).getName(); sb.append(fullName).append(" "); fullName = fullName.replaceAll("[<>]", ""); if (waveItem.name() == null || waveItem.name().isEmpty()) { sb.append(ObjectUtility.lowerFirstChar(fullName.substring(fullName.lastIndexOf('.') + 1))); } else { sb.append(waveItem.name()); } } return sb.toString(); }
java
public String getItems() { final StringBuilder sb = new StringBuilder(); boolean first = true; for (final WaveItem<?> waveItem : items()) { if (first) { first = false; } else { sb.append(", "); } String fullName = waveItem.type() instanceof ParameterizedType ? ((ParameterizedType) waveItem.type()).toString() : ((Class<?>) waveItem.type()).getName(); sb.append(fullName).append(" "); fullName = fullName.replaceAll("[<>]", ""); if (waveItem.name() == null || waveItem.name().isEmpty()) { sb.append(ObjectUtility.lowerFirstChar(fullName.substring(fullName.lastIndexOf('.') + 1))); } else { sb.append(waveItem.name()); } } return sb.toString(); }
[ "public", "String", "getItems", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "final", "WaveItem", "<", "?", ">", "waveItem", ":", "items", "(", ")", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "sb", ".", "append", "(", "\", \"", ")", ";", "}", "String", "fullName", "=", "waveItem", ".", "type", "(", ")", "instanceof", "ParameterizedType", "?", "(", "(", "ParameterizedType", ")", "waveItem", ".", "type", "(", ")", ")", ".", "toString", "(", ")", ":", "(", "(", "Class", "<", "?", ">", ")", "waveItem", ".", "type", "(", ")", ")", ".", "getName", "(", ")", ";", "sb", ".", "append", "(", "fullName", ")", ".", "append", "(", "\" \"", ")", ";", "fullName", "=", "fullName", ".", "replaceAll", "(", "\"[<>]\"", ",", "\"\"", ")", ";", "if", "(", "waveItem", ".", "name", "(", ")", "==", "null", "||", "waveItem", ".", "name", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "ObjectUtility", ".", "lowerFirstChar", "(", "fullName", ".", "substring", "(", "fullName", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ")", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "waveItem", ".", "name", "(", ")", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Return the required method parameter list to handle this WaveType. @return the parameter list (Type1 arg1, Type2 arg2 ...)
[ "Return", "the", "required", "method", "parameter", "list", "to", "handle", "this", "WaveType", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveTypeBase.java#L241-L262
8,483
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java
AbstractBaseController.wrapbuildHandler
private <E extends Event> EventHandler<E> wrapbuildHandler(final EventAdapter eventAdapter, final Class<? extends EventAdapter> adapterClass, final Class<? extends EventHandler<E>> handlerClass) throws CoreException { try { return handlerClass.getDeclaredConstructor(adapterClass).newInstance(eventAdapter); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new CoreException("Impossible to build event handler " + handlerClass.getName() + " for the class " + this.getClass().getName(), e); } }
java
private <E extends Event> EventHandler<E> wrapbuildHandler(final EventAdapter eventAdapter, final Class<? extends EventAdapter> adapterClass, final Class<? extends EventHandler<E>> handlerClass) throws CoreException { try { return handlerClass.getDeclaredConstructor(adapterClass).newInstance(eventAdapter); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new CoreException("Impossible to build event handler " + handlerClass.getName() + " for the class " + this.getClass().getName(), e); } }
[ "private", "<", "E", "extends", "Event", ">", "EventHandler", "<", "E", ">", "wrapbuildHandler", "(", "final", "EventAdapter", "eventAdapter", ",", "final", "Class", "<", "?", "extends", "EventAdapter", ">", "adapterClass", ",", "final", "Class", "<", "?", "extends", "EventHandler", "<", "E", ">", ">", "handlerClass", ")", "throws", "CoreException", "{", "try", "{", "return", "handlerClass", ".", "getDeclaredConstructor", "(", "adapterClass", ")", ".", "newInstance", "(", "eventAdapter", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "|", "IllegalArgumentException", "|", "InvocationTargetException", "|", "NoSuchMethodException", "|", "SecurityException", "e", ")", "{", "throw", "new", "CoreException", "(", "\"Impossible to build event handler \"", "+", "handlerClass", ".", "getName", "(", ")", "+", "\" for the class \"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}" ]
Build an event handler by reflection to wrap the event adapter given. @param eventAdapter the instance of an eventAdapter @param adapterClass the adapter class used by the handler constructor @param handlerClass the handler class to build @return the required event handler @param <E> the Event type to manage @throws CoreException if an error occurred while creating the event handler
[ "Build", "an", "event", "handler", "by", "reflection", "to", "wrap", "the", "event", "adapter", "given", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java#L234-L241
8,484
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java
AbstractBaseController.buildEventHandler
private <E extends Event> EventHandler<E> buildEventHandler(final Class<? extends EventAdapter> adapterClass, final Class<? extends EventHandler<E>> handlerClass) throws CoreException { EventHandler<E> eventHandler = null; // Build the mouse handler instance if (adapterClass.isAssignableFrom(this.getClass())) { eventHandler = wrapbuildHandler(this, adapterClass, handlerClass); } else { throw new CoreException(this.getClass().getName() + " must implement " + adapterClass.getName() + " interface"); } return eventHandler; }
java
private <E extends Event> EventHandler<E> buildEventHandler(final Class<? extends EventAdapter> adapterClass, final Class<? extends EventHandler<E>> handlerClass) throws CoreException { EventHandler<E> eventHandler = null; // Build the mouse handler instance if (adapterClass.isAssignableFrom(this.getClass())) { eventHandler = wrapbuildHandler(this, adapterClass, handlerClass); } else { throw new CoreException(this.getClass().getName() + " must implement " + adapterClass.getName() + " interface"); } return eventHandler; }
[ "private", "<", "E", "extends", "Event", ">", "EventHandler", "<", "E", ">", "buildEventHandler", "(", "final", "Class", "<", "?", "extends", "EventAdapter", ">", "adapterClass", ",", "final", "Class", "<", "?", "extends", "EventHandler", "<", "E", ">", ">", "handlerClass", ")", "throws", "CoreException", "{", "EventHandler", "<", "E", ">", "eventHandler", "=", "null", ";", "// Build the mouse handler instance", "if", "(", "adapterClass", ".", "isAssignableFrom", "(", "this", ".", "getClass", "(", ")", ")", ")", "{", "eventHandler", "=", "wrapbuildHandler", "(", "this", ",", "adapterClass", ",", "handlerClass", ")", ";", "}", "else", "{", "throw", "new", "CoreException", "(", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" must implement \"", "+", "adapterClass", ".", "getName", "(", ")", "+", "\" interface\"", ")", ";", "}", "return", "eventHandler", ";", "}" ]
Build an event handler by reflection using the Controller object as eventAdapter. @param adapterClass the event adapter class to used @param handlerClass the event handler class to used @return the required event handler @param <E> the Event type to manage @throws CoreException if the local api contract is not respected
[ "Build", "an", "event", "handler", "by", "reflection", "using", "the", "Controller", "object", "as", "eventAdapter", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java#L255-L265
8,485
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java
AbstractBaseController.isEventType
private boolean isEventType(final EventType<? extends Event> testEventType, final EventType<? extends Event> anyEventType) { return testEventType.equals(anyEventType) || testEventType.getSuperType().equals(anyEventType); }
java
private boolean isEventType(final EventType<? extends Event> testEventType, final EventType<? extends Event> anyEventType) { return testEventType.equals(anyEventType) || testEventType.getSuperType().equals(anyEventType); }
[ "private", "boolean", "isEventType", "(", "final", "EventType", "<", "?", "extends", "Event", ">", "testEventType", ",", "final", "EventType", "<", "?", "extends", "Event", ">", "anyEventType", ")", "{", "return", "testEventType", ".", "equals", "(", "anyEventType", ")", "||", "testEventType", ".", "getSuperType", "(", ")", ".", "equals", "(", "anyEventType", ")", ";", "}" ]
Check the event type given and check the super level if necessary to always return the ANy event type. @param testEventType the sub event type or any instance @param anyEventType the eventype.ANY instance @return true if the ANY event type is the same for both objects
[ "Check", "the", "event", "type", "given", "and", "check", "the", "super", "level", "if", "necessary", "to", "always", "return", "the", "ANy", "event", "type", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/AbstractBaseController.java#L275-L277
8,486
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java
WaveBase.waveBeanContains
private boolean waveBeanContains(WaveItem<?> waveItem) { return waveBeanList().stream() .flatMap(wb -> Stream.of(wb.getClass().getDeclaredFields())) .map(f -> f.getName()) .anyMatch(n -> waveItem.name().equals(n)); }
java
private boolean waveBeanContains(WaveItem<?> waveItem) { return waveBeanList().stream() .flatMap(wb -> Stream.of(wb.getClass().getDeclaredFields())) .map(f -> f.getName()) .anyMatch(n -> waveItem.name().equals(n)); }
[ "private", "boolean", "waveBeanContains", "(", "WaveItem", "<", "?", ">", "waveItem", ")", "{", "return", "waveBeanList", "(", ")", ".", "stream", "(", ")", ".", "flatMap", "(", "wb", "->", "Stream", ".", "of", "(", "wb", ".", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ")", ")", ".", "map", "(", "f", "->", "f", ".", "getName", "(", ")", ")", ".", "anyMatch", "(", "n", "->", "waveItem", ".", "name", "(", ")", ".", "equals", "(", "n", ")", ")", ";", "}" ]
Check if this item is contained into on Wave bean . @param waveItem the wave item to find @return true, if successful
[ "Check", "if", "this", "item", "is", "contained", "into", "on", "Wave", "bean", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java#L328-L333
8,487
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java
WaveBase.waveBeanGet
private Object waveBeanGet(WaveItem<?> waveItem) { for (final WaveBean wb : waveBeanList()) { final Object o = Stream.of(wb.getClass().getDeclaredFields()) .filter(f -> waveItem.name().equals(f.getName())) .map(f -> ClassUtility.getFieldValue(f, wb)).findFirst().get(); if (o != null) { return o; } } return null; }
java
private Object waveBeanGet(WaveItem<?> waveItem) { for (final WaveBean wb : waveBeanList()) { final Object o = Stream.of(wb.getClass().getDeclaredFields()) .filter(f -> waveItem.name().equals(f.getName())) .map(f -> ClassUtility.getFieldValue(f, wb)).findFirst().get(); if (o != null) { return o; } } return null; }
[ "private", "Object", "waveBeanGet", "(", "WaveItem", "<", "?", ">", "waveItem", ")", "{", "for", "(", "final", "WaveBean", "wb", ":", "waveBeanList", "(", ")", ")", "{", "final", "Object", "o", "=", "Stream", ".", "of", "(", "wb", ".", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ")", ".", "filter", "(", "f", "->", "waveItem", ".", "name", "(", ")", ".", "equals", "(", "f", ".", "getName", "(", ")", ")", ")", ".", "map", "(", "f", "->", "ClassUtility", ".", "getFieldValue", "(", "f", ",", "wb", ")", ")", ".", "findFirst", "(", ")", ".", "get", "(", ")", ";", "if", "(", "o", "!=", "null", ")", "{", "return", "o", ";", "}", "}", "return", "null", ";", "}" ]
Retrieve the field value from wave bean @param waveItem the wave item to retrieve @return the object value
[ "Retrieve", "the", "field", "value", "from", "wave", "bean" ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java#L342-L353
8,488
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java
WaveBase.getWaveBeanMap
private Map<Class<? extends WaveBean>, WaveBean> getWaveBeanMap() { if (this.waveBeanMap == null) { this.waveBeanMap = new HashMap<>(); } return this.waveBeanMap; }
java
private Map<Class<? extends WaveBean>, WaveBean> getWaveBeanMap() { if (this.waveBeanMap == null) { this.waveBeanMap = new HashMap<>(); } return this.waveBeanMap; }
[ "private", "Map", "<", "Class", "<", "?", "extends", "WaveBean", ">", ",", "WaveBean", ">", "getWaveBeanMap", "(", ")", "{", "if", "(", "this", ".", "waveBeanMap", "==", "null", ")", "{", "this", ".", "waveBeanMap", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "return", "this", ".", "waveBeanMap", ";", "}" ]
Get the Wave Bean map. Create it if it hasn't been done before. @return the wave bean map never null
[ "Get", "the", "Wave", "Bean", "map", ".", "Create", "it", "if", "it", "hasn", "t", "been", "done", "before", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java#L394-L399
8,489
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java
WaveBase.fireStatusChanged
private void fireStatusChanged() { // System.out.println("fireStatusChanged " + this.status.toString()); for (final WaveListener waveListener : this.waveListeners) { switch (this.statusProperty.get()) { case Created: waveListener.waveCreated(this); break; case Sent: waveListener.waveSent(this); break; case Processing: waveListener.waveProcessed(this); break; case Consumed: waveListener.waveConsumed(this); break; case Handled: waveListener.waveHandled(this); break; case Failed: waveListener.waveFailed(this); break; case Cancelled: waveListener.waveCancelled(this); break; case Destroyed: waveListener.waveDestroyed(this); break; default: break; } } }
java
private void fireStatusChanged() { // System.out.println("fireStatusChanged " + this.status.toString()); for (final WaveListener waveListener : this.waveListeners) { switch (this.statusProperty.get()) { case Created: waveListener.waveCreated(this); break; case Sent: waveListener.waveSent(this); break; case Processing: waveListener.waveProcessed(this); break; case Consumed: waveListener.waveConsumed(this); break; case Handled: waveListener.waveHandled(this); break; case Failed: waveListener.waveFailed(this); break; case Cancelled: waveListener.waveCancelled(this); break; case Destroyed: waveListener.waveDestroyed(this); break; default: break; } } }
[ "private", "void", "fireStatusChanged", "(", ")", "{", "// System.out.println(\"fireStatusChanged \" + this.status.toString());", "for", "(", "final", "WaveListener", "waveListener", ":", "this", ".", "waveListeners", ")", "{", "switch", "(", "this", ".", "statusProperty", ".", "get", "(", ")", ")", "{", "case", "Created", ":", "waveListener", ".", "waveCreated", "(", "this", ")", ";", "break", ";", "case", "Sent", ":", "waveListener", ".", "waveSent", "(", "this", ")", ";", "break", ";", "case", "Processing", ":", "waveListener", ".", "waveProcessed", "(", "this", ")", ";", "break", ";", "case", "Consumed", ":", "waveListener", ".", "waveConsumed", "(", "this", ")", ";", "break", ";", "case", "Handled", ":", "waveListener", ".", "waveHandled", "(", "this", ")", ";", "break", ";", "case", "Failed", ":", "waveListener", ".", "waveFailed", "(", "this", ")", ";", "break", ";", "case", "Cancelled", ":", "waveListener", ".", "waveCancelled", "(", "this", ")", ";", "break", ";", "case", "Destroyed", ":", "waveListener", ".", "waveDestroyed", "(", "this", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "}" ]
Fire a wave status change.
[ "Fire", "a", "wave", "status", "change", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveBase.java#L506-L541
8,490
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/link/WaveHandlerBase.java
WaveHandlerBase.retrieveCustomMethod
private Method retrieveCustomMethod(final Wave wave) { Method customMethod = null; // Search the wave handler method to call customMethod = this.defaultMethod == null // Method computed according to wave prefix and wave type action // name ? ClassUtility.retrieveMethodList(getWaveReady().getClass(), wave.waveType().toString()) .stream() .filter(m -> CheckerUtility.checkMethodSignature(m, wave.waveType().items())) .findFirst().orElse(null) // Method defined with annotation : this.defaultMethod; if (customMethod == null) { LOGGER.info(CUSTOM_METHOD_NOT_FOUND); } return customMethod; }
java
private Method retrieveCustomMethod(final Wave wave) { Method customMethod = null; // Search the wave handler method to call customMethod = this.defaultMethod == null // Method computed according to wave prefix and wave type action // name ? ClassUtility.retrieveMethodList(getWaveReady().getClass(), wave.waveType().toString()) .stream() .filter(m -> CheckerUtility.checkMethodSignature(m, wave.waveType().items())) .findFirst().orElse(null) // Method defined with annotation : this.defaultMethod; if (customMethod == null) { LOGGER.info(CUSTOM_METHOD_NOT_FOUND); } return customMethod; }
[ "private", "Method", "retrieveCustomMethod", "(", "final", "Wave", "wave", ")", "{", "Method", "customMethod", "=", "null", ";", "// Search the wave handler method to call", "customMethod", "=", "this", ".", "defaultMethod", "==", "null", "// Method computed according to wave prefix and wave type action", "// name", "?", "ClassUtility", ".", "retrieveMethodList", "(", "getWaveReady", "(", ")", ".", "getClass", "(", ")", ",", "wave", ".", "waveType", "(", ")", ".", "toString", "(", ")", ")", ".", "stream", "(", ")", ".", "filter", "(", "m", "->", "CheckerUtility", ".", "checkMethodSignature", "(", "m", ",", "wave", ".", "waveType", "(", ")", ".", "items", "(", ")", ")", ")", ".", "findFirst", "(", ")", ".", "orElse", "(", "null", ")", "// Method defined with annotation", ":", "this", ".", "defaultMethod", ";", "if", "(", "customMethod", "==", "null", ")", "{", "LOGGER", ".", "info", "(", "CUSTOM_METHOD_NOT_FOUND", ")", ";", "}", "return", "customMethod", ";", "}" ]
Retrieve the custom wave handler method. @param wave the wave to be handled @return the custom handler method or null if none exists
[ "Retrieve", "the", "custom", "wave", "handler", "method", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/link/WaveHandlerBase.java#L165-L182
8,491
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/link/WaveHandlerBase.java
WaveHandlerBase.performHandle
private void performHandle(final Wave wave, final Method method) throws WaveException { // Build parameter list of the searched method final List<Object> parameterValues = new ArrayList<>(); // Don't add WaveType parameters if we us the default processWave method if (!AbstractComponent.PROCESS_WAVE_METHOD_NAME.equals(method.getName())) { for (final WaveData<?> wd : wave.waveDatas()) { // Add only wave items defined as parameter if (wd.key().isParameter()) { parameterValues.add(wd.value()); } } } // Add the current wave to process parameterValues.add(wave); try { ClassUtility.callMethod(method, getWaveReady(), parameterValues.toArray()); } catch (final CoreException e) { LOGGER.error(WAVE_DISPATCH_ERROR, e); // Propagate the wave exception throw new WaveException(wave, e); } }
java
private void performHandle(final Wave wave, final Method method) throws WaveException { // Build parameter list of the searched method final List<Object> parameterValues = new ArrayList<>(); // Don't add WaveType parameters if we us the default processWave method if (!AbstractComponent.PROCESS_WAVE_METHOD_NAME.equals(method.getName())) { for (final WaveData<?> wd : wave.waveDatas()) { // Add only wave items defined as parameter if (wd.key().isParameter()) { parameterValues.add(wd.value()); } } } // Add the current wave to process parameterValues.add(wave); try { ClassUtility.callMethod(method, getWaveReady(), parameterValues.toArray()); } catch (final CoreException e) { LOGGER.error(WAVE_DISPATCH_ERROR, e); // Propagate the wave exception throw new WaveException(wave, e); } }
[ "private", "void", "performHandle", "(", "final", "Wave", "wave", ",", "final", "Method", "method", ")", "throws", "WaveException", "{", "// Build parameter list of the searched method", "final", "List", "<", "Object", ">", "parameterValues", "=", "new", "ArrayList", "<>", "(", ")", ";", "// Don't add WaveType parameters if we us the default processWave method", "if", "(", "!", "AbstractComponent", ".", "PROCESS_WAVE_METHOD_NAME", ".", "equals", "(", "method", ".", "getName", "(", ")", ")", ")", "{", "for", "(", "final", "WaveData", "<", "?", ">", "wd", ":", "wave", ".", "waveDatas", "(", ")", ")", "{", "// Add only wave items defined as parameter", "if", "(", "wd", ".", "key", "(", ")", ".", "isParameter", "(", ")", ")", "{", "parameterValues", ".", "add", "(", "wd", ".", "value", "(", ")", ")", ";", "}", "}", "}", "// Add the current wave to process", "parameterValues", ".", "add", "(", "wave", ")", ";", "try", "{", "ClassUtility", ".", "callMethod", "(", "method", ",", "getWaveReady", "(", ")", ",", "parameterValues", ".", "toArray", "(", ")", ")", ";", "}", "catch", "(", "final", "CoreException", "e", ")", "{", "LOGGER", ".", "error", "(", "WAVE_DISPATCH_ERROR", ",", "e", ")", ";", "// Propagate the wave exception", "throw", "new", "WaveException", "(", "wave", ",", "e", ")", ";", "}", "}" ]
Perform the handle independently of thread used. @param wave the wave to manage @param method the handler method to call, could be null @throws WaveException if an error occurred while processing the wave
[ "Perform", "the", "handle", "independently", "of", "thread", "used", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/link/WaveHandlerBase.java#L192-L220
8,492
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveTypeRegistry.java
WaveTypeRegistry.getWaveType
public static WaveType getWaveType(final String action) { WaveType waveType = null; if (waveTypeMap.containsKey(action)) { waveType = waveTypeMap.get(action); } return waveType; }
java
public static WaveType getWaveType(final String action) { WaveType waveType = null; if (waveTypeMap.containsKey(action)) { waveType = waveTypeMap.get(action); } return waveType; }
[ "public", "static", "WaveType", "getWaveType", "(", "final", "String", "action", ")", "{", "WaveType", "waveType", "=", "null", ";", "if", "(", "waveTypeMap", ".", "containsKey", "(", "action", ")", ")", "{", "waveType", "=", "waveTypeMap", ".", "get", "(", "action", ")", ";", "}", "return", "waveType", ";", "}" ]
Retrieve a WaveType according to its unique action name. Be careful it could return null if the {@link WaveType} has not been initialized yet. @param action the unique action name used to register the WaveType @return the WaveType found into registry or null
[ "Retrieve", "a", "WaveType", "according", "to", "its", "unique", "action", "name", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/wave/WaveTypeRegistry.java#L65-L72
8,493
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/image/ImageBuilder.java
ImageBuilder.buildWebImage
private Image buildWebImage(final WebImage jrImage) { final String url = jrImage.getUrl(); Image image = null; if (url == null || url.isEmpty()) { LOGGER.error("Image : {} not found !", url); } else { image = new Image(url); } return image; }
java
private Image buildWebImage(final WebImage jrImage) { final String url = jrImage.getUrl(); Image image = null; if (url == null || url.isEmpty()) { LOGGER.error("Image : {} not found !", url); } else { image = new Image(url); } return image; }
[ "private", "Image", "buildWebImage", "(", "final", "WebImage", "jrImage", ")", "{", "final", "String", "url", "=", "jrImage", ".", "getUrl", "(", ")", ";", "Image", "image", "=", "null", ";", "if", "(", "url", "==", "null", "||", "url", ".", "isEmpty", "(", ")", ")", "{", "LOGGER", ".", "error", "(", "\"Image : {} not found !\"", ",", "url", ")", ";", "}", "else", "{", "image", "=", "new", "Image", "(", "url", ")", ";", "}", "return", "image", ";", "}" ]
Build a web image with its url parameters. @param jrImage the web image params @return the JavaFX image object
[ "Build", "a", "web", "image", "with", "its", "url", "parameters", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/image/ImageBuilder.java#L116-L127
8,494
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/image/ImageBuilder.java
ImageBuilder.loadImage
private Image loadImage(final String resourceName, final boolean skipImagesFolder) { Image image = null; final List<String> imagePaths = skipImagesFolder ? Collections.singletonList("") : ResourceParameters.IMAGE_FOLDER.get(); for (int i = 0; i < imagePaths.size() && image == null; i++) { String imagePath = imagePaths.get(i); if (!imagePath.isEmpty()) { imagePath += Resources.PATH_SEP; } final InputStream imageInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(imagePath + resourceName); if (imageInputStream != null) { image = new Image(imageInputStream); } } if (image == null) { LOGGER.error("Image : {} not found into base folder: {}", resourceName, ResourceParameters.IMAGE_FOLDER.get()); } return image; }
java
private Image loadImage(final String resourceName, final boolean skipImagesFolder) { Image image = null; final List<String> imagePaths = skipImagesFolder ? Collections.singletonList("") : ResourceParameters.IMAGE_FOLDER.get(); for (int i = 0; i < imagePaths.size() && image == null; i++) { String imagePath = imagePaths.get(i); if (!imagePath.isEmpty()) { imagePath += Resources.PATH_SEP; } final InputStream imageInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(imagePath + resourceName); if (imageInputStream != null) { image = new Image(imageInputStream); } } if (image == null) { LOGGER.error("Image : {} not found into base folder: {}", resourceName, ResourceParameters.IMAGE_FOLDER.get()); } return image; }
[ "private", "Image", "loadImage", "(", "final", "String", "resourceName", ",", "final", "boolean", "skipImagesFolder", ")", "{", "Image", "image", "=", "null", ";", "final", "List", "<", "String", ">", "imagePaths", "=", "skipImagesFolder", "?", "Collections", ".", "singletonList", "(", "\"\"", ")", ":", "ResourceParameters", ".", "IMAGE_FOLDER", ".", "get", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "imagePaths", ".", "size", "(", ")", "&&", "image", "==", "null", ";", "i", "++", ")", "{", "String", "imagePath", "=", "imagePaths", ".", "get", "(", "i", ")", ";", "if", "(", "!", "imagePath", ".", "isEmpty", "(", ")", ")", "{", "imagePath", "+=", "Resources", ".", "PATH_SEP", ";", "}", "final", "InputStream", "imageInputStream", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResourceAsStream", "(", "imagePath", "+", "resourceName", ")", ";", "if", "(", "imageInputStream", "!=", "null", ")", "{", "image", "=", "new", "Image", "(", "imageInputStream", ")", ";", "}", "}", "if", "(", "image", "==", "null", ")", "{", "LOGGER", ".", "error", "(", "\"Image : {} not found into base folder: {}\"", ",", "resourceName", ",", "ResourceParameters", ".", "IMAGE_FOLDER", ".", "get", "(", ")", ")", ";", "}", "return", "image", ";", "}" ]
Load an image. @param resourceName the name of the image, path must be separated by '/' @param skipImagesFolder skip imagesFolder prefix addition @return the image loaded
[ "Load", "an", "image", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/resource/image/ImageBuilder.java#L138-L157
8,495
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java
ClassUtility.buildGenericType
public static Object buildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Object... parameters) throws CoreException { return buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters); }
java
public static Object buildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Object... parameters) throws CoreException { return buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters); }
[ "public", "static", "Object", "buildGenericType", "(", "final", "Class", "<", "?", ">", "mainClass", ",", "final", "Class", "<", "?", ">", "assignableClass", ",", "final", "Object", "...", "parameters", ")", "throws", "CoreException", "{", "return", "buildGenericType", "(", "mainClass", ",", "new", "Class", "<", "?", ">", "[", "]", "{", "assignableClass", "}", ",", "parameters", ")", ";", "}" ]
Build the nth generic type of a class. @param mainClass The main class used (that contain at least one generic type) @param assignableClass the parent type of the generic to build @param parameters used by the constructor of the generic type @return a new instance of the generic type @throws CoreException if the instantiation fails
[ "Build", "the", "nth", "generic", "type", "of", "a", "class", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L85-L87
8,496
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java
ClassUtility.buildGenericType
public static Object buildGenericType(final Class<?> mainClass, final Class<?>[] assignableClasses, final Object... constructorParameters) throws CoreException { Class<?> genericClass = null; // Copy parameters type to find the right constructor final Class<?>[] constructorParameterTypes = new Class<?>[constructorParameters.length]; try { int i = 0; for (final Object obj : constructorParameters) { constructorParameterTypes[i] = obj.getClass(); i++; } genericClass = findGenericClass(mainClass, assignableClasses); // Find the right constructor and use arguments to create a new instance final Constructor<?> constructor = getConstructor(genericClass, constructorParameterTypes); return constructor.newInstance(constructorParameters); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { final StringBuilder sb = new StringBuilder("["); for (final Class<?> assignableClass : assignableClasses) { sb.append(assignableClass.getName()).append(", "); } sb.append("]"); if (genericClass == null) { LOGGER.log(GENERIC_TYPE_ERROR_1, e, sb.toString(), mainClass.getName()); } else { LOGGER.log(GENERIC_TYPE_ERROR_2, e, genericClass.getName(), mainClass.getName()); } if (e instanceof IllegalArgumentException) { LOGGER.log(ARGUMENT_LIST); for (int i = 0; i < constructorParameterTypes.length; i++) { LOGGER.log(ARGUMENT_DETAIL, constructorParameterTypes[i].toString(), constructorParameters[i].toString()); } } if (genericClass == null) { throw new CoreException(GENERIC_TYPE_ERROR_1.getText(sb.toString(), mainClass.getName()), e); } else { throw new CoreException(GENERIC_TYPE_ERROR_2.getText(genericClass.getName(), mainClass.getName()), e); } } }
java
public static Object buildGenericType(final Class<?> mainClass, final Class<?>[] assignableClasses, final Object... constructorParameters) throws CoreException { Class<?> genericClass = null; // Copy parameters type to find the right constructor final Class<?>[] constructorParameterTypes = new Class<?>[constructorParameters.length]; try { int i = 0; for (final Object obj : constructorParameters) { constructorParameterTypes[i] = obj.getClass(); i++; } genericClass = findGenericClass(mainClass, assignableClasses); // Find the right constructor and use arguments to create a new instance final Constructor<?> constructor = getConstructor(genericClass, constructorParameterTypes); return constructor.newInstance(constructorParameters); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { final StringBuilder sb = new StringBuilder("["); for (final Class<?> assignableClass : assignableClasses) { sb.append(assignableClass.getName()).append(", "); } sb.append("]"); if (genericClass == null) { LOGGER.log(GENERIC_TYPE_ERROR_1, e, sb.toString(), mainClass.getName()); } else { LOGGER.log(GENERIC_TYPE_ERROR_2, e, genericClass.getName(), mainClass.getName()); } if (e instanceof IllegalArgumentException) { LOGGER.log(ARGUMENT_LIST); for (int i = 0; i < constructorParameterTypes.length; i++) { LOGGER.log(ARGUMENT_DETAIL, constructorParameterTypes[i].toString(), constructorParameters[i].toString()); } } if (genericClass == null) { throw new CoreException(GENERIC_TYPE_ERROR_1.getText(sb.toString(), mainClass.getName()), e); } else { throw new CoreException(GENERIC_TYPE_ERROR_2.getText(genericClass.getName(), mainClass.getName()), e); } } }
[ "public", "static", "Object", "buildGenericType", "(", "final", "Class", "<", "?", ">", "mainClass", ",", "final", "Class", "<", "?", ">", "[", "]", "assignableClasses", ",", "final", "Object", "...", "constructorParameters", ")", "throws", "CoreException", "{", "Class", "<", "?", ">", "genericClass", "=", "null", ";", "// Copy parameters type to find the right constructor", "final", "Class", "<", "?", ">", "[", "]", "constructorParameterTypes", "=", "new", "Class", "<", "?", ">", "[", "constructorParameters", ".", "length", "]", ";", "try", "{", "int", "i", "=", "0", ";", "for", "(", "final", "Object", "obj", ":", "constructorParameters", ")", "{", "constructorParameterTypes", "[", "i", "]", "=", "obj", ".", "getClass", "(", ")", ";", "i", "++", ";", "}", "genericClass", "=", "findGenericClass", "(", "mainClass", ",", "assignableClasses", ")", ";", "// Find the right constructor and use arguments to create a new instance", "final", "Constructor", "<", "?", ">", "constructor", "=", "getConstructor", "(", "genericClass", ",", "constructorParameterTypes", ")", ";", "return", "constructor", ".", "newInstance", "(", "constructorParameters", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "|", "IllegalArgumentException", "|", "InvocationTargetException", "|", "SecurityException", "e", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"[\"", ")", ";", "for", "(", "final", "Class", "<", "?", ">", "assignableClass", ":", "assignableClasses", ")", "{", "sb", ".", "append", "(", "assignableClass", ".", "getName", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "if", "(", "genericClass", "==", "null", ")", "{", "LOGGER", ".", "log", "(", "GENERIC_TYPE_ERROR_1", ",", "e", ",", "sb", ".", "toString", "(", ")", ",", "mainClass", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "LOGGER", ".", "log", "(", "GENERIC_TYPE_ERROR_2", ",", "e", ",", "genericClass", ".", "getName", "(", ")", ",", "mainClass", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "e", "instanceof", "IllegalArgumentException", ")", "{", "LOGGER", ".", "log", "(", "ARGUMENT_LIST", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "constructorParameterTypes", ".", "length", ";", "i", "++", ")", "{", "LOGGER", ".", "log", "(", "ARGUMENT_DETAIL", ",", "constructorParameterTypes", "[", "i", "]", ".", "toString", "(", ")", ",", "constructorParameters", "[", "i", "]", ".", "toString", "(", ")", ")", ";", "}", "}", "if", "(", "genericClass", "==", "null", ")", "{", "throw", "new", "CoreException", "(", "GENERIC_TYPE_ERROR_1", ".", "getText", "(", "sb", ".", "toString", "(", ")", ",", "mainClass", ".", "getName", "(", ")", ")", ",", "e", ")", ";", "}", "else", "{", "throw", "new", "CoreException", "(", "GENERIC_TYPE_ERROR_2", ".", "getText", "(", "genericClass", ".", "getName", "(", ")", ",", "mainClass", ".", "getName", "(", ")", ")", ",", "e", ")", ";", "}", "}", "}" ]
Build the generic type according to assignable class. @param mainClass The main class used (that contain at least one generic type) @param assignableClasses if the array contains only one class it define the type of the generic to build, otherwise it defines the types to skip to find the obejct to build @param constructorParameters used by the constructor of the generic type @return a new instance of the generic type @throws CoreException if the instantiation fails
[ "Build", "the", "generic", "type", "according", "to", "assignable", "class", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L100-L147
8,497
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java
ClassUtility.findAndBuildGenericType
public static Object findAndBuildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Class<?> excludedClass, final Object... parameters) throws CoreException { Object object = null; final Class<?> objectClass = ClassUtility.findGenericClass(mainClass, assignableClass); if (objectClass != null && (excludedClass == null || !excludedClass.equals(objectClass))) { object = buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters); } return object; }
java
public static Object findAndBuildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Class<?> excludedClass, final Object... parameters) throws CoreException { Object object = null; final Class<?> objectClass = ClassUtility.findGenericClass(mainClass, assignableClass); if (objectClass != null && (excludedClass == null || !excludedClass.equals(objectClass))) { object = buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters); } return object; }
[ "public", "static", "Object", "findAndBuildGenericType", "(", "final", "Class", "<", "?", ">", "mainClass", ",", "final", "Class", "<", "?", ">", "assignableClass", ",", "final", "Class", "<", "?", ">", "excludedClass", ",", "final", "Object", "...", "parameters", ")", "throws", "CoreException", "{", "Object", "object", "=", "null", ";", "final", "Class", "<", "?", ">", "objectClass", "=", "ClassUtility", ".", "findGenericClass", "(", "mainClass", ",", "assignableClass", ")", ";", "if", "(", "objectClass", "!=", "null", "&&", "(", "excludedClass", "==", "null", "||", "!", "excludedClass", ".", "equals", "(", "objectClass", ")", ")", ")", "{", "object", "=", "buildGenericType", "(", "mainClass", ",", "new", "Class", "<", "?", ">", "[", "]", "{", "assignableClass", "}", ",", "parameters", ")", ";", "}", "return", "object", ";", "}" ]
Find and Build the generic type according to assignable and excluded classes. @param mainClass The main class used (that contains at least one generic type) @param assignableClasses if the array contains only one class it define the type of the generic to build, otherwise it defines the types to skip to find the obejct to build @param excludedClass the class that shouldn't be retrieved (ie: NullXX class) @param parameters used by the constructor of the generic type @return the first generic type of a class that is compatible with provided assignable class. @throws CoreException if the class cannot be found and is not an excluded class
[ "Find", "and", "Build", "the", "generic", "type", "according", "to", "assignable", "and", "excluded", "classes", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L161-L170
8,498
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java
ClassUtility.getConstructor
private static Constructor<?> getConstructor(final Class<?> genericClass, final Class<?>[] constructorParameterTypes) { Constructor<?> constructor = null; try { constructor = genericClass.getConstructor(constructorParameterTypes); } catch (final NoSuchMethodException e) { // Return the first constructor as a workaround constructor = genericClass.getConstructors()[0]; } catch (final SecurityException e) { LOGGER.log(NO_CONSTRUCTOR, e); throw e; // Pop up the exception to let it managed by the caller method } return constructor; }
java
private static Constructor<?> getConstructor(final Class<?> genericClass, final Class<?>[] constructorParameterTypes) { Constructor<?> constructor = null; try { constructor = genericClass.getConstructor(constructorParameterTypes); } catch (final NoSuchMethodException e) { // Return the first constructor as a workaround constructor = genericClass.getConstructors()[0]; } catch (final SecurityException e) { LOGGER.log(NO_CONSTRUCTOR, e); throw e; // Pop up the exception to let it managed by the caller method } return constructor; }
[ "private", "static", "Constructor", "<", "?", ">", "getConstructor", "(", "final", "Class", "<", "?", ">", "genericClass", ",", "final", "Class", "<", "?", ">", "[", "]", "constructorParameterTypes", ")", "{", "Constructor", "<", "?", ">", "constructor", "=", "null", ";", "try", "{", "constructor", "=", "genericClass", ".", "getConstructor", "(", "constructorParameterTypes", ")", ";", "}", "catch", "(", "final", "NoSuchMethodException", "e", ")", "{", "// Return the first constructor as a workaround", "constructor", "=", "genericClass", ".", "getConstructors", "(", ")", "[", "0", "]", ";", "}", "catch", "(", "final", "SecurityException", "e", ")", "{", "LOGGER", ".", "log", "(", "NO_CONSTRUCTOR", ",", "e", ")", ";", "throw", "e", ";", "// Pop up the exception to let it managed by the caller method", "}", "return", "constructor", ";", "}" ]
Retrieve the constructor of a Type. @param genericClass the type of the object @param constructorParameterTypes an array of parameters' type to find the right constructor @return the right constructor that matchers parameters
[ "Retrieve", "the", "constructor", "of", "a", "Type", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L180-L192
8,499
JRebirth/JRebirth
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java
ClassUtility.underscoreToCamelCase
public static String underscoreToCamelCase(final String undescoredString) { // Split the string for each underscore final String[] parts = undescoredString.split(CASE_SEPARATOR); final StringBuilder camelCaseString = new StringBuilder(undescoredString.length()); camelCaseString.append(parts[0].toLowerCase(Locale.getDefault())); // Skip the first part already added for (int i = 1; i < parts.length; i++) { // First letter to upper case camelCaseString.append(parts[i].substring(0, 1).toUpperCase(Locale.getDefault())); // Others to lower case camelCaseString.append(parts[i].substring(1).toLowerCase(Locale.getDefault())); } return camelCaseString.toString(); }
java
public static String underscoreToCamelCase(final String undescoredString) { // Split the string for each underscore final String[] parts = undescoredString.split(CASE_SEPARATOR); final StringBuilder camelCaseString = new StringBuilder(undescoredString.length()); camelCaseString.append(parts[0].toLowerCase(Locale.getDefault())); // Skip the first part already added for (int i = 1; i < parts.length; i++) { // First letter to upper case camelCaseString.append(parts[i].substring(0, 1).toUpperCase(Locale.getDefault())); // Others to lower case camelCaseString.append(parts[i].substring(1).toLowerCase(Locale.getDefault())); } return camelCaseString.toString(); }
[ "public", "static", "String", "underscoreToCamelCase", "(", "final", "String", "undescoredString", ")", "{", "// Split the string for each underscore", "final", "String", "[", "]", "parts", "=", "undescoredString", ".", "split", "(", "CASE_SEPARATOR", ")", ";", "final", "StringBuilder", "camelCaseString", "=", "new", "StringBuilder", "(", "undescoredString", ".", "length", "(", ")", ")", ";", "camelCaseString", ".", "append", "(", "parts", "[", "0", "]", ".", "toLowerCase", "(", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "// Skip the first part already added", "for", "(", "int", "i", "=", "1", ";", "i", "<", "parts", ".", "length", ";", "i", "++", ")", "{", "// First letter to upper case", "camelCaseString", ".", "append", "(", "parts", "[", "i", "]", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "// Others to lower case", "camelCaseString", ".", "append", "(", "parts", "[", "i", "]", ".", "substring", "(", "1", ")", ".", "toLowerCase", "(", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "return", "camelCaseString", ".", "toString", "(", ")", ";", "}" ]
Convert A_STRING_UNDESCORED into aStringUnderscored. @param undescoredString the string to convert @return the string with camelCase
[ "Convert", "A_STRING_UNDESCORED", "into", "aStringUnderscored", "." ]
93f4fc087b83c73db540333b9686e97b4cec694d
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L251-L267