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

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

Introduction

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

Prototype

public static double[] addAll(double[] array1, double[] array2) 

Source Link

Document

Adds all the elements of the given arrays into a new array.

Usage

From source file:org.broadinstitute.sting.utils.Haplotype.java

@Requires({ "refInsertLocation >= 0" })
public Haplotype insertAllele(final Allele refAllele, final Allele altAllele, final int refInsertLocation) {
    // refInsertLocation is in ref haplotype offset coordinates NOT genomic coordinates
    final int haplotypeInsertLocation = ReadUtils.getReadCoordinateForReferenceCoordinate(
            alignmentStartHapwrtRef, cigar, refInsertLocation, ReadUtils.ClippingTail.RIGHT_TAIL, true);
    if (haplotypeInsertLocation == -1 || haplotypeInsertLocation + refAllele.length() >= bases.length) { // desired change falls inside deletion so don't bother creating a new haplotype
        return null;
    }/*w w w .  j a  v a2 s .c  om*/
    byte[] newHaplotypeBases = new byte[] {};
    newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases,
            ArrayUtils.subarray(bases, 0, haplotypeInsertLocation)); // bases before the variant
    newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, altAllele.getBases()); // the alt allele of the variant
    newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases,
            ArrayUtils.subarray(bases, haplotypeInsertLocation + refAllele.length(), bases.length)); // bases after the variant
    return new Haplotype(newHaplotypeBases);
}

From source file:org.broadinstitute.sting.utils.variant.GATKVariantContextUtils.java

public static Pair<int[], byte[]> getNumTandemRepeatUnits(final byte[] refBases, final byte[] altBases,
        final byte[] remainingRefContext) {
    /* we can't exactly apply same logic as in basesAreRepeated() to compute tandem unit and number of repeated units.
      Consider case where ref =ATATAT and we have an insertion of ATAT. Natural description is (AT)3 -> (AT)2.
    *///  w  w  w  . j a  v  a 2  s  .c o  m

    byte[] longB;
    // find first repeat unit based on either ref or alt, whichever is longer
    if (altBases.length > refBases.length)
        longB = altBases;
    else
        longB = refBases;

    // see if non-null allele (either ref or alt, whichever is longer) can be decomposed into several identical tandem units
    // for example, -*,CACA needs to first be decomposed into (CA)2
    final int repeatUnitLength = findRepeatedSubstring(longB);
    final byte[] repeatUnit = Arrays.copyOf(longB, repeatUnitLength);

    final int[] repetitionCount = new int[2];
    // look for repetitions forward on the ref bases (i.e. starting at beginning of ref bases)
    int repetitionsInRef = findNumberofRepetitions(repeatUnit, refBases, true);
    repetitionCount[0] = findNumberofRepetitions(repeatUnit, ArrayUtils.addAll(refBases, remainingRefContext),
            true) - repetitionsInRef;
    repetitionCount[1] = findNumberofRepetitions(repeatUnit, ArrayUtils.addAll(altBases, remainingRefContext),
            true) - repetitionsInRef;

    return new Pair<int[], byte[]>(repetitionCount, repeatUnit);

}

From source file:org.broadleafcommerce.common.copy.MultiTenantCopyContext.java

public Field[] getAllFields(Class<?> targetClass) {
    Field[] allFields = new Field[] {};
    boolean eof = false;
    Class<?> currentClass = targetClass;
    while (!eof) {
        Field[] fields = currentClass.getDeclaredFields();
        allFields = (Field[]) ArrayUtils.addAll(allFields, fields);
        if (currentClass.getSuperclass() != null) {
            currentClass = currentClass.getSuperclass();
        } else {/*from  w w w.  jav  a 2  s .c  o m*/
            eof = true;
        }
    }

    return allFields;
}

From source file:org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl.java

protected void buildPropertiesFromPolymorphicEntities(Class<?>[] entities, ForeignKey foreignField,
        String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields,
        MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields,
        String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname,
        Map<String, FieldMetadata> mergedProperties, List<Class<?>> parentClasses, String prefix,
        Boolean isParentExcluded) {
    for (Class<?> clazz : entities) {
        String cacheKey = getCacheKey(foreignField, additionalNonPersistentProperties, additionalForeignFields,
                mergedPropertyType, populateManyToOneFields, clazz, configurationKey, isParentExcluded);

        Map<String, FieldMetadata> cacheData = null;
        synchronized (DynamicDaoHelperImpl.LOCK_OBJECT) {
            if (useCache()) {
                cacheData = METADATA_CACHE.get(cacheKey);
            }/*from w  w  w .jav  a 2  s  .  c o m*/

            if (cacheData == null) {
                Map<String, FieldMetadata> props = getPropertiesForEntityClass(clazz, foreignField,
                        additionalNonPersistentProperties, additionalForeignFields, mergedPropertyType,
                        populateManyToOneFields, includeFields, excludeFields, configurationKey,
                        ceilingEntityFullyQualifiedClassname, parentClasses, prefix, isParentExcluded);
                //first check all the properties currently in there to see if my entity inherits from them
                for (Class<?> clazz2 : entities) {
                    if (!clazz2.getName().equals(clazz.getName())) {
                        for (Map.Entry<String, FieldMetadata> entry : props.entrySet()) {
                            FieldMetadata metadata = entry.getValue();
                            try {
                                if (Class.forName(metadata.getInheritedFromType()).isAssignableFrom(clazz2)) {
                                    String[] both = (String[]) ArrayUtils.addAll(metadata.getAvailableToTypes(),
                                            new String[] { clazz2.getName() });
                                    metadata.setAvailableToTypes(both);
                                }
                            } catch (ClassNotFoundException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }
                }
                METADATA_CACHE.put(cacheKey, props);
                cacheData = props;
            }
        }
        //clone the metadata before passing to the system
        Map<String, FieldMetadata> clonedCache = new HashMap<String, FieldMetadata>(cacheData.size());
        for (Map.Entry<String, FieldMetadata> entry : cacheData.entrySet()) {
            clonedCache.put(entry.getKey(), entry.getValue().cloneFieldMetadata());
        }
        mergedProperties.putAll(clonedCache);
    }
}

From source file:org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl.java

@Override
public Field[] getAllFields(Class<?> targetClass) {
    Field[] allFields = new Field[] {};
    boolean eof = false;
    Class<?> currentClass = targetClass;
    while (!eof) {
        Field[] fields = currentClass.getDeclaredFields();
        allFields = (Field[]) ArrayUtils.addAll(allFields, fields);
        if (currentClass.getSuperclass() != null) {
            currentClass = currentClass.getSuperclass();
        } else {//from   ww  w.j a va  2 s  .c om
            eof = true;
        }
    }

    return allFields;
}

From source file:org.broadleafcommerce.openadmin.server.service.persistence.entitymanager.HibernateCleaner.java

protected Field[] getFields(Class<?> clazz) {
    Field[] fields = new Field[] {};
    Class<?> myClass = clazz;
    boolean eof = false;
    while (!eof) {
        Field[] temp = myClass.getDeclaredFields();
        fields = (Field[]) ArrayUtils.addAll(temp, fields);
        if (myClass.getSuperclass() != null) {
            myClass = myClass.getSuperclass();
        } else {/*from   ww  w .  j  a v a  2 s.c  o m*/
            eof = true;
        }
    }

    return fields;
}

From source file:org.carewebframework.api.spring.FrameworkAppContext.java

/**
 * Adds one or more locations to the list of current locations to search for configuration
 * files./*from  ww  w .  j  av  a 2 s .c o  m*/
 * 
 * @param location One or more locations to search.
 */
public void addConfigLocation(String... location) {
    setConfigLocations((String[]) ArrayUtils.addAll(getConfigLocations(), location));
}

From source file:org.carewebframework.maven.plugin.theme.AbstractThemeProcessor.java

protected void addConfigEntry(String insertionTag, String... params) {
    params = (String[]) ArrayUtils
            .addAll(new String[] { theme.getThemeName(), theme.getThemeVersion(), getThemeBase() }, params);
    mojo.addConfigEntry(insertionTag, params);
}

From source file:org.carewebframework.ui.spring.FrameworkAppContext.java

/**
 * For the root container, adds the usual defaults to any custom locations. For a child
 * container, returns just the usual defaults.
 *//*w ww. ja  v a 2s  .com*/
@Override
protected String[] getDefaultConfigLocations() {
    return desktop == null
            ? (String[]) ArrayUtils.addAll(Constants.DEFAULT_LOCATIONS, super.getDefaultConfigLocations())
            : Constants.DEFAULT_LOCATIONS;
}

From source file:org.cesecore.audit.impl.queued.AuditLogProcessQueue.java

public byte[] dependencyData(final AuditLogProcess process) throws IOException {
    byte[] data = {};
    synchronized (pullLock) {
        for (final Iterator<AuditLogData> it = logs.iterator(); it.hasNext();) {
            final AuditLogData auditLogData = it.next();
            if (auditLogData.getSequenceNumber() < process.getAuditLogData().getSequenceNumber()) {
                data = ArrayUtils.addAll(auditLogData.getBytes(), data);
                it.remove();//from   w  ww.  jav a 2s . c o m
            } else {
                break;
            }
        }
    }
    return data;
}