当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils类代码示例

本文整理汇总了Java中org.apache.commons.lang.ArrayUtils的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils类的具体用法?Java ArrayUtils怎么用?Java ArrayUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArrayUtils类属于org.apache.commons.lang包,在下文中一共展示了ArrayUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
/**
 * 删除用户
 */
@SysLog("删除用户")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public R delete(@RequestBody Long[] userIds){
	if(ArrayUtils.contains(userIds, 1L)){
		return R.error("系统管理员不能删除");
	}
	
	if(ArrayUtils.contains(userIds, getUserId())){
		return R.error("当前用户不能删除");
	}
	
	sysUserService.deleteBatch(userIds);
	
	return R.ok();
}
 
开发者ID:guolf,项目名称:pds,代码行数:20,代码来源:SysUserController.java

示例2: getVirtualFile

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
private void getVirtualFile(String sourceName, VirtualFile virtualFile[], String compileRoot)
        throws Exception {
    if (!ArrayUtils.isEmpty(virtualFile)) {
        VirtualFile arr$[] = virtualFile;
        int len$ = arr$.length;
        for (int i$ = 0; i$ < len$; i$++) {
            VirtualFile vf = arr$[i$];
            String srcName;
            if (StringUtils.indexOf(vf.toString(), "$") != -1)
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.indexOf(vf.toString(), "$"));
            else
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.length(vf.toString()) - 6);
            String dstName = StringUtils.substring(sourceName, 0, StringUtils.length(sourceName) - 5);
            if (StringUtils.equals(srcName, dstName)) {
                String outRoot = (new StringBuilder()).append(StringUtils.substring(compileRoot, 0, StringUtils.lastIndexOf(compileRoot, "/"))).append("/out").toString();
                String packagePath = StringUtils.substring(vf.getPath(), StringUtils.length(compileRoot), StringUtils.length(vf.getPath()));
                File s = new File(vf.getPath());
                File t = new File((new StringBuilder()).append(outRoot).append(packagePath).toString());
                FileUtil.copy(s, t);
            }
            if (!ArrayUtils.isEmpty(virtualFile))
                getVirtualFile(sourceName, vf.getChildren(), compileRoot);
        }

    }
}
 
开发者ID:serical,项目名称:patcher,代码行数:27,代码来源:ClassesExportAction.java

示例3: generateToken

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
private JWTToken generateToken(Map<String, Object> claims, Date notBefore) {

        byte[] secret = DEFAULT_JWT_SECRET;

        if (!ArrayUtils.isEmpty(this.jwtSecret)) {
            secret = this.jwtSecret;
        }

        int sessionExpireMinutes = DEFAULT_JWT_SESSION_TIMEOUT_MINUTE;

        if (NumberUtils.isDigits(this.jwtTimeOut)) {
            sessionExpireMinutes = Integer.parseInt(this.jwtTimeOut);
        }

        LocalDateTime expiration = LocalDateTime.now().plusMinutes(sessionExpireMinutes);

        return new JWTToken(Jwts.builder()
                .setClaims(claims)
                .setNotBefore(notBefore)
                .setExpiration(Date.from(expiration.atZone(ZoneId.systemDefault()).toInstant()))
                .signWith(SignatureAlgorithm.HS512, secret)
                .compact());
    }
 
开发者ID:Crunchy-Torch,项目名称:coddy,代码行数:24,代码来源:JWTService.java

示例4: lastSampleHandle

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
@Override
protected void lastSampleHandle() throws Mp4jException {
    TMP_XIDX[count] = xindex;
    int localnum = realNum[cursor2d];
    xidx[cursor2d] = new int[localnum + 1];
    System.arraycopy(TMP_XIDX, 0, xidx[cursor2d], 0, localnum + 1);

    y[cursor2d] = new float[localnum];
    System.arraycopy(TMP_Y, 0, y[cursor2d], 0, localnum);

    weight[cursor2d] = new float[localnum];
    System.arraycopy(TMP_WEIGHT, 0, weight[cursor2d], 0, localnum);

    z[cursor2d] = new float[localnum];
    System.arraycopy(TMP_Z, 0, z[cursor2d], 0, localnum);

    predict[cursor2d] = new float[localnum];

    randMask[cursor2d] = new BitSet(localnum);

    LOG_UTILS.verboseInfo(loadingPrefix + "finished read data, cursor2d:" + cursor2d +
            ", real num:" + ArrayUtils.toString(Arrays.copyOfRange(realNum, 0, cursor2d + 1)) +
            ", weight sum:" + ArrayUtils.toString(Arrays.copyOfRange(weightNum, 0, cursor2d + 1)), false);
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:25,代码来源:GBMLRDataFlow.java

示例5: Version

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
public Version(String version) {
  Objects.requireNonNull(version);

  String[] versions = version.split("\\.", -1);
  if (versions.length > 3) {
    throw new IllegalStateException(String.format("Invalid version \"%s\".", version));
  }

  if (versions.length < 3) {
    versions = (String[]) ArrayUtils.addAll(versions, ZERO);
  }
  this.major = parseNumber("major", version, versions[0]);
  this.minor = parseNumber("minor", version, versions[1]);
  this.patch = parseNumber("patch", version, versions[2]);

  this.version = combineStringVersion();
  this.numberVersion = combineVersion();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:Version.java

示例6: getStartSelection

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
/**
 * Creates an example index start selection for each numerical attribute, or if there is none,
 * only one.
 *
 * @return a map containing for each numerical attribute an example index array such that the
 *         associated attribute values are in ascending order.
 */
public Map<Integer, int[]> getStartSelection() {
	Map<Integer, int[]> selection = new HashMap<>();
	if (columnTable.getNumberOfRegularNumericalAttributes() == 0) {
		selection.put(0, createFullArray(columnTable.getNumberOfExamples()));
	} else {
		Integer[] bigSelectionArray = createFullBigArray(columnTable.getNumberOfExamples());
		for (int j = columnTable.getNumberOfRegularNominalAttributes(); j < columnTable
				.getTotalNumberOfRegularAttributes(); j++) {
			final double[] attributeColumn = columnTable.getNumericalAttributeColumn(j);
			Integer[] startSelection = Arrays.copyOf(bigSelectionArray, bigSelectionArray.length);
			Arrays.sort(startSelection, new Comparator<Integer>() {

				@Override
				public int compare(Integer a, Integer b) {
					return Double.compare(attributeColumn[a], attributeColumn[b]);
				}
			});
			selection.put(j, ArrayUtils.toPrimitive(startSelection));
		}
	}
	return selection;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:30,代码来源:SelectionCreator.java

示例7: registerDependency

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
public static void registerDependency(BeanDefinitionRegistry registry, String beanName, String[] propertyNames) {
    if (ArrayUtils.isEmpty(propertyNames)) {
        return;
    }
    String dependencyBeanName = beanName + ".dependency";
    BeanDefinitionBuilder meta = BeanDefinitionBuilder.genericBeanDefinition(RefreshBeanDependencyFactoryBean.class);
    meta.addPropertyValue("beanName", beanName);
    meta.addPropertyValue("propertyNames", propertyNames);
    registry.registerBeanDefinition(dependencyBeanName, meta.getBeanDefinition());
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:11,代码来源:DependencyConfigUtils.java

示例8: getPrediction

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
public double getPrediction(List<Double> data){
    //Predict a simple value
    //pred[i]= SMA[i-1]+(O[i-2]-SMA[i-2])
    double pred=0.0;

    double[] dObs=ArrayUtils.toPrimitive(data.toArray(new Double[data.size()]));
    List<Double> SMA_data = getWMA((List) ((ArrayList) data).clone());
    double[] dSMA=ArrayUtils.toPrimitive(SMA_data.toArray(new Double[SMA_data.size()]));

    int i = data.size()-1;
    if(i>2){
        pred=dSMA[i]+(dObs[i-1]-dSMA[i-1]);
        //System.out.println("pred: "+pred+"dSMA[i-1]:" + dSMA[i-1]+" + (dObs[i-2]"+dObs[i-2]+"-dSMA[i-2]): "+dSMA[i-2]+")");
    }
    else{
        pred= 0;
    }
    return pred;
}
 
开发者ID:borjalor,项目名称:DroidSentinel,代码行数:20,代码来源:WeightedMovingAverage.java

示例9: pickRandomFromArray

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
/**
 * picks randomly non-repeating some elements from a source array and not in
 * another array. For example, pickRandomFromArray(new int[] {1,2,3,4,5,6},
 * new int[] {2,6}, 2) returns {1,5}.
 * 
 * @param srcArray
 *            the source array where elements will be picked from.
 * @param excludedArray
 *            the array containing elements that must not be picked.
 * @param nPick
 *            number of array to be picked.
 * @sRandom a random object generating controlled random numbers.
 * @return a subset of the source array that have no elements as specified
 *         in the excludedArray.
 */
public static int[] pickRandomFromArray(int[] srcArray, int[] excludedArray,
		int nPick, Random sRandom) {
	if (nPick <= 0 || srcArray == null || srcArray.length == 0) {
		return null;
       }
	int[] excluded = excludedArray;
	int[] finArr = new int[nPick];
	int[] remained = getNonCommonInArrays(srcArray,excluded);
	if (remained.length < nPick) {
		finArr = null;
       } else {
		for (int i = 0; i <= nPick - 1; i++) {
			if (remained.length == 1) {
				finArr[i] = remained[0];
               } else {
				//finArr[i] = remained[sRandom.nextInt(remained.length - 1)];
               	finArr[i] = remained[sRandom.nextInt(remained.length)];
               }
			excluded = ArrayUtils.add(excluded, finArr[i]);
			remained = getNonCommonInArrays(srcArray, excluded);
		}
	}
	return finArr;
}
 
开发者ID:smart-facility,项目名称:calendar-based-microsim,代码行数:40,代码来源:ArrayHandler.java

示例10: getNumTandemRepeatUnits

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
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.
     */

    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<>(repetitionCount, repeatUnit);

}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:27,代码来源:GATKVariantContextUtils.java

示例11: generateMatrix

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
private Map<ControlMetricType, Long[]> generateMatrix(ControlPlaneMonitorService cpms,
                                                      ClusterService cs, DeviceId deviceId) {
    Map<ControlMetricType, Long[]> data = Maps.newHashMap();
    for (ControlMetricType cmt : CONTROL_MESSAGE_METRICS) {
        ControlLoadSnapshot cls = cpms.getLoadSync(cs.getLocalNode().id(),
                cmt, NUM_OF_DATA_POINTS, TimeUnit.MINUTES, Optional.of(deviceId));

        // TODO: in some cases, the number of returned data set is
        // less than what we expected (expected -1)
        // As a workaround, we simply fill the slot with 0 values,
        // such a bug should be fixed with updated RRD4J lib...
        data.put(cmt, ArrayUtils.toObject(fillData(cls.recent(), NUM_OF_DATA_POINTS)));
        timestamp = cls.time();
    }
    return data;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:CpmanViewMessageHandler.java

示例12: getAllPredictions

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
public List<Double> getAllPredictions(List<Double> data, int T){
    //returns all the predictions for a time serie
    //this is expensive, but helps in testing
    double[] dObs=ArrayUtils.toPrimitive(data.toArray(new Double[data.size()]));
    double[] sol= new double[data.size()+T];
    for(int i=0;i<data.size();i++){
        List<Double> subList = new ArrayList<Double>(data.subList(0, i));
        if(i<T){
            sol[i]=dObs[i];
            sol[i+T]=getPrediction(subList);
        }
        else{
            sol[i+T]=getPrediction(subList);
        }
    }//for

    List<Double> auxSOl=convertDoubletoArrayList(sol);
    return auxSOl;
}
 
开发者ID:borjalor,项目名称:DroidSentinel,代码行数:20,代码来源:WeightedMovingAverage.java

示例13: register

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
/**
 * <p>
 * 保存画面的内容
 * </p>
 * 
 * @return
 * @throws Exception
 */
public String register() {
    logger.debug("register start.");
    if (ArrayUtils.contains(YiDuConstants.ALLOW_SAMPLE_TYPES, getSampleContentType())) {
        try {
            // saveArticlespic();
        } catch (Exception e) {
            addActionError(getText("errors.file.save"));
            return FREEMARKER;
        }
    } else {
        addActionError(getText("errors.file.type"));
        return FREEMARKER;
    }

    addActionMessage(getText("messages.save.success"));
    logger.debug("register normally end.");
    return FREEMARKER;
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:27,代码来源:RegiAuthorAction.java

示例14: invokeExactMethod

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
/**
 * <p>Invoke a method whose parameter types match exactly the parameter
 * types given.</p>
 *
 * <p>This uses reflection to invoke the method obtained from a call to
 * <code>getAccessibleMethod()</code>.</p>
 *
 * @param object invoke method on this object
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the
 *  method invoked
 * @throws IllegalAccessException if the requested method is not accessible
 *  via reflection
 */
public static Object invokeExactMethod(Object object, String methodName,
        Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Method method = getAccessibleMethod(object.getClass(), methodName,
            parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException("No such accessible method: "
                + methodName + "() on object: "
                + object.getClass().getName());
    }
    return method.invoke(object, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:MethodUtils.java

示例15: createAdmin

import org.apache.commons.lang.ArrayUtils; //导入依赖的package包/类
private void createAdmin() {
    if (StringUtils.isEmpty(adminUsername) && ArrayUtils.isEmpty(adminPassword) && StringUtils.isEmpty(adminEmail)) {
        return;
    }

    LOGGER.info("create admin user if exists");
    if (!service.exists(adminUsername)) {
        List<String> permissions = new ArrayList<>();
        permissions.add(Permission.PERSO_ACCOUNT);
        permissions.add(Permission.PERSO_SNIPPET);
        permissions.add(Permission.ADMIN);
        service.create(new UpdateUser(adminUsername, adminPassword, adminEmail), permissions);
    }
}
 
开发者ID:Crunchy-Torch,项目名称:coddy,代码行数:15,代码来源:AdminCreationOnStartup.java


注:本文中的org.apache.commons.lang.ArrayUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。