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

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

Introduction

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

Prototype

public static int lastIndexOf(boolean[] array, boolean valueToFind) 

Source Link

Document

Finds the last index of the given value within the array.

Usage

From source file:padl.creator.classfile.util.Utils.java

public static char[] extractPackageName(final char[] aJVMClassName) {
    if (ArrayUtils.indexOf(aJVMClassName, '.') == -1) {
        return Utils.DEFAULT_PACKAGE_NAME;
    } else {// ww  w .j  a  va  2 s .  c o  m
        return ArrayUtils.subarray(aJVMClassName, 0, ArrayUtils.lastIndexOf(aJVMClassName, '.'));
    }
}

From source file:padl.creator.classfile.util.Utils.java

public static boolean isAnonymousOrLocalEntity(final char[] anEntityName) {
    final int first = ArrayUtils.indexOf(anEntityName, '$');
    int last = ArrayUtils.lastIndexOf(anEntityName, '$');
    if (first > -1) {
        if (first == last) {
            last = anEntityName.length;//ww w.j  a va  2 s.co  m
        }

        try {
            Integer.parseInt(String.valueOf(ArrayUtils.subarray(anEntityName, first + 1, last)));
        } catch (final NumberFormatException nfe) {
            return false;
        }
        return true;
    }

    return false;
}

From source file:padl.creator.cppfile.eclipse.plugin.internal.Accumulator.java

IOperation getOperation(final ICPPFunction aCPPFunction) {
    final IOperation operation = this.mapCPPFunctionPADLOperations.get(aCPPFunction);
    if (operation != null) {
        return operation;
    }//from  w  ww . j ava2 s . c om

    // Eclipse is doing something phony in our backs...
    char[] functionSignature = Utils.computeSignature(aCPPFunction);
    // These weird PDOMCPP objects have at the end of their signature
    // some kind of tag that I must remove to make sense... because they
    // don't: no information on the Internet regarding these classes :-(
    functionSignature = ArrayUtils.subarray(functionSignature, 0,
            ArrayUtils.lastIndexOf(functionSignature, ')') + 1);

    final Iterator<Map.Entry<ICPPFunction, IOperation>> iterator = this.mapCPPFunctionPADLOperations.entrySet()
            .iterator();
    while (iterator.hasNext()) {
        final Map.Entry<ICPPFunction, IOperation> entry = iterator.next();
        final ICPPFunction candidateFunction = entry.getKey();
        final char[] candidateFunctionSignature = Utils.computeSignature(candidateFunction);
        if (Arrays.equals(candidateFunctionSignature, functionSignature)) {
            final IOperation candidateOperation = (IOperation) entry.getValue();
            this.mapCPPFunctionPADLOperations.put(aCPPFunction, candidateOperation);
            return candidateOperation;
        }
    }

    Utils.reportUnknownType(Accumulator.class, "operation", aCPPFunction.toString(), aCPPFunction.getClass());
    return null;
}

From source file:padl.creator.cppfile.eclipse.plugin.internal.Utils.java

static char[] removeQualifiers(char[] aName) {
    char cleanedName[] = ArrayUtils.subarray(aName, ArrayUtils.lastIndexOf(aName, ' ') + 1, aName.length);
    int indexOfLessThan = ArrayUtils.indexOf(cleanedName, '<');
    if (indexOfLessThan > -1) {
        cleanedName = ArrayUtils.subarray(cleanedName, 0, indexOfLessThan);
    }//  w w  w.j a v  a 2 s. co  m
    return cleanedName;
}

From source file:padl.creator.javafile.eclipse.util.PadlParserUtil.java

/**
 * Compute a simple name (the term after the last .) from a qualified name
 * //from w ww .j  a va 2s  .c  om
 * @param aFullyQualifiedName
 * @return
 */
public static char[] computeSimpleName(final char[] aFullyQualifiedName) {
    //   final String fullyQualifiedName =
    //      ArrayUtils.toString(aFullyQualifiedName);
    final int index = ArrayUtils.lastIndexOf(aFullyQualifiedName, '.');

    final char[] name = ArrayUtils.subarray(aFullyQualifiedName, index + 1, aFullyQualifiedName.length);

    return name;
}

From source file:padl.creator.javafile.eclipse.util.PadlParserUtil.java

/**
 * extract the name of a package via the name of an entity
 * //from ww  w  .j  a v a  2 s .  c  om
 * @param aJVMClassName
 * @return
 */
public static char[] extractPackageName(final char[] aJVMClassName) {
    if (ArrayUtils.indexOf(aJVMClassName, '.') == -1) {
        return PadlParserUtil.DEFAULT_PACKAGE_NAME;
    } else {
        return ArrayUtils.subarray(aJVMClassName, 0, ArrayUtils.lastIndexOf(aJVMClassName, '.'));
    }
}

From source file:padl.kernel.impl.AbstractGenericContainerOfConstituents.java

private void updatePathUponAddition(final INavigable aContainer, final IConstituent aConstituent) {

    final char[] containerPath = aContainer.getPath();
    final int startIndexInclusive = ArrayUtils.lastIndexOf(aConstituent.getPath(),
            ((Constituent) aConstituent).getPathSymbol()) + 1;
    final int endIndexExclusive = aConstituent.getPath().length;
    final char[] constituentPath = ArrayUtils.subarray(aConstituent.getPath(), startIndexInclusive,
            endIndexExclusive);//ww w  .  ja v  a2 s .c o m

    final char[] newPath = new char[containerPath.length + 1 + constituentPath.length];
    System.arraycopy(containerPath, 0, newPath, 0, containerPath.length);
    newPath[containerPath.length] = ((Constituent) aConstituent).getPathSymbol();
    System.arraycopy(constituentPath, 0, newPath, containerPath.length + 1, constituentPath.length);
    ((Constituent) aConstituent).setPath(newPath);

    // Yann 2013/05/22: Propagation!
    // I should not forget to propagate this change 
    // iff this constituent is a container, silly!
    // I must use instanceof because there is no
    // class Container per se but Constituent plays
    // its role...
    if (aConstituent instanceof IContainer) {
        final Iterator iterator = ((IContainer) aConstituent).getIteratorOnConstituents();
        while (iterator.hasNext()) {
            final Constituent constituent = (Constituent) iterator.next();
            this.updatePathUponAddition((INavigable) aConstituent, constituent);
        }
    }
}

From source file:padl.kernel.impl.AbstractGenericContainerOfConstituents.java

private void updatePathUponRemoval(final IConstituent aConstituent) {
    // Yann 2009/05/06: Path
    // After having removed a constituent from a model,
    // I make sure that I "reset" its path so that I can
    // add it to another model. Also, I will test when
    // adding a constituent if it does not include path
    // information to prevent two models to share
    // constituents, maybe the clone process should be
    // involved too... I'll think about it later.
    final int startIndexInclusive = ArrayUtils.lastIndexOf(aConstituent.getPath(),
            ((Constituent) aConstituent).getPathSymbol()) + 1;
    final int endIndexExclusive = aConstituent.getPath().length;
    ((Constituent) aConstituent)//ww w  .j  a  v a2 s .  c  o m
            .setPath(ArrayUtils.subarray(aConstituent.getPath(), startIndexInclusive, endIndexExclusive));

    // Yann 2013/05/22: Propagation!
    // I should not forget to propagate this change 
    // iff this constituent is a container, silly!
    // I must use instanceof because there is no
    // class Container per se but Constituent plays
    // its role...
    if (aConstituent instanceof IContainer) {
        final Iterator iterator = ((IContainer) aConstituent).getIteratorOnConstituents();
        while (iterator.hasNext()) {
            final Constituent constituent = (Constituent) iterator.next();
            this.updatePathUponRemoval(constituent);
        }
    }
}

From source file:padl.util.Util.java

public static char[] computeSimpleName(final char[] aFullyQualifiedName) {
    char[] simpleName = aFullyQualifiedName;
    int index;/*from w w w . j a  va 2  s  .c o  m*/

    // Yann 2006/08/03: Member class!
    // When computing the simple name of a class, I don't
    // forget that this class could be a member class and
    // that I don't want to care about its declaring class
    // (preceding the '$' sign).
    index = ArrayUtils.lastIndexOf(simpleName, '$');
    if (index > 0) {
        simpleName = ArrayUtils.subarray(aFullyQualifiedName, index + 1, aFullyQualifiedName.length);
    } else {
        index = ArrayUtils.lastIndexOf(simpleName, '.');
        if (index > 0) {
            simpleName = ArrayUtils.subarray(simpleName, index + 1, simpleName.length);
        }
    }

    return simpleName;
}

From source file:ptidej.solver.Occurrence.java

/**
 * Gets the part of the solution with non-enumerated name <name>.
 *//*from  ww  w . j a va 2s.c o m*/
public OccurrenceComponent getComponent(final char[] aName) {
    final Iterator e = this.components.iterator();
    while (e.hasNext()) {
        final OccurrenceComponent c = (OccurrenceComponent) e.next();
        char[] cName = c.getName();
        final int indexOfLastDash = ArrayUtils.lastIndexOf(cName, '-');
        if (indexOfLastDash > 0) {
            try {
                Integer.parseInt(String.valueOf(ArrayUtils.subarray(cName, indexOfLastDash + 1, cName.length)));
                cName = ArrayUtils.subarray(cName, 0, indexOfLastDash);
            } catch (final NumberFormatException nfe) {
            }
        }
        if (Arrays.equals(cName, aName)) {
            return c;
        }
    }
    return null;
}