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


Java ArrayUtils.reverse方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:63,代码来源:MethodsInvoker.java

示例2: reverse

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private static byte[] reverse(final byte[] ba) {
	ArrayUtils.reverse(ba);
	return ba;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:5,代码来源:ECPoint.java

示例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);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:61,代码来源:BlockDbH2Impl.java

示例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());
    }
}
 
开发者ID:whitefire,项目名称:roc-completion,代码行数:60,代码来源:SettingLookupElement.java

示例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);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:21,代码来源:NetworkUtil.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:HologramFrame.java

示例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);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:12,代码来源:AbstractByteArray.java

示例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);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:15,代码来源:NetworkUtil.java


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