當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。