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


Java ArrayUtils.reverse方法代码示例

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


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

示例1: decodeToBit

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
protected String decodeToBit(String data, int precision) {
  switch (data) {
    case "true":
      return "1";
    case "false":
      return "0";
  }

  StringBuilder sb = new StringBuilder();
  String oneByte;
  String result;
  byte[] decoded = Base64.decodeBase64(data);

  ArrayUtils.reverse(decoded);

  for (byte b : decoded) {
    oneByte = String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0');
    sb.append(oneByte);
  }
  result = sb.toString();

  return result.substring(result.length() - precision);
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:25,代码来源:DebeziumPipeLine.java

示例2: setTarget

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public void setTarget(final String hostname) {
    final String simple;
    final String[] parts = StringUtils.split(hostname, '.');
    if(parts.length > 4) {
        ArrayUtils.reverse(parts);
        // Rewrite c.cyberduck.s3.amazonaws.com which does not match wildcard certificate *.s3.amazonaws.com
        simple = StringUtils.join(parts[3], ".", parts[2], ".", parts[1], ".", parts[0]);
        log.warn(String.format("Rewrite hostname target to %s", simple));
    }
    else {
        simple = hostname;
    }
    super.setTarget(simple);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:LaxHostnameDelegatingTrustManager.java

示例3: calculateHash

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * return the hash, as calculated from the other parameters.
 *
 * @return the hash, as calculated from the other parameters.
 */
private UInt256 calculateHash() {
	final ByteArrayOutputStream bout = new ByteArrayOutputStream();
	NetworkUtil.write(bout, nextConsensus.toByteArray());
	NetworkUtil.write(bout, consensusData.toByteArray());
	NetworkUtil.write(bout, index.toByteArray());
	NetworkUtil.write(bout, timestamp.toByteArray());
	NetworkUtil.write(bout, merkleRoot.toByteArray());
	final byte[] prevHashBa = prevHash.toByteArray();
	ArrayUtils.reverse(prevHashBa);
	NetworkUtil.write(bout, prevHashBa);
	NetworkUtil.write(bout, version.toByteArray());
	final byte[] hashDataBa = bout.toByteArray();
	ArrayUtils.reverse(hashDataBa);
	final byte[] hashBa = SHA256HashUtil.getDoubleSHA256Hash(hashDataBa);
	return new UInt256(hashBa);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:22,代码来源:AbstractBlockBase.java

示例4: main

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static void main(String[] args)
{
	String[] array = ArrayUtils.toArray("one", "two", "three");	
	System.out.println(ArrayUtils.toString(array));
	
	array = ArrayUtils.add(array, "four");
	System.out.println(ArrayUtils.toString(array));
	
	if(ArrayUtils.contains(array,"two"))
	{
		System.out.println("found \"two\" in the array.");
	}
	
	ArrayUtils.reverse(array);
	System.out.println(ArrayUtils.toString(array));
}
 
开发者ID:teiniker,项目名称:teiniker-lectures-configurationmanagement,代码行数:17,代码来源:ArrayExample.java

示例5: canonicalStart

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:icaoweiwei,项目名称:otf2ttf,代码行数:13,代码来源:CTQ.java

示例6: toByteArray

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * return the message as a byte array.
 *
 * @return the message as a byte array.
 * @throws IOException
 *             if an error occurs.
 * @throws UnsupportedEncodingException
 *             if an error occurs.
 */
public byte[] toByteArray() throws IOException, UnsupportedEncodingException {
	final byte[] magicBa = NetworkUtil.getIntByteArray(magic);
	ArrayUtils.reverse(magicBa);
	final UInt32 magicObj = new UInt32(magicBa);
	final byte[] checksumFull = SHA256HashUtil.getDoubleSHA256Hash(payloadBa);
	final byte[] checksum = new byte[4];
	System.arraycopy(checksumFull, 0, checksum, 0, 4);
	final ByteArrayOutputStream bout = new ByteArrayOutputStream();
	bout.write(magicObj.getBytesCopy());
	NetworkUtil.writeString(bout, 12, command);

	if (LOG.isTraceEnabled()) {
		LOG.trace("createMessage magic+command {}", Hex.encodeHexString(bout.toByteArray()));
	}
	final byte[] lengthBa = NetworkUtil.getIntByteArray(payloadBa.length);
	ArrayUtils.reverse(lengthBa);
	if (LOG.isTraceEnabled()) {
		LOG.trace("createMessage lengthBa {}", Hex.encodeHexString(lengthBa));
	}
	bout.write(lengthBa);
	if (LOG.isTraceEnabled()) {
		LOG.trace("createMessage magic+command+length {}", Hex.encodeHexString(bout.toByteArray()));
		LOG.trace("createMessage checksum {}", Hex.encodeHexString(checksum));
	}
	bout.write(checksum);
	if (LOG.isTraceEnabled()) {
		LOG.trace("createMessage magic+command+length+checksum {}", Hex.encodeHexString(bout.toByteArray()));
	}
	bout.write(payloadBa);
	if (LOG.isTraceEnabled()) {
		LOG.trace("createMessage payloadBa {}", Hex.encodeHexString(payloadBa));
		LOG.trace("createMessage magic+command+length+checksum+payload {}",
				Hex.encodeHexString(bout.toByteArray()));
	}
	return bout.toByteArray();
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:46,代码来源:Message.java

示例7: toObject

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public TransactionOutput toObject(final ByteBuffer bb) {
	bb.getLong();
	final byte[] assetIdBa = ModelUtil.getVariableLengthByteArray(bb);
	final byte[] valueBa = ModelUtil.getVariableLengthByteArray(bb);
	ArrayUtils.reverse(valueBa);
	final byte[] scriptHashBa = ModelUtil.getVariableLengthByteArray(bb);

	final UInt256 assetId = new UInt256(ByteBuffer.wrap(assetIdBa));
	final Fixed8 value = new Fixed8(ByteBuffer.wrap(valueBa));
	final UInt160 scriptHash = new UInt160(scriptHashBa);
	final TransactionOutput transactionOutput = new TransactionOutput(assetId, value, scriptHash);
	return transactionOutput;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:15,代码来源:TransactionOutputFactory.java

示例8: toObject

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public TransactionOutput toObject(final Map<String, Object> map) {
	final byte[] assetIdBa = getBytes(map, "asset_id");
	final byte[] valueBa = getBytes(map, "value");
	ArrayUtils.reverse(valueBa);
	final byte[] scriptHashBa = getBytes(map, "script_hash");

	final UInt256 assetId = new UInt256(ByteBuffer.wrap(assetIdBa));
	final Fixed8 value = new Fixed8(ByteBuffer.wrap(valueBa));
	final UInt160 scriptHash = new UInt160(scriptHashBa);
	final TransactionOutput transactionOutput = new TransactionOutput(assetId, value, scriptHash);
	return transactionOutput;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:14,代码来源:TransactionOutputMapToObject.java

示例9: decode

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * decodes a Base58 byte array.
 *
 * @param input
 *            the base58 string to use.
 * @return the decoded byte array.
 */
public static byte[] decode(final String input) {

	BigInteger bi = BigInteger.ZERO;

	for (int ix = 0; ix < input.length(); ix++) {
		final char c = input.charAt(ix);
		final int index = ALPHABET.indexOf(c);
		if (index == -1) {
			throw new RuntimeException("invalid char:" + c);
		}

		bi = bi.multiply(BIGINT_58);
		bi = bi.add(BigInteger.valueOf(index));
	}
	final byte[] bytes = bi.toByteArray();

	final boolean stripSignByte = (bytes.length > 1) && (bytes[0] == 0) && (bytes[1] >= (byte) 0x80);

	ArrayUtils.reverse(bytes);

	final ByteArrayOutputStream bout = new ByteArrayOutputStream();
	try {
		if (stripSignByte) {
			bout.write(bytes, 0, bytes.length - 1);
		} else {
			bout.write(bytes);
		}
		for (int ix = 0; (ix < input.length()) && (input.charAt(ix) == ALPHABET.charAt(0)); ix++) {
			bout.write(new byte[1]);
		}
	} catch (final IOException e) {
		throw new RuntimeException(e);
	}

	final byte[] ba = bout.toByteArray();
	return ba;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:45,代码来源:Base58Util.java

示例10: toAddress

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * coverts a scriptHash to an address.
 *
 * @param scriptHash
 *            the scriptHash to use.
 * @return the address.
 */
public static String toAddress(final UInt160 scriptHash) {
	final byte[] data = new byte[21];

	if (LOG.isTraceEnabled()) {
		LOG.trace("toAddress ADDRESS_VERSION {}", ModelUtil.toHexString(ADDRESS_VERSION));
	}

	final byte[] scriptHashBa = scriptHash.toByteArray();
	System.arraycopy(scriptHashBa, 0, data, 0, scriptHashBa.length);

	data[data.length - 1] = ADDRESS_VERSION;
	if (LOG.isTraceEnabled()) {
		LOG.info("toAddress data {}", ModelUtil.toHexString(data));
	}

	final byte[] dataAndChecksum = new byte[25];
	System.arraycopy(data, 0, dataAndChecksum, 4, data.length);

	ArrayUtils.reverse(data);
	final byte[] hash = SHA256HashUtil.getDoubleSHA256Hash(data);
	final byte[] hash4 = new byte[4];
	System.arraycopy(hash, 0, hash4, 0, 4);
	ArrayUtils.reverse(hash4);
	System.arraycopy(hash4, 0, dataAndChecksum, 0, 4);
	if (LOG.isTraceEnabled()) {
		LOG.info("toAddress dataAndChecksum {}", ModelUtil.toHexString(dataAndChecksum));
	}

	final String address = toBase58String(dataAndChecksum);
	return address;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:39,代码来源:ModelUtil.java

示例11: toReverseHexString

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * converts a byte array to a hex string in reverse byte order.
 *
 * @param bytes
 *            the array of bytes.
 * @return the string.
 */
public static String toReverseHexString(final byte... bytes) {
	final byte[] ba = new byte[bytes.length];
	System.arraycopy(bytes, 0, ba, 0, bytes.length);
	ArrayUtils.reverse(ba);
	final BigInteger bi = new BigInteger(1, ba);
	return bi.toString(16);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:15,代码来源:ModelUtil.java

示例12: toByteArray

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public byte[] toByteArray() {
	try {
		final ByteArrayOutputStream out = new ByteArrayOutputStream();
		final byte[] versionBa = version.getBytesCopy();
		ArrayUtils.reverse(versionBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version {}", Hex.encodeHexString(versionBa));
		}
		out.write(versionBa);
		final byte[] servicesBa = services.getBytesCopy();
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload services {}", Hex.encodeHexString(servicesBa));
		}
		ArrayUtils.reverse(servicesBa);
		out.write(servicesBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services {}", Hex.encodeHexString(out.toByteArray()));
		}
		final byte[] timestampBa = timestamp.getBytesCopy();
		ArrayUtils.reverse(timestampBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload timestamp {}", Hex.encodeHexString(timestampBa));
		}
		out.write(timestampBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp {}", Hex.encodeHexString(out.toByteArray()));
		}
		final byte[] portBa = port.getBytesCopy();
		ArrayUtils.reverse(portBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload port {}", Hex.encodeHexString(portBa));
		}
		out.write(portBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp+port {}", Hex.encodeHexString(out.toByteArray()));
		}
		final byte[] nonceBa = nonce.getBytesCopy();
		ArrayUtils.reverse(nonceBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload nonce {}", Hex.encodeHexString(nonceBa));
		}
		out.write(nonceBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp+port+nonce {}",
					Hex.encodeHexString(out.toByteArray()));
		}
		NetworkUtil.writeString(out, userAgent);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp+port+nonce+userAgent {}",
					Hex.encodeHexString(out.toByteArray()));
		}

		final byte[] startHeightBa = startHeight.getBytesCopy();
		ArrayUtils.reverse(startHeightBa);
		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp+port+nonce+userAgent+startHeight {}",
					Hex.encodeHexString(out.toByteArray()));
		}

		out.write(startHeightBa);

		if (relay) {
			out.write(new byte[] { 1 });
		} else {
			out.write(new byte[] { 0 });
		}

		if (LOG.isTraceEnabled()) {
			LOG.trace("versionPayload version+services+timestamp+port+nonce+userAgent+startHeight+relay {}",
					Hex.encodeHexString(out.toByteArray()));
		}

		return out.toByteArray();
	} catch (final IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:79,代码来源:VersionPayload.java

示例13: encode

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * encodes a Base58 byte array.
 *
 * @param input
 *            the byte array to use.
 * @return the encoded Base58 string.
 */
public static String encode(final byte[] input) {
	try {
		final byte[] revInput = new byte[input.length];
		System.arraycopy(input, 0, revInput, 0, input.length);
		ArrayUtils.reverse(revInput);

		BigInteger value = new BigInteger(1, revInput);
		final StringBuilder sb = new StringBuilder();
		if (LOG.isDebugEnabled()) {
			LOG.debug("[0]val58: {}", ModelUtil.toHexString(BIGINT_58.toByteArray()));
			LOG.debug("[0]value: {}", ModelUtil.toHexString(value.toByteArray()));
		}

		while (value.compareTo(BigInteger.ZERO) != 0) {
			final BigInteger[] valueDivAndRemainder = value.divideAndRemainder(BIGINT_58);
			final BigInteger valueDiv = valueDivAndRemainder[0];
			final BigInteger valueRemainder = valueDivAndRemainder[1];

			sb.append(ALPHABET.charAt(valueRemainder.intValue()));
			value = valueDiv;
			if (LOG.isDebugEnabled()) {
				LOG.debug("[1]value: {}", ModelUtil.toHexString(value.toByteArray()));
				LOG.debug("[1]value.compareTo(val58): {}", value.compareTo(BIGINT_58));
			}
		}

		if (LOG.isDebugEnabled()) {
			LOG.debug("[2]value: {}", ModelUtil.toHexString(value.toByteArray()));
		}

		for (int ix = 0; (ix < revInput.length) && (revInput[ix] == 0); ix++) {
			sb.append(ALPHABET.charAt(0));
		}

		sb.reverse();

		return sb.toString();
	} catch (final Exception e) {
		throw new RuntimeException("error encoding \"" + ModelUtil.toHexString(input) + "\"", e);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:49,代码来源:Base58Util.java

示例14: copyAndReverse

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * copies and reverses a byte array.
 *
 * @param input
 *            the byte array to copy and reverse.
 * @return a copy of the byte array, in reverse byte order.
 */
public static byte[] copyAndReverse(final byte[] input) {
	final byte[] revInput = new byte[input.length];
	System.arraycopy(input, 0, revInput, 0, input.length);
	ArrayUtils.reverse(revInput);
	return revInput;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:14,代码来源:ModelUtil.java

示例15: getFixedLengthByteArray

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * gets a fixed length byte array from the ByteBuffer.
 *
 * @param bb
 *            the ByteBuffer to read.
 * @param size
 *            the size of the byte array.
 * @param reverse
 *            if true, reverse the byte array.
 * @return the fixed length byte array.
 */
public static byte[] getFixedLengthByteArray(final ByteBuffer bb, final int size, final boolean reverse) {
	final byte[] ba = new byte[size];
	bb.get(ba);
	if (reverse) {
		ArrayUtils.reverse(ba);
	}
	return ba;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:20,代码来源:ModelUtil.java


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