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
12,000
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.getOrCreateFaceDescriptor
private CommandFaceDescriptor getOrCreateFaceDescriptor() { if (!isFaceConfigured()) { if (logger.isInfoEnabled()) { logger.info("Lazily instantiating default face descriptor on behalf of caller to prevent npe; " + "command is being configured manually, right?"); } if(ValkyrieRepository.isCurrentlyRunningInContext()) { ValkyrieRepository.getInstance().getApplicationConfig().commandConfigurer().configure(this); } else { setFaceDescriptor(new CommandFaceDescriptor()); } } return getFaceDescriptor(); }
java
private CommandFaceDescriptor getOrCreateFaceDescriptor() { if (!isFaceConfigured()) { if (logger.isInfoEnabled()) { logger.info("Lazily instantiating default face descriptor on behalf of caller to prevent npe; " + "command is being configured manually, right?"); } if(ValkyrieRepository.isCurrentlyRunningInContext()) { ValkyrieRepository.getInstance().getApplicationConfig().commandConfigurer().configure(this); } else { setFaceDescriptor(new CommandFaceDescriptor()); } } return getFaceDescriptor(); }
[ "private", "CommandFaceDescriptor", "getOrCreateFaceDescriptor", "(", ")", "{", "if", "(", "!", "isFaceConfigured", "(", ")", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Lazily instantiating default face descriptor on behalf of caller to prevent npe; \"", "+", "\"command is being configured manually, right?\"", ")", ";", "}", "if", "(", "ValkyrieRepository", ".", "isCurrentlyRunningInContext", "(", ")", ")", "{", "ValkyrieRepository", ".", "getInstance", "(", ")", ".", "getApplicationConfig", "(", ")", ".", "commandConfigurer", "(", ")", ".", "configure", "(", "this", ")", ";", "}", "else", "{", "setFaceDescriptor", "(", "new", "CommandFaceDescriptor", "(", ")", ")", ";", "}", "}", "return", "getFaceDescriptor", "(", ")", ";", "}" ]
Returns the defaultFaceDescriptor. Creates one if needed.
[ "Returns", "the", "defaultFaceDescriptor", ".", "Creates", "one", "if", "needed", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L350-L363
12,001
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createButton
public final AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory) { return createButton(faceDescriptorId, buttonFactory, getDefaultButtonConfigurer()); }
java
public final AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory) { return createButton(faceDescriptorId, buttonFactory, getDefaultButtonConfigurer()); }
[ "public", "final", "AbstractButton", "createButton", "(", "String", "faceDescriptorId", ",", "ButtonFactory", "buttonFactory", ")", "{", "return", "createButton", "(", "faceDescriptorId", ",", "buttonFactory", ",", "getDefaultButtonConfigurer", "(", ")", ")", ";", "}" ]
Create a button using the default buttonConfigurer. @see #createButton(String, ButtonFactory, CommandButtonConfigurer)
[ "Create", "a", "button", "using", "the", "default", "buttonConfigurer", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L757-L759
12,002
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createButton
public final AbstractButton createButton(ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer) { return createButton(getDefaultFaceDescriptorId(), buttonFactory, buttonConfigurer); }
java
public final AbstractButton createButton(ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer) { return createButton(getDefaultFaceDescriptorId(), buttonFactory, buttonConfigurer); }
[ "public", "final", "AbstractButton", "createButton", "(", "ButtonFactory", "buttonFactory", ",", "CommandButtonConfigurer", "buttonConfigurer", ")", "{", "return", "createButton", "(", "getDefaultFaceDescriptorId", "(", ")", ",", "buttonFactory", ",", "buttonConfigurer", ")", ";", "}" ]
Create a button using the default buttonFactory. @see #createButton(String, ButtonFactory, CommandButtonConfigurer)
[ "Create", "a", "button", "using", "the", "default", "buttonFactory", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L766-L768
12,003
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createButton
public AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer) { AbstractButton button = buttonFactory.createButton(); attach(button, faceDescriptorId, buttonConfigurer); return button; }
java
public AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer) { AbstractButton button = buttonFactory.createButton(); attach(button, faceDescriptorId, buttonConfigurer); return button; }
[ "public", "AbstractButton", "createButton", "(", "String", "faceDescriptorId", ",", "ButtonFactory", "buttonFactory", ",", "CommandButtonConfigurer", "buttonConfigurer", ")", "{", "AbstractButton", "button", "=", "buttonFactory", ".", "createButton", "(", ")", ";", "attach", "(", "button", ",", "faceDescriptorId", ",", "buttonConfigurer", ")", ";", "return", "button", ";", "}" ]
Creates a button using the provided id, factory and configurer. @param faceDescriptorId id of the faceDescriptor used to configure the button. @param buttonFactory factory that delivers the button. @param buttonConfigurer configurer mapping the faceDescriptor on the button. @return a button attached to this command.
[ "Creates", "a", "button", "using", "the", "provided", "id", "factory", "and", "configurer", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L780-L785
12,004
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createMenuItem
public final JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory) { return createMenuItem(faceDescriptorId, menuFactory, getMenuItemButtonConfigurer()); }
java
public final JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory) { return createMenuItem(faceDescriptorId, menuFactory, getMenuItemButtonConfigurer()); }
[ "public", "final", "JMenuItem", "createMenuItem", "(", "String", "faceDescriptorId", ",", "MenuFactory", "menuFactory", ")", "{", "return", "createMenuItem", "(", "faceDescriptorId", ",", "menuFactory", ",", "getMenuItemButtonConfigurer", "(", ")", ")", ";", "}" ]
Create a menuItem using the default and menuItemButtonConfigurer. @see #createMenuItem(String, MenuFactory, CommandButtonConfigurer)
[ "Create", "a", "menuItem", "using", "the", "default", "and", "menuItemButtonConfigurer", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L822-L824
12,005
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createMenuItem
public final JMenuItem createMenuItem(MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer) { return createMenuItem(getDefaultFaceDescriptorId(), menuFactory, buttonConfigurer); }
java
public final JMenuItem createMenuItem(MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer) { return createMenuItem(getDefaultFaceDescriptorId(), menuFactory, buttonConfigurer); }
[ "public", "final", "JMenuItem", "createMenuItem", "(", "MenuFactory", "menuFactory", ",", "CommandButtonConfigurer", "buttonConfigurer", ")", "{", "return", "createMenuItem", "(", "getDefaultFaceDescriptorId", "(", ")", ",", "menuFactory", ",", "buttonConfigurer", ")", ";", "}" ]
Create a menuItem using the default faceDescriptorId. @see #createMenuItem(String, MenuFactory, CommandButtonConfigurer)
[ "Create", "a", "menuItem", "using", "the", "default", "faceDescriptorId", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L831-L833
12,006
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.createMenuItem
public JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer) { JMenuItem menuItem = menuFactory.createMenuItem(); attach(menuItem, faceDescriptorId, buttonConfigurer); return menuItem; }
java
public JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer) { JMenuItem menuItem = menuFactory.createMenuItem(); attach(menuItem, faceDescriptorId, buttonConfigurer); return menuItem; }
[ "public", "JMenuItem", "createMenuItem", "(", "String", "faceDescriptorId", ",", "MenuFactory", "menuFactory", ",", "CommandButtonConfigurer", "buttonConfigurer", ")", "{", "JMenuItem", "menuItem", "=", "menuFactory", ".", "createMenuItem", "(", ")", ";", "attach", "(", "menuItem", ",", "faceDescriptorId", ",", "buttonConfigurer", ")", ";", "return", "menuItem", ";", "}" ]
Create a menuItem using the provided id, factory and configurer. @param faceDescriptorId id of the faceDescriptor used to configure the button. @param menuFactory factory that delivers the menuItem. @param buttonConfigurer configurer mapping the faceDescriptor on the button. @return a menuItem attached to this command.
[ "Create", "a", "menuItem", "using", "the", "provided", "id", "factory", "and", "configurer", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L845-L850
12,007
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.attach
public void attach(AbstractButton button, String faceDescriptorId, CommandButtonConfigurer configurer) { getButtonManager(faceDescriptorId).attachAndConfigure(button, configurer); onButtonAttached(button); }
java
public void attach(AbstractButton button, String faceDescriptorId, CommandButtonConfigurer configurer) { getButtonManager(faceDescriptorId).attachAndConfigure(button, configurer); onButtonAttached(button); }
[ "public", "void", "attach", "(", "AbstractButton", "button", ",", "String", "faceDescriptorId", ",", "CommandButtonConfigurer", "configurer", ")", "{", "getButtonManager", "(", "faceDescriptorId", ")", ".", "attachAndConfigure", "(", "button", ",", "configurer", ")", ";", "onButtonAttached", "(", "button", ")", ";", "}" ]
Attach and configure the button to the faceDescriptorId using the configurer. @param button the button to attach and configure. @param faceDescriptorId the id of the faceDescriptor. @param configurer that maps the faceDescriptor on the button.
[ "Attach", "and", "configure", "the", "button", "to", "the", "faceDescriptorId", "using", "the", "configurer", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L879-L882
12,008
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.onButtonAttached
protected void onButtonAttached(AbstractButton button) { if (logger.isDebugEnabled()) { logger.debug("Configuring newly attached button for command '" + getId() + "' enabled=" + isEnabled() + ", visible=" + isVisible()); } button.setEnabled(isEnabled()); button.setVisible(isVisible()); }
java
protected void onButtonAttached(AbstractButton button) { if (logger.isDebugEnabled()) { logger.debug("Configuring newly attached button for command '" + getId() + "' enabled=" + isEnabled() + ", visible=" + isVisible()); } button.setEnabled(isEnabled()); button.setVisible(isVisible()); }
[ "protected", "void", "onButtonAttached", "(", "AbstractButton", "button", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Configuring newly attached button for command '\"", "+", "getId", "(", ")", "+", "\"' enabled=\"", "+", "isEnabled", "(", ")", "+", "\", visible=\"", "+", "isVisible", "(", ")", ")", ";", "}", "button", ".", "setEnabled", "(", "isEnabled", "(", ")", ")", ";", "button", ".", "setVisible", "(", "isVisible", "(", ")", ")", ";", "}" ]
Additional code to execute when attaching a button. @param button the button that has been attached.
[ "Additional", "code", "to", "execute", "when", "attaching", "a", "button", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L889-L896
12,009
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.requestFocusIn
public boolean requestFocusIn(Container container) { AbstractButton button = getButtonIn(container); if (button != null) { return button.requestFocusInWindow(); } return false; }
java
public boolean requestFocusIn(Container container) { AbstractButton button = getButtonIn(container); if (button != null) { return button.requestFocusInWindow(); } return false; }
[ "public", "boolean", "requestFocusIn", "(", "Container", "container", ")", "{", "AbstractButton", "button", "=", "getButtonIn", "(", "container", ")", ";", "if", "(", "button", "!=", "null", ")", "{", "return", "button", ".", "requestFocusInWindow", "(", ")", ";", "}", "return", "false", ";", "}" ]
Search for a button representing this command in the provided container and let it request the focus. @param container the container which holds the command button. @return <code>true</code> if the focus request is likely to succeed. @see #getButtonIn(Container) @see JComponent#requestFocusInWindow()
[ "Search", "for", "a", "button", "representing", "this", "command", "in", "the", "provided", "container", "and", "let", "it", "request", "the", "focus", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L1016-L1022
12,010
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java
AbstractCommand.getButtonIn
public AbstractButton getButtonIn(Container container) { Iterator it = buttonIterator(); while (it.hasNext()) { AbstractButton button = (AbstractButton) it.next(); if (SwingUtilities.isDescendingFrom(button, container)) { return button; } } return null; }
java
public AbstractButton getButtonIn(Container container) { Iterator it = buttonIterator(); while (it.hasNext()) { AbstractButton button = (AbstractButton) it.next(); if (SwingUtilities.isDescendingFrom(button, container)) { return button; } } return null; }
[ "public", "AbstractButton", "getButtonIn", "(", "Container", "container", ")", "{", "Iterator", "it", "=", "buttonIterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "AbstractButton", "button", "=", "(", "AbstractButton", ")", "it", ".", "next", "(", ")", ";", "if", "(", "SwingUtilities", ".", "isDescendingFrom", "(", "button", ",", "container", ")", ")", "{", "return", "button", ";", "}", "}", "return", "null", ";", "}" ]
Search for the first button of this command that is a child component of the given container. @param container the container to be searched. @return the {@link AbstractButton} representing this command that is embedded in the container or <code>null</code> if none was found.
[ "Search", "for", "the", "first", "button", "of", "this", "command", "that", "is", "a", "child", "component", "of", "the", "given", "container", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/AbstractCommand.java#L1032-L1041
12,011
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java
ClassUtils.initializeClass
public static void initializeClass(Class clazz) { try { Class.forName(clazz.getName(), true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
java
public static void initializeClass(Class clazz) { try { Class.forName(clazz.getName(), true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
[ "public", "static", "void", "initializeClass", "(", "Class", "clazz", ")", "{", "try", "{", "Class", ".", "forName", "(", "clazz", ".", "getName", "(", ")", ",", "true", ",", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Intializes the specified class if not initialized already. This is required for EnumUtils if the enum class has not yet been loaded.
[ "Intializes", "the", "specified", "class", "if", "not", "initialized", "already", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java#L68-L75
12,012
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java
ClassUtils.getFieldValue
public static Object getFieldValue(String qualifiedFieldName) { Class clazz; try { clazz = classForName(ClassUtils.qualifier(qualifiedFieldName)); } catch (ClassNotFoundException cnfe) { return null; } try { return clazz.getField(ClassUtils.unqualify(qualifiedFieldName)).get(null); } catch (Exception e) { return null; } }
java
public static Object getFieldValue(String qualifiedFieldName) { Class clazz; try { clazz = classForName(ClassUtils.qualifier(qualifiedFieldName)); } catch (ClassNotFoundException cnfe) { return null; } try { return clazz.getField(ClassUtils.unqualify(qualifiedFieldName)).get(null); } catch (Exception e) { return null; } }
[ "public", "static", "Object", "getFieldValue", "(", "String", "qualifiedFieldName", ")", "{", "Class", "clazz", ";", "try", "{", "clazz", "=", "classForName", "(", "ClassUtils", ".", "qualifier", "(", "qualifiedFieldName", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "cnfe", ")", "{", "return", "null", ";", "}", "try", "{", "return", "clazz", ".", "getField", "(", "ClassUtils", ".", "unqualify", "(", "qualifiedFieldName", ")", ")", ".", "get", "(", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}" ]
Gets the field value for the specified qualified field name.
[ "Gets", "the", "field", "value", "for", "the", "specified", "qualified", "field", "name", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java#L104-L118
12,013
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java
ClassUtils.classForName
public static Class classForName(String name) throws ClassNotFoundException { try { return Thread.currentThread().getContextClassLoader().loadClass(name); } catch (Exception e) { return Class.forName(name); } }
java
public static Class classForName(String name) throws ClassNotFoundException { try { return Thread.currentThread().getContextClassLoader().loadClass(name); } catch (Exception e) { return Class.forName(name); } }
[ "public", "static", "Class", "classForName", "(", "String", "name", ")", "throws", "ClassNotFoundException", "{", "try", "{", "return", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "loadClass", "(", "name", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "Class", ".", "forName", "(", "name", ")", ";", "}", "}" ]
Load the class with the specified name. @param name @return The loaded class. @throws ClassNotFoundException
[ "Load", "the", "class", "with", "the", "specified", "name", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java#L127-L134
12,014
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java
ClassUtils.qualifier
public static String qualifier(String qualifiedName) { int loc = qualifiedName.lastIndexOf('.'); if (loc < 0) return ""; return qualifiedName.substring(0, loc); }
java
public static String qualifier(String qualifiedName) { int loc = qualifiedName.lastIndexOf('.'); if (loc < 0) return ""; return qualifiedName.substring(0, loc); }
[ "public", "static", "String", "qualifier", "(", "String", "qualifiedName", ")", "{", "int", "loc", "=", "qualifiedName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "loc", "<", "0", ")", "return", "\"\"", ";", "return", "qualifiedName", ".", "substring", "(", "0", ",", "loc", ")", ";", "}" ]
Returns the qualifier for a name separated by dots. The qualified part is everything up to the last dot separator. @param qualifiedName The qualified name. @return The qualifier portion.
[ "Returns", "the", "qualifier", "for", "a", "name", "separated", "by", "dots", ".", "The", "qualified", "part", "is", "everything", "up", "to", "the", "last", "dot", "separator", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java#L170-L176
12,015
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java
ClassUtils.convertPrimitiveToWrapper
public static Class convertPrimitiveToWrapper(Class clazz) { if (clazz == null || !clazz.isPrimitive()) return clazz; return (Class) primativeToWrapperMap.get(clazz); }
java
public static Class convertPrimitiveToWrapper(Class clazz) { if (clazz == null || !clazz.isPrimitive()) return clazz; return (Class) primativeToWrapperMap.get(clazz); }
[ "public", "static", "Class", "convertPrimitiveToWrapper", "(", "Class", "clazz", ")", "{", "if", "(", "clazz", "==", "null", "||", "!", "clazz", ".", "isPrimitive", "(", ")", ")", "return", "clazz", ";", "return", "(", "Class", ")", "primativeToWrapperMap", ".", "get", "(", "clazz", ")", ";", "}" ]
Gets the equivalent class to convert to if the given clazz is a primitive. @param clazz Class to examin. @return the class to convert to or the inputted clazz.
[ "Gets", "the", "equivalent", "class", "to", "convert", "to", "if", "the", "given", "clazz", "is", "a", "primitive", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/ClassUtils.java#L229-L234
12,016
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.setTargetClass
protected void setTargetClass(Class targetClass) { this.targetClass = targetClass; this.readAccessors.clear(); this.writeAccessors.clear(); introspectMethods(targetClass, new HashSet()); if (isFieldAccessEnabled()) { introspectFields(targetClass, new HashSet()); } }
java
protected void setTargetClass(Class targetClass) { this.targetClass = targetClass; this.readAccessors.clear(); this.writeAccessors.clear(); introspectMethods(targetClass, new HashSet()); if (isFieldAccessEnabled()) { introspectFields(targetClass, new HashSet()); } }
[ "protected", "void", "setTargetClass", "(", "Class", "targetClass", ")", "{", "this", ".", "targetClass", "=", "targetClass", ";", "this", ".", "readAccessors", ".", "clear", "(", ")", ";", "this", ".", "writeAccessors", ".", "clear", "(", ")", ";", "introspectMethods", "(", "targetClass", ",", "new", "HashSet", "(", ")", ")", ";", "if", "(", "isFieldAccessEnabled", "(", ")", ")", "{", "introspectFields", "(", "targetClass", ",", "new", "HashSet", "(", ")", ")", ";", "}", "}" ]
Clears all cached members and introspect methods again. If fieldAccess is enabled introspect fields as well. @param targetClass the target class.
[ "Clears", "all", "cached", "members", "and", "introspect", "methods", "again", ".", "If", "fieldAccess", "is", "enabled", "introspect", "fields", "as", "well", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L73-L81
12,017
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.introspectFields
private void introspectFields(Class type, Set introspectedClasses) { if (type == null || Object.class.equals(type) || type.isInterface() || introspectedClasses.contains(type)) { return; } introspectedClasses.add(type); introspectFields(type.getSuperclass(), introspectedClasses); Field[] fields = type.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (!Modifier.isStatic(fields[i].getModifiers())) { readAccessors.put(fields[i].getName(), fields[i]); if (!Modifier.isFinal(fields[i].getModifiers())) { writeAccessors.put(fields[i].getName(), fields[i]); } } } }
java
private void introspectFields(Class type, Set introspectedClasses) { if (type == null || Object.class.equals(type) || type.isInterface() || introspectedClasses.contains(type)) { return; } introspectedClasses.add(type); introspectFields(type.getSuperclass(), introspectedClasses); Field[] fields = type.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (!Modifier.isStatic(fields[i].getModifiers())) { readAccessors.put(fields[i].getName(), fields[i]); if (!Modifier.isFinal(fields[i].getModifiers())) { writeAccessors.put(fields[i].getName(), fields[i]); } } } }
[ "private", "void", "introspectFields", "(", "Class", "type", ",", "Set", "introspectedClasses", ")", "{", "if", "(", "type", "==", "null", "||", "Object", ".", "class", ".", "equals", "(", "type", ")", "||", "type", ".", "isInterface", "(", ")", "||", "introspectedClasses", ".", "contains", "(", "type", ")", ")", "{", "return", ";", "}", "introspectedClasses", ".", "add", "(", "type", ")", ";", "introspectFields", "(", "type", ".", "getSuperclass", "(", ")", ",", "introspectedClasses", ")", ";", "Field", "[", "]", "fields", "=", "type", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "Modifier", ".", "isStatic", "(", "fields", "[", "i", "]", ".", "getModifiers", "(", ")", ")", ")", "{", "readAccessors", ".", "put", "(", "fields", "[", "i", "]", ".", "getName", "(", ")", ",", "fields", "[", "i", "]", ")", ";", "if", "(", "!", "Modifier", ".", "isFinal", "(", "fields", "[", "i", "]", ".", "getModifiers", "(", ")", ")", ")", "{", "writeAccessors", ".", "put", "(", "fields", "[", "i", "]", ".", "getName", "(", ")", ",", "fields", "[", "i", "]", ")", ";", "}", "}", "}", "}" ]
Introspect fields of a class. This excludes static fields and handles final fields as readOnly. @param type the class to inspect. @param introspectedClasses a set of already inspected classes.
[ "Introspect", "fields", "of", "a", "class", ".", "This", "excludes", "static", "fields", "and", "handles", "final", "fields", "as", "readOnly", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L90-L105
12,018
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.introspectMethods
private void introspectMethods(Class type, Set introspectedClasses) { if (type == null || Object.class.equals(type) || introspectedClasses.contains(type)) { return; } introspectedClasses.add(type); Class[] interfaces = type.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { introspectMethods(interfaces[i], introspectedClasses); } introspectMethods(type.getSuperclass(), introspectedClasses); Method[] methods = type.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (methodName.startsWith("get") && methods[i].getParameterTypes().length == 0) { readAccessors.put(getPropertyName(methodName, 3), methods[i]); } else if (methodName.startsWith("is") && methods[i].getParameterTypes().length == 0) { readAccessors.put(getPropertyName(methodName, 2), methods[i]); } else if (methodName.startsWith("set") && methods[i].getParameterTypes().length == 1) { writeAccessors.put(getPropertyName(methodName, 3), methods[i]); } } }
java
private void introspectMethods(Class type, Set introspectedClasses) { if (type == null || Object.class.equals(type) || introspectedClasses.contains(type)) { return; } introspectedClasses.add(type); Class[] interfaces = type.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { introspectMethods(interfaces[i], introspectedClasses); } introspectMethods(type.getSuperclass(), introspectedClasses); Method[] methods = type.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (methodName.startsWith("get") && methods[i].getParameterTypes().length == 0) { readAccessors.put(getPropertyName(methodName, 3), methods[i]); } else if (methodName.startsWith("is") && methods[i].getParameterTypes().length == 0) { readAccessors.put(getPropertyName(methodName, 2), methods[i]); } else if (methodName.startsWith("set") && methods[i].getParameterTypes().length == 1) { writeAccessors.put(getPropertyName(methodName, 3), methods[i]); } } }
[ "private", "void", "introspectMethods", "(", "Class", "type", ",", "Set", "introspectedClasses", ")", "{", "if", "(", "type", "==", "null", "||", "Object", ".", "class", ".", "equals", "(", "type", ")", "||", "introspectedClasses", ".", "contains", "(", "type", ")", ")", "{", "return", ";", "}", "introspectedClasses", ".", "add", "(", "type", ")", ";", "Class", "[", "]", "interfaces", "=", "type", ".", "getInterfaces", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interfaces", ".", "length", ";", "i", "++", ")", "{", "introspectMethods", "(", "interfaces", "[", "i", "]", ",", "introspectedClasses", ")", ";", "}", "introspectMethods", "(", "type", ".", "getSuperclass", "(", ")", ",", "introspectedClasses", ")", ";", "Method", "[", "]", "methods", "=", "type", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methods", ".", "length", ";", "i", "++", ")", "{", "String", "methodName", "=", "methods", "[", "i", "]", ".", "getName", "(", ")", ";", "if", "(", "methodName", ".", "startsWith", "(", "\"get\"", ")", "&&", "methods", "[", "i", "]", ".", "getParameterTypes", "(", ")", ".", "length", "==", "0", ")", "{", "readAccessors", ".", "put", "(", "getPropertyName", "(", "methodName", ",", "3", ")", ",", "methods", "[", "i", "]", ")", ";", "}", "else", "if", "(", "methodName", ".", "startsWith", "(", "\"is\"", ")", "&&", "methods", "[", "i", "]", ".", "getParameterTypes", "(", ")", ".", "length", "==", "0", ")", "{", "readAccessors", ".", "put", "(", "getPropertyName", "(", "methodName", ",", "2", ")", ",", "methods", "[", "i", "]", ")", ";", "}", "else", "if", "(", "methodName", ".", "startsWith", "(", "\"set\"", ")", "&&", "methods", "[", "i", "]", ".", "getParameterTypes", "(", ")", ".", "length", "==", "1", ")", "{", "writeAccessors", ".", "put", "(", "getPropertyName", "(", "methodName", ",", "3", ")", ",", "methods", "[", "i", "]", ")", ";", "}", "}", "}" ]
Introspect class for accessor methods. This includes methods starting with 'get', 'set' and 'is'. @param type class to introspect. @param introspectedClasses set of already inspected classes.
[ "Introspect", "class", "for", "accessor", "methods", ".", "This", "includes", "methods", "starting", "with", "get", "set", "and", "is", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L114-L137
12,019
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.getPropertyAccessor
protected Member getPropertyAccessor(String propertyName) { if (readAccessors.containsKey(propertyName)) { return (Member) readAccessors.get(propertyName); } else { return (Member) writeAccessors.get(propertyName); } }
java
protected Member getPropertyAccessor(String propertyName) { if (readAccessors.containsKey(propertyName)) { return (Member) readAccessors.get(propertyName); } else { return (Member) writeAccessors.get(propertyName); } }
[ "protected", "Member", "getPropertyAccessor", "(", "String", "propertyName", ")", "{", "if", "(", "readAccessors", ".", "containsKey", "(", "propertyName", ")", ")", "{", "return", "(", "Member", ")", "readAccessors", ".", "get", "(", "propertyName", ")", ";", "}", "else", "{", "return", "(", "Member", ")", "writeAccessors", ".", "get", "(", "propertyName", ")", ";", "}", "}" ]
Return any accessor, be it read or write, for the given property. @param propertyName name of the property. @return an accessor for the property or <code>null</code>
[ "Return", "any", "accessor", "be", "it", "read", "or", "write", "for", "the", "given", "property", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L179-L186
12,020
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.getPropertyName
protected String getPropertyName(String methodName, int prefixLength) { return Character.toLowerCase(methodName.charAt(prefixLength)) + methodName.substring(prefixLength + 1); }
java
protected String getPropertyName(String methodName, int prefixLength) { return Character.toLowerCase(methodName.charAt(prefixLength)) + methodName.substring(prefixLength + 1); }
[ "protected", "String", "getPropertyName", "(", "String", "methodName", ",", "int", "prefixLength", ")", "{", "return", "Character", ".", "toLowerCase", "(", "methodName", ".", "charAt", "(", "prefixLength", ")", ")", "+", "methodName", ".", "substring", "(", "prefixLength", "+", "1", ")", ";", "}" ]
Returns the propertyName based on the methodName. Cuts of the prefix and removes first capital. @param methodName name of method to convert. @param prefixLength length of prefix to cut of. @return property name.
[ "Returns", "the", "propertyName", "based", "on", "the", "methodName", ".", "Cuts", "of", "the", "prefix", "and", "removes", "first", "capital", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L370-L372
12,021
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.getRootPropertyName
protected String getRootPropertyName(String propertyName) { int location = propertyName.indexOf(PROPERTY_KEY_PREFIX); return location == -1 ? propertyName : propertyName.substring(0, location); }
java
protected String getRootPropertyName(String propertyName) { int location = propertyName.indexOf(PROPERTY_KEY_PREFIX); return location == -1 ? propertyName : propertyName.substring(0, location); }
[ "protected", "String", "getRootPropertyName", "(", "String", "propertyName", ")", "{", "int", "location", "=", "propertyName", ".", "indexOf", "(", "PROPERTY_KEY_PREFIX", ")", ";", "return", "location", "==", "-", "1", "?", "propertyName", ":", "propertyName", ".", "substring", "(", "0", ",", "location", ")", ";", "}" ]
Returns the root property of an indexed property. The root property is the property that contains no indices. @param propertyName the name of the property. @return the root property.
[ "Returns", "the", "root", "property", "of", "an", "indexed", "property", ".", "The", "root", "property", "is", "the", "property", "that", "contains", "no", "indices", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L381-L384
12,022
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.getParentPropertyName
protected String getParentPropertyName(String propertyName) { if (!PropertyAccessorUtils.isIndexedProperty(propertyName)) { return ""; } else { return propertyName.substring(0, propertyName.lastIndexOf(PROPERTY_KEY_PREFIX_CHAR)); } }
java
protected String getParentPropertyName(String propertyName) { if (!PropertyAccessorUtils.isIndexedProperty(propertyName)) { return ""; } else { return propertyName.substring(0, propertyName.lastIndexOf(PROPERTY_KEY_PREFIX_CHAR)); } }
[ "protected", "String", "getParentPropertyName", "(", "String", "propertyName", ")", "{", "if", "(", "!", "PropertyAccessorUtils", ".", "isIndexedProperty", "(", "propertyName", ")", ")", "{", "return", "\"\"", ";", "}", "else", "{", "return", "propertyName", ".", "substring", "(", "0", ",", "propertyName", ".", "lastIndexOf", "(", "PROPERTY_KEY_PREFIX_CHAR", ")", ")", ";", "}", "}" ]
Return the parent property name of an indexed property or the empty string. @param propertyName the name of the property. @return the empty string or the parent property name if it was indexed.
[ "Return", "the", "parent", "property", "name", "of", "an", "indexed", "property", "or", "the", "empty", "string", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L392-L399
12,023
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
AbstractMemberPropertyAccessor.setAssemblageValue
protected Object setAssemblageValue(Class assemblageType, Object assemblage, Object index, Object value) { if (assemblageType.isArray()) { int i = ((Integer) index).intValue(); if (Array.getLength(assemblage) <= i) { Object newAssemblage = Array.newInstance(assemblageType.getComponentType(), i + 1); System.arraycopy(assemblage, 0, newAssemblage, 0, Array.getLength(assemblage)); assemblage = newAssemblage; } Array.set(assemblage, i, value); } else if (List.class.isAssignableFrom(assemblageType)) { int i = ((Integer) index).intValue(); List list = (List) assemblage; if (list.size() > i) { list.set(i, value); } else { while (list.size() < i) { list.add(null); } list.add(value); } } else if (Map.class.isAssignableFrom(assemblageType)) { ((Map) assemblage).put(index, value); } else if (assemblage instanceof Collection) { ((Collection) assemblage).add(value); } else { throw new IllegalArgumentException("assemblage must be of type array, collection or map."); } return assemblage; }
java
protected Object setAssemblageValue(Class assemblageType, Object assemblage, Object index, Object value) { if (assemblageType.isArray()) { int i = ((Integer) index).intValue(); if (Array.getLength(assemblage) <= i) { Object newAssemblage = Array.newInstance(assemblageType.getComponentType(), i + 1); System.arraycopy(assemblage, 0, newAssemblage, 0, Array.getLength(assemblage)); assemblage = newAssemblage; } Array.set(assemblage, i, value); } else if (List.class.isAssignableFrom(assemblageType)) { int i = ((Integer) index).intValue(); List list = (List) assemblage; if (list.size() > i) { list.set(i, value); } else { while (list.size() < i) { list.add(null); } list.add(value); } } else if (Map.class.isAssignableFrom(assemblageType)) { ((Map) assemblage).put(index, value); } else if (assemblage instanceof Collection) { ((Collection) assemblage).add(value); } else { throw new IllegalArgumentException("assemblage must be of type array, collection or map."); } return assemblage; }
[ "protected", "Object", "setAssemblageValue", "(", "Class", "assemblageType", ",", "Object", "assemblage", ",", "Object", "index", ",", "Object", "value", ")", "{", "if", "(", "assemblageType", ".", "isArray", "(", ")", ")", "{", "int", "i", "=", "(", "(", "Integer", ")", "index", ")", ".", "intValue", "(", ")", ";", "if", "(", "Array", ".", "getLength", "(", "assemblage", ")", "<=", "i", ")", "{", "Object", "newAssemblage", "=", "Array", ".", "newInstance", "(", "assemblageType", ".", "getComponentType", "(", ")", ",", "i", "+", "1", ")", ";", "System", ".", "arraycopy", "(", "assemblage", ",", "0", ",", "newAssemblage", ",", "0", ",", "Array", ".", "getLength", "(", "assemblage", ")", ")", ";", "assemblage", "=", "newAssemblage", ";", "}", "Array", ".", "set", "(", "assemblage", ",", "i", ",", "value", ")", ";", "}", "else", "if", "(", "List", ".", "class", ".", "isAssignableFrom", "(", "assemblageType", ")", ")", "{", "int", "i", "=", "(", "(", "Integer", ")", "index", ")", ".", "intValue", "(", ")", ";", "List", "list", "=", "(", "List", ")", "assemblage", ";", "if", "(", "list", ".", "size", "(", ")", ">", "i", ")", "{", "list", ".", "set", "(", "i", ",", "value", ")", ";", "}", "else", "{", "while", "(", "list", ".", "size", "(", ")", "<", "i", ")", "{", "list", ".", "add", "(", "null", ")", ";", "}", "list", ".", "add", "(", "value", ")", ";", "}", "}", "else", "if", "(", "Map", ".", "class", ".", "isAssignableFrom", "(", "assemblageType", ")", ")", "{", "(", "(", "Map", ")", "assemblage", ")", ".", "put", "(", "index", ",", "value", ")", ";", "}", "else", "if", "(", "assemblage", "instanceof", "Collection", ")", "{", "(", "(", "Collection", ")", "assemblage", ")", ".", "add", "(", "value", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"assemblage must be of type array, collection or map.\"", ")", ";", "}", "return", "assemblage", ";", "}" ]
Helper method for subclasses to set values of indexed properties, like map-values, collection-values or array-values. @param assemblageType either map or collection or array @param assemblage the assemblage to set the value on @param index the index to set the value at @param value the value to set @return the assemblage
[ "Helper", "method", "for", "subclasses", "to", "set", "values", "of", "indexed", "properties", "like", "map", "-", "values", "collection", "-", "values", "or", "array", "-", "values", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L502-L535
12,024
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/AbstractFormBuilder.java
AbstractFormBuilder.createBinding
protected Binding createBinding(String fieldName, JComponent component) { return getBindingFactory().bindControl(component, fieldName); }
java
protected Binding createBinding(String fieldName, JComponent component) { return getBindingFactory().bindControl(component, fieldName); }
[ "protected", "Binding", "createBinding", "(", "String", "fieldName", ",", "JComponent", "component", ")", "{", "return", "getBindingFactory", "(", ")", ".", "bindControl", "(", "component", ",", "fieldName", ")", ";", "}" ]
Create a binding that uses the given component instead of its default component. @param fieldName the name of the property to bind. @param component the component to bind to the property. @return the {@link Binding} that binds the component to the valuemodel of the property.
[ "Create", "a", "binding", "that", "uses", "the", "given", "component", "instead", "of", "its", "default", "component", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/AbstractFormBuilder.java#L111-L113
12,025
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/AbstractFormBuilder.java
AbstractFormBuilder.createLabelFor
protected JLabel createLabelFor(String fieldName, JComponent component) { JLabel label = getComponentFactory().createLabel(""); getFormModel().getFieldFace(fieldName).configure(label); label.setLabelFor(component); FormComponentInterceptor interceptor = getFormComponentInterceptor(); if (interceptor != null) { interceptor.processLabel(fieldName, label); } return label; }
java
protected JLabel createLabelFor(String fieldName, JComponent component) { JLabel label = getComponentFactory().createLabel(""); getFormModel().getFieldFace(fieldName).configure(label); label.setLabelFor(component); FormComponentInterceptor interceptor = getFormComponentInterceptor(); if (interceptor != null) { interceptor.processLabel(fieldName, label); } return label; }
[ "protected", "JLabel", "createLabelFor", "(", "String", "fieldName", ",", "JComponent", "component", ")", "{", "JLabel", "label", "=", "getComponentFactory", "(", ")", ".", "createLabel", "(", "\"\"", ")", ";", "getFormModel", "(", ")", ".", "getFieldFace", "(", "fieldName", ")", ".", "configure", "(", "label", ")", ";", "label", ".", "setLabelFor", "(", "component", ")", ";", "FormComponentInterceptor", "interceptor", "=", "getFormComponentInterceptor", "(", ")", ";", "if", "(", "interceptor", "!=", "null", ")", "{", "interceptor", ".", "processLabel", "(", "fieldName", ",", "label", ")", ";", "}", "return", "label", ";", "}" ]
Create a label for the property. @param fieldName the name of the property. @param component the component of the property which is related to the label. @return a {@link JLabel} for the property.
[ "Create", "a", "label", "for", "the", "property", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/AbstractFormBuilder.java#L184-L195
12,026
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java
WindowUtils.getCenteringPointOnScreen
public static Point getCenteringPointOnScreen(Dimension dimension) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); if (dimension.width > screen.width) { dimension.width = screen.width; } if (dimension.height > screen.height) { dimension.height = screen.height; } return new Point((screen.width - dimension.width) / 2, (screen.height - dimension.height) / 2); }
java
public static Point getCenteringPointOnScreen(Dimension dimension) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); if (dimension.width > screen.width) { dimension.width = screen.width; } if (dimension.height > screen.height) { dimension.height = screen.height; } return new Point((screen.width - dimension.width) / 2, (screen.height - dimension.height) / 2); }
[ "public", "static", "Point", "getCenteringPointOnScreen", "(", "Dimension", "dimension", ")", "{", "Dimension", "screen", "=", "Toolkit", ".", "getDefaultToolkit", "(", ")", ".", "getScreenSize", "(", ")", ";", "if", "(", "dimension", ".", "width", ">", "screen", ".", "width", ")", "{", "dimension", ".", "width", "=", "screen", ".", "width", ";", "}", "if", "(", "dimension", ".", "height", ">", "screen", ".", "height", ")", "{", "dimension", ".", "height", "=", "screen", ".", "height", ";", "}", "return", "new", "Point", "(", "(", "screen", ".", "width", "-", "dimension", ".", "width", ")", "/", "2", ",", "(", "screen", ".", "height", "-", "dimension", ".", "height", ")", "/", "2", ")", ";", "}" ]
Return the centering point on the screen for the object with the specified dimension. @param dimension the dimension of an object @return The centering point on the screen for that object.
[ "Return", "the", "centering", "point", "on", "the", "screen", "for", "the", "object", "with", "the", "specified", "dimension", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java#L43-L52
12,027
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java
WindowUtils.centerOnScreenAndSetVisible
public static void centerOnScreenAndSetVisible(Window window) { window.pack(); centerOnScreen(window); window.setVisible(true); }
java
public static void centerOnScreenAndSetVisible(Window window) { window.pack(); centerOnScreen(window); window.setVisible(true); }
[ "public", "static", "void", "centerOnScreenAndSetVisible", "(", "Window", "window", ")", "{", "window", ".", "pack", "(", ")", ";", "centerOnScreen", "(", "window", ")", ";", "window", ".", "setVisible", "(", "true", ")", ";", "}" ]
Pack the window, center it on the screen, and set the window visible. @param window the window to center and show.
[ "Pack", "the", "window", "center", "it", "on", "the", "screen", "and", "set", "the", "window", "visible", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java#L59-L63
12,028
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java
WindowUtils.centerOnParentAndSetVisible
public static void centerOnParentAndSetVisible(Window window) { window.pack(); centerOnParent(window, window.getParent()); window.setVisible(true); }
java
public static void centerOnParentAndSetVisible(Window window) { window.pack(); centerOnParent(window, window.getParent()); window.setVisible(true); }
[ "public", "static", "void", "centerOnParentAndSetVisible", "(", "Window", "window", ")", "{", "window", ".", "pack", "(", ")", ";", "centerOnParent", "(", "window", ",", "window", ".", "getParent", "(", ")", ")", ";", "window", ".", "setVisible", "(", "true", ")", ";", "}" ]
Pack the window, center it relative to it's parent, and set the window visible. @param window the window to center and show.
[ "Pack", "the", "window", "center", "it", "relative", "to", "it", "s", "parent", "and", "set", "the", "window", "visible", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java#L101-L105
12,029
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java
WindowUtils.centerOnParent
public static void centerOnParent(Window window, Component parent) { if (parent == null || !parent.isShowing()) { // call our own centerOnScreen so we work around bug in // setLocationRelativeTo(null) centerOnScreen(window); } else { window.setLocationRelativeTo(parent); } }
java
public static void centerOnParent(Window window, Component parent) { if (parent == null || !parent.isShowing()) { // call our own centerOnScreen so we work around bug in // setLocationRelativeTo(null) centerOnScreen(window); } else { window.setLocationRelativeTo(parent); } }
[ "public", "static", "void", "centerOnParent", "(", "Window", "window", ",", "Component", "parent", ")", "{", "if", "(", "parent", "==", "null", "||", "!", "parent", ".", "isShowing", "(", ")", ")", "{", "// call our own centerOnScreen so we work around bug in", "// setLocationRelativeTo(null)", "centerOnScreen", "(", "window", ")", ";", "}", "else", "{", "window", ".", "setLocationRelativeTo", "(", "parent", ")", ";", "}", "}" ]
Center the window relative to it's parent. If the parent is null, or not showing, the window will be centered on the screen @param window the window to center @param parent the parent
[ "Center", "the", "window", "relative", "to", "it", "s", "parent", ".", "If", "the", "parent", "is", "null", "or", "not", "showing", "the", "window", "will", "be", "centered", "on", "the", "screen" ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java#L114-L123
12,030
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/remoting/BasicAuthCommonsHttpInvokerProxyFactoryBean.java
BasicAuthCommonsHttpInvokerProxyFactoryBean.setAuthenticationToken
public void setAuthenticationToken(Authentication authentication) { if( logger.isDebugEnabled() ) { logger.debug("New authentication token: " + authentication); } HttpComponentsHttpInvokerRequestExecutor executor = (HttpComponentsHttpInvokerRequestExecutor) getHttpInvokerRequestExecutor(); DefaultHttpClient httpClient = (DefaultHttpClient) executor.getHttpClient(); BasicCredentialsProvider provider = new BasicCredentialsProvider(); httpClient.setCredentialsProvider(provider); httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor()); UsernamePasswordCredentials usernamePasswordCredentials; if (authentication != null) { usernamePasswordCredentials = new UsernamePasswordCredentials( authentication.getName(), authentication.getCredentials().toString()); } else { usernamePasswordCredentials = null; } provider.setCredentials(AuthScope.ANY, usernamePasswordCredentials); }
java
public void setAuthenticationToken(Authentication authentication) { if( logger.isDebugEnabled() ) { logger.debug("New authentication token: " + authentication); } HttpComponentsHttpInvokerRequestExecutor executor = (HttpComponentsHttpInvokerRequestExecutor) getHttpInvokerRequestExecutor(); DefaultHttpClient httpClient = (DefaultHttpClient) executor.getHttpClient(); BasicCredentialsProvider provider = new BasicCredentialsProvider(); httpClient.setCredentialsProvider(provider); httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor()); UsernamePasswordCredentials usernamePasswordCredentials; if (authentication != null) { usernamePasswordCredentials = new UsernamePasswordCredentials( authentication.getName(), authentication.getCredentials().toString()); } else { usernamePasswordCredentials = null; } provider.setCredentials(AuthScope.ANY, usernamePasswordCredentials); }
[ "public", "void", "setAuthenticationToken", "(", "Authentication", "authentication", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"New authentication token: \"", "+", "authentication", ")", ";", "}", "HttpComponentsHttpInvokerRequestExecutor", "executor", "=", "(", "HttpComponentsHttpInvokerRequestExecutor", ")", "getHttpInvokerRequestExecutor", "(", ")", ";", "DefaultHttpClient", "httpClient", "=", "(", "DefaultHttpClient", ")", "executor", ".", "getHttpClient", "(", ")", ";", "BasicCredentialsProvider", "provider", "=", "new", "BasicCredentialsProvider", "(", ")", ";", "httpClient", ".", "setCredentialsProvider", "(", "provider", ")", ";", "httpClient", ".", "addRequestInterceptor", "(", "new", "PreemptiveAuthInterceptor", "(", ")", ")", ";", "UsernamePasswordCredentials", "usernamePasswordCredentials", ";", "if", "(", "authentication", "!=", "null", ")", "{", "usernamePasswordCredentials", "=", "new", "UsernamePasswordCredentials", "(", "authentication", ".", "getName", "(", ")", ",", "authentication", ".", "getCredentials", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "usernamePasswordCredentials", "=", "null", ";", "}", "provider", ".", "setCredentials", "(", "AuthScope", ".", "ANY", ",", "usernamePasswordCredentials", ")", ";", "}" ]
Handle a change in the current authentication token. This method will fail fast if the executor isn't a CommonsHttpInvokerRequestExecutor. @see org.valkyriercp.security.AuthenticationAware#setAuthenticationToken(org.springframework.security.core.Authentication)
[ "Handle", "a", "change", "in", "the", "current", "authentication", "token", ".", "This", "method", "will", "fail", "fast", "if", "the", "executor", "isn", "t", "a", "CommonsHttpInvokerRequestExecutor", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/remoting/BasicAuthCommonsHttpInvokerProxyFactoryBean.java#L81-L100
12,031
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/ShowPageCommand.java
ShowPageCommand.setPageDescriptor
public final void setPageDescriptor(PageDescriptor pageDescriptor) { Assert.notNull(pageDescriptor, "pageDescriptor"); setId(pageDescriptor.getId()); setLabel(pageDescriptor.getShowPageCommandLabel()); setIcon(pageDescriptor.getIcon()); setCaption(pageDescriptor.getCaption()); this.pageDescriptor = pageDescriptor; }
java
public final void setPageDescriptor(PageDescriptor pageDescriptor) { Assert.notNull(pageDescriptor, "pageDescriptor"); setId(pageDescriptor.getId()); setLabel(pageDescriptor.getShowPageCommandLabel()); setIcon(pageDescriptor.getIcon()); setCaption(pageDescriptor.getCaption()); this.pageDescriptor = pageDescriptor; }
[ "public", "final", "void", "setPageDescriptor", "(", "PageDescriptor", "pageDescriptor", ")", "{", "Assert", ".", "notNull", "(", "pageDescriptor", ",", "\"pageDescriptor\"", ")", ";", "setId", "(", "pageDescriptor", ".", "getId", "(", ")", ")", ";", "setLabel", "(", "pageDescriptor", ".", "getShowPageCommandLabel", "(", ")", ")", ";", "setIcon", "(", "pageDescriptor", ".", "getIcon", "(", ")", ")", ";", "setCaption", "(", "pageDescriptor", ".", "getCaption", "(", ")", ")", ";", "this", ".", "pageDescriptor", "=", "pageDescriptor", ";", "}" ]
Sets the descriptor for the page that is to be opened by this command object. This command object will be assigned the id, label, icon, and caption from the given page descriptor. @param pageDescriptor The page descriptor, cannot be null. @throws IllegalArgumentException if {@code pageDescriptor} is null.
[ "Sets", "the", "descriptor", "for", "the", "page", "that", "is", "to", "be", "opened", "by", "this", "command", "object", ".", "This", "command", "object", "will", "be", "assigned", "the", "id", "label", "icon", "and", "caption", "from", "the", "given", "page", "descriptor", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/ShowPageCommand.java#L74-L81
12,032
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/application/splash/ProgressSplashScreen.java
ProgressSplashScreen.createContentPane
protected Component createContentPane() { JPanel content = new JPanel(new BorderLayout()); Component component = super.createContentPane(); if(component != null) content.add(component); JProgressBar progressBar = getProgressBar(); progressBar.setIndeterminate(isIndeterminate()); progressBar.setStringPainted(isShowProgressLabel()); content.add(progressBar, BorderLayout.SOUTH); return content; }
java
protected Component createContentPane() { JPanel content = new JPanel(new BorderLayout()); Component component = super.createContentPane(); if(component != null) content.add(component); JProgressBar progressBar = getProgressBar(); progressBar.setIndeterminate(isIndeterminate()); progressBar.setStringPainted(isShowProgressLabel()); content.add(progressBar, BorderLayout.SOUTH); return content; }
[ "protected", "Component", "createContentPane", "(", ")", "{", "JPanel", "content", "=", "new", "JPanel", "(", "new", "BorderLayout", "(", ")", ")", ";", "Component", "component", "=", "super", ".", "createContentPane", "(", ")", ";", "if", "(", "component", "!=", "null", ")", "content", ".", "add", "(", "component", ")", ";", "JProgressBar", "progressBar", "=", "getProgressBar", "(", ")", ";", "progressBar", ".", "setIndeterminate", "(", "isIndeterminate", "(", ")", ")", ";", "progressBar", ".", "setStringPainted", "(", "isShowProgressLabel", "(", ")", ")", ";", "content", ".", "add", "(", "progressBar", ",", "BorderLayout", ".", "SOUTH", ")", ";", "return", "content", ";", "}" ]
Returns a component that displays an image above a progress bar. @return A splash screen containing an image and a progress bar, never null.
[ "Returns", "a", "component", "that", "displays", "an", "image", "above", "a", "progress", "bar", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/application/splash/ProgressSplashScreen.java#L75-L88
12,033
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/application/splash/ProgressSplashScreen.java
ProgressSplashScreen.getProgressBar
protected JProgressBar getProgressBar() { if (progressBar == null) { progressBar = createProgressBar(); Assert.notNull(progressBar, "createProgressBar should not return null"); } return progressBar; }
java
protected JProgressBar getProgressBar() { if (progressBar == null) { progressBar = createProgressBar(); Assert.notNull(progressBar, "createProgressBar should not return null"); } return progressBar; }
[ "protected", "JProgressBar", "getProgressBar", "(", ")", "{", "if", "(", "progressBar", "==", "null", ")", "{", "progressBar", "=", "createProgressBar", "(", ")", ";", "Assert", ".", "notNull", "(", "progressBar", ",", "\"createProgressBar should not return null\"", ")", ";", "}", "return", "progressBar", ";", "}" ]
Returns the progress bar. @return not null
[ "Returns", "the", "progress", "bar", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/application/splash/ProgressSplashScreen.java#L112-L118
12,034
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/application/exceptionhandling/DelegatingExceptionHandler.java
DelegatingExceptionHandler.uncaughtException
public void uncaughtException(Thread thread, Throwable throwable) { if (exceptionPurger != null) { throwable = exceptionPurger.purge(throwable); } for (ExceptionHandlerDelegate delegate : delegateList) { if (delegate.hasAppropriateHandler(throwable)) { delegate.uncaughtException(thread, throwable); return; } } // A silent exception handler should be configured if it needs to be silent logger.error("No exception handler found for throwable", throwable); }
java
public void uncaughtException(Thread thread, Throwable throwable) { if (exceptionPurger != null) { throwable = exceptionPurger.purge(throwable); } for (ExceptionHandlerDelegate delegate : delegateList) { if (delegate.hasAppropriateHandler(throwable)) { delegate.uncaughtException(thread, throwable); return; } } // A silent exception handler should be configured if it needs to be silent logger.error("No exception handler found for throwable", throwable); }
[ "public", "void", "uncaughtException", "(", "Thread", "thread", ",", "Throwable", "throwable", ")", "{", "if", "(", "exceptionPurger", "!=", "null", ")", "{", "throwable", "=", "exceptionPurger", ".", "purge", "(", "throwable", ")", ";", "}", "for", "(", "ExceptionHandlerDelegate", "delegate", ":", "delegateList", ")", "{", "if", "(", "delegate", ".", "hasAppropriateHandler", "(", "throwable", ")", ")", "{", "delegate", ".", "uncaughtException", "(", "thread", ",", "throwable", ")", ";", "return", ";", "}", "}", "// A silent exception handler should be configured if it needs to be silent", "logger", ".", "error", "(", "\"No exception handler found for throwable\"", ",", "throwable", ")", ";", "}" ]
Delegates the throwable to the appropriate delegate exception handler. @param thread the thread in which the throwable occurred @param throwable the thrown throwable
[ "Delegates", "the", "throwable", "to", "the", "appropriate", "delegate", "exception", "handler", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/application/exceptionhandling/DelegatingExceptionHandler.java#L96-L108
12,035
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java
ListSelectionValueModelAdapter.setValue
public void setValue( Object newValue ) { int[] newSelection = (int[]) newValue; if( hasChanged(currentSelection, newSelection) ) { int[] oldValue = currentSelection; currentSelection = newSelection; fireValueChange(oldValue, currentSelection); if( !skipSelectionModelUpdate) { // Don't want notifications while we do this model.removeListSelectionListener(this); // Install the selection on the adapted model model.clearSelection(); int i = 0; int len = newSelection.length; while( i < len ) { int start = newSelection[i]; while( i < len - 1 && newSelection[i] == newSelection[i + 1] - 1 ) { i++; } int end = newSelection[i]; model.addSelectionInterval(start, end); i++; } // Reinstall listener model.addListSelectionListener(this); } } }
java
public void setValue( Object newValue ) { int[] newSelection = (int[]) newValue; if( hasChanged(currentSelection, newSelection) ) { int[] oldValue = currentSelection; currentSelection = newSelection; fireValueChange(oldValue, currentSelection); if( !skipSelectionModelUpdate) { // Don't want notifications while we do this model.removeListSelectionListener(this); // Install the selection on the adapted model model.clearSelection(); int i = 0; int len = newSelection.length; while( i < len ) { int start = newSelection[i]; while( i < len - 1 && newSelection[i] == newSelection[i + 1] - 1 ) { i++; } int end = newSelection[i]; model.addSelectionInterval(start, end); i++; } // Reinstall listener model.addListSelectionListener(this); } } }
[ "public", "void", "setValue", "(", "Object", "newValue", ")", "{", "int", "[", "]", "newSelection", "=", "(", "int", "[", "]", ")", "newValue", ";", "if", "(", "hasChanged", "(", "currentSelection", ",", "newSelection", ")", ")", "{", "int", "[", "]", "oldValue", "=", "currentSelection", ";", "currentSelection", "=", "newSelection", ";", "fireValueChange", "(", "oldValue", ",", "currentSelection", ")", ";", "if", "(", "!", "skipSelectionModelUpdate", ")", "{", "// Don't want notifications while we do this", "model", ".", "removeListSelectionListener", "(", "this", ")", ";", "// Install the selection on the adapted model", "model", ".", "clearSelection", "(", ")", ";", "int", "i", "=", "0", ";", "int", "len", "=", "newSelection", ".", "length", ";", "while", "(", "i", "<", "len", ")", "{", "int", "start", "=", "newSelection", "[", "i", "]", ";", "while", "(", "i", "<", "len", "-", "1", "&&", "newSelection", "[", "i", "]", "==", "newSelection", "[", "i", "+", "1", "]", "-", "1", ")", "{", "i", "++", ";", "}", "int", "end", "=", "newSelection", "[", "i", "]", ";", "model", ".", "addSelectionInterval", "(", "start", ",", "end", ")", ";", "i", "++", ";", "}", "// Reinstall listener", "model", ".", "addListSelectionListener", "(", "this", ")", ";", "}", "}", "}" ]
Set the selection value. @param newValue must be an integer array (int[])
[ "Set", "the", "selection", "value", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java#L79-L111
12,036
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java
ListSelectionValueModelAdapter.hasChanged
private boolean hasChanged( int[] oldValue, int[] newValue ) { if( oldValue.length == newValue.length ) { for( int i = 0; i < newValue.length; i++ ) { if( oldValue[i] != newValue[i] ) { return true; } } return false; } return true; }
java
private boolean hasChanged( int[] oldValue, int[] newValue ) { if( oldValue.length == newValue.length ) { for( int i = 0; i < newValue.length; i++ ) { if( oldValue[i] != newValue[i] ) { return true; } } return false; } return true; }
[ "private", "boolean", "hasChanged", "(", "int", "[", "]", "oldValue", ",", "int", "[", "]", "newValue", ")", "{", "if", "(", "oldValue", ".", "length", "==", "newValue", ".", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "newValue", ".", "length", ";", "i", "++", ")", "{", "if", "(", "oldValue", "[", "i", "]", "!=", "newValue", "[", "i", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
See if two arrays are different.
[ "See", "if", "two", "arrays", "are", "different", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java#L116-L126
12,037
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java
ListSelectionValueModelAdapter.getSelectedRows
private int[] getSelectedRows() { int iMin = model.getMinSelectionIndex(); int iMax = model.getMaxSelectionIndex(); if( (iMin == -1) || (iMax == -1) ) { return new int[0]; } int[] rvTmp = new int[1 + (iMax - iMin)]; int n = 0; for( int i = iMin; i <= iMax; i++ ) { if( model.isSelectedIndex(i) ) { rvTmp[n++] = i; } } int[] rv = new int[n]; System.arraycopy(rvTmp, 0, rv, 0, n); return rv; }
java
private int[] getSelectedRows() { int iMin = model.getMinSelectionIndex(); int iMax = model.getMaxSelectionIndex(); if( (iMin == -1) || (iMax == -1) ) { return new int[0]; } int[] rvTmp = new int[1 + (iMax - iMin)]; int n = 0; for( int i = iMin; i <= iMax; i++ ) { if( model.isSelectedIndex(i) ) { rvTmp[n++] = i; } } int[] rv = new int[n]; System.arraycopy(rvTmp, 0, rv, 0, n); return rv; }
[ "private", "int", "[", "]", "getSelectedRows", "(", ")", "{", "int", "iMin", "=", "model", ".", "getMinSelectionIndex", "(", ")", ";", "int", "iMax", "=", "model", ".", "getMaxSelectionIndex", "(", ")", ";", "if", "(", "(", "iMin", "==", "-", "1", ")", "||", "(", "iMax", "==", "-", "1", ")", ")", "{", "return", "new", "int", "[", "0", "]", ";", "}", "int", "[", "]", "rvTmp", "=", "new", "int", "[", "1", "+", "(", "iMax", "-", "iMin", ")", "]", ";", "int", "n", "=", "0", ";", "for", "(", "int", "i", "=", "iMin", ";", "i", "<=", "iMax", ";", "i", "++", ")", "{", "if", "(", "model", ".", "isSelectedIndex", "(", "i", ")", ")", "{", "rvTmp", "[", "n", "++", "]", "=", "i", ";", "}", "}", "int", "[", "]", "rv", "=", "new", "int", "[", "n", "]", ";", "System", ".", "arraycopy", "(", "rvTmp", ",", "0", ",", "rv", ",", "0", ",", "n", ")", ";", "return", "rv", ";", "}" ]
Returns the indices of all selected rows in the model. @return an array of integers containing the indices of all selected rows, or an empty array if no row is selected
[ "Returns", "the", "indices", "of", "all", "selected", "rows", "in", "the", "model", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/list/ListSelectionValueModelAdapter.java#L134-L152
12,038
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/application/support/BeanFactoryViewDescriptorRegistry.java
BeanFactoryViewDescriptorRegistry.getViewDescriptor
public ViewDescriptor getViewDescriptor(String viewName) { Assert.notNull(viewName, "viewName"); try { return (ViewDescriptor) applicationContext.getBean(viewName, ViewDescriptor.class); } catch (NoSuchBeanDefinitionException e) { return null; } }
java
public ViewDescriptor getViewDescriptor(String viewName) { Assert.notNull(viewName, "viewName"); try { return (ViewDescriptor) applicationContext.getBean(viewName, ViewDescriptor.class); } catch (NoSuchBeanDefinitionException e) { return null; } }
[ "public", "ViewDescriptor", "getViewDescriptor", "(", "String", "viewName", ")", "{", "Assert", ".", "notNull", "(", "viewName", ",", "\"viewName\"", ")", ";", "try", "{", "return", "(", "ViewDescriptor", ")", "applicationContext", ".", "getBean", "(", "viewName", ",", "ViewDescriptor", ".", "class", ")", ";", "}", "catch", "(", "NoSuchBeanDefinitionException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Returns the view descriptor with the given identifier, or null if no such bean definition with the given name exists in the current application context. @param viewName The bean name of the view descriptor that is to be retrieved from the underlying application context. Must not be null. @throws IllegalArgumentException if {@code viewName} is null. @throws org.springframework.beans.factory.BeanNotOfRequiredTypeException if the bean retrieved from the underlying application context is not of type {@link ViewDescriptor}.
[ "Returns", "the", "view", "descriptor", "with", "the", "given", "identifier", "or", "null", "if", "no", "such", "bean", "definition", "with", "the", "given", "name", "exists", "in", "the", "current", "application", "context", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/application/support/BeanFactoryViewDescriptorRegistry.java#L66-L77
12,039
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/FormLayoutFormBuilder.java
FormLayoutFormBuilder.setLayout
public void setLayout(FormLayout layout, JPanel panel) { this.panel = panel; this.layout = layout; panel.setLayout(layout); cc = new CellConstraints(); row = -1; }
java
public void setLayout(FormLayout layout, JPanel panel) { this.panel = panel; this.layout = layout; panel.setLayout(layout); cc = new CellConstraints(); row = -1; }
[ "public", "void", "setLayout", "(", "FormLayout", "layout", ",", "JPanel", "panel", ")", "{", "this", ".", "panel", "=", "panel", ";", "this", ".", "layout", "=", "layout", ";", "panel", ".", "setLayout", "(", "layout", ")", ";", "cc", "=", "new", "CellConstraints", "(", ")", ";", "row", "=", "-", "1", ";", "}" ]
Set a panel with the provided layout layout. @param layout JGoodies FormLayout @param panel JPanel on which the builder will place the components.
[ "Set", "a", "panel", "with", "the", "provided", "layout", "layout", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/FormLayoutFormBuilder.java#L208-L215
12,040
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/FormLayoutFormBuilder.java
FormLayoutFormBuilder.addBinding
public JComponent addBinding(Binding binding, int column, int row, int widthSpan, int heightSpan) { ((SwingBindingFactory) getBindingFactory()).interceptBinding(binding); JComponent component = binding.getControl(); addComponent(component, column, row, widthSpan, heightSpan); return component; }
java
public JComponent addBinding(Binding binding, int column, int row, int widthSpan, int heightSpan) { ((SwingBindingFactory) getBindingFactory()).interceptBinding(binding); JComponent component = binding.getControl(); addComponent(component, column, row, widthSpan, heightSpan); return component; }
[ "public", "JComponent", "addBinding", "(", "Binding", "binding", ",", "int", "column", ",", "int", "row", ",", "int", "widthSpan", ",", "int", "heightSpan", ")", "{", "(", "(", "SwingBindingFactory", ")", "getBindingFactory", "(", ")", ")", ".", "interceptBinding", "(", "binding", ")", ";", "JComponent", "component", "=", "binding", ".", "getControl", "(", ")", ";", "addComponent", "(", "component", ",", "column", ",", "row", ",", "widthSpan", ",", "heightSpan", ")", ";", "return", "component", ";", "}" ]
Add a binder to a column and a row with width and height spanning.
[ "Add", "a", "binder", "to", "a", "column", "and", "a", "row", "with", "width", "and", "height", "spanning", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/FormLayoutFormBuilder.java#L271-L277
12,041
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/PopupMenuMouseListener.java
PopupMenuMouseListener.showPopupMenu
protected void showPopupMenu(MouseEvent e) { if (onAboutToShow(e)) { JPopupMenu popupToShow = getPopupMenu(e); if (popupToShow == null) { return; } popupToShow.show(e.getComponent(), e.getX(), e.getY()); popupToShow.setVisible(true); } }
java
protected void showPopupMenu(MouseEvent e) { if (onAboutToShow(e)) { JPopupMenu popupToShow = getPopupMenu(e); if (popupToShow == null) { return; } popupToShow.show(e.getComponent(), e.getX(), e.getY()); popupToShow.setVisible(true); } }
[ "protected", "void", "showPopupMenu", "(", "MouseEvent", "e", ")", "{", "if", "(", "onAboutToShow", "(", "e", ")", ")", "{", "JPopupMenu", "popupToShow", "=", "getPopupMenu", "(", "e", ")", ";", "if", "(", "popupToShow", "==", "null", ")", "{", "return", ";", "}", "popupToShow", ".", "show", "(", "e", ".", "getComponent", "(", ")", ",", "e", ".", "getX", "(", ")", ",", "e", ".", "getY", "(", ")", ")", ";", "popupToShow", ".", "setVisible", "(", "true", ")", ";", "}", "}" ]
Called to display the popup menu.
[ "Called", "to", "display", "the", "popup", "menu", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/PopupMenuMouseListener.java#L64-L73
12,042
lievendoclo/Valkyrie-RCP
valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/editor/EditorComponentPane.java
EditorComponentPane.createViewToolBar
protected JComponent createViewToolBar() { if(getPageComponent() instanceof AbstractEditor){ AbstractEditor editor = (AbstractEditor)getPageComponent(); return editor.getEditorToolBar(); } return null; }
java
protected JComponent createViewToolBar() { if(getPageComponent() instanceof AbstractEditor){ AbstractEditor editor = (AbstractEditor)getPageComponent(); return editor.getEditorToolBar(); } return null; }
[ "protected", "JComponent", "createViewToolBar", "(", ")", "{", "if", "(", "getPageComponent", "(", ")", "instanceof", "AbstractEditor", ")", "{", "AbstractEditor", "editor", "=", "(", "AbstractEditor", ")", "getPageComponent", "(", ")", ";", "return", "editor", ".", "getEditorToolBar", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the view specific toolbar if the underlying view implementation supports it.
[ "Returns", "the", "view", "specific", "toolbar", "if", "the", "underlying", "view", "implementation", "supports", "it", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/editor/EditorComponentPane.java#L77-L83
12,043
lievendoclo/Valkyrie-RCP
valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/editor/EditorComponentPane.java
EditorComponentPane.createViewMenuBar
protected JComponent createViewMenuBar() { if(getPageComponent() instanceof AbstractEditor){ AbstractEditor editor = (AbstractEditor)getPageComponent(); return editor.getEditorMenuBar(); } return null; }
java
protected JComponent createViewMenuBar() { if(getPageComponent() instanceof AbstractEditor){ AbstractEditor editor = (AbstractEditor)getPageComponent(); return editor.getEditorMenuBar(); } return null; }
[ "protected", "JComponent", "createViewMenuBar", "(", ")", "{", "if", "(", "getPageComponent", "(", ")", "instanceof", "AbstractEditor", ")", "{", "AbstractEditor", "editor", "=", "(", "AbstractEditor", ")", "getPageComponent", "(", ")", ";", "return", "editor", ".", "getEditorMenuBar", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the view specific menubar if the underlying view implementation supports it.
[ "Returns", "the", "view", "specific", "menubar", "if", "the", "underlying", "view", "implementation", "supports", "it", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-integrations/valkyrie-rcp-jidedocking/src/main/java/org/valkyriercp/application/docking/editor/EditorComponentPane.java#L89-L95
12,044
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroupModelBuilder.java
CommandGroupModelBuilder.buildModel
public final Object buildModel(CommandGroup commandGroup) { Object model = buildRootModel(commandGroup); recurse(commandGroup, model, 0); return model; }
java
public final Object buildModel(CommandGroup commandGroup) { Object model = buildRootModel(commandGroup); recurse(commandGroup, model, 0); return model; }
[ "public", "final", "Object", "buildModel", "(", "CommandGroup", "commandGroup", ")", "{", "Object", "model", "=", "buildRootModel", "(", "commandGroup", ")", ";", "recurse", "(", "commandGroup", ",", "model", ",", "0", ")", ";", "return", "model", ";", "}" ]
Main service method of this method to call. This builds the complete mapping object-model by traversing the complete passed in command-group structure by performing the appropriate callbacks to the subclass implementations of {@link #buildRootModel(CommandGroup)}, {@link #buildChildModel(Object, AbstractCommand, int)}, and {@link #buildGroupModel(Object, CommandGroup, int)}. Additionally, @param commandGroup the root of the structure for which an mapping objectmodel will be built. @return the build object model
[ "Main", "service", "method", "of", "this", "method", "to", "call", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroupModelBuilder.java#L133-L140
12,045
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java
DefaultApplicationSecurityManager.getAuthenticationManager
@Override public AuthenticationManager getAuthenticationManager() { if(ValkyrieRepository.getInstance().getApplicationConfig().applicationContext().getBeansOfType(AuthenticationManager.class).size() != 0) return ValkyrieRepository.getInstance().getBean(AuthenticationManager.class); else { return null; } }
java
@Override public AuthenticationManager getAuthenticationManager() { if(ValkyrieRepository.getInstance().getApplicationConfig().applicationContext().getBeansOfType(AuthenticationManager.class).size() != 0) return ValkyrieRepository.getInstance().getBean(AuthenticationManager.class); else { return null; } }
[ "@", "Override", "public", "AuthenticationManager", "getAuthenticationManager", "(", ")", "{", "if", "(", "ValkyrieRepository", ".", "getInstance", "(", ")", ".", "getApplicationConfig", "(", ")", ".", "applicationContext", "(", ")", ".", "getBeansOfType", "(", "AuthenticationManager", ".", "class", ")", ".", "size", "(", ")", "!=", "0", ")", "return", "ValkyrieRepository", ".", "getInstance", "(", ")", ".", "getBean", "(", "AuthenticationManager", ".", "class", ")", ";", "else", "{", "return", "null", ";", "}", "}" ]
Get the authentication manager in use. @return authenticationManager instance used for authentication requests
[ "Get", "the", "authentication", "manager", "in", "use", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java#L146-L154
12,046
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java
DefaultApplicationSecurityManager.isUserInRole
@Override public boolean isUserInRole(String role) { boolean inRole = false; Authentication authentication = getAuthentication(); if (authentication != null) { Collection<? extends GrantedAuthority> authorities = authentication .getAuthorities(); for (GrantedAuthority authority : authorities) { if (role.equals(authority.getAuthority())) { inRole = true; break; } } } return inRole; }
java
@Override public boolean isUserInRole(String role) { boolean inRole = false; Authentication authentication = getAuthentication(); if (authentication != null) { Collection<? extends GrantedAuthority> authorities = authentication .getAuthorities(); for (GrantedAuthority authority : authorities) { if (role.equals(authority.getAuthority())) { inRole = true; break; } } } return inRole; }
[ "@", "Override", "public", "boolean", "isUserInRole", "(", "String", "role", ")", "{", "boolean", "inRole", "=", "false", ";", "Authentication", "authentication", "=", "getAuthentication", "(", ")", ";", "if", "(", "authentication", "!=", "null", ")", "{", "Collection", "<", "?", "extends", "GrantedAuthority", ">", "authorities", "=", "authentication", ".", "getAuthorities", "(", ")", ";", "for", "(", "GrantedAuthority", "authority", ":", "authorities", ")", "{", "if", "(", "role", ".", "equals", "(", "authority", ".", "getAuthority", "(", ")", ")", ")", "{", "inRole", "=", "true", ";", "break", ";", "}", "}", "}", "return", "inRole", ";", "}" ]
Determine if the currently authenticated user has the role provided. Note that role comparisons are case sensitive. @param role to check @return true if the user has the role requested
[ "Determine", "if", "the", "currently", "authenticated", "user", "has", "the", "role", "provided", ".", "Note", "that", "role", "comparisons", "are", "case", "sensitive", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java#L250-L266
12,047
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java
DefaultApplicationSecurityManager.tryToWire
protected <T> boolean tryToWire(Class<T> type) { boolean success = false; String className = type.getName(); Map<String, T> map = getApplicationConfig().applicationContext().getBeansOfType(type); if (logger.isDebugEnabled()) { logger.debug("Search for '" + className + "' found: " + map); } if (map.size() == 1) { // Got one - wire it in Map.Entry entry = map.entrySet().iterator().next(); String name = (String) entry.getKey(); AuthenticationManager am = (AuthenticationManager) entry.getValue(); setAuthenticationManager(am); success = true; if (logger.isInfoEnabled()) { logger.info("Auto-configuration using '" + name + "' as authenticationManager"); } } else if (map.size() > 1) { if (logger.isInfoEnabled()) { logger.info("Need a single '" + className + "', found: " + map.keySet()); } } else { // Size 0, no potentials if (logger.isInfoEnabled()) { logger.info("Auto-configuration did not find a suitable authenticationManager of type " + type); } } return success; }
java
protected <T> boolean tryToWire(Class<T> type) { boolean success = false; String className = type.getName(); Map<String, T> map = getApplicationConfig().applicationContext().getBeansOfType(type); if (logger.isDebugEnabled()) { logger.debug("Search for '" + className + "' found: " + map); } if (map.size() == 1) { // Got one - wire it in Map.Entry entry = map.entrySet().iterator().next(); String name = (String) entry.getKey(); AuthenticationManager am = (AuthenticationManager) entry.getValue(); setAuthenticationManager(am); success = true; if (logger.isInfoEnabled()) { logger.info("Auto-configuration using '" + name + "' as authenticationManager"); } } else if (map.size() > 1) { if (logger.isInfoEnabled()) { logger.info("Need a single '" + className + "', found: " + map.keySet()); } } else { // Size 0, no potentials if (logger.isInfoEnabled()) { logger.info("Auto-configuration did not find a suitable authenticationManager of type " + type); } } return success; }
[ "protected", "<", "T", ">", "boolean", "tryToWire", "(", "Class", "<", "T", ">", "type", ")", "{", "boolean", "success", "=", "false", ";", "String", "className", "=", "type", ".", "getName", "(", ")", ";", "Map", "<", "String", ",", "T", ">", "map", "=", "getApplicationConfig", "(", ")", ".", "applicationContext", "(", ")", ".", "getBeansOfType", "(", "type", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Search for '\"", "+", "className", "+", "\"' found: \"", "+", "map", ")", ";", "}", "if", "(", "map", ".", "size", "(", ")", "==", "1", ")", "{", "// Got one - wire it in", "Map", ".", "Entry", "entry", "=", "map", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "String", "name", "=", "(", "String", ")", "entry", ".", "getKey", "(", ")", ";", "AuthenticationManager", "am", "=", "(", "AuthenticationManager", ")", "entry", ".", "getValue", "(", ")", ";", "setAuthenticationManager", "(", "am", ")", ";", "success", "=", "true", ";", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Auto-configuration using '\"", "+", "name", "+", "\"' as authenticationManager\"", ")", ";", "}", "}", "else", "if", "(", "map", ".", "size", "(", ")", ">", "1", ")", "{", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Need a single '\"", "+", "className", "+", "\"', found: \"", "+", "map", ".", "keySet", "(", ")", ")", ";", "}", "}", "else", "{", "// Size 0, no potentials", "if", "(", "logger", ".", "isInfoEnabled", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Auto-configuration did not find a suitable authenticationManager of type \"", "+", "type", ")", ";", "}", "}", "return", "success", ";", "}" ]
Try to locate and "wire in" a suitable authentication manager. @param type The type of bean to look for @return true if we found and wired a suitable bean
[ "Try", "to", "locate", "and", "wire", "in", "a", "suitable", "authentication", "manager", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/DefaultApplicationSecurityManager.java#L325-L360
12,048
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java
LabelInfo.checkForValidEscapedCharacter
private static void checkForValidEscapedCharacter(int index, String labelDescriptor) { if (index >= labelDescriptor.length()) { throw new IllegalArgumentException( "The label descriptor contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash."); } char escapedChar = labelDescriptor.charAt(index); if (escapedChar != '&' && escapedChar != '\\') { throw new IllegalArgumentException( "The label descriptor [" + labelDescriptor + "] contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash."); } }
java
private static void checkForValidEscapedCharacter(int index, String labelDescriptor) { if (index >= labelDescriptor.length()) { throw new IllegalArgumentException( "The label descriptor contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash."); } char escapedChar = labelDescriptor.charAt(index); if (escapedChar != '&' && escapedChar != '\\') { throw new IllegalArgumentException( "The label descriptor [" + labelDescriptor + "] contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash."); } }
[ "private", "static", "void", "checkForValidEscapedCharacter", "(", "int", "index", ",", "String", "labelDescriptor", ")", "{", "if", "(", "index", ">=", "labelDescriptor", ".", "length", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The label descriptor contains an invalid escape sequence. Backslash \"", "+", "\"characters (\\\\) must be followed by either an ampersand (&) or another \"", "+", "\"backslash.\"", ")", ";", "}", "char", "escapedChar", "=", "labelDescriptor", ".", "charAt", "(", "index", ")", ";", "if", "(", "escapedChar", "!=", "'", "'", "&&", "escapedChar", "!=", "'", "'", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The label descriptor [\"", "+", "labelDescriptor", "+", "\"] contains an invalid escape sequence. Backslash \"", "+", "\"characters (\\\\) must be followed by either an ampersand (&) or another \"", "+", "\"backslash.\"", ")", ";", "}", "}" ]
Confirms that the character at the specified index within the given label descriptor is a valid 'escapable' character. i.e. either an ampersand or backslash. @param index The position within the label descriptor of the character to be checked. @param labelDescriptor The label descriptor. @throws NullPointerException if {@code labelDescriptor} is null. @throws IllegalArgumentException if the given {@code index} position is beyond the length of the string or if the character at that position is not an ampersand or backslash.
[ "Confirms", "that", "the", "character", "at", "the", "specified", "index", "within", "the", "given", "label", "descriptor", "is", "a", "valid", "escapable", "character", ".", "i", ".", "e", ".", "either", "an", "ampersand", "or", "backslash", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java#L190-L210
12,049
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java
LabelInfo.configureLabel
public void configureLabel(JLabel label) { Assert.notNull(label, "label"); label.setText(this.text); label.setDisplayedMnemonic(getMnemonic()); if (getMnemonicIndex() >= -1) { label.setDisplayedMnemonicIndex(getMnemonicIndex()); } }
java
public void configureLabel(JLabel label) { Assert.notNull(label, "label"); label.setText(this.text); label.setDisplayedMnemonic(getMnemonic()); if (getMnemonicIndex() >= -1) { label.setDisplayedMnemonicIndex(getMnemonicIndex()); } }
[ "public", "void", "configureLabel", "(", "JLabel", "label", ")", "{", "Assert", ".", "notNull", "(", "label", ",", "\"label\"", ")", ";", "label", ".", "setText", "(", "this", ".", "text", ")", ";", "label", ".", "setDisplayedMnemonic", "(", "getMnemonic", "(", ")", ")", ";", "if", "(", "getMnemonicIndex", "(", ")", ">=", "-", "1", ")", "{", "label", ".", "setDisplayedMnemonicIndex", "(", "getMnemonicIndex", "(", ")", ")", ";", "}", "}" ]
Configures the given label with the parameters from this instance. @param label The label that is to be configured. @throws IllegalArgumentException if {@code label} is null.
[ "Configures", "the", "given", "label", "with", "the", "parameters", "from", "this", "instance", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java#L342-L353
12,050
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java
LabelInfo.configureLabelFor
public void configureLabelFor(JLabel label, JComponent component) { Assert.notNull(label, "label"); Assert.notNull(component, "component"); configureLabel(label); if (!(component instanceof JPanel)) { String labelText = label.getText(); if (!labelText.endsWith(":")) { if (logger.isDebugEnabled()) { logger.debug("Appending colon to text field label text '" + this.text + "'"); } label.setText(labelText + ":"); } } label.setLabelFor(component); }
java
public void configureLabelFor(JLabel label, JComponent component) { Assert.notNull(label, "label"); Assert.notNull(component, "component"); configureLabel(label); if (!(component instanceof JPanel)) { String labelText = label.getText(); if (!labelText.endsWith(":")) { if (logger.isDebugEnabled()) { logger.debug("Appending colon to text field label text '" + this.text + "'"); } label.setText(labelText + ":"); } } label.setLabelFor(component); }
[ "public", "void", "configureLabelFor", "(", "JLabel", "label", ",", "JComponent", "component", ")", "{", "Assert", ".", "notNull", "(", "label", ",", "\"label\"", ")", ";", "Assert", ".", "notNull", "(", "component", ",", "\"component\"", ")", ";", "configureLabel", "(", "label", ")", ";", "if", "(", "!", "(", "component", "instanceof", "JPanel", ")", ")", "{", "String", "labelText", "=", "label", ".", "getText", "(", ")", ";", "if", "(", "!", "labelText", ".", "endsWith", "(", "\":\"", ")", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Appending colon to text field label text '\"", "+", "this", ".", "text", "+", "\"'\"", ")", ";", "}", "label", ".", "setText", "(", "labelText", "+", "\":\"", ")", ";", "}", "}", "label", ".", "setLabelFor", "(", "component", ")", ";", "}" ]
Configures the given label with the property values described by this instance and then sets it as the label for the given component. @param label The label to be configured. @param component The component that the label is 'for'. @throws IllegalArgumentException if either argument is null. @see JLabel#setLabelFor(java.awt.Component)
[ "Configures", "the", "given", "label", "with", "the", "property", "values", "described", "by", "this", "instance", "and", "then", "sets", "it", "as", "the", "label", "for", "the", "given", "component", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java#L366-L389
12,051
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java
LabelInfo.configureButton
public void configureButton(AbstractButton button) { Assert.notNull(button); button.setText(this.text); button.setMnemonic(getMnemonic()); button.setDisplayedMnemonicIndex(getMnemonicIndex()); }
java
public void configureButton(AbstractButton button) { Assert.notNull(button); button.setText(this.text); button.setMnemonic(getMnemonic()); button.setDisplayedMnemonicIndex(getMnemonicIndex()); }
[ "public", "void", "configureButton", "(", "AbstractButton", "button", ")", "{", "Assert", ".", "notNull", "(", "button", ")", ";", "button", ".", "setText", "(", "this", ".", "text", ")", ";", "button", ".", "setMnemonic", "(", "getMnemonic", "(", ")", ")", ";", "button", ".", "setDisplayedMnemonicIndex", "(", "getMnemonicIndex", "(", ")", ")", ";", "}" ]
Configures the given button with the properties held in this instance. Note that this instance doesn't hold any keystroke accelerator information. @param button The button to be configured. @throws IllegalArgumentException if {@code button} is null.
[ "Configures", "the", "given", "button", "with", "the", "properties", "held", "in", "this", "instance", ".", "Note", "that", "this", "instance", "doesn", "t", "hold", "any", "keystroke", "accelerator", "information", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java#L399-L404
12,052
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.updateErrors
private void updateErrors() { boolean oldErrors = hasErrors; hasErrors = false; if (validationResults.getHasErrors()) { hasErrors = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasErrors()) { hasErrors = true; break; } } } firePropertyChange(HAS_ERRORS_PROPERTY, oldErrors, hasErrors); }
java
private void updateErrors() { boolean oldErrors = hasErrors; hasErrors = false; if (validationResults.getHasErrors()) { hasErrors = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasErrors()) { hasErrors = true; break; } } } firePropertyChange(HAS_ERRORS_PROPERTY, oldErrors, hasErrors); }
[ "private", "void", "updateErrors", "(", ")", "{", "boolean", "oldErrors", "=", "hasErrors", ";", "hasErrors", "=", "false", ";", "if", "(", "validationResults", ".", "getHasErrors", "(", ")", ")", "{", "hasErrors", "=", "true", ";", "}", "else", "{", "Iterator", "childIter", "=", "children", ".", "iterator", "(", ")", ";", "while", "(", "childIter", ".", "hasNext", "(", ")", ")", "{", "ValidationResultsModel", "childModel", "=", "(", "ValidationResultsModel", ")", "childIter", ".", "next", "(", ")", ";", "if", "(", "childModel", ".", "getHasErrors", "(", ")", ")", "{", "hasErrors", "=", "true", ";", "break", ";", "}", "}", "}", "firePropertyChange", "(", "HAS_ERRORS_PROPERTY", ",", "oldErrors", ",", "hasErrors", ")", ";", "}" ]
Revaluate the hasErrors property and fire an event if things have changed.
[ "Revaluate", "the", "hasErrors", "property", "and", "fire", "an", "event", "if", "things", "have", "changed", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L215-L232
12,053
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.updateInfo
private void updateInfo() { boolean oldInfo = hasInfo; hasInfo = false; if (validationResults.getHasInfo()) { hasInfo = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasInfo()) { hasInfo = true; break; } } } firePropertyChange(HAS_INFO_PROPERTY, oldInfo, hasInfo); }
java
private void updateInfo() { boolean oldInfo = hasInfo; hasInfo = false; if (validationResults.getHasInfo()) { hasInfo = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasInfo()) { hasInfo = true; break; } } } firePropertyChange(HAS_INFO_PROPERTY, oldInfo, hasInfo); }
[ "private", "void", "updateInfo", "(", ")", "{", "boolean", "oldInfo", "=", "hasInfo", ";", "hasInfo", "=", "false", ";", "if", "(", "validationResults", ".", "getHasInfo", "(", ")", ")", "{", "hasInfo", "=", "true", ";", "}", "else", "{", "Iterator", "childIter", "=", "children", ".", "iterator", "(", ")", ";", "while", "(", "childIter", ".", "hasNext", "(", ")", ")", "{", "ValidationResultsModel", "childModel", "=", "(", "ValidationResultsModel", ")", "childIter", ".", "next", "(", ")", ";", "if", "(", "childModel", ".", "getHasInfo", "(", ")", ")", "{", "hasInfo", "=", "true", ";", "break", ";", "}", "}", "}", "firePropertyChange", "(", "HAS_INFO_PROPERTY", ",", "oldInfo", ",", "hasInfo", ")", ";", "}" ]
Revaluate the hasInfo property and fire an event if things have changed.
[ "Revaluate", "the", "hasInfo", "property", "and", "fire", "an", "event", "if", "things", "have", "changed", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L245-L262
12,054
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.updateWarnings
private void updateWarnings() { boolean oldWarnings = hasWarnings; hasWarnings = false; if (validationResults.getHasWarnings()) { hasWarnings = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasWarnings()) { hasWarnings = true; break; } } } firePropertyChange(HAS_WARNINGS_PROPERTY, oldWarnings, hasWarnings); }
java
private void updateWarnings() { boolean oldWarnings = hasWarnings; hasWarnings = false; if (validationResults.getHasWarnings()) { hasWarnings = true; } else { Iterator childIter = children.iterator(); while (childIter.hasNext()) { ValidationResultsModel childModel = (ValidationResultsModel) childIter.next(); if (childModel.getHasWarnings()) { hasWarnings = true; break; } } } firePropertyChange(HAS_WARNINGS_PROPERTY, oldWarnings, hasWarnings); }
[ "private", "void", "updateWarnings", "(", ")", "{", "boolean", "oldWarnings", "=", "hasWarnings", ";", "hasWarnings", "=", "false", ";", "if", "(", "validationResults", ".", "getHasWarnings", "(", ")", ")", "{", "hasWarnings", "=", "true", ";", "}", "else", "{", "Iterator", "childIter", "=", "children", ".", "iterator", "(", ")", ";", "while", "(", "childIter", ".", "hasNext", "(", ")", ")", "{", "ValidationResultsModel", "childModel", "=", "(", "ValidationResultsModel", ")", "childIter", ".", "next", "(", ")", ";", "if", "(", "childModel", ".", "getHasWarnings", "(", ")", ")", "{", "hasWarnings", "=", "true", ";", "break", ";", "}", "}", "}", "firePropertyChange", "(", "HAS_WARNINGS_PROPERTY", ",", "oldWarnings", ",", "hasWarnings", ")", ";", "}" ]
Revaluate the hasWarnings property and fire an event if things have changed.
[ "Revaluate", "the", "hasWarnings", "property", "and", "fire", "an", "event", "if", "things", "have", "changed", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L276-L293
12,055
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.add
public void add(ValidationResultsModel validationResultsModel) { if (children.add(validationResultsModel)) { validationResultsModel.addValidationListener(this); validationResultsModel.addPropertyChangeListener(HAS_ERRORS_PROPERTY, this); validationResultsModel.addPropertyChangeListener(HAS_WARNINGS_PROPERTY, this); validationResultsModel.addPropertyChangeListener(HAS_INFO_PROPERTY, this); if ((validationResultsModel.getMessageCount() > 0)) fireChangedEvents(); } }
java
public void add(ValidationResultsModel validationResultsModel) { if (children.add(validationResultsModel)) { validationResultsModel.addValidationListener(this); validationResultsModel.addPropertyChangeListener(HAS_ERRORS_PROPERTY, this); validationResultsModel.addPropertyChangeListener(HAS_WARNINGS_PROPERTY, this); validationResultsModel.addPropertyChangeListener(HAS_INFO_PROPERTY, this); if ((validationResultsModel.getMessageCount() > 0)) fireChangedEvents(); } }
[ "public", "void", "add", "(", "ValidationResultsModel", "validationResultsModel", ")", "{", "if", "(", "children", ".", "add", "(", "validationResultsModel", ")", ")", "{", "validationResultsModel", ".", "addValidationListener", "(", "this", ")", ";", "validationResultsModel", ".", "addPropertyChangeListener", "(", "HAS_ERRORS_PROPERTY", ",", "this", ")", ";", "validationResultsModel", ".", "addPropertyChangeListener", "(", "HAS_WARNINGS_PROPERTY", ",", "this", ")", ";", "validationResultsModel", ".", "addPropertyChangeListener", "(", "HAS_INFO_PROPERTY", ",", "this", ")", ";", "if", "(", "(", "validationResultsModel", ".", "getMessageCount", "(", ")", ">", "0", ")", ")", "fireChangedEvents", "(", ")", ";", "}", "}" ]
Add a validationResultsModel as a child to this one. Attach listeners and if it already has messages, fire events. @param validationResultsModel
[ "Add", "a", "validationResultsModel", "as", "a", "child", "to", "this", "one", ".", "Attach", "listeners", "and", "if", "it", "already", "has", "messages", "fire", "events", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L436-L445
12,056
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.remove
public void remove(ValidationResultsModel validationResultsModel) { if (children.remove(validationResultsModel)) { validationResultsModel.removeValidationListener(this); validationResultsModel.removePropertyChangeListener(HAS_ERRORS_PROPERTY, this); validationResultsModel.removePropertyChangeListener(HAS_WARNINGS_PROPERTY, this); validationResultsModel.removePropertyChangeListener(HAS_INFO_PROPERTY, this); if (validationResultsModel.getMessageCount() > 0) fireChangedEvents(); } }
java
public void remove(ValidationResultsModel validationResultsModel) { if (children.remove(validationResultsModel)) { validationResultsModel.removeValidationListener(this); validationResultsModel.removePropertyChangeListener(HAS_ERRORS_PROPERTY, this); validationResultsModel.removePropertyChangeListener(HAS_WARNINGS_PROPERTY, this); validationResultsModel.removePropertyChangeListener(HAS_INFO_PROPERTY, this); if (validationResultsModel.getMessageCount() > 0) fireChangedEvents(); } }
[ "public", "void", "remove", "(", "ValidationResultsModel", "validationResultsModel", ")", "{", "if", "(", "children", ".", "remove", "(", "validationResultsModel", ")", ")", "{", "validationResultsModel", ".", "removeValidationListener", "(", "this", ")", ";", "validationResultsModel", ".", "removePropertyChangeListener", "(", "HAS_ERRORS_PROPERTY", ",", "this", ")", ";", "validationResultsModel", ".", "removePropertyChangeListener", "(", "HAS_WARNINGS_PROPERTY", ",", "this", ")", ";", "validationResultsModel", ".", "removePropertyChangeListener", "(", "HAS_INFO_PROPERTY", ",", "this", ")", ";", "if", "(", "validationResultsModel", ".", "getMessageCount", "(", ")", ">", "0", ")", "fireChangedEvents", "(", ")", ";", "}", "}" ]
Remove the given validationResultsModel from the list of children. Remove listeners and if it had messages, fire events. @param validationResultsModel
[ "Remove", "the", "given", "validationResultsModel", "from", "the", "list", "of", "children", ".", "Remove", "listeners", "and", "if", "it", "had", "messages", "fire", "events", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L453-L462
12,057
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java
DefaultValidationResultsModel.propertyChange
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == HAS_ERRORS_PROPERTY) updateErrors(); else if (evt.getPropertyName() == HAS_WARNINGS_PROPERTY) updateWarnings(); else if (evt.getPropertyName() == HAS_INFO_PROPERTY) updateInfo(); }
java
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == HAS_ERRORS_PROPERTY) updateErrors(); else if (evt.getPropertyName() == HAS_WARNINGS_PROPERTY) updateWarnings(); else if (evt.getPropertyName() == HAS_INFO_PROPERTY) updateInfo(); }
[ "public", "void", "propertyChange", "(", "PropertyChangeEvent", "evt", ")", "{", "if", "(", "evt", ".", "getPropertyName", "(", ")", "==", "HAS_ERRORS_PROPERTY", ")", "updateErrors", "(", ")", ";", "else", "if", "(", "evt", ".", "getPropertyName", "(", ")", "==", "HAS_WARNINGS_PROPERTY", ")", "updateWarnings", "(", ")", ";", "else", "if", "(", "evt", ".", "getPropertyName", "(", ")", "==", "HAS_INFO_PROPERTY", ")", "updateInfo", "(", ")", ";", "}" ]
Forwarding of known property events coming from child models. Each event triggers a specific evaluation of the parent property, which will trigger events as needed.
[ "Forwarding", "of", "known", "property", "events", "coming", "from", "child", "models", ".", "Each", "event", "triggers", "a", "specific", "evaluation", "of", "the", "parent", "property", "which", "will", "trigger", "events", "as", "needed", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/validation/support/DefaultValidationResultsModel.java#L477-L484
12,058
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java
AuthorityConfigurableSecurityController.addAndPrepareControlledObject
private void addAndPrepareControlledObject(Authorizable controlledObject) { controlledObjects.add(new WeakReference<Authorizable>(controlledObject)); // Properly configure the new object boolean authorize = shouldAuthorize(getLastAuthentication(), controlledObject); updateControlledObject(controlledObject, authorize); }
java
private void addAndPrepareControlledObject(Authorizable controlledObject) { controlledObjects.add(new WeakReference<Authorizable>(controlledObject)); // Properly configure the new object boolean authorize = shouldAuthorize(getLastAuthentication(), controlledObject); updateControlledObject(controlledObject, authorize); }
[ "private", "void", "addAndPrepareControlledObject", "(", "Authorizable", "controlledObject", ")", "{", "controlledObjects", ".", "add", "(", "new", "WeakReference", "<", "Authorizable", ">", "(", "controlledObject", ")", ")", ";", "// Properly configure the new object", "boolean", "authorize", "=", "shouldAuthorize", "(", "getLastAuthentication", "(", ")", ",", "controlledObject", ")", ";", "updateControlledObject", "(", "controlledObject", ",", "authorize", ")", ";", "}" ]
Add a new object to the list of controlled objects. Install our last known authorization decision so newly created objects will reflect the current security state. @param controlledObject to add
[ "Add", "a", "new", "object", "to", "the", "list", "of", "controlled", "objects", ".", "Install", "our", "last", "known", "authorization", "decision", "so", "newly", "created", "objects", "will", "reflect", "the", "current", "security", "state", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java#L122-L129
12,059
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java
AuthorityConfigurableSecurityController.runAuthorization
protected void runAuthorization() { // Install the decision for (Iterator iter = controlledObjects.iterator(); iter.hasNext();) { WeakReference ref = (WeakReference) iter.next(); Authorizable controlledObject = (Authorizable) ref.get(); if (controlledObject == null) { // Has been GCed, remove from our list iter.remove(); } else { updateControlledObject(controlledObject, shouldAuthorize(getLastAuthentication(), controlledObject)); } } }
java
protected void runAuthorization() { // Install the decision for (Iterator iter = controlledObjects.iterator(); iter.hasNext();) { WeakReference ref = (WeakReference) iter.next(); Authorizable controlledObject = (Authorizable) ref.get(); if (controlledObject == null) { // Has been GCed, remove from our list iter.remove(); } else { updateControlledObject(controlledObject, shouldAuthorize(getLastAuthentication(), controlledObject)); } } }
[ "protected", "void", "runAuthorization", "(", ")", "{", "// Install the decision", "for", "(", "Iterator", "iter", "=", "controlledObjects", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "WeakReference", "ref", "=", "(", "WeakReference", ")", "iter", ".", "next", "(", ")", ";", "Authorizable", "controlledObject", "=", "(", "Authorizable", ")", "ref", ".", "get", "(", ")", ";", "if", "(", "controlledObject", "==", "null", ")", "{", "// Has been GCed, remove from our list", "iter", ".", "remove", "(", ")", ";", "}", "else", "{", "updateControlledObject", "(", "controlledObject", ",", "shouldAuthorize", "(", "getLastAuthentication", "(", ")", ",", "controlledObject", ")", ")", ";", "}", "}", "}" ]
securityAwareConfigurer Update the authorization of all controlled objects.
[ "securityAwareConfigurer", "Update", "the", "authorization", "of", "all", "controlled", "objects", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java#L319-L338
12,060
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/component/RoundedBorder.java
RoundedBorder.getInteriorRectangle
public static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height) { final Insets insets; if (b != null) { insets = b.getBorderInsets(c); } else { insets = new Insets(0, 0, 0, 0); } return new Rectangle(x + insets.left, // y + insets.top, // width - insets.right - insets.left, // height - insets.top - insets.bottom); }
java
public static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height) { final Insets insets; if (b != null) { insets = b.getBorderInsets(c); } else { insets = new Insets(0, 0, 0, 0); } return new Rectangle(x + insets.left, // y + insets.top, // width - insets.right - insets.left, // height - insets.top - insets.bottom); }
[ "public", "static", "Rectangle", "getInteriorRectangle", "(", "Component", "c", ",", "Border", "b", ",", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "final", "Insets", "insets", ";", "if", "(", "b", "!=", "null", ")", "{", "insets", "=", "b", ".", "getBorderInsets", "(", "c", ")", ";", "}", "else", "{", "insets", "=", "new", "Insets", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "}", "return", "new", "Rectangle", "(", "x", "+", "insets", ".", "left", ",", "//", "y", "+", "insets", ".", "top", ",", "//", "width", "-", "insets", ".", "right", "-", "insets", ".", "left", ",", "//", "height", "-", "insets", ".", "top", "-", "insets", ".", "bottom", ")", ";", "}" ]
Gets the interior rectangle. @param c the target component. @param b the border. @param x the x coordinate. @param y the y coordinate. @param width the width. @param height the height. @return the rectangle.
[ "Gets", "the", "interior", "rectangle", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/component/RoundedBorder.java#L167-L180
12,061
lievendoclo/Valkyrie-RCP
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/remoting/BasicAuthHttpInvokerProxyFactoryBean.java
BasicAuthHttpInvokerProxyFactoryBean.setAuthenticationToken
public void setAuthenticationToken(Authentication authentication) { if( logger.isDebugEnabled() ) { logger.debug( "New authentication token: " + authentication ); } final HttpInvokerRequestExecutor hire = getHttpInvokerRequestExecutor(); if( hire instanceof BasicAuthHttpInvokerRequestExecutor ) { if( logger.isDebugEnabled() ) { logger.debug( "Pass it along to executor" ); } ((BasicAuthHttpInvokerRequestExecutor) hire).setAuthenticationToken( authentication ); } }
java
public void setAuthenticationToken(Authentication authentication) { if( logger.isDebugEnabled() ) { logger.debug( "New authentication token: " + authentication ); } final HttpInvokerRequestExecutor hire = getHttpInvokerRequestExecutor(); if( hire instanceof BasicAuthHttpInvokerRequestExecutor ) { if( logger.isDebugEnabled() ) { logger.debug( "Pass it along to executor" ); } ((BasicAuthHttpInvokerRequestExecutor) hire).setAuthenticationToken( authentication ); } }
[ "public", "void", "setAuthenticationToken", "(", "Authentication", "authentication", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"New authentication token: \"", "+", "authentication", ")", ";", "}", "final", "HttpInvokerRequestExecutor", "hire", "=", "getHttpInvokerRequestExecutor", "(", ")", ";", "if", "(", "hire", "instanceof", "BasicAuthHttpInvokerRequestExecutor", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Pass it along to executor\"", ")", ";", "}", "(", "(", "BasicAuthHttpInvokerRequestExecutor", ")", "hire", ")", ".", "setAuthenticationToken", "(", "authentication", ")", ";", "}", "}" ]
Handle a change in the current authentication token. Pass it along to the executor if it's of the proper type. @see BasicAuthHttpInvokerRequestExecutor @see AuthenticationAware#setAuthenticationToken(org.springframework.security.Authentication)
[ "Handle", "a", "change", "in", "the", "current", "authentication", "token", ".", "Pass", "it", "along", "to", "the", "executor", "if", "it", "s", "of", "the", "proper", "type", "." ]
6aad6e640b348cda8f3b0841f6e42025233f1eb8
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/remoting/BasicAuthHttpInvokerProxyFactoryBean.java#L64-L76
12,062
youngmonkeys/ezyfox-sfs2x
src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java
CreateRoomImpl.execute
@SuppressWarnings("unchecked") @Override public Boolean execute() { for(int i = 0 ; i < agents.length ; i++) { createRoom(i); } return Boolean.TRUE; }
java
@SuppressWarnings("unchecked") @Override public Boolean execute() { for(int i = 0 ; i < agents.length ; i++) { createRoom(i); } return Boolean.TRUE; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "Boolean", "execute", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "agents", ".", "length", ";", "i", "++", ")", "{", "createRoom", "(", "i", ")", ";", "}", "return", "Boolean", ".", "TRUE", ";", "}" ]
Execute to create list of room
[ "Execute", "to", "create", "list", "of", "room" ]
7e004033a3b551c3ae970a0c8f45db7b1ec144de
https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java#L68-L75
12,063
youngmonkeys/ezyfox-sfs2x
src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java
CreateRoomImpl.createRoom
private void createRoom(int index) { ApiRoom agent = agents[index]; try { CreateRoomSettings settings = createRoomSettings(agent); User owner = CommandUtil.getSfsUser(agent.getOwner(), api); Room room = api.createRoom(extension.getParentZone(), settings, owner); room.setProperty(APIKey.ROOM, agent); agent.setId(room.getId()); agent.setPasswordProtected(room.isPasswordProtected()); agent.setCommand(context.command(RoomInfo.class).room(room.getId())); } catch (SFSCreateRoomException e) { throw new IllegalStateException("Can not create room " + agent.getName(), e); } }
java
private void createRoom(int index) { ApiRoom agent = agents[index]; try { CreateRoomSettings settings = createRoomSettings(agent); User owner = CommandUtil.getSfsUser(agent.getOwner(), api); Room room = api.createRoom(extension.getParentZone(), settings, owner); room.setProperty(APIKey.ROOM, agent); agent.setId(room.getId()); agent.setPasswordProtected(room.isPasswordProtected()); agent.setCommand(context.command(RoomInfo.class).room(room.getId())); } catch (SFSCreateRoomException e) { throw new IllegalStateException("Can not create room " + agent.getName(), e); } }
[ "private", "void", "createRoom", "(", "int", "index", ")", "{", "ApiRoom", "agent", "=", "agents", "[", "index", "]", ";", "try", "{", "CreateRoomSettings", "settings", "=", "createRoomSettings", "(", "agent", ")", ";", "User", "owner", "=", "CommandUtil", ".", "getSfsUser", "(", "agent", ".", "getOwner", "(", ")", ",", "api", ")", ";", "Room", "room", "=", "api", ".", "createRoom", "(", "extension", ".", "getParentZone", "(", ")", ",", "settings", ",", "owner", ")", ";", "room", ".", "setProperty", "(", "APIKey", ".", "ROOM", ",", "agent", ")", ";", "agent", ".", "setId", "(", "room", ".", "getId", "(", ")", ")", ";", "agent", ".", "setPasswordProtected", "(", "room", ".", "isPasswordProtected", "(", ")", ")", ";", "agent", ".", "setCommand", "(", "context", ".", "command", "(", "RoomInfo", ".", "class", ")", ".", "room", "(", "room", ".", "getId", "(", ")", ")", ")", ";", "}", "catch", "(", "SFSCreateRoomException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Can not create room \"", "+", "agent", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}" ]
Create a room at index @param index index
[ "Create", "a", "room", "at", "index" ]
7e004033a3b551c3ae970a0c8f45db7b1ec144de
https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java#L82-L96
12,064
youngmonkeys/ezyfox-sfs2x
src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java
CreateRoomImpl.createRoomSettings
private CreateRoomSettings createRoomSettings(ApiRoom agent) { validateRoomAgentClass(agent); CreateRoomSettings settings = new CreateRoomSettings(); settings.setName(agent.getName()); settings.setPassword(agent.getPassword()); settings.setDynamic(agent.isDynamic()); settings.setGame(agent.isGame()); settings.setHidden(agent.isHidden()); settings.setMaxSpectators(agent.getMaxSpectators()); settings.setMaxUsers(agent.getMaxUsers()); settings.setMaxVariablesAllowed(agent.getMaxRoomVariablesAllowed()); settings.setRoomProperties(agent.getProperties()); settings.setGroupId(agent.getGroupdId()); settings.setUseWordsFilter(agent.isUseWordsFilter()); settings.setAutoRemoveMode(SFSRoomRemoveMode.fromString(agent.getRemoveMode().name())); if(agent.getExtension() != null) settings.setExtension(new RoomExtensionSettings(agent.getExtension().getName(), agent.getExtension().getClazz())); return settings; }
java
private CreateRoomSettings createRoomSettings(ApiRoom agent) { validateRoomAgentClass(agent); CreateRoomSettings settings = new CreateRoomSettings(); settings.setName(agent.getName()); settings.setPassword(agent.getPassword()); settings.setDynamic(agent.isDynamic()); settings.setGame(agent.isGame()); settings.setHidden(agent.isHidden()); settings.setMaxSpectators(agent.getMaxSpectators()); settings.setMaxUsers(agent.getMaxUsers()); settings.setMaxVariablesAllowed(agent.getMaxRoomVariablesAllowed()); settings.setRoomProperties(agent.getProperties()); settings.setGroupId(agent.getGroupdId()); settings.setUseWordsFilter(agent.isUseWordsFilter()); settings.setAutoRemoveMode(SFSRoomRemoveMode.fromString(agent.getRemoveMode().name())); if(agent.getExtension() != null) settings.setExtension(new RoomExtensionSettings(agent.getExtension().getName(), agent.getExtension().getClazz())); return settings; }
[ "private", "CreateRoomSettings", "createRoomSettings", "(", "ApiRoom", "agent", ")", "{", "validateRoomAgentClass", "(", "agent", ")", ";", "CreateRoomSettings", "settings", "=", "new", "CreateRoomSettings", "(", ")", ";", "settings", ".", "setName", "(", "agent", ".", "getName", "(", ")", ")", ";", "settings", ".", "setPassword", "(", "agent", ".", "getPassword", "(", ")", ")", ";", "settings", ".", "setDynamic", "(", "agent", ".", "isDynamic", "(", ")", ")", ";", "settings", ".", "setGame", "(", "agent", ".", "isGame", "(", ")", ")", ";", "settings", ".", "setHidden", "(", "agent", ".", "isHidden", "(", ")", ")", ";", "settings", ".", "setMaxSpectators", "(", "agent", ".", "getMaxSpectators", "(", ")", ")", ";", "settings", ".", "setMaxUsers", "(", "agent", ".", "getMaxUsers", "(", ")", ")", ";", "settings", ".", "setMaxVariablesAllowed", "(", "agent", ".", "getMaxRoomVariablesAllowed", "(", ")", ")", ";", "settings", ".", "setRoomProperties", "(", "agent", ".", "getProperties", "(", ")", ")", ";", "settings", ".", "setGroupId", "(", "agent", ".", "getGroupdId", "(", ")", ")", ";", "settings", ".", "setUseWordsFilter", "(", "agent", ".", "isUseWordsFilter", "(", ")", ")", ";", "settings", ".", "setAutoRemoveMode", "(", "SFSRoomRemoveMode", ".", "fromString", "(", "agent", ".", "getRemoveMode", "(", ")", ".", "name", "(", ")", ")", ")", ";", "if", "(", "agent", ".", "getExtension", "(", ")", "!=", "null", ")", "settings", ".", "setExtension", "(", "new", "RoomExtensionSettings", "(", "agent", ".", "getExtension", "(", ")", ".", "getName", "(", ")", ",", "agent", ".", "getExtension", "(", ")", ".", "getClazz", "(", ")", ")", ")", ";", "return", "settings", ";", "}" ]
Create smartfox CreateRoomSettings object @param agent room agent object @return CreateRoomSettings object
[ "Create", "smartfox", "CreateRoomSettings", "object" ]
7e004033a3b551c3ae970a0c8f45db7b1ec144de
https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/CreateRoomImpl.java#L104-L122
12,065
youngmonkeys/ezyfox-sfs2x
src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/UpdateUserImpl.java
UpdateUserImpl.execute
@SuppressWarnings("unchecked") @Override public <T> T execute() { User sfsUser = CommandUtil.getSfsUser(agent, api); if(sfsUser == null) return null; try { AgentClassUnwrapper unwrapper = context.getUserAgentClass(agent.getClass()) .getUnwrapper(); List<UserVariable> variables = new UserAgentSerializer().serialize(unwrapper, agent); List<UserVariable> answer = variables; if(includedVars.size() > 0) answer = getVariables(variables, includedVars); answer.removeAll(getVariables(answer, excludedVars)); //update user variables on server and notify to client if(toClient) api.setUserVariables(sfsUser, answer); // only update user variables on server else sfsUser.setVariables(answer); } catch (SFSVariableException e) { throw new IllegalStateException(e); } return (T)agent; }
java
@SuppressWarnings("unchecked") @Override public <T> T execute() { User sfsUser = CommandUtil.getSfsUser(agent, api); if(sfsUser == null) return null; try { AgentClassUnwrapper unwrapper = context.getUserAgentClass(agent.getClass()) .getUnwrapper(); List<UserVariable> variables = new UserAgentSerializer().serialize(unwrapper, agent); List<UserVariable> answer = variables; if(includedVars.size() > 0) answer = getVariables(variables, includedVars); answer.removeAll(getVariables(answer, excludedVars)); //update user variables on server and notify to client if(toClient) api.setUserVariables(sfsUser, answer); // only update user variables on server else sfsUser.setVariables(answer); } catch (SFSVariableException e) { throw new IllegalStateException(e); } return (T)agent; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "<", "T", ">", "T", "execute", "(", ")", "{", "User", "sfsUser", "=", "CommandUtil", ".", "getSfsUser", "(", "agent", ",", "api", ")", ";", "if", "(", "sfsUser", "==", "null", ")", "return", "null", ";", "try", "{", "AgentClassUnwrapper", "unwrapper", "=", "context", ".", "getUserAgentClass", "(", "agent", ".", "getClass", "(", ")", ")", ".", "getUnwrapper", "(", ")", ";", "List", "<", "UserVariable", ">", "variables", "=", "new", "UserAgentSerializer", "(", ")", ".", "serialize", "(", "unwrapper", ",", "agent", ")", ";", "List", "<", "UserVariable", ">", "answer", "=", "variables", ";", "if", "(", "includedVars", ".", "size", "(", ")", ">", "0", ")", "answer", "=", "getVariables", "(", "variables", ",", "includedVars", ")", ";", "answer", ".", "removeAll", "(", "getVariables", "(", "answer", ",", "excludedVars", ")", ")", ";", "//update user variables on server and notify to client", "if", "(", "toClient", ")", "api", ".", "setUserVariables", "(", "sfsUser", ",", "answer", ")", ";", "// only update user variables on server", "else", "sfsUser", ".", "setVariables", "(", "answer", ")", ";", "}", "catch", "(", "SFSVariableException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "return", "(", "T", ")", "agent", ";", "}" ]
Execute to update user variables
[ "Execute", "to", "update", "user", "variables" ]
7e004033a3b551c3ae970a0c8f45db7b1ec144de
https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/command/impl/UpdateUserImpl.java#L44-L68
12,066
mgormley/pacaya
src/main/java/edu/jhu/pacaya/nlp/data/SentenceCollection.java
SentenceCollection.getVocab
public Set<String> getVocab() { Set<String> vocab = new HashSet<String>(); for (Sentence sent : this) { for (String label : sent) { vocab.add(label); } } return vocab; }
java
public Set<String> getVocab() { Set<String> vocab = new HashSet<String>(); for (Sentence sent : this) { for (String label : sent) { vocab.add(label); } } return vocab; }
[ "public", "Set", "<", "String", ">", "getVocab", "(", ")", "{", "Set", "<", "String", ">", "vocab", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "Sentence", "sent", ":", "this", ")", "{", "for", "(", "String", "label", ":", "sent", ")", "{", "vocab", ".", "add", "(", "label", ")", ";", "}", "}", "return", "vocab", ";", "}" ]
Vocabulary of the sentences.
[ "Vocabulary", "of", "the", "sentences", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/nlp/data/SentenceCollection.java#L77-L85
12,067
JodaOrg/joda-collect
src/main/java/org/joda/collect/grid/ImmutableGrid.java
ImmutableGrid.of
public static <R> ImmutableGrid<R> of(int rowCount, int columnCount) { return new EmptyGrid<R>(rowCount, columnCount); }
java
public static <R> ImmutableGrid<R> of(int rowCount, int columnCount) { return new EmptyGrid<R>(rowCount, columnCount); }
[ "public", "static", "<", "R", ">", "ImmutableGrid", "<", "R", ">", "of", "(", "int", "rowCount", ",", "int", "columnCount", ")", "{", "return", "new", "EmptyGrid", "<", "R", ">", "(", "rowCount", ",", "columnCount", ")", ";", "}" ]
Obtains an empty immutable grid of the specified row-column count. @param <R> the type of the value @param rowCount the number of rows, zero or greater @param columnCount the number of columns, zero or greater @return the empty immutable grid, not null
[ "Obtains", "an", "empty", "immutable", "grid", "of", "the", "specified", "row", "-", "column", "count", "." ]
a4b05d5eebad5beb41715c0678cf11835cf0fa3f
https://github.com/JodaOrg/joda-collect/blob/a4b05d5eebad5beb41715c0678cf11835cf0fa3f/src/main/java/org/joda/collect/grid/ImmutableGrid.java#L44-L46
12,068
JodaOrg/joda-collect
src/main/java/org/joda/collect/grid/ImmutableGrid.java
ImmutableGrid.of
public static <R> ImmutableGrid<R> of(int rowCount, int columnCount, int row, int column, R value) { return new SingletonGrid<R>(rowCount, columnCount, row, column, value); }
java
public static <R> ImmutableGrid<R> of(int rowCount, int columnCount, int row, int column, R value) { return new SingletonGrid<R>(rowCount, columnCount, row, column, value); }
[ "public", "static", "<", "R", ">", "ImmutableGrid", "<", "R", ">", "of", "(", "int", "rowCount", ",", "int", "columnCount", ",", "int", "row", ",", "int", "column", ",", "R", "value", ")", "{", "return", "new", "SingletonGrid", "<", "R", ">", "(", "rowCount", ",", "columnCount", ",", "row", ",", "column", ",", "value", ")", ";", "}" ]
Obtains an immutable grid of the specified row-column count with a single cell. @param <R> the type of the value @param rowCount the number of rows, zero or greater @param columnCount the number of columns, zero or greater @param row the row of the single cell, zero or greater @param column the column of the single cell, zero or greater @param value the value of the single cell, not null @return the empty immutable grid, not null
[ "Obtains", "an", "immutable", "grid", "of", "the", "specified", "row", "-", "column", "count", "with", "a", "single", "cell", "." ]
a4b05d5eebad5beb41715c0678cf11835cf0fa3f
https://github.com/JodaOrg/joda-collect/blob/a4b05d5eebad5beb41715c0678cf11835cf0fa3f/src/main/java/org/joda/collect/grid/ImmutableGrid.java#L72-L74
12,069
JodaOrg/joda-collect
src/main/java/org/joda/collect/grid/ImmutableGrid.java
ImmutableGrid.copyOf
public static <R> ImmutableGrid<R> copyOf(int rowCount, int columnCount, Cell<R> cell) { if (cell == null) { throw new IllegalArgumentException("Cell must not be null"); } return new SingletonGrid<R>(rowCount, columnCount, cell); }
java
public static <R> ImmutableGrid<R> copyOf(int rowCount, int columnCount, Cell<R> cell) { if (cell == null) { throw new IllegalArgumentException("Cell must not be null"); } return new SingletonGrid<R>(rowCount, columnCount, cell); }
[ "public", "static", "<", "R", ">", "ImmutableGrid", "<", "R", ">", "copyOf", "(", "int", "rowCount", ",", "int", "columnCount", ",", "Cell", "<", "R", ">", "cell", ")", "{", "if", "(", "cell", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cell must not be null\"", ")", ";", "}", "return", "new", "SingletonGrid", "<", "R", ">", "(", "rowCount", ",", "columnCount", ",", "cell", ")", ";", "}" ]
Obtains an immutable grid with one cell. @param <R> the type of the value @param rowCount the number of rows, zero or greater @param columnCount the number of columns, zero or greater @param cell the cell that the grid should contain, not null @return the immutable grid, not null @throws IndexOutOfBoundsException if either index is less than zero
[ "Obtains", "an", "immutable", "grid", "with", "one", "cell", "." ]
a4b05d5eebad5beb41715c0678cf11835cf0fa3f
https://github.com/JodaOrg/joda-collect/blob/a4b05d5eebad5beb41715c0678cf11835cf0fa3f/src/main/java/org/joda/collect/grid/ImmutableGrid.java#L87-L92
12,070
JodaOrg/joda-collect
src/main/java/org/joda/collect/grid/ImmutableGrid.java
ImmutableGrid.copyOf
public static <R> ImmutableGrid<R> copyOf(int rowCount, int columnCount, Iterable<? extends Cell<R>> cells) { if (cells == null) { throw new IllegalArgumentException("Cells must not be null"); } if (!cells.iterator().hasNext()) { return new EmptyGrid<R>(rowCount, columnCount); } return new SparseImmutableGrid<R>(rowCount, columnCount, cells); }
java
public static <R> ImmutableGrid<R> copyOf(int rowCount, int columnCount, Iterable<? extends Cell<R>> cells) { if (cells == null) { throw new IllegalArgumentException("Cells must not be null"); } if (!cells.iterator().hasNext()) { return new EmptyGrid<R>(rowCount, columnCount); } return new SparseImmutableGrid<R>(rowCount, columnCount, cells); }
[ "public", "static", "<", "R", ">", "ImmutableGrid", "<", "R", ">", "copyOf", "(", "int", "rowCount", ",", "int", "columnCount", ",", "Iterable", "<", "?", "extends", "Cell", "<", "R", ">", ">", "cells", ")", "{", "if", "(", "cells", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cells must not be null\"", ")", ";", "}", "if", "(", "!", "cells", ".", "iterator", "(", ")", ".", "hasNext", "(", ")", ")", "{", "return", "new", "EmptyGrid", "<", "R", ">", "(", "rowCount", ",", "columnCount", ")", ";", "}", "return", "new", "SparseImmutableGrid", "<", "R", ">", "(", "rowCount", ",", "columnCount", ",", "cells", ")", ";", "}" ]
Obtains an immutable grid by copying a set of cells. @param <R> the type of the value @param rowCount the number of rows, zero or greater @param columnCount the number of columns, zero or greater @param cells the cells to copy, not null @return the immutable grid, not null @throws IndexOutOfBoundsException if either index is less than zero
[ "Obtains", "an", "immutable", "grid", "by", "copying", "a", "set", "of", "cells", "." ]
a4b05d5eebad5beb41715c0678cf11835cf0fa3f
https://github.com/JodaOrg/joda-collect/blob/a4b05d5eebad5beb41715c0678cf11835cf0fa3f/src/main/java/org/joda/collect/grid/ImmutableGrid.java#L104-L112
12,071
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/decode/MbrDecoder.java
MbrDecoder.decode
public FgInferencer decode(FgModel model, UFgExample ex) { // Run inference. FactorGraph fgLatPred = ex.getFactorGraph(); fgLatPred.updateFromModel(model); FgInferencer infLatPred = prm.infFactory.getInferencer(fgLatPred); infLatPred.run(); decode(infLatPred, ex); return infLatPred; }
java
public FgInferencer decode(FgModel model, UFgExample ex) { // Run inference. FactorGraph fgLatPred = ex.getFactorGraph(); fgLatPred.updateFromModel(model); FgInferencer infLatPred = prm.infFactory.getInferencer(fgLatPred); infLatPred.run(); decode(infLatPred, ex); return infLatPred; }
[ "public", "FgInferencer", "decode", "(", "FgModel", "model", ",", "UFgExample", "ex", ")", "{", "// Run inference.", "FactorGraph", "fgLatPred", "=", "ex", ".", "getFactorGraph", "(", ")", ";", "fgLatPred", ".", "updateFromModel", "(", "model", ")", ";", "FgInferencer", "infLatPred", "=", "prm", ".", "infFactory", ".", "getInferencer", "(", "fgLatPred", ")", ";", "infLatPred", ".", "run", "(", ")", ";", "decode", "(", "infLatPred", ",", "ex", ")", ";", "return", "infLatPred", ";", "}" ]
Runs inference and computes the MBR variable configuration. The outputs are stored on the class, and can be queried after this call to decode. @param model The input model. @param ex The input data. @return the FgInferencer that was used.
[ "Runs", "inference", "and", "computes", "the", "MBR", "variable", "configuration", ".", "The", "outputs", "are", "stored", "on", "the", "class", "and", "can", "be", "queried", "after", "this", "call", "to", "decode", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/decode/MbrDecoder.java#L70-L78
12,072
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/decode/MbrDecoder.java
MbrDecoder.decode
public void decode(FgInferencer infLatPred, UFgExample ex) { FactorGraph fgLatPred = ex.getFactorGraph(); mbrVarConfig = new VarConfig(); margs = new ArrayList<VarTensor>(); varMargMap = new HashMap<Var,Double>(); // Get the MBR configuration of all the latent and predicted // variables. if (prm.loss == Loss.L1 || prm.loss == Loss.MSE) { for (int varId = 0; varId < fgLatPred.getNumVars(); varId++) { Var var = fgLatPred.getVar(varId); VarTensor marg = infLatPred.getMarginalsForVarId(varId); margs.add(marg); int argmaxState = marg.getArgmaxConfigId(); mbrVarConfig.put(var, argmaxState); varMargMap.put(var, marg.getValue(argmaxState)); if (log.isTraceEnabled()) { log.trace("Variable marginal: " + marg); } } } else { throw new RuntimeException("Loss type not implemented: " + prm.loss); } }
java
public void decode(FgInferencer infLatPred, UFgExample ex) { FactorGraph fgLatPred = ex.getFactorGraph(); mbrVarConfig = new VarConfig(); margs = new ArrayList<VarTensor>(); varMargMap = new HashMap<Var,Double>(); // Get the MBR configuration of all the latent and predicted // variables. if (prm.loss == Loss.L1 || prm.loss == Loss.MSE) { for (int varId = 0; varId < fgLatPred.getNumVars(); varId++) { Var var = fgLatPred.getVar(varId); VarTensor marg = infLatPred.getMarginalsForVarId(varId); margs.add(marg); int argmaxState = marg.getArgmaxConfigId(); mbrVarConfig.put(var, argmaxState); varMargMap.put(var, marg.getValue(argmaxState)); if (log.isTraceEnabled()) { log.trace("Variable marginal: " + marg); } } } else { throw new RuntimeException("Loss type not implemented: " + prm.loss); } }
[ "public", "void", "decode", "(", "FgInferencer", "infLatPred", ",", "UFgExample", "ex", ")", "{", "FactorGraph", "fgLatPred", "=", "ex", ".", "getFactorGraph", "(", ")", ";", "mbrVarConfig", "=", "new", "VarConfig", "(", ")", ";", "margs", "=", "new", "ArrayList", "<", "VarTensor", ">", "(", ")", ";", "varMargMap", "=", "new", "HashMap", "<", "Var", ",", "Double", ">", "(", ")", ";", "// Get the MBR configuration of all the latent and predicted", "// variables. ", "if", "(", "prm", ".", "loss", "==", "Loss", ".", "L1", "||", "prm", ".", "loss", "==", "Loss", ".", "MSE", ")", "{", "for", "(", "int", "varId", "=", "0", ";", "varId", "<", "fgLatPred", ".", "getNumVars", "(", ")", ";", "varId", "++", ")", "{", "Var", "var", "=", "fgLatPred", ".", "getVar", "(", "varId", ")", ";", "VarTensor", "marg", "=", "infLatPred", ".", "getMarginalsForVarId", "(", "varId", ")", ";", "margs", ".", "add", "(", "marg", ")", ";", "int", "argmaxState", "=", "marg", ".", "getArgmaxConfigId", "(", ")", ";", "mbrVarConfig", ".", "put", "(", "var", ",", "argmaxState", ")", ";", "varMargMap", ".", "put", "(", "var", ",", "marg", ".", "getValue", "(", "argmaxState", ")", ")", ";", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"Variable marginal: \"", "+", "marg", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Loss type not implemented: \"", "+", "prm", ".", "loss", ")", ";", "}", "}" ]
Computes the MBR variable configuration from the marginals cached in the inferencer, which is assumed to have already been run. The outputs are stored on the class, and can be queried after this call to decode.
[ "Computes", "the", "MBR", "variable", "configuration", "from", "the", "marginals", "cached", "in", "the", "inferencer", "which", "is", "assumed", "to", "have", "already", "been", "run", ".", "The", "outputs", "are", "stored", "on", "the", "class", "and", "can", "be", "queried", "after", "this", "call", "to", "decode", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/decode/MbrDecoder.java#L85-L110
12,073
jeffreyning/nh-micro
nh-micro-nhs/src/main/java/com/nh/micro/nhs/util/Parser.java
Parser.getAttributeList
protected AttributeList getAttributeList() throws IOException { int i; int quote; String name = null; String value = null; StringBuilder buffer = new StringBuilder(); Map<String, String> attributes = new LinkedHashMap<String, String>(); Stream stream = this.stream; while(true) { // skip invalid character while((i = stream.peek()) != Stream.EOF) { if(Character.isLetter(i) || Character.isDigit(i) || i == ':' || i == '-' || i == '_' || i == '%' || i == '/' || i == '>') { break; } else { stream.read(); } } // check end if(i == Stream.EOF) { break; } if(i == '>') { break; } else if(i == '%' || i == '/') { if(stream.peek(1) == '>') { break; } continue; } else { } // read name while((i = stream.peek()) != -1) { if(Character.isLetter(i) || Character.isDigit(i) || i == ':' || i == '-' || i == '_') { buffer.append((char)i); stream.read(); } else { break; } } name = buffer.toString(); buffer.setLength(0); if(name.length() < 1) { continue; } this.stream.skipWhitespace(); i = this.stream.peek(); // next character must be '=' if(i != '=') { attributes.put(name, ""); continue; } else { this.stream.read(); } this.stream.skipWhitespace(); i = stream.peek(); if(i == '"') { quote = '"'; stream.read(); } else if(i == '\'') { quote = '\''; stream.read(); } else { quote = ' '; } if(quote == ' ') { value = this.getAttributeValue(buffer); } else { value = this.getAttributeValue(buffer, quote); } attributes.put(name, value); buffer.setLength(0); } this.stream.skipWhitespace(); return this.getAttributeList(attributes); }
java
protected AttributeList getAttributeList() throws IOException { int i; int quote; String name = null; String value = null; StringBuilder buffer = new StringBuilder(); Map<String, String> attributes = new LinkedHashMap<String, String>(); Stream stream = this.stream; while(true) { // skip invalid character while((i = stream.peek()) != Stream.EOF) { if(Character.isLetter(i) || Character.isDigit(i) || i == ':' || i == '-' || i == '_' || i == '%' || i == '/' || i == '>') { break; } else { stream.read(); } } // check end if(i == Stream.EOF) { break; } if(i == '>') { break; } else if(i == '%' || i == '/') { if(stream.peek(1) == '>') { break; } continue; } else { } // read name while((i = stream.peek()) != -1) { if(Character.isLetter(i) || Character.isDigit(i) || i == ':' || i == '-' || i == '_') { buffer.append((char)i); stream.read(); } else { break; } } name = buffer.toString(); buffer.setLength(0); if(name.length() < 1) { continue; } this.stream.skipWhitespace(); i = this.stream.peek(); // next character must be '=' if(i != '=') { attributes.put(name, ""); continue; } else { this.stream.read(); } this.stream.skipWhitespace(); i = stream.peek(); if(i == '"') { quote = '"'; stream.read(); } else if(i == '\'') { quote = '\''; stream.read(); } else { quote = ' '; } if(quote == ' ') { value = this.getAttributeValue(buffer); } else { value = this.getAttributeValue(buffer, quote); } attributes.put(name, value); buffer.setLength(0); } this.stream.skipWhitespace(); return this.getAttributeList(attributes); }
[ "protected", "AttributeList", "getAttributeList", "(", ")", "throws", "IOException", "{", "int", "i", ";", "int", "quote", ";", "String", "name", "=", "null", ";", "String", "value", "=", "null", ";", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "attributes", "=", "new", "LinkedHashMap", "<", "String", ",", "String", ">", "(", ")", ";", "Stream", "stream", "=", "this", ".", "stream", ";", "while", "(", "true", ")", "{", "// skip invalid character", "while", "(", "(", "i", "=", "stream", ".", "peek", "(", ")", ")", "!=", "Stream", ".", "EOF", ")", "{", "if", "(", "Character", ".", "isLetter", "(", "i", ")", "||", "Character", ".", "isDigit", "(", "i", ")", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", ")", "{", "break", ";", "}", "else", "{", "stream", ".", "read", "(", ")", ";", "}", "}", "// check end", "if", "(", "i", "==", "Stream", ".", "EOF", ")", "{", "break", ";", "}", "if", "(", "i", "==", "'", "'", ")", "{", "break", ";", "}", "else", "if", "(", "i", "==", "'", "'", "||", "i", "==", "'", "'", ")", "{", "if", "(", "stream", ".", "peek", "(", "1", ")", "==", "'", "'", ")", "{", "break", ";", "}", "continue", ";", "}", "else", "{", "}", "// read name", "while", "(", "(", "i", "=", "stream", ".", "peek", "(", ")", ")", "!=", "-", "1", ")", "{", "if", "(", "Character", ".", "isLetter", "(", "i", ")", "||", "Character", ".", "isDigit", "(", "i", ")", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", "||", "i", "==", "'", "'", ")", "{", "buffer", ".", "append", "(", "(", "char", ")", "i", ")", ";", "stream", ".", "read", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "name", "=", "buffer", ".", "toString", "(", ")", ";", "buffer", ".", "setLength", "(", "0", ")", ";", "if", "(", "name", ".", "length", "(", ")", "<", "1", ")", "{", "continue", ";", "}", "this", ".", "stream", ".", "skipWhitespace", "(", ")", ";", "i", "=", "this", ".", "stream", ".", "peek", "(", ")", ";", "// next character must be '='", "if", "(", "i", "!=", "'", "'", ")", "{", "attributes", ".", "put", "(", "name", ",", "\"\"", ")", ";", "continue", ";", "}", "else", "{", "this", ".", "stream", ".", "read", "(", ")", ";", "}", "this", ".", "stream", ".", "skipWhitespace", "(", ")", ";", "i", "=", "stream", ".", "peek", "(", ")", ";", "if", "(", "i", "==", "'", "'", ")", "{", "quote", "=", "'", "'", ";", "stream", ".", "read", "(", ")", ";", "}", "else", "if", "(", "i", "==", "'", "'", ")", "{", "quote", "=", "'", "'", ";", "stream", ".", "read", "(", ")", ";", "}", "else", "{", "quote", "=", "'", "'", ";", "}", "if", "(", "quote", "==", "'", "'", ")", "{", "value", "=", "this", ".", "getAttributeValue", "(", "buffer", ")", ";", "}", "else", "{", "value", "=", "this", ".", "getAttributeValue", "(", "buffer", ",", "quote", ")", ";", "}", "attributes", ".", "put", "(", "name", ",", "value", ")", ";", "buffer", ".", "setLength", "(", "0", ")", ";", "}", "this", ".", "stream", ".", "skipWhitespace", "(", ")", ";", "return", "this", ".", "getAttributeList", "(", "attributes", ")", ";", "}" ]
read node name, after read nodeName @return String @throws IOException
[ "read", "node", "name", "after", "read", "nodeName" ]
f1cb420a092f8ba94317519ede739974decb5617
https://github.com/jeffreyning/nh-micro/blob/f1cb420a092f8ba94317519ede739974decb5617/nh-micro-nhs/src/main/java/com/nh/micro/nhs/util/Parser.java#L42-L135
12,074
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/inf/CachingBpSchedule.java
CachingBpSchedule.filterConstantMsgs
@SuppressWarnings("unchecked") private static List<Object> filterConstantMsgs(List<Object> order, FactorGraph fg) { ArrayList<Object> filt = new ArrayList<Object>(); for (Object item : order) { if (item instanceof List) { List<Object> items = filterConstantMsgs((List<Object>) item, fg); if (items.size() > 0) { filt.add(items); } } else if (item instanceof Integer) { // If the parent node is not a leaf. if (!isConstantMsg((Integer) item, fg)) { filt.add(item); } } else if (item instanceof GlobalFactor) { filt.add(item); } else { throw new RuntimeException("Invalid type in order: " + item.getClass()); } } return filt; }
java
@SuppressWarnings("unchecked") private static List<Object> filterConstantMsgs(List<Object> order, FactorGraph fg) { ArrayList<Object> filt = new ArrayList<Object>(); for (Object item : order) { if (item instanceof List) { List<Object> items = filterConstantMsgs((List<Object>) item, fg); if (items.size() > 0) { filt.add(items); } } else if (item instanceof Integer) { // If the parent node is not a leaf. if (!isConstantMsg((Integer) item, fg)) { filt.add(item); } } else if (item instanceof GlobalFactor) { filt.add(item); } else { throw new RuntimeException("Invalid type in order: " + item.getClass()); } } return filt; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "List", "<", "Object", ">", "filterConstantMsgs", "(", "List", "<", "Object", ">", "order", ",", "FactorGraph", "fg", ")", "{", "ArrayList", "<", "Object", ">", "filt", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "for", "(", "Object", "item", ":", "order", ")", "{", "if", "(", "item", "instanceof", "List", ")", "{", "List", "<", "Object", ">", "items", "=", "filterConstantMsgs", "(", "(", "List", "<", "Object", ">", ")", "item", ",", "fg", ")", ";", "if", "(", "items", ".", "size", "(", ")", ">", "0", ")", "{", "filt", ".", "add", "(", "items", ")", ";", "}", "}", "else", "if", "(", "item", "instanceof", "Integer", ")", "{", "// If the parent node is not a leaf.", "if", "(", "!", "isConstantMsg", "(", "(", "Integer", ")", "item", ",", "fg", ")", ")", "{", "filt", ".", "add", "(", "item", ")", ";", "}", "}", "else", "if", "(", "item", "instanceof", "GlobalFactor", ")", "{", "filt", ".", "add", "(", "item", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Invalid type in order: \"", "+", "item", ".", "getClass", "(", ")", ")", ";", "}", "}", "return", "filt", ";", "}" ]
Filters edges from a leaf node.
[ "Filters", "edges", "from", "a", "leaf", "node", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/inf/CachingBpSchedule.java#L51-L72
12,075
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java
IntNaryTree.getAsPennTreebankString
public String getAsPennTreebankString() { StringBuilder sb = new StringBuilder(); sb.append("("); getAsPennTreebankString(1, 1, sb); sb.append(")"); return sb.toString(); }
java
public String getAsPennTreebankString() { StringBuilder sb = new StringBuilder(); sb.append("("); getAsPennTreebankString(1, 1, sb); sb.append(")"); return sb.toString(); }
[ "public", "String", "getAsPennTreebankString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"(\"", ")", ";", "getAsPennTreebankString", "(", "1", ",", "1", ",", "sb", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Gets a string representation of this parse that looks like the typical Penn Treebank style parse. Example: ((ROOT (S (NP (NN time)) (VP (VBZ flies) (PP (IN like) (NP (DT an) (NN arrow))))))) @return A string representing this parse.
[ "Gets", "a", "string", "representation", "of", "this", "parse", "that", "looks", "like", "the", "typical", "Penn", "Treebank", "style", "parse", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java#L71-L77
12,076
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java
IntNaryTree.postOrderFilterNodes
public void postOrderFilterNodes(final NaryTreeNodeFilter filter) { postOrderTraversal(new FnO1ToVoid<IntNaryTree>() { @Override public void call(IntNaryTree node) { if (!node.isLeaf()) { ArrayList<IntNaryTree> filtChildren = new ArrayList<IntNaryTree>(); for (IntNaryTree child : node.children) { if (filter.accept(child)) { filtChildren.add(child); } } node.children = filtChildren; } } }); updateStartEnd(); }
java
public void postOrderFilterNodes(final NaryTreeNodeFilter filter) { postOrderTraversal(new FnO1ToVoid<IntNaryTree>() { @Override public void call(IntNaryTree node) { if (!node.isLeaf()) { ArrayList<IntNaryTree> filtChildren = new ArrayList<IntNaryTree>(); for (IntNaryTree child : node.children) { if (filter.accept(child)) { filtChildren.add(child); } } node.children = filtChildren; } } }); updateStartEnd(); }
[ "public", "void", "postOrderFilterNodes", "(", "final", "NaryTreeNodeFilter", "filter", ")", "{", "postOrderTraversal", "(", "new", "FnO1ToVoid", "<", "IntNaryTree", ">", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "IntNaryTree", "node", ")", "{", "if", "(", "!", "node", ".", "isLeaf", "(", ")", ")", "{", "ArrayList", "<", "IntNaryTree", ">", "filtChildren", "=", "new", "ArrayList", "<", "IntNaryTree", ">", "(", ")", ";", "for", "(", "IntNaryTree", "child", ":", "node", ".", "children", ")", "{", "if", "(", "filter", ".", "accept", "(", "child", ")", ")", "{", "filtChildren", ".", "add", "(", "child", ")", ";", "}", "}", "node", ".", "children", "=", "filtChildren", ";", "}", "}", "}", ")", ";", "updateStartEnd", "(", ")", ";", "}" ]
Keep only those nodes which the filter accepts.
[ "Keep", "only", "those", "nodes", "which", "the", "filter", "accepts", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java#L306-L322
12,077
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/data/LabeledFgExample.java
LabeledFgExample.getGoldConfigPred
public VarConfig getGoldConfigPred(int factorId) { VarSet vars = fgLatPred.getFactor(factorId).getVars(); return goldConfig.getIntersection(VarSet.getVarsOfType(vars, VarType.PREDICTED)); }
java
public VarConfig getGoldConfigPred(int factorId) { VarSet vars = fgLatPred.getFactor(factorId).getVars(); return goldConfig.getIntersection(VarSet.getVarsOfType(vars, VarType.PREDICTED)); }
[ "public", "VarConfig", "getGoldConfigPred", "(", "int", "factorId", ")", "{", "VarSet", "vars", "=", "fgLatPred", ".", "getFactor", "(", "factorId", ")", ".", "getVars", "(", ")", ";", "return", "goldConfig", ".", "getIntersection", "(", "VarSet", ".", "getVarsOfType", "(", "vars", ",", "VarType", ".", "PREDICTED", ")", ")", ";", "}" ]
Gets the gold configuration of the predicted variables ONLY for the given factor.
[ "Gets", "the", "gold", "configuration", "of", "the", "predicted", "variables", "ONLY", "for", "the", "given", "factor", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/data/LabeledFgExample.java#L72-L75
12,078
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/data/LabeledFgExample.java
LabeledFgExample.getGoldConfigIdxPred
public int getGoldConfigIdxPred(int factorId) { VarSet vars = VarSet.getVarsOfType(fgLatPred.getFactor(factorId).getVars(), VarType.PREDICTED); return goldConfig.getConfigIndexOfSubset(vars); }
java
public int getGoldConfigIdxPred(int factorId) { VarSet vars = VarSet.getVarsOfType(fgLatPred.getFactor(factorId).getVars(), VarType.PREDICTED); return goldConfig.getConfigIndexOfSubset(vars); }
[ "public", "int", "getGoldConfigIdxPred", "(", "int", "factorId", ")", "{", "VarSet", "vars", "=", "VarSet", ".", "getVarsOfType", "(", "fgLatPred", ".", "getFactor", "(", "factorId", ")", ".", "getVars", "(", ")", ",", "VarType", ".", "PREDICTED", ")", ";", "return", "goldConfig", ".", "getConfigIndexOfSubset", "(", "vars", ")", ";", "}" ]
Gets the gold configuration index of the predicted variables for the given factor.
[ "Gets", "the", "gold", "configuration", "index", "of", "the", "predicted", "variables", "for", "the", "given", "factor", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/data/LabeledFgExample.java#L78-L81
12,079
jeffreyning/nh-micro
nh-micro-nhs/src/main/java/com/nh/micro/nhs/JspParser.java
JspParser.clip
protected void clip(Node node, int type) { if(node.getNodeType() != NodeType.TEXT) { return; } char c; int j = 0; String content = node.getTextContent(); if(type == 1) { /** * 删除该文本节点的后缀空格 * 也就是删除下�?��标签节点的前导空�? * 只删除空格不删除其他不可见字�? */ for(j = content.length() - 1; j > -1; j--) { c = content.charAt(j); if(c == ' ' || c == '\t') { continue; } else { break; } } content = content.substring(0, j + 1); } else { /** * 删除该文本节点的前导回车 * 也就是删除前�?��标签节点的后�?���? * 只删除回车不删除其他不可见字�? */ int length = content.length(); for(j = 0; j < length; j++) { c = content.charAt(j); if(c == '\r') { continue; } else if(c == '\n') { j++; break; } else { break; } } if(j <= length) { content = content.substring(j, length); } } ((TextNode)node).setTextContent(content); }
java
protected void clip(Node node, int type) { if(node.getNodeType() != NodeType.TEXT) { return; } char c; int j = 0; String content = node.getTextContent(); if(type == 1) { /** * 删除该文本节点的后缀空格 * 也就是删除下�?��标签节点的前导空�? * 只删除空格不删除其他不可见字�? */ for(j = content.length() - 1; j > -1; j--) { c = content.charAt(j); if(c == ' ' || c == '\t') { continue; } else { break; } } content = content.substring(0, j + 1); } else { /** * 删除该文本节点的前导回车 * 也就是删除前�?��标签节点的后�?���? * 只删除回车不删除其他不可见字�? */ int length = content.length(); for(j = 0; j < length; j++) { c = content.charAt(j); if(c == '\r') { continue; } else if(c == '\n') { j++; break; } else { break; } } if(j <= length) { content = content.substring(j, length); } } ((TextNode)node).setTextContent(content); }
[ "protected", "void", "clip", "(", "Node", "node", ",", "int", "type", ")", "{", "if", "(", "node", ".", "getNodeType", "(", ")", "!=", "NodeType", ".", "TEXT", ")", "{", "return", ";", "}", "char", "c", ";", "int", "j", "=", "0", ";", "String", "content", "=", "node", ".", "getTextContent", "(", ")", ";", "if", "(", "type", "==", "1", ")", "{", "/**\n * 删除该文本节点的后缀空格\n * 也就是删除下�?��标签节点的前导空�? * 只删除空格不删除其他不可见字�? */", "for", "(", "j", "=", "content", ".", "length", "(", ")", "-", "1", ";", "j", ">", "-", "1", ";", "j", "--", ")", "{", "c", "=", "content", ".", "charAt", "(", "j", ")", ";", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "continue", ";", "}", "else", "{", "break", ";", "}", "}", "content", "=", "content", ".", "substring", "(", "0", ",", "j", "+", "1", ")", ";", "}", "else", "{", "/**\n * 删除该文本节点的前导回车\n * 也就是删除前�?��标签节点的后�?���? * 只删除回车不删除其他不可见字�? */", "int", "length", "=", "content", ".", "length", "(", ")", ";", "for", "(", "j", "=", "0", ";", "j", "<", "length", ";", "j", "++", ")", "{", "c", "=", "content", ".", "charAt", "(", "j", ")", ";", "if", "(", "c", "==", "'", "'", ")", "{", "continue", ";", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "j", "++", ";", "break", ";", "}", "else", "{", "break", ";", "}", "}", "if", "(", "j", "<=", "length", ")", "{", "content", "=", "content", ".", "substring", "(", "j", ",", "length", ")", ";", "}", "}", "(", "(", "TextNode", ")", "node", ")", ".", "setTextContent", "(", "content", ")", ";", "}" ]
type == 1 prefix clip type == 2 suffix clip @param node @param type
[ "type", "==", "1", "prefix", "clip", "type", "==", "2", "suffix", "clip" ]
f1cb420a092f8ba94317519ede739974decb5617
https://github.com/jeffreyning/nh-micro/blob/f1cb420a092f8ba94317519ede739974decb5617/nh-micro-nhs/src/main/java/com/nh/micro/nhs/JspParser.java#L685-L736
12,080
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java
EdgeScores.edgeScoresToTensor
public static Tensor edgeScoresToTensor(EdgeScores es, Algebra s) { int n = es.child.length; Tensor m = new Tensor(s, n, n); for (int p = -1; p < n; p++) { for (int c = 0; c < n; c++) { if (p == c) { continue; } int pp = getTensorParent(p, c); m.set(es.getScore(p, c), pp, c); } } return m; }
java
public static Tensor edgeScoresToTensor(EdgeScores es, Algebra s) { int n = es.child.length; Tensor m = new Tensor(s, n, n); for (int p = -1; p < n; p++) { for (int c = 0; c < n; c++) { if (p == c) { continue; } int pp = getTensorParent(p, c); m.set(es.getScore(p, c), pp, c); } } return m; }
[ "public", "static", "Tensor", "edgeScoresToTensor", "(", "EdgeScores", "es", ",", "Algebra", "s", ")", "{", "int", "n", "=", "es", ".", "child", ".", "length", ";", "Tensor", "m", "=", "new", "Tensor", "(", "s", ",", "n", ",", "n", ")", ";", "for", "(", "int", "p", "=", "-", "1", ";", "p", "<", "n", ";", "p", "++", ")", "{", "for", "(", "int", "c", "=", "0", ";", "c", "<", "n", ";", "c", "++", ")", "{", "if", "(", "p", "==", "c", ")", "{", "continue", ";", "}", "int", "pp", "=", "getTensorParent", "(", "p", ",", "c", ")", ";", "m", ".", "set", "(", "es", ".", "getScore", "(", "p", ",", "c", ")", ",", "pp", ",", "c", ")", ";", "}", "}", "return", "m", ";", "}" ]
Convert an EdgeScores object to a Tensor, where the wall node is indexed as position n+1 in the Tensor. @param s TODO
[ "Convert", "an", "EdgeScores", "object", "to", "a", "Tensor", "where", "the", "wall", "node", "is", "indexed", "as", "position", "n", "+", "1", "in", "the", "Tensor", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java#L85-L96
12,081
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java
EdgeScores.tensorToEdgeScores
public static EdgeScores tensorToEdgeScores(Tensor t) { if (t.getDims().length != 2) { throw new IllegalArgumentException("Tensor must be an nxn matrix."); } int n = t.getDims()[1]; EdgeScores es = new EdgeScores(n, 0); for (int p = -1; p < n; p++) { for (int c = 0; c < n; c++) { if (p == c) { continue; } int pp = getTensorParent(p, c); es.setScore(p, c, t.get(pp, c)); } } return es; }
java
public static EdgeScores tensorToEdgeScores(Tensor t) { if (t.getDims().length != 2) { throw new IllegalArgumentException("Tensor must be an nxn matrix."); } int n = t.getDims()[1]; EdgeScores es = new EdgeScores(n, 0); for (int p = -1; p < n; p++) { for (int c = 0; c < n; c++) { if (p == c) { continue; } int pp = getTensorParent(p, c); es.setScore(p, c, t.get(pp, c)); } } return es; }
[ "public", "static", "EdgeScores", "tensorToEdgeScores", "(", "Tensor", "t", ")", "{", "if", "(", "t", ".", "getDims", "(", ")", ".", "length", "!=", "2", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Tensor must be an nxn matrix.\"", ")", ";", "}", "int", "n", "=", "t", ".", "getDims", "(", ")", "[", "1", "]", ";", "EdgeScores", "es", "=", "new", "EdgeScores", "(", "n", ",", "0", ")", ";", "for", "(", "int", "p", "=", "-", "1", ";", "p", "<", "n", ";", "p", "++", ")", "{", "for", "(", "int", "c", "=", "0", ";", "c", "<", "n", ";", "c", "++", ")", "{", "if", "(", "p", "==", "c", ")", "{", "continue", ";", "}", "int", "pp", "=", "getTensorParent", "(", "p", ",", "c", ")", ";", "es", ".", "setScore", "(", "p", ",", "c", ",", "t", ".", "get", "(", "pp", ",", "c", ")", ")", ";", "}", "}", "return", "es", ";", "}" ]
Convert a Tensor object to an EdgeScores, where the wall node is indexed as position n+1 in the Tensor.
[ "Convert", "a", "Tensor", "object", "to", "an", "EdgeScores", "where", "the", "wall", "node", "is", "indexed", "as", "position", "n", "+", "1", "in", "the", "Tensor", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java#L99-L113
12,082
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java
EdgeScores.combine
public static double[][] combine(double[] fracRoot, double[][] fracChild) { int nplus = fracChild.length + 1; double[][] scores = new double[nplus][nplus]; for (int p=0; p<nplus; p++) { for (int c=0; c<nplus; c++) { if (c == 0) { scores[p][c] = Double.NEGATIVE_INFINITY; } else if (p == 0 && c > 0) { scores[p][c] = fracRoot[c-1]; } else { scores[p][c] = fracChild[p-1][c-1]; } } } return scores; }
java
public static double[][] combine(double[] fracRoot, double[][] fracChild) { int nplus = fracChild.length + 1; double[][] scores = new double[nplus][nplus]; for (int p=0; p<nplus; p++) { for (int c=0; c<nplus; c++) { if (c == 0) { scores[p][c] = Double.NEGATIVE_INFINITY; } else if (p == 0 && c > 0) { scores[p][c] = fracRoot[c-1]; } else { scores[p][c] = fracChild[p-1][c-1]; } } } return scores; }
[ "public", "static", "double", "[", "]", "[", "]", "combine", "(", "double", "[", "]", "fracRoot", ",", "double", "[", "]", "[", "]", "fracChild", ")", "{", "int", "nplus", "=", "fracChild", ".", "length", "+", "1", ";", "double", "[", "]", "[", "]", "scores", "=", "new", "double", "[", "nplus", "]", "[", "nplus", "]", ";", "for", "(", "int", "p", "=", "0", ";", "p", "<", "nplus", ";", "p", "++", ")", "{", "for", "(", "int", "c", "=", "0", ";", "c", "<", "nplus", ";", "c", "++", ")", "{", "if", "(", "c", "==", "0", ")", "{", "scores", "[", "p", "]", "[", "c", "]", "=", "Double", ".", "NEGATIVE_INFINITY", ";", "}", "else", "if", "(", "p", "==", "0", "&&", "c", ">", "0", ")", "{", "scores", "[", "p", "]", "[", "c", "]", "=", "fracRoot", "[", "c", "-", "1", "]", ";", "}", "else", "{", "scores", "[", "p", "]", "[", "c", "]", "=", "fracChild", "[", "p", "-", "1", "]", "[", "c", "-", "1", "]", ";", "}", "}", "}", "return", "scores", ";", "}" ]
Combines a set of edge weights represented as wall and child weights into a single set of weights. The combined weights are indexed such that the wall has index 0 and the tokens of the sentence are 1-indexed. @param fracRoot The edge weights from the wall to each child. @param fracChild The edge weights from parent to child. @return The combined weights.
[ "Combines", "a", "set", "of", "edge", "weights", "represented", "as", "wall", "and", "child", "weights", "into", "a", "single", "set", "of", "weights", ".", "The", "combined", "weights", "are", "indexed", "such", "that", "the", "wall", "has", "index", "0", "and", "the", "tokens", "of", "the", "sentence", "are", "1", "-", "indexed", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java#L136-L151
12,083
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java
MarginalLogLikelihood.getFgLat
public static FactorGraph getFgLat(FactorGraph fgLatPred, VarConfig goldConfig) { // TODO: instead, have this just look at whether or not the var is in the gold config List<Var> predictedVars = VarSet.getVarsOfType(fgLatPred.getVars(), VarType.PREDICTED); VarConfig predConfig = goldConfig.getIntersection(predictedVars); FactorGraph fgLat = fgLatPred.getClamped(predConfig); assert (fgLatPred.getNumFactors() <= fgLat.getNumFactors()); return fgLat; }
java
public static FactorGraph getFgLat(FactorGraph fgLatPred, VarConfig goldConfig) { // TODO: instead, have this just look at whether or not the var is in the gold config List<Var> predictedVars = VarSet.getVarsOfType(fgLatPred.getVars(), VarType.PREDICTED); VarConfig predConfig = goldConfig.getIntersection(predictedVars); FactorGraph fgLat = fgLatPred.getClamped(predConfig); assert (fgLatPred.getNumFactors() <= fgLat.getNumFactors()); return fgLat; }
[ "public", "static", "FactorGraph", "getFgLat", "(", "FactorGraph", "fgLatPred", ",", "VarConfig", "goldConfig", ")", "{", "// TODO: instead, have this just look at whether or not the var is in the gold config", "List", "<", "Var", ">", "predictedVars", "=", "VarSet", ".", "getVarsOfType", "(", "fgLatPred", ".", "getVars", "(", ")", ",", "VarType", ".", "PREDICTED", ")", ";", "VarConfig", "predConfig", "=", "goldConfig", ".", "getIntersection", "(", "predictedVars", ")", ";", "FactorGraph", "fgLat", "=", "fgLatPred", ".", "getClamped", "(", "predConfig", ")", ";", "assert", "(", "fgLatPred", ".", "getNumFactors", "(", ")", "<=", "fgLat", ".", "getNumFactors", "(", ")", ")", ";", "return", "fgLat", ";", "}" ]
Get a copy of the factor graph where the predicted variables are clamped. @param fgLatPred The original factor graph. @param goldConfig The assignment to the predicted variables. @return The clamped factor graph.
[ "Get", "a", "copy", "of", "the", "factor", "graph", "where", "the", "predicted", "variables", "are", "clamped", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java#L175-L182
12,084
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java
MarginalLogLikelihood.getExpectedFeatureCounts
public static FeatureVector getExpectedFeatureCounts(FgExampleList data, FgInferencerFactory infFactory, FgModel model, double[] params) { model.updateModelFromDoubles(params); FgModel feats = model.getDenseCopy(); feats.zero(); for (int i=0; i<data.size(); i++) { LFgExample ex = data.get(i); FactorGraph fgLatPred = ex.getFactorGraph(); fgLatPred.updateFromModel(model); FgInferencer infLatPred = infFactory.getInferencer(fgLatPred); infLatPred.run(); addExpectedPartials(fgLatPred, infLatPred, 1.0 * ex.getWeight(), feats); } double[] f = new double[model.getNumParams()]; feats.updateDoublesFromModel(f); return new FeatureVector(f); }
java
public static FeatureVector getExpectedFeatureCounts(FgExampleList data, FgInferencerFactory infFactory, FgModel model, double[] params) { model.updateModelFromDoubles(params); FgModel feats = model.getDenseCopy(); feats.zero(); for (int i=0; i<data.size(); i++) { LFgExample ex = data.get(i); FactorGraph fgLatPred = ex.getFactorGraph(); fgLatPred.updateFromModel(model); FgInferencer infLatPred = infFactory.getInferencer(fgLatPred); infLatPred.run(); addExpectedPartials(fgLatPred, infLatPred, 1.0 * ex.getWeight(), feats); } double[] f = new double[model.getNumParams()]; feats.updateDoublesFromModel(f); return new FeatureVector(f); }
[ "public", "static", "FeatureVector", "getExpectedFeatureCounts", "(", "FgExampleList", "data", ",", "FgInferencerFactory", "infFactory", ",", "FgModel", "model", ",", "double", "[", "]", "params", ")", "{", "model", ".", "updateModelFromDoubles", "(", "params", ")", ";", "FgModel", "feats", "=", "model", ".", "getDenseCopy", "(", ")", ";", "feats", ".", "zero", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size", "(", ")", ";", "i", "++", ")", "{", "LFgExample", "ex", "=", "data", ".", "get", "(", "i", ")", ";", "FactorGraph", "fgLatPred", "=", "ex", ".", "getFactorGraph", "(", ")", ";", "fgLatPred", ".", "updateFromModel", "(", "model", ")", ";", "FgInferencer", "infLatPred", "=", "infFactory", ".", "getInferencer", "(", "fgLatPred", ")", ";", "infLatPred", ".", "run", "(", ")", ";", "addExpectedPartials", "(", "fgLatPred", ",", "infLatPred", ",", "1.0", "*", "ex", ".", "getWeight", "(", ")", ",", "feats", ")", ";", "}", "double", "[", "]", "f", "=", "new", "double", "[", "model", ".", "getNumParams", "(", ")", "]", ";", "feats", ".", "updateDoublesFromModel", "(", "f", ")", ";", "return", "new", "FeatureVector", "(", "f", ")", ";", "}" ]
Gets the "expected" feature counts.
[ "Gets", "the", "expected", "feature", "counts", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java#L185-L200
12,085
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java
MarginalLogLikelihood.getObservedFeatureCounts
public static FeatureVector getObservedFeatureCounts(FgExampleList data, FgInferencerFactory infFactory, FgModel model, double[] params) { model.updateModelFromDoubles(params); FgModel feats = model.getDenseCopy(); feats.zero(); for (int i=0; i<data.size(); i++) { LFgExample ex = data.get(i); FactorGraph fgLat = getFgLat(ex.getFactorGraph(), ex.getGoldConfig()); fgLat.updateFromModel(model); FgInferencer infLat = infFactory.getInferencer(fgLat); infLat.run(); addExpectedPartials(fgLat, infLat, 1.0 * ex.getWeight(), feats); } double[] f = new double[model.getNumParams()]; feats.updateDoublesFromModel(f); return new FeatureVector(f); }
java
public static FeatureVector getObservedFeatureCounts(FgExampleList data, FgInferencerFactory infFactory, FgModel model, double[] params) { model.updateModelFromDoubles(params); FgModel feats = model.getDenseCopy(); feats.zero(); for (int i=0; i<data.size(); i++) { LFgExample ex = data.get(i); FactorGraph fgLat = getFgLat(ex.getFactorGraph(), ex.getGoldConfig()); fgLat.updateFromModel(model); FgInferencer infLat = infFactory.getInferencer(fgLat); infLat.run(); addExpectedPartials(fgLat, infLat, 1.0 * ex.getWeight(), feats); } double[] f = new double[model.getNumParams()]; feats.updateDoublesFromModel(f); return new FeatureVector(f); }
[ "public", "static", "FeatureVector", "getObservedFeatureCounts", "(", "FgExampleList", "data", ",", "FgInferencerFactory", "infFactory", ",", "FgModel", "model", ",", "double", "[", "]", "params", ")", "{", "model", ".", "updateModelFromDoubles", "(", "params", ")", ";", "FgModel", "feats", "=", "model", ".", "getDenseCopy", "(", ")", ";", "feats", ".", "zero", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size", "(", ")", ";", "i", "++", ")", "{", "LFgExample", "ex", "=", "data", ".", "get", "(", "i", ")", ";", "FactorGraph", "fgLat", "=", "getFgLat", "(", "ex", ".", "getFactorGraph", "(", ")", ",", "ex", ".", "getGoldConfig", "(", ")", ")", ";", "fgLat", ".", "updateFromModel", "(", "model", ")", ";", "FgInferencer", "infLat", "=", "infFactory", ".", "getInferencer", "(", "fgLat", ")", ";", "infLat", ".", "run", "(", ")", ";", "addExpectedPartials", "(", "fgLat", ",", "infLat", ",", "1.0", "*", "ex", ".", "getWeight", "(", ")", ",", "feats", ")", ";", "}", "double", "[", "]", "f", "=", "new", "double", "[", "model", ".", "getNumParams", "(", ")", "]", ";", "feats", ".", "updateDoublesFromModel", "(", "f", ")", ";", "return", "new", "FeatureVector", "(", "f", ")", ";", "}" ]
Gets the "observed" feature counts.
[ "Gets", "the", "observed", "feature", "counts", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/train/MarginalLogLikelihood.java#L203-L218
12,086
mcaserta/spring-crypto-utils
src/main/java/com/springcryptoutils/core/key/PublicKeyRegistryByAliasImpl.java
PublicKeyRegistryByAliasImpl.get
public PublicKey get(KeyStoreChooser keyStoreChooser, PublicKeyChooserByAlias publicKeyChooserByAlias) { CacheKey cacheKey = new CacheKey(keyStoreChooser.getKeyStoreName(), publicKeyChooserByAlias.getAlias()); PublicKey retrievedPublicKey = cache.get(cacheKey); if (retrievedPublicKey != null) { return retrievedPublicKey; } KeyStore keyStore = keyStoreRegistry.get(keyStoreChooser); if (keyStore != null) { PublicKeyFactoryBean factory = new PublicKeyFactoryBean(); factory.setKeystore(keyStore); factory.setAlias(publicKeyChooserByAlias.getAlias()); try { factory.afterPropertiesSet(); PublicKey publicKey = (PublicKey) factory.getObject(); if (publicKey != null) { cache.put(cacheKey, publicKey); } return publicKey; } catch (Exception e) { throw new PublicKeyException("error initializing the public key factory bean", e); } } return null; }
java
public PublicKey get(KeyStoreChooser keyStoreChooser, PublicKeyChooserByAlias publicKeyChooserByAlias) { CacheKey cacheKey = new CacheKey(keyStoreChooser.getKeyStoreName(), publicKeyChooserByAlias.getAlias()); PublicKey retrievedPublicKey = cache.get(cacheKey); if (retrievedPublicKey != null) { return retrievedPublicKey; } KeyStore keyStore = keyStoreRegistry.get(keyStoreChooser); if (keyStore != null) { PublicKeyFactoryBean factory = new PublicKeyFactoryBean(); factory.setKeystore(keyStore); factory.setAlias(publicKeyChooserByAlias.getAlias()); try { factory.afterPropertiesSet(); PublicKey publicKey = (PublicKey) factory.getObject(); if (publicKey != null) { cache.put(cacheKey, publicKey); } return publicKey; } catch (Exception e) { throw new PublicKeyException("error initializing the public key factory bean", e); } } return null; }
[ "public", "PublicKey", "get", "(", "KeyStoreChooser", "keyStoreChooser", ",", "PublicKeyChooserByAlias", "publicKeyChooserByAlias", ")", "{", "CacheKey", "cacheKey", "=", "new", "CacheKey", "(", "keyStoreChooser", ".", "getKeyStoreName", "(", ")", ",", "publicKeyChooserByAlias", ".", "getAlias", "(", ")", ")", ";", "PublicKey", "retrievedPublicKey", "=", "cache", ".", "get", "(", "cacheKey", ")", ";", "if", "(", "retrievedPublicKey", "!=", "null", ")", "{", "return", "retrievedPublicKey", ";", "}", "KeyStore", "keyStore", "=", "keyStoreRegistry", ".", "get", "(", "keyStoreChooser", ")", ";", "if", "(", "keyStore", "!=", "null", ")", "{", "PublicKeyFactoryBean", "factory", "=", "new", "PublicKeyFactoryBean", "(", ")", ";", "factory", ".", "setKeystore", "(", "keyStore", ")", ";", "factory", ".", "setAlias", "(", "publicKeyChooserByAlias", ".", "getAlias", "(", ")", ")", ";", "try", "{", "factory", ".", "afterPropertiesSet", "(", ")", ";", "PublicKey", "publicKey", "=", "(", "PublicKey", ")", "factory", ".", "getObject", "(", ")", ";", "if", "(", "publicKey", "!=", "null", ")", "{", "cache", ".", "put", "(", "cacheKey", ",", "publicKey", ")", ";", "}", "return", "publicKey", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PublicKeyException", "(", "\"error initializing the public key factory bean\"", ",", "e", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns the selected public key or null if not found. @param keyStoreChooser the keystore chooser @param publicKeyChooserByAlias the public key chooser by alias @return the selected public key or null if not found
[ "Returns", "the", "selected", "public", "key", "or", "null", "if", "not", "found", "." ]
1dbf6211542fb1e3f9297941d691e7e89cc72c46
https://github.com/mcaserta/spring-crypto-utils/blob/1dbf6211542fb1e3f9297941d691e7e89cc72c46/src/main/java/com/springcryptoutils/core/key/PublicKeyRegistryByAliasImpl.java#L53-L81
12,087
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java
DirectedGraph.add
public void add(N node) { if (! node.added) { nodes.add(node); node.added = true; } }
java
public void add(N node) { if (! node.added) { nodes.add(node); node.added = true; } }
[ "public", "void", "add", "(", "N", "node", ")", "{", "if", "(", "!", "node", ".", "added", ")", "{", "nodes", ".", "add", "(", "node", ")", ";", "node", ".", "added", "=", "true", ";", "}", "}" ]
Adds the node if it's not already present in the graph.
[ "Adds", "the", "node", "if", "it", "s", "not", "already", "present", "in", "the", "graph", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java#L103-L108
12,088
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java
DirectedGraph.add
public void add(E edge) { if (! edge.added) { edges.add(edge); edge.added = true; add(edge.getChild()); add(edge.getParent()); } }
java
public void add(E edge) { if (! edge.added) { edges.add(edge); edge.added = true; add(edge.getChild()); add(edge.getParent()); } }
[ "public", "void", "add", "(", "E", "edge", ")", "{", "if", "(", "!", "edge", ".", "added", ")", "{", "edges", ".", "add", "(", "edge", ")", ";", "edge", ".", "added", "=", "true", ";", "add", "(", "edge", ".", "getChild", "(", ")", ")", ";", "add", "(", "edge", ".", "getParent", "(", ")", ")", ";", "}", "}" ]
Adds the edge and its nodes if not already present in the graph.
[ "Adds", "the", "edge", "and", "its", "nodes", "if", "not", "already", "present", "in", "the", "graph", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java#L111-L118
12,089
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java
DirectedGraph.dfs
private void dfs(Node root) { root.setMarked(true); for (Edge e : root.getOutEdges()) { N n = e.getChild(); if (!n.isMarked()) { dfs(n); } } }
java
private void dfs(Node root) { root.setMarked(true); for (Edge e : root.getOutEdges()) { N n = e.getChild(); if (!n.isMarked()) { dfs(n); } } }
[ "private", "void", "dfs", "(", "Node", "root", ")", "{", "root", ".", "setMarked", "(", "true", ")", ";", "for", "(", "Edge", "e", ":", "root", ".", "getOutEdges", "(", ")", ")", "{", "N", "n", "=", "e", ".", "getChild", "(", ")", ";", "if", "(", "!", "n", ".", "isMarked", "(", ")", ")", "{", "dfs", "(", "n", ")", ";", "}", "}", "}" ]
Runs depth-first search on the graph starting at node n, marking each node as it is encountered. @param root
[ "Runs", "depth", "-", "first", "search", "on", "the", "graph", "starting", "at", "node", "n", "marking", "each", "node", "as", "it", "is", "encountered", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java#L206-L214
12,090
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java
DirectedGraph.preOrderTraversal
public void preOrderTraversal(N root, Visitor<N> v) { setMarkedAllNodes(false); preOrderTraveralRecursive(root, v); }
java
public void preOrderTraversal(N root, Visitor<N> v) { setMarkedAllNodes(false); preOrderTraveralRecursive(root, v); }
[ "public", "void", "preOrderTraversal", "(", "N", "root", ",", "Visitor", "<", "N", ">", "v", ")", "{", "setMarkedAllNodes", "(", "false", ")", ";", "preOrderTraveralRecursive", "(", "root", ",", "v", ")", ";", "}" ]
Visits the nodes in a pre-order traversal.
[ "Visits", "the", "nodes", "in", "a", "pre", "-", "order", "traversal", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/util/DirectedGraph.java#L247-L250
12,091
rtyley/roboguice-sherlock
src/main/java/com/github/rtyley/android/sherlock/android/accounts/SherlockAccountAuthenticatorActivity.java
SherlockAccountAuthenticatorActivity.onCreate
protected void onCreate(Bundle icicle) { super.onCreate(icicle); mAccountAuthenticatorResponse = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); if (mAccountAuthenticatorResponse != null) { mAccountAuthenticatorResponse.onRequestContinued(); } }
java
protected void onCreate(Bundle icicle) { super.onCreate(icicle); mAccountAuthenticatorResponse = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); if (mAccountAuthenticatorResponse != null) { mAccountAuthenticatorResponse.onRequestContinued(); } }
[ "protected", "void", "onCreate", "(", "Bundle", "icicle", ")", "{", "super", ".", "onCreate", "(", "icicle", ")", ";", "mAccountAuthenticatorResponse", "=", "getIntent", "(", ")", ".", "getParcelableExtra", "(", "AccountManager", ".", "KEY_ACCOUNT_AUTHENTICATOR_RESPONSE", ")", ";", "if", "(", "mAccountAuthenticatorResponse", "!=", "null", ")", "{", "mAccountAuthenticatorResponse", ".", "onRequestContinued", "(", ")", ";", "}", "}" ]
Retreives the AccountAuthenticatorResponse from either the intent of the icicle, if the icicle is non-zero. @param icicle the save instance data of this Activity, may be null
[ "Retreives", "the", "AccountAuthenticatorResponse", "from", "either", "the", "intent", "of", "the", "icicle", "if", "the", "icicle", "is", "non", "-", "zero", "." ]
691d41f41bd42d6d981c4b9f3451ab342efa0293
https://github.com/rtyley/roboguice-sherlock/blob/691d41f41bd42d6d981c4b9f3451ab342efa0293/src/main/java/com/github/rtyley/android/sherlock/android/accounts/SherlockAccountAuthenticatorActivity.java#L59-L68
12,092
rtyley/roboguice-sherlock
src/main/java/com/github/rtyley/android/sherlock/android/accounts/SherlockAccountAuthenticatorActivity.java
SherlockAccountAuthenticatorActivity.finish
public void finish() { if (mAccountAuthenticatorResponse != null) { // send the result bundle back if set, otherwise send an error. if (mResultBundle != null) { mAccountAuthenticatorResponse.onResult(mResultBundle); } else { mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled"); } mAccountAuthenticatorResponse = null; } super.finish(); }
java
public void finish() { if (mAccountAuthenticatorResponse != null) { // send the result bundle back if set, otherwise send an error. if (mResultBundle != null) { mAccountAuthenticatorResponse.onResult(mResultBundle); } else { mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled"); } mAccountAuthenticatorResponse = null; } super.finish(); }
[ "public", "void", "finish", "(", ")", "{", "if", "(", "mAccountAuthenticatorResponse", "!=", "null", ")", "{", "// send the result bundle back if set, otherwise send an error.", "if", "(", "mResultBundle", "!=", "null", ")", "{", "mAccountAuthenticatorResponse", ".", "onResult", "(", "mResultBundle", ")", ";", "}", "else", "{", "mAccountAuthenticatorResponse", ".", "onError", "(", "AccountManager", ".", "ERROR_CODE_CANCELED", ",", "\"canceled\"", ")", ";", "}", "mAccountAuthenticatorResponse", "=", "null", ";", "}", "super", ".", "finish", "(", ")", ";", "}" ]
Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
[ "Sends", "the", "result", "or", "a", "Constants", ".", "ERROR_CODE_CANCELED", "error", "if", "a", "result", "isn", "t", "present", "." ]
691d41f41bd42d6d981c4b9f3451ab342efa0293
https://github.com/rtyley/roboguice-sherlock/blob/691d41f41bd42d6d981c4b9f3451ab342efa0293/src/main/java/com/github/rtyley/android/sherlock/android/accounts/SherlockAccountAuthenticatorActivity.java#L73-L85
12,093
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/model/globalfac/ProjDepTreeModule.java
ProjDepTreeModule.containsZeros
public static boolean containsZeros(Tensor tmFalseIn) { Algebra s = tmFalseIn.getAlgebra(); for (int c=0; c<tmFalseIn.size(); c++) { if (tmFalseIn.getValue(c) == s.zero()) { return true; } } return false; }
java
public static boolean containsZeros(Tensor tmFalseIn) { Algebra s = tmFalseIn.getAlgebra(); for (int c=0; c<tmFalseIn.size(); c++) { if (tmFalseIn.getValue(c) == s.zero()) { return true; } } return false; }
[ "public", "static", "boolean", "containsZeros", "(", "Tensor", "tmFalseIn", ")", "{", "Algebra", "s", "=", "tmFalseIn", ".", "getAlgebra", "(", ")", ";", "for", "(", "int", "c", "=", "0", ";", "c", "<", "tmFalseIn", ".", "size", "(", ")", ";", "c", "++", ")", "{", "if", "(", "tmFalseIn", ".", "getValue", "(", "c", ")", "==", "s", ".", "zero", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the tensor contains zeros.
[ "Returns", "true", "if", "the", "tensor", "contains", "zeros", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/model/globalfac/ProjDepTreeModule.java#L292-L300
12,094
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java
CkyPcfgParser.parseSentence
public static final void parseSentence(final int[] sent, final CnfGrammar grammar, final LoopOrder loopOrder, final Chart chart, final Scorer scorer) { // Apply lexical rules to each word. for (int i = 0; i <= sent.length - 1; i++) { ChartCell cell = chart.getCell(i, i+1); for (final Rule r : grammar.getLexicalRulesWithChild(sent[i])) { double score = scorer.score(r, i, i+1, i+1); cell.updateCell(r.getParent(), score, i+1, r); } } // For each cell in the chart. (width increasing) for (int width = 1; width <= sent.length; width++) { for (int start = 0; start <= sent.length - width; start++) { int end = start + width; ChartCell cell = chart.getCell(start, end); // Apply binary rules. if (loopOrder == LoopOrder.CARTESIAN_PRODUCT) { processCellCartesianProduct(grammar, chart, start, end, cell, scorer); } else if (loopOrder == LoopOrder.LEFT_CHILD) { processCellLeftChild(grammar, chart, start, end, cell, scorer); } else if (loopOrder == LoopOrder.RIGHT_CHILD) { processCellRightChild(grammar, chart, start, end, cell, scorer); } else { throw new RuntimeException("Not implemented: " + loopOrder); } processCellUnaryRules(grammar, start, end, cell, scorer); if (width == sent.length) { processCellUnaryRules(grammar, start, end, cell, scorer); } cell.close(); } } }
java
public static final void parseSentence(final int[] sent, final CnfGrammar grammar, final LoopOrder loopOrder, final Chart chart, final Scorer scorer) { // Apply lexical rules to each word. for (int i = 0; i <= sent.length - 1; i++) { ChartCell cell = chart.getCell(i, i+1); for (final Rule r : grammar.getLexicalRulesWithChild(sent[i])) { double score = scorer.score(r, i, i+1, i+1); cell.updateCell(r.getParent(), score, i+1, r); } } // For each cell in the chart. (width increasing) for (int width = 1; width <= sent.length; width++) { for (int start = 0; start <= sent.length - width; start++) { int end = start + width; ChartCell cell = chart.getCell(start, end); // Apply binary rules. if (loopOrder == LoopOrder.CARTESIAN_PRODUCT) { processCellCartesianProduct(grammar, chart, start, end, cell, scorer); } else if (loopOrder == LoopOrder.LEFT_CHILD) { processCellLeftChild(grammar, chart, start, end, cell, scorer); } else if (loopOrder == LoopOrder.RIGHT_CHILD) { processCellRightChild(grammar, chart, start, end, cell, scorer); } else { throw new RuntimeException("Not implemented: " + loopOrder); } processCellUnaryRules(grammar, start, end, cell, scorer); if (width == sent.length) { processCellUnaryRules(grammar, start, end, cell, scorer); } cell.close(); } } }
[ "public", "static", "final", "void", "parseSentence", "(", "final", "int", "[", "]", "sent", ",", "final", "CnfGrammar", "grammar", ",", "final", "LoopOrder", "loopOrder", ",", "final", "Chart", "chart", ",", "final", "Scorer", "scorer", ")", "{", "// Apply lexical rules to each word.", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "sent", ".", "length", "-", "1", ";", "i", "++", ")", "{", "ChartCell", "cell", "=", "chart", ".", "getCell", "(", "i", ",", "i", "+", "1", ")", ";", "for", "(", "final", "Rule", "r", ":", "grammar", ".", "getLexicalRulesWithChild", "(", "sent", "[", "i", "]", ")", ")", "{", "double", "score", "=", "scorer", ".", "score", "(", "r", ",", "i", ",", "i", "+", "1", ",", "i", "+", "1", ")", ";", "cell", ".", "updateCell", "(", "r", ".", "getParent", "(", ")", ",", "score", ",", "i", "+", "1", ",", "r", ")", ";", "}", "}", "// For each cell in the chart. (width increasing)", "for", "(", "int", "width", "=", "1", ";", "width", "<=", "sent", ".", "length", ";", "width", "++", ")", "{", "for", "(", "int", "start", "=", "0", ";", "start", "<=", "sent", ".", "length", "-", "width", ";", "start", "++", ")", "{", "int", "end", "=", "start", "+", "width", ";", "ChartCell", "cell", "=", "chart", ".", "getCell", "(", "start", ",", "end", ")", ";", "// Apply binary rules.", "if", "(", "loopOrder", "==", "LoopOrder", ".", "CARTESIAN_PRODUCT", ")", "{", "processCellCartesianProduct", "(", "grammar", ",", "chart", ",", "start", ",", "end", ",", "cell", ",", "scorer", ")", ";", "}", "else", "if", "(", "loopOrder", "==", "LoopOrder", ".", "LEFT_CHILD", ")", "{", "processCellLeftChild", "(", "grammar", ",", "chart", ",", "start", ",", "end", ",", "cell", ",", "scorer", ")", ";", "}", "else", "if", "(", "loopOrder", "==", "LoopOrder", ".", "RIGHT_CHILD", ")", "{", "processCellRightChild", "(", "grammar", ",", "chart", ",", "start", ",", "end", ",", "cell", ",", "scorer", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Not implemented: \"", "+", "loopOrder", ")", ";", "}", "processCellUnaryRules", "(", "grammar", ",", "start", ",", "end", ",", "cell", ",", "scorer", ")", ";", "if", "(", "width", "==", "sent", ".", "length", ")", "{", "processCellUnaryRules", "(", "grammar", ",", "start", ",", "end", ",", "cell", ",", "scorer", ")", ";", "}", "cell", ".", "close", "(", ")", ";", "}", "}", "}" ]
Runs CKY and populates the chart. @param sent The input sentence. @param grammar The input grammar. @param loopOrder The loop order to use when parsing. @param chart The output chart.
[ "Runs", "CKY", "and", "populates", "the", "chart", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java#L98-L134
12,095
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java
CkyPcfgParser.processCellUnaryRules
private static final void processCellUnaryRules(final CnfGrammar grammar, final int start, final int end, final ChartCell cell, final Scorer scorer) { // Apply unary rules. ScoresSnapshot scoresSnapshot = cell.getScoresSnapshot(); int[] nts = cell.getNts(); for(final int parentNt : nts) { for (final Rule r : grammar.getUnaryRulesWithChild(parentNt)) { double score = scorer.score(r, start, end, end) + scoresSnapshot.getScore(r.getLeftChild()); cell.updateCell(r.getParent(), score, end, r); } } }
java
private static final void processCellUnaryRules(final CnfGrammar grammar, final int start, final int end, final ChartCell cell, final Scorer scorer) { // Apply unary rules. ScoresSnapshot scoresSnapshot = cell.getScoresSnapshot(); int[] nts = cell.getNts(); for(final int parentNt : nts) { for (final Rule r : grammar.getUnaryRulesWithChild(parentNt)) { double score = scorer.score(r, start, end, end) + scoresSnapshot.getScore(r.getLeftChild()); cell.updateCell(r.getParent(), score, end, r); } } }
[ "private", "static", "final", "void", "processCellUnaryRules", "(", "final", "CnfGrammar", "grammar", ",", "final", "int", "start", ",", "final", "int", "end", ",", "final", "ChartCell", "cell", ",", "final", "Scorer", "scorer", ")", "{", "// Apply unary rules.", "ScoresSnapshot", "scoresSnapshot", "=", "cell", ".", "getScoresSnapshot", "(", ")", ";", "int", "[", "]", "nts", "=", "cell", ".", "getNts", "(", ")", ";", "for", "(", "final", "int", "parentNt", ":", "nts", ")", "{", "for", "(", "final", "Rule", "r", ":", "grammar", ".", "getUnaryRulesWithChild", "(", "parentNt", ")", ")", "{", "double", "score", "=", "scorer", ".", "score", "(", "r", ",", "start", ",", "end", ",", "end", ")", "+", "scoresSnapshot", ".", "getScore", "(", "r", ".", "getLeftChild", "(", ")", ")", ";", "cell", ".", "updateCell", "(", "r", ".", "getParent", "(", ")", ",", "score", ",", "end", ",", "r", ")", ";", "}", "}", "}" ]
Process a cell, unary rules only.
[ "Process", "a", "cell", "unary", "rules", "only", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java#L137-L149
12,096
mgormley/pacaya
src/main/java/edu/jhu/pacaya/parse/cky/data/NaryTree.java
NaryTree.getLeafAt
public NaryTree getLeafAt(int idx) { NaryTree leaf = null; for (NaryTree l : this.getLeaves()) { if (l.start <= idx && idx < l.end) { leaf = l; } } return leaf; }
java
public NaryTree getLeafAt(int idx) { NaryTree leaf = null; for (NaryTree l : this.getLeaves()) { if (l.start <= idx && idx < l.end) { leaf = l; } } return leaf; }
[ "public", "NaryTree", "getLeafAt", "(", "int", "idx", ")", "{", "NaryTree", "leaf", "=", "null", ";", "for", "(", "NaryTree", "l", ":", "this", ".", "getLeaves", "(", ")", ")", "{", "if", "(", "l", ".", "start", "<=", "idx", "&&", "idx", "<", "l", ".", "end", ")", "{", "leaf", "=", "l", ";", "}", "}", "return", "leaf", ";", "}" ]
Gets the leaf containing the specified token index.
[ "Gets", "the", "leaf", "containing", "the", "specified", "token", "index", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/data/NaryTree.java#L345-L353
12,097
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/model/globalfac/HeadAutomataFactor.java
HeadAutomataFactor.getVarsByDist
public static LinkVar[] getVarsByDist(int head, boolean isRight, LinkVar[] rootVars, LinkVar[][] childVars) { int dir = isRight ? 1 : -1; int maxDist = isRight ? rootVars.length - head - 1: head - 1; LinkVar[] varsByDist = new LinkVar[maxDist]; for (int cDist = 1; cDist <= maxDist; cDist++) { int c = head + dir*cDist; if (head == -1) { varsByDist[cDist-1] = rootVars[c]; } else { varsByDist[cDist-1] = childVars[head][c]; } } return varsByDist; }
java
public static LinkVar[] getVarsByDist(int head, boolean isRight, LinkVar[] rootVars, LinkVar[][] childVars) { int dir = isRight ? 1 : -1; int maxDist = isRight ? rootVars.length - head - 1: head - 1; LinkVar[] varsByDist = new LinkVar[maxDist]; for (int cDist = 1; cDist <= maxDist; cDist++) { int c = head + dir*cDist; if (head == -1) { varsByDist[cDist-1] = rootVars[c]; } else { varsByDist[cDist-1] = childVars[head][c]; } } return varsByDist; }
[ "public", "static", "LinkVar", "[", "]", "getVarsByDist", "(", "int", "head", ",", "boolean", "isRight", ",", "LinkVar", "[", "]", "rootVars", ",", "LinkVar", "[", "]", "[", "]", "childVars", ")", "{", "int", "dir", "=", "isRight", "?", "1", ":", "-", "1", ";", "int", "maxDist", "=", "isRight", "?", "rootVars", ".", "length", "-", "head", "-", "1", ":", "head", "-", "1", ";", "LinkVar", "[", "]", "varsByDist", "=", "new", "LinkVar", "[", "maxDist", "]", ";", "for", "(", "int", "cDist", "=", "1", ";", "cDist", "<=", "maxDist", ";", "cDist", "++", ")", "{", "int", "c", "=", "head", "+", "dir", "*", "cDist", ";", "if", "(", "head", "==", "-", "1", ")", "{", "varsByDist", "[", "cDist", "-", "1", "]", "=", "rootVars", "[", "c", "]", ";", "}", "else", "{", "varsByDist", "[", "cDist", "-", "1", "]", "=", "childVars", "[", "head", "]", "[", "c", "]", ";", "}", "}", "return", "varsByDist", ";", "}" ]
Gets the variables for this factor ordered from the head outward. @param head The 0-indexed head (i.e. -1 denotes the wall). @param isRight Whether or not this is a right or left head automata. @param rootVars The link vars with the wall as parent. @param childVars The other child variables. @return An array of variables order by increasing distance from the head.
[ "Gets", "the", "variables", "for", "this", "factor", "ordered", "from", "the", "head", "outward", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/model/globalfac/HeadAutomataFactor.java#L201-L214
12,098
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/model/VarTensor.java
VarTensor.getMarginal
public VarTensor getMarginal(VarSet vars, boolean normalize) { VarSet margVars = new VarSet(this.vars); margVars.retainAll(vars); VarTensor marg = new VarTensor(s, margVars, s.zero()); if (margVars.size() == 0) { return marg; } IntIter iter = margVars.getConfigIter(this.vars); for (int i=0; i<this.values.length; i++) { int j = iter.next(); marg.values[j] = s.plus(marg.values[j], this.values[i]); } if (normalize) { marg.normalize(); } return marg; }
java
public VarTensor getMarginal(VarSet vars, boolean normalize) { VarSet margVars = new VarSet(this.vars); margVars.retainAll(vars); VarTensor marg = new VarTensor(s, margVars, s.zero()); if (margVars.size() == 0) { return marg; } IntIter iter = margVars.getConfigIter(this.vars); for (int i=0; i<this.values.length; i++) { int j = iter.next(); marg.values[j] = s.plus(marg.values[j], this.values[i]); } if (normalize) { marg.normalize(); } return marg; }
[ "public", "VarTensor", "getMarginal", "(", "VarSet", "vars", ",", "boolean", "normalize", ")", "{", "VarSet", "margVars", "=", "new", "VarSet", "(", "this", ".", "vars", ")", ";", "margVars", ".", "retainAll", "(", "vars", ")", ";", "VarTensor", "marg", "=", "new", "VarTensor", "(", "s", ",", "margVars", ",", "s", ".", "zero", "(", ")", ")", ";", "if", "(", "margVars", ".", "size", "(", ")", "==", "0", ")", "{", "return", "marg", ";", "}", "IntIter", "iter", "=", "margVars", ".", "getConfigIter", "(", "this", ".", "vars", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "values", ".", "length", ";", "i", "++", ")", "{", "int", "j", "=", "iter", ".", "next", "(", ")", ";", "marg", ".", "values", "[", "j", "]", "=", "s", ".", "plus", "(", "marg", ".", "values", "[", "j", "]", ",", "this", ".", "values", "[", "i", "]", ")", ";", "}", "if", "(", "normalize", ")", "{", "marg", ".", "normalize", "(", ")", ";", "}", "return", "marg", ";", "}" ]
Gets the marginal distribution over a subset of the variables in this factor, optionally normalized. @param vars The subset of variables for the marginal distribution. This will sum over all variables not in this set. @param normalize Whether to normalize the resulting distribution. @return The marginal distribution.
[ "Gets", "the", "marginal", "distribution", "over", "a", "subset", "of", "the", "variables", "in", "this", "factor", "optionally", "normalized", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/model/VarTensor.java#L65-L85
12,099
mgormley/pacaya
src/main/java/edu/jhu/pacaya/gm/model/VarTensor.java
VarTensor.add
public void add(VarTensor f) { VarTensor newFactor = applyBinOp(this, f, new AlgebraLambda.Add()); internalSet(newFactor); }
java
public void add(VarTensor f) { VarTensor newFactor = applyBinOp(this, f, new AlgebraLambda.Add()); internalSet(newFactor); }
[ "public", "void", "add", "(", "VarTensor", "f", ")", "{", "VarTensor", "newFactor", "=", "applyBinOp", "(", "this", ",", "f", ",", "new", "AlgebraLambda", ".", "Add", "(", ")", ")", ";", "internalSet", "(", "newFactor", ")", ";", "}" ]
Adds a factor to this one. From libDAI: The sum of two factors is defined as follows: if \f$f : \prod_{l\in L} X_l \to [0,\infty)\f$ and \f$g : \prod_{m\in M} X_m \to [0,\infty)\f$, then \f[f+g : \prod_{l\in L\cup M} X_l \to [0,\infty) : x \mapsto f(x_L) + g(x_M).\f]
[ "Adds", "a", "factor", "to", "this", "one", "." ]
786294cbac7cc65dbc32210c10acc32ed0c69233
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/model/VarTensor.java#L120-L123