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


Java ArrayUtils类代码示例

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


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

示例1: setPropertyValue

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
public boolean setPropertyValue(String propVal)
{
    if (propVal == null)
    {
        this.value = this.defaultValue;
        return false;
    }
    else
    {
        this.value = ArrayUtils.indexOf(this.propertyValues, propVal);

        if (this.value >= 0 && this.value < this.propertyValues.length)
        {
            return true;
        }
        else
        {
            this.value = this.defaultValue;
            return false;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:Property.java

示例2: deletecols

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/**
 * deletes all selected columns if it is not present in the <code>exp</code>
 * List
 *
 * @param table the table to DELETE columns
 * @param exp columns to avoid deleting
 * @see #deletecol(javax.swing.JTable, int)
 */
static void deletecols(JTable table, int[] exp) {
    Integer[] selcols;
    try {
        TableColumnModel tcm = table.getColumnModel();
        selcols = ArrayUtils.toObject(table.getSelectedColumns());
        Arrays.sort(selcols, Collections.reverseOrder());
        List<Integer> explist = Ints.asList(exp);
        for (int i : selcols) {
            if (!explist.contains(i)) {
                tcm.removeColumn(tcm.getColumn(i));
            }
        }

    } catch (Exception e) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, e);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:27,代码来源:JtableUtils.java

示例3: handle

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
@Override
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, IDebugAdapterContext context) {
    if (context.getDebugSession() == null) {
        return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.EMPTY_DEBUG_SESSION, "Empty debug session.");
    }

    String[] filters = ((SetExceptionBreakpointsArguments) arguments).filters;
    try {
        boolean notifyCaught = ArrayUtils.contains(filters, Types.ExceptionBreakpointFilter.CAUGHT_EXCEPTION_FILTER_NAME);
        boolean notifyUncaught = ArrayUtils.contains(filters, Types.ExceptionBreakpointFilter.UNCAUGHT_EXCEPTION_FILTER_NAME);

        context.getDebugSession().setExceptionBreakpoints(notifyCaught, notifyUncaught);
        return CompletableFuture.completedFuture(response);
    } catch (Exception ex) {
        return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.SET_EXCEPTIONBREAKPOINT_FAILURE,
                String.format("Failed to setExceptionBreakpoints. Reason: '%s'", ex.toString()));
    }
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:19,代码来源:SetExceptionBreakpointsRequestHandler.java

示例4: fixAdditionalKeyBindings

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/** Call this to finalise any additional key bindings we want to create in the mod.
 * @param settings Minecraft's original GameSettings object which we are appending to.
 */
private void fixAdditionalKeyBindings(GameSettings settings)
{
    if (this.additionalKeys == null)
    {
        return; // No extra keybindings to add.
    }

    // The keybindings are stored in GameSettings as a java built-in array.
    // There is no way to append to such arrays, so instead we create a new
    // array of the correct
    // length, copy across the current keybindings, add our own ones, and
    // set the new array back
    // into the GameSettings:
    KeyBinding[] bindings = (KeyBinding[]) ArrayUtils.addAll(settings.keyBindings, this.additionalKeys.toArray());
    settings.keyBindings = bindings;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:20,代码来源:KeyManager.java

示例5: getDefinitionByClass

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
private Definition getDefinitionByClass(Class<?> cls, String className, Definition rootDefinition)
        throws ParserException {

    Field[] fields = cls.getDeclaredFields();

    // if cls is enum, remove the values field
    if (cls.isEnum()) {
        for (int i = fields.length - 1; i >= 0; i--) {
            if (!fields[i].isEnumConstant()) {
                fields = ArrayUtils.removeElement(fields, fields[i]);
                break;
            }
        }
    }

    Definition definition = new Definition();
    definition.setClassName(className);
    if (rootDefinition == null) {
        rootDefinition = definition;
    }
    List<Property> properties = processFields(fields, definition, rootDefinition);
    definition.setProperties(properties);
    return definition;
}
 
开发者ID:SPIRIT-21,项目名称:javadoc2swagger,代码行数:25,代码来源:DefinitionParser.java

示例6: GameSettings

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
public GameSettings(Minecraft mcIn, File p_i46326_2_)
{
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar));
    this.difficulty = EnumDifficulty.NORMAL;
    this.lastServer = "";
    this.fovSetting = 70.0F;
    this.language = "en_US";
    this.forceUnicodeFont = false;
    this.mc = mcIn;
    this.optionsFile = new File(p_i46326_2_, "options.txt");
    this.optionsFileOF = new File(p_i46326_2_, "optionsof.txt");
    this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax();
    this.ofKeyBindZoom = new KeyBinding("of.key.zoom", 46, "key.categories.misc");
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom));
    GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
    this.renderDistanceChunks = 8;
    this.loadOptions();
    Config.initGameSettings(this);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:GameSettings.java

示例7: getMessage

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
public static String getMessage(CodeTemp templ, String... params) {
	String regContent = templ.getTemp();
	int index = 0;
	while (regContent.indexOf("{}") >= 0) {
		if (ArrayUtils.isEmpty(params) || params.length <= index) {
			if (regContent.indexOf("{}") >= 0) {
				regContent = regContent.replaceAll("\\{\\}", "");
			}
			break;
		}
		regContent = StringUtils.replaceOnce(regContent, "{}", params[index]);
		index++;
	}

	return regContent;
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:17,代码来源:ErrorHolder.java

示例8: reload

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
public void reload() throws IOException {
    mappings.clear();
    ZipFile zipfile = new ZipFile(zip);

    try {
        for (MappingType type : MappingType.values()) {
            if (type.getCsvName() != null) {
                List<String> lines;
                lines = IOUtils.readLines(zipfile.getInputStream(zipfile.getEntry(type.getCsvName() + ".csv")), Charsets.UTF_8);

                lines.remove(0); // Remove header line

                for (String line : lines) {
                    String[] info = line.split(",", -1);
                    String comment = info.length > 3 ? Joiner.on(',').join(ArrayUtils.subarray(info, 3, info.length)) : "";
                    IMapping mapping = new IMapping.Impl(type, info[0], info[1], comment, Side.values()[Integer.valueOf(info[2])]);
                    mappings.put(type, mapping);
                }
            }
        }
    } finally {
        zipfile.close();
    }
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:25,代码来源:MappingDatabase.java

示例9: testIncludeOnClassLevel

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
@Test
public void testIncludeOnClassLevel() throws NoSuchMethodException {

    Class<?> aClass = TestServiceIncludeOnClass.class;

    when(signature.getMethod()).thenReturn(aClass.getMethod("method1",
                                                            Object.class,
                                                            String.class,
                                                            int.class));
    when(signature.getDeclaringType()).thenReturn(aClass);

    Optional<LoggingAspectConfig> conf = AopAnnotationUtils.getConfigAnnotation(joinPoint);
    assertTrue(conf.isPresent());
    assertArrayEquals(ArrayUtils.toArray("param1", "param3"), conf.get().inputIncludeParams());
    assertArrayEquals(new String[]{}, conf.get().inputExcludeParams());

}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:18,代码来源:AopAnnotationUtilUnitTest.java

示例10: readDict

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/**
 * Reads a bencoded <code>Map</code> (dict in the specification) from the
 * <code>InputStream</code>. The <code>Map</code> may contain lists and maps
 * itself.
 *
 * @since 0.1.0
 * @exception IOException if an IO exception occurs when reading
 * @exception EOFException if the stream ended unexpectedly
 * @exception BencodeReadException if the value read is not a properly bencoded Map
 */
public Map<String, Object> readDict() throws IOException, BencodeReadException {
    int initial = forceRead();
    if (initial != 'd') {
        throw new BencodeReadException("Bencoded dict must start with 'd', not '%c'",
                                       initial);
    }
    LinkedHashMap<String, Object> hm = new LinkedHashMap<String, Object>();
    while (peek() != 'e') {
        String key =  new String(ArrayUtils.toPrimitive(readString()), StandardCharsets.UTF_8);
        Object val = read();
        if (val == null) {
            throw new EOFException();
        }
        hm.put(key, val);
    }
    forceRead(); // read 'e' that we peeked
    return hm;
}
 
开发者ID:jc0541,项目名称:URTorrent,代码行数:29,代码来源:BencodeReader.java

示例11: serialize

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
public JsonElement serialize(LootPool p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.add("entries", p_serialize_3_.serialize(p_serialize_1_.lootEntries));
    jsonobject.add("rolls", p_serialize_3_.serialize(p_serialize_1_.rolls));

    if (p_serialize_1_.bonusRolls.getMin() != 0.0F && p_serialize_1_.bonusRolls.getMax() != 0.0F)
    {
        jsonobject.add("bonus_rolls", p_serialize_3_.serialize(p_serialize_1_.bonusRolls));
    }

    if (!ArrayUtils.isEmpty((Object[])p_serialize_1_.poolConditions))
    {
        jsonobject.add("conditions", p_serialize_3_.serialize(p_serialize_1_.poolConditions));
    }

    return jsonobject;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:LootPool.java

示例12: undoLocalSourceExecute

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/**
 * Performs the undo of LSM operation on the source shard.
 *
 * @param ts
 *            Transaction scope.
 * @return Result of the operation.
 */
@Override
public StoreResults undoLocalSourceExecute(IStoreTransactionScope ts) {
    StoreMapping sourceLeft = mappingsSource.get(0).getLeft();
    StoreMapping targetLeft = mappingsTarget.get(0).getLeft();

    StoreShard dssOriginal = new StoreShard(sourceLeft.getStoreShard().getId(), this.getOriginalShardVersionAdds(), sourceLeft.getShardMapId(),
            sourceLeft.getStoreShard().getLocation(), sourceLeft.getStoreShard().getStatus());

    StoreMapping dsmSource = new StoreMapping(sourceLeft.getId(), sourceLeft.getShardMapId(), sourceLeft.getMinValue(), sourceLeft.getMaxValue(),
            sourceLeft.getStatus(), mappingsSource.get(0).getRight(), dssOriginal);

    StoreMapping dsmTarget = new StoreMapping(targetLeft.getId(), targetLeft.getShardMapId(), targetLeft.getMinValue(), targetLeft.getMaxValue(),
            targetLeft.getStatus(), mappingsTarget.get(0).getRight(), dssOriginal);

    StoreMapping[] ms = new StoreMapping[] {dsmSource};
    StoreMapping[] mt = new StoreMapping[] {dsmTarget};

    return ts.executeOperation(StoreOperationRequestBuilder.SP_BULK_OPERATION_SHARD_MAPPINGS_LOCAL,
            StoreOperationRequestBuilder.replaceShardMappingsLocal(this.getId(), true, shardMap,
                    (StoreMapping[]) ArrayUtils.addAll(mt, mappingsTarget.stream().skip(1).map(Pair::getLeft).toArray()),
                    (StoreMapping[]) ArrayUtils.addAll(ms, mappingsSource.stream().skip(1).map(Pair::getLeft).toArray())));
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:30,代码来源:ReplaceMappingsOperation.java

示例13: convertChunk

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/**
 * Convert chunks get from Redis.
 * Make a zero-filled array if failed to read chunk from Redis.
 *
 * @param redisDataArray chunks get from all Redis nodes
 * @param chunkSize length of chunk data
 * @return pair of chunks and erasures array
 */
static Pair<byte[][], int[]> convertChunk(byte[][] redisDataArray, int chunkSize) {
  Validate.isTrue(ArrayUtils.isNotEmpty(redisDataArray));

  List<Integer> erasures = new ArrayList<Integer>();

  int i = 0;
  for (byte[] chunk : redisDataArray) {
    // can not read chunk data from redis
    // make a zero-filled array for ec decode
    if (ArrayUtils.isEmpty(chunk) || chunk.length != chunkSize) {
      chunk = new byte[chunkSize];
      erasures.add(i);
    }
    redisDataArray[i++] = chunk;
  }
  return Pair.create(redisDataArray, adjustErasures(erasures, redisDataArray.length));
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:26,代码来源:RedisAccessBase.java

示例14: export

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
/**
 * export excel with year and quarter
 * @param baseSearchDto
 * @param excelPath
 * @param exportName
 * @param data
 * @param dataCls
 * @param templateCls
 * @param pictureArea
 * @param hasYear
 * @param hasQuarter
 * @return {@code Optional<InputStream>}
 * @throws IOException
 */
public static <T> Optional<InputStream> export(final BaseSearchDto baseSearchDto,final String excelPath,final String exportName,final List<T> data,final Class<T> dataCls,final Class<?> templateCls,final int[] pictureArea,boolean hasYear,boolean hasQuarter) throws IOException{
	Objects.requireNonNull(baseSearchDto, "baseSearchDto must not be null!");
	Builder<T> builder=new ExcelExportService.Builder<T>(excelPath,exportName,data,dataCls);
	String svg=Objects.requireNonNull(baseSearchDto.getSvgString(), "baseSearchDto svg string must not be null!");
	builder.setSvg(svg);
	List<String> _titles=baseSearchDto.getTitles();
	if(!CollectionUtils.isEmpty(_titles)){
		builder.setTitles(_titles);
	}
	if(hasYear){
		Integer _year=Objects.requireNonNull(baseSearchDto.getYear(), "baseSearchDto year must not be null!");
		builder.setYear(_year.toString());
	}
	if(hasQuarter){
		Integer _quarter=Objects.requireNonNull(baseSearchDto.getQuarter(), "baseSearchDto quarter must not be null!");
		builder.setQuarter(_quarter.toString());
	}
	org.springframework.util.Assert.isTrue(!ArrayUtils.isEmpty(pictureArea),"picture area have not been specified!");
	builder.setPictureStartCol(pictureArea[0]);
	builder.setPictureEndCol(pictureArea[1]);
	builder.setPictureStartRow(pictureArea[2]);
	builder.setPictureEndRow(pictureArea[3]);
	ExportBuilder exportBuilder=builder.build();
	return Optional.of(exportBuilder.writeStreamFromTemplate(templateCls));
}
 
开发者ID:gp15237125756,项目名称:PoiExcelExport2.0,代码行数:40,代码来源:PoiExportFacade.java

示例15: parseCol

import org.apache.commons.lang3.ArrayUtils; //导入依赖的package包/类
private int[] parseCol(String colConf, Set<Integer> existCols, Map<String, Integer> fName2IndexMap) {
    if (colConf.equalsIgnoreCase("default")) {
        CheckUtils.check(!existCols.contains(-1), "[GBDT] feature approximate config error! default has been set twice");
        existCols.add(-1);
        return new int[]{-1};
    }

    List<Integer> colList = new ArrayList<>(16);
    String[] allCols = colConf.split(COL_SPLIT);

    for (String colField : allCols) {
        colField = colField.trim();
        CheckUtils.check(fName2IndexMap.containsKey(colField), "[GBDT] feature approximate config error! feature(%s) does not exist", colField);
        int col = fName2IndexMap.get(colField);
        CheckUtils.check(!existCols.contains(col), "[GBDT] feature approximate config error!, feature(%s) has been set twice", colField);
        colList.add(col);
        existCols.add(col);
    }
    return ArrayUtils.toPrimitive(colList.toArray(new Integer[colList.size()]));
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:21,代码来源:GBDTFeatureParams.java


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