本文整理匯總了Java中org.apache.commons.lang.ArrayUtils.reverse方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayUtils.reverse方法的具體用法?Java ArrayUtils.reverse怎麽用?Java ArrayUtils.reverse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils.reverse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invokeMethodsByAnnotation
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
* Called when using all project-specific annotations (OurBeforeGroups, OurAfterMethod, etc.)
* We decided to catch all kind of exceptions here because
* based on (https://groups.google.com/forum/#!topic/testng-users/0JhqmewMezM) we think that tests get skipped
* in case of failure in any before/after method
*
* @param context
* @param isBeforeAfterGroup
*/
protected void invokeMethodsByAnnotation(final TestClassContext context, boolean isBeforeAfterGroup) {
try {
//for invoke all public methods with @OurBefore... and @OurAfter... from super or this class
Method[] publicMethods = context.getTestClass().getMethods();
//for invoke private methods with @OurBefore... and @OurAfter... from this class
Method[] privateMethods = context.getTestClass().getDeclaredMethods();
//remove public methods of test class
List<Method> filteredMethods = Arrays.asList(publicMethods).stream()
.filter(name -> !name.getDeclaringClass().getName().contains(context.getTestClass().getName()))
.collect(Collectors.toList());
//paste all methods from test class to top of the list
for (int i = 0; i < privateMethods.length; i++) {
filteredMethods.add(i, privateMethods[i]);
}
Method[] allMethods = new Method[filteredMethods.size()];
filteredMethods.toArray(allMethods);
//reverse methods array for correct invoke order if TestClass extends SuperClass with @Before methods
if (context.getAnnotationToInvokeMethod().getName().contains("OurBefore")) {
ArrayUtils.reverse(allMethods);
}
for (Method method : allMethods) {
if (isMethodShouldBeInvoked(method, context)) {
AbstractTest testInstance = context.getTestInstance();
if (testInstance != null || (testInstance = createTestClassInstance(context.getTestClass())) != null) {
//hack for E4 project only (@LoginAs and @LoginTo) by default the method will do nothing until you override it
//and add some specific logic. For example handle your special annotations
testInstance.handleBeforeAfterAnnotations(method);
invokeMethod(testInstance, method, context, isBeforeAfterGroup);
}
}
}
} catch (StopTestExecutionException e) {
if (e.getCause() instanceof InvocationTargetException) {
Throwable targetException = ((InvocationTargetException) e.getCause()).getTargetException();
new Report("*****StopTestExecutionException*****" + context.getTestClass() + " " + targetException.getCause(), e).jenkins();
} else {
new Report("*****StopTestExecutionException*****" + context.getTestClass() + " " + e.getCause(), e).jenkins();
}
try {
context.getTestInstance().setStopTextExecutionThrowable(e);
} catch (NullPointerException ignored) {
}
} catch (Throwable t) {
new Report("*****Throwable*****" + context.getTestClass(), t).jenkins();
}
}
示例2: reverse
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
private static byte[] reverse(final byte[] ba) {
ArrayUtils.reverse(ba);
return ba;
}
示例3: doInTransactionWithoutResult
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
final JdbcTemplate t = new JdbcTemplate(ds);
for (final Block block : blocks) {
final byte[] prevHashBa = block.prevHash.toByteArray();
ArrayUtils.reverse(prevHashBa);
final String putBlockSql = getSql("putBlock");
final byte[] blockIndexBa = block.index.toByteArray();
t.update(putBlockSql, block.hash.toByteArray(), prevHashBa, blockIndexBa, block.toHeaderByteArray());
final String putTransactionSql = getSql("putTransaction");
final String putTransactionInputSql = getSql("putTransactionInput");
final String putTransactionOutputSql = getSql("putTransactionOutput");
final String putTransactionScriptSql = getSql("putTransactionScript");
int transactionIndex = 0;
final List<Object[]> putTransactionList = new ArrayList<>();
final List<Object[]> putTransactionInputList = new ArrayList<>();
final List<Object[]> putTransactionOutputList = new ArrayList<>();
final List<Object[]> putTransactionScriptList = new ArrayList<>();
for (final Transaction transaction : block.getTransactionList()) {
final byte[] txIxByte = new UInt16(transactionIndex).toByteArray();
final byte[] transactionBaseBa = transaction.toBaseByteArray();
add(putTransactionList, blockIndexBa, txIxByte, transaction.hash.toByteArray(), transactionBaseBa);
for (int inputIx = 0; inputIx < transaction.inputs.size(); inputIx++) {
final byte[] txInputIxByte = new UInt32(inputIx).toByteArray();
final CoinReference input = transaction.inputs.get(inputIx);
add(putTransactionInputList, blockIndexBa, txIxByte, txInputIxByte,
input.prevHash.toByteArray(), input.prevIndex.toByteArray());
}
for (int outputIx = 0; outputIx < transaction.outputs.size(); outputIx++) {
final byte[] txOutputIxByte = new UInt16(outputIx).toByteArray();
final TransactionOutput output = transaction.outputs.get(outputIx);
add(putTransactionOutputList, blockIndexBa, txIxByte, txOutputIxByte,
output.assetId.toByteArray(), output.value.toByteArray(),
output.scriptHash.toByteArray());
}
for (int scriptIx = 0; scriptIx < transaction.scripts.size(); scriptIx++) {
final byte[] txScriptIxByte = new UInt32(scriptIx).toByteArray();
final Witness script = transaction.scripts.get(scriptIx);
add(putTransactionScriptList, blockIndexBa, txIxByte, txScriptIxByte,
script.getCopyOfInvocationScript(), script.getCopyOfVerificationScript());
}
transactionIndex++;
}
t.batchUpdate(putTransactionSql, putTransactionList);
t.batchUpdate(putTransactionInputSql, putTransactionInputList);
t.batchUpdate(putTransactionOutputSql, putTransactionOutputList);
t.batchUpdate(putTransactionScriptSql, putTransactionScriptList);
}
}
示例4: handleInsert
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
@Override
public void handleInsert(InsertionContext context)
{
// Remove the text the user typed.
context
.getDocument()
.deleteString(context.getStartOffset(), context.getTailOffset());
context.commitDocument();
// Grab the deepest property available for insertion... hø hø hø!
JSProperty targetProperty = getTargetProperty(context.getFile());
// Generate the remaining jsNotation.
String quote = JSCodeStyleSettings.getQuote(targetProperty);
String jsNotation = setting.toRelativeJsNotation(targetProperty, quote);
// Create a new file to initiate all lexers, parsers grumpkins and snarks...
PsiFile psiContainer = PsiFileFactory
.getInstance(context.getProject())
.createFileFromText(targetProperty.getLanguage(), jsNotation);
JSExpression value = targetProperty.getValue();
if (value == null)
{
return;
}
PsiElement[] childrenForInsertion = psiContainer.getChildren();
// Insert in reverse order. Probably an easier way, but this works just fine...
ArrayUtils.reverse(childrenForInsertion);
// Grab all created elements in the temporary file and insert them into the document.
for (PsiElement completion : childrenForInsertion)
{
value.addAfter(completion, value.getFirstChild());
}
PsiElement formattedValue = CodeStyleManager
.getInstance(context.getProject())
.reformat(value);
value.replace(formattedValue);
List<LookupElement> subCompletions = setting.getSubCompletionVariants();
// User does not need to edit bools or enums with single value.
if (setting.getType().equals("Boolean") || subCompletions.size() == 1)
{
return;
}
context.commitDocument();
moveCursor(context);
if (subCompletions.size() > 1)
{
AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor());
}
}
示例5: write
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
* writes a ByteArraySerializable to an output stream.
*
* @param out
* the output stream to use.
* @param t
* the object to write.
* @param reversed
* if true, reverse the byte array before writing.
* @param <T>
* the ByteArraySerializable type.
*/
public static <T extends ByteArraySerializable> void write(final OutputStream out, final T t,
final boolean reversed) {
final byte[] ba = t.toByteArray();
if (reversed) {
ArrayUtils.reverse(ba);
}
write(out, ba);
}
示例6: HologramFrame
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
* Creates a new {@link HologramFrame} with the specified content.
*
* @param content The content to be displayed
*/
public HologramFrame(String... content) {
ArrayUtils.reverse(content);
this.content = Arrays.asList(content);
}
示例7: toReverseBytesPositiveBigInteger
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
* returns a positive BigInteger, in reverse byte order.
*
* @return this array as a BigInteger, assuming the bytes represent a signed int
* in reverse byte order.
*/
public final BigInteger toReverseBytesPositiveBigInteger() {
final byte[] reverseBytes = getBytesCopy();
ArrayUtils.reverse(reverseBytes);
return new BigInteger(1, reverseBytes);
}
示例8: writeShort
import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
* writes a short as a byte array to the output stream.
*
* @param out
* the output stream to use.
* @param x
* the short to write. (the short can be any integer even a long,
* only the lower bytes will be written).
*/
public static void writeShort(final OutputStream out, final long x) {
final byte[] ba = getShortByteArray(x);
ArrayUtils.reverse(ba);
write(out, ba);
}