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

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

Introduction

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

Prototype

public static boolean[] subarray(boolean[] array, int startIndexInclusive, int endIndexExclusive) 

Source Link

Document

Produces a new boolean array containing the elements between the start and end indices.

Usage

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

static char[][] getQualifiedName(final char[] aName) {
    final char[] name = Utils.convertSeparators(aName);
    final List<char[]> parts = new ArrayList<char[]>();
    int start = -1;
    int end = -1;
    // Yann 2014/06/27: Method names and parameters...
    // For the case
    //   location(enum QLibraryInfo::LibraryLocation)
    // I must also end if a parenthesis is before the next separator.
    while ((end = ArrayUtils.indexOf(name, Utils.SEPARATOR, start)) > -1
            && end > ArrayUtils.indexOf(name, '(', start)) {

        final char[] part = ArrayUtils.subarray(name, start, end);
        start = end + 1;/*from   w  ww .j  a v  a2s.c om*/
        parts.add(part);
    }
    parts.add(ArrayUtils.subarray(name, start, name.length));
    final char[][] qualifiedName = new char[parts.size()][];
    parts.toArray(qualifiedName);
    return qualifiedName;
}

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

static char[][] getQualifiedType(final char[] aName) {
    final List<char[]> parts = new ArrayList<char[]>();
    int start = -1;
    int end = -1;
    while ((end = ArrayUtils.indexOf(aName, Utils.SEPARATOR, start)) > -1) {
        final char[] part = ArrayUtils.subarray(aName, start, end);
        start = end + 1;/*from w  w  w.j  av  a  2s.  com*/
        parts.add(part);
    }
    final char[][] qualifiedName = new char[parts.size()][];
    parts.toArray(qualifiedName);
    return qualifiedName;
}

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  . ja v  a  2s . c o  m
    return cleanedName;
}

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

static void reportUnknownType(final Class<?> aReporter, final String aMessage, final char[] aTypeName,
        final Class<?> aTypeType) {

    final StringBuffer buffer = new StringBuffer();
    buffer.append(aReporter.getName());/*from w w w .ja  v a2 s  . co m*/
    buffer.append(" does not know what to do with ");
    buffer.append(aMessage);
    buffer.append(" \"");
    buffer.append(ArrayUtils.subarray(aTypeName, 0, Math.min(aTypeName.length, 16)));
    buffer.append("...\" (");
    buffer.append(aTypeType.getName());
    buffer.append(')');

    final String message = buffer.toString();

    if (!Utils.CacheErrorMessages.contains(message)) {
        Utils.CacheErrorMessages.add(message);
        ProxyConsole.getInstance().debugOutput().print(message);
    }
}

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  w  w  . j av  a2s  .c o  m*/
 * @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   w w  w  .  j av a2  s .c o  m*/
 * @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.creator.javafile.eclipse.util.PadlParserUtil.java

/**
 * Create possibly recursively packages//www . java2s .co  m
 * 
 * @param aPackageName
 * @param aCodeLevelModel
 * @return
 */
public static IPackage getOrCreatePackage(final char[] aPackageName, final ICodeLevelModel aCodeLevelModel) {

    IPackage currentPackage = null;
    int startIndexInclusive = 0;
    do {
        int endIndexExclusive = ArrayUtils.indexOf(aPackageName, '.', startIndexInclusive);
        if (endIndexExclusive == -1) {
            endIndexExclusive = aPackageName.length;
        }
        final char[] tempName = ArrayUtils.subarray(aPackageName, startIndexInclusive, endIndexExclusive);
        if (currentPackage == null) {
            currentPackage = PadlParserUtil.createPackage(tempName, aCodeLevelModel);
        } else {
            currentPackage = PadlParserUtil.createPackage(tempName, currentPackage, aCodeLevelModel);
        }
        startIndexInclusive = endIndexExclusive + 1;
    } while (startIndexInclusive < aPackageName.length);

    return currentPackage;
}

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

private void addUniqueIDToEnclosedConstituent(final IConstituent aConstituent) {
    // Yann 2006/02/24: UniqueID...
    // I need a UniqueID for IMethodInvocation and IParemeter in IMethod
    // and for any IRelationship in IEntity. So, when using the method
    // concretelyAddConstituent(), I take care of the unique ID.

    this.uniqueID++;
    if (this instanceof AbstractGenericContainerOfConstituents && aConstituent instanceof Constituent) {

        final char[] uniqueID = String.valueOf(this.uniqueID).toCharArray();
        final int endIndexExclusive = aConstituent.getDisplayID().indexOf(Constants.NUMBER_SEPARATOR);
        final char[] constituentID;
        if (endIndexExclusive > 0) {
            constituentID = ArrayUtils.subarray(aConstituent.getID(), 0, endIndexExclusive);
        } else {/*from w ww .  j a  v a  2 s .co m*/
            constituentID = aConstituent.getID();
        }
        final char[] newID = new char[constituentID.length + Constants.NUMBER_SEPARATOR.length()
                + uniqueID.length];
        System.arraycopy(constituentID, 0, newID, 0, constituentID.length);
        System.arraycopy(Constants.NUMBER_SEPARATOR.toCharArray(), 0, newID, constituentID.length,
                Constants.NUMBER_SEPARATOR.length());
        System.arraycopy(uniqueID, 0, newID, constituentID.length + Constants.NUMBER_SEPARATOR.length(),
                uniqueID.length);
        ((Constituent) aConstituent).setID(newID);

        // Yann 2009/06/06: Path!
        // I don't forget to update the path accordingly...
        ((Constituent) aConstituent).setPath(newID);
    }
}

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.j av  a2 s. c  om*/

    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)/*w  ww . j  a  v  a  2 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);
        }
    }
}