Java Code Examples for org.apache.commons.lang3.ArrayUtils.addAll()

The following are Jave code examples for showing how to use addAll() of the org.apache.commons.lang3.ArrayUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OfficeAutomation   File: RowConvert.java   View Source Code Vote up 6 votes
public static <T> T convertWithConstructor(Row row, Class<T> clazz) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ParseException {
    Field[] fields = new Field[]{};
    Class temp = clazz;
    while(temp != null){
        fields = ArrayUtils.addAll(temp.getDeclaredFields(), fields);
        temp = temp.getSuperclass();
    }

    Class<?>[] params = new Class[fields.length];
    Object[] paramValues = new Object[fields.length];

    for (Field field : fields) {
        ExcelCellField filedExcelAnnotation = getAnnotationCellFiled(field.getAnnotations());
        if (filedExcelAnnotation == null) {
            continue;
        }
        Integer index = filedExcelAnnotation.index();
        Class<?> fieldType = field.getType();
        params[index] = fieldType;
        paramValues[index] = getValue(fieldType, row.getCell(index), filedExcelAnnotation);
    }
    Constructor<?> constructor = clazz.getDeclaredConstructor(params);
    return (T) constructor.newInstance(paramValues);
}
 
Example 2
Project: OfficeAutomation   File: RowConvert.java   View Source Code Vote up 6 votes
private static <T> T convertWithMethod(Row row, Class<T> clazz) throws IllegalAccessException, InstantiationException, ParseException, InvocationTargetException {
    Field[] fields = new Field[]{};
    Class temp = clazz;
    while(temp != null){
        fields = ArrayUtils.addAll(temp.getDeclaredFields(),fields);
        temp = temp.getSuperclass();
    }
    Object object = clazz.newInstance();
    for (Field field : fields) {
        ExcelCellField filedExcelAnnotation = getAnnotationCellFiled(field.getAnnotations());
        if (filedExcelAnnotation == null) {
            continue;
        }
        Class<?> fieldType = field.getType();
        Integer index = filedExcelAnnotation.index();
        String propertyName = field.getName();
        Object value = getValue(fieldType, row.getCell(index), filedExcelAnnotation);
        if (value != null) {
            BeanUtils.setProperty(object, propertyName, value);
        }
    }
    return (T) object;
}
 
Example 3
Project: minlia-iot   File: XmlSignatureAnnotationHelper.java   View Source Code Vote up 6 votes
/**
 * 处理单个实体
 *
 * @param entity 实体对象
 * @param list SinpleField的列表
 * @param signField 签名字段
 */
private static void dealSinpleEntity(Object entity, List<FieldPaired> list, Field signField,
    SignatureAlgorithmic algorithmic, String saltParameterPrefix, String charset) {
  Field[] fields = ArrayUtils.addAll(entity.getClass().getSuperclass().getDeclaredFields(),
      entity.getClass().getDeclaredFields());
  for (Field field : fields) {
    if (field.equals(signField)) {
      continue;
    }
    field.setAccessible(true);
    try {
      if (field.isAnnotationPresent(XmlElement.class)) {
        Object value = field.get(entity);
        if (value == null) {
          continue;
        }
        list.add(new FieldPaired(field.getAnnotation(XmlElement.class).name(), value));
      } else if (field.isAnnotationPresent(ApiRequestEntity.class)) {
        Object nextEntity = field.get(entity);
        dealSinpleEntity(nextEntity, list, signField, algorithmic, saltParameterPrefix, charset);
      }
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
  }
}
 
Example 4
Project: otf2ttf   File: CTQ.java   View Source Code Vote up 6 votes
public double[][] getSplitAtXY(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
		double y4, Double splitAtX, Double splitAtY) {
	double ax = 3 * (-x1 + 3 * x2 - 3 * x3 + x4);
	double bx = 6 * (x1 - 2 * x2 + x3);
	double cx = 3 * (x2 - x1);
	double ay = 3 * (-y1 + 3 * y2 - 3 * y3 + y4);
	double by = 6 * (y1 - 2 * y2 + y3);
	double cy = 3 * (y2 - y1);
	double[] ts = new double[] {};
	if (splitAtX != null) {
		ts = ArrayUtils.addAll(ts, quadSolve(ax, bx, cx));
	}
	if (splitAtY != null) {
		ts = ArrayUtils.addAll(ts, quadSolve(ay, by, cy));
	}
	Double[] temp = Stream.of(ArrayUtils.toObject(ts)).filter(t -> (t > 0.001 && t < 0.999)).toArray(Double[]::new);
	Arrays.sort(temp, new Comparator<Double>() {
		@Override
		public int compare(Double o1, Double o2) {
			return (int) substraction(o1, o2);
		}
	});
	return splitAtTs(x1, y1, x2, y2, x3, y3, x4, y4, ArrayUtils.toPrimitive(temp));
}
 
Example 5
Project: SparkSeq   File: BaseGraph.java   View Source Code Vote up 6 votes
/**
 * Walk along the reference path in the graph and pull out the corresponding bases
 * @param fromVertex    starting vertex
 * @param toVertex      ending vertex
 * @param includeStart  should the starting vertex be included in the path
 * @param includeStop   should the ending vertex be included in the path
 * @return              byte[] array holding the reference bases, this can be null if there are no nodes between the starting and ending vertex (insertions for example)
 */
public byte[] getReferenceBytes( final V fromVertex, final V toVertex, final boolean includeStart, final boolean includeStop ) {
    if( fromVertex == null ) { throw new IllegalArgumentException("Starting vertex in requested path cannot be null."); }
    if( toVertex == null ) { throw  new IllegalArgumentException("From vertex in requested path cannot be null."); }

    byte[] bytes = null;
    V v = fromVertex;
    if( includeStart ) {
        bytes = ArrayUtils.addAll(bytes, getAdditionalSequence(v));
    }
    v = getNextReferenceVertex(v); // advance along the reference path
    while( v != null && !v.equals(toVertex) ) {
        bytes = ArrayUtils.addAll(bytes, getAdditionalSequence(v));
        v = getNextReferenceVertex(v); // advance along the reference path
    }
    if( includeStop && v != null && v.equals(toVertex)) {
        bytes = ArrayUtils.addAll(bytes, getAdditionalSequence(v));
    }
    return bytes;
}
 
Example 6
Project: BaseClient   File: GameSettings.java   View Source Code Vote up 5 votes
public GameSettings()
{
    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;
}
 
Example 7
Project: Backmemed   File: GameSettings.java   View Source Code Vote up 5 votes
public GameSettings(Minecraft mcIn, File optionsFileIn)
{
    this.setForgeKeybindProperties();
    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.keyBindFullscreen, this.keyBindSpectatorOutlines, this.keyBindSwapHands}, this.keyBindsHotbar));
    this.difficulty = EnumDifficulty.NORMAL;
    this.lastServer = "";
    this.fovSetting = 70.0F;
    this.language = "en_us";
    this.mc = mcIn;
    this.optionsFile = new File(optionsFileIn, "options.txt");

    if (mcIn.isJava64bit() && Runtime.getRuntime().maxMemory() >= 1000000000L)
    {
        GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
    }
    else
    {
        GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F);
    }

    this.renderDistanceChunks = mcIn.isJava64bit() ? 12 : 8;
    this.optionsFileOF = new File(optionsFileIn, "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);
}
 
Example 8
Project: xtf   File: OpenShiftBinaryClient.java   View Source Code Vote up 5 votes
/**
 * Executes oc command and returns a String
 *
 * @param args command arguments
 * @return Process encapsulating started oc
 */
public String executeCommandWithReturn(final String error, String... args) {
	String[] ocArgs = (String[]) ArrayUtils.addAll(new String[] {ocBinaryPath, "--config=" + CONFIG_FILE.getAbsolutePath()}, args);
	try {
		final Process process = executeLocalCommand(error, false, true, false,
				ocArgs);
		try (final InputStream is = process.getInputStream();
				final StringWriter sw = new StringWriter()) {
			org.apache.commons.io.IOUtils.copy(is, sw);
			return sw.toString();
		}
	} catch (IOException | InterruptedException ex) {
		throw new IllegalArgumentException(error, ex);
	}
}
 
Example 9
Project: DecompiledMinecraft   File: GameSettings.java   View Source Code Vote up 5 votes
public GameSettings()
{
    this.keyBindings = (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;
}
 
Example 10
Project: jblockchain   File: Block.java   View Source Code Vote up 5 votes
/**
 * Calculates the hash using relevant fields of this type
 * @return SHA256-hash as raw bytes
 */
public byte[] calculateHash() {
    byte[] hashableData = ArrayUtils.addAll(previousBlockHash, merkleRoot);
    hashableData = ArrayUtils.addAll(hashableData, Longs.toByteArray(tries));
    hashableData = ArrayUtils.addAll(hashableData, Longs.toByteArray(timestamp));
    return DigestUtils.sha256(hashableData);
}
 
Example 11
Project: jblockchain   File: Block.java   View Source Code Vote up 5 votes
/**
 * Calculates the Hash of all transactions as hash tree.
 * https://en.wikipedia.org/wiki/Merkle_tree
 * @return SHA256-hash as raw bytes
 */
public byte[] calculateMerkleRoot() {
    Queue<byte[]> hashQueue = new LinkedList<>(transactions.stream().map(Transaction::getHash).collect(Collectors.toList()));
    while (hashQueue.size() > 1) {
        // take 2 hashes from queue
        byte[] hashableData = ArrayUtils.addAll(hashQueue.poll(), hashQueue.poll());
        // put new hash at end of queue
        hashQueue.add(DigestUtils.sha256(hashableData));
    }
    return hashQueue.poll();
}
 
Example 12
Project: otf2ttf   File: CTQ.java   View Source Code Vote up 5 votes
public Contour[] canonicalStart(Contour[] points) {
	int jm = 0;
	for (int j = 1; j < points.length; j++) {
		if (points[j].x < points[jm].x || (points[j].x == points[jm].x && points[j].y < points[jm].y)) {
			jm = j;
		}
	}
	Contour[] result = ArrayUtils.addAll(Arrays.copyOfRange(points, jm, points.length),
			Arrays.copyOfRange(points, 0, jm));
	ArrayUtils.reverse(result);
	return result;
}
 
Example 13
Project: hashsdn-controller   File: LLDPTest.java   View Source Code Vote up 5 votes
private static byte[] awaitedBytes(final byte typeTLV, final short length, final byte[] value, final byte[] bytesBeforeValue) {
    byte[] awaited = ArrayUtils.EMPTY_BYTE_ARRAY;

    // 0 - the less meaning byte (right), 1 most meaning byte (left)
    byte lengthByte0 = (byte) length;
    byte lengthByte1 = (byte) (length >> 8);

    awaited = ArrayUtils.addAll(awaited, (byte) (typeTLV | lengthByte1), lengthByte0);
    awaited = ArrayUtils.addAll(awaited, bytesBeforeValue);
    awaited = ArrayUtils.addAll(awaited, value);
    return awaited;
}
 
Example 14
Project: hashsdn-controller   File: LLDPTest.java   View Source Code Vote up 5 votes
private static LLDPTLV dummyCustomTlv(final byte tlvType, final byte[] oui, final byte[] ouiSubtype, final short customLength,
        final byte[] subtypeValue) {
    byte[] fullCustomValue = new byte[0];
    fullCustomValue = ArrayUtils.addAll(fullCustomValue, oui);
    fullCustomValue = ArrayUtils.addAll(fullCustomValue, ouiSubtype);
    fullCustomValue = ArrayUtils.addAll(fullCustomValue, subtypeValue);
    return dummyTlv(tlvType, customLength, fullCustomValue);
}
 
Example 15
Project: convertigo-engine   File: UIControlEvent.java   View Source Code Vote up 5 votes
@Override
public String[] getTagsForProperty(String propertyName) {
	if (propertyName.equals("eventName")) {
		String[] attrEvents = EnumUtils.toNames(AttrEvent.class);
		if (parent != null && parent instanceof UIDynamicElement) {
			String[] eventNames = ((UIDynamicElement)parent).getEventNames();
    		if (eventNames.length > 0) {
    			eventNames = ArrayUtils.add(eventNames, "");
    		}
			return ArrayUtils.addAll(eventNames, attrEvents);
		}
		return attrEvents;
	}
	return new String[0];
}
 
Example 16
Project: froog   File: Feedforward.java   View Source Code Vote up 5 votes
/**
 *
 * @return B1, B2, ...,Bm
 */
public SimpleMatrix getParamsB() {
    if (layers.isEmpty()) {
        System.err.println("Inicialice los pesos primero");
        return null;
    }
    double[] aux = new double[0];
    for (int i = 0; i < layers.size(); i++) {
        aux = ArrayUtils.addAll(aux, layers.get(i).getB().getMatrix().getData());
    }
    return new SimpleMatrix(1, aux.length, true, aux);
}
 
Example 17
Project: xtf   File: OpenShiftBinaryClient.java   View Source Code Vote up 5 votes
/**
 * Executes oc command and returns Process
 *
 * @param args command arguments
 * @return Process encapsulating started oc
 */
public Process executeCommandNoWait(final String error, String... args) {
	String[] ocArgs = ArrayUtils.addAll(new String[] {ocBinaryPath, "--config=" + CONFIG_FILE.getAbsolutePath()}, args);
	try {
		return executeLocalCommand(error, false, false, false, ocArgs);
	} catch (IOException | InterruptedException ex) {
		throw new IllegalArgumentException(error, ex);
	}
}
 
Example 18
Project: BaseClient   File: GameSettings.java   View Source Code Vote up 5 votes
public GameSettings()
{
    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;
}
 
Example 19
Project: smart-id-java-client   File: AuthenticationResponseValidator.java   View Source Code Vote up 4 votes
private static byte[] addPadding(byte[] digestInfoPrefix, byte[] digest) {
  return ArrayUtils.addAll(digestInfoPrefix, digest);
}
 
Example 20
Project: plugin-prov   File: TerraformUtils.java   View Source Code Vote up 4 votes
/**
 * A new {@link ProcessBuilder} with the given arguments
 */
protected ProcessBuilder newBuilder(String... args) {
	return new ProcessBuilder(ArrayUtils.addAll(TERRAFORM_COMMAND,
			configuration.get(TERRAFORM_PATH, "terraform") + " " + StringUtils.join(ArrayUtils.addAll(args), ' ')));
}