Example usage for org.apache.commons.lang ArrayUtils removeElement

List of usage examples for org.apache.commons.lang ArrayUtils removeElement

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils removeElement.

Prototype

public static short[] removeElement(short[] array, short element) 

Source Link

Document

Removes the first occurrence of the specified element from the specified array.

Usage

From source file:org.broadleafcommerce.core.web.processor.ToggleFacetLinkProcessor.java

@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element,
        String attributeName) {/*from   www  . jav  a  2  s  . c  o m*/
    Map<String, String> attrs = new HashMap<String, String>();

    BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext();
    HttpServletRequest request = blcContext.getRequest();

    String baseUrl = request.getRequestURL().toString();
    Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());

    Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
            .parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
    SearchFacetResultDTO result = (SearchFacetResultDTO) expression.execute(arguments.getConfiguration(),
            arguments);

    String key = facetService.getUrlKey(result);
    String value = facetService.getValue(result);
    String[] paramValues = params.get(key);

    if (ArrayUtils.contains(paramValues, facetService.getValue(result))) {
        paramValues = (String[]) ArrayUtils.removeElement(paramValues, facetService.getValue(result));
    } else {
        paramValues = (String[]) ArrayUtils.add(paramValues, value);
    }

    params.remove(SearchCriteria.PAGE_NUMBER);
    params.put(key, paramValues);

    String url = ProcessorUtils.getUrl(baseUrl, params);

    attrs.put("href", url);
    return attrs;
}

From source file:org.codehaus.groovy.eclipse.core.model.GroovyRuntime.java

/**
 * Removes a classpath entry to a project
 *
 * @param project//from ww w . j  a  v a 2 s  .  c om
 *            The project to remove the entry.
 * @param newEntry
 *            The entry to remove.
 * @throws JavaModelException
 */
public static void removeClassPathEntry(IJavaProject project, IClasspathEntry newEntry)
        throws JavaModelException {
    IClasspathEntry[] newEntries = (IClasspathEntry[]) ArrayUtils.removeElement(project.getRawClasspath(),
            newEntry);
    project.setRawClasspath(newEntries, null);
}

From source file:org.datacleaner.panels.fuse.ColumnListMultipleCoalesceUnitPropertyWidget.java

@Override
public void onValueTouched(final InputColumn<?>[] value) {
    try {/*ww  w  .  java 2 s  .c o m*/
        super.onValueTouched(value);
    } catch (final CoalesceUnitMissingColumnException e) {
        logger.warn("Missing input column for coalesce unit", e);
        final CoalesceUnit failingCoalesceUnit = e.getCoalesceUnit();
        final CoalesceUnit[] newCoalesceUnits = (CoalesceUnit[]) ArrayUtils
                .removeElement(_unitPropertyWidget.getValue(), failingCoalesceUnit);
        for (final InputColumn<?> inputColumn : failingCoalesceUnit.getInputColumns()) {
            _pickedInputColumns.remove(inputColumn);
        }
        getCoalesceUnitPanels().stream()
                .filter(coalesceUnitPanel -> coalesceUnitPanel.getCoalesceUnit().equals(failingCoalesceUnit))
                .forEach(this::removeCoalesceUnitPanel);
        _unitPropertyWidget.onValueTouched(newCoalesceUnits);
        updateAvailableInputColumns();
        fireBothValuesChanged();
        updateUI();
    }
}

From source file:org.deeplearning4j.models.embeddings.wordvectors.WordVectorsImpl.java

/**
 * This method returns 2D array, where each row represents corresponding label
 *
 * @param labels//from   www  .j  a va2  s.c  om
 * @return
 */
@Override
public INDArray getWordVectors(@NonNull Collection<String> labels) {
    int indexes[] = new int[labels.size()];
    int cnt = 0;
    for (String label : labels) {
        if (vocab.containsWord(label)) {
            indexes[cnt] = vocab.indexOf(label);
        } else
            indexes[cnt] = -1;
        cnt++;
    }

    while (ArrayUtils.contains(indexes, -1)) {
        indexes = ArrayUtils.removeElement(indexes, -1);
    }

    INDArray result = Nd4j.pullRows(lookupTable.getWeights(), 1, indexes);
    return result;
}

From source file:org.eclipse.wb.gef.tree.policies.LayoutEditPolicy.java

/**
 * Remove host widget from tree selection.
 */// w  w w .  j  a  v  a2 s. co  m
private void removeFromSelection() {
    TreeItem widget = getHostWidget();
    Tree tree = getTree();
    TreeItem[] selection = tree.getSelection();
    if (ArrayUtils.contains(selection, widget)) {
        selection = (TreeItem[]) ArrayUtils.removeElement(selection, widget);
        tree.setSelection(selection);
    }
}

From source file:org.eclipse.wb.internal.core.model.util.factory.FactoryActionsSupport.java

/**
 * Adds new factory type into history, but limit history to some size.
 *//*from w ww  .  ja v a2s . c o  m*/
static void addPreviousTypeName(JavaInfo component, String typeName) throws CoreException {
    String[] typeNames = getPreviousTypeNames(component);
    // move element into head
    typeNames = (String[]) ArrayUtils.removeElement(typeNames, typeName);
    typeNames = (String[]) ArrayUtils.add(typeNames, 0, typeName);
    // limit history size
    if (typeNames.length > MAX_PREVIOUS_FACTORIES) {
        typeNames = (String[]) ArrayUtils.remove(typeNames, typeNames.length - 1);
    }
    // set new type names
    IProject project = component.getEditor().getJavaProject().getProject();
    project.setPersistentProperty(KEY_PREVIOUS_FACTORIES, StringUtils.join(typeNames, ','));
}

From source file:org.eclipse.wb.internal.swing.model.property.editor.beans.JavaBeanEditorProvider.java

@Override
public PropertyEditor getEditorForType(Class<?> propertyType) throws Exception {
    String propertyTypeName = propertyType.getName();
    if (Object.class.isAssignableFrom(propertyType) && propertyType != char[].class
            && propertyType != byte[].class && propertyType != int[].class && propertyType != int[][].class
            && propertyTypeName.indexOf("java.lang.") == -1 && propertyTypeName.indexOf("java.util.") == -1
            && propertyTypeName.indexOf("java.awt.") == -1 && propertyTypeName.indexOf("javax.swing.") == -1
            && propertyTypeName.indexOf("org.eclipse.") == -1) {
        String[] standard_editorSearchPath = PropertyEditorManager.getEditorSearchPath();
        try {//  w ww  .  j a va 2s .c om
            PropertyEditorManager.setEditorSearchPath(
                    (String[]) ArrayUtils.removeElement(standard_editorSearchPath, "sun.beans.editors"));
            java.beans.PropertyEditor propertyEditor = PropertyEditorManager.findEditor(propertyType);
            if (propertyEditor != null) {
                return createEditor(propertyEditor);
            }
        } finally {
            PropertyEditorManager.setEditorSearchPath(standard_editorSearchPath);
        }
    }
    return null;
}

From source file:org.exoplatform.faq.service.search.AnswerSearchResult.java

@Override
public boolean remove(Object o) {
    if (o instanceof ObjectSearchResult) {
        ObjectSearchResult a = (ObjectSearchResult) o;
        ids = (String[]) ArrayUtils.removeElement(ids, a.getId());
        return gotList.remove(o);
    }/*  w  ww  .  j  a v  a2s.  c om*/

    //
    return false;
}

From source file:org.exoplatform.forum.service.search.DiscussionSearchResult.java

@Override
public boolean remove(Object o) {
    if (o instanceof ForumSearchResult) {
        ForumSearchResult a = (ForumSearchResult) o;
        ids = (String[]) ArrayUtils.removeElement(ids, a.getId());
        return gotList.remove(o);
    }/*  w w w  .j  a  v  a  2s . c o  m*/

    //
    return false;
}

From source file:org.exoplatform.forum.webui.UITopicContainer.java

public String[] getActionMenuForum() throws Exception {
    String[] actions = new String[] { "EditForum", "SetUnLockForum", "SetLockedForum", "SetOpenForum",
            "SetCloseForum", "MoveForum", "RemoveForum", "ExportForum", "WatchOption", "BanIpForumTools" };
    if (userProfile.getUserRole() > 0 || (userProfile.getUserRole() == 0
            && (!ForumUtils.isEmpty(getAncestorOfType(UIForumPortlet.class).getForumIdOfSpace())))) {
        actions = (String[]) ArrayUtils.removeElement(actions, "RemoveForum");
        actions = (String[]) ArrayUtils.removeElement(actions, "MoveForum");
    }/*from  ww w. ja va 2  s .  c  o  m*/
    return actions;
}